/* A Phoenix Wild — the book */
:root {
  --paper: #f2e8d2;
  --paper-2: #eadcbf;
  --ink-dark: #2a2117;
  --ink-soft: #5b4d3c;
  --rule: rgba(90, 64, 30, 0.28);
  --gold: #b9853a;
  --book-serif: "EB Garamond", "Cormorant Garamond", Georgia, serif;
}

/* ---------- The stage ---------- */
.stage {
  position: relative; min-height: 100vh; padding: 84px 0 40px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background:
    radial-gradient(900px 640px at 50% 46%, rgba(255, 170, 80, 0.13), transparent 70%),
    radial-gradient(1400px 900px at 50% 120%, rgba(0, 0, 0, 0.7), transparent 60%),
    linear-gradient(180deg, #05070f 0%, #0d0b12 40%, #120d0c 100%);
  overflow: hidden;
}
.stage .eyebrow { margin-bottom: 18px; }
.desk-glow { position: absolute; left: 50%; top: 52%; width: 70vw; height: 50vh; transform: translate(-50%, -50%); background: radial-gradient(closest-side, rgba(255, 190, 110, 0.10), transparent); pointer-events: none; }

.book-wrap { --ph: min(calc(100vh - 230px), calc(90vw * 0.75), 820px); position: relative; width: calc(var(--ph) / 0.75); height: var(--ph); perspective: 2600px; }
.book {
  position: absolute; inset: 0; transform-style: preserve-3d;
  transition: transform 1.1s cubic-bezier(.3,.1,.2,1);
}
.book.closed-front { transform: translateX(-25%); }
.book.closed-back { transform: translateX(25%); }

.leaf {
  position: absolute; top: 0; left: 50%; width: 50%; height: 100%;
  transform-origin: left center; transform-style: preserve-3d;
  transition: transform 1.15s cubic-bezier(.32,.08,.2,1);
  cursor: pointer;
}
.leaf.turned { transform: rotateY(-180deg); }
.face {
  position: absolute; inset: 0; overflow: hidden;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  container-type: size;
  background-color: var(--paper);
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0.35  0 0 0 0 0.25  0 0 0 0 0.12  0 0 0 0.09 0'/></filter><rect width='240' height='240' filter='url(%23n)'/></svg>"),
    radial-gradient(120% 90% at 50% 40%, var(--paper) 55%, var(--paper-2) 100%);
  color: var(--ink-dark);
  font-family: var(--book-serif);
}
.face.front { border-radius: 0 6px 6px 0; box-shadow: inset 14px 0 30px -14px rgba(60, 35, 10, 0.45), 6px 0 18px rgba(0,0,0,0.25); }
.face.back { transform: rotateY(180deg); border-radius: 6px 0 0 6px; box-shadow: inset -14px 0 30px -14px rgba(60, 35, 10, 0.45), -6px 0 18px rgba(0,0,0,0.25); }
/* page-edge stack */
.face.front::before, .face.back::before { content: ""; position: absolute; top: 0.6%; bottom: 0.6%; width: 4px; background: repeating-linear-gradient(90deg, #d9c9a6 0 1px, #f3e9d2 1px 2px); opacity: 0.7; }
.face.front::before { right: 0; }
.face.back::before { left: 0; }
.shade { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.6s; }
.front .shade { background: linear-gradient(90deg, rgba(0,0,0,0.35), rgba(0,0,0,0) 60%); }
.back .shade { background: linear-gradient(270deg, rgba(0,0,0,0.35), rgba(0,0,0,0) 60%); }
.leaf.moving .shade { opacity: 1; }

/* ---------- Page furniture ---------- */
.pg { position: absolute; inset: 0; padding: 9cqh 9% 8cqh 11%; display: flex; flex-direction: column; }
.back .pg { padding: 9cqh 11% 8cqh 9%; }
.runhead { position: absolute; top: 4.4cqh; left: 0; right: 0; text-align: center; font-size: 1.45cqh; letter-spacing: 0.32em; text-transform: uppercase; color: var(--ink-soft); }
.folio { position: absolute; bottom: 3.8cqh; left: 0; right: 0; text-align: center; font-size: 1.7cqh; color: var(--ink-soft); }
.pg h2 { font-family: var(--book-serif); font-weight: 500; font-size: 4.6cqh; line-height: 1.05; margin: 0 0 2.2cqh; color: var(--ink-dark); letter-spacing: 0.01em; }
.pg h3 { font-family: var(--book-serif); font-weight: 600; font-size: 2.6cqh; margin: 0 0 0.4cqh; }
.pg .chap { font-size: 1.5cqh; letter-spacing: 0.36em; text-transform: uppercase; color: var(--gold); margin-bottom: 1.4cqh; }
.pg p { font-size: 2.22cqh; line-height: 1.42; margin: 0 0 1.05cqh; text-align: justify; hyphens: auto; -webkit-hyphens: auto; }
.pg p.ni { text-indent: 0; }
.pg p + p { text-indent: 1.4em; }
.pg .lead::first-letter { float: left; font-size: 6.4cqh; line-height: 0.85; padding: 0.4cqh 0.5cqh 0 0; color: var(--gold); font-weight: 500; }
.pg em { font-style: italic; }
.pg .small { font-size: 1.85cqh; color: var(--ink-soft); }
.orn { display: block; margin: 2cqh auto; width: 46%; height: 2cqh; }
.orn path { fill: none; stroke: var(--gold); stroke-width: 1; }
.orn circle { fill: var(--gold); }
.voices p { font-style: italic; color: var(--ink-soft); text-indent: 0 !important; margin: 0 0 0.35cqh 1.2em; text-align: left; font-size: 2.05cqh; }
.centered { text-align: center; }
.centered p { text-align: center; text-indent: 0 !important; }

/* opener */
.opener { padding-top: 16cqh; }
.opener h2 { font-size: 5.2cqh; text-align: center; }
.opener .chap { text-align: center; }

/* plates */
.plate { padding: 8cqh 9% 6cqh; justify-content: center; }
.back .plate { padding: 8cqh 9% 6cqh; }
.plate figure { margin: 0; display: flex; flex-direction: column; height: 100%; }
.plate .frame { flex: 1; min-height: 0; position: relative; border: 1px solid rgba(90,64,30,0.35); padding: 1.1cqh; background: rgba(255,255,255,0.25); box-shadow: 0 1px 0 rgba(255,255,255,0.6) inset; }
.plate img { width: 100%; height: 100%; object-fit: cover; display: block; filter: saturate(0.95) contrast(1.02); }
.plate figcaption { text-align: center; margin-top: 1.8cqh; font-size: 1.9cqh; font-style: italic; color: var(--ink-soft); }
.plate figcaption b { display: block; font-style: normal; font-weight: 500; font-size: 1.4cqh; letter-spacing: 0.34em; text-transform: uppercase; color: var(--gold); margin-bottom: 0.6cqh; }
.placeholder { position: absolute; inset: 1.1cqh; background: radial-gradient(circle at 50% 60%, rgba(185,133,58,0.25), rgba(40,30,20,0.12)); display: grid; place-items: center; font-style: italic; color: var(--ink-soft); font-size: 1.8cqh; }

/* full-bleed endpapers */
.bleed { position: absolute; inset: 0; background-size: 200% 100%; background-repeat: no-repeat; }
.back .bleed { background-position: left center; }
.front .bleed { background-position: right center; }
.bleed::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0,0,0,0.0), rgba(0,0,0,0.0)); }
.front .bleed::after { background: linear-gradient(90deg, rgba(0,0,0,0.38), transparent 10%); }
.back .bleed::after { background: linear-gradient(270deg, rgba(0,0,0,0.38), transparent 10%); }
.bleed .cap { position: absolute; bottom: 4cqh; left: 0; right: 0; text-align: center; font-size: 1.55cqh; letter-spacing: 0.34em; text-transform: uppercase; color: rgba(255, 238, 205, 0.86); text-shadow: 0 1px 6px rgba(0,0,0,0.8); }

/* cover */
.cover-face { background: #0b0d19; color: #fff3dc; border-radius: 3px 8px 8px 3px !important; box-shadow: 0 30px 80px rgba(0,0,0,0.75), inset 6px 0 0 rgba(255,255,255,0.05) !important; }
.cover-face::before { display: none !important; }
.cover-face img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover-face .veil { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(5,7,15,0.55) 0%, rgba(5,7,15,0) 34%, rgba(5,7,15,0) 70%, rgba(5,7,15,0.7) 100%); }
.cover-face .spine { position: absolute; left: 0; top: 0; bottom: 0; width: 4.5%; background: linear-gradient(90deg, rgba(0,0,0,0.65), rgba(255,255,255,0.10) 60%, rgba(0,0,0,0.2)); }
.cover-type { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; padding: 7cqh 8%; text-align: center; }
.cover-type .series { font-family: var(--mono); font-size: 1.4cqh; letter-spacing: 0.5em; color: #f6d79d; }
.cover-type .ct { font-family: var(--serif); font-weight: 500; font-size: 10.5cqh; line-height: 0.95; margin-top: 1.6cqh; letter-spacing: 0.06em;
  background: linear-gradient(180deg, #fff6e2, #f0cf8e 60%, #b9853a); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 12px rgba(255,170,70,0.35)); }
.cover-type .bk { font-family: var(--serif); font-style: italic; font-size: 2.6cqh; margin-top: 0.6cqh; color: #f4e2bf; }
.cover-type .au { margin-top: auto; font-family: var(--serif); letter-spacing: 0.36em; font-size: 2.5cqh; color: #fff3dc; text-shadow: 0 2px 10px rgba(0,0,0,0.8); }
.back-cover { background: #0d0f1c; color: #e9e4d8; border-radius: 8px 3px 3px 8px !important; }
.back-cover::before { display: none !important; }
.back-cover .pg { padding: 12cqh 12%; justify-content: center; }
.back-cover p { font-family: var(--serif); font-size: 2.5cqh; line-height: 1.45; color: #e9e4d8; text-align: left; text-indent: 0 !important; }
.back-cover .kick { color: #ffd27a; font-style: italic; }
.back-cover .url { margin-top: auto; text-align: center; font-family: var(--mono); font-size: 1.4cqh; letter-spacing: 0.3em; color: #a8a59c; }

/* title page */
.titlepage { align-items: center; justify-content: center; text-align: center; }
.titlepage .s { font-size: 1.7cqh; letter-spacing: 0.5em; color: var(--ink-soft); }
.titlepage .t { font-size: 9.5cqh; letter-spacing: 0.06em; line-height: 1; margin: 2cqh 0 1cqh; color: var(--ink-dark); font-weight: 500; }
.titlepage .b { font-style: italic; font-size: 2.6cqh; color: var(--ink-soft); }
.titlepage .a { margin-top: 9cqh; font-size: 2.8cqh; letter-spacing: 0.32em; }

/* contents */
.toc { list-style: none; padding: 0; margin: 3cqh 0 0; }
.toc li { display: flex; align-items: baseline; gap: 0.6em; font-size: 2.4cqh; margin: 0 0 1.6cqh; }
.toc a { color: var(--ink-dark); }
.toc a:hover { color: var(--gold); }
.toc .dots { flex: 1; border-bottom: 1px dotted rgba(90,64,30,0.45); transform: translateY(-0.3em); }
.toc .n { color: var(--ink-soft); font-variant-numeric: oldstyle-nums; }

/* people */
.who { margin-bottom: 2.2cqh; }
.who h3 { display: flex; justify-content: space-between; align-items: baseline; }
.who h3 span { font-size: 1.45cqh; letter-spacing: 0.22em; text-transform: uppercase; color: var(--ink-soft); font-weight: 400; }
.who p { font-size: 2.05cqh; margin-bottom: 0.5cqh; text-indent: 0 !important; }
.who q { display: block; font-style: italic; color: var(--gold); font-size: 2.1cqh; quotes: "\201C" "\201D"; }

/* exchange */
.exchange-pg q { display: block; font-size: 3.4cqh; line-height: 1.25; text-align: center; quotes: "\201C" "\201D"; margin-bottom: 1.4cqh; }
.exchange-pg q:nth-child(2) { color: var(--ink-soft); }
.exchange-pg q:nth-child(3) { color: var(--gold); font-style: italic; }

/* bug plate interactions */
.bug-plate .frame { cursor: pointer; }
.page-speech { position: absolute; left: 50%; top: 10%; transform: translate(-50%, -8px); width: 78%; padding: 1.4cqh 1.8cqh; background: #fff8e8; color: #1e160c; border-radius: 1.4cqh; font-size: 2.1cqh; line-height: 1.3; text-align: center; box-shadow: 0 1cqh 3cqh rgba(0,0,0,0.35); opacity: 0; transition: opacity 0.3s, transform 0.3s; pointer-events: none; z-index: 3; }
.page-speech.show { opacity: 1; transform: translate(-50%, 0); }

/* lantern form on paper */
.paper-form { display: flex; flex-direction: column; gap: 1.2cqh; margin-top: 2cqh; }
.paper-form input { font: inherit; font-size: 2.2cqh; padding: 1.2cqh 1.4cqh; border: 1px solid rgba(90,64,30,0.45); background: rgba(255,255,255,0.45); color: var(--ink-dark); border-radius: 0.6cqh; outline: none; }
.paper-form input:focus { border-color: var(--gold); }
.paper-form button { font: inherit; font-size: 1.7cqh; letter-spacing: 0.26em; text-transform: uppercase; padding: 1.3cqh; border: 0; border-radius: 0.6cqh; background: var(--ink-dark); color: #f6e8c8; cursor: pointer; }
.paper-form button:hover { background: #4a3a26; }
.form-note { font-style: italic; color: var(--ink-soft); font-size: 1.9cqh; min-height: 2.5cqh; }

/* controls */
.controls { margin-top: 22px; display: flex; align-items: center; gap: 22px; color: var(--muted); font-family: var(--mono); font-size: 12px; letter-spacing: 0.2em; text-transform: uppercase; }
.controls button { width: 46px; height: 46px; border-radius: 50%; border: 1px solid rgba(255,181,71,0.45); background: rgba(10,14,34,0.4); color: var(--ink); cursor: pointer; font-size: 18px; transition: all 0.25s; }
.controls button:hover:not(:disabled) { background: var(--amber); color: var(--night); }
.controls button:disabled { opacity: 0.3; cursor: default; }
.hint-keys { margin-top: 14px; font-family: var(--serif); font-style: italic; color: var(--faint); font-size: 15px; }
.ribbon { position: absolute; top: -1.5%; left: calc(50% + 1.4%); width: 1.8%; height: 17%; background: linear-gradient(180deg, #7a1c1c, #a02a26); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 88%, 0 100%); box-shadow: 0 4px 10px rgba(0,0,0,0.4); z-index: 0; transition: opacity 0.6s; }
.book.closed-front ~ .ribbon, .book.closed-back ~ .ribbon { opacity: 0; }

/* ---------- Mobile: the book becomes a stack of pages ---------- */
@media (max-width: 820px) {
  .stage { padding: 90px 0 50px; }
  .book-wrap { --ph: auto; width: min(92vw, 520px); height: auto; perspective: none; }
  .book, .book.closed-front, .book.closed-back { position: static; transform: none; }
  .leaf { position: static; width: 100%; height: auto; transform: none !important; cursor: default; }
  .face { position: relative; transform: none !important; aspect-ratio: 2 / 3; margin-bottom: 18px; border-radius: 4px !important; box-shadow: 0 10px 30px rgba(0,0,0,0.45) !important; }
  .face::before { display: none; }
  .face.empty-m { display: none; }
  .bleed, .back .bleed, .front .bleed { background-size: cover; background-position: center; }
  .bleed::after { display: none; }
  .controls, .hint-keys, .ribbon { display: none; }
}

/* placeholders while the photoreal plates are made */
.bleed.night { background:
    radial-gradient(1.4px 1.4px at 12% 18%, rgba(255,246,228,.8), transparent 60%),
    radial-gradient(1.2px 1.2px at 37% 9%, rgba(255,246,228,.7), transparent 60%),
    radial-gradient(1.6px 1.6px at 63% 22%, rgba(255,246,228,.8), transparent 60%),
    radial-gradient(1.1px 1.1px at 84% 12%, rgba(255,246,228,.6), transparent 60%),
    radial-gradient(1.3px 1.3px at 22% 34%, rgba(255,246,228,.5), transparent 60%),
    radial-gradient(1.2px 1.2px at 74% 38%, rgba(255,246,228,.5), transparent 60%),
    linear-gradient(180deg, #05081a 0%, #12173a 45%, #3d2846 72%, #a2523f 86%, #04060d 87%, #0b0d1c 100%);
  background-size: 200% 100%; }
.bleed.night::before { content: ""; position: absolute; left: 0; right: 0; top: 79%; height: 6px;
  background: radial-gradient(circle, #ffe2a8 0 2px, rgba(255,190,100,.35) 3px, transparent 4px) 0 50% / 2.44% 100% repeat-x;
  filter: drop-shadow(0 0 4px rgba(255,180,80,.9)); }
.back .bleed.night::before { left: 8%; }
.front .bleed.night::before { right: 30%; }
.plate-blank { position: absolute; inset: 1.1cqh; display: grid; place-items: center;
  background: radial-gradient(120% 90% at 50% 100%, rgba(185,133,58,.18), rgba(30,24,16,.06) 60%), repeating-linear-gradient(135deg, rgba(90,64,30,.05) 0 2px, transparent 2px 9px); }
.plate-blank span { font-style: italic; color: var(--ink-soft); font-size: 2cqh; letter-spacing: .04em; }
.bug-plate .frame { display: grid; place-items: center; background: radial-gradient(70% 60% at 50% 55%, rgba(255,150,60,.16), rgba(20,16,12,.05) 70%); }
.bug-plate #bug { width: 72%; height: auto; filter: drop-shadow(0 2cqh 2.4cqh rgba(0,0,0,.35)); }
@media (max-width: 820px) { .bleed.night { background-size: cover; } }

.cover-face canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
