/* ---------- Tokens ---------- */
:root {
  --bg: #F6F3EC;
  --surface: #FFFDF8;
  --ink: #14213D;
  --muted: #4A5670;
  --accent: #E8590C;
  --accent-text: #B43E00;
  --rule: #D9D2C3;
  --glow: rgba(232, 89, 12, .14);
  --radius: 2px;
  --lamp-red: #E5484D;
  --lamp-amber: #F5A524;
  --lamp-green: #30A46C;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E1420;
    --surface: #161E2E;
    --ink: #E9EEF5;
    --muted: #A9B4C7;
    --accent: #FF7A2F;
    --accent-text: #FF9A5C;
    --rule: #2A3447;
    --glow: rgba(255, 122, 47, .16);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0E1420;
  --surface: #161E2E;
  --ink: #E9EEF5;
  --muted: #A9B4C7;
  --accent: #FF7A2F;
  --accent-text: #FF9A5C;
  --rule: #2A3447;
  --glow: rgba(255, 122, 47, .16);
  color-scheme: dark;
}

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

html { -webkit-text-size-adjust: 100%; }
html.js:not(.reduce) { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Manrope, system-ui, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: clamp(1rem, .96rem + .2vw, 1.0625rem);
  line-height: 1.6;
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: inherit; }

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

h1 {
  font-size: clamp(2.5rem, 1.4rem + 5vw, 5.5rem);
  font-weight: 800;
  letter-spacing: -.035em;
  line-height: 1.02;
  overflow-wrap: anywhere;
}
h2 {
  font-size: clamp(1.75rem, 1.2rem + 2.2vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.1;
}
h3 {
  font-size: clamp(1.25rem, 1.05rem + .8vw, 1.6rem);
  font-weight: 700;
  line-height: 1.25;
}

/* ---------- Scroll progress ---------- */
.progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  transform-origin: 0 50%;
  transform: scaleX(0);
  z-index: 60;
  pointer-events: none;
}

/* ---------- Cursor glow (fine pointer only) ---------- */
.cursor-glow {
  display: none;
  position: fixed;
  left: 0;
  top: 0;
  width: 560px;
  height: 560px;
  margin: -280px 0 0 -280px;
  border-radius: 50%;
  background: radial-gradient(closest-side, var(--glow), transparent);
  pointer-events: none;
  z-index: -1;
  opacity: 0;
  transition: opacity .4s ease;
  will-change: transform;
}
.cursor-glow.is-on { opacity: 1; }
@media (hover: hover) and (pointer: fine) {
  html.js:not(.reduce) .cursor-glow { display: block; }
}

/* ---------- Header and nav ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px max(16px, calc((100% - 1120px) / 2));
  background: var(--bg);
  border-bottom: 1px solid var(--rule);
}

.nav {
  display: flex;
  flex-wrap: wrap;
  flex: 1 1 auto;
  gap: 4px 12px;
  min-width: 0;
  font-size: .875rem;
}
.nav a {
  padding: 6px 4px;
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color .2s, border-color .2s;
}
.nav a:hover {
  color: var(--accent-text);
  border-bottom-color: var(--accent);
}

.theme-toggle {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: border-color .2s, color .2s;
}
.theme-toggle:hover {
  color: var(--accent-text);
  border-color: var(--accent);
}
.icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: block; }
  :root:not([data-theme="light"]) .icon-moon { display: none; }
}
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }
html:not(.js) .theme-toggle { display: none; }

/* ---------- Layout ---------- */
.section {
  position: relative;
  width: min(1120px, 100% - 32px);
  margin-inline: auto;
  padding: clamp(64px, 9vw, 128px) 0;
  scroll-margin-top: 80px;
}
.section__title { margin-bottom: clamp(24px, 4vw, 48px); }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 24px;
  min-height: min(100vh, 760px);
  min-height: min(100svh, 760px);
  padding: clamp(72px, 12vw, 140px) 0 clamp(48px, 8vw, 96px);
  scroll-margin-top: 80px;
}

.hero__canvas {
  position: absolute;
  top: 45%;
  left: 0;
  width: 100%;
  height: 55%;
  opacity: .35;
  pointer-events: none;
  display: block;
}

.hero__name,
.hero__facts {
  position: relative;
  z-index: 1;
  width: min(1120px, 100% - 32px);
  margin-inline: auto;
}
.hero__name { isolation: isolate; }
.hero__name::before {
  content: "";
  position: absolute;
  inset: -48px -80px;
  z-index: -1;
  background: radial-gradient(closest-side, var(--bg) 55%, transparent);
  pointer-events: none;
}

.hero__facts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 0;
  font-size: 1.0625rem;
}
.hero__facts li {
  display: flex;
  align-items: center;
}
.hero__facts li + li::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  margin: 0 14px;
  background: var(--accent);
  transform: rotate(45deg);
}
.hero__facts a {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
  overflow-wrap: anywhere;
}

@media (min-width: 900px) {
  .hero__canvas {
    top: 0;
    left: 40%;
    width: 60%;
    height: 100%;
    opacity: 1;
  }
}

/* ---------- Experience and metro ---------- */
.experience {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}
.experience > .section__title { grid-row: 1; grid-column: 1; }
.experience > .stations { grid-row: 2; grid-column: 1; }

.metro {
  grid-row: 2;
  grid-column: 1;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}
.metro__base {
  fill: none;
  stroke: var(--rule);
  stroke-width: 3;
}
.metro__track {
  fill: none;
  stroke: var(--accent);
  stroke-width: 3;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
}
.station-dot {
  fill: var(--surface);
  stroke: var(--rule);
  stroke-width: 3;
  transition: fill .4s ease, stroke .4s ease;
}
.station-dot.is-lit {
  fill: var(--accent);
  stroke: var(--accent);
}
.train__body { fill: var(--ink); }
.train__nose { fill: var(--accent); }

.stations {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(32px, 5vw, 56px);
}

.station {
  position: relative;
  min-width: 0;
  padding-left: 32px;
  perspective: 900px;
}

.card {
  position: relative;
  min-width: 0;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
.station .card {
  padding-right: 44px;
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
  transition: transform .35s ease-out;
}

.card h3 { margin-bottom: 4px; }
.card__meta,
.kicker {
  margin-bottom: 8px;
  font-size: .875rem;
  letter-spacing: .02em;
  color: var(--muted);
}
.kicker {
  color: var(--accent-text);
  font-weight: 600;
}
.card__desc { margin-bottom: 12px; }
.card__list {
  display: grid;
  gap: 8px;
}
.card__list li {
  position: relative;
  padding-left: 18px;
}
.card__list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .55em;
  width: 6px;
  height: 6px;
  background: var(--accent);
}

/* Signal gantry */
.gantry {
  position: absolute;
  top: 12px;
  right: 8px;
  width: 28px;
  height: 64px;
  pointer-events: none;
}
.gantry__box {
  fill: var(--surface);
  stroke: var(--muted);
  stroke-width: 1.5;
}
.gantry__post { fill: var(--muted); }
.lamp {
  opacity: .18;
  transition: opacity .3s ease;
}
.lamp--red { fill: var(--lamp-red); }
.lamp--amber { fill: var(--lamp-amber); }
.lamp--green { fill: var(--lamp-green); }
.gantry.is-red .lamp--red,
.gantry.is-amber .lamp--amber,
.gantry.is-green .lamp--green { opacity: 1; }

/* ---------- Education and drone ---------- */
.card--edu {
  max-width: 760px;
  padding: clamp(16px, 3vw, 28px);
}
.card--edu h3 { padding-right: clamp(120px, 20vw, 180px); }

.drone {
  position: absolute;
  top: 12px;
  right: 12px;
  width: clamp(120px, 20vw, 180px);
  height: auto;
  animation: bob 4s ease-in-out infinite;
  animation-play-state: paused;
}
.card--edu.is-in .drone { animation-play-state: running; }
.drone__arm {
  fill: none;
  stroke: var(--ink);
  stroke-width: 4;
  stroke-linecap: round;
}
.drone__rotor {
  fill: var(--ink);
  opacity: .5;
}
.drone__body { fill: var(--ink); }
.drone__cam { fill: var(--ink); }
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* ---------- Skills badges ---------- */
.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.badge {
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-weight: 600;
  transform: translate(var(--mx, 0px), var(--my, 0px));
  transition: transform .4s cubic-bezier(.34, 1.56, .64, 1), border-color .2s ease, color .2s ease;
}
.badge:hover {
  color: var(--accent-text);
  border-color: var(--accent);
}
.badge--long {
  display: flex;
  max-width: 100%;
  min-width: 0;
  padding: 10px 16px;
  border-radius: 18px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

/* ---------- About and map ---------- */
.about__grid {
  display: grid;
  gap: 32px;
  align-items: center;
}
.about__grid p + p { margin-top: 16px; }

.map {
  display: block;
  width: 100%;
  max-width: 480px;
  height: auto;
  justify-self: center;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
.map__grid path {
  fill: none;
  stroke: var(--rule);
  stroke-width: 1;
}
.route {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
}
.pin {
  fill: var(--accent);
  transition: transform .6s cubic-bezier(.2, .8, .3, 1), opacity .4s ease;
  transition-delay: calc(var(--i, 0) * 120ms);
}
.pin__dot { fill: var(--surface); }

/* ---------- Reveals (JS only) ---------- */
html.js .reveal {
  transition: opacity .7s cubic-bezier(.2, .7, .2, 1), transform .7s cubic-bezier(.2, .7, .2, 1);
}
html.js .reveal:not(.is-in) {
  opacity: 0;
  transform: translateY(16px);
}
html.js .map:not(.is-in) .route { stroke-dashoffset: 1; }
html.js .map.is-in .route { transition: stroke-dashoffset 1.6s cubic-bezier(.4, 0, .2, 1); }
html.js .map:not(.is-in) .pin {
  opacity: 0;
  transform: translateY(-14px);
}

/* ---------- Hero letter stagger (JS only) ---------- */
.word { display: inline-block; white-space: nowrap; }
.ltr { display: inline-block; }
html.js .hero__name .ltr {
  opacity: 0;
  transform: translateY(.35em);
  transition: opacity .7s ease, transform .7s cubic-bezier(.2, .7, .2, 1);
  transition-delay: calc(var(--i, 0) * 35ms);
}
html.js .hero__name.is-in .ltr {
  opacity: 1;
  transform: none;
}

/* ---------- No-JS metro fallback (drawn in CSS) ---------- */
html:not(.js) .metro { display: none; }
html:not(.js) .stations::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 8px;
  width: 3px;
  margin-left: -1.5px;
  background: var(--accent);
}
html:not(.js) .station::before {
  content: "";
  position: absolute;
  top: 16px;
  left: 0;
  width: 16px;
  height: 16px;
  box-sizing: border-box;
  border: 3px solid var(--accent);
  border-radius: 50%;
  background: var(--surface);
}
html:not(.js) .station:last-child::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 0;
  width: 16px;
  height: 44px;
  border-radius: 4px;
  background: var(--ink);
}

/* ---------- Progress and interaction ---------- */
@media (hover: hover) and (pointer: fine) {
  .badge { cursor: default; }
}

/* ---------- Breakpoints ---------- */
@media (min-width: 600px) {
  .nav { flex-wrap: nowrap; }
  .badges { gap: 10px; }
}

@media (min-width: 900px) {
  .stations {
    grid-template-columns: minmax(0, 1fr) 56px minmax(0, 1fr);
    gap: 48px 0;
  }
  .station { padding-left: 0; }
  .station:nth-child(1) { grid-area: 1 / 1; }
  .station:nth-child(2) { grid-area: 2 / 3; }
  .station:nth-child(3) { grid-area: 3 / 1; }
  .station .card { padding: 24px 56px 24px 24px; }

  .about__grid {
    grid-template-columns: minmax(0, 1.1fr) minmax(0, .9fr);
    gap: 48px;
  }

  html:not(.js) .stations::before { left: 50%; }
  html:not(.js) .station::before { left: auto; right: -36px; }
  html:not(.js) .station:nth-child(even)::before { left: -36px; right: auto; }
  html:not(.js) .station:last-child::after { left: auto; right: -36px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
  html.js .reveal,
  html.js .reveal:not(.is-in) {
    opacity: 1;
    transform: none;
  }
  html.js .map:not(.is-in) .route { stroke-dashoffset: 0; }
  html.js .map:not(.is-in) .pin { opacity: 1; transform: none; }
  html.js .hero__name .ltr { opacity: 1; transform: none; }
  .station .card { transform: none; }
  .cursor-glow { display: none; }
  .drone { animation: none; }
}

html.reduce .station .card { transform: none; }
html.reduce .cursor-glow { display: none; }
html.reduce .reveal,
html.reduce .reveal:not(.is-in) { opacity: 1; transform: none; }
