/* ---------- Tokens ---------- */
:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --hover: #f3f3f1;
  --text: #15171c;
  --muted: #565c68;
  --faint: #868c97;
  --line: #e5e5e2;
  --accent: #2f5bea;
  --critical: #c4282d;
  --critical-bg: #fbeaea;
  --high: #a8510a;
  --high-bg: #fcf0e2;
  --ok: #1a7f37;

  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;
  --gutter: 24px;
  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0c0e11;
    --surface: #13161b;
    --hover: #171a20;
    --text: #e7e9ec;
    --muted: #a2a8b3;
    --faint: #6d737e;
    --line: #22262d;
    --accent: #8aa9ff;
    --critical: #ff7b7b;
    --critical-bg: rgba(255, 123, 123, 0.12);
    --high: #f4ad66;
    --high-bg: rgba(244, 173, 102, 0.12);
    --ok: #3fb950;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0c0e11;
  --surface: #13161b;
  --hover: #171a20;
  --text: #e7e9ec;
  --muted: #a2a8b3;
  --faint: #6d737e;
  --line: #22262d;
  --accent: #8aa9ff;
  --critical: #ff7b7b;
  --critical-bg: rgba(255, 123, 123, 0.12);
  --high: #f4ad66;
  --high-bg: rgba(244, 173, 102, 0.12);
  --ok: #3fb950;
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, p, ol, ul, dl, dd { margin: 0; }
ol, ul { padding: 0; list-style: none; }

a { color: inherit; text-decoration: none; }

code, .mono {
  font-family: var(--mono);
  font-size: 0.86em;
  letter-spacing: -0.01em;
}

code {
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: var(--hover);
  border: 1px solid var(--line);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.wrap {
  width: 100%;
  max-width: 1040px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: var(--gutter);
  top: 12px;
  z-index: 100;
  padding: 8px 14px;
  background: var(--text);
  color: var(--bg);
  border-radius: 6px;
}

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  -webkit-backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}
.site-header.scrolled { border-bottom-color: var(--line); }

.header-inner {
  display: flex;
  align-items: center;
  gap: 32px;
  height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  margin-right: auto;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--text);
  color: var(--bg);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.nav {
  display: flex;
  gap: 28px;
  font-size: 14px;
  color: var(--muted);
}
.nav a { transition: color 0.15s; }
.nav a:hover, .nav a.active { color: var(--text); }

.theme-toggle {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.theme-toggle:hover { color: var(--text); border-color: var(--faint); }
.theme-toggle svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* Show the icon for the theme you'd switch to */
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: block; }
  :root:not([data-theme="light"]) .icon-moon { display: none; }
}

/* ---------- Hero ---------- */
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  column-gap: 56px;
  padding-top: 112px;
  padding-bottom: 104px;
}
.hero > * { grid-column: 1; }

/* ---------- Hero art: live coverage map ---------- */
.hero-art {
  grid-column: 2;
  grid-row: 1 / span 4;
  align-self: center;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  overflow: hidden;
}
.art-bar,
.art-stat {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--faint);
  white-space: nowrap;
}
.art-bar { border-bottom: 1px solid var(--line); }
.art-stat {
  display: block;
  border-top: 1px solid var(--line);
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}
.art-hint { margin-left: auto; overflow: hidden; text-overflow: ellipsis; }
.art-live {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
  animation: live 2s ease-in-out infinite;
}
@keyframes live { 50% { opacity: 0.25; } }
.hero-art canvas {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  cursor: crosshair;
  touch-action: pan-y;
}

.eyebrow {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 24px;
}
.eyebrow span { white-space: nowrap; }

.hero h1 {
  max-width: 18ch;
  font-size: clamp(36px, 6vw, 60px);
  line-height: 1.06;
  letter-spacing: -0.035em;
  font-weight: 600;
  text-wrap: balance;
}

.lede {
  max-width: 60ch;
  margin-top: 28px;
  font-size: 18px;
  line-height: 1.65;
  color: var(--muted);
  text-wrap: pretty;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 40px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding-inline: 20px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn-primary { background: var(--text); color: var(--bg); }
.btn-primary:hover { opacity: 0.86; }
.btn-ghost { border: 1px solid var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--faint); }
.icon-fill { width: 17px; height: 17px; fill: currentColor; }

.stats {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 88px;
  border-top: 1px solid var(--line);
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 24px;
  padding-right: 24px;
}
.stat + .stat { padding-left: 24px; border-left: 1px solid var(--line); }
.stat dd {
  order: -1;
  font-size: clamp(32px, 4.4vw, 44px);
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.stat dt { font-size: 14px; color: var(--muted); }

/* ---------- Sections ---------- */
.section {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 56px;
  padding-top: 88px;
  padding-bottom: 88px;
  border-top: 1px solid var(--line);
}

.section-head {
  align-self: start;
  position: sticky;
  top: 96px;
}
.section-head h2 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.section-head p {
  margin-top: 10px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--muted);
}

/* ---------- Advisories ---------- */
.adv-list { display: grid; gap: 8px; }

.adv-group { position: relative; }
.adv-group::before {
  /* continuity line tying the related pair together, outside the cards so columns stay aligned */
  content: "";
  position: absolute;
  left: -14px;
  top: 4px;
  bottom: 0;
  width: 2px;
  border-radius: 2px;
  background: var(--critical);
  opacity: 0.5;
}
.adv-group-label {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}
.adv-group + li { margin-top: 16px; }

.adv {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.15s;
}
.adv:hover, .adv[open] { border-color: color-mix(in srgb, var(--faint) 55%, var(--line)); }

.adv summary {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr) auto 18px;
  grid-template-areas: "date main sev chev";
  align-items: center;
  gap: 20px;
  padding: 18px 20px;
  cursor: pointer;
  list-style: none;
  border-radius: var(--radius);
}
.adv summary::-webkit-details-marker { display: none; }
.adv summary:hover { background: var(--hover); }
.adv[open] summary { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }

.adv-date {
  grid-area: date;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--faint);
  white-space: nowrap;
}

.adv-main { grid-area: main; display: grid; gap: 4px; min-width: 0; }
.adv-title {
  font-size: 16px;
  font-weight: 550;
  line-height: 1.4;
  letter-spacing: -0.01em;
  text-wrap: pretty;
}
.adv-title code { font-size: 0.82em; }
.adv-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  font-size: 13.5px;
  color: var(--muted);
}
.adv-meta .mono { font-size: 12.5px; color: var(--faint); }

.sev {
  grid-area: sev;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  padding-inline: 10px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
}
.sev b { font-family: var(--mono); font-weight: 500; }
.sev-critical { color: var(--critical); background: var(--critical-bg); }
.sev-high { color: var(--high); background: var(--high-bg); }

.chev {
  grid-area: chev;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--faint);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.2s;
}
.adv[open] .chev { transform: rotate(180deg); }

.adv-body {
  padding: 4px 20px 22px calc(20px + 104px + 20px);
}
.adv-body > p {
  max-width: 62ch;
  color: var(--muted);
  font-size: 15px;
  text-wrap: pretty;
}

.facts {
  display: grid;
  gap: 10px;
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px dashed var(--line);
}
.facts > div {
  display: grid;
  grid-template-columns: 104px minmax(0, 1fr);
  gap: 16px;
  font-size: 14px;
}
.facts dt { color: var(--faint); }
.facts dd { overflow-wrap: anywhere; }
.facts dd.mono { font-size: 13px; }
.facts a { color: var(--accent); }
.facts a:hover { text-decoration: underline; }

.ext {
  display: inline-flex;
  gap: 6px;
  margin-top: 20px;
  font-size: 14px;
  font-weight: 500;
  color: var(--accent);
}
.ext:hover { text-decoration: underline; text-underline-offset: 3px; }

/* Smooth open/close where supported */
@supports (interpolate-size: allow-keywords) {
  :root { interpolate-size: allow-keywords; }
  .adv::details-content,
  .more::details-content {
    height: 0;
    overflow: clip;
    transition: height 0.25s ease, content-visibility 0.25s allow-discrete;
  }
  .adv[open]::details-content,
  .more[open]::details-content { height: auto; }
}

/* ---------- Research ---------- */
.projects { display: grid; gap: 48px; }
.project h3 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.015em;
}
.project h3 a { transition: color 0.15s; }
.project h3 a:hover { color: var(--accent); }
.project h3 span { color: var(--faint); font-weight: 400; }
.all-posts { margin-top: 40px; }
.project .post-meta {
  margin: 0 0 8px;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--faint);
}
.project p {
  max-width: 62ch;
  margin-top: 10px;
  color: var(--muted);
  text-wrap: pretty;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.tags li {
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
}

/* ---------- About ---------- */
.about-text {
  max-width: 60ch;
  font-size: 18px;
  line-height: 1.65;
  text-wrap: pretty;
}

.focus {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 32px 40px;
  margin-top: 48px;
}
.focus h3 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.focus p {
  margin-top: 6px;
  font-size: 14.5px;
  line-height: 1.55;
  color: var(--muted);
  text-wrap: pretty;
}

.timeline {
  display: grid;
  margin-top: 56px;
  border-top: 1px solid var(--line);
}
.timeline li {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 20px;
  padding-block: 20px;
  border-bottom: 1px solid var(--line);
}
.tl-when {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--faint);
  padding-top: 2px;
}
.timeline h3 { font-size: 16px; font-weight: 600; }
.timeline p { font-size: 14.5px; color: var(--muted); margin-top: 2px; }

/* ---------- Experience ---------- */
.section-body > .timeline:first-child { margin-top: 0; }

.more .timeline { margin-top: 0; border-top: 0; }
.more summary {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-block: 16px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
  list-style: none;
}
.more summary::-webkit-details-marker { display: none; }
.more summary:hover { text-decoration: underline; text-underline-offset: 3px; }
.more summary .chev { stroke: currentColor; }
.more-open { display: none; }
.more[open] .more-open { display: inline; }
.more[open] .more-closed { display: none; }
.more[open] .chev { transform: rotate(180deg); }

.sub-head {
  margin-top: 56px;
  font-size: 13px;
  font-weight: 500;
  color: var(--faint);
  font-family: var(--mono);
}
.sub-head + .timeline { margin-top: 12px; }

/* ---------- Contact ---------- */
.contact-list { border-top: 1px solid var(--line); }
.contact-list a {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  padding: 20px 4px;
  border-bottom: 1px solid var(--line);
  transition: background 0.15s, padding 0.2s;
}
.contact-list a:hover { background: var(--hover); padding-inline: 16px; }
.contact-label { font-weight: 500; }
.contact-handle { font-family: var(--mono); font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.arrow { color: var(--faint); transition: color 0.15s; }
.contact-list a:hover .arrow { color: var(--accent); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); }
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 24px;
  padding-block: 32px;
  font-size: 13px;
  color: var(--faint);
}

/* ---------- Boot screen ---------- */
.boot { display: none; }

html.booting { overflow: hidden; }
html.booting .boot {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 40px 48px;
  background: #06080a;
  color: #c4ccd5;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.75;
  text-shadow: 0 0 6px rgba(150, 200, 255, 0.22);
  cursor: default;
  user-select: none;
}

/* CRT scanlines and vignette */
.boot::before,
.boot::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.boot::before {
  background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, 0.028) 0 1px, transparent 1px 3px);
}
.boot::after {
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.55) 100%);
}

.boot-log { position: relative; white-space: pre; }
.b-line { min-height: 1.75em; animation: b-in 0.08s steps(2) both; }
.b-head { color: #8aa9ff; }
.b-dim { color: #6b7480; }
.b-ok { color: #3fb950; }
.b-name { color: #ffffff; font-weight: 500; }
.b-cursor {
  display: inline-block;
  width: 0.6em;
  height: 1.1em;
  margin-left: 4px;
  vertical-align: -0.2em;
  background: #c4ccd5;
  animation: b-blink 0.9s steps(1) infinite;
}

.boot-hint {
  position: relative;
  font-size: 12px;
  color: #4d5560;
  text-shadow: none;
}

/* Exit: old CRT power-off, collapsing to a line then a point */
.boot.boot-exit { animation: b-off 0.6s cubic-bezier(0.7, 0, 0.3, 1) forwards; }

@keyframes b-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes b-blink { 50% { opacity: 0; } }
@keyframes b-off {
  0%   { transform: scale(1, 1); filter: brightness(1); opacity: 1; }
  55%  { transform: scale(1, 0.004); filter: brightness(4); opacity: 1; }
  100% { transform: scale(0, 0.004); filter: brightness(6); opacity: 0; }
}

/* Hero settles in right after the boot screen */
html.just-booted .hero > * { animation: rise 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
html.just-booted .hero > :nth-child(1) { animation-delay: 0.25s; }
html.just-booted .hero > :nth-child(2) { animation-delay: 0.33s; }
html.just-booted .hero > :nth-child(3) { animation-delay: 0.41s; }
html.just-booted .hero > :nth-child(4) { animation-delay: 0.49s; }
html.just-booted .hero > :nth-child(5) { animation-delay: 0.57s; }
html.just-booted .hero > :nth-child(6) { animation-delay: 0.65s; }
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* Footer reboot link: replays the boot screen */
.footer-meta { display: inline-flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.reboot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.reboot:hover { color: var(--text); border-color: var(--faint); }
.reboot svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.4s;
}
.reboot:hover svg { transform: rotate(-180deg); }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .hero { grid-template-columns: minmax(0, 1fr); }
  .hero-art { grid-column: 1; grid-row: auto; margin-top: 48px; }
  .hero-art canvas { aspect-ratio: 16 / 10; }
}

@media (max-width: 900px) {
  .nav { display: none; }
}

@media (max-width: 860px) {
  .section {
    grid-template-columns: minmax(0, 1fr);
    gap: 32px;
    padding-top: 64px;
    padding-bottom: 64px;
  }
  .section-head { position: static; }
  .section-head p { max-width: 52ch; }
}

@media (max-width: 640px) {
  :root { --gutter: 16px; }


  .hero { padding-top: 64px; padding-bottom: 72px; }
  .lede { font-size: 17px; }
  .stats { margin-top: 56px; }
  .hero-art { margin-top: 40px; }
  .hero-art canvas { aspect-ratio: 4 / 3; }
  .art-hint { display: none; }
  .stat { padding-right: 12px; }
  .stat + .stat { padding-left: 12px; }
  .stat dt { font-size: 12.5px; line-height: 1.4; }

  .adv summary {
    grid-template-columns: minmax(0, 1fr) auto 18px;
    grid-template-areas:
      "date sev chev"
      "main main main";
    gap: 10px 12px;
    padding: 16px;
  }
  .adv-body { padding: 4px 16px 20px; }
  .facts > div { grid-template-columns: minmax(0, 1fr); gap: 2px; }

  .adv-group::before { left: -9px; }

  .about-text { font-size: 17px; }
  .focus { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .timeline li { grid-template-columns: minmax(0, 1fr); gap: 4px; }

  html.booting .boot { padding: 24px 16px; font-size: 11px; }

  .contact-list a { grid-template-columns: 84px minmax(0, 1fr) auto; gap: 10px; }
  .contact-label { font-size: 15px; }
  .contact-handle { font-size: 12.5px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
}

/* ---------- 404 ---------- */
.nf {
  display: grid;
  align-content: center;
  min-height: 100vh;
  min-height: 100svh;
  padding-block: 64px;
}
.nf h1 {
  max-width: 18ch;
  font-size: clamp(34px, 5.5vw, 56px);
  line-height: 1.08;
  letter-spacing: -0.035em;
  font-weight: 600;
  text-wrap: balance;
}
