/* ───────────────────────────────────────────────
   brainvi.ai — alt site / design system
   monochrome · ethereal · research-lab minimal
   ─────────────────────────────────────────────── */

:root {
  --bg:        #efece4;
  --bg-2:      #e8e4d9;
  --paper:     #f4f1ea;
  --ink:       #0a0a0a;
  --ink-2:     #2a2a28;
  --mid:       #7a7975;
  --mid-2:     #a8a59d;
  --veil:      #c8c5bd;
  --hair:      #d6d2c7;
  --hair-2:    #cbc7bb;
  --inverse:   #070707;
  --inverse-2: #131311;
  --inverse-ink: #efece4;

  --serif: "Instrument Serif", "Cormorant Garamond", "Times New Roman", serif;
  --sans:  "Geist", -apple-system, BlinkMacSystemFont, "Helvetica Neue", system-ui, sans-serif;
  --mono:  "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --maxw: 1440px;
  --pad: clamp(24px, 4vw, 56px);
  --hair-w: 0.5px;

  --t-fast: 180ms cubic-bezier(.2,.7,.2,1);
  --t-med:  360ms cubic-bezier(.2,.7,.2,1);
  --t-slow: 900ms cubic-bezier(.2,.7,.2,1);
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-feature-settings: "ss01", "ss02", "cv02", "cv11";
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body::before {
  /* global page grain — very subtle */
  content: "";
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.06 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: 200px 200px;
  mix-blend-mode: multiply;
  opacity: .55;
  pointer-events: none;
  z-index: 100;
}

::selection { background: var(--ink); color: var(--bg); }

a { color: inherit; text-decoration: none; }

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

/* ── Typography primitives ────────────────────── */

.serif      { font-family: var(--serif); font-weight: 400; letter-spacing: -0.01em; }
.serif-i    { font-family: var(--serif); font-style: italic; font-weight: 400; letter-spacing: -0.005em; }
.mono       { font-family: var(--mono); font-feature-settings: "ss01"; }
.upper      { text-transform: uppercase; letter-spacing: 0.14em; }
.tight-up   { text-transform: uppercase; letter-spacing: 0.08em; }
.tabular    { font-variant-numeric: tabular-nums; }

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--mid);
}

.eyebrow .dot {
  display: inline-block; width: 5px; height: 5px;
  background: var(--ink); border-radius: 50%;
  vertical-align: 2px; margin-right: 8px;
}

.h-display {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(56px, 9vw, 148px);
  line-height: 0.92;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.h-1 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(40px, 5.5vw, 84px);
  line-height: 0.96;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.h-2 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(28px, 3.4vw, 48px);
  line-height: 1.02;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

.h-3 {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(20px, 2vw, 26px);
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--mid);
}

.lede {
  font-family: var(--serif);
  font-size: clamp(22px, 2.3vw, 30px);
  line-height: 1.28;
  letter-spacing: -0.012em;
  text-wrap: pretty;
  color: var(--ink-2);
}

p { text-wrap: pretty; }

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

.page { padding: 0; }

.bar {
  height: var(--hair-w);
  background: var(--ink);
  opacity: .85;
  width: 100%;
}
.bar.faint { opacity: .25; }

.grid-12 {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 0 24px;
}

.section {
  padding: clamp(72px, 9vw, 140px) var(--pad);
  position: relative;
}

.section .section-head {
  display: grid;
  grid-template-columns: 1fr;            /* stack: small label on top, big title below */
  gap: clamp(14px, 1.6vw, 22px);
  align-items: start;
  padding-bottom: clamp(24px, 3vw, 38px);
  border-bottom: var(--hair-w) solid var(--ink);
  margin-bottom: clamp(40px, 6vw, 80px);
}

.section-head .section-no {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--mid);
  display: flex; justify-content: flex-start; gap: 16px;
}

.section-head .section-title {
  font-family: var(--serif);
  font-size: clamp(40px, 4.8vw, 72px);
  line-height: 1.04;
  letter-spacing: -0.022em;
  max-width: none;          /* use the full header width so the <br> lines never wrap */
  text-wrap: balance;
}

/* ── Top nav ──────────────────────────────────── */

.topbar {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: saturate(120%) blur(8px);
  -webkit-backdrop-filter: saturate(120%) blur(8px);
  border-bottom: var(--hair-w) solid var(--hair);
}
.topbar .row {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 14px var(--pad);
  gap: 24px;
}
.topbar .brand {
  display: flex; align-items: center; gap: 12px;
  font-family: var(--serif);
  font-size: 22px;
  letter-spacing: -0.01em;
}
.topbar .brand .gl {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #000 0%, #000 30%, transparent 75%);
  filter: blur(1.2px) contrast(1.1);
  position: relative;
}
.topbar .brand .gl::after {
  content: ""; position: absolute; inset: -3px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='40' height='40'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='1.4' numOctaves='2'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.4 0'/></filter><circle cx='20' cy='20' r='14' fill='black' filter='url(%23n)' opacity='0.7'/></svg>");
  background-size: contain; opacity: 0.7;
}
.topbar nav {
  display: flex; gap: 28px; justify-self: center;
  font-family: var(--mono); font-size: 11.5px;
  letter-spacing: 0.14em; text-transform: uppercase;
}
.topbar nav a { color: var(--ink-2); position: relative; }
.topbar nav a:hover { color: var(--ink); }
.topbar nav a[aria-current="page"]::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -18px;
  height: 2px; background: var(--ink);
}
/* ── Interests dropdown — disclosure pattern (hover · click · keyboard) ── */
.nav-dropdown { position: relative; display: inline-flex; align-items: center; }
.nav-trigger {
  font: inherit; letter-spacing: inherit; text-transform: inherit;
  color: var(--ink-2); background: none; border: 0; padding: 0; margin: 0;
  cursor: pointer; position: relative; line-height: 1;
}
.nav-trigger::after {
  content: "↓"; font-size: 9px; margin-left: 5px;
  display: inline-block; transition: transform var(--t-fast);
}
.nav-trigger:hover { color: var(--ink); }
.nav-trigger[aria-expanded="true"] { color: var(--ink); }
.nav-trigger[aria-expanded="true"]::after { transform: rotate(180deg); }

.dropdown-menu {
  position: absolute; top: 100%; left: 50%;
  margin-top: 16px; min-width: 190px;
  background: var(--bg);
  border: var(--hair-w) solid var(--hair);
  padding: 10px 0; z-index: 60;
  box-shadow: 0 12px 36px rgba(10, 10, 10, 0.10);
  /* movement-friendly: animate opacity/transform, never display:none */
  opacity: 0; visibility: hidden; pointer-events: none;
  transform: translateX(-50%) translateY(-6px);
  transition: opacity var(--t-fast), transform var(--t-fast), visibility var(--t-fast);
}
/* invisible hover-bridge so the cursor can cross the gap without the menu closing */
.dropdown-menu::before {
  content: ""; position: absolute; top: -16px; left: 0; right: 0; height: 16px;
}
.nav-dropdown:hover .dropdown-menu,
.nav-dropdown.open .dropdown-menu {
  opacity: 1; visibility: visible; pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}
.dropdown-menu a {
  display: block; padding: 9px 22px;
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-2); text-decoration: none;
  transition: background var(--t-fast), color var(--t-fast);
}
.dropdown-menu a:hover,
.dropdown-menu a:focus-visible { color: var(--ink); background: var(--hair); }
.dropdown-menu a .dropdown-desc {
  display: block; font-size: 9.5px; letter-spacing: 0.06em;
  color: var(--mid); margin-top: 2px; text-transform: none;
}
.topbar .right {
  justify-self: end;
  display: flex; gap: 16px; align-items: center;
  font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--mid);
}
.topbar .right .pill {
  border: var(--hair-w) solid var(--ink);
  padding: 8px 14px;
  color: var(--ink);
  border-radius: 999px;
  transition: background var(--t-fast), color var(--t-fast);
}
.topbar .right .pill:hover { background: var(--ink); color: var(--bg); }

.topbar .right .liveDot {
  display: inline-block; width: 6px; height: 6px;
  background: var(--ink);
  border-radius: 50%;
  margin-right: 6px;
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.35; transform: scale(1); }
  50%      { opacity: 1; transform: scale(1.3); }
}

/* ── Buttons ──────────────────────────────────── */

.btn {
  display: inline-flex; align-items: center; gap: 12px;
  padding: 14px 22px;
  font-family: var(--mono);
  font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase;
  border: var(--hair-w) solid var(--ink);
  background: var(--ink); color: var(--bg);
  border-radius: 999px;
  transition: background var(--t-fast), color var(--t-fast);
}
.btn:hover { background: transparent; color: var(--ink); }
.btn .arrow { width: 14px; transition: transform var(--t-fast); }
.btn:hover .arrow { transform: translateX(4px); }

.btn-ghost {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 14px 22px;
  font-family: var(--mono);
  font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase;
  border: var(--hair-w) solid var(--ink);
  color: var(--ink);
  border-radius: 999px;
  transition: background var(--t-fast), color var(--t-fast);
}
.btn-ghost:hover { background: var(--ink); color: var(--bg); }

.btn-inline {
  font-family: var(--mono);
  font-size: 11.5px; letter-spacing: 0.16em; text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 8px;
  border-bottom: var(--hair-w) solid var(--ink);
  padding-bottom: 4px;
  transition: gap var(--t-fast);
}
.btn-inline:hover { gap: 14px; }

/* ── The Orb — grain mind ─────────────────────── */

.orb {
  position: relative;
  display: inline-block;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 48%,
      rgba(8,8,8,0.98) 0%,
      rgba(8,8,8,0.92) 18%,
      rgba(8,8,8,0.74) 32%,
      rgba(8,8,8,0.42) 48%,
      rgba(8,8,8,0.18) 62%,
      rgba(8,8,8,0.06) 75%,
      transparent 88%);
  filter: blur(0.3px);
}
.orb::after {
  content: ""; position: absolute; inset: -8%;
  border-radius: 50%;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='600' height='600'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='1.2' numOctaves='2' seed='3'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.7 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  background-size: cover;
  mix-blend-mode: multiply;
  opacity: 0.6;
  -webkit-mask: radial-gradient(circle at 50% 50%, black 0%, black 38%, transparent 75%);
          mask: radial-gradient(circle at 50% 50%, black 0%, black 38%, transparent 75%);
  pointer-events: none;
}

/* drift animation */
@keyframes drift {
  0%, 100% { transform: translate(0,0) scale(1); }
  33%      { transform: translate(-1.5%, 1%) scale(1.012); }
  66%      { transform: translate(1.2%, -0.8%) scale(0.992); }
}
.orb.drift { animation: drift 14s ease-in-out infinite; }

/* ── Footer ───────────────────────────────────── */

footer.foot {
  background: var(--inverse);
  color: var(--inverse-ink);
  padding: clamp(72px, 9vw, 120px) var(--pad) 32px;
  position: relative;
  overflow: hidden;
}
footer.foot .row1 {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1fr;
  gap: 32px;
  padding-bottom: 60px;
  border-bottom: var(--hair-w) solid #2a2a26;
}
footer.foot h5 {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #8a8780;
  margin: 0 0 18px;
  font-weight: 400;
}
footer.foot ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
footer.foot a { color: #c7c4ba; transition: color var(--t-fast); font-size: 14px; }
footer.foot a:hover { color: #fff; }

footer.foot .row2 {
  display: flex; justify-content: space-between;
  padding-top: 24px;
  font-family: var(--mono);
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
  color: #6a6760;
}
footer.foot .colophon {
  font-family: var(--serif);
  font-style: italic;
  font-size: 22px;
  letter-spacing: -0.01em;
  color: #d9d6cd;
  margin-bottom: 24px;
  max-width: 30ch;
}

footer.foot .footOrb {
  position: absolute;
  width: 700px; height: 700px;
  right: -200px; bottom: -300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(239,236,228,0.10), rgba(239,236,228,0.03) 40%, transparent 70%);
  filter: blur(20px);
  pointer-events: none;
}

/* ── Utility ──────────────────────────────────── */

.hair-x { border-top: var(--hair-w) solid var(--hair); }
.hair-x-d { border-top: var(--hair-w) solid var(--ink); }
.hair-y { border-left: var(--hair-w) solid var(--hair); }

.crosshair::before, .crosshair::after,
.crosshair > .x1::before, .crosshair > .x1::after {
  content: ""; position: absolute; background: var(--ink); opacity: .85;
}
.crosshair { position: relative; }
.crosshair::before { top: 0; left: 0; width: 14px; height: 1px; }
.crosshair::after  { top: 0; left: 0; width: 1px; height: 14px; }

/* corner ticks for boxed sections */
.corner-ticks { position: relative; }
.corner-ticks > .ct {
  position: absolute; width: 10px; height: 10px;
  border: 1px solid var(--ink);
}
.corner-ticks > .ct.tl { top: -5px; left: -5px; border-right: none; border-bottom: none; }
.corner-ticks > .ct.tr { top: -5px; right: -5px; border-left: none; border-bottom: none; }
.corner-ticks > .ct.bl { bottom: -5px; left: -5px; border-right: none; border-top: none; }
.corner-ticks > .ct.br { bottom: -5px; right: -5px; border-left: none; border-top: none; }

.kbd {
  font-family: var(--mono);
  font-size: 10.5px;
  padding: 2px 6px;
  border: var(--hair-w) solid var(--ink);
  border-radius: 4px;
}

.divider-num {
  display: grid;
  grid-template-columns: 80px 1fr 80px;
  gap: 16px;
  align-items: center;
  padding: 18px 0;
  font-family: var(--mono);
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--mid);
  border-top: var(--hair-w) solid var(--ink);
  border-bottom: var(--hair-w) solid var(--ink);
}

.scroll-tape {
  overflow: hidden;
  border-top: var(--hair-w) solid var(--ink);
  border-bottom: var(--hair-w) solid var(--ink);
  padding: 18px 0;
  display: flex;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.scroll-tape .track {
  display: inline-flex; gap: 48px; padding-right: 48px;
  animation: marquee 75s linear infinite;   /* calm, readable pace (was 32s — too fast) */
  will-change: transform;
}
.scroll-tape:hover .track { animation-play-state: paused; }
.scroll-tape .track .sep {
  color: var(--mid);
}
@keyframes marquee {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

/* ── Specific colors for inverse sections ─────── */
.invert {
  background: var(--inverse);
  color: var(--inverse-ink);
}
.invert .label, .invert .eyebrow, .invert .section-head .section-no { color: #888579; }
.invert .bar { background: #efece4; }
.invert .section-head { border-bottom-color: #2a2a26; }
.invert .divider-num { border-color: #2a2a26; color: #888579; }
.invert .hair-x { border-top-color: #2a2a26; }
.invert .btn { background: var(--bg); color: var(--ink); border-color: var(--bg); }
.invert .btn:hover { background: transparent; color: var(--bg); }
.invert .btn-ghost { color: var(--bg); border-color: var(--bg); }
.invert .btn-ghost:hover { background: var(--bg); color: var(--ink); }
.invert .eyebrow .dot { background: var(--bg); }

/* ── Reduced motion ───────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
  /* …but keep the signature stats-tape marquee drifting even with reduce-motion on */
  .scroll-tape .track { animation-duration: 75s !important; }
  /* …and keep the hero intro's fades alive (the typing is JS; these ease the rest in) */
  html.js .hero-orb > #brain-stage { transition-duration: 1.4s !important; }
  html.js body.hero-anim .topbar { transition-duration: 0.6s !important; }
  html.js .hero-orb .brain-hint { transition-duration: 0.5s !important; }
}

/* ── Reveal on scroll ─────────────────────────── */
/* Hidden state only applies when JS is active (html.js); without JS,
   or if app.js fails to load, all content remains fully visible. */
html.js [data-reveal] {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity var(--t-slow), transform var(--t-slow);
}
html.js [data-reveal].in { opacity: 1; transform: none; }

/* ── Code block (terminal) ────────────────────── */
.code {
  background: var(--inverse);
  color: #d9d6cd;
  border-radius: 10px;
  padding: 22px 24px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  overflow-x: auto;
  border: var(--hair-w) solid #2a2a26;
}
.code .c { color: #6a6760; }
.code .k { color: #efece4; }
.code .s { color: #b9b6ac; }
.code-head {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--mid); margin-bottom: 10px;
}

/* ── Capability cards ─────────────────────────── */
.cap-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 0; }
.cap {
  display: block;
  border-top: var(--hair-w) solid var(--ink);
  padding: 34px 28px 38px;
  transition: background var(--t-fast);
}
.cap:hover { background: var(--bg-2); }
.cap .cap-no { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.18em; text-transform: uppercase; color: var(--mid); }
.cap .cap-name { font-family: var(--serif); font-size: 26px; line-height: 1.1; margin: 10px 0 12px; }
.cap .cap-blurb { font-size: 15px; line-height: 1.5; color: var(--ink-2); margin: 0; max-width: 40ch; }
.cap .cap-tag { font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--mid); margin-top: 18px; display: block; }

/* ── Form fields ──────────────────────────────── */
.field { display: grid; gap: 6px; }
.field > span {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.16em;
  text-transform: uppercase; color: #888579;
}
.field input, .field textarea, .field select {
  background: transparent; border: none; border-bottom: 1px solid #888579;
  color: #efece4; font-family: var(--serif); font-size: 22px; padding: 8px 0;
  outline: none; resize: vertical; width: 100%;
}
.field select option { background: #131311; }
.field.light > span { color: var(--mid); }
.field.light input, .field.light textarea, .field.light select {
  border-bottom-color: var(--mid); color: var(--ink);
}

/* ── CTA stack rows ───────────────────────────── */
.cta-row {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 28px; align-items: center;
  padding: 36px 0; border-top: var(--hair-w) solid var(--ink);
}
.cta-row:last-child { border-bottom: var(--hair-w) solid var(--ink); }
.cta-row .cta-k { font-family: var(--mono); font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--mid); }
.cta-row .cta-title { font-family: var(--serif); font-size: clamp(24px, 3vw, 36px); line-height: 1.05; }
.cta-row .cta-sub { font-size: 14px; color: var(--ink-2); margin-top: 6px; max-width: 52ch; }
.invert .cta-row { border-top-color: #2a2a26; }
.invert .cta-row:last-child { border-bottom-color: #2a2a26; }
.invert .cta-row .cta-k, .invert .cta-row .cta-sub { color: #888579; }
.invert .cta-row .cta-title { color: #efece4; }

@media (max-width: 880px) {
  .cta-row { grid-template-columns: 1fr; gap: 14px; }
  .cap { grid-column: 1 / -1 !important; }
}

/* ═══════════════════════════════════════════════
   MOBILE — extraordinarily touch-friendly
   Grounded in Apple HIG (44pt targets), iOS Safari
   (16px inputs, safe-area insets), responsive reflow.
   ═══════════════════════════════════════════════ */

/* Global mobile hardening (all viewports) */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; overflow-x: clip; }
body {
  -webkit-tap-highlight-color: rgba(10,10,10,0.10);
  overflow-x: clip;              /* guard against stray wide elements WITHOUT becoming a
                                    scroll container (overflow:hidden would break the
                                    sticky brain panel; clip doesn't) */
}
img, canvas, pre, svg, table { max-width: 100%; }
pre, .code { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* Safe-area insets (notch / home indicator), no effect off-device */
.topbar .row {
  padding-left: max(var(--pad), env(safe-area-inset-left));
  padding-right: max(var(--pad), env(safe-area-inset-right));
}

/* ── Mobile nav toggle + overlay (injected by app.js) ── */
.nav-toggle { display: none; }
.mobile-menu { display: none; }

@media (max-width: 880px) {
  /* The in-bar link list is replaced by the overlay menu */
  .topbar nav { display: none; }

  /* keep the bar compact: hide the live clock, keep the CTA pill visible */
  .topbar .right > span:first-child { display: none; }
  .topbar .row { grid-template-columns: 1fr auto; gap: 12px; }
  .topbar .right { gap: 10px; }

  .nav-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; min-width: 44px; flex: 0 0 44px;  /* Apple HIG min target */
    position: relative;
  }
  .nav-toggle span {
    position: absolute; left: 10px; right: 10px; height: 1.5px;
    background: var(--ink); transition: transform var(--t-fast), opacity var(--t-fast);
  }
  .nav-toggle span:nth-child(1) { top: 17px; }
  .nav-toggle span:nth-child(2) { bottom: 17px; }
  .nav-toggle.open span:nth-child(1) { transform: translateY(5px) rotate(45deg); }
  .nav-toggle.open span:nth-child(2) { transform: translateY(-5px) rotate(-45deg); }

  .mobile-menu {
    display: block;
    position: fixed; left: 0; right: 0; top: 0; bottom: 0;
    z-index: 90;
    background: color-mix(in oklab, var(--bg) 97%, transparent);
    backdrop-filter: saturate(140%) blur(14px);
    -webkit-backdrop-filter: saturate(140%) blur(14px);
    opacity: 0; pointer-events: none;
    transition: opacity var(--t-med);
    padding: calc(env(safe-area-inset-top) + 84px) var(--pad)
             calc(env(safe-area-inset-bottom) + 40px);
    overflow-y: auto; -webkit-overflow-scrolling: touch;
  }
  .mobile-menu.open { opacity: 1; pointer-events: auto; }
  .mobile-menu-inner { display: flex; flex-direction: column; gap: 4px; }
  .mobile-menu a {
    font-family: var(--serif); font-size: 32px; line-height: 1;
    letter-spacing: -0.015em; color: var(--ink);
    display: flex; align-items: center; min-height: 56px;
    border-bottom: var(--hair-w) solid var(--hair);
  }
  .mobile-menu a[aria-current="page"] { color: var(--mid); }
  .mobile-menu a.mm-pill {
    margin-top: 24px; border: none; justify-content: center;
    font-family: var(--mono); font-size: 13px; letter-spacing: 0.12em;
    text-transform: uppercase; color: var(--bg); background: var(--ink);
    border-radius: 999px; min-height: 56px;
  }
}

/* ── Reflow: collapse all multi-column layouts ── */
@media (max-width: 880px) {
  .section .section-head { grid-template-columns: 1fr; align-items: start; gap: 12px; }
  .section-head .section-no { font-size: 10px; }

  /* Any 12-col grid child spans full width and stacks */
  .grid-12 > * { grid-column: 1 / -1 !important; }
  .grid-12 { gap: 0 !important; row-gap: 28px !important; }

  /* Inline multi-column grids (MARY streams, corpus stats, etc.) */
  [style*="grid-template-columns: repeat(3"],
  [style*="grid-template-columns: repeat(4"],
  [style*="grid-template-columns: repeat(6"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* borders that assumed columns: drop awkward left borders */
  .grid-12 > [style*="border-left"] { border-left: none !important; padding-left: 0 !important; }

  footer.foot .row1 { grid-template-columns: 1fr 1fr; gap: 28px; }
  footer.foot .row2 {
    flex-direction: column; gap: 8px; text-align: left;
    padding-bottom: calc(env(safe-area-inset-bottom) + 8px);
  }
}

@media (max-width: 620px) {
  /* tighten section padding on phones */
  .section { padding: clamp(48px, 12vw, 72px) var(--pad); }

  /* single column everywhere that still had two */
  [style*="grid-template-columns: repeat(3"],
  [style*="grid-template-columns: repeat(4"],
  [style*="grid-template-columns: repeat(6"] {
    grid-template-columns: 1fr !important;
  }
  .cap-grid { grid-template-columns: 1fr; }
  footer.foot .row1 { grid-template-columns: 1fr; gap: 32px; }

  /* type scale down so big display heads don't overflow */
  .h-display { font-size: clamp(38px, 12vw, 60px); line-height: 0.96; }
  .section-head .section-title { font-size: clamp(34px, 9.5vw, 56px); }
  .h-1 { font-size: clamp(34px, 11vw, 56px); }
  .lede { font-size: clamp(19px, 5.4vw, 24px); }

  /* giant inline stat numbers (corpus, etc.) */
  [style*="font-size: 96px"], [style*="font-size: 86px"] { font-size: 64px !important; }

  /* dividers/cells that used heavy horizontal borders inside inline grids */
  [style*="border-right: 1px solid #2a2a26"] { border-right: none !important; }
  [style*="border-left: 1px solid"] { border-left: none !important; }

  /* hero CTA buttons full width, comfortable */
  .section .btn, .section .btn-ghost { width: 100%; justify-content: center; }
}

/* ── Orb caption labels: never overflow the viewport ── */
.orb-cap { white-space: nowrap; }
@media (max-width: 620px) {
  .orb-cap { font-size: 9px !important; letter-spacing: 0.12em !important; }
}

/* ── Touch-target floor on touch devices (Apple HIG 44pt) ── */
@media (pointer: coarse) {
  .topbar .right .pill { padding: 13px 18px; }            /* ~44px tall */
  .btn, .btn-ghost { padding: 16px 24px; }                /* ~52px tall */
  .btn-inline { min-height: 44px; }
  footer.foot a, .paper-title, .pub-title { min-height: 36px; display: inline-flex; align-items: center; }
  footer.foot ul { gap: 4px; }
  /* prevent iOS auto-zoom: inputs must render ≥16px (ours are larger, floor anyway) */
  .field input, .field textarea, .field select { font-size: max(16px, 22px); }
  .cta-row { min-height: 64px; }
}

/* ── Accessibility / ADA · WCAG 2.1 AA ─────────────────────────────────
   Skip link, visible keyboard focus, reduced-motion honoring, and the
   trademark notice. These apply site-wide (every page links styles.css). */

/* 2.4.1 Bypass Blocks — keyboard users jump past the nav straight to content */
.skip-link {
  position: fixed; top: 10px; left: 10px; z-index: 200;
  transform: translateY(-150%);
  background: var(--ink); color: var(--bg);
  font-family: var(--mono); font-size: 12px;
  letter-spacing: 0.08em; text-transform: uppercase;
  padding: 10px 16px; border-radius: 4px; text-decoration: none;
  transition: transform var(--t-fast);
}
.skip-link:focus { transform: translateY(0); outline: none; }

/* 2.4.7 Focus Visible — keyboard focus was previously invisible site-wide */
:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
  border-radius: 2px;
}
/* mouse/touch clicks shouldn't paint the ring; keyboard focus still does */
:focus:not(:focus-visible) { outline: none; }
main:focus { outline: none; }            /* skip-link target shouldn't ring */

/* 1.4.13 / 2.3.3 — respect users who ask the OS to reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* Trademark notice in the footer (common-law ™ assertion) */
.tm-notice {
  margin-top: 18px; padding-top: 14px;
  border-top: var(--hair-w) solid var(--hair);
  font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--mid-2); line-height: 1.6;
}

/* ── MARY model wordmark (orange-glasses logo) ──────────────────────────
   The navy "Mary" reads on light surfaces only — used in the model section
   head and on the MARY-Nano research entry, never on the navy chrome. */
.mary-logo { display: block; width: 240px; max-width: 66%; height: auto; margin: 0 0 18px; }
.mary-mark { display: block; height: 26px; width: auto; margin: 0 0 12px; }
@media (max-width: 880px) {
  .mary-logo { width: 178px; margin-bottom: 14px; }
  .mary-mark { height: 22px; }
}

/* Decode/denoise CTAs jitter faintly — a "live signal" shimmer that nods to the
   denoise theme. steps() makes it snap (glitchy) rather than glide. The global
   prefers-reduced-motion block above neutralizes it for motion-sensitive users. */
@keyframes denoise-jitter {
  0%, 100% { transform: translate(0, 0); }
  18% { transform: translate(0.4px, -0.3px); }
  36% { transform: translate(-0.35px, 0.35px); }
  54% { transform: translate(0.3px, 0.25px); }
  72% { transform: translate(-0.3px, -0.35px); }
  90% { transform: translate(0.25px, 0.2px); }
}
[data-denoise] { animation: denoise-jitter 1.1s steps(1, end) infinite; }
[data-denoise]:hover { animation-duration: 0.5s; }

/* ── Cookie consent (consent.js) — brand-matched, no dark patterns ──────────
   Accept and Reject are deliberately the same visual weight (EU consent rule). */
.cc-banner {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 300;
  display: flex; gap: 18px 28px; flex-wrap: wrap; align-items: center; justify-content: space-between;
  padding: 16px clamp(16px, 4vw, 40px);
  background: var(--bg); border-top: var(--hair-w) solid var(--ink);
  opacity: 0; transform: translateY(100%); transition: opacity var(--t-med), transform var(--t-med);
}
.cc-banner.cc-in { opacity: 1; transform: translateY(0); }
.cc-copy { margin: 0; flex: 1 1 360px; font-family: var(--sans); font-size: 13px; line-height: 1.5; color: var(--ink-2); }
.cc-copy a { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
.cc-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.cc-btn {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase;
  padding: 10px 16px; border-radius: 999px; cursor: pointer;
  border: var(--hair-w) solid var(--ink); background: transparent; color: var(--ink);
  transition: background var(--t-fast), color var(--t-fast);
}
.cc-btn:hover { background: var(--ink); color: var(--bg); }
.cc-btn.cc-text { border-color: transparent; color: var(--mid); padding: 10px 8px; }
.cc-btn.cc-text:hover { background: transparent; color: var(--ink); }

.cc-overlay {
  position: fixed; inset: 0; z-index: 310; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: color-mix(in oklab, var(--inverse) 55%, transparent);
  opacity: 0; transition: opacity var(--t-fast);
}
.cc-overlay.cc-in { opacity: 1; }
.cc-panel {
  width: 100%; max-width: 460px; background: var(--bg);
  border: var(--hair-w) solid var(--ink); border-radius: 10px; padding: clamp(20px, 4vw, 32px);
}
.cc-title { font-family: var(--serif); font-size: 26px; margin: 0 0 6px; color: var(--ink); }
.cc-sub { font-family: var(--sans); font-size: 13px; line-height: 1.5; color: var(--mid); margin: 0 0 18px; }
.cc-cats { list-style: none; margin: 0 0 22px; padding: 0; }
.cc-cats li { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 0; border-top: var(--hair-w) solid var(--hair); }
.cc-cats li:last-child { border-bottom: var(--hair-w) solid var(--hair); }
.cc-cat strong { display: block; font-family: var(--sans); font-size: 14px; color: var(--ink); }
.cc-cat span { display: block; font-size: 12px; color: var(--mid); margin-top: 2px; }
.cc-locked { font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--mid-2); white-space: nowrap; }
.cc-switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: none; cursor: pointer; }
.cc-switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.cc-switch span { position: absolute; inset: 0; background: var(--hair-2); border-radius: 999px; transition: background var(--t-fast); }
.cc-switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; background: var(--bg); border-radius: 50%; transition: transform var(--t-fast); }
.cc-switch input:checked + span { background: var(--orange); }
.cc-switch input:checked + span::after { transform: translateX(18px); }
.cc-switch input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 2px; }
.cc-panel .cc-actions { justify-content: flex-end; }
.cc-panel .cc-save { background: var(--ink); color: var(--bg); }
@media (max-width: 560px) { .cc-actions { width: 100%; } .cc-btn { flex: 1 1 auto; text-align: center; } }
