/* =============================================================
   Rahil Sahu — Portfolio
   Design: report/terminal duality, functional severity accents
   No third-party fonts / no external assets / CSP-friendly
   ============================================================= */

/* -------------------- 1 · Tokens -------------------- */

:root {
  /* Paper (light) — the report cover */
  --bg:            #F0EEE7;
  --surface:       #FBFAF6;
  --surface-alt:   #E8E5DC;
  --ink:           #0B0F14;
  --ink-strong:    #000000;
  --ink-muted:     #5A6068;
  --ink-subtle:    #8A8F98;
  --line:          #D5D0C4;
  --line-strong:   #B8B2A2;

  /* Severity system — functional accent set */
  --sev-crit:      #B91C1C;
  --sev-high:      #C2410C;
  --sev-med:       #A16207;
  --sev-low:       #4D7C0F;
  --sev-info:      #1E40AF;

  /* Signature accent — used sparingly for the one moment */
  --accent:        #B91C1C;
  --accent-ink:    #FFFFFF;

  /* Terminal panel — the documentary inset */
  --term-bg:       #0B0F14;
  --term-fg:       #C9D1D9;
  --term-dim:      #6E7681;
  --term-good:     #58C4A7;
  --term-warn:     #F7B26B;
  --term-crit:     #F85552;
  --term-high:     #FF9E64;
  --term-med:      #E0AF68;
  --term-prompt:   #7EE5C8;
  --term-cursor:   #98C379;

  /* Type */
  --font-body: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", "Roboto Mono", Menlo, Consolas, monospace;

  /* Scale */
  --step--1:  0.8125rem;
  --step-0:   0.9375rem;
  --step-1:   1.0625rem;
  --step-2:   1.25rem;
  --step-3:   1.5625rem;
  --step-4:   2rem;
  --step-5:   2.75rem;
  --step-6:   3.75rem;

  /* Layout */
  --wrap-max:  1180px;
  --gutter:    clamp(1.25rem, 4vw, 2.5rem);
  --radius:    4px;
  --radius-lg: 8px;

  /* Motion */
  --ease:  cubic-bezier(.2,.7,.3,1);
  --dur:   180ms;
}

/* Dark — terminal-forward */
:root[data-theme="dark"] {
  --bg:            #0B0F14;
  --surface:       #131820;
  --surface-alt:   #0F141B;
  --ink:           #E6EDF3;
  --ink-strong:    #FFFFFF;
  --ink-muted:     #9AA4AF;
  --ink-subtle:    #6B7480;
  --line:          #22282F;
  --line-strong:   #363D46;

  --sev-crit:      #F87171;
  --sev-high:      #FB923C;
  --sev-med:       #FBBF24;
  --sev-low:       #A3E635;
  --sev-info:      #60A5FA;

  --accent:        #F87171;
  --accent-ink:    #0B0F14;

  --term-bg:       #010409;
}

/* Auto: follow system when no user override */
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg:            #0B0F14;
    --surface:       #131820;
    --surface-alt:   #0F141B;
    --ink:           #E6EDF3;
    --ink-strong:    #FFFFFF;
    --ink-muted:     #9AA4AF;
    --ink-subtle:    #6B7480;
    --line:          #22282F;
    --line-strong:   #363D46;
    --sev-crit:      #F87171;
    --sev-high:      #FB923C;
    --sev-med:       #FBBF24;
    --sev-low:       #A3E635;
    --sev-info:      #60A5FA;
    --accent:        #F87171;
    --accent-ink:    #0B0F14;
    --term-bg:       #010409;
  }
}

/* -------------------- 2 · Reset & base -------------------- */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

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

a { color: var(--ink); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-color: var(--accent); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 3px;
}

button { font: inherit; color: inherit; cursor: pointer; }

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

.skip-link {
  position: absolute; left: -9999px; top: 8px; padding: 8px 12px;
  background: var(--ink); color: var(--bg); border-radius: var(--radius);
  z-index: 1000;
}
.skip-link:focus { left: 8px; }

/* -------------------- 3 · Layout -------------------- */

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

.section {
  padding: clamp(3.5rem, 8vw, 6.5rem) 0;
  border-top: 1px solid var(--line);
}
.section-alt { background: var(--surface-alt); }

.section-tag {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--ink-muted);
  margin: 0 0 1rem;
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.section-tag-num {
  display: inline-block;
  padding: 2px 6px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  color: var(--ink);
  background: var(--surface);
}

.section-title {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: clamp(1.75rem, 4vw, var(--step-4));
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 0 0 0.75rem;
  color: var(--ink-strong);
  max-width: 22ch;
}

.section-lead {
  font-size: var(--step-1);
  color: var(--ink-muted);
  max-width: 62ch;
  margin: 0 0 2.5rem;
}

/* -------------------- 4 · Header -------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: color-mix(in oklab, var(--bg) 88%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding-top: 0.9rem;
  padding-bottom: 0.9rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--ink);
  min-width: 0;
}

.brand-mark {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: var(--step-1);
  color: var(--accent);
  letter-spacing: 0.02em;
  line-height: 1;
  padding: 6px 8px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface);
}
.brand-bracket { color: var(--ink-muted); }
.brand-initials { color: var(--accent); }

.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-name { font-weight: 700; font-size: var(--step-0); }
.brand-role { font-size: var(--step--1); color: var(--ink-muted); font-family: var(--font-mono); }

.site-nav { display: flex; gap: 1rem; margin-left: auto; }
.site-nav a {
  font-size: var(--step--1);
  text-decoration: none;
  color: var(--ink-muted);
  padding: 6px 2px;
  border-bottom: 1px solid transparent;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.site-nav a:hover,
.site-nav a.is-current { color: var(--ink); border-bottom-color: var(--accent); }

.header-actions { display: flex; gap: 0.75rem; align-items: center; }

@media (max-width: 1200px) {
  .brand-role { display: none; }
}

@media (max-width: 860px) {
  .site-nav { display: none; }
  .brand-role { display: none; }
}

/* -------------------- 5 · Buttons -------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: var(--step-0);
  text-decoration: none;
  border: 1px solid transparent;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
  cursor: pointer;
  line-height: 1.2;
}
.btn-small { padding: 7px 12px; font-size: var(--step--1); }

.btn-primary {
  background: var(--ink-strong);
  color: var(--bg);
  border-color: var(--ink-strong);
}
.btn-primary:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line-strong);
}
.btn-ghost:hover { border-color: var(--ink); background: var(--surface); }

.btn:active { transform: translateY(1px); }

/* Theme toggle */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--surface);
  color: var(--ink-muted);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  min-width: 74px;
  justify-content: center;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--ink-muted); }
.theme-toggle-track {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--sev-low);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--sev-low) 30%, transparent);
}
:root[data-theme="dark"] .theme-toggle-track { background: var(--sev-info); box-shadow: 0 0 0 2px color-mix(in oklab, var(--sev-info) 30%, transparent); }

/* -------------------- 6 · Hero -------------------- */

.hero {
  padding-top: clamp(3rem, 7vw, 5rem);
  padding-bottom: clamp(3.5rem, 8vw, 6rem);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
}

.hero-title {
  font-family: var(--font-body);
  font-weight: 800;
  font-size: clamp(2.25rem, 5.5vw, var(--step-6));
  line-height: 1.02;
  letter-spacing: -0.03em;
  margin: 0.5rem 0 1.5rem;
  color: var(--ink-strong);
}

.hero-lead {
  font-size: var(--step-2);
  line-height: 1.5;
  color: var(--ink-muted);
  max-width: 46ch;
  margin: 0 0 2.25rem;
}

.hero-metrics {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  margin: 0 0 2.25rem;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 1rem 0;
}
.metric {
  padding: 0 0.75rem;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.metric:last-child { border-right: 0; }
.metric-value {
  font-family: var(--font-mono);
  font-size: var(--step-3);
  font-weight: 700;
  line-height: 1;
  color: var(--ink-strong);
  letter-spacing: -0.02em;
}
.metric-plus { color: var(--accent); margin-left: 1px; }
.metric-label {
  font-size: var(--step--1);
  color: var(--ink-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.sev-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
}
.sev-crit { background: var(--sev-crit); }
.sev-high { background: var(--sev-high); }
.sev-med  { background: var(--sev-med); }
.sev-low  { background: var(--sev-low); }
.sev-info { background: var(--sev-info); }

.hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; }

@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-metrics { grid-template-columns: repeat(2, 1fr); }
  .metric { border-right: 0; border-bottom: 1px solid var(--line); padding: 0.5rem 0; }
  .metric:nth-last-child(-n+1) { border-bottom: 0; }
  .metric:nth-child(odd) { padding-right: 0.5rem; }
  .metric:nth-child(even) { padding-left: 0.5rem; border-left: 1px solid var(--line); }
}

/* -------------------- 7 · Terminal -------------------- */

.hero-terminal { position: relative; }

.terminal {
  background: var(--term-bg);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: 0 20px 40px -20px rgba(0,0,0,0.4), 0 2px 8px rgba(0,0,0,0.08);
}

.terminal-chrome {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  background: color-mix(in oklab, var(--term-bg) 92%, white);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.terminal-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: #3A3F47;
}
.terminal-dot:nth-child(1) { background: #E06C75; }
.terminal-dot:nth-child(2) { background: #E5C07B; }
.terminal-dot:nth-child(3) { background: #98C379; }
.terminal-title {
  color: var(--term-dim);
  font-family: var(--font-mono);
  font-size: var(--step--1);
  margin-left: 8px;
  flex: 1;
}
.terminal-copy {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--term-dim);
  padding: 3px 10px;
  font-family: var(--font-mono);
  font-size: 11px;
  border-radius: 3px;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.terminal-copy:hover { color: var(--term-good); border-color: var(--term-good); }
.terminal-copy.is-copied { color: var(--term-good); border-color: var(--term-good); }

.terminal-body {
  margin: 0;
  padding: 18px 20px 22px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--term-fg);
  overflow-x: auto;
  white-space: pre;
  tab-size: 2;
}
.terminal-body .tp { color: var(--term-prompt); }
.terminal-body .tc { color: var(--term-warn); }
.terminal-body .tm { color: var(--term-good); }
.terminal-body .tw { color: var(--term-crit); }
.terminal-body .sc { color: var(--term-crit); font-weight: 600; }
.terminal-body .sh { color: var(--term-high); font-weight: 600; }
.terminal-body .sm { color: var(--term-med); font-weight: 600; }

.terminal-note {
  color: var(--ink-subtle);
  font-size: var(--step--1);
  font-family: var(--font-mono);
  margin: 0.75rem 0 0;
  text-align: right;
}

/* -------------------- 8 · Practice matrix -------------------- */

.matrix-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
  margin-bottom: 3rem;
}

.matrix {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--step-0);
}
.matrix thead {
  background: var(--surface-alt);
}
.matrix th, .matrix td {
  text-align: left;
  padding: 14px 18px;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}
.matrix thead th {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--ink-muted);
  font-weight: 600;
  letter-spacing: 0.02em;
}
.matrix tbody tr:last-child th,
.matrix tbody tr:last-child td { border-bottom: 0; }
.matrix tbody tr:hover { background: color-mix(in oklab, var(--accent) 4%, transparent); }

.matrix-scope {
  font-weight: 700;
  color: var(--ink-strong);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.matrix-scope::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 14px;
  background: var(--accent);
  border-radius: 2px;
}

.matrix tbody th {
  font-weight: 600;
  white-space: nowrap;
  padding-right: 24px;
}

@media (max-width: 800px) {
  .matrix, .matrix thead, .matrix tbody, .matrix tr, .matrix th, .matrix td { display: block; }
  .matrix thead { display: none; }
  .matrix tbody tr {
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
  }
  .matrix tbody tr:last-child { border-bottom: 0; }
  .matrix th, .matrix td { padding: 4px 0; border-bottom: 0; }
  .matrix tbody th { margin-bottom: 6px; }
  .matrix td::before {
    content: attr(data-label);
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--ink-subtle);
    display: block;
  }
}

/* Also-does cards below matrix */
.also-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
}
.also-card {
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
}
.also-title {
  font-size: var(--step-1);
  margin: 0 0 0.5rem;
  color: var(--ink-strong);
}
.also-card p {
  margin: 0;
  color: var(--ink-muted);
  font-size: var(--step-0);
}

/* -------------------- 9 · Timeline -------------------- */

.timeline {
  list-style: none;
  padding: 0;
  margin: 0;
  position: relative;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 176px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: var(--line);
}

.timeline-item {
  display: grid;
  grid-template-columns: 176px 1fr;
  gap: 2rem;
  padding: 1.75rem 0;
  position: relative;
}
.timeline-item + .timeline-item { border-top: 1px solid var(--line); }

.timeline-meta { padding-top: 4px; position: relative; }
.timeline-meta::after {
  content: "";
  position: absolute;
  right: 0;
  top: 10px;
  width: 11px;
  height: 11px;
  transform: translateX(50%);
  background: var(--bg);
  border: 2px solid var(--accent);
  border-radius: 50%;
  z-index: 2;
}
.timeline-date {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--ink);
  font-weight: 600;
}
.timeline-loc {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--ink-muted);
  margin-top: 2px;
}

.timeline-role {
  font-size: var(--step-2);
  margin: 0 0 0.15rem;
  color: var(--ink-strong);
  font-weight: 700;
}
.timeline-org {
  color: var(--ink-muted);
  margin: 0 0 0.9rem;
  font-size: var(--step-0);
}
.timeline-points {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.timeline-points li {
  padding-left: 1.25rem;
  position: relative;
  color: var(--ink);
  font-size: var(--step-0);
  line-height: 1.55;
}
.timeline-points li::before {
  content: "▸";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--accent);
  font-family: var(--font-mono);
}
.timeline-points strong { color: var(--ink-strong); font-weight: 700; }

@media (max-width: 700px) {
  .timeline::before { display: none; }
  .timeline-item { grid-template-columns: 1fr; gap: 0.75rem; }
  .timeline-meta::after { display: none; }
}

/* -------------------- 10 · Toolchain -------------------- */

.tool-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 2rem;
}
.tool-filter {
  padding: 7px 14px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--ink-muted);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.tool-filter:hover { color: var(--ink); border-color: var(--ink-muted); }
.tool-filter.is-active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.tool-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--surface);
}
.tool {
  padding: 14px 18px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 2px;
  transition: background var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.tool.is-hidden { display: none; }
.tool:hover { background: color-mix(in oklab, var(--accent) 4%, transparent); }
.tool-name {
  font-weight: 600;
  color: var(--ink-strong);
  font-size: var(--step-0);
}
.tool-kind {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-muted);
}

/* -------------------- 11 · Credentials -------------------- */

.cred-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
  margin-bottom: 3rem;
}
.cred {
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.cred-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}
.cred-tag {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-muted);
  padding: 3px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
}
.cred-status {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.cred-status.is-active {
  color: var(--sev-low);
  background: color-mix(in oklab, var(--sev-low) 12%, transparent);
}
.cred-status.is-active::before {
  content: "";
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--sev-low);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--sev-low) 25%, transparent);
}

.cred-title {
  font-size: var(--step-1);
  margin: 0;
  color: var(--ink-strong);
  line-height: 1.3;
}

.cred-meta {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}
.cred-meta > div { min-width: 0; }
.cred-meta dt {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink-subtle);
  margin: 0 0 2px;
  letter-spacing: 0.02em;
}
.cred-meta dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--ink);
  word-break: break-all;
}

.edu-block {
  border-top: 1px solid var(--line);
  padding-top: 2rem;
}
.edu-title {
  font-size: var(--step-1);
  margin: 0 0 1rem;
  color: var(--ink-strong);
}
.edu-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.edu-list li {
  display: grid;
  grid-template-columns: 1.2fr 1.5fr 1fr;
  gap: 1.5rem;
  align-items: baseline;
  padding-bottom: 0.75rem;
  border-bottom: 1px dashed var(--line);
}
.edu-list li:last-child { border-bottom: 0; }
.edu-degree { font-weight: 600; color: var(--ink-strong); }
.edu-org { color: var(--ink-muted); font-size: var(--step-0); }
.edu-date { font-family: var(--font-mono); font-size: var(--step--1); color: var(--ink-muted); }

@media (max-width: 700px) {
  .edu-list li { grid-template-columns: 1fr; gap: 0.25rem; }
}

/* -------------------- 12 · Engagement (contact) -------------------- */

.engagement-grid {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: clamp(2rem, 5vw, 4rem);
  align-items: start;
}

.contact-lines {
  list-style: none;
  padding: 0;
  margin: 0;
  border-top: 1px solid var(--line);
}
.contact-lines li {
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 1rem;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  align-items: center;
}
.contact-label {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--ink-muted);
  text-transform: lowercase;
}
.contact-lines a { text-decoration: none; color: var(--ink); border-bottom: 1px solid var(--line-strong); }
.contact-lines a:hover { border-bottom-color: var(--accent); color: var(--accent); }

.engagement-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.75rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}
.form-field { display: flex; flex-direction: column; gap: 0.4rem; }
.form-field label {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--ink-muted);
}
.form-field .opt { color: var(--ink-subtle); }

.form-field input,
.form-field select,
.form-field textarea {
  font: inherit;
  font-size: var(--step-0);
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
  width: 100%;
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 20%, transparent);
}
.form-field textarea { resize: vertical; min-height: 120px; font-family: var(--font-body); }

.honeypot { position: absolute; left: -9999px; top: -9999px; }

.form-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}
.form-note {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--ink-muted);
}
.form-note.is-ok { color: var(--sev-low); }
.form-note.is-err { color: var(--sev-crit); }

@media (max-width: 900px) {
  .engagement-grid { grid-template-columns: 1fr; }
}

/* -------------------- 13 · Footer -------------------- */

.site-footer {
  background: var(--surface-alt);
  border-top: 1px solid var(--line);
  padding: 3rem 0 2rem;
  margin-top: 0;
}
.footer-inner {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1.2fr 1fr;
  gap: 2rem;
  align-items: start;
}
.footer-col { min-width: 0; }
.footer-title {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--ink-muted);
  margin: 0 0 0.75rem;
}
.footer-sub { margin: 0; color: var(--ink-muted); font-size: var(--step-0); }
.footer-links {
  list-style: none;
  padding: 0;
  margin: 0 0 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.footer-links a {
  color: var(--ink);
  text-decoration: none;
  font-size: var(--step-0);
  border-bottom: 1px solid transparent;
}
.footer-links a:hover { border-bottom-color: var(--accent); }
.footer-note {
  margin: 0;
  color: var(--ink-subtle);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.6;
}
.footer-copy {
  margin: 0;
  color: var(--ink-muted);
  font-size: var(--step--1);
  font-family: var(--font-mono);
}

@media (max-width: 700px) {
  .footer-inner { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
  .footer-inner { grid-template-columns: 1fr; }
}

/* -------------------- 14 · Motion & print -------------------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media print {
  .site-header, .site-footer, .header-actions, .hero-actions, .engagement-form, .theme-toggle, .terminal-copy { display: none !important; }
  body { background: white; color: black; }
  .section, .hero { padding: 1.5rem 0; border: 0; }
  .hero-title { font-size: 24pt; }
  a { color: black; text-decoration: underline; }
  .terminal { border: 1px solid #999; }
  .terminal-body { color: #111; background: white !important; }
  .terminal-body .tp, .terminal-body .tc, .terminal-body .tm, .terminal-body .tw, .terminal-body .sc, .terminal-body .sh, .terminal-body .sm { color: black; }
}

/* ============================================================
   15 · MATRIX RAIN CANVAS (fixed background layer)
   ============================================================ */
.matrix-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.10;
  transition: opacity 0.35s ease;
  mix-blend-mode: normal;
}
[data-theme="dark"] .matrix-canvas { opacity: 0.14; }
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] .matrix-canvas { opacity: 0.14; }
}
@media (prefers-reduced-motion: reduce) {
  .matrix-canvas { display: none !important; }
}
/* Ensure page content sits above the canvas */
.site-header, main, .site-footer { position: relative; z-index: 1; }

/* ============================================================
   16 · FX TOGGLE BUTTON
   ============================================================ */
.fx-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: var(--step--2);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.fx-toggle:hover { border-color: var(--accent); color: var(--accent); }
.fx-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.fx-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  animation: fxPulse 1.6s ease-in-out infinite;
}
.fx-toggle[aria-pressed="false"] .fx-dot {
  background: var(--ink-muted);
  box-shadow: none;
  animation: none;
}
@keyframes fxPulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

/* ============================================================
   17 · SCROLL REVEAL ANIMATION
   ============================================================ */
.will-reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.65s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.65s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: opacity, transform;
}
.will-reveal.is-revealed {
  opacity: 1;
  transform: none;
}
/* Staggered children reveal for grids */
.cred-grid .will-reveal.is-revealed,
.tool-grid .will-reveal.is-revealed,
.ctf-grid .will-reveal.is-revealed,
.learn-grid .will-reveal.is-revealed,
.ai-grid .will-reveal.is-revealed { transition-delay: calc(var(--i, 0) * 40ms); }

@media (prefers-reduced-motion: reduce) {
  .will-reveal { opacity: 1 !important; transform: none !important; transition: none !important; }
}

/* Hero title glitch on load */
.hero-title {
  position: relative;
  animation: heroFadeIn 0.8s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes heroFadeIn {
  from { opacity: 0; transform: translateY(6px); letter-spacing: 0.02em; }
  to   { opacity: 1; transform: none; letter-spacing: normal; }
}
@media (prefers-reduced-motion: reduce) {
  .hero-title { animation: none; }
}

/* Terminal body typing effect — blinking cursor at end while typing */
.terminal-body:not(.is-done)::after {
  content: "▊";
  color: var(--accent);
  animation: blink 1s steps(2) infinite;
  margin-left: 2px;
}
@keyframes blink { 50% { opacity: 0; } }

/* Section number label subtle scan animation */
.section-tag-num {
  position: relative;
  overflow: hidden;
}
.section-tag-num::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, var(--accent-tint, rgba(185,28,28,0.15)), transparent);
  transform: translateX(-100%);
  animation: scanLine 3.5s ease-in-out infinite;
}
[data-theme="dark"] { --accent-tint: rgba(248,113,113,0.20); }
@media (prefers-reduced-motion: reduce) {
  .section-tag-num::after { animation: none; display: none; }
}
@keyframes scanLine {
  0%, 30% { transform: translateX(-100%); }
  60%, 100% { transform: translateX(100%); }
}

/* Nav current-section indicator */
.site-nav a.is-current {
  color: var(--accent);
}
.site-nav a.is-current::after {
  content: "";
  display: block;
  height: 2px;
  background: var(--accent);
  margin-top: 2px;
  border-radius: 1px;
}

/* ============================================================
   18 · CTF / PLAYGROUND
   ============================================================ */
.ctf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.25rem;
  margin-top: 2rem;
}
.ctf {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  position: relative;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.ctf:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px -12px rgba(0,0,0,0.15);
}
.ctf-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.ctf-num {
  font-family: var(--font-mono);
  font-size: var(--step--2);
  color: var(--ink-muted);
  letter-spacing: 0.04em;
}
.ctf-diff {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 3px;
  letter-spacing: 0.08em;
  color: #fff;
  font-weight: 700;
}
.ctf-diff.sev-low  { background: #16a34a; }
.ctf-diff.sev-med  { background: #d97706; }
.ctf-diff.sev-high { background: #dc2626; }
.ctf-title {
  font-size: var(--step-1);
  margin: 0;
  flex: 1 100%;
  color: var(--ink-strong);
}
.ctf-brief {
  color: var(--ink);
  font-size: var(--step--1);
  margin: 0;
  line-height: 1.55;
}
.ctf-brief code {
  font-family: var(--font-mono);
  background: var(--bg);
  border: 1px solid var(--line);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.85em;
}
.ctf-muted { color: var(--ink-muted); font-style: italic; }
.ctf-code {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  background: var(--term-bg);
  color: var(--term-fg, #e5e7eb);
  padding: 0.85rem 1rem;
  border-radius: 6px;
  margin: 0;
  overflow-x: auto;
  line-height: 1.5;
  word-break: break-all;
  white-space: pre-wrap;
  border: 1px solid rgba(255,255,255,0.06);
}
.ctf-code .tp { color: #f472b6; }
.ctf-code .tc { color: #60a5fa; }
.ctf-code .ts { color: #34d399; }
.ctf-io {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: stretch;
}
.ctf-input {
  flex: 1 1 180px;
  min-width: 0;
  padding: 0.55rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--ink);
}
.ctf-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(185,28,28,0.12);
}
.ctf-result {
  margin: 0;
  font-family: var(--font-mono);
  font-size: var(--step--2);
  min-height: 1.4em;
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  border-left: 3px solid transparent;
  background: transparent;
  transition: background 0.2s ease;
}
.ctf-result.is-ok  {
  color: #059669;
  background: rgba(5,150,105,0.06);
  border-left-color: #059669;
}
.ctf-result.is-err {
  color: var(--accent);
  background: rgba(185,28,28,0.05);
  border-left-color: var(--accent);
}
[data-theme="dark"] .ctf-result.is-ok  { color: #4ade80; background: rgba(74,222,128,0.08); border-left-color: #4ade80; }
[data-theme="dark"] .ctf-result.is-err { color: #fca5a5; background: rgba(252,165,165,0.08); border-left-color: #fca5a5; }
.ctf-footnote {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: var(--step--2);
  margin: 2rem 0 0;
}
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ============================================================
   19 · LEARN GRID (resource cards)
   ============================================================ */
.learn-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 2rem;
}
.learn-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}
.learn-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
}
.learn-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px -12px rgba(0,0,0,0.15);
}
.learn-card:hover::before { transform: scaleX(1); }
.learn-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: var(--step--2);
}
.learn-kind { color: var(--ink-muted); }
.learn-badge {
  padding: 2px 8px;
  border-radius: 3px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.learn-title {
  font-size: var(--step-1);
  margin: 0;
  color: var(--ink-strong);
  line-height: 1.3;
}
.learn-desc {
  color: var(--ink);
  font-size: var(--step--1);
  line-height: 1.55;
  margin: 0;
}
.learn-link {
  margin-top: auto;
  font-family: var(--font-mono);
  font-size: var(--step--2);
  color: var(--accent);
}

/* ============================================================
   20 · AI × SECURITY GRID
   ============================================================ */
.ai-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 2rem;
}
.ai-card {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s ease, transform 0.2s ease;
  position: relative;
}
.ai-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.ai-tag {
  align-self: flex-start;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 3px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink-muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.ai-title {
  margin: 0;
  font-size: var(--step-1);
  color: var(--ink-strong);
  line-height: 1.3;
}
.ai-desc {
  margin: 0;
  color: var(--ink);
  font-size: var(--step--1);
  line-height: 1.55;
}
.ai-note {
  margin-top: 2rem;
  padding: 1.25rem 1.4rem;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  color: var(--ink);
  font-size: var(--step--1);
  line-height: 1.55;
}
.ai-note p { margin: 0; }
.ai-note strong { color: var(--ink-strong); }

/* ============================================================
   21 · NAV WRAP FOR EXTRA ITEMS
   ============================================================ */
.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 1.1rem;
  align-items: center;
}
@media (max-width: 900px) {
  .site-nav { gap: 0.75rem; font-size: 0.85rem; }
}

/* ============================================================
   22 · SCROLL PROGRESS BAR
   ============================================================ */
.scroll-progress {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #F87171, var(--accent));
  transform: scaleX(0);
  transform-origin: left;
  z-index: 100;
  pointer-events: none;
  box-shadow: 0 0 12px rgba(185,28,28,0.5);
  transition: transform 0.05s linear;
}
@media (prefers-reduced-motion: reduce) { .scroll-progress { display: none; } }

/* ============================================================
   23 · HERO TITLE ACCENT BAR + STRONGER PRESENCE
   ============================================================ */
.hero-title {
  position: relative;
  padding-left: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.hero-title-accent {
  position: absolute;
  left: 0; top: 0.15em;
  bottom: 0.15em;
  width: 4px;
  background: var(--accent);
  border-radius: 2px;
  box-shadow: 0 0 12px rgba(185,28,28,0.4);
  transform: scaleY(0);
  transform-origin: top;
  animation: heroAccentGrow 1.0s cubic-bezier(0.22,1,0.36,1) 0.2s forwards;
}
@keyframes heroAccentGrow {
  from { transform: scaleY(0); }
  to   { transform: scaleY(1); }
}
[data-theme="dark"] .hero-title-accent { box-shadow: 0 0 16px rgba(248,113,113,0.5); }
@media (prefers-reduced-motion: reduce) {
  .hero-title-accent { animation: none; transform: scaleY(1); }
}

/* ============================================================
   24 · CRT SCANLINES (Playground signature effect)
   ============================================================ */
.section-playground { position: relative; overflow: hidden; }
.scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(0,0,0,0.03) 3px,
    rgba(0,0,0,0.03) 4px
  );
  mix-blend-mode: multiply;
  animation: scanlineDrift 8s linear infinite;
}
[data-theme="dark"] .scanlines {
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(248,113,113,0.04) 3px,
    rgba(248,113,113,0.04) 4px
  );
  mix-blend-mode: screen;
}
@keyframes scanlineDrift {
  0% { background-position-y: 0; }
  100% { background-position-y: 100px; }
}
.section-playground > .wrap { position: relative; z-index: 1; }
@media (prefers-reduced-motion: reduce) { .scanlines { animation: none; opacity: 0.5; } }

/* Add a horizontal sweep line that periodically scans over Playground */
.section-playground::before {
  content: "";
  position: absolute;
  left: -10%; right: -10%;
  height: 60px;
  top: -60px;
  background: linear-gradient(to bottom,
    transparent 0%,
    rgba(185,28,28,0) 40%,
    rgba(185,28,28,0.20) 50%,
    rgba(185,28,28,0) 60%,
    transparent 100%);
  pointer-events: none;
  z-index: 0;
  animation: sweepDown 6s linear infinite;
}
[data-theme="dark"] .section-playground::before {
  background: linear-gradient(to bottom,
    transparent 0%,
    rgba(248,113,113,0) 40%,
    rgba(248,113,113,0.16) 50%,
    rgba(248,113,113,0) 60%,
    transparent 100%);
}
@keyframes sweepDown {
  0% { transform: translateY(0); }
  100% { transform: translateY(calc(100vh + 100px)); }
}
@media (prefers-reduced-motion: reduce) { .section-playground::before { display: none; } }

/* ============================================================
   25 · PARTICLE NETWORK CANVAS (AI section signature)
   ============================================================ */
.section-ai { position: relative; overflow: hidden; }
.particles-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 0.55;
}
[data-theme="dark"] .particles-canvas { opacity: 0.75; }
.section-ai > .wrap { position: relative; z-index: 1; }
@media (prefers-reduced-motion: reduce) { .particles-canvas { display: none; } }

/* ============================================================
   26 · 3D TILT — smoother transition
   ============================================================ */
.cred, .ai-card {
  transition: transform 0.15s ease-out, border-color 0.2s ease, box-shadow 0.2s ease;
  transform-style: preserve-3d;
  will-change: transform;
}

/* ============================================================
   27 · MOUSE-TRACKED GLOW ON LEARN CARDS
   ============================================================ */
.learn-card {
  --gx: 50%;
  --gy: 50%;
  position: relative;
  isolation: isolate;
}
.learn-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 8px;
  background: radial-gradient(
    circle 180px at var(--gx) var(--gy),
    rgba(185,28,28,0.12),
    transparent 70%
  );
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  z-index: -1;
}
[data-theme="dark"] .learn-card::after {
  background: radial-gradient(
    circle 180px at var(--gx) var(--gy),
    rgba(248,113,113,0.18),
    transparent 70%
  );
}
.learn-card:hover::after { opacity: 1; }

/* ============================================================
   28 · BOOSTED MATRIX RAIN VISIBILITY
   ============================================================ */
.matrix-canvas { opacity: 0.14 !important; }
[data-theme="dark"] .matrix-canvas { opacity: 0.20 !important; }

/* ============================================================
   29 · SECTION TITLES — heavier presence
   ============================================================ */
.section-title {
  font-weight: 800;
  letter-spacing: -0.02em;
}

/* ============================================================
   30 · NAV — never wrap, keep tight
   ============================================================ */
.site-nav {
  flex-wrap: nowrap;
}
.site-nav a { white-space: nowrap; }
@media (max-width: 1100px) {
  .site-nav { gap: 0.8rem; font-size: 0.87rem; }
}
@media (max-width: 900px) {
  .site-nav { flex-wrap: wrap; }
}

/* ============================================================
   31 · METRIC VALUES — a bit larger, tabular numbers
   ============================================================ */
.metric-value {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* ============================================================
   22 · SIGNATURE PER-SECTION EFFECTS
   ============================================================ */

/* -------- Matrix scan line (Practice matrix table) -------- */
.matrix-wrap { position: relative; overflow: hidden; }
.matrix-scan {
  position: absolute;
  left: 0; right: 0; top: -8px;
  height: 3px;
  background: linear-gradient(90deg,
    transparent,
    var(--accent) 40%,
    var(--accent) 60%,
    transparent);
  box-shadow: 0 0 12px var(--accent), 0 0 32px rgba(185,28,28,0.35);
  opacity: 0;
  z-index: 3;
  pointer-events: none;
}
.matrix-scan.is-scanning {
  animation: matrixScanSweep 2.2s ease-out forwards;
}
@keyframes matrixScanSweep {
  0%   { opacity: 0; top: -8px; }
  10%  { opacity: 1; }
  90%  { opacity: 1; }
  100% { opacity: 0; top: 100%; }
}
[data-theme="dark"] .matrix-scan {
  box-shadow: 0 0 14px var(--accent), 0 0 40px rgba(248,113,113,0.5);
}

/* -------- Credential shine sweep on scroll into view -------- */
.cred {
  position: relative;
  overflow: hidden;
}
.cred::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  left: -60%;
  width: 40%;
  background: linear-gradient(105deg,
    transparent 0%,
    transparent 40%,
    rgba(255,255,255,0.35) 50%,
    transparent 60%,
    transparent 100%);
  transform: skewX(-18deg);
  pointer-events: none;
  opacity: 0;
}
[data-theme="dark"] .cred::after {
  background: linear-gradient(105deg,
    transparent 0%,
    transparent 40%,
    rgba(248,113,113,0.20) 50%,
    transparent 60%,
    transparent 100%);
}
.cred.is-shining::after {
  opacity: 1;
  animation: credShine 1.15s ease-out forwards;
}
@keyframes credShine {
  from { left: -60%; }
  to   { left: 120%; }
}

/* -------- Hero title glitch (on hover) -------- */
.hero-title.is-glitching {
  animation: heroGlitch 0.5s steps(6) 1;
  text-shadow:
    2px 0 var(--accent),
    -2px 0 #22d3ee;
}
@keyframes heroGlitch {
  0%   { transform: translate(0, 0); }
  15%  { transform: translate(-2px, 1px); text-shadow: 2px 0 var(--accent), -2px 0 #22d3ee; }
  30%  { transform: translate(2px, -1px); text-shadow: -2px 0 var(--accent), 2px 0 #22d3ee; }
  45%  { transform: translate(-1px, 1px); text-shadow: 2px 0 var(--accent), -2px 0 #22d3ee; }
  60%  { transform: translate(1px, 0); }
  75%  { transform: translate(-2px, -1px); text-shadow: -2px 0 var(--accent), 2px 0 #22d3ee; }
  100% { transform: translate(0, 0); text-shadow: none; }
}

/* -------- Toolchain tool-name shuffle target (font stability) -------- */
#toolGrid .tool-name {
  display: inline-block;
  min-width: 3ch;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  transition: color 0.2s ease;
}
#toolGrid .tool:hover .tool-name {
  color: var(--accent);
}

/* -------- CTF card CRT scanline overlay -------- */
.ctf {
  overflow: hidden;
}
.ctf::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(0,0,0,0) 0px,
    rgba(0,0,0,0) 2px,
    rgba(0,0,0,0.015) 2px,
    rgba(0,0,0,0.015) 3px
  );
  opacity: 0.4;
  border-radius: inherit;
  z-index: 1;
}
[data-theme="dark"] .ctf::before {
  background: repeating-linear-gradient(
    0deg,
    rgba(255,255,255,0) 0px,
    rgba(255,255,255,0) 2px,
    rgba(255,255,255,0.02) 2px,
    rgba(255,255,255,0.02) 3px
  );
}
.ctf > * { position: relative; z-index: 2; }

/* -------- Contact form field neon focus glow -------- */
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow:
    0 0 0 3px rgba(185,28,28,0.12),
    0 0 22px rgba(185,28,28,0.10);
}
[data-theme="dark"] .form-field input:focus,
[data-theme="dark"] .form-field select:focus,
[data-theme="dark"] .form-field textarea:focus {
  box-shadow:
    0 0 0 3px rgba(248,113,113,0.18),
    0 0 28px rgba(248,113,113,0.20);
}

/* -------- Magnetic primary buttons smooth transform -------- */
.btn-primary {
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1),
              background 0.2s ease, color 0.2s ease;
  will-change: transform;
}

/* -------- Site-wide smooth scroll fallback -------- */
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* -------- Nav item stability (prevent wrap of "AI Security") -------- */
.site-nav a { white-space: nowrap; }

/* ============================================================
   31a · SUB-SECTION HEADINGS (within a section)
   ============================================================ */
.sub-title {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: var(--step-2);
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--ink-strong);
  margin: 3rem 0 0.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}
.sub-title + .section-lead { margin-bottom: 1.5rem; }

/* ============================================================
   31b · PERSONAL PROJECTS
   ============================================================ */

/* ---- Flagship card ---- */
.proj-feature {
  margin-top: 2rem;
  padding: clamp(1.25rem, 3vw, 2rem);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  border-left: 3px solid var(--accent);
  position: relative;
}
.proj-feature-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-mono);
  font-size: var(--step--2);
  margin-bottom: 0.6rem;
}
.proj-feature-title {
  font-size: clamp(1.375rem, 3.2vw, var(--step-3));
  line-height: 1.2;
  margin: 0 0 0.75rem;
  color: var(--ink-strong);
  letter-spacing: -0.015em;
}
.proj-feature-lead {
  margin: 0 0 1.75rem;
  color: var(--ink-muted);
  font-size: var(--step-0);
  line-height: 1.6;
  max-width: 68ch;
}
.proj-feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: 1.5rem 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}
.proj-col-title {
  font-family: var(--font-mono);
  font-size: var(--step--2);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-subtle);
  margin: 0 0 0.75rem;
}
.proj-points {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}
.proj-points li {
  position: relative;
  padding-left: 1.1rem;
  font-size: var(--step--1);
  line-height: 1.55;
  color: var(--ink);
}
.proj-points li::before {
  content: "\25B8";
  position: absolute;
  left: 0;
  top: -0.05em;
  color: var(--accent);
}

/* ---- Tool cards ---- */
.proj-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  gap: 1rem;
  margin-top: 1.25rem;
}
.proj-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.proj-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.3s ease;
}
.proj-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px -12px rgba(0,0,0,0.15);
}
.proj-card:hover::before { transform: scaleX(1); }

.proj-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-mono);
  font-size: var(--step--2);
}
.proj-kind { color: var(--ink-muted); }
.proj-badge {
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 3px;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.proj-badge.is-flagship {
  border-color: var(--accent);
  color: var(--accent);
}
.proj-title {
  font-size: var(--step-1);
  margin: 0;
  color: var(--ink-strong);
  line-height: 1.3;
}
.proj-desc {
  margin: 0;
  color: var(--ink);
  font-size: var(--step--1);
  line-height: 1.55;
}
.proj-desc code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  overflow-wrap: anywhere;
}

/* ---- Capability chips ---- */
.proj-subhead {
  font-size: 1.4rem;
  margin: 2.8rem 0 0.4rem;
}
.proj-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.1rem;
  margin-top: 0.9rem;
}
.proj-repo {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  padding-bottom: 1px;
}
.proj-repo:hover { opacity: 0.75; }
.proj-stack {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: auto 0 0;
  padding: 0;
}
.proj-feature .proj-stack { margin-top: 1.5rem; }
.proj-stack li {
  font-family: var(--font-mono);
  font-size: var(--step--2);
  color: var(--ink-muted);
  padding: 3px 8px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--bg);
}

@media (prefers-reduced-motion: reduce) {
  .proj-card { transition: none; }
  .proj-card:hover { transform: none; }
}

/* ============================================================
   32 · MOBILE FIT — stop horizontal overflow / auto-zoom-out
   ------------------------------------------------------------
   Root cause: grid & flex children default to min-width:auto, so
   the non-wrapping <pre class="terminal-body"> (≈73 mono chars)
   set a ~580px min-content floor on the hero grid track. That
   floor is wider than a phone viewport, so the whole page became
   horizontally scrollable and mobile browsers zoomed out to fit.
   ============================================================ */

/* 1 · Let layout children shrink below their content width.
       Scoped with `*` (specificity 0,0,1) so any real class-based
       min-width — e.g. .theme-toggle — still wins. */
main *,
.site-footer * { min-width: 0; }

/* 2 · Long unbreakable strings (URLs, emails, hashes) wrap. */
body { overflow-wrap: break-word; }

/* 3 · Terminal keeps its column alignment and scrolls inside
       itself instead of stretching the page. */
.terminal,
.terminal-chrome,
.terminal-body { max-width: 100%; }
.terminal-body {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
.terminal-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 4 · Practice matrix scrolls as a table, not as the page. */
.matrix-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* 5 · Media and canvases never exceed the viewport. */
img, svg, video, canvas, iframe, table, pre { max-width: 100%; }

/* ---------- Phones ---------- */
@media (max-width: 700px) {
  .terminal-body { font-size: 11px; padding: 14px 14px 18px; line-height: 1.6; }
  .terminal-note { text-align: left; }
  .hero-metrics { gap: 0.25rem 0; }
  .metric { padding: 0 0.5rem; }
}

/* ---------- Small phones: header must not overflow ---------- */
@media (max-width: 560px) {
  .header-inner { gap: 0.75rem; flex-wrap: wrap; row-gap: 0.5rem; }
  .header-actions { gap: 0.5rem; margin-left: auto; }
  .btn-small { padding: 6px 10px; }
}

/* 7 · auto-fit grids: the track floor must never exceed the
       viewport, or the grid pushes the page wide on small phones. */
.also-grid  { grid-template-columns: repeat(auto-fit,  minmax(min(240px, 100%), 1fr)); }
.cred-grid  { grid-template-columns: repeat(auto-fit,  minmax(min(280px, 100%), 1fr)); }
.ctf-grid   { grid-template-columns: repeat(auto-fit,  minmax(min(320px, 100%), 1fr)); }
.learn-grid { grid-template-columns: repeat(auto-fit,  minmax(min(280px, 100%), 1fr)); }
.ai-grid    { grid-template-columns: repeat(auto-fit,  minmax(min(280px, 100%), 1fr)); }
.tool-grid  { grid-template-columns: repeat(auto-fill, minmax(min(190px, 100%), 1fr)); }

/* 6 · Safety net. `clip` (not `hidden`) so the sticky header
       and scroll-linked effects keep working. */
html { overflow-x: clip; }
body { overflow-x: clip; max-width: 100%; }

/* 8 · Restore the sticky header. Section 15's
       `.site-header, main, .site-footer { position: relative; }`
       silently overrode `position: sticky` from section 4. */
.site-header { position: sticky; top: 0; z-index: 30; }

/* 9 · Header on phones: the 8-item nav was wrapping to 2–3 rows and
       eating the top third of the screen. Keep every link reachable
       as one edge-to-edge, horizontally scrollable row instead. */
/* The header wrap caps at 1180px on every viewport, so the brand row,
   11 nav links and 3 action controls never fit one row. The nav always
   gets its own horizontally-scrollable row: works at any aspect ratio,
   touch-friendly, and the hamburger (<=860px) still collapses it. */
.header-inner {
  flex-wrap: wrap;
  gap: 0.6rem 0.75rem;
  padding-top: 0.7rem;
  padding-bottom: 0.55rem;
}
.brand { flex: 0 1 auto; min-width: 0; }
.header-actions { flex: 0 0 auto; margin-left: auto; }
.site-nav {
  order: 3;
  flex: 1 0 100%;
  flex-wrap: nowrap;
  gap: 1.1rem;
  margin-left: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin-inline: calc(var(--gutter) * -1);
  padding-inline: var(--gutter);
}
.site-nav a { flex: 0 0 auto; }
.site-nav::-webkit-scrollbar { display: none; }

/* 10 · Header fit after the 9th nav item ("Projects").
        .wrap caps at 1180px, so the header's usable width is the same
        on a 1280 and a 2560 monitor — the brand, 9 nav links and 3
        action controls simply do not all fit. Previously .brand could
        shrink (min-width:0) while its text was nowrap, so the name and
        role painted straight over the nav links.
        Fix: brand never shrinks, its box clips, and the role line —
        already repeated in the hero and the footer — comes out. */
.brand { flex: 0 0 auto; }
.brand-text { overflow: hidden; }
.brand-name { white-space: nowrap; }
.brand-role { display: none; }
.site-nav { min-width: 0; gap: 1rem; }

/* 11 · Very small screens: fit brand + actions on one row so the
        header costs two rows, not three. */
@media (max-width: 480px) {
  .header-inner { gap: 0.5rem 0.5rem; }
  .header-actions { gap: 0.4rem; }
  .theme-toggle { min-width: 0; padding: 5px 8px; gap: 6px; }
  .btn-small { padding: 5px 9px; font-size: 0.78rem; }
  .brand-mark { padding: 5px 7px; }
  /* fx is a niche control — the state dot carries it, the aria-label
     still names it for assistive tech. Buys back a header row. */
  .fx-label { display: none; }
  .fx-toggle { padding: 5px 8px; }
}


/* ==========================================================.fold-kbd { font-family: var(--font-mono); background: var(--surface-alt); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }

==
   18 · PIPELINE DIAGRAMS (automation page) — transform/opacity only
   ============================================================ */
.pipe {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 1.25rem 0 0;
}
.pipe-node {
  flex: 1 1 0;
  min-width: min(120px, 100%);
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.6rem 0.7rem;
  font-size: var(--step--1);
  line-height: 1.4;
}
.pipe-node strong { display: block; font-size: var(--step-0); }
.pipe-node .pipe-tool { font-family: var(--font-mono); color: var(--ink-muted); font-size: 0.75rem; }
.pipe-node.is-gate { border-color: var(--sev-med); }
.pipe-link {
  position: relative;
  flex: 0 0 44px;
  min-height: 44px;
  align-self: center;
  overflow: hidden;
}
.pipe-link::before {
  content: "";
  position: absolute; left: 0; right: 0; top: 50%;
  height: 2px; margin-top: -1px;
  background: var(--line-strong);
}
.pipe-link::after {
  content: "";
  position: absolute; top: 50%; left: 0;
  width: 8px; height: 8px; margin: -4px 0 0;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
}
.pipe.is-live .pipe-link::after { animation: pipe-dot 1.8s linear infinite; }
@keyframes pipe-dot {
  0%   { transform: translateX(-10px); opacity: 0; }
  15%  { opacity: 1; }
  85%  { opacity: 1; }
  100% { transform: translateX(48px); opacity: 0; }
}
.pipe-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: clamp(1.1rem, 3vw, 1.9rem);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.pipe-card:hover { transform: translateY(-3px); box-shadow: 0 10px 28px rgba(0,0,0,0.08); }
.pipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr));
  gap: clamp(1.25rem, 3vw, 2rem);
  margin-top: 2rem;
}
.pipe-card h3 { margin: 0 0 0.4rem; font-size: var(--step-2); }
.pipe-kind {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--ink-muted);
  display: block;
  margin-bottom: 0.75rem;
}
.pipe-card p { margin: 0.6rem 0; }
.gate-note {
  margin-top: 0.9rem;
  border: 1px dashed var(--sev-med);
  border-radius: var(--radius);
  padding: 0.55rem 0.8rem;
  font-size: var(--step--1);
  color: var(--ink-muted);
}
.gate-note strong { color: var(--sev-med); }
.principles {
  margin-top: clamp(2rem, 5vw, 3.5rem);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: clamp(1.25rem, 4vw, 2.25rem);
  background: var(--surface);
}
.principles h3 { margin-top: 0; }
.principles ul { margin: 0.75rem 0 0; padding-left: 1.25rem; display: grid; gap: 0.5rem; }

.breadcrumb {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--ink-muted);
  margin: 0 0 1.25rem;
}
.breadcrumb a { color: inherit; }
.page-hero { padding-top: clamp(2.5rem, 6vw, 4.5rem); }

/* ============================================================
   19 · MATRIX UNIVERSE page
   ============================================================ */
.matrix-page { background: #000; color: #d7ffe0; min-height: 100vh; }
.matrix-page .mx-rain {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  z-index: 0; pointer-events: none;
}
.matrix-page .mx-vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(0,0,0,0.55) 100%);
}
.matrix-page .site-header { background: rgba(0,0,0,0.65); }
.matrix-page .site-header a, .matrix-page .brand-name { color: #d7ffe0; }
.mx-gate {
  position: fixed; inset: 0; z-index: 40;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1.5rem; text-align: center;
  background: rgba(0,0,0,0.78);
  transition: opacity 600ms var(--ease);
  padding: 1.5rem;
}
.mx-gate.is-open { opacity: 0; pointer-events: none; }
.mx-gate h1 {
  font-family: var(--font-mono);
  font-size: clamp(1.4rem, 5vw, 2.6rem);
  color: #58c47a;
  margin: 0;
  letter-spacing: 0.06em;
}
.mx-gate p { color: #9fd8ae; max-width: 46ch; margin: 0; }
.mx-jackin {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  color: #000; background: #58c47a;
  border: 0; border-radius: 4px;
  padding: 1rem 2.4rem;
  min-height: 48px;
  letter-spacing: 0.1em;
}
.mx-jackin:hover { background: #7be495; }
.mx-term-wrap {
  position: relative; z-index: 10;
  min-height: calc(100vh - 60px);
  display: flex; align-items: flex-end;
  padding: clamp(1rem, 4vw, 3rem);
}
.mx-term {
  width: min(760px, 100%);
  background: rgba(0, 8, 4, 0.86);
  border: 1px solid #1e7a3a;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: clamp(0.8rem, 2.4vw, 0.95rem);
  color: #b8f5c8;
  box-shadow: 0 0 60px rgba(40, 160, 80, 0.25);
}
.mx-term-head {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid #1e7a3a;
  color: #58c47a;
}
.mx-term-body {
  padding: 1rem;
  height: min(46vh, 420px);
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
form.mx-term-row { margin: 0; }
.mx-term-row { display: flex; gap: 0.6rem; align-items: baseline; padding: 0 1rem 1rem; }
.mx-home-link { color: #7be495; }
.mx-bluepill { color: #9fd8ae; }
.mx-prompt { color: #58c47a; flex: 0 0 auto; }
.mx-input {
  flex: 1 1 auto; min-width: 0;
  background: transparent; border: 0; outline: none;
  color: #eafff0; font: inherit; font-size: 16px; /* >=16px stops iOS auto-zoom */
  min-height: 44px;
}
.mx-exit {
  position: fixed; top: 0.9rem; right: 1rem; z-index: 50;
  font-family: var(--font-mono); font-size: var(--step--1);
  color: #58c47a; background: rgba(0,0,0,0.7);
  border: 1px solid #1e7a3a; border-radius: 4px;
  padding: 0.6rem 1rem; min-height: 44px; text-decoration: none;
}
.mx-fallback {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: #000; color: #b8f5c8; padding: 2rem; text-align: center;
}
@media (prefers-reduced-motion: reduce) {
  .matrix-page .mx-rain { display: none; }
  .matrix-page { background-image: radial-gradient(circle at 50% 30%, #06210f 0%, #000 70%); }
}

/* ============================================================
   20 · HAMBURGER NAV (narrow screens)
   ============================================================ */
.nav-toggle {
  display: none;
  align-items: center; justify-content: center;
  width: 44px; height: 44px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.nav-toggle span { position: relative; width: 20px; height: 2px; background: var(--ink); display: block; }
.nav-toggle span::before, .nav-toggle span::after {
  content: ""; position: absolute; left: 0; width: 20px; height: 2px; background: var(--ink);
  transition: transform var(--dur) var(--ease);
}
.nav-toggle span::before { top: -6px; }
.nav-toggle span::after { top: 6px; }
.nav-toggle[aria-expanded="true"] span { background: transparent; }
.nav-toggle[aria-expanded="true"] span::before { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span::after { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; }
  .site-nav {
    display: none;
    position: absolute;
    top: 100%; left: 0; right: 0;
    flex-direction: column;
    gap: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--line-strong);
    padding: 0.5rem var(--gutter) 1rem;
    order: 0; flex: 0 0 auto; margin: 0;
    overflow: visible;
  }
  .site-nav.is-open { display: flex; }
  .site-nav a {
    padding: 0.8rem 0.2rem;
    min-height: 44px;
    display: flex; align-items: center;
    border-bottom: 1px solid var(--line);
    flex: none;
  }
  .site-header { position: sticky; }
  .header-inner { position: relative; }
}

/* ============================================================
   21 · VEIL, BACK-TO-TOP, REVEAL STAGGER, FLUID TYPE
   ============================================================ */
#veil {
  position: fixed; inset: 0; z-index: 2000;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 500ms var(--ease);
}
#veil .veil-mark {
  font-family: var(--font-mono); color: var(--ink-muted);
  font-size: var(--step-1); letter-spacing: 0.2em;
}
body.is-loaded #veil { opacity: 0; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { #veil { display: none; } }

#toTop {
  position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 500;
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 1.25rem;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transform: translateY(12px);
  pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
#toTop.is-visible { opacity: 1; transform: none; pointer-events: auto; }
#toTop:hover { border-color: var(--accent); color: var(--accent); }

.will-reveal { transition-delay: var(--reveal-delay, 0ms); }

.hero-title { font-size: clamp(2.3rem, 1.6rem + 4.5vw, 3.75rem); }
.section-title { font-size: clamp(1.55rem, 1.2rem + 2.6vw, 2.4rem); }
.hero-lead, .section-lead { font-size: clamp(1rem, 0.92rem + 0.8vw, 1.125rem); }

/* ============================================================
   22 · PROJECT CARD HOVER LIFT (adds to existing tilt)
   ============================================================ */
.proj-card, .learn-card {
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.proj-card:hover, .learn-card:hover { transform: translateY(-4px); }

/* ============================================================
   23 · PRINT — hide interactive-only elements
   ============================================================ */
@media print {
  #veil, #toTop, .nav-toggle, .mx-gate, .mx-rain,
  .pipe-link::after, .scroll-progress, .fx-toggle { display: none !important; }
  .principles { border: 1px solid #000; }
}

/* ============================================================
   18 · PIPELINE DIAGRAMS (automation page) — transform/opacity only
   ============================================================ */
.pipe {
  display: flex;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 1.25rem 0 0;
}
.pipe-node {
  flex: 1 1 0;
  min-width: min(120px, 100%);
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.6rem 0.7rem;
  font-size: var(--step--1);
  line-height: 1.4;
}
.pipe-node strong { display: block; font-size: var(--step-0); }
.pipe-node .pipe-tool { font-family: var(--font-mono); color: var(--ink-muted); font-size: 0.75rem; }
.pipe-node.is-gate { border-color: var(--sev-med); }
.pipe-link {
  position: relative;
  flex: 0 0 44px;
  min-height: 44px;
  align-self: center;
  overflow: hidden;
}
.pipe-link::before {
  content: "";
  position: absolute; left: 0; right: 0; top: 50%;
  height: 2px; margin-top: -1px;
  background: var(--line-strong);
}
.pipe-link::after {
  content: "";
  position: absolute; top: 50%; left: 0;
  width: 8px; height: 8px; margin: -4px 0 0;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
}
.pipe.is-live .pipe-link::after { animation: pipe-dot 1.8s linear infinite; }
@keyframes pipe-dot {
  0%   { transform: translateX(-10px); opacity: 0; }
  15%  { opacity: 1; }
  85%  { opacity: 1; }
  100% { transform: translateX(48px); opacity: 0; }
}
.pipe-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  padding: clamp(1.1rem, 3vw, 1.9rem);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.pipe-card:hover { transform: translateY(-3px); box-shadow: 0 10px 28px rgba(0,0,0,0.08); }
.pipe-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr));
  gap: clamp(1.25rem, 3vw, 2rem);
  margin-top: 2rem;
}
.pipe-card h3 { margin: 0 0 0.4rem; font-size: var(--step-2); }
.pipe-kind {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--ink-muted);
  display: block;
  margin-bottom: 0.75rem;
}
.pipe-card p { margin: 0.6rem 0; }
.gate-note {
  margin-top: 0.9rem;
  border: 1px dashed var(--sev-med);
  border-radius: var(--radius);
  padding: 0.55rem 0.8rem;
  font-size: var(--step--1);
  color: var(--ink-muted);
}
.gate-note strong { color: var(--sev-med); }
.principles {
  margin-top: clamp(2rem, 5vw, 3.5rem);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: clamp(1.25rem, 4vw, 2.25rem);
  background: var(--surface);
}
.principles h3 { margin-top: 0; }
.principles ul { margin: 0.75rem 0 0; padding-left: 1.25rem; display: grid; gap: 0.5rem; }

.breadcrumb {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--ink-muted);
  margin: 0 0 1.25rem;
}
.breadcrumb a { color: inherit; }
.page-hero { padding-top: clamp(2.5rem, 6vw, 4.5rem); }

/* ============================================================
   19 · MATRIX UNIVERSE page
   ============================================================ */
.matrix-page { background: #000; color: #d7ffe0; min-height: 100vh; }
.matrix-page .mx-rain {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  z-index: 0; pointer-events: none;
}
.matrix-page .mx-vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(0,0,0,0.55) 100%);
}
.matrix-page .site-header { background: rgba(0,0,0,0.65); }
.matrix-page .site-header a, .matrix-page .brand-name { color: #d7ffe0; }
.mx-gate {
  position: fixed; inset: 0; z-index: 40;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1.5rem; text-align: center;
  background: rgba(0,0,0,0.78);
  transition: opacity 600ms var(--ease);
  padding: 1.5rem;
}
.mx-gate.is-open { opacity: 0; pointer-events: none; }
.mx-gate h1 {
  font-family: var(--font-mono);
  font-size: clamp(1.4rem, 5vw, 2.6rem);
  color: #58c47a;
  margin: 0;
  letter-spacing: 0.06em;
}
.mx-gate p { color: #9fd8ae; max-width: 46ch; margin: 0; }
.mx-jackin {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  color: #000; background: #58c47a;
  border: 0; border-radius: 4px;
  padding: 1rem 2.4rem;
  min-height: 48px;
  letter-spacing: 0.1em;
}
.mx-jackin:hover { background: #7be495; }
.mx-term-wrap {
  position: relative; z-index: 10;
  min-height: calc(100vh - 60px);
  display: flex; align-items: flex-end;
  padding: clamp(1rem, 4vw, 3rem);
}
.mx-term {
  width: min(760px, 100%);
  background: rgba(0, 8, 4, 0.86);
  border: 1px solid #1e7a3a;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: clamp(0.8rem, 2.4vw, 0.95rem);
  color: #b8f5c8;
  box-shadow: 0 0 60px rgba(40, 160, 80, 0.25);
}
.mx-term-head {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 1rem;
  border-bottom: 1px solid #1e7a3a;
  color: #58c47a;
}
.mx-term-body {
  padding: 1rem;
  height: min(46vh, 420px);
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
form.mx-term-row { margin: 0; }
.mx-term-row { display: flex; gap: 0.6rem; align-items: baseline; padding: 0 1rem 1rem; }
.mx-prompt { color: #58c47a; flex: 0 0 auto; }
.mx-input {
  flex: 1 1 auto; min-width: 0;
  background: transparent; border: 0; outline: none;
  color: #eafff0; font: inherit; font-size: 16px; /* >=16px stops iOS auto-zoom */
  min-height: 44px;
}
.mx-exit {
  position: fixed; top: 0.9rem; right: 1rem; z-index: 50;
  font-family: var(--font-mono); font-size: var(--step--1);
  color: #58c47a; background: rgba(0,0,0,0.7);
  border: 1px solid #1e7a3a; border-radius: 4px;
  padding: 0.6rem 1rem; min-height: 44px; text-decoration: none;
}
.mx-fallback {
  position: fixed; inset: 0; z-index: 60;
  display: flex; align-items: center; justify-content: center;
  background: #000; color: #b8f5c8; padding: 2rem; text-align: center;
}
@media (prefers-reduced-motion: reduce) {
  .matrix-page .mx-rain { display: none; }
  .matrix-page { background-image: radial-gradient(circle at 50% 30%, #06210f 0%, #000 70%); }
}

/* ============================================================
   20 · HAMBURGER NAV (narrow screens)
   ============================================================ */
.nav-toggle {
  display: none;
  align-items: center; justify-content: center;
  width: 44px; height: 44px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.nav-toggle span { position: relative; width: 20px; height: 2px; background: var(--ink); display: block; }
.nav-toggle span::before, .nav-toggle span::after {
  content: ""; position: absolute; left: 0; width: 20px; height: 2px; background: var(--ink);
  transition: transform var(--dur) var(--ease);
}
.nav-toggle span::before { top: -6px; }
.nav-toggle span::after { top: 6px; }
.nav-toggle[aria-expanded="true"] span { background: transparent; }
.nav-toggle[aria-expanded="true"] span::before { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span::after { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 860px) {
  .nav-toggle { display: inline-flex; }
  .site-nav {
    display: none;
    position: absolute;
    top: 100%; left: 0; right: 0;
    flex-direction: column;
    gap: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--line-strong);
    padding: 0.5rem var(--gutter) 1rem;
    order: 0; flex: 0 0 auto; margin: 0;
    overflow: visible;
  }
  .site-nav.is-open { display: flex; }
  .site-nav a {
    padding: 0.8rem 0.2rem;
    min-height: 44px;
    display: flex; align-items: center;
    border-bottom: 1px solid var(--line);
    flex: none;
  }
  .header-inner { position: relative; }
}

/* ============================================================
   21 · VEIL, BACK-TO-TOP, REVEAL STAGGER, FLUID TYPE
   ============================================================ */
#veil {
  position: fixed; inset: 0; z-index: 2000;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 500ms var(--ease);
}
#veil .veil-mark {
  font-family: var(--font-mono); color: var(--ink-muted);
  font-size: var(--step-1); letter-spacing: 0.2em;
}
body.is-loaded #veil { opacity: 0; pointer-events: none; }
@media (prefers-reduced-motion: reduce) { #veil { display: none; } }

#toTop {
  position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 500;
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 1.25rem;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transform: translateY(12px);
  pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
#toTop.is-visible { opacity: 1; transform: none; pointer-events: auto; }
#toTop:hover { border-color: var(--accent); color: var(--accent); }

.will-reveal { transition-delay: var(--reveal-delay, 0ms); }

.hero-title { font-size: clamp(2.3rem, 1.6rem + 4.5vw, 3.75rem); }
.section-title { font-size: clamp(1.55rem, 1.2rem + 2.6vw, 2.4rem); }
.hero-lead, .section-lead { font-size: clamp(1rem, 0.92rem + 0.8vw, 1.125rem); }

/* ============================================================
   22 · PROJECT CARD HOVER LIFT
   ============================================================ */
.proj-card, .learn-card {
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.proj-card:hover, .learn-card:hover { transform: translateY(-4px); }

/* ============================================================
   23 · PRINT — hide interactive-only elements
   ============================================================ */
@media print {
  #veil, #toTop, .nav-toggle, .mx-gate, .mx-rain,
  .pipe-link::after, .scroll-progress, .fx-toggle { display: none !important; }
  .principles { border: 1px solid #000; }
}

/* ============================================================
   24 · GOD MODE — availability badge, severity bars, copy-email,
   quick facts, sticky hire CTA
   ============================================================ */

/* Pulsing availability badge (hero) */
.avail-badge {
  display: inline-flex; align-items: center; gap: .55rem;
  margin: .9rem 0 0; padding: .42rem .9rem;
  border: 1px solid var(--line-strong); border-radius: 999px;
  font-family: var(--font-mono); font-size: var(--step--1);
  color: var(--ink); background: var(--surface);
}
.avail-dot {
  width: .6rem; height: .6rem; border-radius: 50%;
  background: #16A34A; flex: none;
  box-shadow: 0 0 0 0 rgba(22,163,74,.55);
  animation: avail-pulse 2.2s ease-out infinite;
}
@keyframes avail-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(22,163,74,.55); }
  70%  { box-shadow: 0 0 0 9px rgba(22,163,74,0); }
  100% { box-shadow: 0 0 0 0 rgba(22,163,74,0); }
}
@media (prefers-reduced-motion: reduce) { .avail-dot { animation: none; } }

/* Severity distribution bars (practice section) */
.sevdist { margin: 2.4rem 0 0; max-width: 640px; }
.sevdist-title {
  font-family: var(--font-mono); font-size: var(--step--1);
  color: var(--ink-muted); margin: 0 0 .9rem; text-transform: lowercase;
}
.sevdist-row {
  display: grid; grid-template-columns: 110px 1fr 56px;
  gap: .8rem; align-items: center; margin-bottom: .6rem;
}
.sevdist-label { font-size: var(--step--1); }
.sevdist-bar { display: block; height: 10px; border-radius: 999px; background: var(--line); overflow: hidden; }
.sevdist-fill { display: block; height: 100%; border-radius: 999px; }
.sevdist-fill.sev-crit { background: var(--sev-crit); }
.sevdist-fill.sev-high { background: var(--sev-high); }
.sevdist-fill.sev-medlow { background: var(--sev-med); }
/* Widths live in CSS (not inline styles) to respect the strict CSP. */
.sevdist-fill.sev-w-crit { width: 12.3%; }
.sevdist-fill.sev-w-high { width: 27.7%; }
.sevdist-fill.sev-w-medlow { width: 60%; }
.sevdist-num { font-family: var(--font-mono); font-size: var(--step--1); text-align: right; }

/* Copy-email buttons (engagement section) */
.copy-email {
  font-family: var(--font-mono); font-size: var(--step--1);
  margin-left: .6rem; padding: .2rem .55rem;
  border: 1px solid var(--line-strong); border-radius: 6px;
  background: transparent; color: var(--ink-muted); cursor: pointer;
}
.copy-email:hover { color: var(--accent); border-color: var(--accent); }
.copy-email.is-done { color: #16A34A; border-color: #16A34A; }

/* Sticky mobile hire CTA — desktop keeps the header actions */
.hire-cta {
  position: fixed; left: 50%; bottom: max(1rem, env(safe-area-inset-bottom));
  transform: translate(-50%, 90px); z-index: 500;
  padding: .8rem 2.4rem; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 600; text-decoration: none; white-space: nowrap;
  box-shadow: 0 12px 30px -10px rgba(0,0,0,.45);
  transition: transform .35s var(--ease);
}
.hire-cta.is-visible { transform: translate(-50%, 0); }
@media (min-width: 861px) { .hire-cta { display: none; } }
/* Off-screen helper for clipboard fallback — class-based for strict CSP */
.clipboard-helper { position: fixed; opacity: 0; pointer-events: none; }

@media print { .hire-cta, .avail-badge { display: none; } }

/* Konami easter egg — toast + rain overdrive */
.konami-toast {
  position: fixed; left: 50%; bottom: 2rem; z-index: 950;
  transform: translate(-50%, 16px);
  background: #111; color: #fff;
  padding: .7rem 1.2rem; border-radius: 999px;
  font-family: var(--font-mono); font-size: .85rem;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
  opacity: 0; transition: opacity .3s ease, transform .3s ease;
  pointer-events: none; white-space: nowrap;
}
.konami-toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.matrix-canvas.matrix-overdrive { filter: brightness(1.7) saturate(1.5); }
@media (prefers-reduced-motion: reduce) { .matrix-canvas.matrix-overdrive { filter: none; } }
@media print { .konami-toast { display: none; } }
