@import url("style/book-style.css");
:root { --page-ratio: .8; color: var(--ink); background: #fff; font-family: var(--book-serif); font-synthesis: none; }
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; overscroll-behavior: none; }
body { overflow: hidden; background: #fff; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
button { color: inherit; font: inherit; }
.room { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; height: 100vh; height: 100dvh; padding: 22px 24px 20px; }
.book-header { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 20px; width: min(100%, 1100px); margin: auto; }
.book-header h1 { margin: 0; font: 400 16px/1.3 var(--book-serif); letter-spacing: -.01em; }
.book-header a, .book-header span { font: 400 10px/1.4 var(--book-sans); color: #6e7365; text-decoration: none; }
.book-header span:last-child { text-align: right; }
.stage { position: relative; display: grid; place-items: center; min-height: 0; padding: 16px 0; }
/* PageFlip derives leaf height from width. Reserve room for navigation. */
.book-rig { display: grid; place-items: center; width: min(100%, calc((100dvh - 140px) * var(--page-ratio) * 2), calc(640px * var(--page-ratio) * 2)); height: min(calc(100vh - 140px), 640px); height: min(calc(100dvh - 140px), 640px); }
.book { position: relative; isolation: isolate; filter: drop-shadow(0 9px 12px rgb(29 37 21 / 15%)); transition: translate 760ms ease; touch-action: none; -webkit-tap-highlight-color: transparent; }
.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 #dcdfd5; border-radius: 50%; width: 36px; height: 36px; padding: 0; background: #fff; font: 400 15px var(--book-sans); cursor: pointer; }
.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: #666e5d; }
.status small { font: 400 9px/1.4 var(--book-sans); color: #969b8f; }
a:focus-visible, button:focus-visible { outline: 2px solid #6b735d; outline-offset: 4px; }
@media (max-width: 700px) {
  .room { padding: 14px 10px 12px; }
  .book-header { grid-template-columns: 1fr auto; gap: 12px; }
  .book-header h1 { font-size: 13px; }
  .book-header #orientation { display: none; }
}
/* Phones: keep the two-up spread (same as desktop) but fit it to the screen width. */
@media (max-width: 600px) {
  .room { padding: 10px 8px 12px; }
  .book-header { grid-template-columns: 1fr auto; gap: 8px; }
  .book-header h1 { font-size: 12px; }
  .book-header #orientation { display: none; }
  .book-header > span:first-child { display: none; }
  .book-rig {
    width: min(100%, calc((100dvh - 150px) * var(--page-ratio) * 2), calc(640px * var(--page-ratio) * 2));
    height: min(calc(100dvh - 150px), 640px);
  }
  .controls { width: min(100%, 240px); }
  .controls button { width: 46px; height: 46px; font-size: 19px; }
  .status span { font-size: 11px; }
  .status small { font-size: 9px; }
}
/* Very short landscape phones: keep the book fully visible. */
@media (max-height: 480px) and (orientation: landscape) {
  .book-rig { height: min(calc(100dvh - 110px), 90dvh); }
}
@media (prefers-reduced-motion: reduce) { .book { transition: none; } }
@media print { body { overflow: visible; } .book-header, .controls { display: none; } }

/* Cover acts as a button: show a pointer and a "tap to open" hint. */
.book-page.cloth { cursor: pointer; }
.cover-hint {
  position: absolute;
  left: 0; right: 0; bottom: 10%;
  text-align: center;
  font: 400 1.7cqw/1 var(--book-sans);
  letter-spacing: .14em;
  color: rgba(255,255,255,.85);
  pointer-events: none;
  animation: hint-pulse 2.4s ease-in-out infinite;
}
@keyframes hint-pulse { 0%, 100% { opacity: .45; } 50% { opacity: .95; } }
@media (prefers-reduced-motion: reduce) { .cover-hint { animation: none; opacity: .8; } }
