/* styles.css — design tokens + base + landing. Minimal, flat, near-monochrome.
   No gradients anywhere; borders + whitespace do the work. The trainer page adds
   games/trainer.css on top of these tokens. */

:root {
  --bg: #0b0b0c;
  --bg-2: #0f0f11;
  --panel: #131315;
  --panel-2: #1b1b1e;
  --line: #262629;
  --line-2: #34343a;
  --text: #f3f3f5;
  --text-2: #c7c7cd;
  --muted: #8a8a93;
  --muted-2: #5e5e66;
  --accent: #ededf0;          /* "accent" is just near-white — used for inverted buttons */
  /* semantic score colors (trainer grading only) */
  --good: #46b56b;
  --warning: #d9a441;
  --serious: #d67f56;
  --critical: #d15a4f;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'Titillium Web', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --maxw: 940px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}
a { color: inherit; }
/* Landing uses an all-lowercase treatment (source keeps real casing for a11y/SEO). */
body.home { text-transform: lowercase; }
h1, h2, h3, h4 { margin: 0; line-height: 1.12; font-weight: 700; letter-spacing: -0.02em; }
p { margin: 0; }
img { max-width: 100%; display: block; }

/* ---- Buttons (shared) ---- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: 12.5px;
  padding: 7px 13px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line-2); background: transparent; color: var(--text);
  text-decoration: none; transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn-primary { background: var(--text); border-color: var(--text); color: var(--bg); }
.btn-primary:hover { background: #ffffff; border-color: #ffffff; }
.btn-ghost { background: transparent; border-color: var(--line-2); color: var(--text-2); }
.btn-ghost:hover { border-color: var(--muted); color: var(--text); }

/* ============================ LANDING ============================ */

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 clamp(20px, 6vw, 40px); }
/* On wide screens, bias the whole column toward the top-left rather than dead-center. */
@media (min-width: 1040px) {
  .wrap { margin-left: clamp(24px, 5vw, 80px); margin-right: auto; }
}

/* ---- Nav ---- */
.nav {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 18px;
  padding: 16px clamp(20px, 6vw, 40px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s ease;
}
.nav.scrolled { border-color: var(--line); }
.nav .brand { font-weight: 600; letter-spacing: -0.02em; font-size: 14px; text-decoration: none; margin-right: auto; }
.nav .links { display: flex; gap: 4px; align-items: center; }
.nav .links a {
  color: var(--muted); text-decoration: none; font-size: 13px; font-weight: 400;
  padding: 7px 11px; border-radius: 7px;
}
.nav .links a:hover { color: var(--text); }
.nav .links a.cta { color: var(--text); border: 1px solid var(--line-2); }
.nav .links a.cta:hover { border-color: var(--muted); }
@media (max-width: 620px) { .nav .links a.hide-sm { display: none; } }

/* ---- Hero ---- */
.hero { padding: clamp(20px, 3.5vw, 40px) 0 clamp(16px, 3vw, 30px); }
.hero-card {
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(250px, 0.95fr); gap: clamp(22px, 4vw, 48px);
  align-items: start; padding: clamp(20px, 3vw, 32px);
  border: 1px solid var(--line); border-radius: 14px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
}
.hero .name { font-size: clamp(30px, 7.5vw, 62px); font-weight: 700; letter-spacing: -0.03em; }
.hero .caption { margin-top: clamp(11px, 2vw, 17px); font-size: clamp(14.5px, 2.3vw, 18px); color: var(--text); font-weight: 400; letter-spacing: -0.01em; max-width: 24ch; line-height: 1.3; }
.hero .sub { margin-top: 16px; max-width: 62ch; font-size: 13.5px; color: var(--muted); line-height: 1.65; }
.hero .cta-row { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 9px; }

/* Small, quick-reading companion to the name card. */
.interests { min-width: 0; }
.interests-label { font-family: var(--mono); color: var(--muted); font-size: 10px; letter-spacing: 0.1em; margin-bottom: 8px; }
.interest-list { border-top: 1px solid var(--line); }
.interest-item { padding: 9px 0 10px; border-bottom: 1px solid var(--line); }
.interest-item h2 { display: inline; font-size: 13px; letter-spacing: -0.01em; }
.interest-item h2::after { content: " — "; color: var(--muted-2); font-weight: 400; }
.interest-item p { display: inline; color: var(--muted); font-size: 12px; line-height: 1.42; }
.interest-item { transition: border-color 0.15s ease; }
.interest-item:hover { border-color: var(--muted); }
.interest-item:hover h2 { color: #fff; }
.interest-item kbd {
  display: inline-block; padding: 0 4px; border: 1px solid var(--line-2); border-bottom-color: var(--muted-2);
  border-radius: 3px; font: 500 9px/1.55 var(--mono); color: var(--text-2); vertical-align: 1px;
}
@media (max-width: 680px) {
  .hero-card { grid-template-columns: 1fr; gap: 22px; padding: 20px; }
}

/* ---- Ambient CAD backdrop (pre-rendered spinning monochrome SCORPION) ---- */
.cad-backdrop { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.cad-video {
  position: absolute; top: 50%; right: clamp(28px, 11vw, 180px); transform: translateY(-50%);
  width: min(40vw, 520px); height: auto;
  opacity: 0.13; filter: blur(1.6px);
  /* soft edge fade so the (opaque) video melts into the page — no rectangle seam */
  -webkit-mask-image: radial-gradient(115% 100% at 66% 50%, #000 42%, transparent 76%);
          mask-image: radial-gradient(115% 100% at 66% 50%, #000 42%, transparent 76%);
}
/* Page content sits above the backdrop; the project modal (z 60) stays on top of both. */
.hero, main, .foot { position: relative; z-index: 1; }
@media (max-width: 860px) { .cad-backdrop { display: none; } }

/* ---- Section scaffolding ---- */
.section { padding: clamp(24px, 4.5vw, 44px) 0; border-top: 1px solid var(--line); }
.section-head { margin-bottom: 20px; }
.section-head .kicker { font-family: var(--mono); font-size: 10.5px; color: var(--muted); letter-spacing: 0.08em; text-transform: lowercase; margin-bottom: 9px; }
.section-head h2 { font-size: clamp(16.5px, 2.8vw, 21px); }
.section-head p { color: var(--muted); font-size: 12.5px; max-width: 56ch; margin-top: 7px; }

/* ---- Featured trainer (flat) ---- */
.featured {
  border: 1px solid var(--line); border-radius: 14px; background: var(--panel);
  padding: clamp(20px, 3.6vw, 30px);
}
.featured .tag { font-family: var(--mono); font-size: 11px; color: var(--muted); letter-spacing: 0.06em; text-transform: lowercase; }
.featured h3 { font-size: clamp(18px, 3vw, 23px); margin: 10px 0 12px; }
.featured p { color: var(--text-2); font-size: 13.5px; line-height: 1.6; max-width: 62ch; }
.featured .cta-row { margin-top: 18px; display: flex; gap: 10px; flex-wrap: wrap; }

/* ---- Projects ---- */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 820px) { .grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 540px) { .grid { grid-template-columns: 1fr; } }
.proj {
  position: relative; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 15px; text-decoration: none; color: inherit;
  transition: border-color 0.15s ease; min-height: 146px;
}
.proj:hover { border-color: var(--line-2); }
.proj .p-top { display: flex; align-items: center; justify-content: flex-end; margin-bottom: 10px; }
.proj .p-status { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.04em; text-transform: lowercase; color: var(--muted-2); }
.proj .p-status.live { color: var(--good); }
.proj h3 { font-size: 13.5px; letter-spacing: -0.01em; font-weight: 600; }
.proj .p-desc { margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.5; flex: 1; }
.proj .p-tags { margin-top: 11px; display: flex; flex-wrap: wrap; gap: 6px; }
.proj .p-tags span { font-size: 10px; color: var(--muted); font-family: var(--mono); }
.proj .p-tags span::before { content: "#"; opacity: 0.5; }
.proj .p-arrow { position: absolute; top: 15px; right: 15px; color: var(--muted); opacity: 0; transition: opacity 0.15s ease; }
.proj:hover .p-arrow { opacity: 1; }
/* Problem / solution card body (the full write-up now lives in the modal). */
.proj .p-ps { margin-top: 7px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.proj .ps-line { font-size: 11.5px; line-height: 1.42; color: var(--muted); margin: 0; }
.proj .ps-line.sol { color: var(--text-2); }
.proj .ps-k {
  display: block; font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.09em;
  color: var(--muted-2); margin-bottom: 2px;
}
.proj-feature .ps-line { font-size: 12.5px; }

/* Trainer sits standalone on the right (it has an interactive demo); the other work is a grid on the left. */
.projects-layout { display: grid; grid-template-columns: 1.55fr 1fr; gap: 10px; align-items: stretch; }
.projects-layout > .grid { grid-template-columns: 1fr 1fr; }
@media (max-width: 720px) { .projects-layout { grid-template-columns: 1fr; } }
@media (max-width: 540px) { .projects-layout > .grid { grid-template-columns: 1fr; } }

.proj-feature { padding: 20px; background: var(--panel-2); border-color: var(--line-2); }
.proj-feature h3 { font-size: 17px; margin-top: 2px; }
.proj-feature .p-desc { font-size: 12.5px; color: var(--text-2); }
.pf-cta { margin-top: 16px; font-family: var(--mono); font-size: 12px; font-weight: 500; color: var(--text); }
.proj-feature:hover .pf-cta { text-decoration: underline; text-underline-offset: 3px; }

/* ---- About / experience / education ---- */
.about-bio { max-width: 64ch; color: var(--text-2); font-size: 13.5px; line-height: 1.68; }
.about-cols { display: grid; grid-template-columns: 1.5fr 1fr; gap: 34px; margin-top: 28px; }
@media (max-width: 720px) { .about-cols { grid-template-columns: 1fr; gap: 26px; } }
.col-title { font-family: var(--mono); font-size: 10.5px; color: var(--muted); letter-spacing: 0.08em; text-transform: lowercase; margin-bottom: 15px; }

.xp { display: flex; flex-direction: column; }
.xp-item { padding: 13px 0; border-top: 1px solid var(--line); }
.xp-item:first-of-type { border-top: 0; padding-top: 0; }
.xp-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.xp-role { font-size: 13.5px; font-weight: 600; letter-spacing: -0.01em; }
.xp-when { font-family: var(--mono); font-size: 10.5px; color: var(--muted-2); white-space: nowrap; }
.xp-org { font-size: 12px; color: var(--muted); margin-top: 2px; }
.xp-note { font-size: 12px; color: var(--text-2); margin-top: 7px; line-height: 1.55; }

.edu-item { padding-bottom: 18px; }
.edu-item .xp-role { font-size: 13.5px; }
.edu-item .deg { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.skills { margin-top: 26px; }
.skill-group { margin-bottom: 14px; }
.skill-group .sg-label { font-size: 11px; color: var(--muted-2); margin-bottom: 6px; }
.skill-group .sg-items { display: flex; flex-wrap: wrap; gap: 6px; }
.skill-group .sg-items span { font-size: 11px; font-family: var(--mono); color: var(--text-2); border: 1px solid var(--line); border-radius: 6px; padding: 3px 8px; }

/* ---- Story / timeline (horizontal rail; titles always shown, notes reveal on hover) ---- */
.timeline-h { margin-top: 4px; }
/* single continuous rail: one row, items shrink to fit so it never scrolls */
.tl-track { display: flex; flex-wrap: nowrap; gap: 0; align-items: flex-start; overflow: visible; }
.tl-item {
  position: relative; flex: 1 1 0; min-width: 0; cursor: pointer;
  border-top: 1px solid var(--line);
  padding: 17px 16px 4px 0;      /* rail sits on the top border; right pad separates columns */
  align-self: flex-start;
}
.tl-item:focus-visible { outline: 2px solid var(--muted); outline-offset: 4px; border-radius: 2px; }
.tl-dot {
  position: absolute; top: -6px; left: 0; width: 12px; height: 12px;
  border-radius: 50%; border: 1px solid var(--line-2); background: var(--bg);
  transition: border-color 0.15s ease;
}
.tl-item:hover .tl-dot { border-color: var(--muted); }
/* the present moment reads as a filled node */
.tl-now .tl-dot { background: var(--text); border-color: var(--text); }
/* clicking a node pins its blurb open; an extra ring marks the selected node */
.tl-dot::after {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  border: 1px solid var(--muted); opacity: 0; transform: scale(0.55);
  transition: opacity 0.18s ease, transform 0.18s ease; pointer-events: none;
}
.tl-item.tl-pinned .tl-dot { border-color: var(--text); }
.tl-item.tl-pinned .tl-dot::after { opacity: 1; transform: none; }

.tl-meta { display: flex; align-items: baseline; gap: 8px; }
.tl-meta .tl-year { font-family: var(--mono); font-size: 12.5px; font-weight: 500; color: var(--text); letter-spacing: 0.01em; }
.tl-meta .tl-when { font-family: var(--mono); font-size: 9.5px; color: var(--muted-2); letter-spacing: 0.05em; text-transform: lowercase; }
.tl-title { font-size: 12.5px; font-weight: 600; letter-spacing: -0.01em; margin-top: 8px; color: var(--text); }
/* note is a floating popover: it overlays neighbours on hover, never pushes layout */
.tl-note {
  position: absolute; top: 100%; left: 0; z-index: 8;
  width: 240px; max-width: 82vw; margin-top: 8px;
  color: var(--text-2); font-size: 11.5px; line-height: 1.5;
  background: var(--panel-2); border: 1px solid var(--line-2); border-radius: 10px;
  box-shadow: 0 12px 32px -12px rgba(0, 0, 0, 0.65);
  padding: 11px 13px;
  opacity: 0; visibility: hidden; transform: translateY(-4px); pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0.18s ease;
}
/* right-edge items open leftward so the popover stays on-screen */
.tl-item:nth-last-child(-n+2) .tl-note { left: auto; right: 0; }
/* hover/focus peek only when nothing is pinned — so at most one caption ever shows */
.tl-track:not(.has-pinned) .tl-item:hover .tl-note,
.tl-track:not(.has-pinned) .tl-item:focus-within .tl-note,
.tl-item.tl-pinned .tl-note { opacity: 1; visibility: visible; transform: none; pointer-events: auto; }
.tl-note em { font-style: italic; color: var(--text); }
@media (prefers-reduced-motion: reduce) { .tl-note { transition: opacity 0.18s ease; } }

/* narrow screens: a horizontal line won't fit, so switch to a vertical timeline (still no scrollbars) */
@media (max-width: 820px) {
  .tl-track { flex-direction: column; }
  .tl-item {
    flex: none; width: 100%; min-width: 0;
    border-top: 0; border-left: 1px solid var(--line);
    padding: 0 0 20px 22px;        /* rail moves to the left edge */
  }
  .tl-item:last-child { padding-bottom: 0; }
  .tl-dot { top: 2px; left: -6px; }
  .tl-note,
  .tl-item:nth-last-child(-n+2) .tl-note { left: 22px; right: auto; width: min(340px, 86%); }
}

/* ---- Contact / footer ---- */
.contact h2 { font-size: clamp(18px, 3.6vw, 25px); }
.contact p { color: var(--muted); margin: 12px 0 20px; max-width: 50ch; font-size: 13.5px; }
.contact .links { display: flex; gap: 10px; flex-wrap: wrap; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 9px;
  border: 1px solid var(--line-2); background: transparent; color: var(--text-2);
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.icon-btn:hover { border-color: var(--muted); color: var(--text); transform: translateY(-1px); }
.icon-btn:focus-visible { outline: 2px solid var(--muted); outline-offset: 2px; }
.icon-btn svg { width: 18px; height: 18px; display: block; }
@media (prefers-reduced-motion: reduce) { .icon-btn { transition: none; } .icon-btn:hover { transform: none; } }
footer.foot { border-top: 1px solid var(--line); padding: 24px 0; }
footer.foot .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
footer.foot .muted { color: var(--muted-2); font-size: 12px; }

/* reveal-on-scroll — fade only (no translate) so elements don't shift on render */
.reveal { opacity: 0; transition: opacity 0.5s ease; }
.reveal.in { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transition: none; }
  html { scroll-behavior: auto; }
}

/* ---- Project detail modal ---- */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: clamp(14px, 4vw, 32px); }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.62); backdrop-filter: blur(4px); animation: modal-fade 0.18s ease; }
.modal-card {
  position: relative; z-index: 1; width: min(880px, 100%); max-height: min(88vh, 720px);
  overflow: auto; background: var(--panel); border: 1px solid var(--line-2);
  border-radius: 16px; animation: modal-pop 0.2s ease;
}
.modal-x {
  position: absolute; top: 12px; right: 12px; z-index: 3;
  width: 30px; height: 30px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line-2); background: var(--panel-2); color: var(--text-2);
  font-size: 19px; line-height: 1; display: grid; place-items: center;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.modal-x:hover { color: var(--text); border-color: var(--muted); }
.modal-body { display: grid; grid-template-columns: 1fr 0.85fr; align-items: stretch; }
.modal.no-media .modal-body { grid-template-columns: 1fr; }
.modal-main { padding: clamp(22px, 3.4vw, 34px); }
.pm-status { font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em; color: var(--muted-2); text-transform: lowercase; }
.pm-status.live { color: var(--good); }
.pm-title { font-size: clamp(20px, 3.2vw, 26px); margin: 8px 0 14px; }
.pm-ps {
  margin: 0 0 16px; display: flex; flex-direction: column; gap: 10px;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel-2);
}
.pm-ps:empty { display: none; }
.pm-ps .ps-line { font-size: 13px; line-height: 1.5; color: var(--text-2); margin: 0; }
.pm-ps .ps-k {
  display: block; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.08em;
  color: var(--muted); margin-bottom: 3px;
}
.pm-desc { color: var(--text-2); font-size: 14px; line-height: 1.68; }
.pm-tags { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 8px; }
.pm-tags:empty { display: none; }
.pm-tags span { font-size: 11px; font-family: var(--mono); color: var(--muted); }
.pm-tags span::before { content: "#"; opacity: 0.5; }
.pm-actions { margin-top: 22px; display: flex; gap: 10px; flex-wrap: wrap; }
.pm-actions:empty { display: none; }
.modal-media { background: #f4f4f5; display: flex; flex-direction: column; min-height: 260px; border-left: 1px solid var(--line); }
.modal.no-media .modal-media { display: none; }
.modal-media > #pmImg { width: 100%; flex: 1; min-height: 0; object-fit: contain; padding: 18px; }
.modal-media > #pmModel {
  width: 100%; flex: 1; min-height: 340px;
  --poster-color: transparent;
  background:
    radial-gradient(120% 90% at 50% 12%, #fbfbfc 0%, #eeeef1 60%, #e4e4e8 100%);
}
.modal-media > #pmModel[hidden] { display: none; }
.pm-thumbs { display: flex; gap: 8px; padding: 0 14px 14px; flex-wrap: wrap; }
.pm-thumbs:empty { display: none; }
.pm-thumbs button {
  width: 54px; height: 40px; padding: 0; border-radius: 6px; overflow: hidden; cursor: pointer;
  border: 1px solid var(--line-2); background: #fff; opacity: 0.55;
  transition: opacity 0.15s ease, border-color 0.15s ease;
}
.pm-thumbs button:hover { opacity: 0.85; }
.pm-thumbs button.active { opacity: 1; border-color: #6b6b74; }
.pm-thumbs button img { width: 100%; height: 100%; object-fit: cover; padding: 0; }
.pm-thumbs button.thumb-3d {
  display: grid; place-items: center; opacity: 0.75;
  font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: 0.04em;
  color: var(--text-2); background: #fff;
}
.pm-thumbs button.thumb-3d::after { content: "\00B7 spin"; font-size: 9px; color: var(--muted); margin-left: 3px; }
.pm-thumbs button.thumb-3d.active { opacity: 1; color: var(--text); }
body.modal-open { overflow: hidden; }
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-pop { from { opacity: 0; transform: translateY(8px) scale(0.99); } to { opacity: 1; transform: none; } }
@media (max-width: 680px) {
  .modal-body { grid-template-columns: 1fr; }
  .modal-media { order: -1; border-left: 0; border-bottom: 1px solid var(--line); min-height: 200px; }
}
@media (prefers-reduced-motion: reduce) {
  .modal-backdrop, .modal-card { animation: none; }
}
