/* ==========================================================================
   ENGINEER'S BLUEPRINT — design system
   Cream/ink base · one electric violet accent · Clash Display + Satoshi +
   JetBrains Mono · sharp corners · hairlines · no gradients, no glass.
   ========================================================================== */

/* --- Tokens ----------------------------------------------------------- */
:root {
  --bg: #F4F1EA;
  --ink: #16150F;
  --muted: #6E6B60;
  --line: rgba(22, 21, 15, 0.14);
  --line-strong: rgba(22, 21, 15, 0.34);
  --accent: #4101F5;
  --accent-soft: rgba(65, 1, 245, 0.07);
  --surface: #ECE8DE;

  --font-display: 'Clash Display', 'Satoshi', sans-serif;
  --font-body: 'Satoshi', 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Consolas', monospace;

  --hud-h: 60px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

:root[data-theme="b"] {
  --bg: #0D0D0F;
  --ink: #EFEEE8;
  --muted: #96948A;
  --line: rgba(239, 238, 232, 0.14);
  --line-strong: rgba(239, 238, 232, 0.36);
  --accent: #8B6BFF;
  --accent-soft: rgba(139, 107, 255, 0.09);
  --surface: #151518;
}

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

html { scroll-behavior: auto; }

html.lenis, html.lenis body { height: auto; }
.lenis-smooth { scroll-behavior: auto !important; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  transition: background-color 0.35s var(--ease), color 0.35s var(--ease);
}

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

a { color: inherit; }

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

.skip-link {
  position: fixed;
  top: -100px;
  left: 1rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-decoration: none;
}
.skip-link:focus { top: 1rem; }

/* --- HUD header -------------------------------------------------------- */
.hud {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: var(--hud-h);
  padding: 0 clamp(1rem, 3vw, 2.5rem);
  border-bottom: 1px solid var(--line);
  background: var(--bg); /* fallback for browsers without color-mix */
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
}

.hud-brand {
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}

.hud-nav { display: flex; gap: 1.75rem; }
.hud-nav a {
  text-decoration: none;
  color: var(--muted);
  text-transform: uppercase;
  transition: color 0.2s var(--ease);
}
.hud-nav a:hover { color: var(--accent); }

.hud-status { display: flex; align-items: center; gap: 1.5rem; white-space: nowrap; }

.status { color: var(--muted); }
.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 0.55em;
  background: var(--accent);
  animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.clock { color: var(--muted); font-variant-numeric: tabular-nums; }

.theme-btn {
  font: inherit;
  letter-spacing: inherit;
  color: var(--ink);
  background: none;
  border: 1px solid var(--line-strong);
  padding: 0.45em 0.8em;
  cursor: pointer;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}
.theme-btn:hover { background: var(--ink); color: var(--bg); }

.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 60;
  width: 100%;
  height: 2px;
  background: var(--accent);
  transform-origin: 0 50%;
  transform: scaleX(0);
}

/* --- Hero -------------------------------------------------------------- */
.hero {
  position: relative;
  min-height: 100vh; /* fallback for browsers without svh */
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: calc(var(--hud-h) + 3rem) clamp(1rem, 4vw, 4rem) 4rem;
  overflow: hidden;
}

#agent-graph {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.hero-inner { position: relative; z-index: 2; max-width: 1200px; }

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  color: var(--muted);
  margin-bottom: 1.6rem;
}

.hero-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(4.2rem, 13.5vw, 12.5rem);
  line-height: 0.92;
  letter-spacing: -0.02em;
  text-transform: uppercase;
}

.hero-name .line { display: block; overflow: hidden; }
.hero-name .line-inner { display: inline-block; will-change: transform; }

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

.hero-line {
  max-width: 34rem;
  margin-top: 2rem;
  font-size: clamp(1.05rem, 1.6vw, 1.3rem);
  color: var(--muted);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-top: 2.4rem;
}

.hero-meta {
  margin-top: 2.2rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: var(--muted);
}

/* --- Buttons ----------------------------------------------------------- */
.btn {
  display: inline-block;
  padding: 0.85rem 1.5rem;
  border: 1px solid var(--line-strong);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink);
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease),
              border-color 0.2s var(--ease);
}
.btn:hover { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.btn-primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

/* --- Ticker ------------------------------------------------------------- */
/* --- Custom cursor (square motif; JS + fine pointer only) ------------------ */
#cursor {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 90;
  width: 10px;
  height: 10px;
  background: var(--accent);
  border: 1px solid transparent;
  pointer-events: none;
  opacity: 0;
  transition: width 0.18s var(--ease), height 0.18s var(--ease),
              background-color 0.18s var(--ease), border-color 0.18s var(--ease),
              opacity 0.2s var(--ease);
}
#cursor.is-visible { opacity: 1; }
#cursor.is-link {
  width: 34px;
  height: 34px;
  background: transparent;
  border-color: var(--accent);
}
body.has-cursor, body.has-cursor a, body.has-cursor button { cursor: none; }
@media (hover: none) { #cursor { display: none; } }

/* --- Hero scroll cue --------------------------------------------------------- */
.scroll-cue {
  margin-top: 3rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  color: var(--muted);
  animation: cue-bob 2.2s ease-in-out infinite;
}
@keyframes cue-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(6px); }
}

/* --- Story chapters (pinned scroll-zoom on desktop) ---------------------------- */
.chapters { position: relative; }

.chapter { max-width: 900px; margin-bottom: 3.2rem; }
.chapter:last-child { margin-bottom: 0; }

.chapter-kicker {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  color: var(--accent);
  margin-bottom: 1rem;
}

.chapter-line {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.4rem, 6.5vw, 5.5rem);
  line-height: 1.02;
  letter-spacing: -0.015em;
}

.chapter-sub {
  margin-top: 1.2rem;
  max-width: 30rem;
  color: var(--muted);
}

.chapters-hint { display: none; }

/* Pinned mode is added by JS only (gsap + desktop + motion allowed);
   without it the chapters are a plain readable stack. */
.chapters--pin { height: 100svh; }
.chapters--pin .chapters-hint {
  display: block;
  position: absolute;
  top: calc(var(--hud-h) + 1.5rem);
  left: 0;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  color: var(--muted);
}
.chapters--pin .chapter {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin: 0;
  will-change: transform, opacity;
}

/* --- Ticker gets scroll-velocity skew (JS) ------------------------------------ */
.ticker { will-change: transform; }

.ticker {
  overflow: hidden;
  border-block: 1px solid var(--line);
  padding: 0.8rem 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  color: var(--muted);
  background: var(--surface);
}

.ticker-track {
  display: flex;
  width: max-content;
  animation: ticker 30s linear infinite;
}
.ticker-track > span { white-space: nowrap; padding-right: 2ch; }
.ticker .sq { color: var(--accent); font-weight: 400; padding: 0 1ch; }

@keyframes ticker {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}

/* --- Sections ----------------------------------------------------------- */
.section {
  max-width: 1200px;
  margin: 0 auto;
  padding: clamp(5rem, 10vw, 8.5rem) clamp(1rem, 4vw, 4rem) 0;
}

.section-head { margin-bottom: clamp(2.5rem, 5vw, 4rem); }

.sec-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin-bottom: 1rem;
}

.section h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2.1rem, 4.6vw, 3.6rem);
  line-height: 1.05;
  letter-spacing: -0.01em;
}

.sec-note {
  margin-top: 1.1rem;
  max-width: 34rem;
  color: var(--muted);
}

/* --- About ---------------------------------------------------------------- */
.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 5rem);
  align-items: start;
}

.about-copy p { max-width: 36rem; }
.about-copy p + p { margin-top: 1.2rem; color: var(--muted); }

.about-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--line);
  border-left: 1px solid var(--line);
}
.about-stats > div {
  padding: 1.4rem 1.2rem;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.about-stats dt {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.about-stats dd {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 2rem;
  line-height: 1;
}

/* --- Work / projects ------------------------------------------------------ */
.project-list { border-top: 1px solid var(--line); }

.project {
  display: grid;
  grid-template-columns: 4ch minmax(0, 1fr) auto;
  gap: clamp(1rem, 3vw, 3rem);
  align-items: baseline;
  padding: 2.2rem 0.8rem;
  border-bottom: 1px solid var(--line);
  transition: background-color 0.25s var(--ease);
}
.project:hover { background: var(--accent-soft); }

.project-index {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.project-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.project-blurb {
  max-width: 34rem;
  margin-top: 0.6rem;
  color: var(--muted);
}

.project-tags {
  margin-top: 1rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.project-link {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-decoration: none;
  color: var(--ink);
  white-space: nowrap;
  border-bottom: 1px solid var(--line-strong);
  padding-bottom: 2px;
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.project:hover .project-link { color: var(--accent); border-color: var(--accent); }

/* --- Live GitHub strip ----------------------------------------------------- */
.gh-block { margin-top: clamp(3rem, 6vw, 5rem); }

.gh-title {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
}
.gh-hint { color: var(--muted); font-weight: 400; }

.gh-strip { margin-top: 1rem; border-top: 1px solid var(--line); }

.gh-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 1.5rem;
  align-items: baseline;
  padding: 0.85rem 0.4rem;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  text-decoration: none;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}
.gh-row:hover { background: var(--accent-soft); color: var(--accent); }

.gh-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gh-meta { color: var(--muted); letter-spacing: 0.08em; }

.gh-more { margin-top: 1.6rem; }

/* --- Stack ------------------------------------------------------------------ */
.stack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}

.stack-group { background: var(--bg); padding: 1.8rem 1.5rem; }

.stack-group h3 {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1.2rem;
}

.stack-group ul { list-style: none; }
.stack-group li {
  padding: 0.45rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.95rem;
}
.stack-group li:last-child { border-bottom: none; }
.stack-group li::before { content: '▮ '; color: var(--accent); font-size: 0.6em; }

/* --- Education ---------------------------------------------------------------- */
.edu-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 2rem;
  padding: 2rem 0.8rem;
  border-block: 1px solid var(--line);
}
.edu-school {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(1.8rem, 3.5vw, 2.8rem);
}
.edu-degree { color: var(--muted); margin-top: 0.4rem; }
.edu-years { font-family: var(--font-mono); font-size: 0.8rem; color: var(--muted); white-space: nowrap; }
.edu-note { margin-top: 1.4rem; color: var(--muted); max-width: 34rem; }

/* --- Contact -------------------------------------------------------------------- */
.contact-title { font-size: clamp(3rem, 9vw, 7.5rem); }
.contact-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding-bottom: clamp(4rem, 8vw, 6rem);
}

/* --- Footer ---------------------------------------------------------------------- */
.footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem clamp(1rem, 4vw, 4rem) 3rem;
  border-top: 1px solid var(--line);
  margin-top: clamp(4rem, 8vw, 6rem);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  color: var(--muted);
}

/* --- Scroll reveals (JS-gated: no hidden content without JS) ---------------------- */
.js .reveal { opacity: 0; transform: translateY(26px); }
.js .reveal.in {
  opacity: 1;
  transform: none;
  transition: opacity 0.7s var(--ease), transform 0.7s var(--ease);
}

/* --- Responsive --------------------------------------------------------------------- */
@media (max-width: 860px) {
  .hud-nav { display: none; }
  .about-grid { grid-template-columns: 1fr; }
  .project { grid-template-columns: 3ch minmax(0, 1fr); }
  .project-link { grid-column: 2; justify-self: start; margin-top: 1.2rem; }
  .edu-row { flex-direction: column; gap: 0.6rem; }
  .gh-row { grid-template-columns: minmax(0, 1fr) auto; }
  .gh-row .gh-meta:last-child { display: none; }
}

/* --- Reduced motion ------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .ticker-track { animation: none; }
  .status-dot { animation: none; }
  .scroll-cue { animation: none; }
  .js .reveal { opacity: 1; transform: none; transition: none; }
  .js .hero-name .line-inner { transform: none; }
  #cursor { display: none; }
}
