/*
 * Kalibre landing page.
 *
 * Scroll-driven scenes: each <section data-scene> is several screens tall and
 * holds a sticky .stage. landing.js writes the scene's progress (0 to 1) to
 * --p, and any .t element turns that into its own local --t between --a and --b.
 * The same palette as the app (paper and ink); the themes scene overrides it
 * on its own section.
 */

@font-face {
    font-family: 'Atkinson Hyperlegible';
    src: url('./assets/static/fonts/atkinson-hyperlegible-latin-400-normal.woff2') format('woff2');
    font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'Atkinson Hyperlegible';
    src: url('./assets/static/fonts/atkinson-hyperlegible-latin-700-normal.woff2') format('woff2');
    font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'Atkinson Hyperlegible Mono';
    src: url('./assets/static/fonts/atkinson-hyperlegible-mono-latin-400-normal.woff2') format('woff2');
    font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'Atkinson Hyperlegible Mono';
    src: url('./assets/static/fonts/atkinson-hyperlegible-mono-latin-700-normal.woff2') format('woff2');
    font-weight: 700; font-style: normal; font-display: swap;
}

:root {
    --bg: #f6f5f1;
    --surface: #ecebe6;
    --text: #2b2a27;
    --dim: #67645c;
    --accent: #3d6b8f;
    --on-accent: #ffffff;
    --bad: #b0342b;
    --sep: #dcdad3;
    --font-ui: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-mono: "Atkinson Hyperlegible Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);
    /* the app's own finger colours (scripts/learn/finger-colours.js): little, ring, middle, index, thumb, then the right hand */
    --f-lp: #8e5cc4; --f-lr: #3b73c7; --f-lm: #2a9d8f; --f-li: #5c9c33; --f-t: #8a8a8a; --f-ri: #c9a227; --f-rm: #d9782d; --f-rr: #d0473f; --f-rp: #c9458a;
    --f-alpha: 30%;
    color-scheme: light;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #16181b;
        --surface: #1f2226;
        --text: #d9d7d0;
        --dim: #8b8e94;
        --accent: #7fb0d6;
        --on-accent: #16181b;
        --bad: #e8716a;
        --sep: #2c3035;
        --f-lp: #b58ae6; --f-lr: #6fa0f0; --f-lm: #4fc3b3; --f-li: #8cc764; --f-t: #a0a0a0; --f-ri: #e8c250; --f-rm: #f0a05a; --f-rr: #f07a70; --f-rp: #ec7ab5;
        --f-alpha: 24%;
        color-scheme: dark;
    }
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--bg); scroll-behavior: auto; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 400 1rem/1.55 var(--font-ui);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}
a { color: inherit; }
h1, h2, h3, p, ol, ul { margin: 0; padding: 0; }
ol, ul { list-style: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

/* ---- scenes ------------------------------------------------------------ */

.scene {
    --p: 0;
    position: relative;
    height: calc(var(--len, 300) * 1vh);
    background: var(--bg);
    color: var(--text);
    transition: background-color 700ms var(--ease), color 700ms var(--ease);
}
.stage {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100svh;
    display: grid;
    align-content: center;
    justify-items: center;
    padding: clamp(5rem, 11vh, 7rem) clamp(1.25rem, 5vw, 4rem) clamp(2rem, 6vh, 4rem);
    overflow: hidden;
}

/* a local 0-to-1 progress between --a and --b of the scene's progress */
.t {
    --a: 0;
    --b: 1;
    --t: clamp(0, calc((var(--p) - var(--a)) / (var(--b) - var(--a))), 1);
}
.t:not(.lockup):not(.scroll-cue):not(.hero-line) {
    opacity: var(--t);
    transform: translateY(calc((1 - var(--t)) * 2.2rem));
}

/* headings type themselves (landing.js makeTyper): they stay put and the letters arrive, with a caret */
html .t.typed:not(.lockup):not(.scroll-cue):not(.hero-line) { opacity: 1; transform: none; }
.tw { display: inline-block; white-space: nowrap; }
.ch { position: relative; opacity: 0; }
.ch.on { opacity: 1; }
/* a slip: the wrong letter sits in the right one's place, in red, until it is deleted (the layout never moves) */
.ch.wrong { opacity: 1; color: transparent; }
.ch .wr { position: absolute; left: 0; top: 0; font-style: normal; color: var(--bad); }
.ch.num { color: var(--accent); }
.slips { max-width: 34rem; color: var(--dim); font-size: clamp(0.95rem, 1.4vw, 1.1rem); text-wrap: balance; min-height: 3.1em; }
.typed.live .ch.caret-after::after, .typed.live .ch.caret-before::before {
    content: ""; position: absolute; top: 0.1em; bottom: 0.04em; width: 0; border-left: 0.055em solid var(--accent);
}
.ch.caret-after::after { right: -0.04em; }
.ch.caret-before::before { left: -0.04em; }
.typed.live.blink .ch::after, .typed.live.blink .ch::before { animation: caret 1.05s steps(1, end) infinite; }
@keyframes caret { 50% { opacity: 0; } }

.split {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
    gap: clamp(2rem, 6vw, 6rem);
    max-width: 1280px;
    margin-inline: auto;
    width: 100%;
    align-items: center;
}
.split.reverse .copy { order: 2; }
.stack { gap: clamp(1.25rem, 3.5vh, 2.5rem); text-align: center; width: 100%; max-width: 1180px; margin-inline: auto; }

.copy { display: grid; gap: 1.1rem; align-content: center; }
.copy.center { justify-items: center; text-align: center; max-width: 52rem; }
.eyebrow { font: 700 0.85rem/1 var(--font-ui); letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); }
h2 { font: 700 clamp(2rem, 5.2vw, 4.25rem)/1.05 var(--font-ui); letter-spacing: -0.02em; text-wrap: balance; }
.body { font-size: clamp(1.05rem, 1.7vw, 1.3rem); color: var(--dim); max-width: 34rem; text-wrap: pretty; }
.copy.center .body { max-width: 40rem; }
.body em { font-style: normal; color: var(--text); font-weight: 700; }
.huge { font: 700 clamp(2rem, 6.4vw, 5.2rem)/1.05 var(--font-ui); letter-spacing: -0.025em; text-wrap: balance; }
.accent { color: var(--accent); }

/* ---- buttons ----------------------------------------------------------- */

.cta { display: grid; justify-items: center; gap: 1.1rem; }
.btn-play {
    display: inline-block;
    padding: 1.15rem clamp(2.4rem, 6vw, 3.6rem);
    border-radius: 999px;
    background: var(--accent);
    color: var(--on-accent);
    font: 700 clamp(1.15rem, 2.2vw, 1.45rem)/1 var(--font-ui);
    border: 0;
    text-decoration: none;
    box-shadow: 0 14px 34px -14px color-mix(in srgb, var(--accent) 80%, transparent);
    transition: transform 220ms var(--ease), box-shadow 220ms var(--ease);
}
.btn-play:hover { transform: scale(1.04); box-shadow: 0 20px 44px -14px color-mix(in srgb, var(--accent) 85%, transparent); }
.btn-play:active { transform: scale(0.98); }
.btn-play:disabled { cursor: not-allowed; opacity: 0.55; box-shadow: none; }
.nav-play:disabled { cursor: not-allowed; border: 0; filter: saturate(0.4) brightness(0.9); }
.btn-play:disabled:hover, .btn-play:disabled:active { transform: none; box-shadow: none; }
.btn-kanary {
    font-size: 0.95rem;
    color: var(--dim);
    text-decoration: underline;
    text-decoration-color: transparent;
    text-underline-offset: 4px;
    transition: color 160ms, text-decoration-color 160ms;
}
.btn-kanary:hover, .btn-kanary:focus-visible { color: var(--text); text-decoration-color: currentColor; }

/* ---- nav --------------------------------------------------------------- */

.nav {
    position: fixed; inset: 0 0 auto 0; z-index: 10;
    display: flex; align-items: center; justify-content: space-between;
    height: 3.25rem; padding: 0 clamp(1.25rem, 4vw, 2.5rem);
    background: color-mix(in srgb, var(--nav-bg, var(--bg)) 72%, transparent);
    color: var(--nav-text, var(--text));
    -webkit-backdrop-filter: saturate(1.6) blur(14px);
    backdrop-filter: saturate(1.6) blur(14px);
    border-bottom: 1px solid transparent;
    transition: border-color 240ms, background-color 700ms var(--ease), color 700ms var(--ease);
}
.past-hero .nav { border-bottom-color: var(--sep); }
/* while the hero fills the top of the screen, the nav is dark and clear, whatever the page's scheme */
.on-film .nav { --nav-bg: #0d0f13; --nav-text: #ece9e2; --accent: #7fb0d6; --on-accent: #16181b; }
.on-film:not(.past-hero) .nav { background: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; }
.nav { transition: opacity 600ms var(--ease), border-color 240ms, background-color 700ms var(--ease), color 700ms var(--ease); }
.nav-mark { display: inline-flex; color: inherit; }
.nav-mark svg { height: 1.15rem; width: auto; }
.nav-play {
    padding: 0.4rem 1rem; border-radius: 999px; background: var(--accent); color: var(--on-accent);
    font: 700 0.85rem/1.2 var(--font-ui); text-decoration: none;
    opacity: 0; transform: translateY(-6px); pointer-events: none; visibility: hidden;
    transition: opacity 240ms var(--ease), transform 240ms var(--ease), visibility 0s 240ms;
}
.past-hero .nav-play { opacity: 1; transform: none; pointer-events: auto; visibility: visible; transition-delay: 0s; }

/* ---- hero: a film, then the title ------------------------------------- */

/* The hero is always dark (the film's last frame is), whatever the page's scheme. */
.hero {
    --bg: #0d0f13; --surface: #171a20; --text: #ece9e2; --dim: #b4b1a9; --accent: #7fb0d6;
    --on-accent: #16181b; --sep: #2c3035;
    background: #0d0f13;
    color-scheme: dark;
}
.hero .stage { place-items: center; align-content: stretch; grid-template-rows: minmax(0, 1fr); }
.film { position: absolute; inset: 0; background: #0d0f13; overflow: hidden; }
.film-still, .film-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.film-still { transition: opacity 500ms linear; }
/* while the film is starting, the stage is plain dark: the film itself opens from black */
html.film-playing:not(.film-running) .film-still { opacity: 0; }
.film-video { opacity: 0; transition: opacity 360ms linear; }
html.film-running .film-video, html.film-replay .film-video { opacity: 1; }
html.film-skipped:not(.film-replay) .film-video { opacity: 0; }
/* the film is 16:9 and its camera-work lives near the edges, so it is never cropped hard */
@media (max-aspect-ratio: 3/2), (min-aspect-ratio: 2/1) { .film-still, .film-video { object-fit: contain; } }
/* on a tall screen the film is the portrait one, scaled to the screen's width. Phones differ in height
   (browser bars come and go), so a little of its top and bottom is cut: everything that matters sits
   in the middle two-thirds of the frame, which every screen taller than 7:10 shows whole. */
@media (max-aspect-ratio: 4/5) { .film-still, .film-video { object-fit: cover; } }
.film picture { display: contents; }
/* the page's own darkening, as the title gives way to the tagline */
.film-shade { position: absolute; inset: 0; background: #0d0f13; opacity: calc(var(--p) * 0.62); pointer-events: none; }

.lockup, .tagline, .scroll-cue { grid-area: 1 / 1; position: relative; }
.lockup, .tagline { align-self: center; }
.lockup {
    display: grid; justify-items: center; gap: clamp(1.4rem, 4vh, 2.4rem); text-align: center;
    opacity: calc(1 - var(--t) * 1.15);
    transform: translateY(calc(var(--t) * -9vh)) scale(calc(1 - var(--t) * 0.28));
    transition: visibility 0s;
}
/* until the film is nearly over, the title waits */
html.js:not(.film-title) .lockup { visibility: hidden; }
.hero.lockup-off .lockup { visibility: hidden; pointer-events: none; }
.mark { display: flex; justify-content: center; color: var(--text); }
.mark svg { width: min(78vw, 44rem); height: auto; overflow: visible; }
.mark path { stroke-dasharray: 1; stroke-dashoffset: 0; }
@keyframes draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes rise { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: no-preference) {
    html.film-title .mark path { animation: draw 1.5s var(--ease) both; }
    html.film-title .mark path:nth-child(2) { animation-delay: 0.08s; }
    html.film-title .mark path:nth-child(3) { animation-delay: 0.16s; }
    html.film-title .mark path:nth-child(4) { animation-delay: 0.24s; }
    html.film-title .mark path:nth-child(5) { animation-delay: 0.32s; }
    html.film-title .mark path:nth-child(6) { animation-delay: 0.4s; }
    html.film-title .mark path:nth-child(7) { animation-delay: 0.48s; }
    html.film-title .lede { animation: rise 900ms 500ms var(--ease) both; }
    html.film-title .lockup .cta { animation: rise 900ms 700ms var(--ease) both; }
}
.lede { font-size: clamp(1.1rem, 2vw, 1.5rem); color: var(--dim); max-width: 30rem; text-wrap: balance; }
.btn-film {
    font: 400 0.95rem/1.2 var(--font-ui); color: var(--dim); background: none; border: 0; padding: 0.2rem 0;
    cursor: pointer; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 4px;
    transition: color 160ms, text-decoration-color 160ms;
}
.btn-film:hover, .btn-film:focus-visible { color: var(--text); text-decoration-color: currentColor; }

/* skip: a way out of the lock (and the only control on the film) */
.film-skip {
    position: absolute; right: clamp(1rem, 3vw, 2rem); bottom: clamp(1rem, 3.5vh, 2rem); z-index: 3;
    padding: 0.55rem 1.15rem; border-radius: 999px; cursor: pointer;
    font: 700 0.9rem/1 var(--font-ui); letter-spacing: 0.04em; text-transform: lowercase;
    color: #ece9e2; background: rgba(13, 15, 19, 0.72); border: 1px solid rgba(236, 233, 226, 0.28);
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
    opacity: 0; visibility: hidden;
}
.film-skip::after { content: " \2192"; }
.film-skip:hover, .film-skip:focus-visible { background: rgba(13, 15, 19, 0.9); border-color: rgba(236, 233, 226, 0.6); }
html.film-playing .film-skip, html.film-replay .film-skip { visibility: visible; animation: skip-in 500ms 1.2s var(--ease) forwards; }
html.film-playing .film-skip:focus-visible, html.film-replay .film-skip:focus-visible { animation: none; opacity: 1; }
@keyframes skip-in { to { opacity: 0.9; } }
html:not(.film-playing):not(.film-replay) .film-skip { display: none; }

/* the page is held still while the film plays */
html.film-playing, html.film-playing body { overflow: hidden; overscroll-behavior: none; }
html.film-playing body { touch-action: none; }
html.film-playing .nav { opacity: 0; visibility: hidden; }
html.film-playing .scroll-cue, html.film-playing .tagline { visibility: hidden; }
/* a replay hides the title and plays over the hero, without holding anything still */
html.film-replay .hero .lockup, html.film-replay .hero .tagline, html.film-replay .hero .scroll-cue { visibility: hidden; }

.tagline { display: grid; gap: 0.15em; text-align: center; pointer-events: none; }
.big { font: 700 clamp(2.4rem, 8.6vw, 7.5rem)/1.02 var(--font-ui); letter-spacing: -0.03em; }
.scroll-cue {
    align-self: end; justify-self: center; margin-bottom: 0.5rem;
    font-size: 0.8rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--dim);
    opacity: calc(1 - var(--t)); transform: none;
}
.scroll-cue::after { content: ""; display: block; width: 1px; height: 2.2rem; margin: 0.6rem auto 0; background: linear-gradient(var(--dim), transparent); animation: cue 1.8s ease-in-out infinite; }
/* on a short screen (a laptop's browser window, a phone with its bars up or on its side) the title fills the stage and the cue would sit on the buttons */
@media (max-height: 790px) { .scroll-cue { display: none; } }
@keyframes cue { 0%, 100% { transform: scaleY(0.4); transform-origin: top; } 50% { transform: scaleY(1); transform-origin: top; } }

.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0; }

/* ---- scene: notice (typed rows) --------------------------------------- */

.demo { width: 100%; }
.typed-rows { display: grid; gap: clamp(1.1rem, 3vh, 1.9rem); }
.row { display: grid; gap: 0.5rem; }
.row .line {
    font: 400 clamp(1.25rem, 2.6vw, 2rem)/1.4 var(--font-mono);
    background: var(--surface); border: 1px solid var(--sep); border-radius: 14px;
    padding: 0.9rem 1.2rem; min-height: 3.6rem; white-space: pre-wrap; overflow-wrap: anywhere;
}
.row .c { opacity: 0; transition: opacity 90ms; }
.row .c.on { opacity: 1; }
.row .c.bad { color: var(--bad); text-decoration: underline wavy; text-underline-offset: 5px; }
.row .c.cur { box-shadow: 2px 0 0 var(--accent); }
.row .chip {
    justify-self: start; font-size: 0.9rem; font-weight: 700; color: var(--bad);
    padding: 0.2rem 0.75rem; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent);
    opacity: 0; transform: translateY(-4px); transition: opacity 260ms var(--ease), transform 260ms var(--ease);
}
.row.done .chip { opacity: 1; transform: none; }

/* ---- scene: train (chart) --------------------------------------------- */

.card { background: var(--surface); border: 1px solid var(--sep); border-radius: 22px; padding: clamp(1.1rem, 2.4vw, 1.9rem); box-shadow: 0 30px 60px -34px rgba(0, 0, 0, 0.35); }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.slip { color: var(--dim); }
.slip b { font-family: var(--font-mono); color: var(--text); margin-left: 0.4rem; }
.badge { padding: 0.25rem 0.9rem; border-radius: 999px; font-weight: 700; font-size: 0.9rem; background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); transition: background-color 400ms, color 400ms; }
.badge[data-state="improving"] { background: color-mix(in srgb, #c88a1a 18%, transparent); color: #a8700f; }
.badge[data-state="mastered"] { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
@media (prefers-color-scheme: dark) { .badge[data-state="improving"] { color: #e0b055; } }
.chart { width: 100%; height: clamp(10rem, 28vh, 17rem); overflow: visible; }
.chart .grid { stroke: var(--sep); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 4; stroke-linecap: round; vector-effect: non-scaling-stroke; stroke-dasharray: 1; stroke-dashoffset: calc(1 - var(--draw, 0)); }
.chart .dot { fill: var(--accent); }
.axis { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--dim); margin-top: 0.5rem; }

/* ---- scene: lessons (keyboard) ---------------------------------------- */

.keys-wrap { display: flex; align-items: center; justify-content: center; gap: clamp(0.75rem, 3vw, 2.5rem); width: 100%; }
.buddy { width: clamp(3.4rem, 9vw, 6.5rem); flex: none; }
.buddy .mascot-drawing { display: block; width: 100%; height: auto; overflow: visible; transform-origin: 50% 94%; }

/* Cal and Libby, as in the app (learn/cal-mascot.css, cal-animation.css): a few frames a second, on purpose. */
.mascot-cap { fill: var(--surface); stroke: var(--text); stroke-width: 2.5; }
.mascot-top { fill: var(--bg); stroke: var(--sep); stroke-width: 1.5; }
.mascot-leg, .mascot-limb, .mascot-paw { fill: var(--text); }
.mascot-letter { fill: var(--accent); font: 700 15px var(--font-mono); }
.mascot-eye, .mascot-mouth, .mascot-bump, .mascot-lash { fill: none; stroke: var(--text); stroke-linecap: round; stroke-linejoin: round; }
.mascot-eye { stroke-width: 4.5; transform-box: fill-box; transform-origin: center; }
/* closed (happy) eyes are thin lines in the app, not the open eyes' thick dots */
.buddy[data-state="happy"] .mascot-eye, .buddy[data-state="highfive"] .mascot-eye { stroke-width: 2.25; }
.mascot-mouth { stroke-width: 2; }
.mascot-bump { stroke-width: 2; opacity: 0.55; }
.mascot-lash { stroke-width: 1.4; }
/* the arms swing about the shoulder. transform-box: view-box measures from the drawing's own origin (0,0), not from
   the viewBox's corner, so these are the app's own numbers (cal-drawing.js SHOULDER) and the arm stays on the body */
.swing { transform-box: view-box; }
.swing.right { transform-origin: 62.5px 30px; }
.swing.left { transform-origin: 1.5px 30px; }
.buddy.right { --lag: -0.7s; }
.buddy[data-state="idle"] .mascot-drawing { animation: bob 1.6s steps(1, end) var(--lag, 0s) infinite; }
.buddy[data-state="idle"] .mascot-eye, .buddy[data-state="watching"] .mascot-eye, .buddy[data-state="ready"] .mascot-eye { animation: blink 4.4s steps(1, end) var(--lag, 0s) infinite; }
.buddy[data-state="watching"] .mascot-drawing { animation: bob 2.4s steps(1, end) var(--lag, 0s) infinite; }
.buddy[data-state="ready"] .swing.right { animation: wave 1s steps(1, end) var(--lag, 0s) infinite; }
.buddy[data-state="happy"] .mascot-drawing { animation: hop 0.6s steps(1, end) var(--lag, 0s) infinite; }
.buddy[data-state="highfive"] .mascot-drawing { animation: hop 0.5s steps(1, end) var(--lag, 0s) infinite; }
.buddy[data-state="highfive"] .swing.right { transform: translateY(-3px) rotate(-165deg); }
/* touched, as in the app (cal-animation.css): petted they purr and a heart floats up, poked they jump, tickled they wriggle */
.buddy { position: relative; touch-action: none; -webkit-user-select: none; user-select: none; }
.buddy .mascot-drawing { cursor: grab; -webkit-tap-highlight-color: transparent; }
.buddy.is-petted .mascot-drawing { cursor: grabbing; }
.mascot-heart { display: none; fill: var(--bad); stroke: none; }
.buddy.is-petted .mascot-heart { display: inline; animation: heart 1.2s steps(4, end) infinite; }
.buddy.is-petted[data-state] .mascot-drawing { animation: purr 0.24s steps(1, end) infinite; }
.buddy.is-poked[data-state] .mascot-drawing { animation: jolt 0.36s steps(1, end); }
.buddy.is-tickled[data-state] .mascot-drawing { animation: wriggle 0.2s steps(1, end) infinite; }
.buddy.is-petted .mascot-eye, .buddy.is-poked .mascot-eye, .buddy.is-tickled .mascot-eye { stroke-width: 2.25; animation: none; }
@keyframes purr { 0% { transform: translateX(0); } 50% { transform: translateX(0.6px) rotate(0.6deg); } }
@keyframes jolt { 0% { transform: translateY(0); } 25% { transform: translateY(1px) scale(1.06, 0.9); } 50% { transform: translateY(-4px) scale(0.96, 1.05); } 75% { transform: translateY(-1px); } }
@keyframes wriggle { 0% { transform: rotate(-4deg) translateY(-1px); } 50% { transform: rotate(4deg); } }
@keyframes heart { 0% { transform: translateY(0); opacity: 1; } 100% { transform: translateY(-10px); opacity: 0; } }
/* what they say */
.buddy-bubble {
    position: absolute; bottom: calc(100% + 0.5rem); z-index: 6; width: max-content; max-width: min(12rem, 46vw); margin: 0;
    padding: 0.5rem 0.7rem; border: 1px solid var(--sep); border-radius: 12px; background: var(--surface); color: var(--text);
    font: 400 0.82rem/1.35 var(--font-ui); text-align: left; box-shadow: 0 8px 22px -14px rgba(0, 0, 0, 0.5);
    opacity: 0; transform: translateY(4px); pointer-events: none; transition: opacity 200ms linear, transform 200ms var(--ease);
}
.buddy.left .buddy-bubble { left: 0; }
.buddy.right .buddy-bubble { right: 0; }
.buddy.is-speaking .buddy-bubble { opacity: 1; transform: none; }
@keyframes bob { 0% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
@keyframes blink { 0% { transform: scaleY(1); } 94% { transform: scaleY(0.15); } 98% { transform: scaleY(1); } }
@keyframes hop { 0% { transform: translateY(0); } 33% { transform: translateY(-5px); } 66% { transform: translateY(-2px); } }
@keyframes wave { 0% { transform: rotate(-142deg); } 50% { transform: rotate(-158deg); } }
.keyboard { display: grid; gap: clamp(0.3rem, 0.8vw, 0.55rem); justify-items: center; flex: 0 1 46rem; }
.krow { display: flex; gap: clamp(0.3rem, 0.8vw, 0.55rem); justify-content: center; width: 100%; }
.krow.home { padding-left: 3%; }
.krow.bottom { padding-left: 8%; }
.key {
    --f: var(--dim);
    flex: 1 1 0; max-width: 3.7rem; aspect-ratio: 1; display: grid; place-items: center;
    border-radius: 10px; border: 1px solid var(--sep); background: var(--surface); color: var(--dim);
    font: 700 clamp(0.7rem, 1.6vw, 1.05rem)/1 var(--font-mono); text-transform: lowercase;
    transition: background-color 380ms var(--ease), color 380ms, transform 380ms var(--ease), border-color 380ms;
}
/* a key takes its finger's colour the way the app's diagram does: the colour at a fraction over the surface, the letter stays the text colour */
.key.f0 { --f: var(--f-lp); } .key.f1 { --f: var(--f-lr); } .key.f2 { --f: var(--f-lm); } .key.f3 { --f: var(--f-li); } .key.ft { --f: var(--f-t); }
.key.f4 { --f: var(--f-ri); } .key.f5 { --f: var(--f-rm); } .key.f6 { --f: var(--f-rr); } .key.f7 { --f: var(--f-rp); }
.key.lit {
    background: color-mix(in srgb, var(--f) var(--f-alpha), var(--surface)); border-color: var(--f); color: var(--text); transform: translateY(-3px);
}
.key.space { width: 46%; max-width: none; aspect-ratio: auto; height: clamp(1.9rem, 4.4vw, 3rem); justify-self: center; }
.caption { min-height: 1.6em; font-size: clamp(1.1rem, 2vw, 1.5rem); color: var(--dim); }

/* ---- scene: games ------------------------------------------------------ */

.game-list { display: grid; gap: 0.15rem; margin-top: 1rem; }
.game-list li {
    font: 700 clamp(1.4rem, 3.2vw, 2.6rem)/1.15 var(--font-ui); letter-spacing: -0.02em;
    color: color-mix(in srgb, var(--text) 24%, transparent);
    transition: color 320ms var(--ease), transform 320ms var(--ease);
}
.game-list li.is-active { color: var(--text); transform: translateX(0.6rem); }
.game-list li .g-line { display: none; }
html:not(.js) .game-list li { font-size: 1.1rem; color: var(--text); margin-bottom: 0.9rem; }
html:not(.js) .game-list li .g-line { display: block; font: 400 1rem/1.5 var(--font-ui); color: var(--dim); letter-spacing: 0; }
html:not(.js) .game-card { display: none; }
/* the card shows the app's own card demo: the real game, played by the app's own scripted player */
.game-card {
    display: grid; background: var(--surface); border: 1px solid var(--sep); border-radius: 28px;
    overflow: hidden; box-shadow: 0 30px 70px -40px rgba(0, 0, 0, 0.4);
}
.game-screen { position: relative; width: 100%; aspect-ratio: 1098 / 381; background: var(--bg); border-bottom: 1px solid var(--sep); }
.game-screen video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity 220ms linear; }
.game-screen video.is-active { opacity: 1; }
.game-info { display: grid; gap: 0.8rem; padding: clamp(1.1rem, 2.4vw, 1.9rem) clamp(1.2rem, 3vw, 2.2rem) clamp(1.2rem, 2.6vw, 2rem); text-align: left; }
.game-name { font: 700 clamp(1.6rem, 3vw, 2.4rem)/1.1 var(--font-mono); letter-spacing: -0.01em; color: var(--accent); }
.game-line { color: var(--dim); font-size: clamp(1rem, 1.5vw, 1.2rem); min-height: 4.6em; text-wrap: pretty; }
.rail { width: 100%; height: 4px; border-radius: 4px; background: var(--sep); overflow: hidden; }
.rail span { display: block; height: 100%; background: var(--accent); transform-origin: left; transform: scaleX(var(--p)); }

/* ---- scene: themes ----------------------------------------------------- */

.window {
    width: min(100%, 46rem); text-align: left; background: var(--surface); border: 1px solid var(--sep);
    border-radius: 18px; overflow: hidden; box-shadow: 0 30px 70px -40px rgba(0, 0, 0, 0.5);
    transition: background-color 700ms var(--ease), border-color 700ms;
}
.window-bar { display: flex; align-items: center; gap: 0.4rem; padding: 0.7rem 1rem; border-bottom: 1px solid var(--sep); color: var(--dim); font-size: 0.85rem; transition: border-color 700ms; }
.window-bar i { width: 0.7rem; height: 0.7rem; border-radius: 50%; background: var(--sep); }
.window-bar span { margin-left: auto; font-weight: 700; letter-spacing: 0.04em; }
.sample { font: 400 clamp(1.3rem, 3vw, 2.1rem)/1.6 var(--font-mono); padding: clamp(1.2rem, 3vw, 2.2rem); min-height: 9.5rem; color: var(--dim); }
.sample .c.ok { color: var(--text); }
.sample .c.bad { color: var(--bad); text-decoration: underline wavy; text-underline-offset: 6px; }
.sample .c.cur { box-shadow: 2px 0 0 var(--accent); }
.swatches { display: flex; flex-wrap: wrap; gap: 0.5rem 0.75rem; justify-content: center; }
.swatches li {
    display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.3rem 0.85rem 0.3rem 0.4rem;
    border-radius: 999px; border: 1px solid var(--sep); font-size: 0.9rem; color: var(--dim);
    transition: color 300ms, border-color 300ms, background-color 300ms;
}
.swatches li i { width: 1.1rem; height: 1.1rem; border-radius: 50%; background: var(--sw-bg); border: 3px solid var(--sw-accent); }
.swatches li.is-active { color: var(--text); border-color: var(--accent); background: var(--surface); }

/* ---- scene: private ---------------------------------------------------- */

.says { display: grid; gap: clamp(0.9rem, 2.4vh, 1.5rem); margin-top: 0.4rem; }
.say-item { display: grid; gap: 0.35rem; opacity: 0; transition: opacity 500ms var(--ease); }
.say-item.is-past { opacity: 0.42; }
.say-item.is-current { opacity: 1; }
.say { font: 700 clamp(1.55rem, 3.1vw, 2.7rem)/1.08 var(--font-ui); letter-spacing: -0.02em; text-wrap: balance; }
.say-item.emph .say { color: var(--accent); font-size: clamp(1.75rem, 3.7vw, 3.2rem); }
.sub { color: var(--dim); font-size: clamp(0.95rem, 1.3vw, 1.1rem); max-width: 30rem; text-wrap: pretty; opacity: 0; transition: opacity 400ms var(--ease); }
.say-item.is-current .sub { opacity: 1; }
.diagram svg { display: block; width: 100%; height: auto; max-height: 78vh; overflow: visible; }
.diagram .badge { fill: var(--surface); stroke: var(--sep); stroke-width: 2; }
.diagram .icon { fill: none; stroke: var(--text); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.diagram .cap { font: 700 13px var(--font-ui); fill: var(--dim); text-anchor: middle; letter-spacing: 0.04em; }
.diagram .slash { fill: none; stroke: var(--bad); stroke-width: 5.5; stroke-linecap: round; stroke-dasharray: 1; stroke-dashoffset: 1; transition: stroke-dashoffset 600ms var(--ease); }
.diagram .sat { opacity: 0.4; transition: opacity 500ms var(--ease); }
.diagram.on-0 .sat-0, .diagram.on-1 .sat-1, .diagram.on-3 .sat-3 { opacity: 1; }
.diagram.on-0 .slash-0, .diagram.on-1 .slash-1, .diagram.on-3 .slash-3 { stroke-dashoffset: 0; }
.diagram .wire { fill: none; stroke: var(--dim); stroke-width: 2; stroke-dasharray: 3 7; stroke-linecap: round; opacity: 0.7; transition: opacity 500ms; }
.diagram.on-0 .w-0, .diagram.on-1 .w-1, .diagram.on-3 .w-3 { opacity: 0.12; }
.diagram .dev { fill: var(--bg); stroke: var(--text); stroke-width: 3.2; transition: stroke 500ms; }
.diagram .dev-in { fill: var(--surface); stroke: var(--sep); stroke-width: 1.5; }
.diagram.on-2 .dev { stroke: var(--accent); }
.diagram .pv-mark { fill: none; stroke: var(--text); stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.diagram .pv-rule { fill: none; stroke: var(--sep); stroke-width: 5; stroke-linecap: round; }
.diagram .pv-text { font: 700 15px var(--font-mono); fill: var(--text); }
.diagram .pv-reveal { transform-box: fill-box; transform-origin: 0 50%; animation: pv-type 4.6s steps(19, end) infinite; }
.diagram .pv-caret { fill: var(--accent); animation: pv-caret 4.6s steps(19, end) infinite; }
@keyframes pv-type { 0% { transform: scaleX(0); } 80%, 100% { transform: scaleX(0.9); } }
@keyframes pv-caret { 0% { transform: translateX(0); } 80%, 100% { transform: translateX(171px); } }
.diagram .pill { opacity: 0; transition: opacity 400ms; }
.diagram .pill rect { fill: var(--bad); }
.diagram .pill text { font: 700 10px var(--font-ui); fill: #fff; text-anchor: middle; dominant-baseline: central; }
.diagram.on-3 .pill { opacity: 1; }
.diagram .lock { opacity: 0; transition: opacity 400ms; }
.diagram .lock circle { fill: var(--accent); }
.diagram .lock rect { fill: var(--on-accent); }
.diagram .lock path { fill: none; stroke: var(--on-accent); stroke-width: 2.6; stroke-linecap: round; }
.diagram.on-2 .lock { opacity: 1; }
.diagram .on-device { fill: var(--text); opacity: 0.55; transition: fill 500ms, opacity 500ms; }
.diagram.on-2 .on-device { fill: var(--accent); opacity: 1; }
.diagram .block { fill: none; stroke: var(--bad); stroke-width: 5; stroke-linecap: round; opacity: 0; transform: rotate(-16deg); transform-origin: 312px 150px; transition: opacity 400ms; }
.diagram.on-2 .block { opacity: 1; }
.diagram .chips { opacity: 0; transition: opacity 400ms; }
.diagram.on-2 .chips { opacity: 1; }
.diagram .chip rect { fill: var(--bg); stroke: var(--accent); stroke-width: 2; }
.diagram .chip text { font: 700 13px var(--font-mono); fill: var(--text); text-anchor: middle; dominant-baseline: central; }
.diagram .chip { transform: translate(322px, 238px); }
.diagram.on-2 .chip { animation: pv-try 3s steps(1, end) infinite; }
.diagram.on-2 .c2 { animation-delay: 0.45s; }
.diagram.on-2 .c3 { animation-delay: 0.9s; }
/* up to the edge of the device, a shove at the wall, and back in: a few frames a second, like the rest */
@keyframes pv-try {
    0% { transform: translate(322px, 238px); }
    12% { transform: translate(322px, 214px); }
    24% { transform: translate(322px, 190px); }
    36% { transform: translate(322px, 168px); }
    44% { transform: translate(322px, 160px); }
    52% { transform: translate(322px, 168px); }
    60% { transform: translate(322px, 184px); }
    72% { transform: translate(322px, 210px); }
    84%, 100% { transform: translate(322px, 238px); }
}
@media (max-width: 860px) {
    .privacy .demo { order: -1; }
    .privacy .copy { gap: 0.5rem; }
    .say-item:not(.is-current) { display: none; }
    .diagram svg { max-height: 40vh; }
    .say, .say-item.emph .say { font-size: clamp(1.5rem, 7vw, 2.2rem); }
}
@media (prefers-reduced-motion: reduce) {
    .say-item, .say-item.is-past, .say-item.is-current, .say-item .sub { opacity: 1; display: grid !important; }
    .diagram .sat { opacity: 1; }
    .diagram .pv-reveal, .diagram .pv-caret, .diagram .chip { animation: none; }
    .diagram .pv-reveal { transform: scaleX(0.9); }
    .diagram .pv-caret { transform: translateX(171px); }
    .diagram .chip { transform: translate(322px, 238px); }
}
html:not(.js) .say-item, html:not(.js) .say-item .sub { opacity: 1; display: grid !important; }
html:not(.js) .diagram .sat { opacity: 1; }
html:not(.js) .diagram .slash { stroke-dashoffset: 0; }

/* ---- scene: more ------------------------------------------------------- */

.more { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(0.8rem, 1.6vw, 1.3rem); width: 100%; text-align: left; }
.more li { background: var(--surface); border: 1px solid var(--sep); border-radius: 20px; padding: clamp(1rem, 2vw, 1.6rem); display: grid; gap: 0.4rem; align-content: start; }
.more h3 { font: 700 clamp(1.1rem, 1.8vw, 1.45rem)/1.2 var(--font-ui); }
.more p { color: var(--dim); font-size: clamp(0.92rem, 1.2vw, 1.05rem); }

/* ---- scene: finale ----------------------------------------------------- */

/* The app's own views, looping at the app's own few frames a second, gather round the invitation.
   Each tile flies in from its own edge (--fx, --fy) between --a and --b of the scene, settling at a slight tilt. */
.finale .stage.stack { max-width: none; }  /* the tiles reach to the screen's edges */
.finale .huge { font-size: clamp(2rem, 5vw, 4.2rem); position: relative; z-index: 2; }
.finale .cta { position: relative; z-index: 2; }
.tiles { position: absolute; inset: 0; pointer-events: none; }
.tile {
    --t: clamp(0, calc((var(--p) - var(--a)) / (var(--b) - var(--a))), 1);
    --e: calc(1 - (1 - var(--t)) * (1 - var(--t)));
    --tw: clamp(10rem, min(24vw, 40vh), 22rem);
    position: absolute;
    left: calc(var(--x) * 1%);
    top: calc(var(--y) * 1%);
    width: calc(var(--tw) * var(--s, 1));
    margin: 0;
    translate: -50% -50%;
    opacity: min(1, calc(var(--e) * 2.4));
    transform:
        translate(calc((1 - var(--e)) * var(--fx) * 1vw), calc((1 - var(--e)) * var(--fy) * 1vh))
        rotate(calc(var(--r) * 1deg + (1 - var(--e)) * var(--fx) * 0.35deg))
        scale(calc(0.7 + 0.3 * var(--e)));
}
.tile .screen {
    position: relative;
    aspect-ratio: 960 / 628;
    overflow: hidden;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--sep);
    box-shadow: 0 18px 40px -22px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.08);
}
.tile picture, .tile img, .tile video { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.tile video { object-fit: cover; opacity: 0; transition: opacity 240ms linear; }
.tile.is-playing video { opacity: 1; }
.tile figcaption { margin-top: 0.5rem; text-align: center; font: 400 0.8rem/1 var(--font-ui); color: var(--dim); }
@media (max-width: 600px), (max-aspect-ratio: 4/5) {
    /* a phone, or any tall screen: four above the invitation, four below, overlapping like prints on a table */
    .tile { --tw: min(40vw, 25vh); left: calc(var(--px) * 1%); top: calc(var(--py) * 1%); }
    .tile .screen { border-radius: 9px; }
}
@media (max-width: 600px) { .tile figcaption { display: none; } }
html:not(.js) .tile { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
    .tile { transform: rotate(calc(var(--r) * 1deg)); opacity: 1; }
}

/* ---- footer ------------------------------------------------------------ */

.foot { display: flex; justify-content: space-between; gap: 1rem; padding: 1.4rem clamp(1.25rem, 4vw, 2.5rem); font-size: 0.85rem; color: var(--dim); border-top: 1px solid var(--sep); }

/* ---- small screens ----------------------------------------------------- */

@media (max-width: 860px) {
    .split { grid-template-columns: 1fr; gap: 1.6rem; align-content: center; }
    .split.reverse .copy { order: 0; }
    .copy { gap: 0.8rem; }
    .stage { padding-top: 4.5rem; }
    .more { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .game-list { display: none; }
    .keys-wrap { flex-wrap: wrap; }
    .keys-wrap .keyboard { order: -1; flex-basis: 100%; }
    .buddy { width: 4.2rem; }
    
}
@media (max-width: 520px) {
    /* a plain list with its descriptions, not cards: six cards with text would not fit a phone's screen */
    .more { grid-template-columns: 1fr; gap: 0; }
    .more li { background: none; border: 0; border-top: 1px solid var(--sep); border-radius: 0; padding: 0.7rem 0.1rem; gap: 0.15rem; }
    .more li:last-child { border-bottom: 1px solid var(--sep); }
    .more h3 { font-size: 1.05rem; }
    .more p { font-size: 0.86rem; line-height: 1.38; }
    .typed-rows { gap: 0.7rem; }
}
/* on a short screen the pinned stage has no room for the descriptions: titles only */
@media (max-width: 860px) and (max-height: 700px) { .more p { display: none; } }

/* ---- no motion, or no script: every scene shows its finished state ----- */

html:not(.js) .scene { --p: 1; height: auto; }
html:not(.js) .stage { position: static; height: auto; min-height: 100svh; }
html:not(.js) .lockup { opacity: 1; transform: none; }
html:not(.js) .film-video, html:not(.js) .btn-film { display: none; }
html:not(.js) .tagline { grid-area: auto; }
html:not(.js) .scroll-cue { display: none; }
@media (prefers-reduced-motion: reduce) {
    .scene { --p: 1; height: auto; }
    .stage { position: static; height: auto; min-height: 100svh; }
    .lockup { opacity: 1; transform: none; }
    .tagline { grid-area: auto; margin-top: 2rem; }
    .hero .stage { align-content: center; gap: 2rem; }
    .scroll-cue { display: none; }
    .scroll-cue::after { animation: none; }
    .film-video { display: none; }
    html.film-replay .film-video { display: block; }
    .buddy *, .buddy .mascot-drawing { animation: none !important; }
    .hero.lockup-off .lockup { visibility: visible; pointer-events: auto; }
    .game-list li { color: var(--text); }
    .nav-play { opacity: 1; transform: none; pointer-events: auto; visibility: visible; }
}
