/* ---------- Theme tokens (notebook paper palette) ---------- */
:root {
  --paper: #fdfcf9;
  --paper-muted: #f2f0ea;
  --ink: #1d2230;
  --ink-soft: #424855;
  --ink-muted: #5d6370;
  --accent: #0060df;
  --accent-soft: #0060df14;
  --good: #15803d;
  --rule: #2c261c1a;
  --rule-strong: #2c261c38;
  --dot: #0060df29;
  --shadow: 0 10px 30px rgb(0 0 0 / 0.12);

  --font-sans: "Source Sans 3", system-ui, sans-serif;
  --font-serif: "Source Serif 4", Georgia, serif;
  --font-hand: "Caveat", cursive;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;

  --max-width: 66rem;
  color-scheme: light;
}

[data-theme="dark"] {
  --paper: #0f172a;
  --paper-muted: #111827;
  --ink: #e7edf8;
  --ink-soft: #c3cede;
  --ink-muted: #9fb0c7;
  --accent: #60a5fa;
  --accent-soft: #60a5fa1a;
  --good: #4ade80;
  --rule: #60a5fa24;
  --rule-strong: #60a5fa57;
  --dot: #0060df2e;
  --shadow: 0 10px 30px rgb(0 0 0 / 0.45);
  color-scheme: dark;
}

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

html { scroll-behavior: smooth; scroll-padding-top: 4.5rem; font-size: 125%; /* 20px base: scales every rem-based size up */ }

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  font-size: 1.15rem;
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  overflow-x: clip; /* the tilted photo shouldn't cause sideways scrolling */
  transition: background-color 0.3s, color 0.3s;
}

.dot-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background-image: radial-gradient(var(--dot) 1.25px, transparent 1.25px);
  background-size: 24px 24px;
}

/* ---------- Cursor glow on the dot grid ----------
   A second, brighter dot layer that only shows in a soft circle around the mouse. */
.dot-glow {
  --mx: -500px;
  --my: -500px;
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  background-image: radial-gradient(var(--accent) 1.6px, transparent 1.7px);
  background-size: 24px 24px;
  opacity: 0;
  transition: opacity 0.4s;
  -webkit-mask-image: radial-gradient(200px circle at var(--mx) var(--my), #000 0%, transparent 75%);
  mask-image: radial-gradient(200px circle at var(--mx) var(--my), #000 0%, transparent 75%);
}
.dot-glow.on { opacity: 0.6; }

/* ---------- Scroll runner (decorative) ----------
   Position along the bottom = how far you've scrolled (set by script.js as --x).
   Runs while moving, turns around on scroll-up, celebrates at the finish flag. */
.runner-track {
  --x: 0px;
  --runner-w: 78px;
  --runner-h: 104px;
  --flag-w: 34px;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 130px;
  pointer-events: none;
  z-index: -1;
}
/* dashed ground */
.runner-track::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  height: 2px;
  background: repeating-linear-gradient(90deg, var(--rule-strong) 0 10px, transparent 10px 20px);
}
/* solid trail behind the runner = scroll progress */
.runner-track::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 10px;
  height: 2px;
  width: calc(var(--x) + var(--runner-w) / 2);
  background: linear-gradient(90deg, transparent, var(--accent));
  opacity: 0.6;
  border-radius: 2px;
}

.runner {
  position: absolute;
  bottom: 11px;
  left: 0;
  width: var(--runner-w);
  height: var(--runner-h);
  color: var(--accent);
  opacity: 0.6;
  transform: translateX(var(--x));
  will-change: transform;
}
/* soft shadow under the feet */
.runner::before {
  content: "";
  position: absolute;
  left: 22%;
  right: 22%;
  bottom: -3px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0.18;
  transition: transform 0.3s;
}
.running .runner::before { animation: shadow 0.3s ease-in-out infinite alternate; }

.figure { position: absolute; inset: 0; transition: transform 0.25s ease; }
.reverse .figure { transform: scaleX(-1); }
.figure svg { display: block; width: 100%; height: 100%; overflow: visible; }
.runner line,
.runner circle { stroke: currentColor; stroke-width: 4; stroke-linecap: round; fill: none; }
.runner circle { fill: currentColor; }

/* dust puffs kicked up behind the feet while running */
.dust {
  position: absolute;
  bottom: 0;
  left: 30%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
}
.dust:nth-of-type(2) { width: 5px; height: 5px; }
.running .dust { animation: puff 0.6s ease-out infinite; }
.running .dust:nth-of-type(2) { animation-delay: 0.3s; }

/* each limb pivots around its joint (SVG user units) */
.runner .limb { transform-box: view-box; transition: transform 0.25s ease; }
.runner .thigh { transform-origin: 30px 46px; transform: rotate(14deg); }
.runner .back.thigh { transform: rotate(-14deg); }
.runner .shin { transform-origin: 30px 61px; }
.runner .arm { transform-origin: 31px 26px; transform: rotate(8deg); }
.runner .forearm { transform-origin: 31px 37px; transform: rotate(-20deg); }

/* idle: gentle breathing */
.runner .body { animation: breathe 2.4s ease-in-out infinite; }

/* running */
.running .runner .body { animation: bob 0.3s ease-in-out infinite alternate; }
.running .runner .thigh { animation: thigh 0.6s ease-in-out infinite; }
.running .runner .shin { animation: shin 0.6s ease-in-out infinite; }
.running .runner .arm { animation: arm 0.6s ease-in-out infinite; }
.running .runner .forearm { transform: rotate(-80deg); }
.running .runner .back,
.running .runner .back .shin { animation-delay: -0.3s; }

/* finished: arms up and a little hop */
.finished:not(.running) .runner .body { animation: hop 0.9s ease-in-out infinite; }
.finished:not(.running) .runner .arm { transform: rotate(-150deg); }
.finished:not(.running) .runner .back.arm { transform: rotate(150deg); }
.finished:not(.running) .runner .forearm { transform: rotate(0deg); }

/* finish flag at the far right */
.flag {
  position: absolute;
  right: 6px;
  bottom: 11px;
  width: var(--flag-w);
  height: 52px;
  color: var(--accent);
  opacity: 0.45;
  transition: opacity 0.3s;
}
.flag svg { display: block; width: 100%; height: 100%; overflow: visible; }
.flag line { stroke: currentColor; stroke-width: 3; stroke-linecap: round; }
.flag path { fill: currentColor; transform-box: fill-box; transform-origin: left center; }
.finished .flag { opacity: 0.8; }
.finished .flag path { animation: wave 0.8s ease-in-out infinite alternate; }

@keyframes breathe { 50% { transform: translateY(-1.5px); } }
@keyframes bob { from { transform: translateY(0); } to { transform: translateY(-4px); } }
@keyframes hop { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-10px); } }
@keyframes shadow { to { transform: scaleX(0.8); } }
@keyframes thigh { 0%, 100% { transform: rotate(-40deg); } 50% { transform: rotate(34deg); } }
@keyframes shin { 0%, 100% { transform: rotate(15deg); } 35% { transform: rotate(10deg); } 65% { transform: rotate(90deg); } }
@keyframes arm { 0%, 100% { transform: rotate(45deg); } 50% { transform: rotate(-45deg); } }
@keyframes puff {
  0% { opacity: 0.35; transform: translate(0, 0) scale(0.6); }
  100% { opacity: 0; transform: translate(-22px, -10px) scale(1.6); }
}
@keyframes wave { from { transform: skewY(0deg) scaleX(1); } to { transform: skewY(-8deg) scaleX(0.85); } }

a { color: var(--accent); text-underline-offset: 3px; }
a:focus-visible,
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--ink);
  color: var(--paper);
  z-index: 100;
}
.skip-link:focus { left: 0.5rem; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Navbar ---------- */
.navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.6rem clamp(1rem, 5vw, 4rem);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
}

.logo {
  flex-grow: 1;
  font-family: var(--font-hand);
  font-size: 2rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.2s;
}
.logo:hover { transform: scale(1.05); }

.navbar ul { display: flex; gap: 1.25rem; list-style: none; margin: 0; padding: 0; }
.navbar nav a {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--ink-soft);
  text-decoration: none;
  padding-bottom: 2px;
  border-bottom: 2px solid transparent;
}
.navbar nav a:hover { color: var(--accent); }
.navbar nav a.active { color: var(--accent); border-bottom-color: var(--accent); }

.theme-toggle {
  flex-shrink: 0;
  border: 1px solid var(--rule-strong);
  background: transparent;
  color: var(--ink);
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
}

/* ---------- Layout ---------- */
main {
  flex: 1;
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 clamp(1rem, 5vw, 2rem);
}

.section { padding: 4.5rem 0; border-top: 1px dashed var(--rule-strong); }

h1, h2, h3 { font-family: var(--font-serif); color: var(--ink); line-height: 1.2; }
h2 { font-size: 2.1rem; margin: 0 0 0.5rem; }
.num { font-family: var(--font-mono); font-size: 1rem; font-weight: 400; color: var(--accent); margin-right: 0.6rem; vertical-align: 0.35em; }
h2::after {
  content: "";
  display: block;
  width: 3rem;
  height: 3px;
  margin-top: 0.4rem;
  background: var(--accent);
  border-radius: 2px;
}
h3 { font-size: 1.2rem; margin: 0; }
.section-intro { color: var(--ink-muted); margin: 0.75rem 0 2rem; max-width: 40rem; }

/* ---------- Hero ---------- */
.hero {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 3rem;
  align-items: center;
  min-height: calc(100dvh - 4rem);
  padding: 3rem 0 2rem;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.3rem 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
}
.pulse {
  width: 9px;
  height: 9px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #22c55e;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 #22c55e80; }
  70% { box-shadow: 0 0 0 8px #22c55e00; }
  100% { box-shadow: 0 0 0 0 #22c55e00; }
}

.eyebrow { font-family: var(--font-hand); font-size: 1.75rem; color: var(--ink-muted); margin: 1.25rem 0 0; }
.hero h1 { font-size: clamp(2.75rem, 8vw, 5rem); margin: 0 0 0.75rem; }
.tagline { font-family: var(--font-serif); font-size: clamp(1.3rem, 3vw, 1.6rem); color: var(--ink); margin: 0 0 1rem; }
.lede { font-size: 1.2rem; color: var(--ink-soft); max-width: 36rem; margin: 0; }

/* staggered entrance on page load */
.hero-text > * { animation: rise 0.7s cubic-bezier(.2,.7,.2,1) backwards; }
.hero-text > :nth-child(2) { animation-delay: 0.08s; }
.hero-text > :nth-child(3) { animation-delay: 0.16s; }
.hero-text > :nth-child(4) { animation-delay: 0.24s; }
.hero-text > :nth-child(5) { animation-delay: 0.32s; }
.hero-text > :nth-child(6) { animation-delay: 0.4s; }
.hero-photo { animation: drop 0.9s 0.2s cubic-bezier(.2,.7,.2,1) backwards; /* "backwards" so :hover transform still works after */ }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
@keyframes drop { from { opacity: 0; transform: rotate(-4deg) translateY(-16px); } to { opacity: 1; transform: rotate(2deg); } }

.accent-dot { color: var(--accent); }

.highlight {
  font-weight: 600;
  color: var(--ink);
  background: linear-gradient(transparent 60%, var(--dot) 60%);
}

.cta-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; margin-top: 1.75rem; }

.btn {
  display: inline-block;
  padding: 0.6rem 1.25rem;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--paper);
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 999px;
  text-decoration: none;
  transition: transform 0.2s, background-color 0.2s, border-color 0.2s;
}
.btn:hover { background: var(--accent); border-color: var(--accent); transform: translateY(-2px); }
.btn-ghost { color: var(--ink); background: transparent; border-color: var(--rule-strong); }
.btn-ghost:hover { color: var(--paper); }

.socials { display: flex; gap: 0.25rem; list-style: none; margin: 0 0 0 0.25rem; padding: 0; }
.socials a {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  color: var(--ink-soft);
  transition: color 0.2s, background-color 0.2s;
}
.socials a:hover { color: var(--accent); background: var(--accent-soft); }
.socials svg { width: 1.3rem; height: 1.3rem; }


.hero-photo { margin: 0; text-align: center; transform: rotate(2deg); transition: transform 0.3s; }
.hero-photo:hover { transform: rotate(0deg) scale(1.02); }
.hero-photo img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1; /* matches the square source photo, so nothing is cropped */
  object-fit: cover;
  border: 10px solid #fff;
  border-bottom-width: 44px;
  box-shadow: var(--shadow);
}
/* Caption sits on the white polaroid border, so keep it dark in both themes */
.handwritten { font-family: var(--font-hand); font-size: 1.5rem; color: #424855; margin-top: -2.5rem; position: relative; }

/* ---------- Quick facts ---------- */
.facts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--rule-strong);
  border: 1px solid var(--rule-strong);
  border-radius: 12px;
  overflow: hidden;
}
.facts li { padding: 1rem 1.2rem; background: var(--paper); transition: background-color 0.2s; }
.facts li:hover { background: color-mix(in srgb, var(--accent) 6%, var(--paper)); }
.fact-label { display: block; font-family: var(--font-mono); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-muted); }
.fact-value { display: block; font-weight: 600; color: var(--ink); line-height: 1.35; margin-top: 0.2rem; }

/* ---------- Experience timeline ---------- */
.timeline { list-style: none; margin: 1.5rem 0 0; padding: 0 0 0 0.4rem; border-left: 2px solid var(--rule-strong); }
.timeline > li {
  position: relative;
  padding: 0.9rem 1.1rem;
  margin-bottom: 0.75rem;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: background-color 0.2s, border-color 0.2s, transform 0.2s;
}
.timeline > li:last-child { margin-bottom: 0; }
.timeline > li:hover { background: var(--paper); border-color: var(--rule-strong); transform: translateX(4px); }
.timeline > li::before {
  content: "";
  position: absolute;
  left: calc(-0.4rem - 7px);
  top: calc(0.9rem + 0.5rem);
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--accent);
}
.timeline > li.current::before { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.timeline > li:hover::before { background: var(--accent); }
.timeline-head { display: flex; justify-content: space-between; gap: 0.25rem 1rem; flex-wrap: wrap; }
.role { font-weight: 500; color: var(--ink-muted); }
/* company name links: look like the heading, reveal they're links on hover */
.org-link { color: inherit; text-decoration: none; border-bottom: 1px dashed var(--rule-strong); transition: color 0.2s, border-color 0.2s; }
.org-link:hover { color: var(--accent); border-bottom-color: var(--accent); }
.org-link .ext { display: inline-block; margin-left: 0.15em; font-size: 0.7em; vertical-align: 0.35em; color: var(--accent); transition: transform 0.2s; }
.org-link:hover .ext { transform: translate(2px, -2px); }
.date { font-family: var(--font-mono); font-size: 0.85rem; color: var(--ink-muted); }
.timeline p { margin: 0.35rem 0 0; color: var(--ink-soft); }


/* ---------- Project cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(22rem, 100%), 1fr)); /* 2×2 on desktop, 1 column on phones */ gap: 1.5rem; margin-top: 1.5rem; }
.card {
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: 12px;
  border-top: 3px solid var(--rule-strong);
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}
.card:hover { transform: translateY(-4px); box-shadow: 4px 6px 0 var(--rule-strong); border-top-color: var(--accent); }
.card:hover .card-link { text-decoration: underline; }
.card-kicker { font-family: var(--font-mono); font-size: 0.75rem; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.06em; margin: 0 0 0.35rem; }
.card > p:not(.card-kicker) { color: var(--ink-soft); flex: 1; }
.card-link { font-family: var(--font-mono); font-size: 0.9rem; margin-top: auto; }
.card-links { display: flex; flex-wrap: wrap; gap: 1.25rem; margin-top: auto; }

.tags { display: flex; flex-wrap: wrap; gap: 0.4rem; list-style: none; padding: 0; margin: 0 0 1rem; }
.tags li {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.15rem 0.55rem;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  color: var(--ink-muted);
  background: var(--paper);
}

/* ---------- About / skills ---------- */
.about-text { font-size: 1.2rem; color: var(--ink-soft); max-width: 42rem; margin: 1.5rem 0 2rem; }
.skills { margin-top: 1.5rem; gap: 0.5rem; }
.skills li { font-size: 0.85rem; padding: 0.3rem 0.8rem; color: var(--ink); transition: transform 0.15s, border-color 0.15s, color 0.15s; }
.skills li:hover { transform: translateY(-2px); border-color: var(--accent); color: var(--accent); }

/* ---------- Contact ---------- */
.contact {
  text-align: center;
  padding: 3rem clamp(1rem, 5vw, 3rem);
  margin-bottom: 2rem;
  background: var(--paper);
  border: 1px solid var(--rule-strong);
  border-radius: 16px;
}
.contact h2::after { margin-left: auto; margin-right: auto; }
.contact p { color: var(--ink-soft); max-width: 34rem; margin: 1rem auto 0; }
.contact .cta-row { justify-content: center; }
.contact-email { font-family: var(--font-mono); font-size: 0.95rem; margin-top: 1.25rem; }

.footer {
  padding: 1.5rem 1.5rem 8rem;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--ink-muted);
  border-top: 1px solid var(--rule);
}

/* ---------- Scroll reveal (only when JS is running) ---------- */
.js .reveal { opacity: 0; transform: translateY(16px); transition: opacity 0.6s ease, transform 0.6s ease; }
.js .reveal.visible { opacity: 1; transform: none; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .facts { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 720px) {
  html { font-size: 112.5%; } /* slightly smaller base on phones so lines fit */
  .runner-track { --runner-w: 54px; --runner-h: 72px; --flag-w: 26px; height: 90px; }
  .flag { height: 40px; }
  .hero { grid-template-columns: 1fr; min-height: auto; }
  .hero { padding-top: 2rem; }
  .hero-photo { max-width: 18rem; margin: 0 auto; grid-row: 1; }
  .navbar { flex-wrap: wrap; row-gap: 0.25rem; }
  /* Nav moves onto its own scrollable row instead of disappearing */
  .navbar nav { order: 3; width: 100%; overflow-x: auto; scrollbar-width: none; }
  .navbar nav::-webkit-scrollbar { display: none; }
  .navbar ul { gap: 1rem; }
  .navbar nav a { font-size: 0.85rem; }
}

@media (max-width: 420px) {
  .facts { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .runner-track, .dot-glow { display: none; }
  *,
  .js .reveal { transition: none !important; animation: none !important; opacity: 1 !important; transform: none !important; }
}

@media print {
  .navbar, .dot-grid, .dot-glow, .runner-track, .theme-toggle, .footer { display: none; }
  .js .reveal { opacity: 1; transform: none; }
}
