/* ==========================================================================
   Design tokens
   ========================================================================== */
:root {
  --bg: #f5f3ee;
  --bg-elev: #ffffff;
  --ink: #161513;
  --ink-soft: #55524b;
  --ink-faint: #8c887f;
  --line: rgba(22, 21, 19, 0.1);
  --accent: #b4532a;
  --glow-a: rgba(220, 140, 90, 0.28);
  --glow-b: rgba(120, 150, 220, 0.2);

  --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --max: 1120px;
  --gutter: clamp(20px, 5vw, 48px);
  --radius: 999px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0e0d;
    --bg-elev: #171715;
    --ink: #f1eee7;
    --ink-soft: #b3aea4;
    --ink-faint: #7a766e;
    --line: rgba(241, 238, 231, 0.1);
    --accent: #e8875a;
    --glow-a: rgba(232, 135, 90, 0.16);
    --glow-b: rgba(110, 140, 230, 0.14);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0e0e0d;
  --bg-elev: #171715;
  --ink: #f1eee7;
  --ink-soft: #b3aea4;
  --ink-faint: #7a766e;
  --line: rgba(241, 238, 231, 0.1);
  --accent: #e8875a;
  --glow-a: rgba(232, 135, 90, 0.16);
  --glow-b: rgba(110, 140, 230, 0.14);
  color-scheme: dark;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 0.4s var(--ease), color 0.4s var(--ease);
}

/* Subtle film grain for warmth */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a { color: inherit; text-decoration: none; }
em { font-style: italic; }
h1, h2, h3 { margin: 0; font-weight: 400; }
p { margin: 0; }
ul, ol { list-style: none; margin: 0; padding: 0; }

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

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

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

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

/* ==========================================================================
   Navigation
   ========================================================================== */
.nav {
  position: fixed;
  top: 16px;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  justify-content: center;
  padding: 0 16px;
  pointer-events: none;
}

.nav__inner {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 18px;
  background: color-mix(in srgb, var(--bg-elev) 72%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(14px) saturate(160%);
  -webkit-backdrop-filter: blur(14px) saturate(160%);
  box-shadow: 0 8px 30px -12px rgba(0, 0, 0, 0.18);
}

.nav__mark {
  font-family: var(--serif);
  font-size: 22px;
  letter-spacing: 0.02em;
  margin-right: 8px;
}

.nav__links { display: flex; gap: 2px; }

.nav__links a {
  display: block;
  padding: 7px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-soft);
  border-radius: var(--radius);
  transition: color 0.25s var(--ease), background-color 0.25s var(--ease);
}
.nav__links a:hover,
.nav__links a.is-active {
  color: var(--ink);
  background: var(--line);
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: color 0.25s, background-color 0.25s;
}
.theme-toggle:hover { color: var(--ink); background: var(--line); }
.theme-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-moon { display: none; }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: block; }
}

/* ==========================================================================
   Hero
   ========================================================================== */
.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  align-items: center;
  padding: 140px 0 96px;
  overflow: hidden;
}

.hero__glow {
  position: absolute;
  inset: -20% -10% auto;
  height: 90%;
  background:
    radial-gradient(40% 50% at 25% 40%, var(--glow-a), transparent 70%),
    radial-gradient(35% 45% at 75% 30%, var(--glow-b), transparent 70%);
  filter: blur(40px);
  animation: drift 18s var(--ease) infinite alternate;
  pointer-events: none;
}

@keyframes drift {
  from { transform: translate3d(-2%, 0, 0) scale(1); }
  to   { transform: translate3d(3%, 4%, 0) scale(1.08); }
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--bg-elev) 50%, transparent);
}

.status-dot {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #3fb26b;
}
.status-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: inherit;
  animation: pulse 2.4s ease-out infinite;
}
@keyframes pulse {
  0%   { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(2.8); opacity: 0; }
}

.hero__title {
  margin-top: 28px;
  font-family: var(--serif);
  font-size: clamp(64px, 13vw, 176px);
  line-height: 0.92;
  letter-spacing: -0.035em;
}
.hero__title em { color: var(--ink-soft); }

.hero__lede {
  margin-top: 32px;
  max-width: 34ch;
  font-size: clamp(19px, 2.1vw, 24px);
  line-height: 1.45;
  color: var(--ink-soft);
}

.hero__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 28px;
  font-size: 14px;
  color: var(--ink-faint);
}
.hero__meta strong { font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; }
.hero__meta .sep { opacity: 0.5; }

.hero__cta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 40px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 13px 22px;
  font-size: 15px;
  font-weight: 500;
  border-radius: var(--radius);
  transition: transform 0.3s var(--ease), background-color 0.3s, border-color 0.3s, color 0.3s;
}
.btn:hover { transform: translateY(-2px); }
.btn--solid { background: var(--ink); color: var(--bg); }
.btn--ghost { border: 1px solid var(--line); color: var(--ink); }
.btn--ghost:hover { border-color: var(--ink-faint); }

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

.grid-2 {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 2.4fr;
  gap: clamp(32px, 6vw, 96px);
}

.section__head {
  position: sticky;
  top: 110px;
  align-self: start;
}

.section__num {
  display: block;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.section__title {
  margin-top: 8px;
  font-family: var(--serif);
  font-size: clamp(36px, 4.5vw, 52px);
  line-height: 1.05;
  letter-spacing: -0.02em;
}

/* About */
.prose { max-width: 62ch; }
.prose p + p { margin-top: 1.1em; }
.prose p { color: var(--ink-soft); }
.prose__lead {
  font-family: var(--serif);
  font-size: clamp(26px, 3vw, 34px);
  line-height: 1.3;
  color: var(--ink) !important;
  margin-bottom: 0.6em;
}

/* Experience timeline */
.timeline__item {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 24px;
  padding: 28px 0;
  border-bottom: 1px solid var(--line);
}
.timeline__item:first-child { padding-top: 0; }
.timeline__date {
  font-size: 14px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
  padding-top: 4px;
}
.timeline__role {
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}
.timeline__role .at {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 400;
  color: var(--ink-faint);
  padding: 0 2px;
}
.timeline__item p { color: var(--ink-soft); font-size: 16px; }

/* Projects */
.projects li { border-bottom: 1px solid var(--line); }
.projects li:first-child .project { padding-top: 0; }

.project {
  position: relative;
  display: grid;
  grid-template-columns: 80px 1fr auto;
  align-items: baseline;
  gap: 24px;
  padding: 28px 0;
}
.project__year {
  font-size: 14px;
  color: var(--ink-faint);
  font-variant-numeric: tabular-nums;
}
.project__body { display: flex; flex-direction: column; gap: 6px; }
.project__name {
  font-family: var(--serif);
  font-size: clamp(28px, 3.4vw, 40px);
  line-height: 1.1;
  letter-spacing: -0.015em;
  transition: transform 0.45s var(--ease), color 0.3s;
}
.project__desc { color: var(--ink-soft); font-size: 16px; }
.project__arrow {
  font-size: 22px;
  color: var(--ink-faint);
  transition: transform 0.45s var(--ease), color 0.3s;
}
.project:hover .project__name { transform: translateX(8px); }
.project:hover .project__arrow { color: var(--accent); transform: translate(4px, -4px); }

/* Contact */
.contact { text-align: left; }
.contact__title {
  margin-top: 12px;
  font-family: var(--serif);
  font-size: clamp(48px, 9vw, 120px);
  line-height: 0.98;
  letter-spacing: -0.03em;
  max-width: 12ch;
}
.contact__title em { color: var(--accent); }

.contact__email {
  display: inline-block;
  margin-top: 40px;
  font-size: clamp(20px, 2.6vw, 28px);
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 100% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  padding-bottom: 4px;
  transition: background-size 0.5s var(--ease), color 0.3s;
}
.contact__email:hover { background-size: 0% 1px; background-position: 100% 100%; color: var(--accent); }

.socials {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  margin-top: 40px;
}
.socials a {
  font-size: 15px;
  color: var(--ink-soft);
  transition: color 0.25s;
}
.socials a::after { content: " ↗"; color: var(--ink-faint); }
.socials a:hover { color: var(--ink); }

/* Footer */
.footer {
  padding: 32px 0 40px;
  border-top: 1px solid var(--line);
  font-size: 14px;
  color: var(--ink-faint);
}
.footer__inner { display: flex; justify-content: space-between; gap: 16px; }
.footer a:hover { color: var(--ink); }

/* ==========================================================================
   Reveal-on-scroll
   ========================================================================== */
.js .reveal {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
  transition-delay: var(--delay, 0s);
}
.js .reveal.is-visible { opacity: 1; transform: none; }

/* ==========================================================================
   Responsive
   ========================================================================== */
@media (max-width: 820px) {
  .grid-2 { grid-template-columns: 1fr; }
  .section__head { position: static; }
}

@media (max-width: 560px) {
  body { font-size: 16px; }
  .nav__inner { padding-left: 14px; }
  .nav__mark { margin-right: 2px; }
  .nav__links a { padding: 7px 9px; font-size: 13px; }
  .timeline__item { grid-template-columns: 1fr; gap: 6px; }
  .project { grid-template-columns: 1fr auto; gap: 8px 16px; }
  .project__year { grid-column: 1 / -1; }
  .footer__inner { flex-direction: column; }
}

@media (max-width: 380px) {
  .nav__links li:nth-child(3) { display: none; }
}

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