/* Fluenics landing: the app's own tokens (theme/tokens.ts), warm stone and paper,
   umber ink, lapis for the one thing to press, malachite for what you know. */

:root {
  --bg: #F4EEE3;
  --surface: #FFFBF4;
  --sunken: #EAE1D1;
  --border: #DFD3BF;
  --border-strong: #C4B49A;
  --ink: #2A2118;
  --ink-soft: #6B5D4E;
  --ink-muted: #9A8B78;
  --accent: #27509B;
  --accent-pressed: #1D3F7E;
  --on-accent: #FFF9EE;
  --accent-soft: #DEE6F5;
  --accent-ink: #1D3F7E;
  --positive: #1F7558;
  --positive-soft: #DCEDE3;
  --caution: #A66A12;
  --caution-soft: #F5E6C8;
  --danger: #AE3D2A;
  --danger-soft: #F6DED6;
  --slab: #2E251B;
  --slab-raised: #3D3225;
  --slab-border: #524434;
  --on-slab: #F6ECDA;
  --on-slab-soft: #C2B198;
  --slab-accent: #E3B55C;
  --heat0: #E6DCCA;
  --heat1: #C9DBCB;
  --heat2: #8FC0A6;
  --heat3: #4A9A7B;
  --heat4: #1F7558;
  --shadow: 0 18px 50px rgba(74, 58, 36, 0.18);
  --shallows-alpha: 0.6;
  --display: 'Marcellus', 'Palatino Linotype', 'Book Antiqua', Georgia, serif;
  --phrase: 'Source Serif 4', Georgia, 'Times New Roman', serif;
  --ui: 'Source Sans 3', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --gutter: 20px;
  --max: 1120px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15120E; --surface: #201B15; --sunken: #1A1611; --border: #372F24; --border-strong: #55493A;
    --ink: #F3E9D8; --ink-soft: #BFB09A; --ink-muted: #8C7E6B;
    --accent: #8DB0F2; --accent-pressed: #A9C4F6; --on-accent: #10203F; --accent-soft: #1F2B45; --accent-ink: #B7CDF8;
    --positive: #6FCBA6; --positive-soft: #17302A; --caution: #E3B55C; --caution-soft: #3A2D14; --danger: #F08C74; --danger-soft: #3D1E17;
    --slab: #2A231A; --slab-raised: #372E22; --slab-border: #4B3F30; --on-slab: #F6ECDA; --on-slab-soft: #B9A98F; --slab-accent: #E3B55C;
    --heat0: #2F281F; --heat1: #1E3A30; --heat2: #27624E; --heat3: #3F9272; --heat4: #6FCBA6;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
    --shallows-alpha: 0.4;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #15120E; --surface: #201B15; --sunken: #1A1611; --border: #372F24; --border-strong: #55493A;
  --ink: #F3E9D8; --ink-soft: #BFB09A; --ink-muted: #8C7E6B;
  --accent: #8DB0F2; --accent-pressed: #A9C4F6; --on-accent: #10203F; --accent-soft: #1F2B45; --accent-ink: #B7CDF8;
  --positive: #6FCBA6; --positive-soft: #17302A; --caution: #E3B55C; --caution-soft: #3A2D14; --danger: #F08C74; --danger-soft: #3D1E17;
  --slab: #2A231A; --slab-raised: #372E22; --slab-border: #4B3F30; --on-slab: #F6ECDA; --on-slab-soft: #B9A98F; --slab-accent: #E3B55C;
  --heat0: #2F281F; --heat1: #1E3A30; --heat2: #27624E; --heat3: #3F9272; --heat4: #6FCBA6;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.5);
  --shallows-alpha: 0.4;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.55 var(--ui);
  overflow-x: hidden;
}
img, canvas, svg { display: block; max-width: 100%; }
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent-pressed); }
h1, h2, h3 { font-family: var(--display); font-weight: 400; line-height: 1.15; margin: 0 0 .4em; letter-spacing: .005em; }
h1 { font-size: clamp(2.3rem, 6.4vw, 3.9rem); }
h2 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h3 { font-size: 1.3rem; }
p { margin: 0 0 1em; }
.phrase { font-family: var(--phrase); font-weight: 600; }
.gloss { font-family: var(--phrase); font-style: italic; color: var(--ink-soft); }
.overline { font: 700 11px/1.3 var(--ui); letter-spacing: .13em; text-transform: uppercase; color: var(--ink-muted); margin-bottom: 12px; }
.lede { font-size: clamp(1.1rem, 2.2vw, 1.3rem); color: var(--ink-soft); max-width: 36em; }
.wrap { width: min(var(--max), 100% - 2 * var(--gutter)); margin-inline: auto; }
.muted { color: var(--ink-muted); }
.small { font-size: .92rem; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .92em; background: var(--sunken); padding: .1em .35em; border-radius: 6px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- nav ---------- */
.nav {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.nav .wrap { display: flex; align-items: center; gap: 18px; height: 60px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-family: var(--display); font-size: 1.35rem; }
.brand img { width: 32px; height: 32px; border-radius: 8px; }
.nav-links { display: flex; gap: 20px; margin-left: auto; font-weight: 600; font-size: .95rem; }
.nav-links a { color: var(--ink-soft); text-decoration: none; }
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--ink); }
.theme-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--ink-soft);
  display: grid; place-items: center; cursor: pointer; flex: none;
}
.theme-btn svg { width: 18px; height: 18px; }
.theme-btn .moon, :root[data-theme="dark"] .theme-btn .sun { display: none; }
:root[data-theme="dark"] .theme-btn .moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-btn .sun { display: none; }
  :root:not([data-theme="light"]) .theme-btn .moon { display: block; }
}
@media (max-width: 640px) { .nav-links { display: none; } .theme-btn { margin-left: auto; } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: 999px; border: 1px solid transparent;
  font: 600 1rem var(--ui); cursor: pointer; text-decoration: none; transition: background .15s, color .15s, transform .15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-pressed); color: var(--on-accent); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--sunken); color: var(--ink); }
.btn-sm { padding: 8px 14px; font-size: .9rem; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
  background: var(--sunken); color: var(--ink-soft); font: 600 .85rem var(--ui); border: 1px solid transparent; cursor: pointer;
}
.chip[aria-pressed="true"], .chip.on { background: var(--accent-soft); color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.chip-static { cursor: default; }

/* ---------- hero ---------- */
.hero { padding: clamp(36px, 7vw, 90px) 0 clamp(30px, 5vw, 60px); position: relative; overflow: hidden; }
.hero .wrap { display: grid; gap: 40px; align-items: center; grid-template-columns: 1fr; }
@media (min-width: 880px) { .hero .wrap { grid-template-columns: 1.15fr .85fr; gap: 56px; } }
.hero-copy h1 { margin-bottom: .35em; }
.hero-copy .lede { margin-bottom: 1.6em; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 18px; }
.stores { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; color: var(--ink-muted); font-size: .92rem; }
.stores .chip-static { background: var(--surface); border-color: var(--border); }
.hero-bg {
  position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60% 50% at 85% 20%, color-mix(in srgb, var(--accent-soft) 70%, transparent), transparent 70%),
    radial-gradient(50% 40% at 10% 90%, color-mix(in srgb, var(--positive-soft) 60%, transparent), transparent 70%);
}

/* the phone with the arcade in it */
.phone-wrap { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.phone {
  width: min(340px, 100%); padding: 12px; border-radius: 40px;
  background: var(--slab); border: 1px solid var(--slab-border); box-shadow: var(--shadow);
  position: relative;
}
.phone::before { content: ''; position: absolute; top: 20px; left: 50%; transform: translateX(-50%); width: 84px; height: 8px; border-radius: 999px; background: var(--slab-raised); z-index: 2; }
.phone-screen { border-radius: 30px; overflow: hidden; background: #15120E; aspect-ratio: 360 / 640; position: relative; touch-action: none; user-select: none; -webkit-user-select: none; }
.arcade-canvas { width: 100%; height: 100%; touch-action: none; outline: none; cursor: crosshair; }
.arcade-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--on-slab-soft); font-size: .9rem; text-align: center; padding: 20px; }
.arcade-overlay {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 16px 18px; pointer-events: none;
  background: linear-gradient(transparent, rgba(21, 18, 14, 0.85)); color: var(--on-slab); font-size: .9rem; text-align: center;
  transition: opacity .3s;
}
.arcade-overlay strong { color: var(--slab-accent); }
.arcade-overlay.hidden { opacity: 0; }
.game-tabs { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.arcade-meta { text-align: center; color: var(--ink-soft); font-size: .92rem; max-width: 340px; min-height: 2.6em; }
.arcade-meta strong { color: var(--ink); }

/* ---------- sections ---------- */
.section { padding: clamp(48px, 8vw, 96px) 0; }
.section-head { max-width: 42em; margin-bottom: clamp(24px, 4vw, 40px); }
.section-alt { background: var(--surface); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: 1fr; }
.grid-4 { grid-template-columns: 1fr; }
@media (min-width: 700px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-4 { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1000px) { .grid-4 { grid-template-columns: repeat(4, 1fr); } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 22px; }
.section-alt .card { background: var(--bg); }
.card h3 { margin-top: 0; }
.card p:last-child { margin-bottom: 0; }

/* steps: heard → said → recalled → kept */
.steps { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .steps { grid-template-columns: repeat(4, 1fr); } }
.step {
  text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 18px 18px 16px;
  cursor: pointer; font: inherit; color: inherit; transition: border-color .2s, transform .2s; position: relative;
}
.step[aria-pressed="true"] { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow); }
.step .pebble { display: block; width: 28px; height: 28px; border-radius: 50%; background: var(--heat0); margin-bottom: 12px; border: 2px solid var(--border-strong); transition: background .3s; }
.step[data-level="1"][aria-pressed="true"] .pebble, .step[data-level="1"].lit .pebble { background: var(--heat1); }
.step[data-level="2"][aria-pressed="true"] .pebble, .step[data-level="2"].lit .pebble { background: var(--heat2); }
.step[data-level="3"][aria-pressed="true"] .pebble, .step[data-level="3"].lit .pebble { background: var(--heat3); }
.step[data-level="4"][aria-pressed="true"] .pebble, .step[data-level="4"].lit .pebble { background: var(--heat4); }
.step .n { position: absolute; top: 16px; right: 18px; font: 700 .8rem var(--ui); color: var(--ink-muted); letter-spacing: .1em; }
.step h3 { font-size: 1.25rem; margin-bottom: .3em; }
.step p { margin: 0; color: var(--ink-soft); font-size: .95rem; }
.phrase-card {
  margin-top: 22px; background: var(--slab); color: var(--on-slab); border: 1px solid var(--slab-border); border-radius: var(--radius-lg);
  padding: 24px; display: grid; gap: 16px; grid-template-columns: 1fr; align-items: center;
}
@media (min-width: 700px) { .phrase-card { grid-template-columns: 1fr auto; } }
.phrase-card .phrase { font-size: clamp(1.5rem, 3.5vw, 2rem); line-height: 1.25; }
.phrase-card .gloss { color: var(--on-slab-soft); }
.phrase-card .state { display: inline-flex; align-items: center; gap: 8px; margin-top: 10px; font-size: .9rem; color: var(--on-slab-soft); }
.phrase-card .state i { width: 12px; height: 12px; border-radius: 50%; background: var(--heat0); display: inline-block; }
.phrase-card .btn-ghost { color: var(--on-slab); border-color: var(--slab-border); }
.phrase-card .btn-ghost:hover { background: var(--slab-raised); color: var(--on-slab); }
.phrase-card .btn-primary { background: var(--slab-accent); color: var(--slab); }
.phrase-card .btn-primary:hover { background: #F0C56B; color: var(--slab); }
.phrase-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* islands */
.islands-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.section-alt .islands-card { background: var(--bg); }
.islands-canvas { width: 100%; height: clamp(300px, 46vw, 420px); touch-action: manipulation; cursor: pointer; }
.islands-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--border); }
.islands-bar .caption { flex: 1 1 220px; color: var(--ink-soft); font-size: .95rem; min-height: 1.5em; }
.islands-bar .caption strong { color: var(--ink); font-family: var(--phrase); font-size: 1.05rem; }
.legend { display: flex; flex-wrap: wrap; gap: 14px 18px; padding: 0 16px 16px; color: var(--ink-soft); font-size: .88rem; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 14px; height: 14px; border-radius: 50%; display: inline-block; border: 1px solid var(--border-strong); }

/* arena grid */
.games { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .games { grid-template-columns: 1fr 1fr; } }
@media (min-width: 900px) { .games { grid-template-columns: repeat(3, 1fr); } }
.game { display: flex; gap: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px 16px; }
.section-alt .game { background: var(--bg); }
.game .e { font-size: 1.6rem; line-height: 1; flex: none; width: 2rem; text-align: center; padding-top: 2px; }
.game h3 { font: 600 1.02rem var(--ui); margin: 0 0 2px; }
.game p { margin: 0; color: var(--ink-soft); font-size: .9rem; }
.game .skill { color: var(--ink-muted); font-size: .8rem; margin-top: 4px; }
.game.playable { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.game.playable a { font-size: .85rem; }

/* commission demo */
.commission { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 22px; }
.section-alt .commission { background: var(--bg); }
.prompt-box { background: var(--sunken); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px 16px; font-family: var(--phrase); font-size: 1.1rem; min-height: 3.2em; color: var(--ink); }
.prompt-box .caret { display: inline-block; width: 2px; height: 1.1em; background: var(--accent); vertical-align: -2px; margin-left: 2px; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.lines { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 8px; }
.lines li { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); opacity: 0; transform: translateY(6px); transition: opacity .35s, transform .35s; }
.section-alt .lines li { background: var(--bg); }
.lines li.in { opacity: 1; transform: none; }
.lines .t { flex: 1; }
.lines .t .phrase { display: block; font-size: 1.05rem; }
.lines .t .gloss { display: block; font-size: .9rem; }
.lines .tags { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; max-width: 40%; }
.lines .tag { font: 600 .72rem var(--ui); padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); }
.hear { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border-strong); background: transparent; color: var(--ink-soft); display: grid; place-items: center; cursor: pointer; flex: none; }
.hear:hover { background: var(--sunken); }
.hear svg { width: 16px; height: 16px; }
.commission .foot { margin: 14px 0 0; color: var(--ink-muted); font-size: .88rem; }

/* data */
.data-flow { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .data-flow { grid-template-columns: 1.2fr 1fr; } }
.stays { background: var(--positive-soft); border: 1px solid color-mix(in srgb, var(--positive) 30%, transparent); border-radius: var(--radius-md); padding: 20px 22px; }
.stays h3, .leaves h3 { margin-top: 0; }
.leaves { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 20px 22px; }
.section-alt .leaves { background: var(--bg); }
.data-flow ul { margin: 0; padding-left: 1.2em; }
.data-flow li { margin-bottom: .4em; }
.data-flow li:last-child { margin-bottom: 0; }

/* languages */
.langs { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 18px; padding: 0; list-style: none; }
.langs li { padding: 8px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-weight: 600; font-size: .95rem; }
.langs li small { color: var(--ink-muted); font-weight: 500; margin-left: 6px; }

/* closing */
.closing { text-align: center; padding: clamp(56px, 10vw, 120px) 0; }
.closing h2 { margin-bottom: .5em; }
.closing .lede { margin-inline: auto; }

/* ---------- footer ---------- */
.footer { border-top: 1px solid var(--border); padding: 36px 0 44px; color: var(--ink-muted); font-size: .9rem; }
.footer .wrap { display: flex; flex-wrap: wrap; gap: 14px 28px; align-items: center; }
.footer a { color: var(--ink-soft); text-decoration: none; }
.footer a:hover { color: var(--ink); text-decoration: underline; }
.footer .legal { margin-left: auto; }
@media (max-width: 640px) { .footer .legal { margin-left: 0; width: 100%; } }

/* ---------- prose pages ---------- */
.prose { padding: clamp(32px, 6vw, 72px) 0 clamp(48px, 8vw, 96px); }
.prose .wrap { max-width: 44em; }
.prose h1 { font-size: clamp(2rem, 5vw, 3rem); }
.prose h2 { font-size: 1.5rem; margin-top: 2em; }
.prose h3 { font-size: 1.15rem; margin-top: 1.6em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin-bottom: .45em; }
.prose table { border-collapse: collapse; width: 100%; font-size: .95rem; margin: 1em 0; }
.prose th, .prose td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.prose th { color: var(--ink-muted); font-weight: 600; font-size: .85rem; letter-spacing: .04em; text-transform: uppercase; }
.prose .note { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 16px 20px; margin: 1.2em 0; }
.prose .meta { color: var(--ink-muted); margin-bottom: 2em; }
details { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 10px; background: var(--surface); }
summary { cursor: pointer; font-weight: 600; }
details p { margin: .7em 0 0; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001s !important; transition-duration: .001s !important; }
}
