:root{
  --ink: #14110d;
  --paper: #f4ecdd;
  --accent: #c9a24b;
  --serif: "Iowan Old Style", "Palatino Linotype", "Palatino", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
*{ box-sizing: border-box; margin: 0; padding: 0; }
html, body{ height: 100%; }
body{
  background: var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;                 /* the player hijacks scroll */
}

/* ---------- stage ---------- */
#stage{ position: fixed; inset: 0; overflow: hidden; touch-action: none; }
.clip{
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover; background: var(--ink);
  opacity: 0; transition: opacity .05s linear;
}
.clip.active{ opacity: 1; }

#vignette{
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(130% 100% at 50% 45%, transparent 45%, rgba(8,6,4,.5) 100%),
    linear-gradient(to bottom, rgba(8,6,4,.30), transparent 22%, transparent 74%, rgba(8,6,4,.5));
}
#white{
  position: absolute; inset: 0; pointer-events: none;
  background: #fff; opacity: 0;
}

/* ---------- captions ---------- */
#captions{ position: absolute; inset: 0; }
.cap{
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center; padding: 10vh 8vw;
  opacity: 0; pointer-events: none;
  transition: opacity .7s ease, transform .7s ease;
  transform: translateY(14px);
  /* localized halo so text stays readable over any frame */
  background: radial-gradient(58% 44% at 50% 50%, rgba(8,6,4,.6), transparent 72%);
}
.cap.show{ opacity: 1; transform: translateY(0); }
.cap a, .cap button, .cap .cta{ pointer-events: auto; }

.kicker{
  text-transform: uppercase; letter-spacing: .34em;
  font-size: clamp(.62rem, 1.5vw, .8rem); font-weight: 600;
  color: var(--accent); margin-bottom: 1.4rem;
  text-shadow: 0 1px 12px rgba(0,0,0,.8);
}
.title{
  font-family: var(--serif); font-weight: 600; line-height: .95;
  font-size: clamp(3rem, 11vw, 9rem);
  text-shadow: 0 2px 40px rgba(0,0,0,.7), 0 0 16px rgba(0,0,0,.45);
}
.subtitle{
  font-family: var(--serif); font-style: italic;
  font-size: clamp(1.1rem, 3.4vw, 2rem); opacity: .85; margin-top: .6rem;
  text-shadow: 0 2px 20px rgba(0,0,0,.7);
}
.line{
  font-family: var(--serif); font-weight: 500; line-height: 1.28;
  font-size: clamp(1.5rem, 4.4vw, 3.1rem); max-width: 17ch;
  text-shadow: 0 2px 24px rgba(0,0,0,.85), 0 0 10px rgba(0,0,0,.6);
}
.line.accent{ color: #fff; }
.wordline{
  font-family: var(--serif); font-weight: 600; line-height: 1.5;
  font-size: clamp(1.5rem, 5vw, 3.4rem); max-width: 20ch;
  text-shadow: 0 2px 24px rgba(0,0,0,.85), 0 0 10px rgba(0,0,0,.6);
}
/* words stagger in when the themes caption shows */
.words.show .wordline span{ animation: wordIn .5s ease both; }
.wordline span{ display: inline-block; margin: 0 .28em; opacity: 0; }
.words.show .wordline span:nth-child(1){ animation-delay:.05s }
.words.show .wordline span:nth-child(2){ animation-delay:.20s }
.words.show .wordline span:nth-child(3){ animation-delay:.35s }
.words.show .wordline span:nth-child(4){ animation-delay:.50s }
.words.show .wordline span:nth-child(5){ animation-delay:.65s }
.words.show .wordline span:nth-child(6){ animation-delay:.80s }
.words.show .wordline span:nth-child(7){ animation-delay:.95s }
.words.show .wordline span:nth-child(8){ animation-delay:1.10s }
@keyframes wordIn{ from{ opacity:0; transform:translateY(.4em) } to{ opacity:1; transform:translateY(0) } }

/* ---------- outro caption ---------- */
.cap--outro{ background: radial-gradient(75% 60% at 50% 50%, rgba(8,6,4,.82), rgba(8,6,4,.5) 90%); }
.dim{ opacity:.55; font-style: italic; }
.outro-blurb{
  font-family: var(--serif); font-size: clamp(1.05rem, 2.4vw, 1.35rem);
  line-height: 1.7; color: #ece2cd; max-width: 40rem; margin: 1.6rem 0 0;
  text-shadow: 0 2px 16px rgba(0,0,0,.7);
}
.cta-row{ margin-top: 2.6rem; display: flex; gap: 1.6rem; align-items: center; flex-wrap: wrap; justify-content: center; }
.cta{
  font-family: var(--sans); font-weight: 600; color: var(--ink);
  background: var(--accent); padding: .95rem 1.8rem; border-radius: 999px;
  text-decoration: none; transition: transform .2s ease, background .2s ease;
}
.cta:hover{ transform: translateY(-2px); background: #d8b45a; }
.socials{ display: flex; gap: 1.15rem; align-items: center; }
.socials a{ color: var(--paper); opacity: .55; transition: opacity .2s, transform .2s; display: inline-flex; }
.socials a:hover{ opacity: 1; transform: translateY(-2px); color: var(--accent); }
.socials svg{ width: 22px; height: 22px; fill: currentColor; display: block; }

/* ---------- progress dots ---------- */
#dots{
  position: absolute; right: 26px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; gap: 12px; z-index: 20;
}
#dots button{
  width: 9px; height: 9px; border-radius: 50%; border: 0; padding: 0;
  background: rgba(244,236,221,.28); cursor: pointer;
  transition: transform .25s ease, background .25s ease;
}
#dots button:hover{ background: rgba(244,236,221,.6); }
#dots button.on{ background: var(--accent); transform: scale(1.5); }

/* ---------- scroll cue ---------- */
.cue{
  position: absolute; bottom: 13vh; left: 50%; transform: translateX(-50%);
  font-size: .7rem; letter-spacing: .28em; text-transform: uppercase; opacity: .7;
  display: flex; flex-direction: column; align-items: center; gap: .7rem;
  transition: opacity .5s ease; z-index: 20;
}
.cue.hide{ opacity: 0; pointer-events: none; }
.cue span{ width: 1px; height: 44px; background: linear-gradient(var(--paper), transparent); animation: drop 1.8s ease-in-out infinite; }
@keyframes drop{
  0%{ transform: scaleY(0); transform-origin: top; opacity: 0; }
  40%{ transform: scaleY(1); opacity: 1; }
  100%{ transform: scaleY(1); transform-origin: bottom; opacity: 0; }
}
.a11y-hint{ position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- persistent buy-the-book bar ---------- */
#buybar{
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  z-index: 45;
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px 10px 10px;
  background: rgba(18,15,11,.74); backdrop-filter: blur(10px);
  border: 1px solid rgba(201,162,75,.4); border-radius: 14px;
  text-decoration: none; color: var(--paper);
  box-shadow: 0 10px 34px rgba(0,0,0,.5);
  transition: transform .2s ease, background .2s ease, border-color .2s ease;
  max-width: calc(100vw - 24px);
}
#buybar:hover{ transform: translateX(-50%) translateY(-3px); border-color: var(--accent); background: rgba(18,15,11,.9); }
#buybar .cover{
  width: 52px; height: 76px; flex: 0 0 auto; border-radius: 5px; overflow: hidden;
  background: #24406e; box-shadow: 0 3px 12px rgba(0,0,0,.55);
}
#buybar .cover img{ width: 100%; height: 100%; object-fit: cover; display: block; }
#buybar .txt{ display: flex; flex-direction: column; gap: 4px; line-height: 1.15; padding-right: 4px; }
#buybar .txt strong{ font-family: var(--serif); font-weight: 600; font-size: 1.12rem; }
#buybar .sub{ font-family: var(--serif); font-style: italic; font-size: .74rem; opacity: .6; }
#buybar .btn{
  margin-top: 4px; align-self: flex-start;
  font-family: var(--sans); font-weight: 600; font-size: .76rem; letter-spacing: .01em;
  color: var(--ink); background: var(--accent);
  padding: 6px 13px; border-radius: 999px;
}
#buybar:hover .btn{ background: #d8b45a; }
@media (max-width: 480px){
  #buybar{ bottom: 12px; gap: 10px; padding: 8px 12px 8px 8px; }
  #buybar .cover{ width: 44px; height: 64px; }
  #buybar .txt strong{ font-size: .98rem; }
  #buybar .sub{ display: none; }
}

/* ---------- loading veil ---------- */
#loading{
  position: fixed; inset: 0; z-index: 50;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1.2rem;
  background: var(--ink); color: var(--paper);
  transition: opacity .6s ease; opacity: 1;
}
#loading.gone{ opacity: 0; pointer-events: none; }
#loading p{ font-family: var(--sans); letter-spacing: .28em; text-transform: uppercase; font-size: .7rem; opacity: .6; }
#loading .spin{
  width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid rgba(244,236,221,.2); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin{ to{ transform: rotate(360deg); } }

/* ---------- mobile / reduced-motion fallback ---------- */
body.no-scrub{ overflow: auto; }
body.no-scrub #stage{ position: static; }
body.no-scrub .clip{ display: none; }
body.no-scrub #captions{ position: static; }
body.no-scrub .cap{
  position: relative; inset: auto; opacity: 1; transform: none;
  min-height: 100vh; background-size: cover; background-position: center;
}
body.no-scrub .wordline span{ opacity: 1; animation: none; }
body.no-scrub #dots, body.no-scrub .cue{ display: none; }

/* ---------- dev-only tuner ---------- */
#tuner{
  position: fixed; left: 16px; bottom: 16px; z-index: 9999; width: 288px;
  padding: 14px 16px; background: rgba(18,15,11,.94); backdrop-filter: blur(8px);
  border: 1px solid rgba(201,162,75,.35); border-radius: 12px; color: var(--paper);
  font-family: var(--sans); font-size: 12px; box-shadow: 0 12px 40px rgba(0,0,0,.5);
}
#tuner strong{ font-size: 12px; letter-spacing: .04em; color: var(--accent); }
#tuner .row{ display:flex; gap:8px; align-items:center; margin:.5rem 0; }
#tuner .row button{ flex:0 0 auto; background:rgba(201,162,75,.18); color:var(--paper); border:1px solid rgba(201,162,75,.4); border-radius:6px; padding:3px 8px; cursor:pointer; font-size:11px; }
#tuner .stn{ flex:1; text-align:center; opacity:.9; }
#tuner label{ display:block; margin:.7rem 0; }
#tuner label span{ display:block; margin-bottom:.3rem; opacity:.85; }
#tuner input[type=range]{ width:100%; accent-color: var(--accent); }
#tuner output{ display:block; margin-top:.25rem; opacity:.7; font-size:10.5px; }
#tuner .hint{ opacity:.5; font-size:10px; margin-top:.5rem; line-height:1.4; }
