/* ---------- Theme tokens ----------
   Palette: blue-grey paper (light) or blue-black (dark), ink, one steel-blue accent, and a near-black contact block shared by both themes.
   Type: Rethink Sans for headings and interface text, Vollkorn for running prose. */
:root {
  --bg: #e8eff4;               /* blue-grey */
  --bg-alt: #dfe7ee;
  --surface: #f3f7fa;
  --fg: #12171c;               /* ink */
  --muted: #4f5b66;
  --faint: #5d6873;
  --border: #d3dde6;
  --border-strong: #b4c1cd;
  --accent: #2f6690;           /* steel blue: status dot, production badge, credential labels, focus */
  --ink: #12171c;              /* primary buttons */
  --ink-hover: #27313b;
  --ink-fg: #f3f7fa;
  --pine: #0e1318;             /* contact block */
  --cta-fg: #e3eaf0;
  --cta-strong: #f3f7fa;       /* contact heading, primary button */
  --cta-muted: #a7b3bf;
  --cta-border: #222b34;
  --ring: color-mix(in srgb, var(--accent) 70%, transparent);
  --shadow-menu: 0 24px 48px -32px rgba(15, 25, 35, 0.32);
  --radius: 4px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --font-heading: "Cormorant Garamond", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --font-display: "Rethink Sans", "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-text: "Vollkorn", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0e11;
    --bg-alt: #0f1317;
    --surface: #141a1f;
    --fg: #e3eaf0;
    --muted: #9aa7b3;
    --faint: #7f8c98;
    --border: #222a31;
    --border-strong: #36414b;
    --accent: #7fb0d9;
    --ink: #e3eaf0;
    --ink-hover: #ffffff;
    --ink-fg: #0b0e11;
    --shadow-menu: 0 24px 48px -28px rgba(0, 0, 0, 0.85);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0b0e11;
  --bg-alt: #0f1317;
  --surface: #141a1f;
  --fg: #e3eaf0;
  --muted: #9aa7b3;
  --faint: #7f8c98;
  --border: #222a31;
  --border-strong: #36414b;
  --accent: #7fb0d9;
  --ink: #e3eaf0;
  --ink-hover: #ffffff;
  --ink-fg: #0b0e11;
  --shadow-menu: 0 24px 48px -28px rgba(0, 0, 0, 0.85);
  color-scheme: dark;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 5rem; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 17px/1.65 var(--font-text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3 {
  font-family: var(--font-heading);
  font-weight: 500; line-height: 1.02; margin: 0; letter-spacing: -0.015em;
  text-wrap: balance;
}
p { margin: 0; text-wrap: pretty; }
a {
  color: var(--fg); text-underline-offset: 0.22em; text-decoration-thickness: 1px;
  text-decoration-color: var(--border-strong);
  transition: color 200ms ease, text-decoration-color 200ms ease;
}
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 3px; border-radius: var(--radius); }
::selection { background: color-mix(in srgb, var(--accent) 24%, transparent); color: var(--fg); }
svg { flex: none; }

.wrap { width: min(100% - 3rem, 76rem); margin-inline: auto; }

.skip {
  position: absolute; left: -999px; top: 0.75rem; z-index: 50;
  background: var(--ink); color: var(--ink-fg); padding: 0.5rem 0.9rem; border-radius: var(--radius);
  font-family: var(--font-display);
}
.skip:focus { left: 0.75rem; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(140%) blur(14px);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color 300ms ease;
}
.site-header.scrolled { border-bottom-color: var(--border); }
.bar { display: flex; align-items: center; gap: 1.5rem; min-height: 4.5rem; }

.brand { display: inline-flex; align-items: center; gap: 0.8rem; text-decoration: none; color: var(--fg); }
.brand-mark {
  display: grid; place-items: center; width: 2.3rem; height: 2.3rem; border-radius: 50%;
  background: var(--ink); color: var(--ink-fg);
  font-family: var(--font-display); font-weight: 500; font-size: 0.82rem; letter-spacing: 0.04em;
}
.brand-name { font-family: var(--font-heading); font-size: 1.45rem; font-weight: 500; letter-spacing: 0; }

#site-nav { margin-left: auto; }
#site-nav ul { display: flex; align-items: center; gap: 0.35rem; list-style: none; margin: 0; padding: 0; }
#site-nav a {
  position: relative; display: block; padding: 0.5rem 0.85rem;
  color: var(--muted); text-decoration: none; font-family: var(--font-display); font-size: 0.98rem; font-weight: 400;
  transition: color 200ms ease, background-color 200ms ease;
}
#site-nav a::after {
  content: ""; position: absolute; left: 0.85rem; right: 0.85rem; bottom: 0.2rem; height: 1px;
  background: currentColor; transform: scaleX(0); transform-origin: left;
  transition: transform 300ms var(--ease-out);
}
#site-nav a:hover, #site-nav a.active { color: var(--fg); }
#site-nav a:hover::after, #site-nav a.active::after { transform: scaleX(1); }
#site-nav a.nav-cta {
  color: var(--ink-fg); background: var(--ink); margin-left: 0.6rem;
  border-radius: var(--radius); padding-inline: 1.2rem; font-weight: 500;
}
#site-nav a.nav-cta::after { display: none; }
#site-nav a.nav-cta:hover { background: var(--ink-hover); }

.bar-actions { display: flex; gap: 0.5rem; }
.icon-btn {
  display: grid; place-items: center; width: 2.4rem; height: 2.4rem;
  border: 1px solid var(--border-strong); border-radius: 50%;
  background: transparent; color: var(--fg); cursor: pointer;
  transition: border-color 200ms ease, transform 160ms var(--ease-out);
}
.icon-btn:hover { border-color: var(--fg); }
.icon-btn:active { transform: scale(0.95); }
.menu-btn { display: none; }

.i-sun { display: none; }
:root[data-theme="dark"] .i-sun { display: block; }
:root[data-theme="dark"] .i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: block; }
  :root:not([data-theme="light"]) .i-moon { display: none; }
}

/* ---------- Buttons & tag lists ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 0.65rem;
  padding: 0.85rem 1.5rem; border-radius: var(--radius);
  border: 1px solid var(--border-strong); background: transparent;
  color: var(--fg); text-decoration: none; font-family: var(--font-display); font-weight: 500; font-size: 1rem;
  transition: transform 160ms var(--ease-out), background-color 200ms ease, border-color 200ms ease, color 200ms ease;
}
.btn:hover { border-color: var(--fg); }
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--ink); color: var(--ink-fg); border-color: var(--ink); }
.btn.primary:hover { background: var(--ink-hover); border-color: var(--ink-hover); }

/* Tags read as a typeset list, not boxed chips. */
.chips {
  list-style: none; display: flex; flex-wrap: wrap; gap: 0.1rem 0; margin: 0; padding: 0;
  color: var(--muted); font-family: var(--font-display); font-size: 0.92rem;
}
.chips li { white-space: nowrap; }
.chips li::first-letter { text-transform: uppercase; }
.chips li:not(:last-child)::after { content: ","; margin-right: 0.4em; }

.badge {
  display: inline-block; font-family: var(--font-display); font-size: 0.82rem; font-weight: 500;
  padding: 0.12rem 0.6rem; border-radius: 99px; margin-right: 0.85rem; border: 1px solid;
}
.badge.prod { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.badge.side { color: var(--muted); border-color: var(--border-strong); }

/* ---------- Hero ---------- */
.hero { position: relative; padding-block: 7.5rem 6.5rem; }
.hero::after {
  content: ""; position: absolute; bottom: 0; left: 50%; translate: -50% 0;
  width: min(100% - 3rem, 76rem); height: 1px; background: var(--border);
}
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 5rem; align-items: end; }

.status {
  display: inline-flex; align-items: center; gap: 0.7rem;
  font-family: var(--font-display); font-size: 1rem; font-weight: 400; color: var(--muted);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: pulse 2.8s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 50%, transparent); }
  70% { box-shadow: 0 0 0 9px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* The one loud element: the name, set large and light. */
.hero h1 {
  font-size: clamp(3.8rem, 9.4vw, 8.6rem); margin-top: 1.75rem;
  font-weight: 500; letter-spacing: -0.03em; line-height: 0.9;
}
.role {
  margin-top: 1.5rem; font-family: var(--font-heading); font-style: italic;
  font-size: clamp(1.8rem, 3vw, 2.4rem); font-weight: 500; color: var(--muted); line-height: 1.2;
}
.lead { font-size: 1.15rem; color: var(--muted); max-width: 36rem; margin-top: 1.75rem; line-height: 1.7; }
.lead strong { color: var(--fg); font-weight: 500; }
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 2.5rem; }
.socials { display: flex; gap: 1.75rem; margin-top: 2rem; }
.socials a {
  display: inline-flex; align-items: center; gap: 0.5rem; color: var(--muted); text-decoration: none;
  font-family: var(--font-display); font-weight: 400; font-size: 1rem;
}
.socials a:hover { color: var(--fg); }

.profile-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 2rem;
}
.profile-meta { margin: 0 0 1.5rem; display: grid; gap: 0.85rem; }
.profile-meta div { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: 0.75rem; font-size: 1rem; line-height: 1.5; }
.profile-meta dt { color: var(--faint); font-family: var(--font-display); font-size: 0.92rem; padding-top: 0.05rem; }
.profile-meta dd { margin: 0; font-weight: 500; }
.profile-card .chips { padding-top: 1.25rem; border-top: 1px solid var(--border); }

/* ---------- Sections ---------- */
.section { padding-block: 8rem; }
.section.alt { background: var(--bg-alt); border-block: 1px solid var(--border); }
.section-head { margin-bottom: 4rem; max-width: 46rem; }
.section-head h2, .cta h2 { font-size: clamp(2.9rem, 5.8vw, 4.9rem); font-weight: 500; letter-spacing: -0.02em; line-height: 0.98; }
.section-intro { color: var(--muted); margin-top: 1.5rem; font-size: 1.12rem; max-width: 38rem; }

.split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); gap: 5rem; align-items: start; }
.split .section-head { margin-bottom: 0; position: sticky; top: 7rem; }
.prose p { color: var(--muted); font-size: 1.12rem; line-height: 1.7; }
.prose p:first-child { color: var(--fg); font-family: var(--font-heading); font-weight: 500; font-size: 2rem; line-height: 1.25; letter-spacing: -0.005em; }
.prose p + p { margin-top: 1.75rem; }
/* Running prose is justified and hyphenated (needs <html lang>); display text stays ragged.
   Card details stay ragged: their column is too narrow to justify without rivers. */
.lead, .section-intro, .prose p:not(:first-child), .timeline ul li, .cred p:last-child { text-align: justify; hyphens: auto; }

/* ---------- Cards ---------- */
/* Cards in a row share row tracks (subgrid), so titles, metrics, details and stacks line up across cards. */
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; }
.card {
  display: grid; grid-row: span 5; grid-template-rows: subgrid; row-gap: 1.15rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 2.25rem;
}
.card > dl { grid-row: 4; }
.card-tag { display: flex; align-items: center; color: var(--muted); font-family: var(--font-display); font-size: 1rem; }
.card h3 { font-size: 2.4rem; font-weight: 500; line-height: 1.02; letter-spacing: -0.01em; }
.metric { padding: 0.8rem 0; border-block: 1px solid var(--border); color: var(--muted); font-family: var(--font-display); font-size: 1rem; }
.card dl { display: grid; gap: 0.85rem; margin: 0; }
.card dl div { display: grid; grid-template-columns: 5rem minmax(0, 1fr); gap: 0.75rem; }
.card dt { font-family: var(--font-display); font-weight: 500; color: var(--faint); font-size: 0.92rem; padding-top: 0.12rem; }
.card dd { margin: 0; font-size: 1.02rem; line-height: 1.55; }
.card .chips { grid-row: 5; padding-top: 0.75rem; }
.card:last-child:nth-child(odd) { grid-column: 1 / -1; }
.card:last-child:nth-child(odd) dl { max-width: 52rem; }
.card:last-child:nth-child(odd) dl div { grid-template-columns: 6rem minmax(0, 1fr); }

/* Hover only changes the border, and only on pointer devices. */
.card, .js .card.reveal { transition: border-color 300ms ease, opacity 900ms var(--ease-out), transform 900ms var(--ease-out); }
@media (hover: hover) and (pointer: fine) {
  .card:hover { border-color: var(--border-strong); }
}

/* ---------- Timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 4px; top: 0.85rem; bottom: 0.85rem; width: 1px; background: var(--border-strong); }
.timeline > li { position: relative; padding-left: 2.75rem; }
.timeline > li + li { margin-top: 4rem; }
.timeline > li::before {
  content: ""; position: absolute; left: 0; top: 0.7rem; width: 9px; height: 9px; border-radius: 50%;
  background: var(--bg); border: 1px solid var(--faint);
}
.timeline > li:first-child::before { background: var(--accent); border-color: var(--accent); }
.tl-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.4rem 1.5rem; max-width: 48rem; }
.tl-head h3 { font-size: 2.5rem; font-weight: 500; letter-spacing: -0.01em; }
.when { font-family: var(--font-display); font-size: 1rem; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.org { color: var(--muted); font-family: var(--font-heading); font-style: italic; font-weight: 500; font-size: 1.5rem; margin-top: 0.3rem; }
.timeline ul { margin: 1.4rem 0 0; padding-left: 1.2rem; color: var(--muted); max-width: 48rem; }
.timeline ul li { margin-bottom: 0.65rem; padding-left: 0.35rem; }
.timeline ul li::marker { content: "– "; color: var(--faint); }

/* ---------- Skills & credentials ---------- */
.skills { border-top: 1px solid var(--border-strong); }
.skill-row {
  display: grid; grid-template-columns: 17rem minmax(0, 1fr); gap: 1.5rem; align-items: baseline;
  padding-block: 1.35rem; border-bottom: 1px solid var(--border);
}
.skill-row h3 { font-size: 1.8rem; font-weight: 500; letter-spacing: -0.005em; }
.skill-row .chips { color: var(--fg); font-size: 1.05rem; }

.creds { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2.5rem 4rem; margin-top: 5rem; }
.cred { border-top: 1px solid var(--border-strong); padding-top: 1.5rem; }
.cred-label { font-family: var(--font-display); font-size: 1rem; font-weight: 500; color: var(--accent); }
.cred-title { font-family: var(--font-heading); font-weight: 500; font-size: 2.1rem; line-height: 1.1; letter-spacing: -0.01em; margin: 0.5rem 0 0.6rem; }
.cred-note {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.4rem 1.25rem;
  margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--border);
  color: var(--muted); font-size: 1.02rem;
}
.cred p:last-child { color: var(--muted); font-size: 1.02rem; }

/* ---------- Contact ---------- */
.cta {
  text-align: center; padding: 7rem 2rem; border-radius: var(--radius);
  color: var(--cta-fg); background: var(--pine); border: 1px solid var(--cta-border);
}
.cta h2 { color: var(--cta-strong); font-size: clamp(3rem, 6.6vw, 5.6rem); }
.cta > p:not(.actions) { color: var(--cta-muted); max-width: 38rem; margin: 1.5rem auto 0; font-size: 1.15rem; text-wrap: balance; }
.cta .actions { justify-content: center; margin-top: 3rem; }
.btn.on-dark { background: var(--cta-strong); color: var(--pine); border-color: var(--cta-strong); }
.btn.on-dark:hover { background: #ffffff; border-color: #ffffff; }
.btn.ghost { background: transparent; color: var(--cta-fg); border-color: color-mix(in srgb, var(--cta-fg) 28%, transparent); }
.btn.ghost:hover { border-color: var(--cta-fg); background: rgba(255, 255, 255, 0.05); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--border); padding-block: 2.5rem; color: var(--muted); font-family: var(--font-display); font-size: 0.95rem; }
.foot { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.foot a { color: var(--muted); text-decoration: none; }
.foot a:hover { color: var(--fg); }

/* ---------- Motion (only when JS is running) ---------- */
/* Hero: first-visit entrance, staggered. `backwards` keeps the resting state visible if animations are off. */
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes rise-soft { from { opacity: 0; transform: translateY(18px); filter: blur(8px); } }
.js .hero-copy > * { animation: rise 1000ms var(--ease-out) backwards; }
.js .hero-copy > h1 { animation-name: rise-soft; animation-duration: 1200ms; }
.js .hero-copy > :nth-child(2) { animation-delay: 70ms; }
.js .hero-copy > :nth-child(3) { animation-delay: 160ms; }
.js .hero-copy > :nth-child(4) { animation-delay: 230ms; }
.js .hero-copy > :nth-child(5) { animation-delay: 300ms; }
.js .hero-copy > :nth-child(6) { animation-delay: 360ms; }

/* Scroll reveal: transitions, so a fast scroll retargets instead of restarting. */
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity 900ms var(--ease-out), transform 900ms var(--ease-out); }
.js .reveal.in { opacity: 1; transform: none; }
.js .hero .profile-card.reveal { transition-delay: 280ms; }
.js .cards .reveal:nth-child(2n), .js .creds .reveal:nth-child(2n) { transition-delay: 80ms; }

/* ---------- Responsive ---------- */
@media (max-width: 60rem) {
  .hero-grid { grid-template-columns: 1fr; gap: 3.5rem; align-items: start; }
  .profile-card { max-width: 32rem; }
  .split { grid-template-columns: 1fr; gap: 2rem; }
  .split .section-head { position: static; }
  .skill-row { grid-template-columns: 12rem minmax(0, 1fr); }
}

@media (max-width: 48rem) {
  .wrap { width: min(100% - 2.5rem, 76rem); }
  .brand-name { display: none; }
  .menu-btn { display: grid; }
  .bar { gap: 0.75rem; }
  .bar-actions { margin-left: auto; }
  #site-nav {
    position: absolute; top: 100%; left: 0; right: 0; margin: 0;
    background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow-menu);
    display: none;
  }
  #site-nav.open { display: block; }
  #site-nav ul { flex-direction: column; align-items: stretch; padding: 0.75rem 1.25rem 1.25rem; gap: 0.15rem; }
  #site-nav a { padding: 0.8rem 0.9rem; font-size: 1.1rem; }
  #site-nav a::after { display: none; }
  #site-nav a.nav-cta { margin: 0.5rem 0 0; text-align: center; }
  .cards, .creds { grid-template-columns: 1fr; }
  .card { padding: 1.75rem; }
  .card dl div, .card:last-child:nth-child(odd) dl div { grid-template-columns: 1fr; gap: 0.15rem; }
  .js .cards .reveal:nth-child(2n), .js .creds .reveal:nth-child(2n) { transition-delay: 0ms; }
  .skill-row { grid-template-columns: 1fr; gap: 0.5rem; }
  .section { padding-block: 5.5rem; }
  .section-head { margin-bottom: 3rem; }
  .hero { padding-block: 4.5rem 4rem; }
  .hero::after { width: min(100% - 2.5rem, 76rem); }
  .prose p:first-child { font-size: 1.65rem; }
  .creds { margin-top: 3.5rem; gap: 2rem; }
  .cta { padding: 4.5rem 1.25rem; }
  /* Narrow measures can't justify cleanly, especially where the browser lacks hyphenation. */
  .lead, .section-intro, .prose p:not(:first-child), .timeline ul li, .cred p:last-child { text-align: start; }
}

@media (max-width: 30rem) {
  .actions .btn { flex: 1 1 auto; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .js .reveal { opacity: 1; transform: none; }
}

@media print {
  .site-header, .actions, .socials, .bar-actions, .site-footer a { display: none; }
  body { background: #fff; color: #000; }
  .section.alt, .cta { background: none; color: #000; border: 0; }
  .cta h2, .cta p { color: #000 !important; }
  .js .reveal { opacity: 1; transform: none; }
  .js .hero-copy > * { animation: none; }
}
