/* claubase site. Plain CSS, no build step.
   Colours from design/brand/BRIEF.md: palette B (navy, cream, teal) in light mode, palette A
   (dark amethyst, pearl beige, pink, tea green) in dark mode. Every token uses light-dark(), so the
   theme follows color-scheme (the system, or the toggle).
   Shape rule: buttons and badges are pills, cards 16px, code 10px. */

:root {
  color-scheme: light dark;
  &:has(> head > meta[name="color-scheme"][content="dark"]) { color-scheme: dark; }
  &:has(> head > meta[name="color-scheme"][content="light"]) { color-scheme: light; }

  --font-sans: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI", Cantarell, "Noto Sans", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --r-card: 16px;
  --r-code: 10px;
  --wrap: 1160px;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --spring: cubic-bezier(0.3, 1.6, 0.5, 1);

  --bg: light-dark(#FEF9DE, #1A0A1F);
  --surface: light-dark(#FFFEF6, #26112C);
  --surface-2: light-dark(#F5EDBE, #321838);
  --ink: light-dark(#1B2146, #F6ECD3);
  --muted: light-dark(#474E77, #CDBBC9);
  --line: light-dark(#E6DDA9, #4A2C51);
  --brand: light-dark(#343E74, #EE85B5);       /* links, primary button, focus */
  --on-brand: light-dark(#FEF7CD, #2B0B33);
  --soft: light-dark(#BDEDE5, #2F3A27);        /* "built" badge: teal tint / tea green */
  --on-soft: light-dark(#0F3B35, #D8EAC7);
  --warm: light-dark(#343E74, #ECDCB0);        /* status strip */
  --on-warm: light-dark(#FEF7CD, #2B0B33);
  --term-bg: light-dark(#10142B, #12060F);
  --term-ink: light-dark(#FEF7CD, #F6ECD3);
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 5rem; -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 1.0625rem/1.6 var(--font-sans); overflow-x: clip; }
img { max-width: 100%; height: auto; display: block; }
h1, h2, h3 { line-height: 1.12; margin: 0; text-wrap: balance; letter-spacing: -0.02em; }
h2 { font-size: clamp(1.85rem, 1.2rem + 2.2vw, 2.8rem); font-weight: 750; }
h3 { font-size: 1.1875rem; font-weight: 700; letter-spacing: -0.01em; }
p { margin: 0; text-wrap: pretty; }
a { color: var(--brand); text-underline-offset: 0.2em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
code { font-family: var(--font-mono); font-size: 0.9em; background: var(--surface-2); padding: 0.08em 0.35em; border-radius: 6px; overflow-wrap: anywhere; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; border-radius: 4px; }
.wrap { width: min(100% - 2.5rem, var(--wrap)); margin-inline: auto; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: absolute; left: 1rem; top: -4rem; z-index: 20; background: var(--brand); color: var(--on-brand); padding: 0.6rem 1rem; border-radius: 999px; }
.skip:focus { top: 1rem; }
section { padding-block: clamp(4rem, 3rem + 4vw, 7rem); }
.section-lede { color: var(--muted); max-width: 56ch; margin-top: 1rem; font-size: 1.125rem; }
html:not(.js) .js-only { display: none; }

/* Layers: the 3D canvas sits behind all content; opaque panels cover it where blocks fly past. */
.scene { position: fixed; top: 0; left: 0; z-index: 0; pointer-events: none; }
main, .site-footer, .status-strip { position: relative; z-index: 1; }

/* Theme-dependent visibility. Follows the system unless pinned. */
.on-dark { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not(:has(meta[name="color-scheme"][content="light"])) .on-dark { display: revert; }
  :root:not(:has(meta[name="color-scheme"][content="light"])) .on-light { display: none; }
}
:root:has(meta[name="color-scheme"][content="dark"]) .on-dark { display: revert; }
:root:has(meta[name="color-scheme"][content="dark"]) .on-light { display: none; }

/* Mascot art has its own cream background, so it is framed as a card in both themes. */
.art { border-radius: var(--r-card); border: 1px solid var(--line); }

/* Header */
.status-strip { background: var(--warm); color: var(--on-warm); font-size: 0.9375rem; }
.status-strip p { width: min(100% - 2.5rem, var(--wrap)); margin-inline: auto; padding-block: 0.55rem; }
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-row { display: flex; align-items: center; gap: 1.5rem; min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 0.55rem; color: var(--ink); text-decoration: none; }
.brand .mark { width: 36px; height: 36px; }
.wordmark { font-weight: 800; font-size: 1.25rem; letter-spacing: -0.03em; }
.site-nav { display: flex; gap: 0.25rem; margin-left: auto; }
.site-nav a { color: var(--ink); text-decoration: none; padding: 0.45rem 0.8rem; border-radius: 999px; font-weight: 600; font-size: 0.9375rem; white-space: nowrap; }
.site-nav a:hover, .site-nav a[aria-current] { background: var(--surface-2); }
.controls[hidden] { display: none; }
.theme-btn {
  font: 650 0.8125rem/1 var(--font-sans); color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 999px; padding: 0.45rem 0.9rem; cursor: pointer; min-height: 32px; white-space: nowrap;
}
.theme-btn:hover { background: var(--surface-2); }

/* Buttons and badges */
.ctas { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 2.25rem; }
.btn {
  display: inline-flex; align-items: center; min-height: 48px; padding: 0 1.4rem; border-radius: 999px;
  font-weight: 700; text-decoration: none; white-space: nowrap; transition: transform 160ms var(--ease);
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(1px) scale(0.98); }
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-ghost { color: var(--ink); border: 1.5px solid var(--line); background: var(--surface); }
.badge { display: inline-block; font: 700 0.75rem/1 var(--font-sans); padding: 0.4rem 0.7rem; border-radius: 999px; white-space: nowrap; }
.badge--built { background: var(--soft); color: var(--on-soft); }
.badge--review { background: var(--surface-2); color: var(--ink); }
.badge--designed { color: var(--ink); box-shadow: inset 0 0 0 1.5px currentColor; }

/* 3D slots. They keep their size with or without WebGL, so nothing shifts when it loads. */
.stage { position: relative; display: grid; place-items: center; min-height: 240px; }
.stage-art { width: min(88%, 440px); transition: opacity 500ms var(--ease), transform 700ms var(--ease); }
.gl .stage:not([data-figure="key"]) .stage-art { opacity: 0; visibility: hidden; }
/* With the 3D key up, the mascot steps down to the corner and bobs. */
.gl [data-figure="key"] .stage-art { position: absolute; width: 38%; right: 0; bottom: 0; rotate: 4deg; box-shadow: 0 18px 40px -24px #000a; }

/* Hero */
.hero { display: grid; grid-template-columns: 1fr 1.15fr; align-items: center; gap: 2rem; min-height: calc(100svh - 112px); padding-block: 2rem 3rem; }
.hero h1 { font-size: clamp(3rem, 1.5rem + 5vw, 5.4rem); font-weight: 800; letter-spacing: -0.04em; line-height: 0.98; }
.lede { font-size: clamp(1.15rem, 1rem + 0.5vw, 1.35rem); color: var(--muted); margin-top: 1.5rem; max-width: 34ch; }
.hero .stage { height: min(66svh, 560px); }
@media (prefers-reduced-motion: no-preference) {
  .hero-copy > * { animation: rise 600ms var(--ease) both; }
  .hero-copy > :nth-child(2) { animation-delay: 80ms; }
  .hero-copy > :nth-child(3) { animation-delay: 160ms; }
  .hero .stage-art { animation: bob 4.5s ease-in-out infinite; }
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes bob { 50% { translate: 0 -10px; } }

/* How: the chain stays put while the steps scroll */
.how { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(2rem, 5vw, 5rem); align-items: start; }
.how-stage { position: sticky; top: 5rem; align-self: start; }
.stage--chain { height: min(70svh, 520px); }
.flow { list-style: none; margin: 3rem 0 0; padding: 0; counter-reset: flow; }
.flow li { counter-increment: flow; position: relative; padding: 0 0 3rem 3.75rem; }
.flow li:last-child { padding-bottom: 0; }
.flow li::before {
  content: counter(flow); position: absolute; left: 0; top: -0.3rem; width: 2.4rem; height: 2.4rem;
  border-radius: 50%; display: grid; place-items: center; background: var(--brand); color: var(--on-brand); font-weight: 800;
}
.flow li:not(:last-child)::after { content: ""; position: absolute; left: calc(1.2rem - 1px); top: 2.4rem; bottom: 0.6rem; width: 2px; background: var(--line); }
.flow p { margin-top: 0.5rem; color: var(--muted); }

/* Screenshots */
.shots { display: grid; grid-template-columns: repeat(3, 1fr); gap: 2rem 1.25rem; margin-top: 2.5rem; }
.shot { margin: 0; min-width: 0; }
.shot--wide { grid-column: 1 / -1; }
.shot a { display: block; }
.shot.shot a.on-dark { display: none; }
:root:has(meta[name="color-scheme"][content="dark"]) .shot.shot a.on-dark { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not(:has(meta[name="color-scheme"][content="light"])) .shot.shot a.on-dark { display: block; }
}
.shot img { width: 100%; border-radius: var(--r-card); border: 1px solid var(--line); background: var(--surface); box-shadow: 0 24px 48px -32px color-mix(in srgb, var(--brand) 55%, transparent); transition: transform 240ms var(--ease); }
.shot a:hover img { transform: translateY(-4px); }
.shot figcaption { margin-top: 0.8rem; color: var(--muted); font-size: 0.9375rem; }
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .shot--wide { animation: settle linear both; animation-timeline: view(); animation-range: entry 0% cover 40%; }
  }
}
@keyframes settle { from { transform: perspective(1400px) rotateX(14deg) scale(0.93); } to { transform: none; } }

/* Status */
.status { background: var(--surface); border-block: 1px solid var(--line); }
.state { display: grid; grid-template-columns: 1.15fr 1fr 1fr; margin-top: 2.5rem; border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; }
.state > div { padding: 1.75rem; }
.state > div + div { border-left: 1px solid var(--line); }
.state-built { background: var(--soft); color: var(--on-soft); }
.state-built code { background: color-mix(in srgb, var(--on-soft) 12%, transparent); }
.state-mid { background: var(--surface-2); }
.state-no { background: var(--bg); }
.state ul { margin: 1rem 0 0; padding: 0; list-style: none; display: grid; gap: 0.6rem; }
.limits-title { margin-top: 3.5rem; font-size: 1.5rem; }
.limits { list-style: none; margin: 1.25rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem 2rem; color: var(--muted); }
.limits strong { display: block; color: var(--ink); border-top: 2px solid var(--brand); padding-top: 0.8rem; margin-bottom: 0.25rem; }

/* Mascot toys */
.toys { list-style: none; margin: 3rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 2rem 1.25rem; }
.toys li { display: grid; gap: 0.6rem; justify-items: center; text-align: center; align-content: start; min-width: 0; }
.toys li:nth-child(odd) .art { rotate: -2.5deg; }
.toys li:nth-child(even) .art { rotate: 2deg; }
.toys li:nth-child(3n) { translate: 0 1rem; }
.toys span { color: var(--muted); font-size: 0.9375rem; font-weight: 600; }
.toy { display: block; width: 100%; padding: 0; border: 0; background: none; border-radius: var(--r-card); cursor: grab; touch-action: pan-y; transition: translate 600ms var(--spring), rotate 600ms var(--spring), scale 200ms var(--ease); }
.toy:hover { scale: 1.05; }
.toy.is-held { cursor: grabbing; transition: none; position: relative; z-index: 2; scale: 1.08; }
.toy img { width: 100%; user-select: none; }
@media (prefers-reduced-motion: no-preference) {
  .js .toys li { animation: sway 5s ease-in-out infinite alternate; }
  .js .toys li:nth-child(2n) { animation-duration: 6.5s; animation-delay: -2s; }
  .js .toys li:nth-child(3n) { animation-duration: 4.2s; animation-delay: -1s; }
}
@keyframes sway { from { transform: translateY(-4px) rotate(-0.8deg); } to { transform: translateY(5px) rotate(0.8deg); } }

/* Downloads */
.download-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: clamp(2rem, 5vw, 4rem); align-items: center; }
.download-copy { min-width: 0; }
.tablewrap { margin-top: 2rem; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--surface); }
.downloads { width: 100%; border-collapse: collapse; text-align: left; }
.downloads th, .downloads td { padding: 0.65rem 0.9rem; vertical-align: middle; }
.downloads thead th { font-size: 0.875rem; color: var(--muted); font-weight: 650; }
.downloads tbody tr { border-top: 1px solid var(--line); }
.downloads th span { display: block; font-weight: 500; font-size: 0.875rem; color: var(--muted); }
.downloads td a { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; min-width: 4.5rem; padding: 0 1rem; border-radius: 999px; background: var(--brand); color: var(--on-brand); font: 700 0.875rem/1 var(--font-mono); text-decoration: none; transition: transform 160ms var(--ease); }
.downloads td a::after { content: " \2193"; white-space: pre; }
.downloads td a:hover { transform: translateY(-2px); }
.sums { margin-top: 1rem; color: var(--muted); font-size: 0.9375rem; }
.quorum { margin: 0; }
.stage--quorum { height: 440px; }
.quorum figcaption { text-align: center; color: var(--muted); font-weight: 650; }

/* Footer */
.site-footer { border-top: 1px solid var(--line); padding-block: 2.5rem; color: var(--muted); font-size: 0.9375rem; background: var(--bg); }
.footer-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 2rem; }
.site-footer strong { color: var(--ink); }

/* Manual and 404 */
.manual { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 3rem; padding-block: 3rem 5rem; align-items: start; }
.manual-nav { position: sticky; top: 5.5rem; display: grid; gap: 0.25rem; }
.manual-nav a { color: var(--ink); text-decoration: none; padding: 0.5rem 0.8rem; border-radius: 999px; font-weight: 600; font-size: 0.9375rem; }
.manual-nav a:hover { background: var(--surface-2); }
.manual-nav a[aria-current="page"] { background: var(--brand); color: var(--on-brand); }
.prose { max-width: 70ch; min-width: 0; }
.prose h1 { font-size: clamp(2rem, 1.4rem + 2.5vw, 3rem); font-weight: 800; letter-spacing: -0.035em; }
.prose h2 { font-size: 1.6rem; margin-top: 3rem; }
.prose h3 { margin-top: 2rem; }
.prose p, .prose ul, .prose ol { margin-top: 1rem; }
.prose li { margin-top: 0.35rem; }
.prose .tablewrap { margin-top: 1.25rem; }
.prose table { width: 100%; border-collapse: collapse; text-align: left; font-size: 0.9375rem; }
.prose th, .prose td { padding: 0.65rem 0.9rem; vertical-align: top; }
.prose tbody tr { border-top: 1px solid var(--line); }
.prose pre { margin: 1rem 0 0; padding: 1rem 1.1rem; border-radius: var(--r-code); background: var(--term-bg); color: var(--term-ink); overflow-x: auto; font: 500 0.8438rem/1.65 var(--font-mono); }
.prose pre code { background: none; padding: 0; font-size: inherit; overflow-wrap: normal; }
.note { margin-top: 1.5rem; padding: 1rem 1.25rem; border-radius: var(--r-card); background: var(--surface-2); }
.prose .note p:first-child { margin-top: 0; }
.prose .art { margin-top: 2rem; width: min(100%, 380px); }
.lost { text-align: center; padding-block: 4rem 6rem; display: grid; justify-items: center; gap: 1.5rem; }
.lost .art { width: min(100%, 440px); }

/* Responsive */
@media (max-width: 860px) {
  .header-row { flex-wrap: wrap; gap: 0.25rem 1rem; padding-block: 0.5rem; }
  .controls { margin-left: auto; }
  .site-nav { order: 3; width: 100%; margin-inline: -0.6rem; gap: 0; }
  .landing .site-nav { justify-content: space-between; }
  .site-nav a { padding: 0.45rem 0.55rem; font-size: 0.875rem; }
  .site-header { position: static; }
  .hero, .how, .download-grid, .limits, .footer-row, .state, .manual { grid-template-columns: minmax(0, 1fr); }
  .hero { min-height: 0; padding-top: 0.5rem; gap: 0.5rem; }
  .hero .stage { order: -1; height: 230px; min-height: 0; }
  .hero .stage-art { max-height: 100%; width: auto; }
  .hero .ctas { margin-top: 1.5rem; }
  .how-stage { position: static; }
  .stage--chain { height: 300px; }
  .stage--quorum { height: 300px; }
  .shots { grid-template-columns: 1fr; }
  .state > div + div { border-left: 0; border-top: 1px solid var(--line); }
  .toys { grid-template-columns: 1fr 1fr; }
  .manual { gap: 2rem; padding-top: 1.5rem; }
  .manual-nav { position: static; display: flex; flex-wrap: wrap; }
}
@media (max-width: 420px) {
  .btn { padding: 0 1.1rem; }
  /* Three download columns have to fit 360px without scrolling. */
  .downloads th, .downloads td { padding: 0.55rem 0.3rem; }
  .downloads thead th, .downloads th span { font-size: 0.75rem; }
  .downloads td a { min-width: 0; padding: 0 0.55rem; font-size: 0.8125rem; }
  .downloads td a::after { content: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
  .btn:hover, .shot a:hover img, .downloads td a:hover { transform: none; }
  .toy { cursor: default; }
  .toy:hover { scale: none; }
}

@media (forced-colors: active) {
  .badge, .btn, .downloads td a { border: 1px solid CanvasText; }
}
