/* ---------------------------------------------------------------------------
   Design tokens
   A single accent color, generous whitespace, restrained type scale.
   Light and dark themes are driven by [data-theme] on <html>.
---------------------------------------------------------------------------- */
:root {
  /* Type */
  --font-sans: 'Inter Variable', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* Spacing / layout */
  --maxw: 56rem;          /* content column */
  --maxw-wide: 72rem;     /* wide sections */
  --radius: 14px;
  --radius-sm: 9px;

  /* Light theme (default) */
  --bg: #fbfbfa;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --border: #e7e7e4;
  --text: #1a1a18;
  --text-muted: #6b6b66;
  --text-faint: #9a9a93;
  --accent: #4f46e5;
  --accent-soft: rgba(79, 70, 229, 0.1);
  --accent-text: #4f46e5;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.05);
  --shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.06), 0 16px 40px rgba(0, 0, 0, 0.09);
}

:root[data-theme='dark'] {
  --bg: #0e0e10;
  --bg-elev: #161618;
  --surface: #161618;
  --border: #27272a;
  --text: #f2f2f0;
  --text-muted: #a1a1a6;
  --text-faint: #6e6e75;
  --accent: #818cf8;
  --accent-soft: rgba(129, 140, 248, 0.14);
  --accent-text: #a5b4fc;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-hover: 0 2px 4px rgba(0, 0, 0, 0.4), 0 16px 40px rgba(0, 0, 0, 0.5);
}

/* ---------------------------------------------------------------------------
   Reset / base
---------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5rem; /* offset for sticky header */
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  font-size: 1rem;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background 0.3s ease, color 0.3s ease;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}

h1, h2, h3, h4 {
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: -0.02em;
}

a {
  color: var(--accent-text);
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover { color: var(--text); }

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

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

/* ---------------------------------------------------------------------------
   Layout helpers
---------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: 1.5rem;
}
.container--wide { max-width: var(--maxw-wide); }

.section {
  padding-block: clamp(3.5rem, 8vw, 6rem);
}

.section__label {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-text);
  margin-bottom: 0.75rem;
}

.section__title {
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  margin-bottom: 2.5rem;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-faint);
}

/* Tag / chip */
.tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: var(--accent-text);
  background: var(--accent-soft);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
}

/* Button */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 550;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:hover {
  color: var(--text);
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn--primary:hover { color: #fff; opacity: 0.92; }

/* Reveal-on-scroll animation */
.reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* ===========================================================================
   COMPONENTS
=========================================================================== */

/* --- Skip link (accessibility) --- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 100;
}
.skip-link:focus { left: 0; color: #fff; }

/* --- Header --- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4rem;
}
.brand { display: inline-flex; align-items: center; gap: 0.6rem; color: var(--text); font-weight: 600; }
.brand:hover { color: var(--text); }
.brand__mark {
  display: grid; place-items: center; width: 2rem; height: 2rem;
  border-radius: 8px; background: var(--accent); color: #fff;
  font-family: var(--font-mono); font-size: 0.8rem; font-weight: 600; letter-spacing: -0.03em;
}
.brand__name { font-size: 0.95rem; letter-spacing: -0.01em; }
.nav { display: flex; gap: 0.4rem; }
.nav__link {
  color: var(--text-muted); font-size: 0.9rem; font-weight: 500;
  padding: 0.4rem 0.75rem; border-radius: var(--radius-sm);
  transition: color 0.15s ease, background 0.15s ease;
}
.nav__link:hover { color: var(--text); background: var(--accent-soft); }
.site-header__actions { display: flex; align-items: center; gap: 0.5rem; }

.nav-toggle {
  display: none; flex-direction: column; justify-content: center; gap: 5px;
  width: 2.25rem; height: 2.25rem; padding: 0 0.5rem;
  background: transparent; border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer;
}
.nav-toggle span { display: block; height: 2px; width: 100%; background: var(--text); border-radius: 2px; transition: transform 0.25s ease, opacity 0.25s ease; }
.nav-toggle.is-open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-toggle.is-open span:nth-child(2) { opacity: 0; }
.nav-toggle.is-open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

.mobile-nav { display: flex; flex-direction: column; padding: 0.5rem 1.5rem 1rem; border-bottom: 1px solid var(--border); background: var(--bg); }
.mobile-nav[hidden] { display: none; } /* respect the hidden attribute (beats .mobile-nav display) */
.mobile-nav__link { color: var(--text); padding: 0.7rem 0; border-bottom: 1px solid var(--border); font-weight: 500; }
.mobile-nav__link:last-child { border-bottom: none; }

@media (max-width: 640px) {
  .nav { display: none; }
  .nav-toggle { display: flex; }
}

/* --- Theme toggle --- */
.theme-toggle {
  position: relative;
  display: grid; place-items: center; width: 2.25rem; height: 2.25rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: transparent; color: var(--text-muted); cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.theme-toggle:hover { color: var(--text); border-color: var(--accent); }
.theme-toggle .icon { position: absolute; transition: opacity 0.2s ease, transform 0.2s ease; }
:root[data-theme='light'] .icon--sun { opacity: 0; transform: scale(0.6) rotate(-90deg); }
:root[data-theme='light'] .icon--moon { opacity: 1; }
:root[data-theme='dark'] .icon--moon { opacity: 0; transform: scale(0.6) rotate(90deg); }
:root[data-theme='dark'] .icon--sun { opacity: 1; }

/* --- Social links --- */
.socials { display: flex; align-items: center; gap: 0.4rem; list-style: none; }
.socials__link {
  display: grid; place-items: center;
  width: calc(var(--icon-size) + 1.1rem); height: calc(var(--icon-size) + 1.1rem);
  color: var(--text-muted); border-radius: var(--radius-sm);
  transition: color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.socials__link:hover { color: var(--accent-text); background: var(--accent-soft); transform: translateY(-2px); }

/* --- Hero --- */
.hero { position: relative; padding-block: clamp(4rem, 14vh, 8rem) clamp(3rem, 8vh, 5rem); overflow: hidden; }
.hero__inner { position: relative; z-index: 1; }
.hero__eyebrow { margin-bottom: 1.25rem; }
.hero__name { font-size: clamp(2.6rem, 8vw, 4.5rem); font-weight: 700; letter-spacing: -0.035em; margin-bottom: 0.5rem; }
.hero__role { font-size: clamp(1.15rem, 3vw, 1.5rem); color: var(--text); font-weight: 550; margin-bottom: 0.75rem; }
.hero__tagline { font-size: clamp(1rem, 2.5vw, 1.15rem); color: var(--text-muted); max-width: 38ch; margin-bottom: 2rem; }
.hero__actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-bottom: 2rem; }
.hero__socials { margin-left: -0.55rem; }
.hero__glow {
  position: absolute; top: -20%; right: -10%; width: 45rem; height: 45rem; max-width: 90vw;
  background: radial-gradient(circle, var(--accent-soft) 0%, transparent 65%);
  pointer-events: none; z-index: 0;
}

/* --- Sections --- */
.section--alt { background: var(--bg-elev); border-block: 1px solid var(--border); }
.prose { max-width: 60ch; }
.prose p { color: var(--text-muted); margin-bottom: 1.1rem; }
.prose p:last-child { margin-bottom: 0; }

/* --- Project grid + cards --- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1.25rem; }
.card {
  display: flex; flex-direction: column; height: 100%;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}
.card:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); transform: translateY(-3px); box-shadow: var(--shadow-hover); }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-bottom: 0.9rem; }
.card__period { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-faint); text-align: right; }
.card__title { font-size: 1.15rem; margin-bottom: 0.5rem; }
.card__desc { color: var(--text-muted); font-size: 0.92rem; flex-grow: 1; }
.card__meta { margin-top: 0.75rem; font-size: 0.82rem; color: var(--text-faint); }
.card__tags { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 1rem; list-style: none; }
.card__chip { font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-muted); border: 1px solid var(--border); border-radius: 999px; padding: 0.15rem 0.55rem; }
.card__link { display: inline-flex; align-items: center; gap: 0.35rem; margin-top: 1.25rem; font-size: 0.85rem; font-weight: 550; color: var(--accent-text); transition: gap 0.15s ease; }
.card__link:hover { gap: 0.55rem; color: var(--accent-text); }

/* --- Publications --- */
.pub { display: grid; grid-template-columns: 4.5rem 1fr; gap: 1rem; padding: 1.4rem 0; border-bottom: 1px solid var(--border); }
.pub:last-child { border-bottom: none; }
.pub__year { font-family: var(--font-mono); font-size: 0.85rem; color: var(--accent-text); padding-top: 0.2rem; }
.pub__title { font-size: 1.05rem; margin-bottom: 0.35rem; }
.pub__authors { font-size: 0.88rem; color: var(--text-muted); }
.pub__venue { font-size: 0.85rem; color: var(--text-faint); font-style: italic; margin-top: 0.1rem; }
.pub__links { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 0.6rem; }
.pub__link { font-size: 0.82rem; font-weight: 550; color: var(--accent-text); }
.pub__link:hover { color: var(--text); }
@media (max-width: 480px) { .pub { grid-template-columns: 1fr; gap: 0.25rem; } }

/* --- Resume CTA --- */
.resume-cta {
  display: flex; align-items: center; justify-content: space-between; gap: 1.5rem; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem;
}
.resume-cta__text { color: var(--text-muted); max-width: 40ch; }

/* --- Footer --- */
.site-footer { border-top: 1px solid var(--border); padding-block: 2rem; margin-top: 2rem; }
.site-footer__inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.site-footer__copy { color: var(--text-muted); font-size: 0.9rem; }
.site-footer__built { color: var(--text-faint); font-size: 0.85rem; }
@media (max-width: 560px) { .site-footer__inner { flex-direction: column; text-align: center; } }
