@import url("style/book-style.css");
:root { --page-ratio: .8; color: var(--ink); background: var(--room); font-family: var(--book-serif); font-synthesis: none; }
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { overflow: hidden; background: var(--room); }
button { color: inherit; font: inherit; }
.room { --chrome: 104px; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100dvh; padding: 14px 18px 12px; }
.book-header { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 20px; width: 100%; margin: auto; }
.book-header h1 { margin: 0; font: 400 16px/1.3 var(--book-serif); letter-spacing: -.01em; color: #e7e4d9; }
.book-header a, .book-header span { font: 400 10px/1.4 var(--book-sans); color: #8a8f83; text-decoration: none; }
.book-header span:last-child { text-align: right; }
.stage { position: relative; display: grid; place-items: center; min-height: 0; padding: 6px 0; }
/* PageFlip derives leaf height from width, so the rig is sized to the larger of
   the two viewport constraints and the book fills whatever screen it is given. */
.book-rig { display: grid; place-items: center; width: min(100%, calc((100dvh - var(--chrome)) * var(--page-ratio) * 2)); height: min(calc(100dvh - var(--chrome)), calc(50vw / var(--page-ratio))); }
.book { position: relative; isolation: isolate; filter: drop-shadow(0 16px 34px rgb(0 0 0 / 62%)); transition: translate 760ms ease; }
.book[data-layout="landscape"][data-edge="front"] { translate: -25% 0; }
.book[data-layout="landscape"][data-edge="back"] { translate: 25% 0; }
.book-page { position: relative; overflow: hidden; background: var(--paper); }
.book-page.--left::before, .book-page.--right::before { position: absolute; inset-block: 0; z-index: 3; width: clamp(14px, 4%, 28px); content: ""; pointer-events: none; }
.book-page.--left::before { right: 0; background: linear-gradient(to left, rgb(28 30 24 / 12%), rgb(28 30 24 / 3%) 40%, transparent); }
.book-page.--right::before { left: 0; background: linear-gradient(to right, rgb(28 30 24 / 12%), rgb(28 30 24 / 3%) 40%, transparent); }
.controls { display: grid; grid-template-columns: 38px 1fr 38px; align-items: center; gap: 20px; width: min(100%, 280px); margin: auto; }
.controls button { border: 1px solid #2f332c; border-radius: 50%; width: 36px; height: 36px; padding: 0; background: #161814; color: #ddd9cd; font: 400 15px var(--book-sans); cursor: pointer; }
.controls button:hover:not(:disabled) { border-color: #4a5045; background: #1e211b; }
.controls button:disabled { opacity: .28; cursor: default; }
.status { display: grid; gap: 4px; text-align: center; }
.status span { font: 400 10px/1.4 var(--book-sans); letter-spacing: .04em; color: #9aa093; }
.status small { font: 400 9px/1.4 var(--book-sans); color: #6d7268; }
a:focus-visible, button:focus-visible { outline: 2px solid #9aa093; outline-offset: 4px; }
.book { min-width: 0 !important; min-height: 0 !important; touch-action: pan-y pinch-zoom; -webkit-tap-highlight-color: transparent; }
@media (max-width: 700px) {
  .room { --chrome: 132px; padding: max(12px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left)); }
  .book-header { grid-template-columns: auto minmax(0, 1fr); gap: 12px; }
  .book-header h1 { overflow: hidden; font-size: 15px; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
  .book-header a { display: inline-flex; align-items: center; min-height: 44px; font-size: 13px; }
  .book-header #orientation { display: none; }
  .controls { grid-template-columns: 46px 1fr 46px; gap: 12px; width: min(100%, 340px); }
  .controls button { width: 44px; height: 44px; font-size: 18px; }
  .status span { font-size: 13px; }
  .status small { font-size: 11px; }
}
/* Phone landscape: little vertical room, so slim the header and controls. */
@media (max-height: 500px) and (orientation: landscape) {
  .room { --chrome: 96px; padding: 6px max(12px, env(safe-area-inset-right)) 6px max(12px, env(safe-area-inset-left)); }
  .book-header a { min-height: 32px; }
  .stage { padding: 2px 0; }
  .status small { display: none; }
}
/* Below this envelope PageFlip shows one leaf, so the rig is sized for one leaf.
   The thresholds mirror the point where a spread would fall under its minimum. */
@media (max-width: 909px), (max-height: 711px) {
  .book-rig { width: min(100%, calc((100dvh - var(--chrome)) * var(--page-ratio))); height: min(calc(100dvh - var(--chrome)), calc(100vw / var(--page-ratio))); }
}
@media (prefers-reduced-motion: reduce) { .book { transition: none; } }
@media print { body { overflow: visible; } .book-header, .controls { display: none; } }
