/* Bigfoot's Book Nook */
:root {
  --ink: #2a1c12;
  --ink-soft: #5a4330;
  --paper: #f7ecd8;
  --paper-2: #efe0c4;
  --wood: #6b3f1f;
  --wood-deep: #3e2412;
  --wood-light: #b57a45;
  --gold: #e3b04b;
  --brass: #d4a017;
  --shadow: rgba(30, 18, 8, 0.45);
  --serif: "Fraunces", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: "Nunito", "Segoe UI", Tahoma, system-ui, sans-serif;
  --topbar: 58px;
  --focus: 0 0 0 3px #fff, 0 0 0 6px #c45c12;
}
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; height: 100dvh; background: #1a120c; color: var(--ink); }
body {
  font-family: var(--sans);
  min-height: 100%;
  min-height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}
button, input { font: inherit; }
button { cursor: pointer; }
img { max-width: 100%; height: auto; display: block; }
:focus-visible { outline: none; box-shadow: var(--focus); }

[data-season="spring"] { --sky-top:#8ecdee; --sky-bot:#e9f6c4; --hill:#4f9a4a; --hill-2:#3c7a40; --foliage:#3e8f3a; --foliage-2:#e889b3; --accent:#d45f8d; --ambient:#fff6d8; }
[data-season="summer"] { --sky-top:#4aa9e3; --sky-bot:#cfe89a; --hill:#3b8c36; --hill-2:#2c6d2c; --foliage:#2f7a2c; --foliage-2:#6db33a; --accent:#f0c02e; --ambient:#fff4b8; }
[data-season="fall"] { --sky-top:#f0a24a; --sky-bot:#f6d399; --hill:#7a8a34; --hill-2:#5c6a24; --foliage:#c44e10; --foliage-2:#d4861a; --accent:#c44500; --ambient:#ffd9a0; }
[data-season="halloween"] { --sky-top:#1b1036; --sky-bot:#c25416; --hill:#2a351c; --hill-2:#1a2212; --foliage:#5a3010; --foliage-2:#8a4a10; --accent:#ff7a18; --ambient:#ffb060; }
[data-season="thanksgiving"] { --sky-top:#e07a32; --sky-bot:#f2c888; --hill:#6a762e; --hill-2:#4e581e; --foliage:#b33a12; --foliage-2:#c86a16; --accent:#a8321c; --ambient:#ffcc88; }
[data-season="winter"] { --sky-top:#b9cce2; --sky-bot:#eef3f8; --hill:#d5e0ec; --hill-2:#b7c6d6; --foliage:#dfe7ef; --foliage-2:#c5d0dc; --accent:#5d7ea6; --ambient:#f4f8ff; }
[data-season="holiday"] { --sky-top:#15233f; --sky-bot:#7a3a32; --hill:#d8e3ef; --hill-2:#b9c7d6; --foliage:#1c5a30; --foliage-2:#2a7a42; --accent:#c9a227; --ambient:#ffd9a0; }

.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 14px; z-index: 40;
  background: linear-gradient(180deg, rgba(28,18,10,.88), rgba(28,18,10,.72));
  color: var(--paper); backdrop-filter: blur(6px);
  border-bottom: 1px solid rgba(227,176,75,.25);
}
.brand { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.brand h1 {
  font-family: var(--serif); font-size: 1.05rem; font-weight: 700;
  margin: 0; letter-spacing: .01em; white-space: nowrap;
}
.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; flex: none; }
.btn-watch-intro {
  font-size: .8rem; font-weight: 800; padding: 6px 14px; white-space: nowrap;
}
body:not([data-stage="outside"]) #btn-watch-intro,
body.walking #btn-watch-intro,
body.goodbye-on #btn-watch-intro { display: none; }
.home-link {
  color: var(--paper); text-decoration: none; font-size: .8rem; font-weight: 700;
  opacity: .88; white-space: nowrap; margin-left: 0;
}
.home-link:hover, .home-link:focus-visible { opacity: 1; color: var(--gold); }
.sample-tag {
  font-size: .68rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  background: rgba(227,176,75,.2); color: var(--gold); border: 1px solid rgba(227,176,75,.4);
  border-radius: 999px; padding: 2px 8px; white-space: nowrap;
}
.stage {
  position: fixed;
  top: var(--topbar); left: 0; right: 0; bottom: 0;
  display: none; overflow: hidden;
}
.stage.is-on { display: block; }
.stage.fade-out { opacity: 0; transition: opacity .7s ease; }
.stage.fade-in { animation: fadeIn .7s ease both; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ===== Outside / painted cottage ===== */
#stage-outside { background: #1a120c; }
.scene-wrap {
  position: absolute; inset: 0;
  transform-origin: 49.85% 60.7%;
}
body.walking .scene-wrap {
  animation: walkIn 1.8s cubic-bezier(.22,.7,.2,1) forwards;
}
@keyframes walkIn {
  0%   { transform: scale(1) translateY(0); filter: brightness(1); opacity: 1; }
  18%  { transform: scale(1.55) translateY(8px); filter: brightness(1.05); opacity: 1; }
  36%  { transform: scale(2.15) translateY(-5px); opacity: 1; }
  54%  { transform: scale(2.9) translateY(6px); filter: brightness(1.12); opacity: 1; }
  78%  { transform: scale(3.7) translateY(-3px); opacity: 1; }
  100% { transform: scale(4.3) translateY(0); filter: brightness(1.28); opacity: 0; }
}
.cottage-scene {
  position: absolute; inset: 0;
  overflow: hidden;
  background: #1a120c;
}
.exterior-bleed {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center 8%;
  filter: blur(16px) saturate(1.35) brightness(1.12);
  transform: scale(1.08);
  transform-origin: center top;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  z-index: 0;
}
.painting-stage {
  position: absolute;
  overflow: hidden;
  z-index: 1;
  perspective: 1200px;
  perspective-origin: 49.85% 60.7%;
}
.exterior-art {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: fill;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}
.door-well {
  position: absolute;
  left: 40.3%; top: 43.7%; width: 19.1%; height: 34%;
  border-radius: 50%;
  overflow: hidden;
  background: #100a05;
  box-shadow: inset 0 0 28px 8px rgba(0,0,0,.72);
  z-index: 2;
}
.door-room-peek {
  position: absolute;
  inset: -4%;
  width: 108%;
  height: 108%;
  max-width: none;
  object-fit: cover;
  object-position: 48% 46%;
  filter: brightness(0.95) saturate(0.96) contrast(0.92);
}
.door-well-glow {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 50% 36%, rgba(255,186,90,.16), transparent 52%),
    radial-gradient(ellipse at 50% 100%, rgba(0,0,0,.58), transparent 52%),
    linear-gradient(180deg, rgba(0,0,0,.32), rgba(20,8,0,.1) 42%, rgba(0,0,0,.52));
  pointer-events: none;
  box-shadow:
    inset 0 0 24px 6px rgba(0,0,0,.55),
    inset 0 -30px 34px rgba(0,0,0,.42);
}
#door-swing {
  position: absolute;
  left: 40.3%; top: 43.7%; width: 19.1%; height: 34%;
  border-radius: 50%;
  background-repeat: no-repeat;
  transform-origin: 0% 50%;
  transform-style: preserve-3d;
  transition: transform 1.4s cubic-bezier(.2,.7,.2,1);
  z-index: 3;
  pointer-events: none;
  box-shadow: none;
  backface-visibility: hidden;
}
body.door-open #door-swing {
  transform: rotateY(-78deg);
  box-shadow: 10px 6px 22px rgba(0,0,0,.5);
}
#door-btn {
  position: absolute;
  left: 39.2%; top: 41.8%; width: 21.3%; height: 38%;
  border-radius: 50%; border: 0; padding: 0;
  background: transparent; cursor: pointer;
  z-index: 5;
}
#bell-btn {
  position: absolute;
  left: 58.9%; top: 54%; width: 5%; height: 9%;
  border-radius: 50%; border: 0; padding: 0;
  background: transparent; cursor: pointer;
  z-index: 6;
}
#door-btn:hover, #door-btn:focus-visible {
  box-shadow: 0 0 0 3px rgba(255, 224, 154, .85);
}
body.door-open #door-btn,
body.walking #door-btn,
body.door-open #bell-btn,
body.walking #bell-btn {
  box-shadow: none !important;
  outline: none !important;
  background: transparent !important;
}
#bell-btn:hover, #bell-btn:focus-visible {
  box-shadow: 0 0 0 3px rgba(255, 224, 154, .95);
  background: rgba(255, 224, 154, .18);
}
.pip-window {
  /* Same oval as the painted left window, clipped to the inner glass
     so only Pip himself peeks up over the sill and back down. */
  position: absolute;
  left: 19.0%;
  top: 42.4%;
  width: 11.0%;
  height: 19.56%;
  border-radius: 50%;
  overflow: hidden;
  clip-path: ellipse(50% 50% at 50% 50%);
  isolation: isolate;
  z-index: 4;
  pointer-events: none;
}
#pip-peek {
  position: absolute;
  left: 50%;
  bottom: 4%;
  width: 100%;
  height: auto;
  max-width: none;
  display: block;
  transform: translate(-50%, 110%);
  transform-origin: 50% 100%;
  animation: pipPeekLoop 5.8s ease-in-out infinite;
}
@keyframes pipPeekLoop {
  0%, 12% { transform: translate(-50%, 110%); }
  30%, 48% { transform: translate(-50%, 38%); }
  66%, 100% { transform: translate(-50%, 110%); }
}
body.walking #pip-peek,
body[data-stage="room"] #pip-peek,
body[data-stage="shelf"] #pip-peek,
body[data-stage="player"] #pip-peek {
  animation: none;
  transform: translate(-50%, 112%);
}

.window-glow {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  z-index: 2;
  mix-blend-mode: screen;
  background: radial-gradient(circle, rgba(255,210,110,.55), rgba(255,160,50,.16) 55%, transparent 72%);
  animation: windowFlicker 2.8s ease-in-out infinite;
}
.left-window { left: 19.0%; top: 42.4%; width: 11.0%; height: 19.56%; }
.right-window { left: 67.5%; top: 42.6%; width: 10.8%; height: 19.2%; }
.lantern-glow {
  position: absolute;
  left: 32.4%; top: 46.2%; width: 5.2%; height: 9.4%;
  border-radius: 50%;
  pointer-events: none;
  z-index: 2;
  mix-blend-mode: screen;
  background: radial-gradient(circle, rgba(255,200,90,.7), rgba(255,150,40,.2) 50%, transparent 70%);
  animation: windowFlicker 2.2s ease-in-out infinite 0.4s;
}
@keyframes windowFlicker {
  0%, 100% { opacity: .72; }
  35% { opacity: 1; }
  58% { opacity: .78; }
  76% { opacity: .96; }
}
.breeze-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 6;
}

.hint {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  margin: 0; padding: 8px 14px; border-radius: 999px;
  background: rgba(42,28,18,.72); color: var(--paper);
  font-size: .95rem; font-weight: 700; letter-spacing: .01em;
  pointer-events: none; text-align: center; max-width: calc(100% - 24px);
  box-shadow: 0 6px 18px var(--shadow);
  z-index: 7;
}
body.door-open .hint, body.walking .hint, body.goodbye-on .hint { opacity: 0; }

.weather { display: none; }
.flake, .leaf-fall {
  position: absolute; top: -10%; color: #fff; opacity: .85;
  animation: fall linear infinite;
  font-size: 14px;
}
@keyframes fall {
  to { transform: translate3d(20px, 120vh, 0) rotate(240deg); }
}
[data-season="spring"] .weather,
[data-season="summer"] .weather,
[data-season="thanksgiving"] .weather { display: none; }

.goodbye {
  position: absolute; inset: 0; display: none;
  align-items: center; justify-content: center;
  background: rgba(20,12,8,.35);
  z-index: 5;
}
body.goodbye-on .goodbye { display: flex; }
.goodbye-card {
  background: var(--paper); color: var(--ink);
  border-radius: 22px; padding: 32px 28px 28px;
  text-align: center; max-width: 420px; width: calc(100% - 32px);
  box-shadow: 0 20px 50px var(--shadow);
  animation: fadeIn .45s ease;
}
.goodbye-card h2 { font-family: var(--serif); font-size: 2rem; margin: 0 0 8px; }
.goodbye-card p { margin: 0 0 22px; color: var(--ink-soft); }

.btn {
  appearance: none; border: 0; border-radius: 999px;
  background: var(--wood); color: var(--paper);
  font-weight: 800; padding: 12px 22px;
  box-shadow: 0 3px 0 var(--wood-deep);
  transition: transform .12s ease, filter .12s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(2px); box-shadow: none; }
.btn.gold { background: #8a5a18; box-shadow: 0 3px 0 #5c3a0c; color: #fff8e6; }
.btn.ghost {
  background: transparent; color: var(--ink); box-shadow: none;
  border: 2px solid rgba(42,28,18,.25);
}

/* ===== Room ===== */
#stage-room { background: #1a120c; }
.room-art {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: center 40%;
}
.welcome {
  position: absolute; left: 50%;
  bottom: max(96px, calc(env(safe-area-inset-bottom, 0px) + 88px));
  transform: translateX(-50%);
  width: min(460px, calc(100% - 28px));
  background: rgba(247,236,216,.95);
  border-radius: 18px; padding: 14px 18px 14px;
  box-shadow: 0 16px 40px var(--shadow);
  text-align: center;
  opacity: 0;
  z-index: 8;
}
#stage-room.is-on .welcome {
  animation: welcomeIn 1.1s ease both;
  animation-delay: 0.35s;
}
@keyframes welcomeIn {
  from { opacity: 0; transform: translateX(-50%) translateY(14px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.welcome h2 { font-family: var(--serif); margin: 0 0 4px; font-size: 1.45rem; }
.welcome p { margin: 0; color: var(--ink-soft); line-height: 1.4; font-size: .95rem; }

/* Fixed to the real viewport so iPhone Safari chrome cannot hide it.
   Lives as a direct child of body — no transformed ancestor. */
#btn-see-books.bookshelf-launch {
  position: fixed;
  left: 50%;
  bottom: max(18px, calc(env(safe-area-inset-bottom, 0px) + 12px));
  transform: translateX(-50%);
  z-index: 60;
  display: none;
  font-size: 1.12rem;
  font-weight: 800;
  letter-spacing: .01em;
  padding: 16px 32px;
  min-width: min(280px, calc(100vw - 32px));
  background: #b06a14;
  color: #fff8e6;
  box-shadow: 0 4px 0 #5c3a0c, 0 12px 28px rgba(30,18,8,.5);
}
body[data-stage="room"] #btn-see-books.bookshelf-launch {
  display: inline-block;
  animation: launchIn .45s ease both;
}
@keyframes launchIn {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
#btn-see-books.bookshelf-launch:hover { filter: brightness(1.1); }
#btn-see-books.bookshelf-launch:focus-visible {
  box-shadow: var(--focus), 0 4px 0 #5c3a0c, 0 12px 28px rgba(30,18,8,.5);
}

/* ===== Bookshelf ===== */
#stage-shelf {
  background:
    radial-gradient(1200px 500px at 50% 0%, rgba(255,220,150,.15), transparent 60%),
    linear-gradient(180deg, #3a2414, #1e120a);
}
.shelf-frame {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  padding: 16px 16px 18px;
}
.shelf-top {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  justify-content: space-between; color: var(--paper); margin-bottom: 10px;
}
.shelf-top h2 { font-family: var(--serif); margin: 0; font-size: 1.45rem; }
.shelf-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.shelf-tools input[type="search"] {
  border: 1px solid rgba(247,236,216,.3); background: rgba(0,0,0,.25);
  color: var(--paper); border-radius: 999px; padding: 8px 14px; min-width: 180px;
}
.shelf-tools input::placeholder { color: rgba(247,236,216,.6); }
.toggle {
  border: 1px solid rgba(247,236,216,.35); background: transparent; color: var(--paper);
  border-radius: 999px; padding: 7px 12px; font-weight: 800; font-size: .85rem;
}
.toggle[aria-pressed="true"] { background: var(--paper); color: var(--ink); }
.shelf-nav { display: flex; gap: 6px; }
.shelf-nav button {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid rgba(247,236,216,.35);
  background: rgba(0,0,0,.25); color: var(--paper); font-size: 1.1rem; font-weight: 800;
}
.shelf-nav button:disabled { opacity: .35; cursor: default; }

.case {
  flex: 1; min-height: 0; overflow: auto;
  background:
    repeating-linear-gradient(90deg, #4a2a12 0 8px, #5c3618 8px 16px);
  border: 10px solid #4a2a12;
  border-radius: 10px 10px 14px 14px;
  box-shadow: inset 0 20px 40px rgba(0,0,0,.35), 0 8px 0 #2a160a;
  padding: 16px 14px 20px;
}
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  column-gap: 16px;
  row-gap: 32px;
  align-items: start;
  align-content: start;
}
.book {
  appearance: none; border: 0; background: transparent; padding: 0 0 4px;
  color: inherit; text-align: center; position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: 100%;
  height: auto;
  overflow: visible;
  min-height: 0;
}
.book .cover-wrap {
  position: relative; border-radius: 3px 6px 6px 3px;
  box-shadow: 4px 6px 12px rgba(0,0,0,.45);
  overflow: hidden; background: #222;
  aspect-ratio: 1 / 1;
  width: 100%;
  flex: 0 0 auto;
}
.book img { width: 100%; height: 100%; object-fit: cover; }
.book figcaption, .book .title {
  display: block;
  margin-top: 10px;
  font-size: .78rem;
  font-weight: 800;
  color: #f3e6cc;
  line-height: 1.3;
  min-height: 3.2em;
  position: relative;
  z-index: 1;
}
.book:hover .cover-wrap, .book:focus-visible .cover-wrap { transform: translateY(-4px); }
.cover-wrap { transition: transform .18s ease; }
.ribbon {
  position: absolute; top: 10px; right: -24px; width: 96px;
  background: #8a1e16; color: #fff4e0; font-size: .58rem; font-weight: 800;
  letter-spacing: .04em; text-transform: uppercase; text-align: center;
  padding: 3px 0; transform: rotate(35deg);
  box-shadow: 0 2px 6px rgba(0,0,0,.35);
}
.empty-shelf {
  color: #f3e6cc; text-align: center; padding: 40px 16px; font-size: 1.05rem;
}

.shelf-foot {
  display: flex; justify-content: space-between; align-items: flex-end;
  gap: 12px; margin-top: 12px; color: var(--paper);
}
.stone-sign {
  appearance: none; border: 0; background: transparent; padding: 0; color: inherit;
  display: flex; align-items: center; gap: 10px; text-align: left;
}
.stone-sign svg { width: 86px; height: 64px; display: block; filter: drop-shadow(2px 4px 6px rgba(0,0,0,.4)); }
.stone-sign:hover { filter: brightness(1.08); }
.stone-caption { font-size: .8rem; font-weight: 700; max-width: 160px; line-height: 1.3; opacity: .95; }

/* ===== Overlays / player / store ===== */
.overlay {
  position: fixed; inset: 0; background: rgba(16,10,6,.62);
  display: none; align-items: center; justify-content: center;
  z-index: 50; padding: 18px;
}
.overlay.is-on { display: flex; }
.modal {
  background: var(--paper);
  border-radius: 18px; width: min(760px, 100%);
  max-height: calc(100vh - 36px); overflow: auto;
  box-shadow: 0 24px 60px var(--shadow);
  position: relative;
}
.player {
  background:
    linear-gradient(180deg, #4a2e18, #2b1a0e);
  color: var(--paper);
  padding: 18px 18px 20px;
  border: 10px solid #c4a36a;
  box-shadow: inset 0 0 0 3px #6a4a22, 0 24px 60px var(--shadow);
}
.player-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.player-head h2 { font-family: var(--serif); margin: 0; font-size: 1.5rem; }
.player-head .by { margin: 4px 0 0; opacity: .8; font-size: .9rem; }
.icon-x {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid rgba(247,236,216,.35);
  background: rgba(0,0,0,.25); color: var(--paper); font-size: 1.2rem; flex: none;
}
.player-body { display: grid; grid-template-columns: 180px 1fr; gap: 18px; margin-top: 16px; }
.player-body .cover { border-radius: 6px; box-shadow: 0 8px 18px rgba(0,0,0,.45); width: 100%; }
.screen {
  background: #120c08; border-radius: 10px; min-height: 180px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 20px; border: 2px solid #5a3e20;
}
.screen p { margin: 0; font-size: 1.05rem; line-height: 1.45; max-width: 28em; }
.screen .sub { margin-top: 8px; opacity: .75; font-size: .9rem; }
.player-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }

.intro-modal { width: min(920px, 100%); padding: 16px 16px 18px; }
.intro-video { max-height: min(70vh, 620px); margin-top: 12px; background: #000; }
.player-video {
  display: block;
  width: 100%;
  max-height: min(56vh, 520px);
  border-radius: 8px;
  background: #000;
}
.screen.is-playing {
  padding: 0;
  overflow: hidden;
  min-height: 0;
  background: #000;
  border-color: #3a2814;
}
.screen.is-playing #player-msg,
.screen.is-playing #player-sub { display: none; }
.player-body.is-watching { grid-template-columns: 1fr; }
.player-body.is-watching .cover { display: none; }
.modal.player.is-watching { width: min(920px, 100%); }


.modal.paper { padding: 24px 22px 22px; color: var(--ink); }
.modal.paper h2 { font-family: var(--serif); margin: 0 0 8px; }
.modal.paper p { margin: 0 0 12px; color: var(--ink-soft); line-height: 1.5; }
.modal.paper .icon-x { position: absolute; top: 10px; right: 10px; color: var(--ink); background: rgba(0,0,0,.06); border-color: rgba(0,0,0,.1); }

.store-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.store-list li {
  display: flex; align-items: center; gap: 12px;
  background: #efe0c4; border-radius: 12px; padding: 8px 10px;
}
.store-list img { width: 52px; height: 52px; object-fit: cover; border-radius: 4px; flex: none; }
.store-list .meta { flex: 1; min-width: 0; }
.store-list .meta strong { display: block; font-size: .95rem; }
.store-list .meta span { font-size: .78rem; color: var(--ink-soft); }
.btn.amazon { background: #355c3a; box-shadow: 0 3px 0 #1e3822; }
.btn[disabled], .btn:disabled {
  background: #8a8070; box-shadow: none; color: #f3ece0; cursor: default; opacity: .85;
}

@media (max-width: 700px) {
  :root { --topbar: 92px; }
  .topbar { height: auto; min-height: 58px; flex-wrap: wrap; padding: 8px 10px 6px; }
  .brand h1 { font-size: .95rem; }
  .player-body { grid-template-columns: 1fr; }
  .player-body .cover { width: 140px; margin: 0 auto; }
  .book-grid {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    column-gap: 14px;
    row-gap: 28px;
  }
  .book .title { min-height: 3.6em; }
  .shelf-tools input[type="search"] { min-width: 120px; flex: 1; }
  .welcome {
    bottom: max(88px, calc(env(safe-area-inset-bottom, 0px) + 80px));
    width: min(100% - 20px, 420px);
    padding: 10px 12px 10px;
  }
  .welcome h2 { font-size: 1.2rem; }
  .welcome p { display: none; }
  #btn-see-books.bookshelf-launch {
    font-size: 1.08rem;
    padding: 15px 22px;
    width: calc(100vw - 32px);
    max-width: 320px;
  }
}

/* ===== Self-paced book reader ===== */
#btn-read-book[hidden] { display: none !important; }
.book .read-chip {
  margin-top: 8px;
  appearance: none; border: 0;
  background: #b06a14; color: #fff8e6;
  font-weight: 800; font-size: .72rem;
  letter-spacing: .02em;
  border-radius: 999px;
  padding: 7px 10px;
  box-shadow: 0 2px 0 #5c3a0c;
}
.book .read-chip:hover { filter: brightness(1.08); }
.book .book-face {
  appearance: none; border: 0; background: transparent; padding: 0;
  color: inherit; text-align: center; cursor: pointer;
  display: flex; flex-direction: column; align-items: stretch; width: 100%;
}
.book .book-face:hover .cover-wrap,
.book .book-face:focus-visible .cover-wrap { transform: translateY(-4px); }

#reader-overlay { background: rgba(16, 10, 6, .88); padding: 0; align-items: stretch; }
.reader {
  display: flex; flex-direction: column;
  width: 100%; height: 100%;
  overflow: hidden;
  background:
    radial-gradient(900px 400px at 50% 0%, rgba(255,210,140,.12), transparent 55%),
    linear-gradient(180deg, #3a2414, #1a100a);
  color: var(--paper);
  padding: 10px 12px 12px;
}
.reader-bar {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap;
  padding: 4px 4px 10px;
}
.reader-bar h2 {
  font-family: var(--serif); font-size: 1.15rem; margin: 0;
  flex: 1; min-width: 140px; text-align: center;
}
.reader-folio {
  font-weight: 800; font-size: .9rem; opacity: .9;
  min-width: 9em; text-align: right;
}
.reader-back { color: var(--paper) !important; border-color: rgba(247,236,216,.35) !important; }
.reader-stage {
  flex: 1; min-height: 0;
  display: flex; align-items: stretch;
  position: relative;
}
/* 3D page-flip book — always animates, including reduced motion */
.flip-book {
  flex: 1; min-width: 0; min-height: 0;
  position: relative;
  display: flex; align-items: stretch; justify-content: center;
  background:
    linear-gradient(90deg, #23160e, #3a2416 10%, #3a2416 90%, #23160e);
  border-radius: 8px;
  box-shadow: inset 0 0 0 2px rgba(90, 58, 28, .7), 0 16px 40px rgba(0,0,0,.45);
  overflow: visible;
  perspective: 2400px;
  perspective-origin: 50% 50%;
  transform-style: preserve-3d;
  padding: 12px 16px;
}
.flip-book.single { background: #2a1a10; padding: 10px 12px; }
.flip-book.cover { padding: 12px 16px; }
.flip-page {
  position: relative;
  z-index: 1;
  width: 50%;
  min-width: 0;
  display: flex; align-items: center; justify-content: center;
  background: #f3e6cc;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0,0,0,.28);
}
.flip-page.left { border-radius: 4px 0 0 4px; }
.flip-page.right { border-radius: 0 4px 4px 0; }
.flip-page img {
  max-width: 100%; max-height: 100%;
  width: auto; height: auto;
  object-fit: contain;
  display: block;
}
.flip-page.empty {
  background:
    linear-gradient(90deg, #c9b48a, #e6d4b0 40%, #d8c49a);
}
.flip-page.empty img { visibility: hidden; height: 0; }
.flip-book.single .flip-page.left { display: none; }
.flip-book.single .flip-page.right {
  width: auto;
  max-width: min(100%, 72vh);
  margin: 0 auto;
  border-radius: 4px;
  background: transparent;
  box-shadow: none;
}
/* Cover sits on the right of the spine, like a real book, so the first flip stays lined up */
.flip-book:not(.single)::after {
  content: "";
  position: absolute;
  left: 50%; top: 12px; bottom: 12px;
  width: 28px;
  transform: translateX(-50%);
  background: linear-gradient(90deg,
    rgba(0,0,0,.22) 0%,
    rgba(0,0,0,.04) 42%,
    rgba(255,255,255,.16) 50%,
    rgba(0,0,0,.05) 58%,
    rgba(0,0,0,.25) 100%);
  pointer-events: none;
  z-index: 6;
}
.flip-leaf {
  position: absolute;
  top: 12px; bottom: 12px;
  width: calc(50% - 16px);
  transform-style: preserve-3d;
  z-index: 8;
  pointer-events: none;
  visibility: hidden;
}
.flip-book.single .flip-leaf,
.flip-book.cover .flip-leaf {
  top: 10px; bottom: 10px;
  width: auto;
  height: auto;
}
.flip-leaf.is-next { left: 50%; transform-origin: 0% 50%; }
.flip-leaf.is-prev { right: 50%; left: auto; transform-origin: 100% 50%; }
.flip-book.single .flip-leaf.is-next,
.flip-book.cover .flip-leaf.is-next {
  left: 50%;
  transform: translateX(-50%);
  transform-origin: 0% 50%;
}
.flip-book.single .flip-leaf.is-prev,
.flip-book.cover .flip-leaf.is-prev {
  left: 50%;
  right: auto;
  transform: translateX(-50%);
  transform-origin: 100% 50%;
}
.leaf-face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex; align-items: center; justify-content: center;
  background: #f3e6cc;
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(0,0,0,.35);
}
.leaf-front { transform: rotateY(0deg); }
.leaf-back { transform: rotateY(180deg); }
.leaf-face img {
  max-width: 100%; max-height: 100%;
  width: auto; height: auto;
  object-fit: contain;
  display: block;
}
.leaf-shade {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 3;
  backface-visibility: hidden;
  background: linear-gradient(90deg, rgba(0,0,0,.28), rgba(0,0,0,0) 18%, rgba(0,0,0,0) 82%, rgba(0,0,0,.2));
  opacity: 0;
}
.flip-leaf.flipping-next,
.flip-leaf.flipping-prev { visibility: visible; }
.flip-leaf.flipping-next {
  animation: flipLeafNext .72s cubic-bezier(.2,.75,.2,1) forwards;
}
.flip-leaf.flipping-prev {
  animation: flipLeafPrev .72s cubic-bezier(.2,.75,.2,1) forwards;
}
.flip-leaf.flipping-next .leaf-shade,
.flip-leaf.flipping-prev .leaf-shade {
  animation: flipShade .72s ease-in-out forwards;
}
@keyframes flipLeafNext {
  0%   { transform: rotateY(0deg); }
  100% { transform: rotateY(-180deg); }
}
@keyframes flipLeafPrev {
  0%   { transform: rotateY(0deg); }
  100% { transform: rotateY(180deg); }
}
@keyframes flipShade {
  0%   { opacity: .15; }
  45%  { opacity: .85; }
  100% { opacity: .1; }
}
/* Never disable the page-flip, even when the device asks to reduce motion */
.reader-hint {
  margin: 8px 0 0; text-align: center; font-size: .85rem;
  opacity: .8; font-weight: 700;
}

@media (max-width: 700px) {
  .reader { padding: 6px 4px 8px; }
  .reader-bar { padding: 2px 6px 6px; gap: 8px; }
  .reader-bar h2 { font-size: 1rem; text-align: left; flex-basis: 100%; order: -1; }
  .reader-folio { text-align: left; min-width: 0; }
  .flip-book { padding: 6px; }
  .flip-book.single .flip-page.right,
  .flip-book.cover .flip-page.right {
    max-width: 100%;
  }
  .flip-leaf { top: 6px; bottom: 6px; }
  .reader-edge { width: 44px; font-size: 1.8rem; }
  .reader-hint { font-size: .72rem; margin-top: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  /* Only the ambient breeze/flicker is optional. The door swing,
     walk-through, and Pip's window peek must always play, including
     when the device asks to reduce motion. */
  .window-glow, .lantern-glow, .breeze-canvas { animation: none; display: none; }
  .welcome {
    animation: none !important;
    opacity: 1;
    transform: translateX(-50%);
  }
  #btn-see-books.bookshelf-launch {
    animation: none !important;
    opacity: 1;
    transform: translateX(-50%);
  }
}


/* Printable Your Turn activity page */
.activity-modal #activity-copy { margin: 0 0 12px; }
#activity-preview {
  display: block;
  width: min(420px, 100%);
  height: auto;
  margin: 8px auto 16px;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0,0,0,.18);
  background: #fff;
}
#activity-preview[hidden] { display: none; }
.activity-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.activity-actions a.btn { text-decoration: none; }
