/* ==========================================================================
   McNeil Labs — design system
   Warm near-black workshop palette, single ember accent.
   Every page composes ONLY these tokens/classes; no page-local colors.
   ========================================================================== */

/* ---- fonts (self-hosted, latin subsets) ---- */
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('/assets/fonts/space-grotesk-var-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Space Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/space-mono-400-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Space Mono';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/assets/fonts/space-mono-700-latin.woff2') format('woff2');
}

/* ---- tokens ---- */
:root {
  /* Warm near-black ground, bone text, one ember accent. No cyan, no purple. */
  --ink-0: oklch(16.5% 0.008 60);        /* page ground — warm near-black   */
  --ink-1: oklch(20% 0.009 60);          /* raised surface                  */
  --ink-2: oklch(24% 0.01 60);           /* higher surface / hover          */
  --line: oklch(32% 0.012 60);           /* hairline borders                */
  --line-soft: oklch(26% 0.01 60);       /* subtler hairlines               */
  --bone: oklch(92% 0.012 75);           /* primary text — warm bone        */
  --bone-dim: oklch(72% 0.014 70);       /* secondary text                  */
  --bone-faint: oklch(54% 0.014 65);     /* tertiary / labels               */
  --ember: oklch(71% 0.16 55);           /* the accent — burnt orange       */
  --ember-bright: oklch(78% 0.16 60);    /* accent hover                    */
  --ember-dim: oklch(45% 0.09 55);       /* accent borders / underlines     */
  --ember-ghost: oklch(30% 0.045 55);    /* accent-tinted surface           */

  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-mono: 'Space Mono', ui-monospace, monospace;

  /* modular scale, fluid */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: clamp(1rem, 0.95rem + 0.2vw, 1.0625rem);
  --text-lg: clamp(1.125rem, 1.05rem + 0.4vw, 1.3125rem);
  --text-xl: clamp(1.4rem, 1.2rem + 0.9vw, 1.85rem);
  --text-2xl: clamp(1.9rem, 1.5rem + 1.8vw, 2.8rem);
  --text-hero: clamp(2.9rem, 1.9rem + 5.2vw, 6rem);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 1rem;
  --space-4: 1.75rem;
  --space-5: 3rem;
  --space-6: clamp(4rem, 3rem + 4vw, 7rem);

  --measure: 62ch;
  --site-max: 72rem;
}

/* ---- reset-ish ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
body {
  background: var(--ink-0);
  color: var(--bone);
  font-family: var(--font-display);
  font-size: var(--text-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
img, svg { display: block; max-width: 100%; }
a { color: inherit; }
::selection { background: var(--ember-dim); color: var(--bone); }

/* faint blueprint grid on the page ground */
.ground {
  background-image:
    linear-gradient(var(--line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--line-soft) 1px, transparent 1px);
  background-size: 72px 72px;
  background-position: center top;
  position: relative;
}
.ground::after {
  /* fade the grid out toward the bottom so it doesn't fight the content */
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 0%, var(--ink-0) 85%);
  pointer-events: none;
}
.ground > * { position: relative; z-index: 1; }

/* ---- layout ---- */
.shell { max-width: var(--site-max); margin-inline: auto; padding-inline: clamp(1.25rem, 4vw, 2.5rem); }
.section { padding-block: var(--space-6); }
.section-tight { padding-block: var(--space-5); }
.measure { max-width: var(--measure); }

/* ---- type ---- */
.h-hero {
  font-size: var(--text-hero);
  font-weight: 640;
  line-height: 0.99;
  letter-spacing: -0.03em;
  text-wrap: balance;
}
.h-xl { font-size: var(--text-2xl); font-weight: 600; line-height: 1.12; letter-spacing: -0.02em; text-wrap: balance; }
.h-lg { font-size: var(--text-xl); font-weight: 600; line-height: 1.2; letter-spacing: -0.015em; }
.h-md { font-size: var(--text-lg); font-weight: 600; line-height: 1.3; }
.lede { font-size: var(--text-lg); font-weight: 330; color: var(--bone-dim); line-height: 1.55; }
.body-dim { color: var(--bone-dim); }
.body-faint { color: var(--bone-faint); }
.small { font-size: var(--text-sm); }

/* mono label — section markers, indices, metadata */
.tag {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ember);
}
.tag-dim { color: var(--bone-faint); }

/* accent word inside a heading */
.ember { color: var(--ember); }

/* ---- links & buttons ---- */
.link {
  color: var(--bone);
  text-decoration: underline;
  text-decoration-color: var(--ember-dim);
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
  transition: text-decoration-color 160ms ease-out, color 160ms ease-out;
}
.link:hover { color: var(--ember-bright); text-decoration-color: var(--ember-bright); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  letter-spacing: 0.04em;
  padding: 0.7em 1.4em;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--bone);
  text-decoration: none;
  cursor: pointer;
  transition: border-color 160ms ease-out, background 160ms ease-out, color 160ms ease-out;
}
.btn:hover { border-color: var(--ember); color: var(--ember-bright); }
.btn:active { transform: translateY(1px); }
.btn-solid { background: var(--ember); border-color: var(--ember); color: var(--ink-0); font-weight: 700; }
.btn-solid:hover { background: var(--ember-bright); border-color: var(--ember-bright); color: var(--ink-0); }

:where(a, button):focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: 3px;
}

/* ---- surfaces ---- */
.panel {
  background: var(--ink-1);
  border: 1px solid var(--line-soft);
}
.panel-pad { padding: var(--space-4); }
.hairline-top { border-top: 1px solid var(--line-soft); }
.hairline-bottom { border-bottom: 1px solid var(--line-soft); }

/* section header row: mono index + rule */
.rule-head {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  margin-bottom: var(--space-5);
}
.rule-head::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line-soft);
  align-self: center;
}

/* ---- header / footer ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in oklab, var(--ink-0) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line-soft);
}
.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding-block: 0.9rem;
}
.brand {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: var(--text-sm);
  letter-spacing: 0.06em;
  text-decoration: none;
  color: var(--bone);
}
.brand .ember { color: var(--ember); }
.site-nav { display: flex; gap: clamp(1rem, 3vw, 2.25rem); }
.site-nav a {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--bone-dim);
  transition: color 160ms ease-out;
}
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--ember-bright); }

.site-footer { border-top: 1px solid var(--line-soft); padding-block: var(--space-5); }
.footer-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-4);
  align-items: flex-start;
}
.footer-links { display: flex; flex-wrap: wrap; gap: var(--space-3) var(--space-4); }
.footer-links a {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  color: var(--bone-faint);
  text-decoration: none;
  transition: color 160ms ease-out;
}
.footer-links a:hover { color: var(--ember-bright); }

/* ---- entrance animation (staggered, opt-in via .rise) ---- */
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}
.rise { animation: rise 640ms cubic-bezier(0.22, 1, 0.36, 1) both; }
.rise-2 { animation-delay: 90ms; }
.rise-3 { animation-delay: 180ms; }
.rise-4 { animation-delay: 270ms; }

/* ==========================================================================
   Bolder layer — technical-drawing craft details & choreographed motion.
   Everything here stays inside the blueprint/ember language.
   ========================================================================== */

/* film grain over the whole page — kills the flat-black deadness */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* blinking caret on the header brand underscore */
@keyframes caret-blink { 0%, 55% { opacity: 1; } 56%, 100% { opacity: 0; } }
.site-header .brand .ember { animation: caret-blink 1.2s steps(1) infinite; }

/* registration marks — technical-drawing corner ticks on a surface */
.marks { position: relative; }
.marks::before {
  content: '';
  position: absolute;
  inset: -1px;
  pointer-events: none;
  background:
    linear-gradient(var(--ember) 0 0) left  0    top    0    / 14px 1px,
    linear-gradient(var(--ember) 0 0) left  0    top    0    / 1px 14px,
    linear-gradient(var(--ember) 0 0) right 0    top    0    / 14px 1px,
    linear-gradient(var(--ember) 0 0) right 0    top    0    / 1px 14px,
    linear-gradient(var(--ember) 0 0) left  0    bottom 0    / 14px 1px,
    linear-gradient(var(--ember) 0 0) left  0    bottom 0    / 1px 14px,
    linear-gradient(var(--ember) 0 0) right 0    bottom 0    / 14px 1px,
    linear-gradient(var(--ember) 0 0) right 0    bottom 0    / 1px 14px;
  background-repeat: no-repeat;
}

/* spec-sheet row hover — ember tick slides in, row lifts a shade */
.tick-row {
  position: relative;
  transition: background 200ms cubic-bezier(0.22, 1, 0.36, 1);
}
.tick-row::before {
  content: '';
  position: absolute;
  left: calc(-1 * var(--space-3));
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--ember);
  transform: scaleY(0);
  transform-origin: top;
  transition: transform 240ms cubic-bezier(0.22, 1, 0.36, 1);
}
.tick-row:hover { background: color-mix(in oklab, var(--ink-1) 55%, transparent); }
.tick-row:hover::before { transform: scaleY(1); }

/* scroll-reveal — inert without JS; html.js gates the hidden state */
html.js .reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 700ms cubic-bezier(0.22, 1, 0.36, 1), transform 700ms cubic-bezier(0.22, 1, 0.36, 1);
}
html.js .reveal.in { opacity: 1; transform: none; }

/* hero schematic — blueprint line work that draws itself in.
   Stroke offsets live only inside the keyframes, so with animations
   disabled (reduced motion / no support) the drawing renders complete. */
.schematic { color: oklch(46% 0.016 60); }
.schematic .node { stroke: currentColor; stroke-width: 1.5; fill: var(--ink-1); }
.schematic .node-hot { stroke: var(--ember-dim); }
.schematic .wire { stroke: currentColor; stroke-width: 1.25; fill: none; }
.schematic .pip { fill: var(--ember); stroke: none; }
.schematic .anno { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.12em; fill: var(--bone-faint); }
@keyframes draw-wire {
  from { stroke-dasharray: 400; stroke-dashoffset: 400; }
  to { stroke-dasharray: 400; stroke-dashoffset: 0; }
}
@keyframes fade-node { from { opacity: 0; } to { opacity: 1; } }
@keyframes pip-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
.schematic .wire { animation: draw-wire 1400ms cubic-bezier(0.65, 0, 0.35, 1) both; animation-delay: 500ms; }
.schematic .node, .schematic .anno { animation: fade-node 600ms ease-out both; }
.schematic .n2 { animation-delay: 350ms; }
.schematic .n3 { animation-delay: 550ms; }
.schematic .n4 { animation-delay: 750ms; }
.schematic .w2 { animation-delay: 800ms; }
.schematic .w3 { animation-delay: 1100ms; }
.schematic .anno { animation-delay: 1300ms; }
.schematic .pip { animation: pip-pulse 2.6s ease-in-out 1.8s infinite; }

/* ---- prose (legal pages) ---- */
.prose { max-width: var(--measure); }
.prose h2 { font-size: var(--text-xl); font-weight: 600; letter-spacing: -0.015em; margin-top: var(--space-5); margin-bottom: var(--space-3); }
.prose h3 { font-size: var(--text-lg); font-weight: 600; margin-top: var(--space-4); margin-bottom: var(--space-2); }
.prose p, .prose ul, .prose ol { margin-bottom: var(--space-3); color: var(--bone-dim); }
.prose li { margin-bottom: var(--space-2); margin-left: 1.2em; }
.prose strong { color: var(--bone); font-weight: 600; }
.prose a { color: var(--bone); text-decoration: underline; text-decoration-color: var(--ember-dim); text-underline-offset: 0.2em; }
.prose a:hover { color: var(--ember-bright); text-decoration-color: var(--ember-bright); }
