/* v07 The Climb: tokens, sky, buttons, the snow card, transitions. */
:root {
  --ink: #141a45;
  --ink-2: #3b4372;
  --ink-3: #6b729a;
  --snow: #fbfcff;
  --snow-2: #eef1fb;
  --line: #dfe3f3;
  --rope: #ff5a4e;
  --sun-1: #ffb347;
  --sun-2: #ff6b4a;
  --good: #22b573;
  --good-soft: #e3f7ec;
  --bad: #ff5a4e;
  --bad-soft: #ffe9e6;
  --hold: #ffc94a;
  --hold-rim: #b86a00;
  --display: ui-serif, 'New York', 'Iowan Old Style', Georgia, serif;
  --ui: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --r: 22px;
  /* mountain colours (alpenglow) */
  --rock-lit-top: #7c86c4; --rock-lit-bot: #3d4688;
  --rock-sh-top: #4a4f92; --rock-sh-bot: #232860;
  --snow-lit: #fff3ef; --snow-sh: #c3c8ec;
  --sun: #ffb27a;
  --far: #6b5d9e; --mid: #3c3a7c; --near: #1a1d4d; --tree: #161a45;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #141a45; color: var(--ink); font: 500 16px/1.4 var(--ui); -webkit-font-smoothing: antialiased; }
body { overscroll-behavior: none; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- the sky (behind everything but the stage) ---------- */
.sky { position: fixed; inset: 0; z-index: 1; overflow: hidden; }
.sky-layer { position: absolute; inset: 0; opacity: 0; transition: opacity 1.2s ease; }
.sky-layer--dawn { background: linear-gradient(180deg, #0b1233 0%, #261f5c 38%, #7b3c78 64%, #ff8a5b 88%, #ffc27a 100%); }
.sky-layer--day { background: linear-gradient(180deg, #1c3a8c 0%, #3f74cf 40%, #8fc0f0 72%, #ffe2c2 100%); }
.sky-layer--storm { background: linear-gradient(180deg, #151a33 0%, #2c3256 45%, #5d6286 78%, #8e8faa 100%); }
.sky-layer--gold { background: linear-gradient(180deg, #121a4a 0%, #4a3a8e 40%, #e0707a 70%, #ffc06a 100%); }
.sky[data-sky=dawn] .sky-layer--dawn, .sky[data-sky=day] .sky-layer--day,
.sky[data-sky=storm] .sky-layer--storm, .sky[data-sky=gold] .sky-layer--gold { opacity: 1; }

/* ---------- the stage (the engine's 3D) ---------- */
.stage { position: fixed; left: 0; top: 0; width: calc(100% / var(--ss, 1)); height: calc(100% / var(--ss, 1)); transform: scale(var(--ss, 1)); transform-origin: 0 0; z-index: 3; display: none; }
.pt-mk .hold { zoom: var(--hz, 1); }
.stage.pt-stage { background: #0a2a17; }
body[data-phase=play] .stage, body[data-phase=reveal] .stage { display: block; }

/* ---------- the screen layer (pages over the sky) ---------- */
.screen { position: fixed; inset: 0; z-index: 10; overflow: hidden auto; -webkit-overflow-scrolling: touch; }
body[data-phase=play] .screen, body[data-phase=reveal] .screen { display: none; }

/* ---------- buttons ---------- */
.cta {
  position: relative; display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  min-height: 60px; padding: 16px 22px; border: 0; border-radius: 18px; cursor: pointer;
  background: linear-gradient(180deg, var(--sun-1), var(--sun-2)); color: #2a0d05;
  font: 800 19px/1.1 var(--ui); letter-spacing: .01em;
  box-shadow: 0 10px 24px -8px rgba(255, 90, 60, .7), inset 0 -3px 0 rgba(120, 30, 0, .25), inset 0 2px 0 rgba(255, 255, 255, .45);
  transition: transform .12s ease, box-shadow .12s ease;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.cta:active { transform: translateY(2px) scale(.985); box-shadow: 0 4px 12px -6px rgba(255, 90, 60, .7), inset 0 -1px 0 rgba(120, 30, 0, .25); }
.cta svg { width: 22px; height: 22px; flex: none; }
.cta[disabled] { cursor: progress; filter: saturate(.25) brightness(1.05); color: #6b4a3a; box-shadow: none; }
.cta.is-wait[disabled] { filter: none; opacity: .6; color: #2a0d05; cursor: default; }
.cta .spin { width: 18px; height: 18px; border-radius: 50%; border: 3px solid rgba(80, 40, 20, .25); border-top-color: #6b4a3a; animation: spin .8s linear infinite; }
.cta.is-pulse::after { content: ''; position: absolute; inset: -4px; border-radius: 22px; border: 3px solid rgba(255, 179, 71, .8); animation: ring 1.8s ease-out infinite; pointer-events: none; }
.cta--dark { background: var(--ink); color: #fff; box-shadow: 0 10px 24px -10px rgba(20, 26, 69, .8); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes ring { 0% { opacity: .9; transform: scale(.98); } 100% { opacity: 0; transform: scale(1.08); } }

/* keyboard focus: a white ring with a dark halo reads on the snow card and on the night sky alike */
.cta:focus-visible, .rate-n:focus-visible, .mute:focus-visible { outline: 3px solid #fff; outline-offset: 3px; box-shadow: 0 0 0 7px var(--ink); }
.pt-mk:focus-visible { outline: 3px solid #fff; outline-offset: 6px; border-radius: 50%; }
.fld-in input:focus-visible { outline: none; }

/* ---------- the snow card ---------- */
.card {
  position: relative; background: var(--snow); border-radius: var(--r); padding: 22px 20px 20px;
  box-shadow: 0 24px 60px -20px rgba(10, 12, 40, .6), 0 1px 0 rgba(255, 255, 255, .8) inset;
}
.kicker { display: inline-flex; align-items: center; gap: 8px; font: 800 12px/1 var(--ui); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-3); }
.kicker i { width: 8px; height: 8px; border-radius: 50%; background: var(--rope); }
.h1 { font: 900 clamp(34px, 9.4vw, 56px)/1.02 var(--display); letter-spacing: -.02em; margin: 0; }
.h2 { font: 900 clamp(26px, 7vw, 36px)/1.08 var(--display); letter-spacing: -.015em; margin: 0; }
.p { margin: 0; color: var(--ink-2); font-size: 16px; }

/* ---------- reveal-on-enter (motion on every state change) ---------- */
.in { animation: rise .55s cubic-bezier(.2, .8, .2, 1) both; animation-delay: calc(var(--d, 0) * 90ms + 60ms); }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
.pop { animation: pop .5s cubic-bezier(.2, 1.4, .4, 1) both; animation-delay: calc(var(--d, 0) * 90ms); }
@keyframes pop { from { opacity: 0; transform: scale(.6); } to { opacity: 1; transform: none; } }

/* ---------- the cloud wipe between worlds ---------- */
.wipe { position: fixed; inset: 0; z-index: 40; pointer-events: none; overflow: hidden; visibility: hidden; }
.wipe i { position: absolute; border-radius: 50%; background: radial-gradient(circle at 40% 40%, #fff 0 45%, rgba(236, 240, 255, .96) 62%, rgba(236, 240, 255, 0) 72%); width: 140vmax; height: 90vmax; }
.wipe i:nth-child(1) { left: -20vmax; top: -30vmax; }
.wipe i:nth-child(2) { left: 30vmax; top: 10vmax; }
.wipe i:nth-child(3) { left: -40vmax; top: 30vmax; }
.wipe i:nth-child(4) { left: 20vmax; top: -40vmax; }
.wipe.is-on { visibility: visible; animation: wipe 1s cubic-bezier(.6, 0, .4, 1) both; }
@keyframes wipe { 0% { transform: translateX(110%); } 45%, 55% { transform: translateX(0); } 100% { transform: translateX(-120%); } }

/* ---------- mute ---------- */
.mute { position: fixed; z-index: 45; top: calc(10px + var(--sat)); right: 10px; width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(20, 26, 69, .6); color: #fff; display: grid; place-items: center; }
.mute svg { width: 20px; height: 20px; }
body[data-phase=results] .mute { display: none; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; } }

/* the result scrolls the page itself (native scroll, full-page captures) */
/* html scrolls (it hands its overflow to the viewport); body must stay overflow:visible, or it becomes its own scroll
   box that never scrolls and every position:sticky inside (the laptop mountain, the phone Book bar) stops sticking */
html:has(body[data-phase=results]) { height: auto; min-height: 100%; overflow-x: hidden; overflow-y: auto; }
body[data-phase=results] { height: auto; min-height: 100%; overflow: visible; }
body[data-phase=results] .screen { position: relative; inset: auto; overflow: visible; }

/* during plays the sky + mountain sit under an opaque stage: take them out so they cost nothing per frame */
body[data-phase=play] .sky, body[data-phase=reveal] .sky { display: none; }
