:root {
  --ink: #0c0a18;
  --ink-2: #13102a;
  --panel: #1a1636;
  --line: #2c2652;
  --fg: #ece9ff;
  --muted: #a49fc8;
  --dim: #6e6894;
  --violet: #8b6cff;
  --violet-2: #b7a4ff;
  --cyan: #5ee6ff;
  --pink: #ff6fae;
  --gold: #ffd166;
  --shell: #6a4fd8;
  --shell-hi: #9a84ff;
  --shell-lo: #3e2a99;
  --rainbow: linear-gradient(90deg,
    #ff5d73 0 16.6%, #ff9f43 0 33.3%, #ffd166 0 50%, #5cdb95 0 66.6%, #5ee6ff 0 83.3%, #8b6cff 0);
  --display: "Space Grotesk", "Inter", system-ui, sans-serif;
  --brand: "Chakra Petch", "Space Grotesk", sans-serif;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--ink);
  color: var(--fg);
  font: 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { color: var(--violet-2); text-decoration: none; }
a:hover { color: var(--fg); }
code { font: 0.9em var(--mono); color: var(--cyan); }
img { image-rendering: pixelated; }

/* ---- Nav ----------------------------------------------------------------- */

.nav {
  position: fixed; inset: 0 0 auto; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px clamp(16px, 4vw, 48px);
  background: linear-gradient(var(--ink) 0%, rgba(12, 10, 24, 0.75) 70%, transparent);
  backdrop-filter: blur(6px);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--fg); }
.brand img { width: 30px; height: 30px; }
.brand:hover { color: var(--fg); }

/* The wordmark: "WASM" in a squared bold italic, "AD" on a slanted chip. */
.wordmark { display: inline-flex; align-items: center; gap: 7px; font-family: var(--brand); font-style: italic; font-weight: 700; line-height: 1; white-space: nowrap; }
.wordmark b { font-weight: 700; font-size: 25px; letter-spacing: 0.01em; }
.wordmark i { font-style: italic; font-weight: 700; font-size: 15px; letter-spacing: 0.06em; color: var(--ink);
  background: var(--violet-2); padding: 4px 11px 3px 10px; clip-path: polygon(16% 0, 100% 0, 84% 100%, 0 100%); }
.wordmark.big b { font-size: 40px; }
.wordmark.big i { font-size: 22px; padding: 6px 15px 5px 14px; }
.nav-links { display: flex; gap: clamp(12px, 2.4vw, 28px); font-size: 15px; }
.nav-links a { color: var(--muted); }
.nav-links a:hover { color: var(--fg); }
.nav-links .gh { color: var(--fg); }

/* ---- Hero ---------------------------------------------------------------- */

/* Console width: 1000px shows the screen at exactly 2×; on short viewports it
   shrinks so the peeking part still fits above the fold. */
:root { --cw: max(min(1000px, calc(100vw - 32px), calc((100svh - 514px) * 2.7)), min(560px, calc(100vw - 32px))); --ch: calc(var(--cw) * 0.56); }
.hero { position: relative; min-height: calc(100svh - 64px); display: grid; grid-template-rows: 1fr auto; justify-items: center; padding: 84px clamp(16px, 4vw, 48px) 0; isolation: isolate; overflow: hidden; }
.hero-sky {
  position: absolute; inset: 0; z-index: -1;
  background:
    linear-gradient(180deg, rgba(12, 10, 24, 0.55) 0%, rgba(12, 10, 24, 0) 22%, rgba(12, 10, 24, 0) 70%, rgba(12, 10, 24, 0.55) 100%),
    url("assets/hero.png") center 62% / cover no-repeat;
  image-rendering: pixelated;
}
.hero-copy { max-width: 820px; text-align: center; align-self: start; padding: 2vh 0 24px; }
.hero-copy::before { /* a soft pool of shade behind the text, so the art can stay bright */
  content: ""; position: absolute; z-index: -1; left: 50%; top: 60px; width: min(1100px, 120vw); height: 560px; transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(12, 10, 24, 0.62), rgba(12, 10, 24, 0));
  pointer-events: none;
}
.eyebrow { font: 600 13px var(--sans); letter-spacing: 0.16em; text-transform: uppercase; color: var(--gold); margin: 0 0 12px; text-shadow: 0 2px 0 rgba(0, 0, 0, 0.5); }
h1 { font: 700 clamp(34px, min(4.6vw, 7svh), 64px)/1.04 var(--display); margin: 0 0 16px; letter-spacing: -0.035em; text-wrap: balance; text-shadow: 0 2px 18px rgba(0, 0, 0, 0.55), 0 1px 2px rgba(0, 0, 0, 0.6); }
.soft { color: #cdbfff; }
.lede { font-size: clamp(16px, 1.3vw, 18px); color: #ece8ff; max-width: 40em; margin: 0 auto 22px; text-shadow: 0 2px 6px rgba(0, 0, 0, 0.7); }
.ctas, .links { display: flex; gap: 12px; flex-wrap: wrap; }
.ctas { justify-content: center; }
.btn {
  display: inline-flex; align-items: center; gap: 8px; padding: 12px 20px;
  font: 600 15px var(--sans); color: var(--fg);
  background: rgba(26, 22, 54, 0.78); border: 2px solid var(--line); border-radius: 6px;
  box-shadow: 0 4px 0 #000;
  transition: transform 0.08s, box-shadow 0.08s, border-color 0.15s;
}
.btn:hover { border-color: var(--violet); color: var(--fg); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #000; }
.btn.primary { background: var(--violet); border-color: var(--violet-2); color: #0c0a18; }
.btn.primary:hover { background: var(--violet-2); }

/* The console peeks out of the separator, cut off; it rises when played. */
.dock { width: var(--cw); height: calc(var(--ch) * 0.58); overflow: hidden; scroll-margin-top: 80px;
  transition: height 0.7s cubic-bezier(0.2, 0.9, 0.25, 1.08); }
.dock.raised { height: calc(var(--ch) + 28px); }
.console { position: relative; width: var(--cw); height: var(--ch); margin-top: 14px; user-select: none; -webkit-user-select: none; touch-action: none; }
.console svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.console .screen { position: absolute; left: 26%; top: 14.2857%; width: 48%; height: 57.1429%; background: #000; }
.console .screen::after { /* glass */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(125deg, rgba(255, 255, 255, 0.07) 0%, rgba(255, 255, 255, 0.015) 38%, transparent 38.5%);
}
.console canvas { width: 100%; height: 100%; display: block; image-rendering: pixelated; image-rendering: crisp-edges; }
.engage {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  padding: 10px 18px; border-radius: 6px; cursor: pointer;
  background: rgba(12, 10, 24, 0.78); color: var(--fg); border: 2px solid rgba(255, 255, 255, 0.3);
  font: 600 15px var(--sans); letter-spacing: 0.02em; box-shadow: 0 4px 0 #000;
  transition: opacity 0.2s;
}
.console.engaged .engage { opacity: 0; pointer-events: none; }
.console .key { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.console .hit { fill: #000; fill-opacity: 0; pointer-events: all; }
.console .hit.pressed { fill-opacity: 0.3; }
.console .btn-round { transition: transform 0.05s; transform-box: fill-box; transform-origin: center; }
.console .btn-round.pressed { transform: translateY(3px) scale(0.96); filter: brightness(0.82); }
.console path.key.pressed { transform: translateY(4px); }
.console .emboss { font: italic 700 22px var(--brand); fill: rgba(255, 255, 255, 0.55); }
.console .small-label { font: 600 13px var(--sans); letter-spacing: 0.12em; fill: rgba(255, 255, 255, 0.6); }
.console .lens-label { font: 600 10px var(--sans); letter-spacing: 0.24em; fill: #7d7e96; text-anchor: middle; }
.console .lens-logo { font: italic 700 36px var(--brand); fill: #e4e0f7; }
.console .lens-chip { font: italic 700 19px var(--brand); letter-spacing: 1px; fill: #15122a; }
.console .led { filter: drop-shadow(0 0 6px #3dff9a); }

.separator { height: 6px; background: var(--rainbow); box-shadow: 0 0 24px rgba(139, 108, 255, 0.45); position: relative; z-index: 2; }
.status { display: grid; justify-items: center; gap: 6px; padding: 18px 16px 0; text-align: center; }
.now-playing { margin: 0; font: 600 15px var(--sans); color: var(--fg); }
.now-playing .err { color: var(--pink); }
.keys { margin: 0; font-size: 13px; color: var(--muted); }
kbd { font: 500 12px var(--mono); color: var(--fg); background: var(--panel); border: 1px solid var(--line); border-bottom-width: 2px; padding: 1px 5px; border-radius: 4px; margin: 0 2px; }

/* ---- Sections ------------------------------------------------------------ */

.section { max-width: 1240px; margin: 0 auto; padding: 96px clamp(16px, 4vw, 48px) 32px; scroll-margin-top: 40px; }
.section-head { max-width: 44em; margin-bottom: 40px; }
h2 { font: 700 clamp(30px, 3.6vw, 44px)/1.1 var(--display); letter-spacing: -0.03em; margin: 0 0 14px; }
h3 { font: 600 17px var(--sans); margin: 0 0 6px; }
.section-head p:not(.eyebrow) { color: var(--muted); font-size: 17px; margin: 0; }

/* Carts */
.carts { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 24px; }
.cart {
  position: relative; display: grid; gap: 4px; justify-items: start; text-align: left;
  padding: 18px 18px 22px; cursor: pointer; color: var(--fg); font: inherit;
  background: linear-gradient(180deg, #2a2357, #1b1640);
  border: 2px solid #3a3170; border-radius: 10px 10px 4px 4px;
  clip-path: polygon(0 0, 100% 0, 100% 100%, 62% 100%, 58% calc(100% - 8px), 42% calc(100% - 8px), 38% 100%, 0 100%);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.12);
  transition: transform 0.15s, border-color 0.15s;
}
.cart:hover { transform: translateY(-4px); border-color: var(--violet); }
.cart.active { border-color: var(--gold); }
.cart.active .cart-title::after { content: "  ● playing"; color: var(--gold); font: 600 12px var(--sans); }
.cart-label {
  width: 100%; aspect-ratio: 16 / 9; margin-bottom: 12px; border-radius: 4px; overflow: hidden;
  display: grid; place-items: center; box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.35);
}
.cart-label img { height: 74%; width: auto; filter: drop-shadow(0 4px 0 rgba(0, 0, 0, 0.35)); }
.twirl-label { background: url("assets/twirl.png") center / cover; image-rendering: pixelated; }
.hello-label { background: linear-gradient(180deg, #283c9f, #8d5aa0 55%, #ff8c60); }
.river-label { background: linear-gradient(180deg, rgba(12, 10, 24, 0.1), rgba(12, 10, 24, 0.35)), url("assets/hero.png") center 65% / cover; }
.own-label { background: repeating-linear-gradient(45deg, #1d1840 0 10px, #221c4b 10px 20px); font: 700 44px var(--display); color: var(--dim); border: 2px dashed var(--line); }
.cart.own input { display: none; }
.cart.own.dragging { border-color: var(--cyan); }
.cart-title { font: 700 20px var(--display); letter-spacing: -0.02em; }
.cart-meta { font-size: 14px; color: var(--muted); }

/* Specs */
.specs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; background: var(--line); border: 2px solid var(--line); border-radius: 10px; overflow: hidden; }
.spec { background: var(--ink-2); padding: 26px 22px; display: grid; gap: 4px; }
.spec b { font: 700 38px/1 var(--display); letter-spacing: -0.03em; color: var(--fg); }
.spec:nth-child(6n+1) b { color: #ff8b9a; } .spec:nth-child(6n+2) b { color: #ffb86b; }
.spec:nth-child(6n+3) b { color: var(--gold); } .spec:nth-child(6n+4) b { color: #7be3a8; }
.spec:nth-child(6n+5) b { color: var(--cyan); } .spec:nth-child(6n+6) b { color: var(--violet-2); }
.spec span { color: var(--muted); font-size: 15px; }

/* Memory map */
.memmap { display: flex; border: 2px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 40px; min-height: 120px; }
.seg { flex: 1; padding: 14px 12px; display: grid; align-content: space-between; gap: 18px; min-width: 0; border-right: 2px solid var(--ink); }
.seg:last-child { border-right: 0; }
.seg b { font: 500 12px var(--mono); color: rgba(255, 255, 255, 0.8); }
.seg span { font: 600 14px var(--sans); line-height: 1.25; }
.seg.null { flex: 0.6; background: #1b1830; color: var(--dim); }
.seg.io { background: #4a2a6e; } .seg.pal { background: #6b2f6c; } .seg.oam { background: #8a3a5c; }
.seg.vram { flex: 3.2; background: linear-gradient(135deg, #2d3a8c, #2a5a9a); }
.seg.save { flex: 1.2; background: #2b6b5f; } .seg.audio { flex: 1; background: #2a2a40; color: var(--dim); }
.seg.free { flex: 2.4; background: repeating-linear-gradient(90deg, #1a1636 0 12px, #1e1a3e 12px 24px); color: var(--muted); }

.why { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 20px; }
.card { padding: 22px; background: var(--ink-2); border: 2px solid var(--line); border-radius: 10px; }
.card p { margin: 0; color: var(--muted); font-size: 15px; }

/* Code */
.code-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 32px; align-items: start; }
pre { margin: 0; overflow-x: auto; }
pre code { color: #d9d5f5; }
.code { padding: 22px 24px; background: #0f0d22; border: 2px solid var(--line); border-radius: 10px; font: 13.5px/1.65 var(--mono); box-shadow: 0 6px 0 #000; }
.code .k { color: #c792ea; } .code .f { color: #82aaff; } .code .s { color: #c3e88d; }
.code .n { color: #f78c6c; } .code .c { color: #6e6894; } .code .a { color: #ffcb6b; }
.steps { display: grid; gap: 22px; }
.step { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 14px; }
.step > div, .steps { min-width: 0; }
.step > span { width: 36px; height: 36px; display: grid; place-items: center; background: var(--violet); color: var(--ink); font: 700 18px var(--display); border-radius: 6px; box-shadow: 0 3px 0 #000; }
.step p { margin: 4px 0 0; color: var(--muted); font-size: 15px; }
.step pre { padding: 10px 12px; background: #0f0d22; border: 1px solid var(--line); border-radius: 6px; font: 12.5px var(--mono); }

/* Footer */
.footer { max-width: 1240px; margin: 64px auto 0; padding: 32px clamp(16px, 4vw, 48px) 56px; display: grid; justify-items: center; gap: 6px; text-align: center; color: var(--muted); font-size: 14px; }
.footer p { margin: 0; }
.footer .wordmark { margin-bottom: 14px; color: var(--fg); }
.dim { color: var(--dim); }

/* ---- Responsive ---------------------------------------------------------- */

@media (max-width: 760px) {
  .nav-links a:not(.gh):not([href="spec.html"]) { display: none; }
  .nav-links { gap: 16px; font-size: 14px; }
  .brand img { width: 24px; height: 24px; }
  .wordmark b { font-size: 21px; }
  .wordmark i { font-size: 12px; padding: 3px 9px 2px 8px; }
  .hero { padding-top: 88px; }
  .dock { height: calc(var(--ch) * 0.62); }
  .code-grid { grid-template-columns: minmax(0, 1fr); }
  .engage { font-size: 12px; padding: 6px 10px; white-space: nowrap; }
  .memmap { flex-direction: column; }
  .seg { border-right: 0; border-bottom: 2px solid var(--ink); grid-template-columns: 90px 1fr; align-items: center; gap: 12px; }
  .keys { display: none; }
  .specs { grid-template-columns: repeat(2, 1fr); }
  .spec b { font-size: 30px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .cart, .btn, .dock { transition: none; }
}
