/* ==========================================================================
   Fonts (self-hosted, Latin subset; Geist and Geist Mono are variable)
   ========================================================================== */
@font-face {
  font-family: "Instrument Serif";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/instrument-serif.woff2") format("woff2");
}

@font-face {
  font-family: "Instrument Serif";
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("fonts/instrument-serif-italic.woff2") format("woff2");
}

@font-face {
  font-family: "Geist";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/geist.woff2") format("woff2");
}

@font-face {
  font-family: "Geist Mono";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/geist-mono.woff2") format("woff2");
}

/* ==========================================================================
   Tokens
   ========================================================================== */
:root {
  --bg: #f4f1ea;
  --surface: #ece7dc;
  --surface-2: #e4ded1;
  --ink: #17150f;
  --ink-2: #3b372f;
  --muted: #6d675b;
  --line: #d9d2c3;
  --accent: #d6401f;
  --accent-ink: #fff8f2;
  --focus: #d6401f;
  --header-bg: rgba(244, 241, 234, 0.82);

  --font-display: "Instrument Serif", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-body: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --container: 1120px;
  --header-h: 64px;
  --gutter: clamp(16px, 4vw, 40px);
  --radius: 14px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0e0c;
    --surface: #181613;
    --surface-2: #211e1a;
    --ink: #eee9df;
    --ink-2: #cfc8bb;
    --muted: #9b9486;
    --line: #2c2924;
    --accent: #ff6a45;
    --accent-ink: #1a0d08;
    --focus: #ff6a45;
    --header-bg: rgba(15, 14, 12, 0.78);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f0e0c;
  --surface: #181613;
  --surface-2: #211e1a;
  --ink: #eee9df;
  --ink-2: #cfc8bb;
  --muted: #9b9486;
  --line: #2c2924;
  --accent: #ff6a45;
  --accent-ink: #1a0d08;
  --focus: #ff6a45;
  --header-bg: rgba(15, 14, 12, 0.78);
  color-scheme: dark;
}

/* ==========================================================================
   Base
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
  transition: background-color 0.3s var(--ease), color 0.3s var(--ease);
}

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

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 400;
}

p {
  margin: 0;
}

ul,
ol,
dl,
dd {
  margin: 0;
  padding: 0;
}

ul,
ol {
  list-style: none;
}

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

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

.container {
  width: 100%;
  max-width: calc(var(--container) + var(--gutter) * 2);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -48px;
  z-index: 100;
  padding: 8px 14px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 8px;
  font-size: 14px;
  transition: top 0.2s var(--ease);
}

.skip-link:focus {
  top: 12px;
}

/* ==========================================================================
   Header
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  backdrop-filter: saturate(140%) blur(12px);
  /* A shadow rather than a border, so the header is exactly --header-h tall. */
  box-shadow: 0 1px 0 transparent;
  transition: box-shadow 0.3s var(--ease), background-color 0.3s var(--ease);
}

.site-header.is-scrolled {
  box-shadow: 0 1px 0 var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  height: var(--header-h);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-right: auto;
  font-weight: 500;
  font-size: 15px;
  letter-spacing: -0.01em;
}

/* The name stays in the link for screen readers but isn't shown;
   the round mark is the visible logo. */
.brand-name {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: 0.02em;
  transition: background-color 0.3s var(--ease), transform 0.4s var(--ease);
}

.brand:hover .brand-mark {
  background: var(--accent);
  color: var(--accent-ink);
  transform: rotate(-8deg);
}

.nav {
  display: flex;
  gap: 4px;
}

.nav a {
  position: relative;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 14px;
  color: var(--muted);
  transition: color 0.2s var(--ease), background-color 0.2s var(--ease);
}

.nav a:hover {
  color: var(--ink);
}

.nav a.is-active {
  color: var(--ink);
  background: var(--surface);
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease);
}

.theme-toggle:hover {
  border-color: var(--ink);
}

.theme-toggle svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Show the icon for the theme you'd switch TO. */
.theme-toggle .icon-sun {
  display: none;
}

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

:root[data-theme="dark"] .theme-toggle .icon-sun {
  display: block;
}

:root[data-theme="dark"] .theme-toggle .icon-moon {
  display: none;
}

/* ==========================================================================
   Hero
   ========================================================================== */
/* The hero fills exactly one screen below the sticky header. Type and spacing
   scale with viewport height as well as width so it still fits on short
   laptop screens; the stats strip is pinned to the bottom of the fold. */
.hero {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--header-h));
  min-height: calc(100svh - var(--header-h));
  padding: clamp(16px, 3vh, 48px) 0 clamp(16px, 3vh, 40px);
}

.hero > .container {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Name-led hero: status kicker, two-line name with an italic accent,
   role + tagline, short intro, and a light row of links.
   Spare height is split 1:3 (above : below). */
.hero > .container::before {
  content: "";
  flex: 1 1 0;
}

.hero-main {
  flex: 3 1 auto;
  padding-bottom: clamp(12px, 3vh, 64px);
}

.hero-kicker {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.hero-kicker::before {
  content: "";
  flex: none;
  width: 32px;
  height: 1px;
  background: currentColor;
}

.hero-kicker strong {
  font-weight: 500;
  color: var(--ink);
}

.status-dot {
  position: relative;
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

.status-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2.4s var(--ease) infinite;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.6; }
  80%, 100% { transform: scale(2.8); opacity: 0; }
}

.hero-name {
  margin-top: clamp(8px, 1.6vh, 16px);
  font-family: var(--font-display);
  /* Height term keeps ~100px on a 1440x900 laptop but shrinks faster on
     short screens so the hero still fits. */
  font-size: clamp(48px, min(7.4vw, calc(14.4vh - 30px)), 108px);
  line-height: 0.92;
  letter-spacing: -0.03em;
  color: var(--ink);
}

.hero-name em {
  display: block;
  /* The italic A leans left of the column; nudge it back onto the edge. */
  padding-left: 0.05em;
  font-style: italic;
  color: var(--accent);
}

.hero-role {
  margin-top: clamp(10px, 2.6vh, 32px);
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.hero-role strong {
  font-weight: 500;
  color: var(--ink-2);
}

.hero-tagline {
  margin-top: clamp(10px, 2.2vh, 24px);
  font-family: var(--font-display);
  font-size: clamp(20px, min(2.2vw, 3.4vh), 30px);
  line-height: 1.2;
  color: var(--ink-2);
  text-wrap: balance;
}

.hero-tagline em {
  font-style: italic;
  color: var(--accent);
}

.hero-lede {
  max-width: 600px;
  margin-top: clamp(12px, 2.6vh, 28px);
  font-size: clamp(16px, min(1.3vw, 2.2vh), 18px);
  line-height: 1.65;
  color: var(--muted);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: clamp(12px, 2.2vh, 20px);
}

.hero-contact {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: clamp(14px, 3vh, 32px);
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--muted);
}

.hero-contact a {
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}

.hero-contact a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.contact-title em {
  font-style: italic;
  color: var(--accent);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  padding: 0 22px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 500;
  transition: transform 0.2s var(--ease), background-color 0.2s var(--ease), border-color 0.2s var(--ease), color 0.2s var(--ease);
}

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

.btn-icon {
  flex: none;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn-icon-fill {
  width: 16px;
  height: 16px;
  fill: currentColor;
  stroke: none;
}

.btn-resume .btn-icon {
  transition: transform 0.25s var(--ease);
}

.btn-resume:hover .btn-icon {
  transform: translate(2px, -2px);
}

.header-resume {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}

.header-resume:hover {
  background: var(--ink);
  color: var(--bg);
}

.btn-primary {
  background: var(--ink);
  color: var(--bg);
}

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

.btn-ghost {
  border-color: var(--line);
  color: var(--ink);
}

.btn-ghost:hover {
  border-color: var(--ink);
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 0;
  border-top: 1px solid var(--line);
}

.stats li {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: clamp(12px, 2vh, 24px) 24px 0 0;
}

.stats li + li {
  padding-left: 24px;
  border-left: 1px solid var(--line);
}

.stat-num {
  font-family: var(--font-display);
  font-size: clamp(40px, min(6vw, 6.5vh), 80px);
  line-height: 1;
  letter-spacing: -0.02em;
}

.stat-unit {
  color: var(--accent);
}

.stat-label {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}

/* ==========================================================================
   Sections
   ========================================================================== */
.section {
  padding: clamp(72px, 10vw, 128px) 0;
  border-top: 1px solid var(--line);
}

.section-head {
  display: grid;
  gap: 12px;
  margin-bottom: clamp(40px, 6vw, 64px);
  max-width: 720px;
}

.section-kicker {
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.section-title {
  font-family: var(--font-display);
  font-size: clamp(40px, 6vw, 72px);
  line-height: 1;
  letter-spacing: -0.02em;
}

.section-sub {
  font-size: 17px;
  color: var(--muted);
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tags li {
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  color: var(--ink-2);
  white-space: nowrap;
}

/* ---- Experience ---- */
.roles {
  border-top: 1px solid var(--line);
}

.role {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr) minmax(0, 1.5fr);
  gap: 20px 40px;
  padding: clamp(28px, 4vw, 44px) 0;
  border-bottom: 1px solid var(--line);
}

.role-when {
  display: grid;
  gap: 4px;
  align-content: start;
  padding-top: 8px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}

.role-when span:first-child {
  color: var(--ink);
  transition: color 0.3s var(--ease);
}

.role:hover .role-when span:first-child {
  color: var(--accent);
}

.role-head {
  display: grid;
  gap: 6px;
  align-content: start;
}

.role-head h3 {
  font-family: var(--font-display);
  font-size: clamp(32px, 3.4vw, 42px);
  line-height: 1.05;
  letter-spacing: -0.01em;
}

.role-title {
  margin-bottom: 12px;
  font-size: 15.5px;
  color: var(--ink-2);
}

.role-body {
  padding-top: 6px;
}

.role-edu .role-head h3 {
  font-size: clamp(24px, 2.4vw, 30px);
}

.role-edu .role-title {
  margin-bottom: 0;
}

.highlights {
  margin-top: clamp(48px, 7vw, 80px);
}

.highlights-title {
  margin-bottom: 20px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.highlights-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.highlight {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.highlight h4 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 400;
  line-height: 1.1;
}

.highlight p {
  flex: 1;
  font-size: 15px;
  color: var(--muted);
}

.bullets {
  display: grid;
  gap: 8px;
}

.bullets li {
  position: relative;
  padding-left: 22px;
  font-size: 15.5px;
  color: var(--muted);
}

.bullets li::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 0.8em;
  width: 10px;
  height: 1px;
  background: var(--accent);
}

.bullets strong {
  font-weight: 600;
  color: var(--ink);
}

/* ---- Projects ---- */
/* Four cards as a 2 x 2 grid. */
.projects {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.project {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: transform 0.35s var(--ease), border-color 0.35s var(--ease), background-color 0.35s var(--ease);
}

.project:hover {
  transform: translateY(-4px);
  border-color: var(--ink);
}

.project-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.project-kind {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.project-link {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 50%;
  transition: background-color 0.25s var(--ease), border-color 0.25s var(--ease), color 0.25s var(--ease);
}

/* Make the whole card clickable via the arrow link. */
.project-link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
}

.project-link svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.3s var(--ease);
}

.project:hover .project-link {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.project:hover .project-link svg {
  transform: translate(1px, -1px);
}

.project h3 {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.project p {
  flex: 1;
  font-size: 15.5px;
  color: var(--muted);
}

.project .tags li {
  background: var(--bg);
}

.more-link {
  margin-top: 32px;
}

.more-link a {
  font-family: var(--font-mono);
  font-size: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 2px;
  transition: border-color 0.2s var(--ease), color 0.2s var(--ease);
}

.more-link a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---- Stack ---- */
.stack-layout {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: clamp(32px, 5vw, 64px);
  align-items: start;
}

.stack-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line);
}

.stack-group {
  padding: 20px 24px 20px 0;
  border-bottom: 1px solid var(--line);
}

.stack-group:nth-child(even) {
  padding-left: 24px;
  border-left: 1px solid var(--line);
}

.stack-group dt {
  margin-bottom: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.stack-group dd {
  font-size: 16px;
  color: var(--ink);
}

.exploring {
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.exploring h3 {
  margin-bottom: 16px;
  font-family: var(--font-display);
  font-size: 28px;
  line-height: 1.1;
}

.exploring ul {
  display: grid;
  gap: 12px;
}

.exploring li {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 8px;
  font-size: 15.5px;
  color: var(--ink-2);
}

.exploring li::before {
  content: "→";
  font-family: var(--font-mono);
  color: var(--accent);
}

/* ---- Contact ---- */
.contact {
  padding-bottom: clamp(80px, 12vw, 160px);
}

.contact .section-kicker {
  margin-bottom: 20px;
}

.contact-title {
  max-width: 980px;
  font-family: var(--font-display);
  font-size: clamp(44px, 7.5vw, 104px);
  line-height: 0.98;
  letter-spacing: -0.025em;
}

.contact-availability {
  margin-top: clamp(16px, 2.4vw, 24px);
  font-size: clamp(17px, 1.6vw, 20px);
  color: var(--ink-2);
}

.contact-email {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  margin-top: clamp(40px, 6vw, 64px);
}

.email-link {
  font-family: var(--font-mono);
  font-size: clamp(17px, 2.6vw, 28px);
  letter-spacing: -0.02em;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 2px;
  overflow-wrap: anywhere;
  transition: color 0.2s var(--ease);
}

.email-link:hover {
  color: var(--accent);
}

.copy-btn {
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12.5px;
  cursor: pointer;
  transition: border-color 0.2s var(--ease), background-color 0.2s var(--ease), color 0.2s var(--ease);
}

.copy-btn:hover {
  border-color: var(--ink);
}

.copy-btn.is-copied {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
}

.socials {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  margin-top: 32px;
}

.socials a {
  font-size: 16px;
  color: var(--muted);
  transition: color 0.2s var(--ease);
}

.socials a:hover {
  color: var(--ink);
}

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 28px 0;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--muted);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
}

.to-top:hover {
  color: var(--ink);
}

/* ==========================================================================
   Scroll reveal (only when JS is running)
   ========================================================================== */
.js .reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.8s var(--ease), transform 0.8s var(--ease);
}

.js .reveal.is-visible {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .js .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
  .status-dot::after {
    animation: none;
  }
  .project:hover {
    transform: none;
  }
}

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 900px) {
  .stack-layout {
    grid-template-columns: 1fr;
  }

  .projects,
  .highlights-grid {
    grid-template-columns: 1fr;
  }

  .role {
    grid-template-columns: 150px minmax(0, 1fr);
  }

  .role-body {
    grid-column: 2;
  }
}

@media (max-width: 640px) {
  :root {
    --header-h: 58px;
  }

  body {
    font-size: 16px;
  }

  .header-inner {
    gap: 8px;
  }

  .header-resume {
    display: none;
  }

  .hero-actions .btn-resume {
    flex: 1 1 100%;
    justify-content: center;
  }

  .hero-actions .btn-ghost {
    flex: 1 1 0;
    justify-content: center;
  }




  .nav a {
    padding: 6px 8px;
    font-size: 13.5px;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .stats li,
  .stats li + li {
    flex-direction: row;
    align-items: baseline;
    gap: 16px;
    padding: 18px 0;
    border-left: 0;
    border-bottom: 1px solid var(--line);
  }

  .stat-num {
    min-width: 92px;
  }

  .role {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .role-when {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    padding-top: 0;
  }

  .role-body {
    grid-column: auto;
    padding-top: 4px;
  }

  .stack-grid {
    grid-template-columns: 1fr;
  }

  .stack-group,
  .stack-group:nth-child(even) {
    padding: 18px 0;
    border-left: 0;
  }

  .hero-name {
    font-size: clamp(52px, 15vw, 72px);
  }

  /* Keep the two small-caps lines on one line each at phone widths. */
  .hero-kicker::before {
    display: none;
  }

  .hero-kicker,
  .hero-role {
    font-size: 12px;
    letter-spacing: 0.08em;
  }
}

@media (max-width: 360px) {
  .nav a {
    padding: 6px 6px;
    font-size: 13px;
  }
}

/* ==========================================================================
   "Ask my AI" button + chat panel
   ========================================================================== */
.ask-ai {
  position: fixed;
  right: clamp(16px, 2.4vw, 28px);
  bottom: clamp(16px, 2.4vw, 28px);
  z-index: 60;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 46px;
  padding: 0 20px 0 16px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--font-body);
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease), transform 0.2s var(--ease);
}

.ask-ai:hover {
  background: var(--accent);
  color: var(--accent-ink);
  transform: translateY(-1px);
}

.ask-ai-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent);
}

.ask-ai:hover .ask-ai-dot {
  background: var(--accent-ink);
}

/* Modal panel anchored bottom-right on desktop, full screen on phones. */
.ai-dialog {
  width: min(440px, calc(100vw - 32px));
  height: min(700px, calc(100dvh - 32px));
  max-width: none;
  max-height: none;
  margin: auto clamp(16px, 2.4vw, 28px) clamp(16px, 2.4vw, 28px) auto;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25);
}

.ai-dialog[open] {
  display: flex;
  flex-direction: column;
}

.ai-dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}

html:has(.ai-dialog[open]) {
  overflow: hidden;
}

.ai-dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 14px 20px;
  border-bottom: 1px solid var(--line);
}

.ai-dialog-title {
  font-family: var(--font-display);
  font-size: 28px;
  line-height: 1.1;
}

.ai-dialog-sub {
  margin-top: 4px;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--muted);
}

.ai-close {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.2s var(--ease);
}

.ai-close:hover {
  border-color: var(--ink);
}

.ai-close svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.ai-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: var(--surface);
}

.ai-dialog-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  border-top: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.ai-dialog-foot a {
  color: var(--muted);
  transition: color 0.2s var(--ease);
}

.ai-dialog-foot a:hover {
  color: var(--ink);
}

@media (max-width: 640px) {
  .ask-ai {
    height: 44px;
    padding: 0 18px 0 14px;
    font-size: 14px;
  }

  .ai-dialog {
    width: 100vw;
    height: 100dvh;
    margin: 0;
    border: 0;
    border-radius: 0;
  }
}
