/* ===========================================================================
   Edward Vartanessian — personal site v2
   Dark-first. Vanilla CSS, no build step. Space Grotesk + Inter + system mono.
   Motion: transform/opacity only, fully gated behind prefers-reduced-motion.
   =========================================================================== */

/* Self-hosted variable fonts (latin subset) — no third-party requests. */
@font-face {
  font-family: "Space Grotesk";
  src: url("assets/fonts/space-grotesk-var-latin.woff2") format("woff2");
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  src: url("assets/fonts/inter-var-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Metric-tuned fallback so the display face doesn't jump on font swap */
@font-face {
  font-family: "Space Grotesk Fallback";
  src: local("Arial");
  size-adjust: 105%;
  ascent-override: 98%;
}

/* ----------------------------- Tokens: dark (default) -------------------- */
:root {
  --bg-0: #05060a;
  --bg-1: #0a0c13;
  --surface: #10131c;
  --surface-2: #161a26;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text-hi: #f2f4f8;
  --text: #c3c9d5;
  --text-muted: #8a93a6;
  --accent: #5b8cff;
  --accent-2: #a78bfa;
  --grad: linear-gradient(135deg, #5b8cff 0%, #7c7cff 50%, #a78bfa 100%);
  --grad-border: linear-gradient(135deg, rgba(91, 140, 255, 0.55), rgba(167, 139, 250, 0.55));
  --glow-blue: rgba(91, 140, 255, 0.22);
  --glow-purple: rgba(167, 139, 250, 0.18);
  --btn-bg: #f2f4f8;
  --btn-fg: #05060a;
  --nav-bg: rgba(5, 6, 10, 0.62);
  --grid-line: rgba(255, 255, 255, 0.045);
  --shadow-card: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 8px 32px rgba(0, 0, 0, 0.45);
  --shadow-glow: 0 0 48px -12px rgba(91, 140, 255, 0.35);
  --font-display: "Space Grotesk", "Space Grotesk Fallback", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Inter", -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --container: 72rem;
  color-scheme: dark;
}

/* ----------------------------- Tokens: light ------------------------------ */
:root[data-theme="light"] {
  --bg-0: #fafbfe;
  --bg-1: #f2f4fa;
  --surface: #ffffff;
  --surface-2: #edf0f7;
  --border: rgba(11, 18, 32, 0.1);
  --border-strong: rgba(11, 18, 32, 0.18);
  --text-hi: #0b1220;
  --text: #333d52;
  --text-muted: #5a657d;
  --accent: #2557d6;
  --accent-2: #6d28d9;
  --grad: linear-gradient(135deg, #2557d6 0%, #4f46e5 50%, #6d28d9 100%);
  --grad-border: linear-gradient(135deg, rgba(37, 87, 214, 0.45), rgba(109, 40, 217, 0.45));
  --glow-blue: rgba(37, 87, 214, 0.1);
  --glow-purple: rgba(109, 40, 217, 0.08);
  --btn-bg: #0b1220;
  --btn-fg: #ffffff;
  --nav-bg: rgba(250, 251, 254, 0.72);
  --grid-line: rgba(11, 18, 32, 0.05);
  --shadow-card: 0 1px 2px rgba(11, 18, 32, 0.06), 0 12px 32px rgba(11, 18, 32, 0.08);
  --shadow-glow: 0 12px 40px -12px rgba(37, 87, 214, 0.25);
  color-scheme: light;
}

/* ----------------------------- Type scale --------------------------------- */
:root {
  --fs-display: clamp(2.6rem, 1.2rem + 5.5vw, 4.75rem);
  --fs-h2: clamp(1.8rem, 1.1rem + 2.6vw, 2.75rem);
  --fs-h3: clamp(1.125rem, 1rem + 0.4vw, 1.3rem);
  --fs-stat: clamp(2.25rem, 1.3rem + 3.2vw, 3.5rem);
  --fs-body: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
  --fs-lead: clamp(1.1rem, 1rem + 0.6vw, 1.3rem);
  --fs-mono: 0.8125rem;
  --fs-small: 0.875rem;
}

/* ----------------------------- Base --------------------------------------- */
* { box-sizing: border-box; }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.7;
  background: var(--bg-0);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3 { font-family: var(--font-display); color: var(--text-hi); }
h2 { font-size: var(--fs-h2); font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; margin: 0 0 1rem; }
h3 { font-size: var(--fs-h3); font-weight: 500; letter-spacing: -0.01em; line-height: 1.3; margin: 0 0 0.5rem; }

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

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

::selection { background: rgba(91, 140, 255, 0.35); color: var(--text-hi); }
.gradient-text::selection { -webkit-text-fill-color: var(--text-hi); }

.container {
  max-width: var(--container);
  margin: 0 auto;
  padding-inline: clamp(1.25rem, 4vw, 2.5rem);
}

section { scroll-margin-top: 5.5rem; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}

.skip-link {
  position: fixed;
  top: 0.75rem; left: -999px;
  background: var(--btn-bg); color: var(--btn-fg);
  padding: 0.55rem 1.1rem; border-radius: 999px;
  font-weight: 600; text-decoration: none;
  z-index: 100;
}
.skip-link:focus { left: 0.75rem; }

/* Eyebrow: the mono connective tissue */
.eyebrow {
  display: block;
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin: 0 0 0.75rem;
}

/* Gradient text with graceful fallback */
.gradient-text { color: var(--accent); padding-right: 0.05em; }
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .gradient-text {
    background: var(--grad);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--text-hi);
  }
}

/* ----------------------------- Nav ---------------------------------------- */
.site-header {
  position: fixed;
  inset: 0 0 auto;
  z-index: 10;
  border-bottom: 1px solid transparent;
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

body.scrolled .site-header {
  background: var(--nav-bg);
  -webkit-backdrop-filter: blur(14px) saturate(1.4);
  backdrop-filter: blur(14px) saturate(1.4);
  border-bottom-color: var(--border);
}
@supports not (backdrop-filter: blur(1px)) {
  body.scrolled .site-header { background: var(--bg-0); }
}

.nav {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0.85rem clamp(1.25rem, 4vw, 2.5rem);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.nav-name {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-hi);
  text-decoration: none;
}

.nav-links { display: flex; align-items: center; gap: 1.4rem; font-size: 0.95rem; }

.nav-links a[data-spy] {
  position: relative;
  color: var(--text-muted);
  text-decoration: none;
  padding-block: 0.25rem;
}
.nav-links a[data-spy]::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 2px;
  background: var(--grad);
  border-radius: 2px;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.2s ease;
}
.nav-links a[data-spy]:hover,
.nav-links a[aria-current="true"] { color: var(--text-hi); }
.nav-links a[data-spy]:hover::after,
.nav-links a[aria-current="true"]::after { transform: scaleX(1); }

.theme-toggle {
  display: grid;
  place-items: center;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  width: 2.1rem;
  height: 2.1rem;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}
.theme-toggle:hover { border-color: var(--accent); color: var(--accent); }
.theme-toggle svg { grid-area: 1 / 1; transition: opacity 0.25s ease; }
/* dark shows sun (tap → light); light shows moon */
.icon-moon { opacity: 0; }
:root[data-theme="light"] .icon-sun { opacity: 0; }
:root[data-theme="light"] .icon-moon { opacity: 1; }

@media (max-width: 540px) {
  .nav-links { gap: 0.9rem; font-size: 0.88rem; }
  .nav-hide-sm { display: none; }
}

/* ----------------------------- Hero --------------------------------------- */
.hero {
  position: relative;
  min-height: min(92svh, 56rem);
  display: flex;
  align-items: center;
  overflow: hidden;
  padding-top: 5.5rem;
}

.hero-bg { position: absolute; inset: 0; pointer-events: none; }

.hero-grid {
  position: absolute;
  inset: 0 0 40% 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48'%3E%3Cpath d='M48 .5H.5V48' fill='none' stroke='%23ffffff' stroke-opacity='.05'/%3E%3C/svg%3E");
  -webkit-mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, black, transparent 72%);
  mask-image: radial-gradient(ellipse 80% 60% at 50% 0%, black, transparent 72%);
}
:root[data-theme="light"] .hero-grid {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48'%3E%3Cpath d='M48 .5H.5V48' fill='none' stroke='%230b1220' stroke-opacity='.06'/%3E%3C/svg%3E");
}

.orb { position: absolute; aspect-ratio: 1; border-radius: 50%; will-change: auto; }
.orb-a {
  width: 60vmin;
  top: -12%; left: -8%;
  background: radial-gradient(closest-side, var(--glow-blue), transparent 70%);
}
.orb-b {
  width: 48vmin;
  top: 34%; right: -6%;
  background: radial-gradient(closest-side, var(--glow-purple), transparent 70%);
}

.hero-inner { position: relative; width: 100%; }

.hero-term {
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  margin: 0 0 0.4rem;
}
.hero-term .prompt { color: var(--text-muted); }
#typed { color: var(--accent); }

.caret, .t-caret {
  display: inline-block;
  width: 0.55em;
  height: 1em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: var(--accent);
}

.hero-kicker {
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  margin: 0 0 1.25rem;
}

.hero-title {
  font-size: var(--fs-display);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.05;
  margin: 0 0 1.5rem;
  max-width: 18ch;
}

.hero-sub {
  font-size: var(--fs-lead);
  line-height: 1.6;
  color: var(--text);
  max-width: 46ch;
  margin: 0 0 0.9rem;
}
.hero-sub strong { color: var(--text-hi); font-weight: 600; }

.hero-meta { color: var(--text-muted); font-size: var(--fs-small); margin: 0 0 2rem; }

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

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.75rem 1.5rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-hi);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, color 0.16s ease;
}
.btn:hover { border-color: var(--accent); color: var(--text-hi); transform: translateY(-1px); }
.btn svg { opacity: 0.6; }

.btn-primary {
  background: var(--btn-bg);
  border-color: var(--btn-bg);
  color: var(--btn-fg);
}
.btn-primary:hover { color: var(--btn-fg); box-shadow: var(--shadow-glow); }


/* ----------------------------- Sections ----------------------------------- */
.section { padding-block: clamp(5rem, 10vw, 8.5rem); }
.section-alt { background: var(--bg-1); }

.section-head { margin-bottom: clamp(2.5rem, 5vw, 4rem); }
.section-sub { color: var(--text-muted); max-width: 60ch; margin: 0.75rem 0 0; }

/* ----------------------------- Stats --------------------------------------- */
.stats { border-block: 1px solid var(--border); background: var(--bg-1); }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  margin: 0;
  padding-block: clamp(2rem, 4vw, 3rem);
}

.stat { display: flex; flex-direction: column; padding: 0.75rem 1.5rem; }
.stat + .stat { border-left: 1px solid var(--border); }
@media (max-width: 780px) {
  .stat + .stat { border-left: none; }
  .stat { border-top: 1px solid var(--border); }
  .stats-grid > .stat:first-child { border-top: none; }
}

/* Solid numerals — the gradient is spent on the hero headline, nowhere else. */
.stat-value {
  order: 1;
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--fs-stat);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--text-hi);
}

.stat-label {
  order: 2;
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-top: 0.4rem;
}

/* ----------------------------- Cards --------------------------------------- */
.cards {
  display: grid;
  gap: 1.25rem;
}
@media (min-width: 900px) { .cards { grid-template-columns: repeat(3, 1fr); } }

.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.75rem;
  box-shadow: var(--shadow-card);
  transition: transform 0.22s ease, box-shadow 0.22s ease;
  overflow: hidden;
}
/* gradient border sheen, revealed on hover */
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: var(--grad-border);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
/* pointer spotlight */
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(240px circle at var(--mx, 50%) var(--my, 0%), rgba(91, 140, 255, 0.08), transparent 70%);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}
@media (hover: hover) and (pointer: fine) {
  .card:hover { transform: translateY(-4px); box-shadow: var(--shadow-card), var(--shadow-glow); }
  .card:hover::before, .card:hover::after { opacity: 1; }
}

.icon-chip {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--accent);
  margin-bottom: 1.1rem;
}

.card p { margin: 0; color: var(--text-muted); font-size: 0.97rem; }

/* ----------------------------- Timeline ------------------------------------ */
.timeline {
  position: relative;
  padding-left: 2rem;
}
.timeline::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 6px;
  bottom: 0;
  width: 2px;
  background: linear-gradient(180deg, #5b8cff, #a78bfa 70%, transparent);
  border-radius: 2px;
}
:root[data-theme="light"] .timeline::before {
  background: linear-gradient(180deg, #2557d6, #6d28d9 70%, transparent);
}

.job {
  position: relative;
  margin-bottom: clamp(2.5rem, 5vw, 3.5rem);
}
.job::before {
  content: "";
  position: absolute;
  left: calc(-2rem + 0px);
  top: 8px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bg-0);
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 6px rgba(91, 140, 255, 0.12);
}
.section-alt .job::before { background: var(--bg-1); }

@media (min-width: 800px) {
  .job { display: grid; grid-template-columns: 13rem 1fr; gap: 2rem; }
}

.job-company {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-hi);
  margin: 0 0 0.2rem;
}
.job-dates, .job-note {
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  color: var(--text-muted);
  margin: 0 0 0.2rem;
}

.pill-present {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  color: var(--text);
}
.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
@media (prefers-reduced-motion: no-preference) {
  .pulse-dot { animation: pulse 2s ease-in-out infinite; }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.5); opacity: 0.55; }
}

.job-body h3 { margin-top: 0; }
.job-body ul { margin: 0.6rem 0 0; padding-left: 1.2rem; }
.job-body li { margin-bottom: 0.55rem; color: var(--text-muted); }
.job-body li::marker { color: var(--accent); }
.job-body strong { color: var(--text-hi); font-weight: 600; }

.earlier {
  position: relative;
  color: var(--text-muted);
  max-width: 60ch;
  margin: 0;
  padding-top: 0.5rem;
}
.earlier .eyebrow { margin-bottom: 0.35rem; }

/* ----------------------------- Skills -------------------------------------- */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(19rem, 1fr));
  gap: 2rem 3rem;
}

.skill-group { border-top: 1px solid var(--border); padding-top: 1.25rem; }
.skill-group .eyebrow { margin-bottom: 0.9rem; }

.chips {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0;
  padding: 0;
}
.chip {
  font-size: var(--fs-small);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
}
.chip-hi {
  position: relative;
  border-color: transparent;
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    var(--grad-border) border-box;
  border: 1px solid transparent;
  color: var(--text-hi);
}

/* ----------------------------- Colophon ------------------------------------ */
.colophon-grid {
  display: grid;
  gap: 2rem;
  align-items: start;
}
@media (min-width: 960px) {
  .colophon-grid { grid-template-columns: 3fr 2fr; }
}

.diagram-wrap { margin: 0; overflow-x: auto; }
.diagram { width: 100%; height: auto; min-width: 34rem; display: block; }

.diagram rect {
  fill: var(--surface);
  stroke: var(--border-strong);
}
.d-label {
  font-family: var(--font-mono);
  font-size: 13px;
  fill: var(--text-hi);
  text-anchor: middle;
}
.d-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  fill: var(--text-muted);
  text-anchor: middle;
}
.d-edge {
  fill: none;
  stroke: var(--accent);
  stroke-opacity: 0.5;
  stroke-width: 1.5;
  stroke-dasharray: 6 10;
}
.d-you rect { stroke: var(--accent); stroke-opacity: 0.6; }
.packet { fill: var(--accent-2); opacity: 0; }

@media (prefers-reduced-motion: no-preference) {
  .diagram-live .d-edge { animation: dashflow 2.4s linear infinite; }
  .diagram-live .packet {
    opacity: 1;
    offset-path: path("M126 73 H196 M346 73 H416 M556 73 H600 Q612 73 612 85 V133");
    offset-path: path("M8 73 H600 Q612 73 612 85 V133");
    animation: packet 6s ease-in-out infinite;
  }
}
@keyframes dashflow { to { stroke-dashoffset: -32; } }
@keyframes packet {
  0% { offset-distance: 0%; opacity: 0; }
  8% { opacity: 1; }
  92% { opacity: 1; }
  100% { offset-distance: 100%; opacity: 0; }
}

.terminal {
  position: relative;
  background: var(--surface);
  border: 1px solid transparent;
  border-radius: 24px;
  overflow: hidden;
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    var(--grad-border) border-box;
  box-shadow: var(--shadow-card);
}

.terminal-bar {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.8rem 1.1rem;
  border-bottom: 1px solid var(--border);
}
.t-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); }
.t-title {
  margin-left: 0.5rem;
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  color: var(--text-muted);
}

.terminal-body {
  margin: 0;
  padding: 1.1rem 1.25rem 1.25rem;
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  line-height: 1.9;
  color: var(--text);
  overflow-x: auto;
}
.t-prompt { color: var(--text-muted); }
.t-cmd { color: var(--text-hi); font-weight: 600; }
.t-ok { color: var(--accent); }
.t-res { color: var(--accent-2); }
.t-caret { background: var(--text-muted); }

@media (prefers-reduced-motion: no-preference) {
  .caret, .t-caret { animation: blink 1.1s steps(2, start) infinite; }
  html.js .t-line { opacity: 0; transform: translateY(6px); }
  html.js .terminal.is-visible .t-line {
    opacity: 1;
    transform: none;
    transition: opacity 0.4s ease, transform 0.4s ease;
  }
  html.js .terminal.is-visible .t-line:nth-child(1) { transition-delay: 0ms; }
  html.js .terminal.is-visible .t-line:nth-child(2) { transition-delay: 60ms; }
  html.js .terminal.is-visible .t-line:nth-child(3) { transition-delay: 120ms; }
  html.js .terminal.is-visible .t-line:nth-child(4) { transition-delay: 180ms; }
  html.js .terminal.is-visible .t-line:nth-child(5) { transition-delay: 260ms; }
  html.js .terminal.is-visible .t-line:nth-child(6) { transition-delay: 340ms; }
  html.js .terminal.is-visible .t-line:nth-child(7) { transition-delay: 440ms; }
}
@keyframes blink { 50% { opacity: 0; } }
.t-line { display: inline; }
@media (prefers-reduced-motion: no-preference) { .t-line { display: inline-block; min-width: 100%; } }

/* ----------------------------- About --------------------------------------- */
.about-body { max-width: 62ch; }
.lead { font-size: var(--fs-lead); line-height: 1.6; color: var(--text); margin: 0 0 1rem; }

/* ----------------------------- Contact CTA --------------------------------- */
.cta {
  position: relative;
  text-align: center;
  padding: clamp(3rem, 8vw, 5.5rem) clamp(1.5rem, 5vw, 4rem);
  border-radius: 24px;
  background:
    radial-gradient(60% 80% at 50% 0%, rgba(91, 140, 255, 0.12), transparent 70%) var(--bg-1);
  border: 1px solid transparent;
  background-clip: padding-box, padding-box;
  overflow: hidden;
}
.cta::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: var(--grad-border);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}
:root[data-theme="light"] .cta {
  background:
    radial-gradient(60% 80% at 50% 0%, rgba(37, 87, 214, 0.07), transparent 70%) var(--bg-1);
}

.cta .eyebrow { text-transform: none; letter-spacing: 0.06em; }
.cta h2 { margin-bottom: 1.75rem; }
.cta-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem; }
.cta-slo {
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  color: var(--text-muted);
  margin: 1.5rem 0 0;
}

/* ----------------------------- Footer -------------------------------------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding-block: 2rem;
  color: var(--text-muted);
  font-size: var(--fs-small);
}
.footer-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem; }
.footer-row p { margin: 0; }
.footer-mono { font-family: var(--font-mono); font-size: var(--fs-mono); }
.footer-mono a { color: var(--text-muted); }
.footer-mono a:hover { color: var(--accent); }

/* ----------------------------- Reveal system ------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  html.js [data-reveal] {
    opacity: 0;
    transform: translateY(16px);
  }
  html.js [data-reveal].is-visible {
    opacity: 1;
    transform: none;
    transition:
      opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1),
      transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
    transition-delay: var(--reveal-delay, 0ms);
  }

  /* Hero entrance */
  .hero-term, .hero-kicker, .hero-title, .hero-sub, .hero-meta, .hero-actions {
    animation: fade-up 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
  }
  .hero-kicker { animation-delay: 60ms; }
  .hero-title { animation-delay: 120ms; }
  .hero-sub { animation-delay: 240ms; }
  .hero-meta { animation-delay: 320ms; }
  .hero-actions { animation-delay: 400ms; }

  /* Typed kicker: role line waits for typing to finish */
  html.js .hero-role { opacity: 0; transform: translateY(6px); animation: none; }
  html.js .hero.typed-done .hero-role {
    opacity: 1;
    transform: none;
    transition: opacity 0.5s ease, transform 0.5s ease;
  }
}
@keyframes fade-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: none; }
}

/* ----------------------------- Work cards as links ------------------------- */
.card-link {
  display: block;
  text-decoration: none;
  color: inherit;
}
.card-path {
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  color: var(--accent);
  margin: 0 0 0.9rem;
  word-break: break-all;
}
.card-cta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.1rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  color: var(--text-muted);
}
.card-cta .cta-read { color: var(--text-hi); white-space: nowrap; }
.card-link:hover .cta-read { color: var(--accent); }

/* ----------------------------- Case-study pages ---------------------------- */
.cs-header { padding-top: 7.5rem; margin-bottom: clamp(2rem, 4vw, 3rem); }
.breadcrumb {
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  color: var(--text-muted);
  text-decoration: none;
}
.breadcrumb:hover { color: var(--accent); }
.cs-header .eyebrow { margin-top: 1.5rem; }
.cs-title { font-size: var(--fs-h2); font-weight: 700; letter-spacing: -0.02em; line-height: 1.12; margin: 0 0 1rem; max-width: 24ch; }
.cs-meta {
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  color: var(--text-muted);
  margin: 1rem 0 0;
}

.prose { margin-top: clamp(2rem, 4vw, 3rem); }
.prose p, .prose ul, .prose ol { max-width: 65ch; }
.prose p { color: var(--text); margin: 0 0 1.1rem; }
.prose > .eyebrow { margin-top: clamp(2.5rem, 5vw, 3.5rem); }
.prose h2 {
  font-size: clamp(1.4rem, 1.1rem + 1vw, 1.75rem);
  margin: 0 0 0.9rem;
}
.prose ul { padding-left: 1.2rem; color: var(--text); }
.prose li { margin-bottom: 0.5rem; }
.prose li::marker { color: var(--accent); }
.prose strong { color: var(--text-hi); font-weight: 600; }
.prose .lead { max-width: 58ch; }
.prose .diagram-wrap, .prose .terminal { margin-block: clamp(1.75rem, 3.5vw, 2.5rem); }
.fill-slot { background: rgba(91, 140, 255, 0.14); border-radius: 4px; padding: 0 0.25em; }

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.1em 0.35em;
  color: var(--text-hi);
}

.cs-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: clamp(3rem, 6vw, 4.5rem);
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.cs-nav a { font-family: var(--font-mono); font-size: var(--fs-mono); text-decoration: none; color: var(--text-muted); }
.cs-nav a:hover { color: var(--accent); }

/* ----------------------------- Print (case pages + resume habits) ---------- */
@media print {
  .site-header, .hero-bg, .cs-nav, .site-footer, .theme-toggle, .skip-link { display: none !important; }
  body { background: #fff; color: #111; }
  .cs-header { padding-top: 0; }
  a { color: #111; text-decoration: none; }
  .terminal, .card { border: 1px solid #ccc; box-shadow: none; }
}

/* ----------------------------- Forced colors ------------------------------- */
@media (forced-colors: active) {
  .gradient-text, .stat-value { background: none; -webkit-text-fill-color: currentColor; color: CanvasText; }
  .chip, .chip-hi, .card, .terminal { border: 1px solid CanvasText; background: Canvas; }
  .orb, .hero-grid { display: none; }
}

/* ----------------------------- Observability page --------------------------- */
.obs-updated {
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  color: var(--text-muted);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.6rem;
  margin-top: 0.35rem;
  color: var(--text);
  background: var(--surface-2);
}
.status-pill.ok { color: var(--accent); border-color: var(--accent); }
.status-pill.warn { color: #d97706; border-color: #d97706; }
:root[data-theme="light"] .status-pill.warn { color: #b45309; border-color: #b45309; }

.stat-target {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.spark-grid { display: grid; gap: 1.5rem; margin-top: 2.5rem; }
@media (min-width: 900px) { .spark-grid { grid-template-columns: 1fr 1fr; } }

.spark-figure {
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem 1.4rem;
  box-shadow: var(--shadow-card);
}
.spark-figure figcaption {
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.9rem;
}
.spark-svg { width: 100%; height: auto; display: block; }
.spark-svg .grid-line { stroke: var(--border); stroke-width: 1; }
.spark-svg .series { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark-svg .series-fill { fill: var(--accent); opacity: 0.09; }
.spark-svg .axis-label, .spark-svg .value-label {
  font-family: var(--font-mono);
  font-size: 11px;
  fill: var(--text-muted);
}
.spark-svg .value-label { fill: var(--text-hi); }
.spark-svg .hover-dot { fill: var(--accent); opacity: 0; }
.spark-svg .hover-dot.on { opacity: 1; }

.obs-tip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  padding: 0.3rem 0.6rem;
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  color: var(--text-hi);
  opacity: 0;
  transition: opacity 0.12s ease;
}
.obs-tip.on { opacity: 1; }

.spark-figure details { margin-top: 0.75rem; }
.spark-figure summary {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  cursor: pointer;
}
.spark-figure table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text);
  margin-top: 0.5rem;
}
.spark-figure td, .spark-figure th {
  text-align: left;
  padding: 0.15rem 0.5rem 0.15rem 0;
  border-bottom: 1px solid var(--border);
}

.obs-empty {
  display: none;
  font-family: var(--font-mono);
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  padding: 1.25rem;
  margin-top: 2rem;
}
body.obs-no-data .obs-empty { display: block; }

/* ----------------------------- View transitions (progressive) -------------- */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root), ::view-transition-new(root) { animation-duration: 0.22s; }
}
