/* ═════════ THE CODEX (8 Oct 2026): the stars above the graveyard are the cards of Book I.
   Three stars wake first; opening a card wakes the stars it is bound to. Threads stay faintly etched. ═════════ */
:root { --cx-gold: #e6c27a; --cx-quote: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; }

#cx-threads { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 2; pointer-events: none; overflow: visible; }
#cx-threads line { stroke: rgba(143, 211, 187, .16); stroke-width: 1; vector-effect: non-scaling-stroke; }
#cx-threads line.live { stroke: rgba(230, 194, 122, .75); stroke-width: 1.4; stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: cx-draw .9s ease forwards; }
#cx-threads line.group { stroke: rgba(230, 194, 122, .42); stroke-width: 1.2; }
#cx-threads text { fill: rgba(230, 194, 122, .55); font-family: var(--serif); font-size: 11px; letter-spacing: .26em; text-transform: uppercase; text-anchor: middle; }
@keyframes cx-draw { to { stroke-dashoffset: 0; } }

#cx-stars { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
.cx-star { all: unset; position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px; display: grid; place-items: center; cursor: pointer; pointer-events: auto; -webkit-tap-highlight-color: transparent; }
.cx-star .dot { width: var(--d, 5px); height: var(--d, 5px); border-radius: 50%; background: #fff; box-shadow: 0 0 6px 1px rgba(255, 255, 255, .7), 0 0 18px 4px var(--halo, rgba(143, 211, 187, .35)); transition: transform .4s, opacity .4s; }
.cx-star.r-uncommon { --d: 6px; } .cx-star.r-rare { --d: 7px; } .cx-star.r-mythic { --d: 9px; --halo: rgba(230, 194, 122, .45); }
.cx-star.k-dream { --halo: rgba(170, 160, 255, .4); } .cx-star.k-place { --halo: rgba(143, 211, 187, .45); }
.cx-star.awake .dot { animation: cx-twinkle 3.4s ease-in-out infinite; animation-delay: var(--tw, 0s); }
.cx-star.asleep { cursor: default; }
.cx-star.asleep .dot { width: 3.5px; height: 3.5px; opacity: .45; box-shadow: 0 0 3px rgba(255, 255, 255, .4); animation: none; }
.cx-star.awake:not(.seen)::after { content: ''; position: absolute; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%; border: 1px solid rgba(230, 194, 122, .55); animation: cx-call 2.6s ease-out infinite; animation-delay: var(--tw, 0s); pointer-events: none; }
@keyframes cx-call { 0% { transform: scale(.4); opacity: .9; } 100% { transform: scale(1.5); opacity: 0; } }
.cx-star.seen .dot { box-shadow: 0 0 6px 1px rgba(255, 255, 255, .8), 0 0 0 3px rgba(230, 194, 122, .0), 0 0 0 4px rgba(230, 194, 122, .5), 0 0 18px 4px var(--halo, rgba(143, 211, 187, .35)); }
.cx-star.wake .dot { animation: cx-wake 1.1s ease-out; }
.cx-star.secret .dot { --halo: rgba(227, 230, 233, .6); }
.cx-star .lbl { position: absolute; top: 34px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-family: var(--serif); font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--pewter-hi); text-shadow: 0 1px 6px #000, 0 0 2px #000; opacity: 0; transition: opacity .25s; pointer-events: none; }
.cx-star:not(.asleep):hover .lbl, .cx-star:not(.asleep):focus-visible .lbl, .cx-star.named .lbl { opacity: .9; }
.cx-star:focus-visible .dot { outline: 2px solid var(--verdi-hi); outline-offset: 6px; }
@keyframes cx-twinkle { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.78); opacity: .78; } }
@keyframes cx-wake { 0% { transform: scale(.3); opacity: .2; } 45% { transform: scale(2.4); opacity: 1; } 100% { transform: scale(1); } }

/* the Codex HUD: a quiet counter, and the deck view */
#cx-hud { position: fixed; z-index: 5; left: 16px; top: calc(var(--safe-t) + 16px); display: flex; flex-direction: column; gap: 4px; font-family: var(--serif); pointer-events: none; }
#cx-hud .t { font-size: 11px; letter-spacing: .3em; text-transform: uppercase; color: var(--verdi); }
#cx-hud .n { font-size: 12px; letter-spacing: .12em; color: var(--pewter); }
#cx-hud .hint { font-size: 11px; letter-spacing: .14em; color: var(--pewter-dim); max-width: 22ch; line-height: 1.5; }
#cx-hud a { pointer-events: auto; font-size: 10.5px; letter-spacing: .22em; text-transform: uppercase; color: var(--pewter-dim); text-decoration: none; border-bottom: 1px solid rgba(124, 132, 139, .35); width: max-content; margin-top: 4px; }
#cx-hud a:hover, #cx-hud a:focus-visible { color: var(--verdi-hi); outline: none; }

/* the free book: always one tap away (Brooke: essential) */
.cx-cta { position: relative; z-index: 6; display: inline-flex; pointer-events: auto; margin-bottom: 6px; align-items: center; gap: .6em; padding: 12px 22px; border-radius: 999px;
  background: linear-gradient(180deg, #e9cf8f, #c9a35a); color: #1a1408; font-family: var(--serif); font-weight: 700; font-size: 14px; letter-spacing: .12em; text-transform: uppercase; text-decoration: none; border: 0; cursor: pointer;
  box-shadow: 0 0 0 1px rgba(255, 236, 190, .5), 0 8px 28px rgba(0, 0, 0, .55), 0 0 30px rgba(230, 194, 122, .25); white-space: nowrap; }
.cx-cta:hover, .cx-cta:focus-visible { filter: brightness(1.08); outline: 2px solid var(--cx-gold); outline-offset: 3px; }
body.cx .foot .soon, body.cx #hint { display: none; }

/* the card: blooms out of its star */
#cx-view { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; overflow-y: auto; overscroll-behavior: contain; padding: calc(var(--safe-t) + 56px) 16px calc(var(--safe-b) + 40px); }
#cx-view { scroll-padding-bottom: 28px; } #cx-view .cx-stack { margin: auto 0; }   /* centred when it fits, scrollable when the spoiler opens beneath */
#cx-view[hidden] { display: none !important; }
#cx-view .back-drop { position: fixed; inset: 0; background: radial-gradient(ellipse at 50% 45%, rgba(3, 5, 9, .55), rgba(3, 5, 9, .9)); backdrop-filter: blur(2px); opacity: 0; transition: opacity .35s; }
#cx-view.on .back-drop { opacity: 1; }
.cx-card { position: relative; width: min(84vw, 360px, calc((100svh - 220px) * 2 / 3)); aspect-ratio: 2 / 3; perspective: 1200px; container-type: inline-size; cursor: pointer; transform-origin: 50% 50%; }
.cx-card .face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; transition: transform .6s cubic-bezier(.3, .7, .2, 1); border-radius: 16px; overflow: hidden; }
.cx-card .face.b { transform: rotateY(180deg); }
.cx-card.on .face.f { transform: rotateY(-180deg); } .cx-card.on .face.b { transform: rotateY(0); }
.cx-plate { position: absolute; inset: 0; background: #0b1017; box-shadow: 0 0 0 1px var(--edge, #3a434d), 0 24px 60px rgba(0, 0, 0, .7); border-radius: 16px; overflow: hidden; }
.cx-plate.mythic { --edge: rgba(232, 118, 60, .7); box-shadow: 0 0 0 1px rgba(232, 118, 60, .7), 0 0 40px rgba(232, 118, 60, .25), 0 24px 60px rgba(0, 0, 0, .7); }
.cx-plate.secret { --edge: #9aa3ab; box-shadow: 0 0 0 1px #9aa3ab, 0 0 40px rgba(227, 230, 233, .2), 0 24px 60px rgba(0, 0, 0, .7); }
.cx-plate img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; }
.cx-plate .scrim { position: absolute; left: 0; right: 0; bottom: 0; height: 26%; background: linear-gradient(180deg, rgba(5, 7, 12, 0), rgba(5, 7, 12, .55) 55%, rgba(5, 7, 12, .78)); }
.cx-plate .cap { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 7cqi 7cqi; }
.cx-plate .nm { font-family: var(--serif); font-weight: 700; color: var(--pewter-hi); font-size: clamp(1.1rem, 8.6cqi, 1.9rem); line-height: 1.08; text-wrap: balance; text-shadow: 0 2px 10px rgba(0, 0, 0, .9), 0 0 3px #000; }
.cx-plate .tg { text-shadow: 0 1px 6px rgba(0, 0, 0, .9), 0 0 2px #000; margin-top: 2cqi; font-family: var(--serif); font-size: clamp(.6rem, 4.2cqi, .82rem); letter-spacing: .2em; text-transform: uppercase; color: var(--verdi-hi); }
.cx-plate .turn { position: absolute; top: 5cqi; right: 5cqi; font-family: var(--serif); font-size: clamp(.55rem, 3.6cqi, .7rem); letter-spacing: .2em; text-transform: uppercase; color: rgba(227, 230, 233, .8); background: rgba(5, 7, 12, .55); padding: .45em .8em; border-radius: 999px; }
.cx-quote { position: absolute; inset: 0; padding: 8cqi 8cqi 5cqi; display: flex; flex-direction: column; gap: 3cqi; border-radius: 16px; background: radial-gradient(ellipse at 50% 0%, rgba(255, 240, 210, .12), transparent 60%), linear-gradient(#e9e1cd, #d5c9ad); color: #1f1a12; box-shadow: 0 24px 60px rgba(0, 0, 0, .7); }
.cx-quote .qn { font-family: var(--serif); font-weight: 700; font-size: clamp(.8rem, 5.6cqi, 1.05rem); letter-spacing: .06em; color: #4a3c28; border-bottom: 1px solid rgba(74, 60, 40, .3); padding-bottom: 2.4cqi; }
.cx-quote blockquote { flex: 1; min-height: 0; overflow: hidden; margin: 0; font-family: var(--cx-quote); font-style: italic; line-height: 1.45; font-size: 18px; }
.cx-quote .qm { font-family: var(--serif); font-style: normal; font-size: 2.2em; line-height: 0; vertical-align: -.42em; margin-right: .08em; color: #8a6a3a; }
.cx-quote .src { font-family: var(--serif); font-size: clamp(.55rem, 3.6cqi, .7rem); letter-spacing: .18em; text-transform: uppercase; color: #7a6648; text-align: right; }
.cx-quote.secret { background: linear-gradient(#1a1d22, #0d0f12); color: #d9dde1; } .cx-quote.secret .qn { color: #e3e6e9; border-color: rgba(227, 230, 233, .25); } .cx-quote.secret .qm, .cx-quote.secret .src { color: #9aa3ab; }
.cx-under { position: relative; margin-top: 14px; display: flex; flex-wrap: wrap; gap: 6px 8px; justify-content: center; align-items: center; max-width: min(92vw, 520px); }
.cx-under .lab { font-family: var(--serif); font-size: 10.5px; letter-spacing: .24em; text-transform: uppercase; color: var(--pewter-dim); width: 100%; text-align: center; }
.cx-chip { all: unset; cursor: pointer; font-family: var(--serif); font-size: 12px; letter-spacing: .08em; color: var(--pewter-hi); padding: 7px 12px; border-radius: 999px; border: 1px solid rgba(230, 194, 122, .35); background: rgba(5, 7, 12, .6); }
.cx-chip:hover, .cx-chip:focus-visible { border-color: var(--cx-gold); color: #fff; }
.cx-chip.spoil { border-style: dashed; color: var(--pewter); }
.cx-reveal { margin-top: 10px; max-width: min(88vw, 460px); font-family: var(--cx-quote); font-size: 15px; line-height: 1.55; color: var(--pewter-hi); background: rgba(5, 7, 12, .75); border: 1px solid rgba(143, 211, 187, .25); border-radius: 10px; padding: 12px 14px; }
.cx-x { all: unset; position: fixed; top: calc(var(--safe-t) + 12px); right: 14px; width: 40px; height: 40px; display: grid; place-items: center; cursor: pointer; color: var(--pewter-hi); font-size: 26px; z-index: 2; }
.cx-x:focus-visible { outline: 2px solid var(--verdi-hi); border-radius: 50%; }
.cx-stack { position: relative; display: flex; flex-direction: column; align-items: center; }

/* constellation found */
.cx-found { position: fixed; z-index: 30; left: 50%; top: calc(var(--safe-t) + 18px); transform: translateX(-50%); width: min(92vw, 420px); text-align: center; padding: 14px 18px 16px; border-radius: 12px;
  background: rgba(8, 11, 16, .92); border: 1px solid rgba(230, 194, 122, .45); box-shadow: 0 12px 40px rgba(0, 0, 0, .6); animation: cx-in .5s ease; }
.cx-found .k { font-family: var(--serif); font-size: 10.5px; letter-spacing: .3em; text-transform: uppercase; color: var(--cx-gold); }
.cx-found .nm { font-family: var(--serif); font-weight: 700; font-size: 1.2rem; color: var(--pewter-hi); margin: 4px 0 8px; }
.cx-found .ln { font-family: var(--cx-quote); font-style: italic; color: var(--pewter); font-size: 14px; margin: 0 0 10px; }
.cx-found a { color: var(--cx-gold); font-family: var(--serif); font-size: 12px; letter-spacing: .16em; text-transform: uppercase; }
@keyframes cx-in { from { opacity: 0; transform: translate(-50%, -10px); } }

/* free book sheet (email + ebook delivery wire up next week) */
#cx-book { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(2, 3, 6, .82); padding: 16px; }
#cx-book[hidden] { display: none !important; }
#cx-book .sheet { position: relative; width: min(92vw, 420px); background: linear-gradient(#0f1520, #090c12); border: 1px solid rgba(230, 194, 122, .35); border-radius: 14px; padding: 24px 22px 22px; text-align: center; }
#cx-book .cx-x-sheet { top: 6px; right: 6px; }
#cx-book h2 { font-family: var(--serif); color: var(--pewter-hi); font-size: 1.3rem; margin: 0 0 6px; letter-spacing: .04em; }
#cx-book p { color: var(--pewter); font-size: 14px; line-height: 1.5; margin: 0 0 14px; }
#cx-book input { width: 100%; box-sizing: border-box; padding: 12px 14px; border-radius: 8px; border: 1px solid #2a3340; background: #05080c; color: var(--pewter-hi); font-size: 16px; margin-bottom: 10px; }
#cx-book .cx-cta { position: static; transform: none; width: 100%; justify-content: center; }
#cx-book small { display: block; margin-top: 10px; color: var(--pewter-dim); font-size: 11.5px; }

@media (max-width: 600px) {
  #cx-threads text { opacity: 0; transition: opacity .6s; } #cx-threads text.recent { opacity: 1; }
  body.cx .foot .studio { display: none; }
  .cx-star .lbl { font-size: 9.5px; top: 30px; }
  .cx-cta { font-size: 13px; padding: 12px 18px; }
  #cx-hud .hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .cx-star.awake .dot, .cx-star.wake .dot, .cx-star.awake::after { animation: none; }
  #cx-threads line.live { animation: none; stroke-dashoffset: 0; }
  .cx-card .face { transition: none; }
}

/* 9 Oct (mobile pass): the arrow never wraps alone */
.cx-found .nw { white-space: nowrap; }

/* ═════════ THE FINALE (9 Oct): thirty stars ═════════ */
body.cx-cer .stage, body.cx-cer .foot, body.cx-cer #cx-hud, body.cx-cer .top, body.cx-cer #cx-dock, body.cx-cer .cx-cta { opacity: 0 !important; pointer-events: none !important; transition: opacity .9s ease; }
#cx-threads.cer line.group, #cx-threads.cer text { opacity: 0; transition: none; }
#cx-threads.cer line.group.cer-on { opacity: 1; stroke: rgba(240, 206, 140, .85); stroke-width: 1.6; stroke-dasharray: var(--len); stroke-dashoffset: var(--len); animation: cx-draw 1.1s ease forwards; filter: drop-shadow(0 0 4px rgba(255, 190, 110, .7)); }
#cx-threads.cer text.cer-on { opacity: 1; fill: rgba(246, 220, 168, .95); font-size: 12px; transition: opacity .8s ease; }
#cx-threads.cer-all line.group { opacity: 1; stroke: rgba(255, 214, 150, .95); animation: cx-glow 1.6s ease-in-out infinite alternate; stroke-dashoffset: 0; }
#cx-threads.cer-all text { opacity: 1; }
@keyframes cx-glow { from { filter: drop-shadow(0 0 2px rgba(255, 190, 110, .5)); } to { filter: drop-shadow(0 0 9px rgba(255, 200, 120, .95)); } }
#cx-finale { position: fixed; inset: 0; z-index: 70; cursor: pointer; }
#cx-finale .cap { position: absolute; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom, 0px) + 16svh); text-align: center; padding: 0 20px; font-family: var(--serif); font-size: clamp(20px, 5.4vw, 34px); letter-spacing: .14em; text-transform: uppercase; color: #f3dcae; text-shadow: 0 0 18px rgba(255, 170, 80, .65), 0 2px 10px #000; opacity: 0; }
#cx-finale .cap .n { display: block; font-size: .42em; letter-spacing: .5em; color: rgba(230, 194, 122, .8); margin-bottom: 10px; }
#cx-finale .cap.in { animation: cx-capin 1.5s ease both; }
@keyframes cx-capin { 0% { opacity: 0; transform: translateY(8px); filter: blur(6px); } 25% { opacity: 1; transform: none; filter: blur(0); } 80% { opacity: 1; } 100% { opacity: .85; } }
#cx-finale .skip { position: absolute; left: 0; right: 0; bottom: calc(env(safe-area-inset-bottom, 0px) + 18px); text-align: center; font-family: var(--serif); font-size: 10.5px; letter-spacing: .3em; text-transform: uppercase; color: rgba(200, 205, 212, .35); }
.cx-flare { position: fixed; inset: 0; z-index: 80; pointer-events: none; mix-blend-mode: screen; background: radial-gradient(circle at var(--fx, 50%) var(--fy, 40%), rgba(255, 246, 220, .98), rgba(255, 186, 120, .75) 14%, rgba(255, 120, 40, .25) 34%, transparent 62%); animation: cx-flare 1.3s ease-out both; }
@keyframes cx-flare { 0% { opacity: 0; transform: scale(.4); } 10% { opacity: 1; } 35% { opacity: 1; transform: scale(1.6); } 100% { opacity: 0; transform: scale(2.4); } }
body.cx-quake #cx-stars, body.cx-quake #cx-threads, body.cx-quake #sky, body.cx-quake #yard { animation: cx-quake .6s ease; }
@keyframes cx-quake { 0%, 100% { transform: none; } 15% { transform: translate(-6px, 4px); } 35% { transform: translate(7px, -5px); } 55% { transform: translate(-4px, 5px); } 75% { transform: translate(3px, -2px); } }
#cx-reward { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px calc(env(safe-area-inset-bottom, 0px) + 14px); background: radial-gradient(70% 60% at 50% 45%, rgba(40, 18, 6, .55), rgba(2, 2, 4, .9)); opacity: 0; transition: opacity .6s ease; }
#cx-reward.on { opacity: 1; }
#cx-reward .fr { display: grid; justify-items: center; gap: 12px; max-width: 100%; }
#cx-reward .k { font-family: var(--serif); font-size: 11px; letter-spacing: .38em; text-transform: uppercase; color: #e6c27a; }
#cx-reward img { height: min(66svh, 720px); max-width: calc(100vw - 32px); aspect-ratio: 9 / 16; object-fit: cover; border-radius: 14px; box-shadow: 0 0 0 1px rgba(230, 194, 122, .35), 0 0 60px rgba(255, 140, 50, .35), 0 24px 60px rgba(0, 0, 0, .7); }
#cx-reward.on img { animation: cx-rise 1.1s cubic-bezier(.2, .9, .25, 1) both; }
@keyframes cx-rise { 0% { opacity: 0; transform: scale(1.12) translateY(14px); filter: blur(10px) brightness(1.6); } 55% { filter: blur(0) brightness(1.15); } 100% { opacity: 1; transform: none; filter: none; } }
#cx-reward .acts { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
#cx-reward .acts button { all: unset; cursor: pointer; padding: 11px 18px; border-radius: 999px; font-family: var(--serif); font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: #ffd6a8; border: 1px solid rgba(255, 154, 60, .55); }
#cx-reward .acts button.main { background: linear-gradient(180deg, #ffb066, #e0611a); color: #1a0d04; border-color: transparent; font-weight: 700; }
#cx-reward .acts button:focus-visible { outline: 2px solid #ffb066; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { #cx-reward.on img, #cx-finale .cap.in, #cx-threads.cer-all line.group { animation: none; } #cx-threads.cer line.group.cer-on { animation: none; stroke-dashoffset: 0; } }
/* finale: only the constellation being drawn shows; on phones the caption names it (the small sky labels collide there) */
#cx-threads.cer line:not(.group) { opacity: 0; }
@media (max-width: 600px) { #cx-threads.cer text, #cx-threads.cer text.cer-on, #cx-threads.cer-all text { opacity: 0; } }
/* the finale caption bows out when the reward rises */
body:has(#cx-reward) #cx-finale { opacity: 0; transition: opacity .5s; }

/* 10 Oct (Brooke): card backs read like a page of the book: its own paragraphs, upright type, every quote mark as printed */
.cx-quote blockquote { font-style: normal; display: flex; flex-direction: column; justify-content: center; }
.cx-quote blockquote p { margin: 0 0 .62em; text-wrap: pretty; }
.cx-quote blockquote p:last-child { margin-bottom: 0; }
.cx-quote blockquote .cut { opacity: .55; letter-spacing: .04em; }
