/* ---------- Tokens ---------- */
:root {
  color-scheme: dark;
  --bg: #0d0e10;
  --bg-raised: #15171a;
  --bg-card: #1a1c20;
  --line: #2a2d32;
  --line-strong: #3a3e44;
  --text: #ecedef;
  --text-muted: #a6abb2;
  --text-faint: #8a9098;
  --accent: #f0b44c;
  --accent-strong: #ffc766;
  --accent-ink: #1a1305;
  --accent-soft: rgba(240, 180, 76, 0.12);

  --radius: 14px;
  --radius-sm: 8px;
  --max: 1080px;
  --gutter: clamp(16px, 4vw, 32px);
  --header-h: 64px;

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-h) + 16px);
  -webkit-text-size-adjust: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3, h4 { line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
p { margin: 0 0 1em; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: inherit; }
svg { flex-shrink: 0; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.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;
}

.skip-link {
  position: absolute; left: 16px; top: -48px; z-index: 100;
  background: var(--accent); color: var(--accent-ink);
  padding: 10px 16px; border-radius: var(--radius-sm);
  font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 12px; }

.container { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); }
.container.narrow { max-width: 780px; }

/* ---------- Header / nav ---------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(13, 14, 16, 0.82);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s ease;
}
.site-header.scrolled { border-bottom-color: var(--line); }

.nav {
  height: var(--header-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}

.brand {
  display: inline-flex; align-items: center; gap: 10px;
  text-decoration: none; font-weight: 600;
}
.brand-mark {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, #5b6068, #26292e);
  border: 1px solid var(--line-strong);
  font-size: .8rem; font-weight: 800; letter-spacing: .02em;
}

.nav-menu { display: flex; gap: 4px; }
.nav-menu a {
  display: block; padding: 8px 14px; border-radius: 999px;
  text-decoration: none; color: var(--text-muted); font-size: .95rem; font-weight: 500;
  transition: color .15s ease, background-color .15s ease;
}
.nav-menu a:hover { color: var(--text); background: var(--bg-card); }
.nav-menu a[aria-current="true"] { color: var(--accent); }

.nav-toggle {
  display: none;
  width: 44px; height: 44px; border-radius: 10px;
  background: transparent; border: 1px solid var(--line-strong);
  color: var(--text); cursor: pointer; position: relative;
}
.nav-toggle-bar,
.nav-toggle-bar::before,
.nav-toggle-bar::after {
  position: absolute; left: 50%; width: 18px; height: 2px; margin-left: -9px;
  background: currentColor; border-radius: 2px; content: "";
  transition: transform .2s ease, opacity .2s ease;
}
.nav-toggle-bar { top: 50%; margin-top: -1px; }
.nav-toggle-bar::before { top: -6px; left: 0; margin-left: 0; }
.nav-toggle-bar::after { top: 6px; left: 0; margin-left: 0; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar { background: transparent; }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar::before { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] .nav-toggle-bar::after { transform: translateY(-6px) rotate(-45deg); }

@media (max-width: 760px) {
  .nav-toggle { display: block; }
  .nav-menu {
    position: absolute; top: var(--header-h); left: 0; right: 0;
    flex-direction: column; gap: 0;
    padding: 8px var(--gutter) 16px;
    background: var(--bg-raised); border-bottom: 1px solid var(--line);
    display: none;
  }
  .nav-menu.open { display: flex; }
  .nav-menu a { padding: 14px 12px; border-radius: var(--radius-sm); font-size: 1rem; }
}

/* ---------- Buttons & links ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 48px; padding: 12px 22px; border-radius: 999px;
  font-weight: 600; font-size: 1rem; text-decoration: none;
  transition: background-color .15s ease, border-color .15s ease, transform .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-strong); }
.btn-ghost { border: 1px solid var(--line-strong); color: var(--text); }
.btn-ghost:hover { border-color: var(--text-faint); background: var(--bg-card); }

.link-arrow {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--accent); font-weight: 600; text-decoration: none;
}
.link-arrow::after { content: "→"; transition: transform .15s ease; }
.link-arrow:hover { text-decoration: underline; text-underline-offset: 4px; }
.link-arrow:hover::after { transform: translateX(3px); }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding: clamp(64px, 12vw, 128px) 0 clamp(56px, 9vw, 96px);
  background:
    radial-gradient(900px 480px at 85% -10%, rgba(255, 255, 255, 0.06), transparent 60%),
    radial-gradient(700px 400px at -10% 110%, rgba(240, 180, 76, 0.06), transparent 60%);
}
.hero-grid {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  align-items: center; gap: clamp(32px, 5vw, 64px);
}
.hero-text { min-width: 0; }
.hero-photo { order: 2; position: relative; }
.hero-photo img {
  display: block; width: 300px; height: 300px; object-fit: cover;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  box-shadow:
    0 0 0 8px var(--bg-raised),
    0 0 0 9px var(--line),
    0 24px 60px -12px rgba(0, 0, 0, 0.7);
  background: #3b3e43;
}
/* A short amber arc on the ring: the one accent on the portrait */
.hero-photo::after {
  content: ""; position: absolute; inset: -9px; border-radius: 50%;
  border: 2px solid transparent; border-top-color: var(--accent); border-right-color: var(--accent);
  transform: rotate(20deg); opacity: .9; pointer-events: none;
  -webkit-mask: linear-gradient(135deg, #000 30%, transparent 60%);
          mask: linear-gradient(135deg, #000 30%, transparent 60%);
}

@media (max-width: 900px) {
  .hero-photo img { width: 220px; height: 220px; }
}
@media (max-width: 760px) {
  .hero-grid { grid-template-columns: 1fr; gap: 28px; }
  .hero-photo { order: 0; justify-self: start; }
  .hero-photo img { width: 132px; height: 132px; box-shadow: 0 0 0 5px var(--bg-raised), 0 0 0 6px var(--line), 0 16px 40px -12px rgba(0,0,0,.7); }
  .hero-photo::after { inset: -6px; }
}

.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: .85rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--accent); margin-bottom: 20px;
}
.eyebrow::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft);
}
.hero h1 {
  font-size: clamp(2.6rem, 8vw, 5rem);
  font-weight: 800; letter-spacing: -0.035em; line-height: 1.02;
  background: linear-gradient(180deg, #ffffff 30%, #9ca1a8);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.headline {
  margin: 18px 0 0;
  font-size: clamp(1.05rem, 2.4vw, 1.35rem); font-weight: 600; color: var(--text);
}
.headline .hl { white-space: nowrap; }
.headline .sep { color: var(--text-faint); margin: 0 .5em; font-weight: 400; }
@media (max-width: 560px) {
  .headline .hl { display: block; }
  .headline .hl + .sep + .hl { margin-top: 2px; }
  .headline .sep { display: none; }
}
.pitch {
  max-width: 640px; margin: 16px 0 32px;
  font-size: clamp(1.05rem, 2vw, 1.2rem); color: var(--text-muted);
}
.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }

.stats {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px;
  margin-top: clamp(40px, 7vw, 64px); max-width: 780px;
}
.stats li {
  padding: 18px 20px; border-radius: var(--radius);
  background: var(--bg-raised); border: 1px solid var(--line);
}
.stats strong {
  display: block; font-size: clamp(1.5rem, 3.4vw, 2rem); font-weight: 800;
  letter-spacing: -0.02em; color: var(--text);
}
.stats span { font-size: .9rem; color: var(--text-muted); line-height: 1.4; display: block; margin-top: 4px; }

@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr; }
  .stats li { display: flex; align-items: baseline; gap: 14px; padding: 14px 18px; }
  .stats strong { min-width: 84px; }
  .stats span { margin-top: 0; }
  .hero-actions .btn { width: 100%; justify-content: center; }
}

/* The "Gray Area": a ten-step grayscale ramp ending in the accent */
.grayscale-bar {
  position: absolute; left: 0; right: 0; bottom: 0; height: 4px;
  background: linear-gradient(90deg,
    #111 0 10%, #1e1f22 10% 20%, #2c2e32 20% 30%, #3b3e43 30% 40%, #4c4f55 40% 50%,
    #5e6168 50% 60%, #72767d 60% 70%, #898d94 70% 80%, #a4a8ae 80% 90%, var(--accent) 90% 100%);
}

/* ---------- Sections ---------- */
.section { padding: clamp(64px, 10vw, 112px) 0; border-top: 1px solid var(--line); }
.hero + .section { border-top: 0; }

.section-title {
  display: flex; align-items: baseline; gap: 14px;
  font-size: clamp(1.75rem, 4vw, 2.4rem); font-weight: 800; letter-spacing: -0.025em;
  margin-bottom: 28px;
}
.section-title .num {
  font-size: .9rem; font-weight: 600; color: var(--accent);
  font-variant-numeric: tabular-nums; letter-spacing: .04em;
}
.section-intro { color: var(--text-muted); max-width: 720px; margin-bottom: 32px; }

.lead { font-size: clamp(1.15rem, 2.4vw, 1.35rem); color: var(--text); font-weight: 500; line-height: 1.5; }
#about p:not(.lead), .beyond p { color: var(--text-muted); }

/* ---------- Experience ---------- */
.timeline { display: grid; gap: 20px; }
.job {
  position: relative;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 24px;
  padding: clamp(20px, 3.5vw, 32px);
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius);
}
.job::before {
  content: ""; position: absolute; left: -1px; top: 28px; bottom: 28px; width: 3px;
  border-radius: 3px; background: var(--line-strong);
}
.job:first-child::before { background: var(--accent); }
.job-head { grid-column: 1; }
.job h3 { font-size: clamp(1.1rem, 2.2vw, 1.3rem); font-weight: 700; }
.job-meta { margin: 8px 0 0; color: var(--text-muted); font-size: .98rem; }
.job-meta .org { color: var(--text); font-weight: 600; }
.job-dates {
  margin: 6px 0 0; font-size: .88rem; font-weight: 600; color: var(--text-faint);
  font-variant-numeric: tabular-nums; letter-spacing: .02em;
}
.job-highlights {
  grid-column: 2; grid-row: 1;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end;
}
.job-highlights li {
  padding: 6px 12px; border-radius: 999px; white-space: nowrap;
  background: var(--accent-soft); border: 1px solid rgba(240, 180, 76, 0.28);
  color: var(--text); font-size: .85rem;
}
.job-highlights strong { color: var(--accent); }
.job-points { grid-column: 1 / -1; margin-top: 16px; display: grid; gap: 10px; }
.job-points li {
  position: relative; padding-left: 20px; color: var(--text-muted); font-size: 1rem;
}
.job-points li::before {
  content: ""; position: absolute; left: 2px; top: .7em;
  width: 6px; height: 6px; border-radius: 2px; background: var(--text-faint);
}

@media (max-width: 760px) {
  .job { grid-template-columns: 1fr; }
  .job-highlights { grid-column: 1; grid-row: auto; flex-direction: row; flex-wrap: wrap; align-items: flex-start; margin-top: 8px; }
  .job-highlights li { white-space: normal; }
}

.earlier {
  margin: 20px 0 0; padding: 16px 20px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius);
  color: var(--text-muted); font-size: .95rem;
}
.earlier span { color: var(--text); font-weight: 600; }

/* ---------- Projects ---------- */
.projects { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 20px; }
.projects > .project { grid-column: span 2; }
.projects > .project.featured { grid-column: span 3; }
@media (max-width: 980px) {
  .projects { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .projects > .project, .projects > .project.featured { grid-column: auto; }
  .projects > .project:last-child { grid-column: 1 / -1; }
}
@media (max-width: 660px) { .projects { grid-template-columns: 1fr; } }

.project {
  display: flex; flex-direction: column;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .2s ease, transform .2s ease;
}
.project:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.project-top {
  padding: 24px 24px 20px;
  background: linear-gradient(180deg, var(--bg-card), var(--bg-raised));
  border-bottom: 1px solid var(--line);
}
.project h3 { font-size: 1.3rem; font-weight: 700; margin-bottom: 10px; }
.project-what { margin: 0; color: var(--text); font-size: .98rem; }
.project-body { padding: 20px 24px; flex: 1; }
.project h4 {
  font-size: .78rem; text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-faint); font-weight: 700; margin: 0 0 8px;
}
.project-body p { color: var(--text-muted); font-size: .95rem; margin-bottom: 20px; }
.project-links {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  padding: 16px 24px; border-top: 1px solid var(--line);
}
.private-note { font-size: .82rem; color: var(--text-faint); }

/* ---------- Tags ---------- */
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tags li {
  padding: 5px 12px; border-radius: 999px;
  background: var(--bg-card); border: 1px solid var(--line);
  font-size: .85rem; color: var(--text); line-height: 1.4;
}

/* ---------- Skills ---------- */
.skills-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
@media (max-width: 700px) { .skills-grid { grid-template-columns: 1fr; } }
.skill-group {
  padding: 24px; border-radius: var(--radius);
  background: var(--bg-raised); border: 1px solid var(--line);
}
.skill-group h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: 14px; }

.certs-title { font-size: 1.05rem; font-weight: 700; margin: 40px 0 14px; }
.certs { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.certs li {
  display: flex; flex-direction: column; gap: 2px;
  padding: 14px 16px 14px 18px; border-radius: var(--radius-sm);
  background: var(--bg-raised); border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
}
.cert-name { font-weight: 600; font-size: .98rem; }
.cert-issuer { font-size: .85rem; color: var(--text-faint); }

/* ---------- Beyond ---------- */
.beyond {
  padding: 28px; border-radius: var(--radius);
  background:
    linear-gradient(90deg, rgba(255,255,255,0.04), transparent 60%),
    var(--bg-raised);
  border: 1px solid var(--line);
}
.beyond p { margin-bottom: 16px; }
.beyond strong { color: var(--text); }

/* ---------- Contact ---------- */
.contact-list { display: grid; gap: 12px; margin-top: 28px; }
.contact-list a {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 20px; border-radius: var(--radius);
  background: var(--bg-raised); border: 1px solid var(--line);
  text-decoration: none; word-break: break-word;
  transition: border-color .15s ease, background-color .15s ease;
}
.contact-list a:hover { border-color: var(--accent); background: var(--bg-card); }
.contact-list svg { color: var(--accent); }
.contact-label {
  display: block; font-size: .78rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-faint);
}

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 28px 0; font-size: .9rem; color: var(--text-faint); }
.site-footer .container { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; }
.site-footer p { margin: 0; }
.site-footer a { color: var(--text-muted); }
.site-footer a:hover { color: var(--accent); }

/* ---------- Case study page ---------- */
.case-hero {
  padding: clamp(48px, 8vw, 88px) 0 clamp(32px, 5vw, 48px);
  background: radial-gradient(700px 360px at 90% -10%, rgba(255, 255, 255, 0.05), transparent 60%);
  border-bottom: 1px solid var(--line);
}
.back-link { display: inline-block; margin-bottom: 28px; color: var(--text-muted); text-decoration: none; font-size: .95rem; }
.back-link:hover { color: var(--accent); }
.case-hero h1 { font-size: clamp(2rem, 5vw, 3rem); font-weight: 800; letter-spacing: -0.03em; line-height: 1.1; }
.case-hero .pitch { margin-bottom: 28px; }
.case-facts {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0;
}
@media (max-width: 560px) { .case-facts { grid-template-columns: 1fr; } }
.case-facts div { padding: 14px 16px; border-radius: var(--radius-sm); background: var(--bg-raised); border: 1px solid var(--line); }
.case-facts dt { font-size: .75rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--text-faint); }
.case-facts dd { margin: 4px 0 0; font-weight: 600; }
.case-facts a { color: var(--accent); }

.case-body { padding-top: clamp(40px, 6vw, 64px); padding-bottom: clamp(56px, 8vw, 96px); }
.case-body section { margin-bottom: clamp(44px, 6vw, 64px); }
.case-body h2 { font-size: clamp(1.45rem, 3.2vw, 1.85rem); font-weight: 800; letter-spacing: -0.02em; margin-bottom: 16px; }
.case-body h3 { font-size: 1.1rem; font-weight: 700; margin: 32px 0 12px; color: var(--accent); }
.case-body p { color: var(--text-muted); }
.case-body p strong, .case-body li strong { color: var(--text); }
.case-body a { color: var(--accent); }
.case-body code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .88em;
  padding: 1px 6px; border-radius: 5px; background: var(--bg-card); border: 1px solid var(--line); color: var(--text);
}
.principles { list-style: none; counter-reset: p; display: grid; gap: 12px; }
.principles li {
  counter-increment: p; position: relative; padding: 18px 20px 18px 60px;
  border-radius: var(--radius); background: var(--bg-raised); border: 1px solid var(--line); color: var(--text-muted);
}
.principles li::before {
  content: counter(p, decimal-leading-zero); position: absolute; left: 20px; top: 18px;
  font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums;
}
.decision {
  padding: 20px 22px; margin-bottom: 14px; border-radius: var(--radius);
  background: var(--bg-raised); border: 1px solid var(--line); border-left: 3px solid var(--accent);
}
.decision p { margin-bottom: 10px; font-size: .98rem; }
.decision p:last-child { margin-bottom: 0; }
.decision .rule { color: var(--text); font-size: 1.02rem; }
.decision .label { color: var(--text); font-weight: 700; }
.case-list { display: grid; gap: 10px; margin-top: 4px; }
.case-list li { position: relative; padding-left: 20px; color: var(--text-muted); }
.case-list li::before {
  content: ""; position: absolute; left: 2px; top: .7em; width: 6px; height: 6px; border-radius: 2px; background: var(--accent);
}
.case-close { padding: 28px; border-radius: var(--radius); background: var(--bg-raised); border: 1px solid var(--line); }
.case-close .hero-actions { margin-top: 20px; }

/* Case-study link on the project card */
.project-links .case-link { flex-basis: 100%; }
.case-hero .eyebrow { display: flex; }
.case-body .btn-primary { color: var(--accent-ink); }
.case-body .btn-ghost { color: var(--text); }
