@layer reset, tokens, base, components, responsive;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { scroll-behavior: smooth; }
  body, h1, h2, h3, p, dl, dd, ul, figure { margin: 0; }
  button, input { font: inherit; }
  button, a { -webkit-tap-highlight-color: transparent; }
  img, svg { display: block; max-width: 100%; }
}

@layer tokens {
  :root {
    --ink-950: oklch(0.17 0.014 155);
    --ink-900: oklch(0.205 0.016 155);
    --ink-850: oklch(0.25 0.018 155);
    --line: oklch(0.48 0.022 155 / .58);
    --line-soft: oklch(0.48 0.022 155 / .27);
    --paper: oklch(0.95 0.012 105);
    --muted: oklch(0.78 0.022 120);
    --amber: oklch(0.79 0.14 72);
    --uv: oklch(0.7 0.23 302);
    --probe: oklch(0.86 0.15 91);
    --signal: oklch(0.81 0.11 207);
    --font-display: "Space Grotesk", sans-serif;
    --font-mono: "IBM Plex Mono", monospace;
    --radius: 6px;
    --wrap: 1400px;
  }
}

@layer base {
  body {
    min-width: 320px;
    min-height: 100dvh;
    overflow-x: hidden;
    color: var(--paper);
    background: var(--ink-950);
    font-family: var(--font-display);
    font-size: 16px;
    line-height: 1.65;
  }
  a { color: inherit; text-decoration: none; }
  button { color: inherit; cursor: pointer; }
  button:disabled { cursor: not-allowed; opacity: .45; }
  button, a, summary, input { outline-offset: 4px; }
  :focus-visible { outline: 2px solid var(--amber); }
  ::selection { color: var(--ink-950); background: var(--amber); }
  .wrap { width: min(calc(100% - 48px), var(--wrap)); margin-inline: auto; }
  .section-anchor { scroll-margin-top: 88px; }
  .sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
  .skip-link { position: fixed; top: 8px; left: 8px; z-index: 20; padding: 12px 16px; color: var(--ink-950); background: var(--amber); transform: translateY(-160%); transition: transform 180ms ease-out; }
  .skip-link:focus { transform: translateY(0); }
  .eyebrow { color: var(--amber); font-family: var(--font-mono); font-size: 11px; font-weight: 500; letter-spacing: .12em; line-height: 1.5; text-transform: uppercase; }
  h1, h2, h3 { font-weight: 500; letter-spacing: -.045em; }
  h2 { font-size: clamp(38px, 5vw, 68px); line-height: 1.04; }
  h3 { font-size: clamp(27px, 3vw, 42px); line-height: 1.12; }
  .section-heading { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(280px, .7fr); gap: 72px; align-items: end; margin-bottom: 48px; }
  .section-heading h2 { margin-top: 18px; }
  .section-heading > p, .section-copy { max-width: 50ch; color: var(--muted); font-size: 17px; line-height: 1.65; }
  .section-copy { display: grid; gap: 16px; }
  .section-copy strong { color: var(--paper); font-weight: 500; }
}

@layer components {
  .site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    min-height: 72px;
    padding: 0 max(24px, calc((100vw - var(--wrap)) / 2));
    border-bottom: 1px solid var(--line-soft);
    background: oklch(0.17 0.014 155 / .9);
    backdrop-filter: blur(18px);
  }
  .wordmark { display: flex; align-items: center; gap: 14px; width: fit-content; font-family: var(--font-mono); font-size: 12px; letter-spacing: .05em; text-transform: uppercase; }
  .wordmark > span:first-child { display: grid; width: 36px; height: 36px; place-items: center; border: 1px solid var(--line); color: var(--amber); font-weight: 600; }
  .site-header nav { display: flex; align-items: center; gap: 32px; }
  .site-header nav a, .workspace-link { position: relative; min-height: 44px; display: inline-flex; align-items: center; color: var(--muted); font-size: 14px; transition: color 180ms ease-out; }
  .site-header nav a:hover, .workspace-link:hover { color: var(--paper); }
  .workspace-link { justify-self: end; font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; }

  .hero { padding-block: 104px 80px; }
  .hero-label { display: flex; align-items: center; gap: 10px; color: var(--muted); font-family: var(--font-mono); font-size: 11px; letter-spacing: .12em; }
  .hero-label > span { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 18px var(--amber); }
  .hero h1 { max-width: 1240px; margin-top: 36px; font-size: clamp(56px, 7.25vw, 106px); line-height: .98; letter-spacing: -.065em; }
  .hero h1 span { color: var(--amber); }
  .hero-bottom { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 48px; align-items: end; margin-top: 56px; }
  .hero-bottom > p { max-width: 610px; color: var(--muted); font-size: clamp(18px, 1.8vw, 23px); line-height: 1.5; }
  .button { display: inline-flex; align-items: center; justify-content: center; gap: 28px; min-height: 52px; padding: 13px 20px; border: 1px solid transparent; border-radius: var(--radius); font-family: var(--font-mono); font-size: 12px; font-weight: 600; transition: color 180ms ease-out, background-color 180ms ease-out, transform 180ms ease-out; }
  .button:hover { transform: translateY(-2px); }
  .button:active { transform: translateY(0); }
  .button-primary { color: var(--ink-950); background: var(--amber); }
  .button-primary:hover { background: var(--paper); }
  .hero-facts { display: grid; grid-template-columns: repeat(3, 1fr); margin-top: 72px; border-block: 1px solid var(--line-soft); }
  .hero-facts > div { display: grid; gap: 5px; padding: 22px 28px; border-right: 1px solid var(--line-soft); }
  .hero-facts > div:first-child { padding-left: 0; }
  .hero-facts > div:last-child { border-right: 0; }
  .hero-facts dt { color: var(--muted); font-family: var(--font-mono); font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
  .hero-facts dd { font-size: 15px; }

  .experiment { padding-block: 96px 112px; }
  .instrument-shell { display: grid; grid-template-columns: minmax(0, 1fr) 350px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--ink-900); box-shadow: 0 32px 90px oklch(0.08 0.01 155 / .25); }
  .viewer-column { min-width: 0; border-right: 1px solid var(--line); }
  .viewer-topline, .viewer-bottomline { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 48px; padding-inline: 18px; color: var(--muted); font-family: var(--font-mono); font-size: 10px; letter-spacing: .06em; }
  .viewer-topline { border-bottom: 1px solid var(--line-soft); }
  .viewer-topline > span:last-child { color: var(--amber); }
  .viewer-bottomline { border-top: 1px solid var(--line-soft); }
  .viewer-bottomline button { min-height: 44px; padding: 0; border: 0; color: var(--paper); background: none; font-family: var(--font-mono); font-size: 10px; text-transform: uppercase; }
  .viewer-bottomline button:hover { color: var(--amber); }
  .cad-view { position: relative; height: 590px; overflow: hidden; background: radial-gradient(circle at 52% 42%, oklch(0.29 0.024 165), var(--ink-950) 74%); }
  .cad-view canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
  .cad-poster { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); background: var(--ink-950); font-family: var(--font-mono); font-size: 11px; }
  .cad-poster img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: .55; }
  .cad-poster span { position: absolute; bottom: 18px; padding: 7px 10px; background: var(--ink-900); }
  .cad-view.ready .cad-poster { display: none; }
  .model-label { position: absolute; z-index: 2; display: flex; flex-direction: column; min-width: 106px; padding: 7px 9px; border: 1px solid var(--line-soft); border-radius: 3px; color: var(--paper); background: oklch(0.17 0.014 155 / .84); font-family: var(--font-mono); font-size: 10px; line-height: 1.5; pointer-events: none; opacity: 0; transition: opacity 180ms ease-out, border-color 180ms ease-out; backdrop-filter: blur(8px); }
  .cad-view.ready .model-label { opacity: .72; }
  .cad-view.ready .model-label.active { border-color: var(--amber); opacity: 1; }
  .model-label small { color: var(--muted); font-size: 9px; }
  .model-label b { font-weight: 500; }
  .label-d8.active { border-color: var(--uv) !important; }
  .label-probe.active, .label-sensor.active { border-color: var(--signal) !important; }

  .story-panel { display: flex; flex-direction: column; min-width: 0; }
  .step-story { min-height: 210px; padding: 28px 26px; border-bottom: 1px solid var(--line-soft); }
  #step-kicker { color: var(--amber); font-family: var(--font-mono); font-size: 10px; letter-spacing: .09em; }
  #step-title { margin-top: 14px; font-size: 28px; line-height: 1.12; letter-spacing: -.035em; }
  #step-description { margin-top: 16px; color: var(--muted); font-size: 14px; line-height: 1.6; }
  .sequence { display: grid; padding: 10px 24px; }
  .sequence button { display: grid; grid-template-columns: 26px 1fr; gap: 12px; align-items: center; min-height: 70px; padding: 10px 0; border: 0; border-bottom: 1px solid var(--line-soft); color: var(--muted); background: none; text-align: left; transition: color 160ms ease-out, transform 160ms ease-out; }
  .sequence button:last-child { border-bottom: 0; }
  .sequence button:hover { color: var(--paper); transform: translateX(3px); }
  .sequence button.active { color: var(--paper); }
  .sequence button > span:first-child { display: grid; width: 24px; height: 24px; place-items: center; border: 1px solid var(--line); border-radius: 50%; font-family: var(--font-mono); font-size: 10px; }
  .sequence button.active > span:first-child { color: var(--ink-950); border-color: var(--amber); background: var(--amber); }
  .sequence button > span:last-child { display: flex; flex-direction: column; }
  .sequence b { font-size: 14px; font-weight: 500; }
  .sequence small { color: var(--muted); font-size: 11px; }
  .playback { display: grid; grid-template-columns: 1fr 46px; gap: 8px; align-items: center; margin-top: auto; padding: 20px 24px; border-top: 1px solid var(--line-soft); }
  .play-toggle, .icon-button { min-height: 46px; border: 1px solid var(--line); border-radius: var(--radius); background: transparent; transition: border-color 160ms ease-out, color 160ms ease-out; }
  .play-toggle { display: flex; align-items: center; justify-content: center; gap: 10px; font-family: var(--font-mono); font-size: 11px; }
  .play-toggle:hover, .icon-button:hover { border-color: var(--amber); color: var(--amber); }
  .icon-button { font-size: 20px; }
  .progress-track { grid-column: 1 / -1; height: 2px; overflow: hidden; background: var(--line-soft); }
  .progress-track > span { display: block; width: 100%; height: 100%; background: var(--amber); transform: scaleX(0); transform-origin: left; }

  .readout-simple { display: grid; grid-template-columns: 1fr 1fr 1.35fr; border: 1px solid var(--line); border-top: 0; }
  .readout-cell { display: grid; gap: 4px; padding: 24px 28px; border-right: 1px solid var(--line); transition: background-color 200ms ease-out; }
  .readout-cell:last-child { border-right: 0; }
  .readout-cell > span, .readout-cell > small { color: var(--muted); font-family: var(--font-mono); font-size: 10px; }
  .readout-cell > span { letter-spacing: .07em; text-transform: uppercase; }
  .readout-cell strong { font-family: var(--font-mono); font-size: 25px; font-weight: 500; }
  .readout-cell.active { background: var(--ink-850); }
  .readout-cell.done strong { color: var(--signal); }
  .delta-cell.active strong, .delta-cell.done strong { color: var(--amber); }
  .demo-note { margin-top: 16px; color: var(--muted); font-size: 13px; }

  .trial-section { padding-block: 104px; background: var(--ink-900); }
  .trial-layout { display: grid; grid-template-columns: 1.05fr .58fr .87fr; gap: 32px; align-items: stretch; }
  .image-button { position: relative; overflow: hidden; padding: 0; border: 1px solid var(--line-soft); border-radius: var(--radius); color: var(--paper); background: var(--ink-950); }
  .image-button::after { position: absolute; right: 12px; bottom: 12px; padding: 7px 10px; color: var(--paper); background: oklch(0.17 0.014 155 / .88); content: "VIEW +"; font-family: var(--font-mono); font-size: 9px; opacity: 0; transition: opacity 180ms ease-out; }
  .image-button:hover::after, .image-button:focus-visible::after { opacity: 1; }
  .image-button img { width: 100%; height: 100%; object-fit: cover; transition: transform 240ms ease-out, opacity 240ms ease-out; }
  .image-button:hover img { transform: scale(1.012); opacity: .92; }
  .trial-main { min-height: 610px; }
  .trial-main > span { position: absolute; top: 16px; left: 16px; padding: 7px 10px; color: var(--paper); background: oklch(0.17 0.014 155 / .88); font-family: var(--font-mono); font-size: 10px; letter-spacing: .06em; }
  .trial-proof { display: grid; grid-template-rows: 1fr 1fr auto; gap: 16px; }
  .trial-proof .image-button { min-height: 260px; }
  .trial-proof .image-button img { object-position: center 58%; }
  .trial-proof > p { color: var(--muted); font-size: 13px; line-height: 1.6; }
  .production-note { align-self: center; padding-left: 24px; }
  .production-note h3 { margin-block: 18px 24px; }
  .production-note > p:not(.eyebrow) { color: var(--muted); }
  .production-note ul { display: grid; gap: 12px; margin-top: 28px; padding: 24px 0 0; border-top: 1px solid var(--line); list-style: none; }
  .production-note li { position: relative; padding-left: 24px; font-size: 14px; }
  .production-note li::before { position: absolute; left: 0; color: var(--amber); content: "+"; font-family: var(--font-mono); }

  .software-section { padding-block: 112px; }
  .software-shot { display: block; width: 100%; background: oklch(0.96 0.015 155); }
  .software-shot img { height: auto; max-height: 820px; object-fit: contain; }
  .image-caption { margin-top: 12px; color: var(--muted); font-family: var(--font-mono); font-size: 10px; }

  .v1-section { padding-block: 104px; border-top: 1px solid var(--line-soft); background: var(--ink-900); }
  .v1-flow { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr; gap: 24px; align-items: center; padding-block: 28px; border-block: 1px solid var(--line); }
  .v1-flow span { display: flex; align-items: center; gap: 14px; font-size: 16px; }
  .v1-flow b { display: grid; flex: 0 0 30px; width: 30px; height: 30px; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--amber); font-family: var(--font-mono); font-size: 11px; font-weight: 500; }
  .v1-flow i { color: var(--muted); font-style: normal; }
  .archive-feature { display: grid; grid-template-columns: 1.15fr .85fr; gap: 72px; align-items: center; padding-block: 64px; }
  .archive-image { min-height: 460px; }
  .archive-feature h3 { margin-block: 18px 24px; }
  .archive-feature p:not(.eyebrow) { color: var(--muted); }
  .archive-details { border-block: 1px solid var(--line); }
  .archive-details summary { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 80px; cursor: pointer; list-style: none; }
  .archive-details summary::-webkit-details-marker { display: none; }
  .archive-details summary span { font-size: 18px; }
  .archive-details summary small { color: var(--muted); font-family: var(--font-mono); font-size: 10px; }
  .archive-details summary::after { content: "+"; color: var(--amber); font-family: var(--font-mono); font-size: 24px; }
  .archive-details[open] summary::after { content: "−"; }
  .gallery-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px 16px; padding-block: 16px 48px; }
  .gallery-item { display: grid; gap: 10px; align-content: start; }
  .gallery-item .image-button { aspect-ratio: 4 / 3; }
  .gallery-item .image-button img { object-fit: contain; }
  .gallery-item figcaption { color: var(--muted); font-family: var(--font-mono); font-size: 10px; line-height: 1.5; }

  .site-footer { display: flex; align-items: center; justify-content: space-between; gap: 32px; padding-block: 32px; color: var(--muted); font-size: 13px; }
  .site-footer strong { color: var(--paper); font-weight: 500; }
  .site-footer a { display: inline-flex; align-items: center; min-height: 44px; color: var(--paper); }
  .site-footer a:hover { color: var(--amber); }
  .image-dialog { width: min(1100px, calc(100% - 32px)); max-height: 90dvh; padding: 0; border: 1px solid var(--line); border-radius: var(--radius); color: var(--paper); background: var(--ink-900); }
  .image-dialog::backdrop { background: oklch(0.09 0.01 155 / .88); backdrop-filter: blur(8px); }
  .image-dialog img { width: 100%; max-height: 78dvh; object-fit: contain; background: var(--ink-950); }
  .image-dialog p { padding: 16px 56px 16px 16px; color: var(--muted); font-family: var(--font-mono); font-size: 11px; }
  .dialog-close { position: absolute; top: 8px; right: 8px; z-index: 2; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 50%; color: var(--paper); background: oklch(0.17 0.014 155 / .9); font-size: 24px; }
}

@layer responsive {
  @media (max-width: 1120px) {
    .site-header { grid-template-columns: 1fr auto; }
    .site-header nav { display: none; }
    .hero { padding-block: 88px 72px; }
    .instrument-shell { grid-template-columns: 1fr; }
    .viewer-column { border-right: 0; border-bottom: 1px solid var(--line); }
    .cad-view { height: 570px; }
    .story-panel { display: grid; grid-template-columns: .85fr 1.15fr; }
    .step-story { min-height: 0; border-right: 1px solid var(--line-soft); }
    .sequence { grid-template-columns: 1fr 1fr; gap: 0 20px; }
    .sequence button:nth-child(3) { border-bottom: 0; }
    .playback { grid-column: 1 / -1; }
    .trial-layout { grid-template-columns: 1fr 1fr; }
    .production-note { grid-column: 1 / -1; max-width: 720px; padding: 24px 0 0; }
    .gallery-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  }

  @media (max-width: 760px) {
    .wrap { width: min(calc(100% - 32px), var(--wrap)); }
    .site-header { min-height: 64px; padding-inline: 16px; }
    .wordmark > span:last-child { font-size: 10px; }
    .workspace-link { font-size: 10px; }
    .hero { padding-block: 64px; }
    .hero h1 { margin-top: 28px; font-size: clamp(49px, 13.5vw, 76px); }
    .hero-bottom { grid-template-columns: 1fr; gap: 28px; margin-top: 36px; }
    .hero-bottom .button { width: fit-content; }
    .hero-facts { grid-template-columns: 1fr; margin-top: 48px; }
    .hero-facts > div { padding: 16px 0; border-right: 0; border-bottom: 1px solid var(--line-soft); }
    .hero-facts > div:last-child { border-bottom: 0; }
    .section-heading { grid-template-columns: 1fr; gap: 24px; margin-bottom: 36px; }
    .section-heading > p, .section-copy { font-size: 16px; }
    .experiment, .software-section { padding-block: 72px; }
    .trial-section, .v1-section { padding-block: 72px; }
    .cad-view { height: 430px; }
    .viewer-topline, .viewer-bottomline { padding-inline: 12px; font-size: 9px; }
    .model-label { min-width: 0; padding: 5px 7px; font-size: 9px; }
    .model-label small { display: none; }
    .story-panel { display: flex; }
    .step-story { min-height: 190px; border-right: 0; }
    .sequence { grid-template-columns: 1fr 1fr; gap: 0 16px; }
    .sequence button { min-height: 76px; }
    .sequence small { font-size: 10px; }
    .readout-simple { grid-template-columns: 1fr; border-top: 0; }
    .readout-cell { padding: 20px; border-right: 0; border-bottom: 1px solid var(--line); }
    .readout-cell:last-child { border-bottom: 0; }
    .trial-layout { grid-template-columns: 1fr; }
    .trial-main { min-height: 520px; }
    .trial-proof { grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; }
    .trial-proof .image-button { min-height: 320px; }
    .trial-proof > p { grid-column: 1 / -1; }
    .production-note { grid-column: auto; padding-top: 20px; }
    .software-shot img { max-height: none; }
    .v1-flow { grid-template-columns: 1fr; gap: 14px; }
    .v1-flow i { padding-left: 8px; transform: rotate(90deg); transform-origin: left center; }
    .archive-feature { grid-template-columns: 1fr; gap: 36px; padding-block: 48px; }
    .archive-image { min-height: 340px; }
    .archive-details summary { flex-wrap: wrap; gap: 4px 16px; padding-block: 16px; }
    .archive-details summary small { width: calc(100% - 36px); }
    .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 12px; }
    .site-footer { align-items: flex-start; flex-direction: column; gap: 8px; }
  }

  @media (max-width: 420px) {
    .hero h1 { font-size: 47px; }
    .cad-view { height: 390px; }
    .trial-main { min-height: 460px; }
    .trial-proof .image-button { min-height: 250px; }
    .gallery-grid { grid-template-columns: 1fr; }
  }

  @media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
  }
}
