/* ==========================================================================
   Design tokens
   ========================================================================== */
:root {
  /* Colors: muted charcoal/navy dark theme, warm off-white accent — no purple gradients */
  --bg: #12141a;
  --bg-elevated: #191c24;
  --border: #262a35;
  --border-hover: #3a4053;
  --text-primary: #e9eaee;
  --text-secondary: #a2a7b5;
  --text-muted: #6b7080;
  --accent: #d9a441;      /* warm amber — used sparingly: CTAs, highlights, active states */
  --accent-soft: rgba(217, 164, 65, 0.12);
  --accent-ring: rgba(217, 164, 65, 0.45);

  /* Type — fluid modular scale, ~1.25-1.6 ratio between tiers */
  --font-heading: "Space Grotesk", "Segoe UI", sans-serif;
  --font-body: "Inter", "Segoe UI", sans-serif;
  --fs-eyebrow: 0.875rem;
  --fs-body: 1rem;
  --fs-lead: 1.125rem;
  --fs-h3: 1.25rem;
  --fs-h2: clamp(1.75rem, 1.55rem + 1vw, 2.25rem);
  --fs-hero: clamp(2.5rem, 1.9rem + 2.6vw, 3.75rem);

  /* Spacing — 8px grid */
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 48px;
  --space-6: 64px;
  --space-7: 96px;

  /* Layout */
  --max-width: 880px;
  --radius: 10px;
  --nav-height: 72px;
  --nav-height-scrolled: 56px;

  /* Motion — physical, decelerating easing; never linear or default ease-in-out */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-snappy: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-fast: 180ms;
  --dur-base: 220ms;
  --dur-slow: 500ms;
}

/* ==========================================================================
   Reset & base
   ========================================================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

ul {
  list-style: none;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--space-3);
}

/* Offset scroll target so the sticky nav never covers a heading */
section[id] {
  scroll-margin-top: calc(var(--nav-height-scrolled) + var(--space-3));
}

/* Custom focus states — visible ring, not the browser default outline */
a:focus-visible,
button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-ring);
  border-radius: 4px;
}

/* ==========================================================================
   Header / Nav
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: transparent;
  border-bottom: 1px solid transparent;
  transition: background var(--dur-base) var(--ease-snappy),
              border-color var(--dur-base) var(--ease-snappy);
}

.site-header.is-scrolled {
  background: rgba(18, 20, 26, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--nav-height);
  transition: height var(--dur-base) var(--ease-snappy);
}

.site-header.is-scrolled .nav {
  height: var(--nav-height-scrolled);
}

.nav-brand {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
}

.nav-links {
  display: flex;
  gap: var(--space-4);
}

.nav-links a {
  position: relative;
  display: inline-block;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 4px 0;
  transition: color var(--dur-fast) var(--ease-snappy);
}

/* Underline draws in from the left on hover/active, not a color swap */
.nav-links a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--dur-base) var(--ease-snappy);
}

.nav-links a:hover,
.nav-links a:focus-visible {
  color: var(--text-primary);
}

.nav-links a:hover::after,
.nav-links a:focus-visible::after {
  transform: scaleX(1);
}

/* Scrollspy: current section highlighted in accent, underline stays drawn */
.nav-links a.is-active {
  color: var(--accent);
}

.nav-links a.is-active::after {
  transform: scaleX(1);
}

/* Scroll progress bar — thin strip under the nav, scaled via transform (GPU) */
.scroll-progress {
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 100%;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  will-change: transform;
}

/* Mobile hamburger — hidden on desktop */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 32px;
  height: 32px;
  background: none;
  border: none;
  cursor: pointer;
}

.nav-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  background: var(--text-primary);
  transition: transform var(--dur-base) var(--ease-snappy), opacity var(--dur-fast) var(--ease-snappy);
}

/* ==========================================================================
   Hero
   ========================================================================== */
.hero {
  position: relative;
  padding: var(--space-7) var(--space-3) var(--space-6);
  overflow: hidden;
}

/* Very subtle grain texture behind the hero content — not flat black */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.eyebrow {
  color: var(--accent);
  font-size: var(--fs-eyebrow);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: var(--space-1);
}

.hero-name {
  font-family: var(--font-heading);
  font-size: var(--fs-hero);
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: var(--space-2);
}

.hero-tagline {
  font-size: var(--fs-h3);
  color: var(--text-secondary);
  font-weight: 500;
  margin-bottom: var(--space-3);
}

.hero-intro {
  max-width: 620px;
  color: var(--text-secondary);
  font-size: var(--fs-lead);
  line-height: 1.7;
  margin-bottom: var(--space-5);
}

.hero-actions {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

/* Hero load stagger: each .hero-item fades/slides up once, on first load only.
   Delays step by ~70ms via nth-child; JS adds .is-loaded to trigger it. */
.hero-item {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out);
}

.hero.is-loaded .hero-item {
  opacity: 1;
  transform: translateY(0);
}

.hero.is-loaded .hero-item:nth-child(1) { transition-delay: 0ms; }
.hero.is-loaded .hero-item:nth-child(2) { transition-delay: 70ms; }
.hero.is-loaded .hero-item:nth-child(3) { transition-delay: 140ms; }
.hero.is-loaded .hero-item:nth-child(4) { transition-delay: 210ms; }
.hero.is-loaded .hero-item:nth-child(5) { transition-delay: 280ms; }

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  display: inline-block;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 600;
  transition: transform var(--dur-base) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out),
              background var(--dur-base) var(--ease-snappy),
              border-color var(--dur-base) var(--ease-snappy);
}

.btn-primary {
  background: var(--accent);
  color: #1a1503;
  /* #primaryCta also gets a small magnetic pull toward the cursor, see script.js */
}

.btn-primary:hover {
  transform: translateY(-2px);
  background: #e6b355;
  box-shadow: 0 12px 24px -8px rgba(217, 164, 65, 0.45);
}

.btn-ghost {
  border: 1px solid var(--border);
  color: var(--text-primary);
}

.btn-ghost:hover {
  transform: translateY(-2px);
  border-color: var(--border-hover);
  box-shadow: 0 12px 24px -12px rgba(0, 0, 0, 0.5);
}

/* ==========================================================================
   Mission statement — short, standalone, generous whitespace
   ========================================================================== */
.mission {
  padding-top: var(--space-6);
  padding-bottom: var(--space-6);
  border-top: 1px solid var(--border);
  text-align: center;
}

.mission-statement {
  max-width: 640px;
  margin: 0 auto;
  font-family: var(--font-heading);
  font-size: clamp(1.35rem, 1.1rem + 1.2vw, 1.85rem);
  font-weight: 500;
  line-height: 1.45;
  color: var(--text-primary);
}

/* ==========================================================================
   Featured story (InThink) — more visual weight than a grid card
   ========================================================================== */
.story-kicker {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--space-1);
}

.story-text {
  max-width: 680px;
  color: var(--text-secondary);
  font-size: var(--fs-lead);
  line-height: 1.7;
  margin: var(--space-2) 0 var(--space-3);
}

.story-links {
  display: flex;
  gap: var(--space-2);
}

/* ==========================================================================
   Sections (shared)
   ========================================================================== */
.section {
  padding: var(--space-6) var(--space-3);
  border-top: 1px solid var(--border);
}

.section-title {
  font-family: var(--font-heading);
  font-size: var(--fs-h2);
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.section-subtitle {
  color: var(--text-secondary);
  font-size: var(--fs-body);
  margin-bottom: var(--space-5);
}

/* ==========================================================================
   Projects
   ========================================================================== */
.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-3);
}

.project-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4);
  transition: transform var(--dur-base) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out),
              border-color var(--dur-base) var(--ease-out);
}

.project-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-hover);
  box-shadow: 0 16px 32px -16px rgba(0, 0, 0, 0.6);
}

.project-status {
  display: inline-block;
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 4px 10px;
  border-radius: 6px;
  margin-bottom: var(--space-2);
}

.project-status--live {
  color: var(--accent);
  background: var(--accent-soft);
}

.project-title {
  font-family: var(--font-heading);
  font-size: var(--fs-h3);
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.project-desc {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.65;
  margin-bottom: var(--space-2);
}

.project-skill {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.project-skill span {
  color: var(--accent);
  font-weight: 600;
}

.project-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-2);
}

.project-links a {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 1px solid var(--accent);
  transition: color var(--dur-fast) var(--ease-snappy);
}

.project-links a:hover {
  color: var(--accent);
}

/* Genuine "coming soon" card — desaturated, with a pulsing status dot
   instead of repeated placeholder text */
.project-card--placeholder {
  border-style: dashed;
  color: var(--text-muted);
  filter: saturate(0.85);
}

.project-card--placeholder h3 {
  font-family: var(--font-heading);
  font-size: var(--fs-h3);
  color: var(--text-secondary);
  margin: var(--space-2) 0 var(--space-1);
}

.project-card--placeholder p {
  font-size: 0.92rem;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  position: relative;
}

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

@keyframes pulse-dot {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(2.6); opacity: 0; }
}

/* Stagger the grid's entrance left-to-right (~80ms per card) when a section
   reveals — see .reveal / .is-visible below */
.project-grid > *:nth-child(1) { transition-delay: 0ms; }
.project-grid > *:nth-child(2) { transition-delay: 80ms; }
.project-grid > *:nth-child(3) { transition-delay: 160ms; }
.project-grid > *:nth-child(4) { transition-delay: 240ms; }
.project-grid > *:nth-child(5) { transition-delay: 320ms; }

/* ==========================================================================
   Learning badges
   ========================================================================== */
.badge-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.badge {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: border-color var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out);
}

.badge:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.badge-list > *:nth-child(1) { transition-delay: 0ms; }
.badge-list > *:nth-child(2) { transition-delay: 80ms; }
.badge-list > *:nth-child(3) { transition-delay: 160ms; }

/* ==========================================================================
   Timeline — horizontal on desktop, stacked on mobile, with a connecting line
   ========================================================================== */
.timeline-list {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-3);
  position: relative;
}

.timeline-list::before {
  content: "";
  position: absolute;
  top: 19px; /* centers on the icon row */
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  display: flex;
  flex-direction: column;
}

.timeline-icon {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--accent);
  margin-bottom: var(--space-2);
  transition: border-color var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}

.timeline-icon svg {
  width: 18px;
  height: 18px;
}

.timeline-item:hover .timeline-icon {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.timeline-date {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.02em;
  margin-bottom: var(--space-1);
}

.timeline-title {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.timeline-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.timeline-list > *:nth-child(1) { transition-delay: 0ms; }
.timeline-list > *:nth-child(2) { transition-delay: 80ms; }
.timeline-list > *:nth-child(3) { transition-delay: 160ms; }
.timeline-list > *:nth-child(4) { transition-delay: 240ms; }

/* ==========================================================================
   About
   ========================================================================== */
.about-content {
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  color: var(--text-secondary);
  line-height: 1.7;
}

/* ==========================================================================
   Contact
   ========================================================================== */
.contact-links {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  max-width: 420px;
}

.contact-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 22px;
  transition: transform var(--dur-base) var(--ease-out),
              box-shadow var(--dur-base) var(--ease-out),
              border-color var(--dur-base) var(--ease-out);
}

.contact-link:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 16px 32px -18px rgba(0, 0, 0, 0.6);
}

.contact-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.contact-value {
  font-weight: 600;
  font-size: 0.95rem;
}

.contact-links > *:nth-child(1) { transition-delay: 0ms; }
.contact-links > *:nth-child(2) { transition-delay: 80ms; }

/* ==========================================================================
   Footer
   ========================================================================== */
.site-footer {
  text-align: center;
  padding: var(--space-4) var(--space-3);
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
}

/* ==========================================================================
   Scroll-reveal (section-level, progressive enhancement — see script.js)
   Each section fades/slides up the first time it enters the viewport;
   children with the nth-child rules above cascade in on the same trigger.
   ========================================================================== */
.reveal,
.reveal .project-grid > *,
.reveal .badge-list > *,
.reveal .contact-links > *,
.reveal .timeline-list > * {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out);
}

.reveal.is-visible,
.reveal.is-visible .project-grid > *,
.reveal.is-visible .badge-list > *,
.reveal.is-visible .contact-links > *,
.reveal.is-visible .timeline-list > * {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================================================
   Responsive — mobile nav & spacing
   ========================================================================== */
@media (max-width: 640px) {
  .nav-toggle {
    display: flex;
  }

  .nav-links {
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    flex-direction: column;
    gap: 0;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--dur-base) var(--ease-snappy);
  }

  .site-header.is-scrolled .nav-links {
    top: var(--nav-height-scrolled);
  }

  .nav-links.is-open {
    max-height: 260px;
  }

  .nav-links li {
    border-top: 1px solid var(--border);
  }

  .nav-links a {
    display: block;
    padding: 16px var(--space-3);
  }

  .nav-links a::after {
    display: none;
  }

  .hero {
    padding: var(--space-6) var(--space-2) var(--space-5);
  }

  .section {
    padding: var(--space-5) var(--space-2);
  }

  .timeline-list {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }

  .timeline-list::before {
    top: 0;
    bottom: 0;
    left: 19px;
    right: auto;
    width: 1px;
    height: auto;
  }

  .timeline-item {
    padding-left: var(--space-5);
  }

  .timeline-icon {
    position: absolute;
    left: 0;
    top: 0;
    margin-bottom: 0;
  }
}

/* ==========================================================================
   Reduced motion — shorten/disable non-essential animation
   ========================================================================== */
@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;
    transition-delay: 0ms !important;
    scroll-behavior: auto !important;
  }

  .hero-item,
  .reveal,
  .reveal .project-grid > *,
  .reveal .badge-list > *,
  .reveal .contact-links > *,
  .reveal .timeline-list > * {
    opacity: 1;
    transform: none;
  }
}
