:root {
  /* Base surfaces */
  --bg: #0a0e14;
  --bg-alt: #0d1220;
  --bg-raised: #10162299;
  --hair: rgba(255,255,255,0.09);
  --hair-strong: rgba(255,255,255,0.16);

  /* Text */
  --ink: #e9edf5;
  --ink-dim: #b7bdcc;
  --muted: #7c869c;

  /* Brand */
  --accent: #3fb8ec;      /* lifted from brand sky blue #27AAE1 for dark-bg contrast */
  --accent-dim: rgba(63, 184, 236, 0.12);
  --signal: #ff5a34;      /* lifted from brand orange #F04E25 for dark-bg contrast */
  --signal-dim: rgba(255, 90, 52, 0.12);
  --signal-line: rgba(255, 90, 52, 0.35);
  --signal-fill: var(--signal-fill);
  --accent-line: rgba(63, 184, 236, 0.35);

  /* Contextual: these differ between themes, so they must be tokens rather
     than literals or light mode breaks. */
  --on-accent: #06121a;                      /* text on an accent-filled surface */
  --header-bg: rgba(10, 14, 20, 0.88);       /* translucent sticky header */
  --grid-line: rgba(255, 255, 255, 0.035);   /* blueprint texture */
  /* The dark-mode shield has a white knockout S-band, which vanishes on white.
     Light mode uses the original two-colour artwork instead. */
  --brand-mark: url("/assets/shield.png");

  --font: 'Avenir Next', 'Century Gothic', -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius: 3px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

/* ---------- keyboard accessibility ---------- */
/* Visible focus for keyboard users. :focus-visible keeps mouse clicks clean
   while ensuring tab navigation is always traceable, which browser defaults
   often fail to do against a near-black background. */
a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}
/* Fallback for browsers without :focus-visible support. */
@supports not selector(:focus-visible) {
  a:focus, button:focus { outline: 2px solid var(--accent); outline-offset: 3px; }
}
.post-row:focus-visible,
.recognition a:focus-visible,
.file-card:focus-visible { outline-offset: -2px; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
}
.skip-link:focus {
  left: 16px;
  top: 16px;
  padding: 10px 16px;
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  text-decoration: none;
  border-radius: var(--radius);
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 32px; }

a { color: var(--accent); }

/* ---------- header ---------- */
header.site {
  border-bottom: 1px solid var(--hair);
  padding: 22px 0;
  position: sticky;
  top: 0;
  background: var(--header-bg);
  backdrop-filter: blur(8px);
  z-index: 50;
}
header.site .wrap { display: flex; align-items: center; justify-content: space-between; }
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 600; color: var(--ink); text-decoration: none;
  letter-spacing: 0.2px; font-size: 15px;
}
.brand-mark {
  width: 28px; height: 28px; flex-shrink: 0;
  background: var(--brand-mark) center / contain no-repeat;
  opacity: 0.96;
}
.brand-mark-sm { width: 22px; height: 22px; opacity: 0.85; }
nav.primary a {
  color: var(--ink-dim);
  text-decoration: none;
  margin-left: 30px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  transition: color .15s;
}
nav.primary a.active, nav.primary a:hover { color: var(--accent); }

/* ---------- eyebrow / tag ---------- */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 20px;
}
.tag::before {
  content: '';
  width: 6px; height: 6px;
  background: var(--accent);
  display: inline-block;
}

/* ---------- hero ---------- */
.hero {
  padding: 88px 0 56px;
  border-bottom: 1px solid var(--hair);
  position: relative;
  background-image:
    linear-gradient(var(--bg) 0%, var(--bg) 100%),
    repeating-linear-gradient(0deg, var(--grid-line) 0px, var(--grid-line) 1px, transparent 1px, transparent 48px),
    repeating-linear-gradient(90deg, var(--grid-line) 0px, var(--grid-line) 1px, transparent 1px, transparent 48px);
}
.hero h1 {
  font-size: 46px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 20px;
  letter-spacing: -0.5px;
  line-height: 1.12;
  max-width: 780px;
}
.hero p.lede {
  font-size: 18px;
  color: var(--ink-dim);
  max-width: 660px;
  margin: 0;
  font-weight: 400;
}

/* ---------- sections ---------- */
section { padding: 64px 0; }
section.alt { background: var(--bg-alt); border-top: 1px solid var(--hair); border-bottom: 1px solid var(--hair); }
h2.section-title {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 1.8px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  margin: 0 0 28px;
  display: flex;
  align-items: center;
  gap: 12px;
}
h2.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--hair);
}

.prose p { max-width: 720px; color: var(--ink-dim); }
.prose strong { color: var(--ink); }

/* ---------- long-form article body (Insights posts) ---------- */
.article-body {
  max-width: 720px;
  color: var(--ink-dim);
  font-size: 16px;
}
.article-body h2, .article-body h3, .article-body h4 {
  color: var(--ink);
  font-weight: 600;
  margin: 40px 0 16px;
  line-height: 1.3;
}
.article-body h2 { font-size: 22px; }
.article-body h3 { font-size: 18px; }
.article-body p { margin: 0 0 20px; }
.article-body a { color: var(--accent); text-decoration: underline; text-decoration-color: var(--accent-line); }
.article-body a:hover { text-decoration-color: var(--accent); }
.article-body ul, .article-body ol { margin: 0 0 20px; padding-left: 22px; }
.article-body li { margin-bottom: 8px; }
.article-body img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  margin: 8px 0 28px;
  display: block;
}
.article-body figure { margin: 0 0 28px; }
.article-body figcaption {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  margin-top: -18px;
  margin-bottom: 28px;
}
.article-body blockquote {
  margin: 0 0 24px;
  padding: 4px 20px;
  border-left: 2px solid var(--accent);
  color: var(--ink-dim);
  font-style: italic;
}
.article-body code {
  font-family: var(--font-mono);
  font-size: 13.5px;
  background: var(--bg-alt);
  border: 1px solid var(--hair);
  padding: 2px 6px;
  border-radius: 2px;
  color: var(--accent);
}
.article-body pre {
  background: var(--bg-alt);
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  padding: 18px 20px;
  overflow-x: auto;
  margin: 0 0 28px;
}
.article-body pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--ink-dim);
  font-size: 13px;
  line-height: 1.6;
}
.article-body hr { border: none; border-top: 1px solid var(--hair); margin: 40px 0; }

/* ---------- technical diagrams (inline SVG) ---------- */
.diagram {
  margin: 32px 0 0;
  border: 1px solid var(--hair);
  border-radius: var(--radius);
  background: var(--bg-alt);
  padding: 28px 24px 20px;
  /* Technical diagrams stay legible rather than shrinking to nothing on
     narrow screens; scroll horizontally instead. */
  overflow-x: auto;
}
.diagram svg {
  display: block;
  width: 100%;
  min-width: 720px;
  height: auto;
}
.diagram-caption {
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--muted);
  margin: 18px 0 0;
  max-width: 640px;
}

/* Shared type + shape language for all diagrams. */
.dg-band-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  fill: var(--muted);
}
.dg-box {
  fill: var(--bg);
  stroke: var(--hair-strong);
  stroke-width: 1;
}
.dg-box-label {
  font-family: var(--font);
  font-size: 12.5px;
  fill: var(--ink-dim);
}
.dg-flow {
  stroke: var(--accent);
  stroke-width: 1.25;
  fill: none;
}
.dg-boundary {
  stroke: var(--signal);
  stroke-width: 1.25;
  stroke-dasharray: 5 4;
  fill: none;
}
.dg-boundary-alt {
  stroke: var(--hair-strong);
  stroke-width: 1;
  stroke-dasharray: 3 4;
  fill: none;
}
.dg-boundary-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  fill: var(--signal);
}
.dg-note {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.4px;
  fill: var(--muted);
}

/* Intersection diagram: three disciplines, emphasised overlap. */
.dg-domain {
  fill: none;
  stroke: var(--hair-strong);
  stroke-width: 1;
}
.dg-domain-label {
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  fill: var(--ink-dim);
  text-anchor: middle;
}
.dg-overlap {
  fill: var(--signal-fill);
  stroke: var(--signal);
  stroke-width: 1;
}
.dg-overlap-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  fill: var(--signal);
  text-anchor: middle;
}
.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 28px;
  font-size: 14px;
}
.article-body th,
.article-body td {
  text-align: left;
  padding: 10px 14px;
  border: 1px solid var(--hair);
  vertical-align: top;
}
.article-body th {
  font-family: var(--font-mono);
  font-size: 11.5px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  background: var(--bg-alt);
}
.article-body td { color: var(--ink-dim); }

.article-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

/* ---------- insights index list ---------- */
.post-list { border: 1px solid var(--hair); }
.post-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 24px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--hair);
  text-decoration: none;
  color: inherit;
}
.post-row:last-child { border-bottom: none; }
.post-row:hover { background: var(--bg-alt); }
.post-row .post-title { color: var(--ink); font-weight: 600; font-size: 15.5px; }
.post-row .post-excerpt { color: var(--muted); font-size: 13.5px; margin-top: 4px; max-width: 560px; }
.post-row .post-date { font-family: var(--font-mono); font-size: 12px; color: var(--muted); white-space: nowrap; }

.category-pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--muted);
  border: 1px solid var(--hair-strong);
  padding: 3px 8px;
  border-radius: 2px;
  margin-bottom: 10px;
}

.file-card {
  display: flex;
  align-items: center;
  gap: 18px;
  border: 1px solid var(--hair-strong);
  padding: 20px 22px;
  border-radius: var(--radius);
  text-decoration: none;
  margin: 8px 0 28px;
  transition: border-color .15s;
}
.file-card:hover { border-color: var(--accent); }
.file-card-icon {
  flex-shrink: 0;
  width: 42px; height: 42px;
  border: 1px solid var(--hair-strong);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
}
.file-card-title { color: var(--ink); font-weight: 600; font-size: 15px; margin-bottom: 4px; }
.file-card-caption { font-family: var(--font-mono); font-size: 12px; color: var(--muted); }

/* ---------- team grid ---------- */
.people-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  margin-top: 8px;
  background: var(--hair);
  border: 1px solid var(--hair);
}
.people-grid-3 { grid-template-columns: repeat(3, 1fr); }

.person {
  padding: 24px;
  background: var(--bg);
  display: flex;
  align-items: flex-start;
  gap: 18px;
}
.person-info { flex: 1; min-width: 0; }
.person .avatar {
  width: 84px; height: 84px;
  flex-shrink: 0;
  border-radius: var(--radius);
  background: var(--bg-alt);
  border: 1px solid var(--hair-strong);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); font-weight: 700; font-size: 20px;
  font-family: var(--font-mono);
  overflow: hidden;
  position: relative;
}
.person .avatar img,
.single-person .avatar-lg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Photo hover reveal: two stacked <img> tags pointing at the SAME source
   photo — the top layer gets the live duotone filter, the bottom is plain
   color. Hover crossfades between them. Only one photo file needed per
   person; the browser does the duotone work, no offline preprocessing
   required. Markup pattern:
   <div class="avatar avatar-photo">
     <img class="photo-color" src="team/name.jpg">
     <img class="photo-duo" src="team/name.jpg">
   </div>
   Crossfading opacity rather than transitioning the filter itself, since
   CSS can't reliably interpolate a url()-referenced SVG filter smoothly
   across browsers. */
.avatar-photo { position: relative; }
.avatar-photo img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.avatar-photo .photo-color { opacity: 0; transition: opacity .45s ease; }
.avatar-photo .photo-duo {
  opacity: 1;
  transition: opacity .45s ease;
  filter: url(#stigian-duotone) grayscale(1) contrast(1.12);
}
.avatar-photo:hover .photo-color { opacity: 1; }
.avatar-photo:hover .photo-duo { opacity: 0; }
@media (prefers-reduced-motion: reduce) {
  .avatar-photo .photo-color, .avatar-photo .photo-duo { transition: none; }
}
.person h3 { margin: 0 0 2px; font-size: 16px; color: var(--ink); font-weight: 600; }
.person-info .role { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); margin-bottom: 10px; letter-spacing: 0.3px; text-transform: uppercase; }
.person-info p { font-size: 14px; color: var(--ink-dim); margin: 0; }
.person-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
}
.person-link:hover { color: var(--accent); }
.person-link svg { width: 12px; height: 12px; fill: currentColor; }

.single-person { display: flex; gap: 36px; align-items: flex-start; margin-top: 8px; }
.single-person .avatar-lg {
  width: 108px; height: 108px; border-radius: var(--radius);
  background: var(--bg-alt);
  border: 1px solid var(--hair-strong);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); font-weight: 700; font-size: 34px;
  font-family: var(--font-mono);
  overflow: hidden;
  position: relative;
}
.single-person h3 { margin: 0 0 2px; font-size: 21px; color: var(--ink); }
.single-person .role { font-family: var(--font-mono); color: var(--muted); font-size: 12px; letter-spacing: 0.3px; text-transform: uppercase; margin-bottom: 16px; }
.single-person p { max-width: 620px; color: var(--ink-dim); }

/* ---------- stats ---------- */
.stat-row {
  display: flex;
  gap: 0;
  margin-top: 8px;
  flex-wrap: wrap;
  border: 1px solid var(--hair);
}

/* ---------- record list (track record / firsts) ---------- */
.record-list {
  border-top: 1px solid var(--hair);
  margin-top: 4px;
  max-width: 780px;
}
.record-item {
  display: flex;
  gap: 18px;
  padding: 16px 0;
  border-bottom: 1px solid var(--hair);
  align-items: baseline;
}
.record-item .marker {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  flex-shrink: 0;
  width: 26px;
  letter-spacing: 0.5px;
}
.record-item .record-text {
  color: var(--ink-dim);
  font-size: 15px;
}
.record-item .record-text strong { color: var(--ink); font-weight: 600; }
.stat {
  flex: 1;
  min-width: 160px;
  padding: 20px 24px;
  border-right: 1px solid var(--hair);
}
.stat:last-child { border-right: none; }
.stat .n { font-family: var(--font-mono); font-size: 26px; font-weight: 600; color: var(--ink); }
.stat .l { font-family: var(--font-mono); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.8px; margin-top: 4px; }

/* ---------- recognition ---------- */
.recognition {
  border: 1px solid var(--hair);
  padding: 28px 32px;
  background: var(--bg);
  display: flex;
  gap: 24px;
  align-items: flex-start;
}
.recognition + .recognition { margin-top: -1px; }
.recognition .badge {
  flex-shrink: 0;
  width: 42px; height: 42px;
  border-radius: var(--radius);
  background: var(--signal-dim);
  border: 1px solid var(--signal-line);
  color: var(--signal);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px;
  font-family: var(--font-mono);
}
.recognition .rec-label {
  font-family: var(--font-mono);
  font-size: 11px; letter-spacing: 1px; text-transform: uppercase;
  color: var(--signal); font-weight: 600; margin-bottom: 8px;
}
.recognition h3 { margin: 0 0 8px; font-size: 18px; color: var(--ink); font-weight: 600; }
.recognition p { margin: 0 0 12px; color: var(--ink-dim); font-size: 15px; max-width: 620px; }
.recognition a.rec-link { font-family: var(--font-mono); font-size: 12.5px; font-weight: 600; color: var(--accent); text-decoration: none; }
.recognition a.rec-link:hover { text-decoration: underline; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  text-decoration: none;
  padding: 12px 20px;
  border: 1px solid var(--hair-strong);
  color: var(--ink);
  border-radius: var(--radius);
  transition: all .15s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.primary:hover { background: transparent; color: var(--accent); }

/* ---------- footer ---------- */
footer.site {
  border-top: 1px solid var(--hair);
  padding: 40px 0;
  font-size: 13px;
  color: var(--muted);
}
.footer-grid {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
  flex-wrap: wrap;
  font-family: var(--font-mono);
  font-size: 12px;
}

.footer-grid a { color: var(--muted); text-decoration: none; }
.footer-grid a:hover { color: var(--accent); }
.footer-grid .copyright { color: var(--muted); }

/* ---------- mobile nav ---------- */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 32px; height: 32px;
  background: none; border: none; cursor: pointer;
}
.nav-toggle span { display: block; height: 2px; width: 100%; background: var(--ink); }


/* ---------- comparison banner (dev-only) ---------- */
.compare-banner {
  background: var(--bg-alt);
  color: var(--ink-dim);
  border-bottom: 1px solid var(--hair);
  padding: 10px 0;
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: center;
}
.compare-banner a { color: var(--accent); text-decoration: none; margin: 0 10px; font-weight: 600; }
.compare-banner a.current { color: var(--ink); text-decoration: underline; }

/* ==========================================================================
   LIGHT MODE
   --------------------------------------------------------------------------
   Dark is the house default. Light is provided for users whose system asks
   for it, plus a manual [data-theme] override.

   Three of the four canonical brand colours FAIL contrast as text on white
   (sky 2.65:1, orange 3.61:1, warm grey 3.93:1 — only navy passes at
   10.92:1). So light mode darkens them, exactly as dark mode lightened them.
   Every value below is verified >= 4.5:1 against both light surfaces.

   The two blocks are identical and MUST STAY IN SYNC. CSS cannot share one
   declaration block across a media-query boundary, so this is duplicated
   deliberately rather than cleverly.
   ========================================================================== */

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg:          #ffffff;
    --bg-alt:      #f4f6f9;
    --bg-raised:   #ffffff;
    --hair:        rgba(31, 59, 113, 0.14);
    --hair-strong: rgba(31, 59, 113, 0.26);

    --ink:     #0f172a;   /* 17.9:1 */
    --ink-dim: #39435c;   /*  9.9:1 */
    --muted:   #5f6b82;   /*  5.4:1 */

    --accent:      #0d6ea3;                  /* 5.6:1 — darkened brand sky */
    --accent-dim:  rgba(13, 110, 163, 0.10);
    --signal:      #c63b18;                  /* 5.2:1 — darkened brand orange */
    --signal-dim:  rgba(198, 59, 24, 0.10);
    --signal-line: rgba(198, 59, 24, 0.35);
    --signal-fill: rgba(198, 59, 24, 0.10);
    --accent-line: rgba(13, 110, 163, 0.35);
    --on-accent:   #ffffff;
    --header-bg:   rgba(255, 255, 255, 0.88);
    --grid-line:   rgba(31, 59, 113, 0.055);
    --brand-mark:  url("/assets/shield-light.png");
  }
}

:root[data-theme="light"] {
  --bg:          #ffffff;
  --bg-alt:      #f4f6f9;
  --bg-raised:   #ffffff;
  --hair:        rgba(31, 59, 113, 0.14);
  --hair-strong: rgba(31, 59, 113, 0.26);

  --ink:     #0f172a;
  --ink-dim: #39435c;
  --muted:   #5f6b82;

  --accent:      #0d6ea3;
  --accent-dim:  rgba(13, 110, 163, 0.10);
  --signal:      #c63b18;
  --signal-dim:  rgba(198, 59, 24, 0.10);
  --signal-line: rgba(198, 59, 24, 0.35);
  --signal-fill: rgba(198, 59, 24, 0.10);
  --accent-line: rgba(13, 110, 163, 0.35);
  --on-accent:   #ffffff;
  --header-bg:   rgba(255, 255, 255, 0.88);
  --grid-line:   rgba(31, 59, 113, 0.055);
  --brand-mark:  url("/assets/shield-light.png");
}

/* Tell the browser to render native controls and scrollbars to match. */
:root { color-scheme: dark light; }
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"]  { color-scheme: dark; }

/* --- per-element light-mode corrections ------------------------------------
   Things that cannot be fixed by swapping a token alone. */

@media (prefers-color-scheme: light) {
  /* The duotone headshot treatment maps shadows to near-black, which reads as
     a hole punched in a white page. Use a light desaturation instead; the
     hover-to-colour reveal still works. */
  :root:not([data-theme="dark"]) .avatar-photo .photo-duo {
    filter: grayscale(1) contrast(0.95) brightness(1.05);
  }
}

:root[data-theme="light"] .avatar-photo .photo-duo { filter: grayscale(1) contrast(0.95) brightness(1.05); }

/* ==========================================================================
   MOBILE
   --------------------------------------------------------------------------
   Most visits are expected to be from executives on phones, so this is a
   primary target rather than a fallback. Breakpoints are in em so they
   respect browser zoom.
   ========================================================================== */

/* Never let a long unbroken token (an ARN, a hash, a URL) force a horizontal
   scrollbar on the whole page. */
body { overflow-wrap: break-word; }

/* Honour notch/home-indicator insets on iOS. */
@supports (padding: max(0px)) {
  .wrap {
    padding-left:  max(var(--sp-8, 32px), env(safe-area-inset-left));
    padding-right: max(var(--sp-8, 32px), env(safe-area-inset-right));
  }
}

/* Hover effects must not stick after a tap on touch devices. */
@media (hover: none) {
  .post-row:hover { background: none; }
  .avatar-photo:hover .photo-color { opacity: 0; }
  .avatar-photo:hover .photo-duo { opacity: 1; }
}

/* Touch targets. WCAG 2.5.8 requires 24px minimum; Apple and Google both
   recommend 44px. Applied only for coarse pointers so desktop stays compact. */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  nav.primary a { min-height: 44px; display: flex; align-items: center; }
  .nav-toggle { width: 44px; height: 44px; }
  .post-row { padding-top: var(--sp-4); padding-bottom: var(--sp-4); }
  .person-link { min-height: 32px; align-items: center; }
}

@media (max-width: 47.5em) {           /* 760px */
  .wrap { padding-left: 20px; padding-right: 20px; }

  /* Collapsed navigation */
  .nav-toggle { display: flex; }
  nav.primary {
    display: none;
    position: absolute;
    top: 100%; left: 0; right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--hair);
    flex-direction: column;
    padding: 8px 20px 20px;
  }
  nav.primary.open { display: flex; }
  nav.primary a { margin: 0; }
  header.site .wrap { position: relative; flex-wrap: wrap; }

  /* Stack the grids */
  .people-grid, .people-grid-3 { grid-template-columns: 1fr; }
  .person { flex-direction: column; }
  .single-person { flex-direction: column; }
  .stat-row { flex-direction: column; }
  .stat { border-right: none; border-bottom: 1px solid var(--hair); }
  .stat:last-child { border-bottom: none; }

  /* Tighten the vertical rhythm — desktop section padding wastes a phone screen. */
  section { padding: 40px 0; }
  .hero { padding: 48px 0 32px; }

  .hero h1 { font-size: 30px; }
  .hero p.lede { font-size: 16.5px; }

  /* Post list rows: date under the title instead of squeezed beside it. */
  .post-row { flex-direction: column; align-items: flex-start; gap: var(--sp-2); }
  .post-row .post-date { order: -1; }

  /* Recognition / Speaking items stack under their badge. */
  .recognition { flex-direction: column; gap: var(--sp-3); padding: 22px 20px; }

  /* Track-record rows keep the numeral inline but tighten up. */
  .record-item { gap: 12px; padding: 14px 0; }
  .record-item .marker { width: 20px; }

  /* Long-form articles */
  .article-body { font-size: 16px; }
  .article-body h2 { font-size: 20px; }
  .article-body pre { padding: 14px; font-size: 12.5px; }

  /* Diagrams stay legible and scroll, with reduced chrome. */
  .diagram { padding: 18px 14px 14px; }

  .file-card { flex-direction: column; align-items: flex-start; gap: var(--sp-3); }
}

@media (max-width: 30em) {             /* 480px — small phones */
  .hero h1 { font-size: 26px; }
  .stat .n { font-size: 22px; }
  .btn { width: 100%; justify-content: center; }
  .btn + .btn { margin-top: var(--sp-2); }
}

/* Tables inside migrated articles were authored as bare <table> with no
   scroll wrapper. Make them scrollable rather than letting them blow out the
   page width on a phone. */
.article-body table { display: block; overflow-x: auto; white-space: nowrap; }
@media (min-width: 47.5625em) {
  .article-body table { display: table; white-space: normal; }
}
