:root {
  --bg: #0d1117;
  --surface: #151b23;
  --surface-2: #1b222c;
  --border: #262d38;
  --border-strong: #333c49;
  --text: #e6edf3;
  --muted: #9aa7b4;
  --accent: #3fb950;
  --accent-strong: #56d364;
  --accent-dim: rgba(63, 185, 80, 0.12);
  --page-max-width: 1600px;
  --page-gutter: clamp(16px, 3vw, 64px);
  --section-gap: clamp(40px, 5vw, 80px);
  --header-h: 64px;
  --measure: 62ch;
  --radius: 12px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  width: 100%;
  max-width: var(--page-max-width);
  margin-inline: auto;
  padding-inline: var(--page-gutter);
}

section[id],
article[id] { scroll-margin-top: calc(var(--header-h) + 8px); }

a { color: var(--accent-strong); }
a:hover { color: var(--accent); }

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

/* Accessibility helpers */
.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 100;
  background: var(--accent);
  color: #06210c;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 8px;
  text-decoration: none;
  transition: top 0.15s ease;
}
.skip-link:focus { top: 12px; }

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

/* Header + nav */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(13, 17, 23, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-h);
  gap: 16px;
}
.brand {
  font-family: var(--mono);
  font-size: 14px;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
}
.brand-mono { color: var(--accent); }
.brand-sep { color: var(--muted); }
.brand-path { color: var(--muted); }

.site-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.site-nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 15px;
  padding: 10px 12px;
  border-radius: 8px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}
.site-nav a:hover { color: var(--text); background: var(--surface); }
.site-nav a.active { color: var(--accent-strong); }

.nav-toggle {
  display: none;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 8px 14px;
  font-family: var(--mono);
  font-size: 14px;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  cursor: pointer;
}
.nav-toggle:hover { border-color: var(--accent); }
.nav-toggle-icon,
.nav-toggle-icon::before,
.nav-toggle-icon::after {
  display: block;
  width: 18px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
  transition: transform 0.2s ease, background 0.2s ease;
}
.nav-toggle-icon { position: relative; }
.nav-toggle-icon::before,
.nav-toggle-icon::after { content: ""; position: absolute; left: 0; }
.nav-toggle-icon::before { top: -6px; }
.nav-toggle-icon::after { top: 6px; }
.nav-toggle[aria-expanded="true"] .nav-toggle-icon { background: transparent; }
.nav-toggle[aria-expanded="true"] .nav-toggle-icon::before { top: 0; transform: rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-icon::after { top: 0; transform: rotate(-45deg); }

/* Phones: collapse the nav into a dropdown (only when JS can toggle it) */
@media (max-width: 639.98px) {
  .js .nav-toggle { display: inline-flex; }
  .js .site-nav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    flex-wrap: nowrap;
    gap: 2px;
    padding: 8px var(--page-gutter) 12px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    max-height: calc(100vh - var(--header-h));
    max-height: calc(100dvh - var(--header-h));
    overflow-y: auto;
  }
  .js .site-nav.is-open { display: flex; }
}

/* Shared section styling */
.section { padding-block: var(--section-gap); border-top: 1px solid var(--border); }
.section.alt { background: var(--surface); }

.eyebrow {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--accent);
  margin: 0 0 10px;
  letter-spacing: 0.3px;
}

h1, h2, h3, h4, h5 { line-height: 1.2; font-weight: 700; }

h2 {
  font-size: clamp(1.75rem, 2.5vw, 2.5rem);
  margin: 0 0 14px;
  letter-spacing: -0.3px;
}
h2.mt { margin-top: var(--section-gap); }
h2.visually-small { font-size: 22px; color: var(--muted); font-weight: 600; }
h3 { font-size: 19px; margin: 22px 0 8px; }
h4 { font-size: 16px; margin: 18px 0 6px; }
h5 { font-size: 15px; margin: 16px 0 6px; }

.section-sub {
  color: var(--muted);
  max-width: var(--measure);
  margin: 0 0 28px;
}

/* Hero */
.hero { padding-block: clamp(32px, 4vw, 64px) var(--section-gap); }
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 32px;
  align-items: center;
}
.hero-text { min-width: 0; }
.hero-title {
  font-size: clamp(2.5rem, 4.5vw, 4.5rem);
  line-height: 1.05;
  letter-spacing: -0.5px;
  margin: 4px 0 12px;
}
.role {
  font-family: var(--mono);
  color: var(--accent-strong);
  font-size: clamp(1rem, 1.3vw, 1.25rem);
  margin: 0 0 20px;
}
.hero-description {
  font-size: 18px;
  line-height: 1.65;
  color: var(--text);
  max-width: var(--measure);
  margin: 0 0 28px;
}
.hero-description a { white-space: nowrap; }

.hero-portrait { margin: 0; min-width: 0; }
.hero-portrait img {
  width: min(100%, 320px);
  height: auto;
  margin-inline: auto;
  border-radius: 16px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
}

@media (min-width: 1024px) {
  .hero-grid {
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    gap: clamp(32px, 5vw, 80px);
  }
  .hero-portrait img {
    width: min(100%, clamp(320px, 24vw, 440px));
    margin-inline: auto 0;
  }
}

/* Buttons */
.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 11px 20px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
}
.btn-primary {
  background: var(--accent);
  color: #06210c;
}
.btn-primary:hover { background: var(--accent-strong); color: #06210c; transform: translateY(-1px); }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: var(--accent); }

/* Projects: every project is one .project article in .project-list */
.project-list { margin-top: 8px; }
.project + .project {
  margin-top: var(--section-gap);
  padding-top: var(--section-gap);
  border-top: 1px solid var(--border);
}
.project-head { margin-bottom: 24px; }
.project-kicker {
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 6px;
}
.project-title {
  font-size: clamp(1.5rem, 2.2vw, 2rem);
  margin: 0 0 8px;
}
.project-tagline {
  color: var(--muted);
  max-width: var(--measure);
  margin: 0;
}
.project-result {
  max-width: var(--measure);
  margin: 16px 0 0;
  padding-left: 14px;
  border-left: 2px solid var(--accent);
}
.project-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}
.project-shot { margin: 0; min-width: 0; }
.project-shot img {
  width: 100%;
  height: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
}
.project-body { min-width: 0; }
.project-body h4 { font-size: 18px; margin: 20px 0 6px; }
.project-body h4:first-child { margin-top: 0; }
.project-body p, .feature-list { max-width: var(--measure); }

@media (min-width: 1024px) {
  .project-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(32px, 4vw, 64px);
  }
  .project-shot { position: sticky; top: calc(var(--header-h) + 24px); }
}

.feature-list, .plain-list { padding-left: 20px; margin: 8px 0 0; }
.feature-list li, .plain-list li { margin-bottom: 8px; color: var(--text); }
.plain-list { list-style: none; padding-left: 0; }
.plain-list li { color: var(--muted); }
.plain-list strong { color: var(--text); }

.badges {
  list-style: none;
  padding: 0;
  margin: 20px 0 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.badges li {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--accent-strong);
  background: var(--accent-dim);
  border: 1px solid rgba(63, 185, 80, 0.28);
  padding: 5px 10px;
  border-radius: 999px;
}

/* Details / case study */
.case-study {
  margin-top: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  overflow: hidden;
}
.section.alt .case-study { background: var(--bg); }
.case-study summary {
  cursor: pointer;
  padding: 14px 18px;
  font-weight: 600;
  font-size: 15px;
  color: var(--text);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}
.case-study summary::-webkit-details-marker { display: none; }
.case-study summary::before {
  content: "›";
  font-family: var(--mono);
  color: var(--accent);
  font-size: 18px;
  transition: transform 0.2s ease;
}
.case-study summary::after {
  content: "expand";
  content: "expand" / "";
  margin-left: auto;
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}
.case-study[open] summary::before { transform: rotate(90deg); }
.case-study[open] summary::after { content: "collapse"; content: "collapse" / ""; }
.case-study[open] summary { color: var(--accent-strong); }
.case-study summary:hover { color: var(--accent-strong); }
.case-study summary:focus-visible { outline-offset: -3px; }
.case-study-body {
  padding: 4px 18px 18px;
  border-top: 1px solid var(--border);
}
.case-study-body h5 { color: var(--accent-strong); }
.case-study-body p { color: var(--muted); margin: 6px 0 14px; }

/* Skills grid */
.skills-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}
@media (min-width: 640px) {
  .skills-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1200px) {
  .skills-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.skill-group {
  min-width: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.section.alt .skill-group { background: var(--bg); }
.skill-group h3 { margin: 0 0 10px; font-size: 15px; color: var(--accent-strong); }
.skill-group ul { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 7px; }
.skill-group li {
  font-family: var(--mono);
  font-size: 14px;
  overflow-wrap: anywhere;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: 7px;
}
.section.alt .skill-group li { background: var(--surface); }

/* Timeline */
.timeline { list-style: none; padding: 0; margin: 8px 0 0; }
.timeline li {
  display: grid;
  grid-template-columns: minmax(96px, 8.5rem) minmax(0, 1fr);
  gap: 8px 24px;
  padding: 18px 0;
  border-top: 1px solid var(--border);
}
.timeline li:first-child { border-top: none; }
.timeline .when {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--accent);
  padding-top: 2px;
}
.timeline .what h3 { margin: 0 0 6px; font-size: 18px; }
.timeline .what p { margin: 0; max-width: var(--measure); color: var(--muted); }
.timeline .what p + p { margin-top: 6px; }

/* Redacted / classified entry */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.classified { margin: 0 0 6px; }
.redact-bars {
  font-family: var(--mono);
  color: var(--border-strong);
  letter-spacing: 1px;
  line-height: 1.5;
  user-select: none;
  overflow-wrap: anywhere;
}
.redact-inline {
  color: var(--border-strong);
  letter-spacing: 1px;
  user-select: none;
}
.classified-tag {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--accent);
  margin: 0;
}

/* Interests */
.interests {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.interests li {
  font-size: 14px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: 999px;
}

/* Contact */
.contact-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
.contact-intro .section-sub { margin-bottom: 0; }
@media (min-width: 768px) {
  .contact-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: clamp(32px, 5vw, 80px);
  }
}
.contact-list {
  list-style: none;
  padding: 0;
  margin: 0 0 24px;
  display: grid;
  gap: 2px;
}
.contact-list li {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: baseline;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.contact-label {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  min-width: 70px;
}
.contact-list a { font-size: 17px; overflow-wrap: anywhere; }

/* Click-to-reveal contact buttons */
.reveal {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--accent-strong);
  background: transparent;
  border: 1px dashed var(--border-strong);
  border-radius: 8px;
  padding: 8px 14px;
  min-height: 44px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.reveal:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.btn.reveal { font-family: var(--sans); border-style: solid; }
.revealed { font-size: 17px; overflow-wrap: anywhere; }

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 0;
  color: var(--muted);
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.footer-inner p { margin: 0; font-size: 14px; }
.footer-mono { font-family: var(--mono); color: var(--accent); }

/* Responsive */
@media (max-width: 639.98px) {
  body { font-size: 16px; }
  .timeline li { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .timeline .when { padding-top: 0; }
}

@media (max-width: 479.98px) {
  .cta-row .btn { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}
