/* Spacing is a 4/8 px scale. Radii: 8 for controls, 10 for blocks. Colours only through tokens. */
/* Space Grotesk, latin subset, variable weight; self-hosted so it does not block the first paint. */
@font-face {
  font-family: "Space Grotesk";
  font-weight: 300 700;
  font-display: swap;
  src: url("/fonts/space-grotesk-latin.woff2") format("woff2");
}

:root {
  --bg: #fafafa;
  --card: #ffffff;
  --fg: #18181b;
  --muted: #6c6c75;
  --border: #e4e4e8;
  --input: #d4d4d9;
  /* Amber, one hue in three strengths. Fills use --accent; thin lines and icons on a light page need the
     darker steps to stay visible. On the dark theme all three are the same amber. */
  --accent: #ffb547;         /* primary: buttons, switches, probes, highlights */
  --accent-strong: #c27406;  /* thin graphics: flow arrows, fact icons */
  --accent-ink: #a34a08;     /* text-level contrast: link hover, focus rings */
  --on-accent: #18181b;
  --danger: #ba1c1c;
  --part: #9a9aa2;
  --font-heading: "Space Grotesk", system-ui, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #17171a;
  --card: #1c1c1f;
  --fg: #ececef;
  --muted: #a1a1ab;
  --border: #2c2c30;
  --input: #38383e;
  --accent-strong: var(--accent);
  --accent-ink: var(--accent);
  --danger: #f87171;
  --part: #c7c7cc;
  color-scheme: dark;
}

* { box-sizing: border-box; }
.theme-fade, .theme-fade *, .theme-fade *::before, .theme-fade *::after {
  transition: background-color 300ms ease, color 300ms ease, border-color 300ms ease, fill 300ms ease, stroke 300ms ease !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 24px;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--fg); }
a:hover { color: var(--accent-ink); }
:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }

.wrap { max-width: 1120px; margin: 0 auto; padding-left: 24px; padding-right: 24px; }
.muted { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.mono { font-family: var(--font-mono); font-size: 13px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--input);
  border-radius: 8px;
  background: var(--card);
  color: var(--fg);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { border-color: var(--muted); color: var(--fg); }
.btn-primary { border-color: var(--accent); background: var(--accent); color: var(--on-accent); font-weight: 600; }
.btn-primary:hover { border-color: var(--accent); color: var(--on-accent); filter: brightness(0.95); }
.btn-wide { padding: 0 24px; }
.btn-icon { width: 44px; padding: 0; justify-content: center; border-color: transparent; background: transparent; color: var(--muted); }
.btn-small { width: 32px; min-height: 32px; }
.btn-icon:hover { border-color: transparent; color: var(--fg); }
.btn[disabled] { opacity: 0.45; cursor: default; }
.icon-caliper { flex: none; width: 18px; height: 18px; fill: currentColor; }
.icon-caliper-window { fill: var(--accent); }
.icon { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* Header */
.site-header { position: sticky; top: 0; z-index: 10; background: var(--bg); border-bottom: 1px solid var(--border); }
.site-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 0 32px; min-height: 56px; }
.brand { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 44px; margin-right: 32px; padding: 6px 0; text-decoration: none; }
.brand-name { font-family: var(--font-heading); font-weight: 600; font-size: 20px; line-height: 24px; }
.brand-tag { display: flex; justify-content: center; align-items: center; gap: 4px; width: 0; white-space: nowrap; margin-left: 14px; transform: rotate(-1.5deg); transform-origin: center; font-family: var(--font-heading); font-size: 12px; line-height: 16px; font-weight: 500; letter-spacing: 0.01em; color: var(--muted); }
.heart { flex: none; width: 16px; height: 16px; fill: var(--accent); }
.nav-links { display: flex; flex-wrap: wrap; flex: 1 1 auto; gap: 0 24px; font-size: 14px; }
.nav-links a { color: var(--muted); text-decoration: none; line-height: 44px; }
.nav-links a:hover { color: var(--fg); }
.nav-actions { display: flex; align-items: center; gap: 8px; }
:root[data-theme="dark"] .only-light, :root:not([data-theme="dark"]) .only-dark { display: none; }

/* Hero */
.hero { padding-top: 64px; padding-bottom: 32px; }
.hero-text { max-width: 640px; }
.hero h1 { text-wrap: balance; font-family: var(--font-heading); font-weight: 600; font-size: clamp(36px, 5vw, 56px); line-height: 1.08; letter-spacing: -0.03em; }
.hero .hl { color: var(--accent-strong); }
.hero-lead { max-width: 640px; margin-top: 24px; text-wrap: balance; font-size: 20px; line-height: 32px; color: var(--muted); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 32px; }

/* Sections: 48 px top and bottom, so neighbours sit 96 px apart. */
.section { padding-top: 48px; padding-bottom: 48px; }
.section-title, .cta h2 { font-family: var(--font-heading); font-weight: 600; letter-spacing: -0.02em; }
.section-title { max-width: 640px; font-size: 32px; line-height: 40px; }
.section-action { display: flex; justify-content: center; margin-top: 48px; }

/* How it works and showcase */
/* The steps stay under the sticky header (56 px nav + 1 px border) while the showcase scrolls past, and
   leave with the section. Their vertical padding is taken from the section and the showcase gap. */
.examples { padding-top: 32px; padding-bottom: 48px; }
.steps { position: sticky; top: 57px; z-index: 5; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 40px; padding: 16px 1px; background: var(--bg); container-type: scroll-state; }
/* A rule under the row only while it is stuck; browsers without scroll-state queries skip it. */
@container scroll-state(stuck: top) { .steps::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; border-bottom: 1px solid var(--border); } }
.steps > div { padding: 0 16px; }
.steps h2 { font-family: var(--font-heading); font-weight: 600; font-size: 20px; line-height: 32px; letter-spacing: -0.01em; }
.steps p { font-size: 14px; line-height: 20px; color: var(--muted); }
.flow-arrow { display: flex; align-items: center; justify-content: center; height: 32px; color: var(--muted); }
/* Flow arrow: a dot where the step starts, a dashed run, a solid amber head. */
.flow-arrow svg { width: 40px; height: 16px; overflow: visible; }
.arrow-dot { fill: var(--accent-strong); }
.arrow-line { fill: none; stroke: var(--accent-strong); stroke-width: 1.75; stroke-linecap: round; stroke-dasharray: 0.1 4.5; }
.arrow-head { fill: var(--accent-strong); }
.showcase { display: flex; flex-direction: column; gap: 48px; margin-top: 80px; }
.case-row { display: grid; grid-template-columns: minmax(0, 1fr) 40px minmax(0, 1fr) 40px minmax(0, 1fr); }
.case-row .flow-arrow { height: auto; }
.case-col { display: flex; flex-direction: column; gap: 8px; min-width: 0; padding: 0 16px; }
.chat-panel { flex: 1; display: flex; flex-direction: column; justify-content: center; min-height: 264px; font-size: 14px; line-height: 20px; }
/* The request as a sent message in a messenger: right side, filled, the corner nearest the sender squared off. */
.message { align-self: center; display: flex; flex-direction: column; gap: 6px; max-width: 92%; padding: 6px 12px 8px; border-radius: 16px 16px 4px 16px; background: color-mix(in srgb, var(--accent) 22%, var(--card)); color: var(--fg); }
.message:has(.chat-attachments) { padding-top: 6px; }
.chat-attachments { display: flex; gap: 4px; margin: 0 -6px; }
.thumb { display: block; flex: 1 1 0; min-width: 0; padding: 0; border: 0; border-radius: 12px; background: none; cursor: zoom-in; overflow: hidden; }
.thumb img { display: block; width: 100%; height: 64px; object-fit: cover; }
.model-tile { position: relative; flex: 1; min-height: 264px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); cursor: zoom-in; }
.tile-stage { position: absolute; inset: 40px 8px 44px; pointer-events: none; }
.tile-stage canvas, .lb-stage canvas { display: block; width: 100%; height: 100%; }
.photo-tile { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; min-height: 264px; padding: 16px 56px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); }
.photo-placeholder { font-size: 14px; line-height: 20px; color: var(--muted); text-align: center; }
.tile-downloads { position: absolute; left: 4px; bottom: 4px; display: flex; gap: 4px; }
.tile-download { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 8px; border-radius: 8px; color: var(--fg); font-size: 13px; font-weight: 500; text-decoration: none; }
.tile-download:hover { background: color-mix(in srgb, var(--fg) 6%, transparent); color: var(--fg); }
.tile-download .mono { font-size: 12px; }
.tile-expand { position: absolute; top: 4px; right: 4px; }
.mass { position: absolute; top: 4px; left: 12px; font-size: 12px; line-height: 32px; }
.photo-count { position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); }
.carousel-nav { position: absolute; top: 50%; transform: translateY(-50%); }
.carousel-nav.prev { left: 8px; }
.carousel-nav.next { right: 8px; }

/* What you get */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 32px 48px; margin-top: 48px; }
.facts > div { display: flex; gap: 16px; }
.fact-icon { flex: none; width: 24px; height: 24px; margin-top: 2px; fill: none; stroke: var(--accent-strong); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.facts h3 { font-size: 16px; line-height: 24px; font-weight: 600; }
.facts p { margin-top: 4px; font-size: 14px; line-height: 20px; color: var(--muted); }

/* Questions */
.faq { max-width: 800px; margin-top: 32px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--card); }
.faq-item + .faq-item { border-top: 1px solid var(--border); }
.faq h3 { margin: 0; padding: 16px 24px 4px; font-size: 16px; line-height: 24px; font-weight: 600; }
.faq p { padding: 0 24px 16px; color: var(--muted); }

/* Closing action and footer */
.cta { padding-top: 48px; padding-bottom: 96px; }
.cta > div { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px 24px; padding: 24px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); }
.cta h2 { font-size: 20px; line-height: 32px; letter-spacing: -0.01em; }
.site-footer { border-top: 1px solid var(--border); }
.site-footer > div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px; padding-top: 32px; padding-bottom: 32px; font-size: 14px; line-height: 20px; color: var(--muted); }

/* Viewer dialog: 200 ms fade and rise. Esc, the backdrop and the close button close it. */
.modal { width: 100%; max-width: none; height: 100%; max-height: none; margin: 0; padding: 0; border: 0; background: transparent; color: var(--fg); overflow: auto; overscroll-behavior: contain; }
body:has(.modal[open]) { overflow: hidden; }
.modal::backdrop { background: rgb(11 11 13 / 0.6); }
.modal[open], .modal[open]::backdrop { animation: modal-fade 200ms ease-out; }
.modal[open] .modal-panel { animation: modal-rise 200ms ease-out; }
@keyframes modal-fade { from { opacity: 0; } }
@keyframes modal-rise { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.modal-frame { display: flex; align-items: center; justify-content: center; gap: 16px; min-height: 100%; padding: 32px 16px; }
.modal-panel { display: flex; flex-direction: column; width: 100%; max-width: 1120px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); overflow: hidden; box-shadow: 0 16px 48px rgb(0 0 0 / 0.24); }
.modal-panel:focus { outline: none; }
.modal-nav { flex: none; }
.modal-head { position: relative; display: flex; align-items: center; gap: 16px; min-height: 56px; padding: 0 8px 0 24px; border-bottom: 1px solid var(--border); }
.modal-head h2 { flex: 1 1 auto; font-family: var(--font-heading); font-weight: 600; font-size: 20px; line-height: 32px; letter-spacing: -0.01em; }
.modal-head .mono { white-space: nowrap; }
.lb-stage { width: 100%; height: 100%; cursor: grab; }
.lb-stage:active { cursor: grabbing; }
.legend { display: flex; flex-direction: column; min-width: 0; overflow-y: auto; padding: 8px 12px 8px 4px; border-left: 1px solid var(--border); background: var(--card); font-size: 14px; line-height: 20px; }
.legend-row { display: flex; align-items: center; gap: 8px; min-height: 40px; border-radius: 6px; cursor: pointer; }
.legend-row.child { padding-left: 20px; font-size: 13px; }
.legend-row:hover { background: color-mix(in srgb, var(--fg) 5%, transparent); }
/* Selection matches the body: grey for printed parts, amber for probes. */
.legend-row.selected { background: color-mix(in srgb, var(--fg) 12%, transparent); }
.legend-row.probe.selected { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.legend-slot { display: inline-flex; flex: none; width: 28px; height: 28px; }
.legend-label { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-open { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0; border: 0; background: none; color: var(--muted); cursor: pointer; }
.legend-open .icon { transition: transform 150ms ease; }
.legend-open[aria-expanded="true"] .icon { transform: rotate(90deg); }
.legend-files { display: inline-flex; flex: none; gap: 2px; width: 84px; justify-content: flex-end; }
.legend-file { padding: 2px 6px; border-radius: 6px; color: var(--muted); font-family: var(--font-mono); font-size: 11px; line-height: 16px; text-decoration: none; }
.legend-file:hover { background: color-mix(in srgb, var(--fg) 8%, transparent); color: var(--fg); }
.switch[aria-checked="mixed"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 45%, var(--input)); }
.switch[aria-checked="mixed"]::after { left: 10px; }
.legend-folder { display: inline-flex; flex: none; width: 16px; margin: 0 -2px; color: var(--muted); }
.legend-swatch { flex: none; width: 12px; height: 12px; border-radius: 4px; background: var(--part); }
.legend-swatch.probe { background: var(--accent); }
.switch { position: relative; flex: none; width: 36px; height: 20px; padding: 0; border: 1px solid var(--input); border-radius: 10px; background: var(--input); cursor: pointer; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 7px; background: var(--card); transition: left 120ms ease-out; }
.switch[aria-checked="true"] { border-color: var(--accent); background: var(--accent); }
.switch[aria-checked="true"]::after { left: 18px; }
.hover-tip { position: absolute; z-index: 1; padding: 4px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); font-size: 12px; line-height: 16px; white-space: nowrap; pointer-events: none; }
.lb-panel { max-width: 1280px; }
/* 3D view on the left, the legend as a side panel on the right so it never covers the model. */
.lb-viewer { display: grid; grid-template-columns: minmax(0, 1fr) 360px; height: min(76vh, 680px); background: var(--bg); }
.lb-viewer .lb-stage { position: relative; min-width: 0; }
/* Photo mode: just the photo on the backdrop, a floating close button, plain arrows. */
.lb-photo { display: flex; justify-content: center; margin: 0; }
.lb-photo img { display: block; max-width: 100%; max-height: 86vh; border-radius: 8px; object-fit: contain; }
.photo-mode .modal-panel { position: relative; border: 0; background: transparent; box-shadow: none; }
.photo-mode .modal-head { position: absolute; top: 0; right: 0; z-index: 1; min-height: 0; padding: 4px; border: 0; }
.photo-mode .modal-head h2, .photo-mode .modal-head .mono { display: none; }
.photo-mode .modal-head [data-close], .photo-mode .modal-nav { color: #fff; }
.photo-mode .modal-head [data-close] { background: rgb(0 0 0 / 0.35); border-radius: 8px; }
.modal-nav.btn-icon:hover { color: var(--fg); }
.photo-mode .modal-nav.btn-icon:hover { color: var(--accent); }

/* Open app page */
.entry { min-height: 100vh; display: flex; flex-direction: column; }
.entry-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; padding: 0 24px; }
.entry-header a { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; color: var(--muted); font-size: 14px; text-decoration: none; }
.entry-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px 96px; }
.entry-logo { width: 144px; height: auto; margin-bottom: 16px; }
.entry-card { width: 100%; max-width: 416px; padding: 24px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); }
.entry-card h1 { font-family: var(--font-heading); font-weight: 600; font-size: 20px; line-height: 32px; letter-spacing: -0.01em; }
.entry-card h1 + p { margin-top: 4px; font-size: 14px; line-height: 20px; color: var(--muted); }
.entry-card form { display: flex; flex-direction: column; margin-top: 24px; }
.entry-card label { font-size: 14px; line-height: 20px; font-weight: 500; }
.field { min-height: 44px; margin-top: 8px; padding: 0 12px; border: 1px solid var(--input); border-radius: 8px; background: var(--bg); color: var(--fg); font: inherit; }
.field:focus-visible { outline: none; border-color: var(--accent-ink); }
.field[aria-invalid="true"] { border-color: var(--danger); }
.field-error { min-height: 16px; margin-top: 4px; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--danger); }
.check { display: flex; align-items: flex-start; gap: 8px; min-height: 44px; margin-top: 8px; font-weight: 400 !important; cursor: pointer; }
.check input { flex: none; width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--accent); }
.entry-card .btn-primary { justify-content: center; margin-top: 16px; }
.fine { margin-top: 16px; font-size: 12px; line-height: 16px; color: var(--muted); }
.trap { position: absolute; left: -9999px; }
[hidden] { display: none !important; }

[id] { scroll-margin-top: 72px; }

@media (max-width: 880px) {
  .site-header { position: static; }
  .nav-links { display: none; }
  .brand { flex: 1 1 auto; }
  .steps { display: none; }
  .showcase { margin-top: 48px; }
  .hero { padding-top: 32px; }
  .case-row { grid-template-columns: minmax(0, 1fr); }
  .case-row .flow-arrow { height: 24px; }
  .case-row .flow-arrow svg { transform: rotate(90deg); }
  .chat-panel, .model-tile, .photo-tile { min-height: 220px; }
  .lb-viewer { grid-template-columns: minmax(0, 1fr); grid-template-rows: 55vh minmax(0, 1fr); height: auto; max-height: none; }
  .legend { max-height: 40vh; border-left: 0; border-top: 1px solid var(--border); }
  .modal-frame { align-items: stretch; padding: 0; }
  .modal-nav { display: none; }
  .modal-panel { max-width: none; border: 0; border-radius: 0; }
  .modal-head { flex-wrap: wrap; gap: 0 16px; padding: 6px 60px 6px 16px; }
  .modal-head h2 { flex-basis: 100%; }
  .modal-head [data-close] { position: absolute; top: 6px; right: 8px; }
  .entry-main { justify-content: flex-start; }
}

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