/* ─────────────────────────────────────────────────────────────
   GAUSSIAN NORTH — shared design tokens & global styles
   Aesthetic: paper datasheet · IBM Plex pair · signal blue accent
   ───────────────────────────────────────────────────────────── */

:root {
  /* PAPER (default — matches the deck) */
  --bg:          oklch(0.965 0.004 85);       /* warm off-white */
  --bg-2:        oklch(0.935 0.005 85);       /* subtle panel */
  --surface:     oklch(0.99 0.002 85);        /* paper white */
  --fg:          oklch(0.18 0.005 250);       /* near-black */
  --fg-2:        oklch(0.34 0.008 250);       /* deep gray */
  --muted:       oklch(0.52 0.010 250);       /* mid gray */
  --dim:         oklch(0.72 0.010 250);       /* light gray */
  --border:      oklch(0.85 0.008 250);       /* hairline */
  --border-2:    oklch(0.78 0.010 250);       /* heavier divider */
  --grid:        oklch(0.90 0.008 250 / 0.5);

  /* ACCENT — IBM signal blue */
  --accent:      oklch(0.52 0.22 250);
  --accent-2:    oklch(0.66 0.18 250);
  --accent-dim:  oklch(0.78 0.10 250);

  /* TYPE */
  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  /* SCALE */
  --t-micro: 10.5px;
  --t-small: 12px;
  --t-body:  15px;
  --t-lead:  18px;
  --t-h3:    clamp(20px, 1.6vw, 24px);
  --t-h2:    clamp(28px, 3.4vw, 48px);
  --t-h1:    clamp(44px, 7.2vw, 112px);

  --tracked: 0.14em;
  --tracked-tight: 0.06em;

  --page-max: 1440px;
  --gutter: clamp(16px, 3vw, 40px);
  --row: 56px;
}

/* DARK variant — terminal/datasheet on black */
:root[data-aesthetic="dark"] {
  --bg:          oklch(0.135 0.006 240);
  --bg-2:        oklch(0.165 0.008 240);
  --surface:     oklch(0.19 0.009 240);
  --fg:          oklch(0.95 0.003 240);
  --fg-2:        oklch(0.78 0.005 240);
  --muted:       oklch(0.58 0.012 240);
  --dim:         oklch(0.38 0.013 240);
  --border:      oklch(0.26 0.012 240);
  --border-2:    oklch(0.32 0.013 240);
  --grid:        oklch(0.22 0.010 240 / 0.55);
  --accent:      oklch(0.80 0.14 215);
  --accent-2:    oklch(0.88 0.10 215);
  --accent-dim:  oklch(0.45 0.10 215);
}

/* BLUEPRINT variant */
:root[data-aesthetic="blueprint"] {
  --bg:       oklch(0.22 0.08 245);
  --bg-2:     oklch(0.27 0.09 245);
  --surface:  oklch(0.31 0.09 245);
  --fg:       oklch(0.97 0.02 220);
  --fg-2:     oklch(0.86 0.03 220);
  --muted:    oklch(0.70 0.05 220);
  --dim:      oklch(0.50 0.07 235);
  --border:   oklch(0.55 0.10 235);
  --border-2: oklch(0.62 0.11 235);
  --grid:     oklch(0.60 0.10 235 / 0.55);
  --accent:   oklch(0.92 0.06 200);
  --accent-2: oklch(0.98 0.02 200);
  --accent-dim: oklch(0.65 0.10 220);
}

/* ACCENT overrides */
:root[data-accent="blue"]   { --accent: oklch(0.52 0.22 250); --accent-2: oklch(0.66 0.18 250); --accent-dim: oklch(0.78 0.10 250); }
:root[data-accent="cyan"]   { --accent: oklch(0.62 0.18 215); --accent-2: oklch(0.74 0.14 215); --accent-dim: oklch(0.82 0.07 215); }
:root[data-accent="amber"]  { --accent: oklch(0.62 0.17 65);  --accent-2: oklch(0.74 0.13 65);  --accent-dim: oklch(0.82 0.07 65); }
:root[data-accent="ink"]    { --accent: oklch(0.20 0.01 250); --accent-2: oklch(0.40 0.01 250); --accent-dim: oklch(0.70 0.005 250); }

/* Dark mode accent overrides — pull them brighter on dark bg */
:root[data-aesthetic="dark"][data-accent="blue"]  { --accent: oklch(0.74 0.18 250); --accent-2: oklch(0.84 0.13 250); --accent-dim: oklch(0.48 0.14 250); }
:root[data-aesthetic="dark"][data-accent="cyan"]  { --accent: oklch(0.80 0.14 215); --accent-2: oklch(0.88 0.10 215); --accent-dim: oklch(0.45 0.10 215); }
:root[data-aesthetic="dark"][data-accent="amber"] { --accent: oklch(0.80 0.14 75);  --accent-2: oklch(0.88 0.10 75);  --accent-dim: oklch(0.50 0.10 75); }
:root[data-aesthetic="dark"][data-accent="ink"]   { --accent: oklch(0.96 0.003 240); --accent-2: oklch(1 0 0); --accent-dim: oklch(0.65 0.005 240); }

/* ─────────────────────────────────────────────────────────────
   Reset + base
   ───────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { background: var(--bg); color: var(--fg); }
body {
  font-family: var(--sans);
  font-size: var(--t-body);
  line-height: 1.55;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background: var(--bg);
  overflow-x: hidden;
}

/* Only show body horizontal grid lines in DARK aesthetic (terminal feel).
   In paper / blueprint they create unnecessary noise. */
:root[data-aesthetic="dark"] body {
  background:
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 100% var(--row),
    var(--bg);
  background-attachment: fixed;
}

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

img, svg, canvas { display: block; max-width: 100%; }

::selection { background: var(--accent); color: var(--surface); }

/* ─────────────────────────────────────────────────────────────
   Layout primitives
   ───────────────────────────────────────────────────────────── */

.page {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--gutter);
  position: relative;
}

/* Side rules — only in dark mode (datasheet frame). Off in paper. */
:root[data-aesthetic="dark"] .page::before,
:root[data-aesthetic="dark"] .page::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  width: 1px;
  background: var(--border);
  pointer-events: none;
}
:root[data-aesthetic="dark"] .page::before { left: var(--gutter); }
:root[data-aesthetic="dark"] .page::after  { right: var(--gutter); }

/* Section */
section.sec { position: relative; padding: clamp(64px, 8vw, 128px) 0; }
section.sec + section.sec { border-top: 1px solid var(--border); }

/* Section header row */
.sec-head {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(0, 3fr);
  gap: clamp(24px, 4vw, 64px);
  align-items: baseline;
  margin-bottom: clamp(40px, 6vw, 80px);
}
.sec-id {
  font-family: var(--mono);
  font-size: var(--t-micro);
  letter-spacing: var(--tracked);
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}
.sec-id .num { color: var(--accent); margin-right: 0.4em; }
.sec-title em { font-style: normal; color: var(--accent); font-weight: 500; }
.sec-title {
  font-family: var(--sans);
  font-size: var(--t-h2);
  font-weight: 300;
  letter-spacing: -0.015em;
  line-height: 1.05;
  margin: 0;
  text-wrap: balance;
}
.sec-lede {
  margin-top: 1em;
  font-size: var(--t-lead);
  color: var(--fg-2);
  font-weight: 300;
  max-width: 56ch;
  text-wrap: pretty;
}

/* Grid 12 */
.g12 {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: clamp(12px, 1.5vw, 24px);
}

/* ─────────────────────────────────────────────────────────────
   Header / nav
   ───────────────────────────────────────────────────────────── */

.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in oklch, var(--bg) 90%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--gutter);
  height: 112px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
}
.brand {
  display: flex; align-items: center; gap: 1px;
  font-family: var(--mono);
  font-weight: 600;
  letter-spacing: var(--tracked-tight);
  text-transform: uppercase;
  font-size: 24px;
  color: var(--fg);
}
.wordmark { display: inline-flex; align-items: baseline; gap: 0; }
.wordmark .wm-light { color: var(--accent); }
.brand-mark {
  width: 84px; height: 84px;
  display: inline-flex; align-items: center; justify-content: center;
  position: relative;
  flex: 0 0 auto;
}
.brand-mark img {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
}
/* In paper mode the logo PNG (black) sits naturally on the off-white bg.
   In dark/blueprint, invert so the dot-matrix shape stays legible. */
:root[data-aesthetic="dark"] .brand-mark img,
:root[data-aesthetic="blueprint"] .brand-mark img {
  filter: invert(1);
}
/* Footer brand uses a larger mark */
footer.foot .brand-mark { width: 108px; height: 108px; }

.nav {
  display: flex; gap: clamp(16px, 2vw, 32px);
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: var(--tracked-tight);
  text-transform: uppercase;
  color: var(--fg-2);
}
.nav a { padding: 4px 0; border-bottom: 1px solid transparent; transition: color .15s, border-color .15s; }
.nav a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.nav a.active { color: var(--accent); }

.meta-right {
  justify-self: end;
  display: flex; gap: 18px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: var(--tracked);
  text-transform: uppercase;
  color: var(--muted);
}
.meta-right .dot {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); margin-right: 6px; vertical-align: middle;
}
:root[data-aesthetic="dark"] .meta-right .dot { box-shadow: 0 0 8px var(--accent); }

@media (max-width: 820px) {
  .nav { display: none; }
  .topbar-inner { grid-template-columns: 1fr auto; }
}

/* ─────────────────────────────────────────────────────────────
   Eyebrows, labels, micro
   ───────────────────────────────────────────────────────────── */

.eyebrow {
  font-family: var(--mono);
  font-size: var(--t-micro);
  letter-spacing: var(--tracked);
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
}
.eyebrow .accent { color: var(--accent); }

.kv {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 0 16px;
  font-size: var(--t-small);
  border-top: 1px solid var(--border);
}
.kv > * {
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.kv dt { color: var(--muted); letter-spacing: var(--tracked-tight); text-transform: uppercase; font-size: 10.5px; font-family: var(--mono); padding-top: 13px; }
.kv dd { margin: 0; color: var(--fg); font-family: var(--sans); font-size: 13.5px; }

/* Bullet list */
.dotlist { list-style: none; padding: 0; margin: 0; }
.dotlist li {
  position: relative;
  padding: 11px 0 11px 22px;
  border-bottom: 1px solid var(--border);
  font-size: var(--t-body);
  color: var(--fg);
}
.dotlist li::before {
  content: ""; position: absolute; left: 0; top: 19px;
  width: 6px; height: 6px;
  background: var(--accent);
}
.dotlist.crosses li::before {
  content: "×"; width: auto; height: auto; background: none; top: 8px;
  color: oklch(0.55 0.18 25); font-size: 16px; font-family: var(--mono);
}

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: clamp(20px, 2vw, 28px);
  position: relative;
}
.card .corner {
  position: absolute; width: 10px; height: 10px;
  border: 1px solid var(--accent);
}
.card .corner.tl { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.card .corner.tr { top: -1px; right: -1px; border-left: 0; border-bottom: 0; }
.card .corner.bl { bottom: -1px; left: -1px; border-right: 0; border-top: 0; }
.card .corner.br { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }

/* Cta link / button */
.cta {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  border: 1px solid var(--fg);
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: var(--tracked);
  text-transform: uppercase;
  color: var(--fg);
  background: transparent;
  transition: background .15s, color .15s, border-color .15s;
}
.cta:hover { color: var(--bg); background: var(--accent); border-color: var(--accent); }
.cta .arrow { width: 12px; height: 8px; }
.cta.ghost { border-color: transparent; padding-left: 0; padding-right: 0; }
.cta.ghost:hover { color: var(--accent); background: transparent; }
.cta.ghost:hover .arrow { transform: translateX(4px); }
.cta .arrow { transition: transform .2s; }

/* Placeholder image (annotated box) */
.ph {
  position: relative;
  border: 1px dashed var(--border-2);
  background:
    repeating-linear-gradient(45deg,
      transparent 0 8px,
      color-mix(in oklch, var(--border) 60%, transparent) 8px 9px);
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  min-height: 240px;
  color: var(--muted);
  overflow: hidden;
}
.ph .ph-label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: var(--tracked);
  text-transform: uppercase;
  padding: 10px 12px;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  border-right: 1px solid var(--border);
  display: flex; gap: 12px; align-items: center;
  color: var(--fg-2);
}
.ph .ph-label .tag {
  color: var(--accent); font-weight: 500;
}
.ph .ph-corner {
  font-family: var(--mono);
  position: absolute; top: 8px; right: 8px;
  font-size: 10px; letter-spacing: var(--tracked);
  color: var(--muted);
}

/* Hr */
hr.rule { border: 0; border-top: 1px solid var(--border); margin: 0; }

/* ─────────────────────────────────────────────────────────────
   Photo figure (real imagery, datasheet-style caption)
   ───────────────────────────────────────────────────────────── */
figure.photo {
  margin: 0;
  position: relative;
  border: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}
figure.photo img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
}
figure.photo figcaption {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: var(--tracked);
  text-transform: uppercase;
  color: var(--fg-2);
  background: var(--bg-2);
}
figure.photo figcaption .ph-corner {
  position: static;
  color: var(--accent);
  font-weight: 500;
}
/* Slight desaturation so real photos integrate with the paper palette */
:root[data-aesthetic="light"] figure.photo img { filter: saturate(0.92) contrast(1.02); }
/* In dark/blueprint, dim images a touch */
:root[data-aesthetic="dark"] figure.photo img,
:root[data-aesthetic="blueprint"] figure.photo img { filter: brightness(0.92) contrast(1.03); }

/* ─────────────────────────────────────────────────────────────
   Footer
   ───────────────────────────────────────────────────────────── */
footer.foot {
  border-top: 1px solid var(--border);
  padding: 64px 0 32px;
  margin-top: 64px;
}
footer.foot .foot-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 32px;
}
@media (max-width: 720px) {
  footer.foot .foot-grid { grid-template-columns: 1fr 1fr; }
}
footer.foot h4 {
  font-family: var(--mono);
  font-size: 10.5px; letter-spacing: var(--tracked); text-transform: uppercase;
  color: var(--muted); font-weight: 500; margin: 0 0 16px;
}
footer.foot ul { list-style: none; padding: 0; margin: 0; }
footer.foot li { padding: 5px 0; font-size: 13px; color: var(--fg-2); }
footer.foot li a:hover { color: var(--accent); }
.foot-meta {
  margin-top: 40px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-between;
  font-family: var(--mono);
  font-size: 10.5px; letter-spacing: var(--tracked); text-transform: uppercase;
  color: var(--muted);
}

/* ─────────────────────────────────────────────────────────────
   Hero
   ───────────────────────────────────────────────────────────── */
.hero {
  position: relative;
  padding: clamp(80px, 14vw, 200px) 0 clamp(64px, 10vw, 140px);
  overflow: hidden;
}
.hero-canvas-wrap {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
.hero-canvas-wrap canvas { width: 100%; height: 100%; display: block; }
.hero-canvas-wrap::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 0%, transparent 50%, var(--bg) 100%);
  pointer-events: none;
}
.hero-inner {
  position: relative; z-index: 1;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--gutter);
}
.hero h1 {
  font-family: var(--sans);
  font-size: var(--t-h1);
  line-height: 0.96;
  letter-spacing: -0.025em;
  font-weight: 300;
  margin: 0;
  text-wrap: balance;
  max-width: 18ch;
}
.hero h1 em {
  font-style: normal; color: var(--accent);
  font-weight: 500;
}
.hero-sub {
  margin-top: 32px;
  font-size: var(--t-lead);
  color: var(--fg-2);
  max-width: 56ch;
  font-weight: 300;
  text-wrap: pretty;
}
.hero-meta {
  display: flex; gap: 24px; flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 10.5px; letter-spacing: var(--tracked); text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 32px;
}
.hero-meta .accent { color: var(--accent); }
.hero-cta {
  display: flex; gap: 12px; flex-wrap: wrap;
  margin-top: 40px;
}

/* ─────────────────────────────────────────────────────────────
   Utility
   ───────────────────────────────────────────────────────────── */
.acc { color: var(--accent); }
.mut { color: var(--muted); }
.dim { color: var(--dim); }
.upper { text-transform: uppercase; letter-spacing: var(--tracked); }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.span-6 { grid-column: span 6; }
.span-4 { grid-column: span 4; }
.span-3 { grid-column: span 3; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }

@media (max-width: 820px) {
  .span-6, .span-4, .span-3, .span-8 { grid-column: span 12; }
  .sec-head { grid-template-columns: 1fr; }
}

/* Reveal-on-scroll */
.reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity .8s ease, transform .8s ease;
}
.reveal.in { opacity: 1; transform: none; }

/* Tweaks panel: keep its built-in font */
#tweaks-root .tw-panel { font-family: var(--sans); }

/* ─────────────────────────────────────────────────────────────
   Glossary tooltips — Explore audience only.
   Spans emitted by src/lib/terms.ts as <span class="gn-term">…</span>.
   Hover, focus, or focus-within reveals the tip (works on touch via
   tabindex — tap to focus, tap elsewhere to dismiss).
   ───────────────────────────────────────────────────────────── */

.gn-term {
  position: relative;
  display: inline;
  cursor: help;
  border-bottom: 1px dashed var(--accent-dim);
  color: inherit;
  transition: border-color .15s, color .15s;
}
.gn-term:hover,
.gn-term:focus,
.gn-term:focus-within {
  outline: none;
  border-bottom-color: var(--accent);
  color: var(--accent);
}
.gn-term .gn-tip {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translate(-50%, 4px);
  width: clamp(220px, 26vw, 320px);
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border-2);
  box-shadow: 0 14px 32px -16px oklch(0 0 0 / 0.28), 0 2px 0 0 var(--border);
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: 0;
  text-transform: none;
  color: var(--fg);
  text-align: left;
  white-space: normal;
  z-index: 80;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .18s ease, transform .22s ease, visibility 0s linear .22s;
}
.gn-term:hover .gn-tip,
.gn-term:focus .gn-tip,
.gn-term:focus-within .gn-tip {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
  transition: opacity .18s ease, transform .22s ease, visibility 0s linear 0s;
}
.gn-term .gn-tip::before,
.gn-term .gn-tip::after {
  content: "";
  position: absolute;
  width: 7px; height: 7px;
  border: 1px solid var(--accent);
  pointer-events: none;
}
.gn-term .gn-tip::before { top: -1px; left: -1px; border-right: 0; border-bottom: 0; }
.gn-term .gn-tip::after  { bottom: -1px; right: -1px; border-left: 0; border-top: 0; }
.gn-term .gn-tip-expand {
  display: block;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: var(--tracked);
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.gn-term .gn-tip-def { color: var(--fg-2); }

/* Product-name mention — inline. Emitted by src/lib/products.ts and by
   renderTerms when [term:<product>] is used. Mono face + accent colour,
   datasheet feel; coexists with .gn-term on Explore (product names that
   also have a tooltip get both classes). */
.gn-prod {
  font-family: var(--mono);
  color: var(--accent);
  font-weight: 500;
  /* Mono glyphs visually appear slightly larger than the surrounding sans —
     a small tracking nudge keeps the rhythm of body copy intact. */
  letter-spacing: 0;
}
/* When a product mention is also a glossary tooltip, the gn-term dashed
   underline already provides the affordance — keep the colour solid accent
   so the underline + colour read as one unit. */
.gn-term.gn-prod { color: var(--accent); }

/* On narrow screens, anchor the tip to the viewport so it doesn't clip. */
@media (max-width: 560px) {
  .gn-term .gn-tip {
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 24px;
    top: auto;
    width: auto;
    max-width: none;
    transform: translateY(8px);
  }
  .gn-term:hover .gn-tip,
  .gn-term:focus .gn-tip,
  .gn-term:focus-within .gn-tip {
    transform: translateY(0);
  }
}
