/* style.css — DOM overlay styling. Colors come from theme.json (injected as --c-* by main.js);
   fallbacks below mirror theme.json v0 so the no-JS page still looks intentional. */
:root {
  --c-ink: #0b0b0b; --c-paper: #fffdf5; --c-accent: #f9c74f; --c-danger: #e63946; --c-skyHigh: #14205a; --c-skyLow: #9ad7ee;
  --c-hudText: #ffffff; --c-hudShadow: #000000; --c-coin: #f9c74f; --c-ground: #4caf50;
  --beat-top-offset: -10vh; /* beat panel vertical offset from the package hold line; mobile puts beats BELOW the package */
  --font-pixel: 'Press Start 2P', monospace; --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: var(--font-body); color: var(--c-ink); background: var(--c-skyBlue, #558af0); line-height: 1.5; overflow-x: hidden; } /* [G-0831] purple page ground removed by order */
h1, h2, h3 { font-family: var(--font-pixel); line-height: 1.5; margin: 0 0 .6em; font-weight: 400; }

/* canvas = decoration, fixed behind everything */
#scene { position: fixed; top: 0; left: 0; z-index: 0; image-rendering: pixelated; image-rendering: crisp-edges; pointer-events: none; }
main { position: relative; z-index: 1; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0 0 auto 0; z-index: 5; pointer-events: none; background: linear-gradient(rgba(0,0,0,.42), rgba(0,0,0,0)); font-family: var(--font-pixel); color: var(--c-hudText); text-shadow: 2px 2px 0 var(--c-hudShadow); font-size: clamp(10px, 1.4vw, 14px); padding: 14px 16px 30px; display: flex; justify-content: space-between; align-items: flex-start; }
.hud-left { letter-spacing: 1px; } .hud-k { opacity: .85; }
.hud-right { display: flex; gap: 18px; align-items: center; }
.hud-btn { pointer-events: auto; font: inherit; color: inherit; background: rgba(0,0,0,.35); border: 2px solid rgba(255,255,255,.6); padding: 4px 8px; text-shadow: none; cursor: not-allowed; opacity: .7; }
.hud-hint { position: fixed; left: 50%; bottom: 6vh; transform: translateX(-50%); animation: blink 1.1s steps(2, end) infinite; font-size: clamp(10px, 1.6vw, 14px); transition: opacity .4s; }
.hud-hint.hidden { opacity: 0; animation: none; }
.hud-banner { position: fixed; left: 50%; top: 18vh; transform: translateX(-50%) scale(.9); font-size: clamp(14px, 3.2vw, 34px); color: var(--c-accent); opacity: 0; transition: opacity .3s, transform .3s; white-space: nowrap; text-shadow: 3px 3px 0 var(--c-hudShadow); }
.hud-banner.show { opacity: 1; transform: translateX(-50%) scale(1); }
#hud.panel-in-view .hud-hint { opacity: 0 !important; animation: none; }
.hud-banner.flash { animation: flash 1s steps(2, end) 4; }
@keyframes blink { 50% { opacity: 0; } }
@keyframes flash { 50% { opacity: .15; } }

/* score popups */
.popup { position: fixed; z-index: 6; pointer-events: none; font-family: var(--font-pixel); color: var(--c-coin); text-shadow: 2px 2px 0 var(--c-hudShadow); font-size: clamp(10px, 1.5vw, 14px); transform: translate(-50%, -50%); animation: pop .9s ease-out forwards; }
@keyframes pop { 0% { opacity: 0; transform: translate(-50%, -40%) } 15% { opacity: 1 } 100% { opacity: 0; transform: translate(-50%, -160%) } }

/* ---------- track + hero ---------- */
#track { position: relative; }
.hero { position: absolute; top: 0; left: 0; right: 0; min-height: 100vh; display: flex; flex-direction: column; justify-content: center; align-items: flex-start; padding: 12vh 6vw; max-width: min(760px, 46vw); }
.hero-brand { font-family: var(--font-pixel); color: var(--c-accent); font-size: clamp(10px, 1.4vw, 13px); letter-spacing: 2px; text-shadow: 2px 2px 0 var(--c-hudShadow); margin: 0 0 1.2em; }
.hero h1 { color: #fff; font-size: clamp(18px, 3.4vw, 34px); text-shadow: 3px 3px 0 var(--c-hudShadow); max-width: 14em; }
.hero-copy { color: #fff; font-size: clamp(18px, 1.6vw, 21px); max-width: 34em; text-shadow: 1px 1px 0 rgba(0,0,0,.6); background: rgba(11,11,11,.28); padding: .6em .8em; border-left: 4px solid var(--c-accent); }
.hero-ctas { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 1.2em; }

/* ---------- beats (real HTML, pinned beside the action) ---------- */
.beat { position: absolute; width: min(440px, 42vw); padding: 20px 22px 22px; background: rgba(255,253,245,.94); border: 3px solid var(--c-ink); box-shadow: 6px 6px 0 var(--c-ink); opacity: 0; transform: translateY(14px); transition: opacity .45s ease, transform .45s ease; }
.beat.side-left { left: 6vw; } .beat.side-right { right: 6vw; }
.beat.active { opacity: 1; transform: translateY(0); }
.beat-label { font-family: var(--font-pixel); font-size: clamp(9px, 1.1vw, 11px); color: var(--c-danger); margin: 0 0 1.2em; letter-spacing: 1px; }
.beat h2 { font-size: clamp(12px, 1.6vw, 16px); }
.beat-copy { font-size: 18px; margin: 0; }

/* ---------- stall variant: sticky centered beats + typewriter ---------- */
.beat-hold-track { position: absolute; left: 0; right: 0; pointer-events: none; }
.beat-hold-track .beat { position: -webkit-sticky; position: sticky; width: min(520px, 88vw); margin: 0 auto; transform: translateY(10px); pointer-events: auto; }
.beat-hold-track .beat.active { transform: translateY(0); }
.ch { display: inline; }
.ch-hid { visibility: hidden; }

/* sampler text treatments */
.beat.scrollbox { background: rgba(10,12,24,.93); color: var(--c-paper); border-color: var(--c-paper); box-shadow: 6px 6px 0 rgba(0,0,0,.55); }
.beat.scrollbox .beat-label { color: var(--c-accent); }
.mq-window { display: block; overflow: hidden; white-space: nowrap; padding: 6px 0 4px; }
.mq-inner { display: inline-block; font-family: var(--font-pixel); font-size: clamp(11px, 1.4vw, 14px); line-height: 1.8; will-change: transform; }
.beat.posted .post-line { transition: opacity .2s; }
.post-line.line-hid { visibility: hidden; }
.stage-card { position: fixed; inset: 0; z-index: 4; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; background: rgba(5,8,20,.85); opacity: 0; pointer-events: none; transition: opacity .25s; font-family: var(--font-pixel); text-align: center; }
.stage-card.show { opacity: 1; }
.stage-kicker { color: var(--c-danger); font-size: clamp(10px, 1.6vw, 14px); margin: 0; letter-spacing: 2px; }
.stage-title { color: var(--c-paper); font-size: clamp(18px, 4vw, 40px); margin: 0; text-shadow: 4px 4px 0 #000; }

/* ---------- landing / form / leaderboard ---------- */
#landing { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 8vh 5vw; }
@media (min-width: 1000px) { #landing { justify-content: flex-end; padding-right: 6vw; } }
.panel { width: min(540px, 92vw); background: var(--c-paper); border: 4px solid var(--c-ink); box-shadow: 10px 10px 0 var(--c-ink); padding: 28px clamp(18px, 4vw, 36px) 30px; }
#landing.landed .panel { animation: floatin .7s cubic-bezier(.2,.9,.3,1.2) both; }
@keyframes floatin { from { opacity: 0; transform: translateY(40px) } to { opacity: 1; transform: none } }
.land-kicker { font-family: var(--font-pixel); color: var(--c-ground); font-size: 12px; margin: 0 0 .8em; }
.land-banner { font-family: var(--font-pixel); color: var(--c-danger); font-size: clamp(16px, 3vw, 26px); margin: 0 0 .4em; }
.land-score { font-family: var(--font-pixel); font-size: 14px; margin: 0 0 1.6em; }
.land-title { font-size: clamp(13px, 2vw, 18px); }
.land-intro { font-size: 18px; margin: 0 0 1.2em; }
.initials-row { display: flex; gap: 12px; margin-bottom: 1.2em; }
.initial { width: 58px; height: 62px; text-align: center; font-family: var(--font-pixel); font-size: 24px; border: 3px solid var(--c-ink); background: #fff; text-transform: uppercase; }
.initial:focus, #score-form input:focus, #score-form select:focus { outline: 3px solid var(--c-accent); outline-offset: 1px; }
#score-form label { display: block; font-size: 16px; font-weight: 600; margin: 0 0 .9em; }
#score-form input:not(.initial), #score-form select { display: block; width: 100%; font: 16px var(--font-body); padding: 10px 12px; border: 3px solid var(--c-ink); background: #fff; margin-top: 4px; min-height: 44px; }
.btn-arcade, .btn-ghost { display: inline-block; font-family: var(--font-pixel); font-size: 12px; padding: 14px 18px; border: 3px solid var(--c-ink); text-decoration: none; cursor: pointer; min-height: 44px; line-height: 1.2; }
.btn-arcade { background: var(--c-accent); color: var(--c-ink); box-shadow: 4px 4px 0 var(--c-ink); transition: transform .08s, box-shadow .08s; }
.btn-arcade:hover, .btn-arcade:focus { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--c-ink); }
.btn-ghost { background: rgba(255,255,255,.12); color: #fff; border-color: #fff; }
.land-reassure { font-size: 15px; opacity: .8; margin: 1em 0 0; }
.form-error { color: var(--c-danger); font-weight: 600; }
.leaderboard { list-style: none; margin: 0 0 1.2em; padding: 0; font-family: var(--font-pixel); font-size: clamp(10px, 1.5vw, 14px); }
.leaderboard li { display: grid; grid-template-columns: 2.2em 4em 1fr auto; gap: 14px; padding: 8px 6px; border-bottom: 2px dashed rgba(11,11,11,.25); white-space: pre; }
.leaderboard li.you { background: var(--c-accent); animation: youpulse 1.2s steps(2, end) 3; }
@keyframes youpulse { 50% { background: var(--c-paper); } }
.leaderboard .pts { text-align: right; } .leaderboard .tag { color: var(--c-danger); }
.confirm-line { font-size: 18px; font-weight: 600; }
.site-foot { padding: 20px 5vw 40px; color: #fff; font-size: 14px; opacity: .8; text-align: center; }

/* ---------- [G-0827] THE ARCADE SCREENS: the form and the board are PAGES, not sections ----------
   Grammar: game over → ENTER YOUR INITIALS owns the display → SUBMIT → HIGH SCORES owns the display.
   Both are the same DOM nodes the panel always held (#initials-screen, #confirm), repositioned to a
   fixed full-viewport view. No scrolling is involved in either, so the HUD collision, the cut-off
   panel and the footer creeping over the top are all structurally impossible.
   Dark backdrop + paper-bordered box = the .stage-card / .beat.scrollbox vocabulary already in use. */
.confirm-kicker { font-family: var(--font-pixel); color: var(--c-danger); font-size: clamp(14px, 2.6vw, 22px); margin: 0 0 .9em; }
.confirm-back { font-family: var(--font-pixel); font-size: 10px; letter-spacing: 1px; color: var(--c-ink); background: none; border: 2px solid rgba(11,11,11,.45); padding: 10px 14px; min-height: 44px; cursor: pointer; }
.confirm:not(.takeover) .confirm-back, .initials:not(.takeover) .confirm-back { display: none; }
/* [G-0831 RULED — final]: the white in-flow panel presentation is DEAD. The dark full-screen
   takeover is THE ONLY form presentation, ever. The panel node renders nothing in the page flow
   in any state; while a takeover screen is open the node passes through (display:contents) so
   its fixed-position screens can render. */
#landing-panel { display: none; }
html.takeover-open #landing-panel { display: contents; }
.confirm[hidden] { display: none; }  /* author rules beat the UA's [hidden] — say it out loud */
/* in flow the initials screen is the panel it always was: the wrappers carry no box at all */
.initials, .initials-inner { display: contents; }
.initials[hidden] { display: none; }

/* --- shared screen vocabulary (either screen up) --- */
html.takeover-open { overflow: hidden; }                       /* nothing scrolls behind a screen */
/* the panel's finished `floatin` keeps a filled identity transform, which would make it the containing
   block for our fixed screens — clear it while one is up (it is behind the backdrop anyway) */
html.takeover-open #landing .panel { animation: none; transform: none; }
/* the screen owns the display: the ride's HUD, the site nav and any stage card step aside (main is
   z-index 1, so its children can never paint over them from their own stacking contexts) */
html.takeover-open #hud, html.takeover-open #site-header, html.takeover-open .stage-card { display: none; }
.confirm.takeover, .initials.takeover { position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: center; background: rgba(5,8,20,.92); overflow-y: auto; animation: ct-in .18s steps(3, end) both; }
.confirm.takeover .confirm-inner, .initials.takeover .initials-inner { display: block; margin: auto; text-align: center; color: var(--c-ink); background: var(--c-paper); border: 4px solid var(--c-ink); box-shadow: 10px 10px 0 rgba(0,0,0,.55); }
.confirm.takeover .confirm-back, .initials.takeover .confirm-back { color: var(--c-ink); border-color: rgba(11,11,11,.45); }
.confirm.takeover .confirm-back:hover, .confirm.takeover .confirm-back:focus,
.initials.takeover .confirm-back:hover, .initials.takeover .confirm-back:focus { color: var(--c-accent); border-color: var(--c-accent); }
.confirm.takeover .land-title, .initials.takeover .land-title { letter-spacing: 2px; }
@keyframes ct-in { from { opacity: 0 } to { opacity: 1 } }

/* --- screen 1: ENTER YOUR INITIALS --- */
.initials.takeover { padding: clamp(10px, 2.4vh, 30px) 4vw; }
.initials.takeover .initials-inner { width: min(680px, 94vw); padding: clamp(18px, 2.6vw, 28px); }
.initials.takeover .land-kicker { font-size: clamp(10px, 1.7vw, 13px); letter-spacing: 2px; margin: 0 0 1em; }
.initials.takeover .land-banner { font-size: clamp(17px, 3.2vw, 28px); text-shadow: 3px 3px 0 #000; margin: 0 0 .5em; animation: flash 1s steps(2, end) 2; }
.initials.takeover .land-score { font-size: clamp(11px, 1.6vw, 14px); margin: 0 0 1.8em; }
.initials.takeover .land-title { font-size: clamp(12px, 2vw, 17px); margin: 0 0 .9em; }
.initials.takeover .land-intro { font-size: 16px; max-width: 46em; margin: 0 auto 1.4em; opacity: .9; }
.initials.takeover .initials-row { justify-content: center; gap: clamp(10px, 2vw, 18px); margin: 0 0 1.6em; }
.initials.takeover .initial { width: clamp(56px, 9vw, 76px); height: clamp(62px, 10vw, 82px); font-size: clamp(24px, 4vw, 32px); }
.initials.takeover .form-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 clamp(12px, 2vw, 20px); text-align: left; }
.initials.takeover #score-form label { margin: 0 0 .7em; }

.initials.takeover #score-form button[type=submit] { margin: .4em 0 0; box-shadow: 4px 4px 0 rgba(0,0,0,.55); }
.initials.takeover .land-reassure { font-size: 14px; margin: 1em auto 1.4em; max-width: 44em; }
.initials.takeover .form-error { margin: 0 0 1.2em; }

/* --- screen 2: HIGH SCORES (the confirmation) --- */
.confirm.takeover { padding: clamp(14px, 4vh, 48px) 5vw; }
.confirm.takeover .confirm-inner { width: min(560px, 92vw); padding: clamp(20px, 3.4vw, 34px); }
.confirm.takeover .confirm-kicker { font-size: clamp(15px, 3vw, 26px); text-shadow: 3px 3px 0 #000; animation: flash 1s steps(2, end) 4; }
.confirm.takeover .land-title { margin: 0 0 1.4em; }
.confirm.takeover .leaderboard { text-align: left; margin: 0 0 1.3em; }

.confirm.takeover .leaderboard li.you { color: var(--c-ink); }
.confirm.takeover .confirm-line { margin: 0 0 1.5em; }

/* ---------- website chrome (framing round v1: simple) ---------- */
#site-header { position: fixed; inset: 0 0 auto 0; z-index: 7; height: 54px; display: flex; align-items: center; gap: 26px; padding: 0 clamp(14px, 3vw, 32px); background: rgba(9, 10, 14, .92); border-bottom: 2px solid rgba(255,255,255,.08); }
.sh-logo { font-family: var(--font-pixel); font-size: 13px; color: var(--c-accent); text-decoration: none; letter-spacing: 1px; }
.sh-logo span { color: #fff; }
.sh-nav { display: flex; gap: 20px; margin-left: auto; }
.sh-nav a { color: #e8eaf0; text-decoration: none; font: 500 14px var(--font-body); opacity: .85; }
.sh-nav a:hover { opacity: 1; color: var(--c-accent); }
#site-header .sh-cta { font-size: 10px; padding: 10px 14px; min-height: 0; }
body.chrome-site #hud { top: 54px; background: none; padding-top: 10px; padding-bottom: 10px; }
body.chrome-site .hud-left, body.chrome-site .hud-right { background: rgba(0,0,0,.35); padding: 6px 10px; border-radius: 4px; }
.sf-site { background: #0b0c10; color: #c9cdd6; text-align: left; padding: 40px clamp(16px, 5vw, 60px) 28px; font-size: 14px; opacity: 1; }
.sf-cols { display: flex; gap: clamp(24px, 6vw, 80px); flex-wrap: wrap; padding-bottom: 22px; }
.sf-col { display: flex; flex-direction: column; gap: 8px; max-width: 340px; }
.sf-col a { color: #c9cdd6; text-decoration: none; }
.sf-col a:hover { color: var(--c-accent); }
.sf-h { font-family: var(--font-pixel); font-size: 10px; color: #ffffff; margin: 0 0 6px; }
.sf-legal { border-top: 1px solid rgba(255,255,255,.12); padding-top: 16px; margin: 0; font-size: 12px; opacity: .7; }
@media (max-width: 720px) { .sh-nav { display: none; } }

/* ---------- reduced motion: stepped scenes, everything readable ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .beat, .hud-banner, .hud-hint, .popup, #landing.landed .panel, .leaderboard li.you, .btn-arcade, .stage-card, .post-line,
  .confirm.takeover, .confirm.takeover .confirm-kicker, .initials.takeover, .initials.takeover .land-banner { transition: none; animation: none; }
  .beat { opacity: 1; transform: none; }
}

/* ---------- no-JS / crawler: clean stacked page ---------- */
html.no-js #scene, html.no-js #hud { display: none; }
html.no-js body { background: var(--c-skyHigh); }
html.no-js #track { height: auto !important; padding: 4vh 0; }
html.no-js .hero { position: static; min-height: 0; }
html.no-js .beat { position: static; opacity: 1; transform: none; width: min(640px, 90vw); margin: 24px auto; }
html.boot-failed #scene, html.boot-failed #hud { display: none; }
html.boot-failed .beat { opacity: 1; transform: none; }

/* ---------- mobile ---------- */
@media (max-width: 720px) {
  :root { --beat-top-offset: 9vh; }
  .hero { max-width: none; justify-content: flex-end; padding-bottom: 7vh; }
  .hero .hero-brand { margin-bottom: .8em; }
  .hero h1.hero-h1, .hero h1 { font-size: 16px !important; max-width: none; }
  .hero .hero-copy { font-size: 16px; padding: .5em .7em; }
  .hero-ctas { gap: 10px; }
  #hud { font-size: 10px; }
  .beat { width: 86vw; left: 7vw !important; right: auto !important; padding: 16px; }
  .beat-copy { font-size: 17px; }
  .hero { padding: 14vh 7vw; }
  .hud-right { gap: 10px; }
  /* the initials screen is a long form: tighten it so the whole page fits a phone without inner scroll */
  .initials.takeover { padding: 8px; }
  .initials.takeover .initials-inner { padding: 16px 14px 18px; }
  .initials.takeover .form-fields { grid-template-columns: 1fr; }
  .initials.takeover .land-kicker { margin-bottom: .7em; }
  .initials.takeover .land-score { margin-bottom: 1.2em; }
  .initials.takeover .land-intro { font-size: 15px; margin-bottom: 1.1em; }
  .initials.takeover .initials-row { margin-bottom: 1.1em; }
  .initials.takeover #score-form label { margin-bottom: .5em; font-size: 15px; }
  .initials.takeover .land-reassure { font-size: 13px; margin: .8em auto 1.1em; }
}
