/* CraQED — craqed.ai. Tokens from the CraQED Design System (dark). */
@font-face { font-family: "Outfit"; src: url("/fonts/outfit-latin.woff2") format("woff2"); font-weight: 400 600; font-display: swap; }
@font-face { font-family: "JetBrains Mono"; src: url("/fonts/jetbrains-mono-latin.woff2") format("woff2"); font-weight: 400 500; font-display: swap; }

:root {
  --surface-000: #0b0d11; --surface-100: #12151b; --surface-200: #1a1e26;
  --ink: #e9ecf1; --ink-muted: #a3abb9; --ink-faint: #7f8897; --ink-inverse: #0b0d11;
  --line: #262b35; --line-strong: #5f6877;
  --accent: #4cc9ff; --accent-soft: #143241; --accent-ink: #8adbff;
  --steel-hi: #2c323c; --steel-lo: #0f1217;
  --warn: #f2b84b; --danger: #ff7a7a;
  --font-display: "Outfit", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --gutter: clamp(16px, 4vw, 56px);
  --page-max: max(1560px, min(84vw, 2200px)); /* grows on large monitors */
  /* side padding that lines header and footer up with the centred page column */
  --edge: max(var(--gutter), calc((100% - var(--page-max)) / 2 + var(--gutter)));
  --gap: clamp(12px, 2.4vh, 28px);
  --pad: clamp(12px, 2vh, 20px);      /* demo panel padding */
  --steps-h: clamp(92px, 13vh, 118px); /* desktop step-row height */
  --amber: #f2b84b; --amber-ink: #f5c46a; --amber-soft: #33270f;
  color-scheme: dark;
}
/* Light theme: system preference, unless the visitor picked dark; or picked light explicitly. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --surface-000: #eef0f3; --surface-100: #ffffff; --surface-200: #e3e6eb;
    --ink: #0b0d11; --ink-muted: #4b5564; --ink-faint: #5c6574; --ink-inverse: #eef0f3;
    --line: #d1d6de; --line-strong: #6f7886;
    --accent: #006e9e; --accent-soft: #d6edf8; --accent-ink: #005a82;
    --steel-hi: #ffffff; --steel-lo: #dde1e7;
    --warn: #8a5a00; --danger: #b3261e;
    --amber: #c98a00; --amber-ink: #8a5a00; --amber-soft: #f6ead2;
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --surface-000: #eef0f3; --surface-100: #ffffff; --surface-200: #e3e6eb;
  --ink: #0b0d11; --ink-muted: #4b5564; --ink-faint: #5c6574; --ink-inverse: #eef0f3;
  --line: #d1d6de; --line-strong: #6f7886;
  --accent: #006e9e; --accent-soft: #d6edf8; --accent-ink: #005a82;
  --steel-hi: #ffffff; --steel-lo: #dde1e7;
  --warn: #8a5a00; --danger: #b3261e;
  --amber: #c98a00; --amber-ink: #8a5a00; --amber-soft: #f6ead2;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  display: grid; grid-template-rows: auto 1fr auto;
  font: 400 16px/1.5 var(--font-display); color: var(--ink);
  background-color: var(--surface-000);
  background-image: radial-gradient(var(--line) 1px, transparent 1.2px);
  background-size: 24px 24px;
}
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: var(--gutter); top: -100px; padding: 8px 12px; background: var(--accent); color: var(--ink-inverse); z-index: 10; }
.skip:focus { top: 8px; }

.label {
  font: 500 0.75rem/1.3 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--ink-faint); margin: 0;
}

/* Top bar */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: clamp(12px, 2.2vh, 22px) var(--edge);
  border-bottom: 1px solid var(--line); background: var(--surface-000);
}
.brand { display: inline-flex; color: var(--ink); padding: 6px 0; }
.logo { display: block; height: clamp(24px, 3.6vh, 32px); width: auto; }
.tools { display: flex; align-items: center; gap: 8px; }
.iconbtn {
  display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 0;
  background: transparent; color: var(--ink-muted); border: 1px solid var(--line-strong); cursor: pointer;
  transition: color 120ms var(--ease), border-color 120ms var(--ease), background-color 120ms var(--ease);
}
.iconbtn:hover { color: var(--ink); border-color: var(--ink-muted); background: var(--surface-100); }
.iconbtn svg { width: 18px; height: 18px; }
.iconbtn path { fill: currentColor; }
.theme svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.theme path { fill: none; }
/* show the icon of the theme you would switch to */
.theme .i-moon { display: none; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .theme .i-sun { display: none; } :root:not([data-theme="dark"]) .theme .i-moon { display: block; } }
:root[data-theme="light"] .theme .i-sun { display: none; }
:root[data-theme="light"] .theme .i-moon { display: block; }
:root[data-theme="dark"] .theme .i-sun { display: block; }

/* Main */
main {
  display: grid; gap: var(--gap) clamp(24px, 4vw, 64px);
  grid-template-columns: minmax(0, 1fr);
  padding: var(--gap) var(--gutter);
  width: 100%; max-width: var(--page-max); margin-inline: auto;
}
.hero { display: flex; flex-direction: column; align-items: flex-start; gap: clamp(12px, 2.4vh, 24px); }
h1 {
  margin: 0; font-weight: 600; letter-spacing: -0.02em; line-height: 0.98; text-wrap: balance;
  font-size: clamp(2.1rem, 8.4vw, 3rem);
}
.lede { margin: 0; max-width: 40ch; color: var(--ink-muted); font-size: clamp(1rem, 0.6rem + 1.1vh, 1.3rem); line-height: 1.45; }
.lede strong { color: var(--amber-ink); font-weight: 600; }
.btn {
  display: inline-flex; align-items: center; gap: 10px; min-height: 3rem;
  padding: 0.75rem 1.5rem; background: var(--accent); color: var(--ink-inverse);
  font: 500 1rem/1 var(--font-display); text-decoration: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.06), inset 0 -1px 0 rgba(0,0,0,.5);
  transition: background-color 120ms var(--ease);
}
.btn:hover { background: var(--accent-ink); }
.btn .arrow { font-family: var(--font-mono); transition: transform 120ms var(--ease); }
.btn:hover .arrow { transform: translateX(3px); }

/* Demo panel */
.demo { margin: 0; min-width: 0; }
.panel {
  padding: var(--pad); border: 1px solid var(--line);
  background: repeating-linear-gradient(90deg, rgba(255,255,255,.025) 0 1px, transparent 1px 3px), linear-gradient(135deg, var(--steel-hi), var(--steel-lo));
}
/* the demo repaints every frame; keep those repaints inside the panel */
.panel { position: relative; contain: layout paint; }
.panel svg { display: block; width: 100%; height: auto; overflow: visible; }

/* Steps */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
.steps li { background: var(--surface-100); border: 1px solid var(--line); border-top: 2px solid var(--line-strong); padding: clamp(10px, 1.8vh, 16px) 16px; }
.steps li { border-top-color: var(--amber); }
.steps .n { color: var(--amber-ink); }
.steps p { margin: 6px 0 0; color: var(--ink-muted); font-size: clamp(0.95rem, 0.6rem + 0.8vh, 1.05rem); line-height: 1.4; }

/* Footer */
.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; padding: clamp(10px, 1.6vh, 16px) var(--edge); border-top: 1px solid var(--line); background: var(--surface-000); }

/* Tablet and up: steps in a row */
@media (min-width: 720px) {
  .steps { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  h1 { font-size: clamp(2.4rem, 6vw, 3.4rem); }
}

/* Desktop: one view, no scroll */
@media (min-width: 960px) and (min-height: 600px) {
  body { height: 100vh; height: 100dvh; }
  /* main is a size container: the demo column is as wide as the panel can be at the
     height that is actually available, capped at 62% of the width. The hero text takes
     the rest, so there is never an empty band between the two on wide, short screens. */
  main {
    min-height: 0; align-content: center; container-type: size;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas: "hero demo" "steps steps";
  }
  .hero { grid-area: hero; justify-content: center; min-height: 0; container-type: inline-size; }
  .demo {
    grid-area: demo; min-height: 0; container-type: size; display: grid; place-items: center end;
    width: min(62cqw, (100cqh - var(--steps-h) - var(--gap) - 2 * var(--pad) - 2px) * 740 / 560 + 2 * var(--pad) + 2px);
  }
  /* inside its column the panel keeps the drawing's aspect ratio and fits whichever side is tighter */
  .panel { width: min(100cqw, (100cqh - 2 * var(--pad) - 2px) * 740 / 560 + 2 * var(--pad) + 2px); }
  .steps li { min-height: var(--steps-h); }
  .steps { grid-area: steps; }
  /* the headline also follows its own column, so it stays at about three lines */
  h1 { font-size: clamp(2.1rem, min(3.7vw, 6.6vh, 8.4cqw), 5.2rem); }
}

/* Large monitors (1440p and up): scale all rem-based text so it keeps up with the wider page */
@media (min-width: 2200px) and (min-height: 1200px) { html { font-size: 125%; } }

/* ---------- Demo: a looping investigation, driven by demo.js ----------
   Without JS (or with reduced motion) the final frame shows: tree + report.
   With JS, <html class="play"> and each [data-in] element gets .on inside its window. */
.demo text { font-family: var(--font-mono); font-weight: 500; letter-spacing: 0.06em; fill: var(--ink-faint); font-size: 13px; }
.demo .big { font-size: 14px; }
.demo .stage { font-size: 15px; fill: var(--ink); }
/* amber = the agent at work (stages, policy, tests in flight); cyan = verified */
.demo .s-amb, .demo .amb { fill: var(--amber-ink); }
.demo .acc { fill: var(--accent-ink); }
.demo .sm { font-size: 12px; }
.demo .t-warn { fill: var(--warn); }
.demo .mid { font-size: 14px; }
.demo .val { fill: var(--ink-muted); font-size: 13px; letter-spacing: 0.02em; }
.demo .pt { font-family: var(--font-display); font-size: 17px; font-weight: 400; letter-spacing: 0; fill: var(--ink-muted); }
.demo .pt .strong { fill: var(--ink); font-weight: 500; }
.demo .okt { fill: var(--accent-ink); }
.demo .huge { font-family: var(--font-display); font-size: 52px; font-weight: 600; letter-spacing: -0.02em; fill: var(--warn); }
.units text { text-anchor: middle; }
.rule { stroke: var(--line); stroke-width: 1; }
.card, .prow { fill: var(--surface-100); stroke: var(--line); stroke-width: 1; }

/* fleet */
.floor, .rail { stroke: var(--line-strong); stroke-width: 1; }
.legs { fill: none; stroke: var(--line); stroke-width: 2; }
.belt { stroke: var(--ink-faint); stroke-width: 3; stroke-dasharray: 2 14; animation: belt 1.6s linear infinite; }
.arm line { stroke: var(--ink-faint); stroke-width: 7; stroke-linecap: square; }
.arm path { fill: none; stroke: var(--ink-muted); stroke-width: 2; }
.arm circle { fill: var(--surface-000); stroke: var(--ink-muted); stroke-width: 2; }
.arm .base { fill: var(--surface-200); stroke: var(--ink-faint); stroke-width: 1.5; }
.box { fill: var(--surface-200); stroke: var(--ink-muted); stroke-width: 1.5; }
.arm { --cycle: 4s; --d: 0ms; }
.a184 { --d: -1300ms; } .a308 { --d: -500ms; } .a432 { --d: -2100ms; } .a556 { --d: -900ms; } .a680 { --d: -2900ms; }
.sh { transform-origin: 0 -30px; animation: sh var(--cycle) ease-in-out var(--d) infinite; }
.el { transform-origin: 0 -82px; animation: el var(--cycle) ease-in-out var(--d) infinite; }
.wr { transform-origin: 40px -82px; animation: wr var(--cycle) ease-in-out var(--d) infinite; }
.carry { opacity: 0; animation: carry var(--cycle) linear var(--d) infinite; }
.pick { animation: pick var(--cycle) linear var(--d) infinite; }
.place { opacity: 0; animation: place var(--cycle) linear var(--d) infinite; }
/* the drifting arm runs slower and turns amber once detected */
.arm.drift { --cycle: 5.6s; }
.drift line, .drift .base, .drift path, .drift circle, .drift .box { transition: stroke 600ms var(--ease); }
.drift.on line, .drift.on .base, .drift.on path, .drift.on circle, .drift.on .box { stroke: var(--warn); }
.driftbox { fill: none; stroke: var(--warn); stroke-width: 1.5; stroke-dasharray: 4 3; }

/* chart */
.grid { stroke: var(--line); stroke-width: 1; opacity: .6; }
.axis { stroke: var(--line-strong); stroke-width: 1; }
.peer { fill: none; stroke: var(--line-strong); stroke-width: 2; }
.series { fill: none; stroke: var(--ink); stroke-width: 2.5; stroke-linejoin: round; stroke-dasharray: 1; }
.series.post { transition: stroke 600ms var(--ease); }
.series.post.on { stroke: var(--warn); }
.cp { stroke: var(--amber); stroke-width: 2; transform-box: fill-box; transform-origin: top; }

/* hypothesis tree */
.root { fill: var(--surface-100); stroke: var(--warn); stroke-width: 1; }
.edge { fill: none; stroke: var(--line-strong); stroke-width: 1.5; stroke-dasharray: 1; }
.node { fill: var(--surface-100); stroke: var(--line); stroke-width: 1; }
.won { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.5; }
.demo .rank { fill: var(--ink-faint); font-size: 14px; }
.demo .tag { font-size: 11px; }
.demo .ht { font-family: var(--font-display); font-size: 17px; font-weight: 500; letter-spacing: 0; fill: var(--ink); }
.demo .tst { font-size: 12px; letter-spacing: 0.02em; }
.demo .ord { fill: var(--amber-ink); font-size: 13px; }
.testing { fill: none; stroke: var(--amber); stroke-width: 1.5; stroke-dasharray: 5 4; animation: march 1s linear infinite; }
.dim { fill: var(--surface-000); fill-opacity: .55; }
.strike { fill: var(--danger); transform-box: fill-box; transform-origin: left; }
.demo .res { font-size: 12px; }
.demo .bad { fill: var(--danger); }
.demo .ok { fill: var(--accent-ink); }

/* policy + experiments */
.track { fill: var(--surface-200); stroke: var(--line); stroke-width: 1; }
.bar { fill: var(--ink-faint); transform-box: fill-box; transform-origin: left; }
.bar.cost { fill: var(--line-strong); }
.bar.prior { fill: var(--amber); }
.bar.okb { fill: var(--accent); }
.pick-row { fill: none; stroke: var(--amber); stroke-width: 1.5; }
.pipe { stroke: var(--line-strong); stroke-width: 1.5; stroke-dasharray: 3 3; }
/* the isolated sandbox: a thick wall built into its box */
.sandbox { fill: var(--surface-200); stroke: var(--line-strong); stroke-width: 1.5; }
/* a square that carries data between boxes; it travels once each time it turns on */
.hop { fill: var(--amber); opacity: 0; }
.hop.on { animation: hop 840ms var(--ease) both; }

/* report */
.verdict { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1; }
.therefore { fill: var(--accent-ink); }
.demo .vt { font-size: 16px; fill: var(--ink); letter-spacing: 0.02em; }
.qed { fill: var(--accent); }

/* agent log */
.log { fill: var(--surface-200); stroke: var(--line); stroke-width: 1; }
.demo .prompt { fill: var(--amber-ink); font-size: 16px; }
.demo .logt { fill: var(--ink-muted); font-size: 14px; letter-spacing: 0.02em; }
.cursor { fill: var(--amber); animation: blink 1s steps(1) infinite; }

/* no JS: final frame only */
html:not(.play) .demo .pre { display: none; }

/* JS timeline states */
.play .fx:not(.on) { opacity: 0; }
.play .dr:not(.on) { stroke-dashoffset: 1; }
.play .dp:not(.on) { transform: scaleY(0); }
.play .st:not(.on) { transform: scaleX(0); }
.play .land:not(.on) { opacity: 0; transform: translateY(-10px); }
.ready .fx { transition: opacity 700ms var(--ease); }
.ready .dr { transition: stroke-dashoffset 900ms var(--ease); }
.ready .series.dr { transition-duration: 2600ms; transition-timing-function: linear; }
.ready .dp { transition: transform 500ms var(--ease); }
.ready .st { transition: transform 600ms var(--ease); }
.ready .bar.grow { transition-duration: 900ms; }
.ready .land { transition: opacity 400ms var(--ease), transform 400ms var(--ease); }
.land { transform-box: fill-box; }
/* swapped text (logs, stage names, live values) cuts out instantly instead of crossfading */
.ready .sw:not(.on) { transition-duration: 0s; }
/* the agent log types itself out */
.ready .logt.on { animation: type 1.6s steps(40, end) both; }

/* step cards follow the same timeline */
.steps li { position: relative; overflow: hidden; }
.steps li::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--amber); transform: scaleX(0); transform-origin: left; }
.ready .steps li { transition: background-color 500ms var(--ease), border-color 500ms var(--ease); }
.play .steps li:not(.on) { border-top-color: var(--line); }
.play .steps li:not(.on) .n { color: var(--ink-faint); }
.play .steps li.on { background: linear-gradient(var(--amber-soft), var(--surface-100) 70%); border-color: var(--line-strong); border-top-color: var(--amber); }
.play .steps li.on .n { color: var(--amber-ink); }

/* Phones: while the demo plays, the step cards collapse into a thin strip under it,
   with the active step's sentence below, so both fit on screen together. */
@media (max-width: 719px) {
  .play main { gap: 10px; }
  .play .steps { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; padding-bottom: 2.6em; }
  .play .steps li { overflow: visible; background: none; border: 0; border-top: 2px solid var(--line); padding: 8px 0 0; }
  .play .steps li.on { background: none; border-top-color: var(--line); }
  .play .steps li::after { top: -2px; bottom: auto; }
  .play .steps .n { font-size: clamp(9px, 2.6vw, 11px); letter-spacing: 0.02em; white-space: nowrap; }
  .play .steps .num { display: none; }
  .play .steps p { display: none; position: absolute; top: calc(100% + 6px); width: calc(400% + 18px); margin: 0; font-size: 0.95rem; color: var(--ink-muted); }
  .play .steps li.on p { display: block; }
  .play .steps li:nth-child(2) p { left: calc(-100% - 6px); }
  .play .steps li:nth-child(3) p { left: calc(-200% - 12px); }
  .play .steps li:nth-child(4) p { left: calc(-300% - 18px); }
}
.play .steps li.on::after { transform: scaleX(1); transition: transform var(--dur) linear; }
/* clicking a step card jumps the demo to that stage */
.play .steps li { cursor: pointer; }
@media (hover: hover) and (min-width: 720px) {
  .play .steps li:not(.on):hover { border-color: var(--line-strong); }
}

@keyframes sh { 0%, 12% { transform: rotate(-18.7deg); } 45%, 58% { transform: rotate(56.2deg); } 90%, 100% { transform: rotate(-18.7deg); } }
@keyframes el { 0%, 12% { transform: rotate(164.9deg); } 45%, 58% { transform: rotate(15.1deg); } 90%, 100% { transform: rotate(164.9deg); } }
@keyframes wr { 0%, 12% { transform: rotate(-146.2deg); } 45%, 58% { transform: rotate(-71.3deg); } 90%, 100% { transform: rotate(-146.2deg); } }
@keyframes carry { 0%, 11% { opacity: 0; } 12%, 56% { opacity: 1; } 57%, 100% { opacity: 0; } }
@keyframes pick { 0%, 11% { opacity: 1; transform: translateX(0); } 12%, 78% { opacity: 0; transform: translateX(-30px); } 80% { opacity: 1; transform: translateX(-30px); } 92%, 100% { opacity: 1; transform: translateX(0); } }
@keyframes place { 0%, 56% { opacity: 0; transform: translateX(0); } 57%, 82% { opacity: 1; transform: translateX(0); } 96%, 100% { opacity: 0; transform: translateX(30px); } }
@keyframes belt { to { stroke-dashoffset: -16; } }
@keyframes march { to { stroke-dashoffset: -18; } }
@keyframes hop { 0% { transform: translateX(0); opacity: 0; } 15%, 85% { opacity: 1; } 100% { transform: translateX(46px); opacity: 0; } }
@keyframes blink { 50% { opacity: 0; } }
@keyframes type { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* 404 */
main.nf { display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: clamp(12px, 2.4vh, 24px); max-width: var(--page-max); }
main.nf h1 { font-size: clamp(2.4rem, min(6vw, 10vh), 5rem); }
