/* ===== Tokens ===== */
:root {
  --ink: #0A1F38;      /* deep blueprint, panels */
  --blue: #0F2A4A;     /* blueprint paper */
  --chalk: #E9EEF4;    /* lines and text */
  --chalk-2: #A9BBD0;  /* secondary text */
  --amber: #F5B841;    /* data packets, actions */
  --line: rgba(233, 238, 244, 0.16);
  --grid: rgba(233, 238, 244, 0.045);
  --display: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --nav-h: 60px;
  --gutter: clamp(1.25rem, 6vw, 6rem);
  color-scheme: dark;
  box-sizing: border-box;
}
*, *::before, *::after { box-sizing: inherit; }

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(env(safe-area-inset-top, 0px) + var(--nav-h));
}
.no-motion { scroll-behavior: auto; }

body {
  margin: 0;
  background: var(--blue);
  color: var(--chalk);
  font: 400 1.0625rem/1.65 var(--body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* blueprint graph paper: fine grid + heavier 5x grid */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(233, 238, 244, 0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(233, 238, 244, 0.07) 1px, transparent 1px),
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 160px 160px, 160px 160px, 32px 32px, 32px 32px;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  display: block;
  opacity: var(--fade, 1);
}
.no-3d #scene, .no-3d .hint, .no-3d .readout { display: none; }

a { color: inherit; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; border-radius: 2px; }

/* ===== Nav ===== */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: calc(env(safe-area-inset-top, 0px) + 0.9rem) var(--gutter) 0.9rem;
  background: linear-gradient(var(--blue) 60%, rgba(15, 42, 74, 0));
}
.nav-mark {
  font: 700 1rem/1 var(--display);
  font-stretch: 118%;
  text-decoration: none;
  white-space: nowrap;
  margin-right: auto;
}
.nav nav { display: flex; gap: clamp(0.9rem, 2.2vw, 1.8rem); overflow-x: auto; scrollbar-width: none; }
.nav nav::-webkit-scrollbar { display: none; }
.nav nav a {
  color: var(--chalk-2);
  text-decoration: none;
  font-size: 0.95rem;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.nav nav a:hover { color: var(--chalk); }
.nav nav a[aria-current="true"] { color: var(--chalk); border-bottom-color: var(--amber); }

.motion-toggle {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--line); border-radius: 4px;
  background: rgba(10, 31, 56, 0.6); color: var(--chalk-2);
  font: 500 0.75rem/1 var(--mono); letter-spacing: 0.06em; text-transform: uppercase;
  cursor: pointer; white-space: nowrap;
}
.motion-toggle:hover { color: var(--chalk); border-color: var(--chalk-2); }
.mt-icon { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.motion-toggle[aria-pressed="false"] .mt-icon { background: transparent; box-shadow: none; border: 1.5px solid var(--chalk-2); }

/* ===== Type ===== */
main { position: relative; z-index: 1; }
h1, h2, h3 { font-family: var(--display); margin: 0; }
h1 {
  font-size: clamp(2.6rem, 5.6vw, 5rem);
  font-weight: 800;
  font-stretch: 125%;
  line-height: 0.92;
  letter-spacing: -0.02em;
  max-width: 9ch;
}
h2 {
  font-size: clamp(1.9rem, 3.6vw, 2.9rem);
  font-weight: 700;
  font-stretch: 112%;
  line-height: 1.05;
  letter-spacing: -0.01em;
  margin-bottom: 0.6em;
}
p { margin: 0 0 1em; max-width: 62ch; }
.intro { color: var(--chalk-2); }
.sheet-no, .step-tag {
  font: 500 0.75rem/1.4 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--amber);
  margin-bottom: 0.9rem;
}

/* ===== Buttons ===== */
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.8rem; }
.btn {
  display: inline-block;
  padding: 0.75em 1.25em;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(10, 31, 56, 0.55);
  text-decoration: none;
  font-weight: 500;
  transition: border-color 0.2s;
}
.btn:hover { border-color: var(--chalk-2); }
.btn-primary { background: var(--amber); border-color: var(--amber); color: var(--ink); font-weight: 600; }
.btn-primary:hover { border-color: var(--chalk); }

/* ===== Hero ===== */
.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  padding: 6.5rem 0 4rem;
  cursor: crosshair;
}
.hero a, .hero button { cursor: pointer; }
.no-3d .hero { cursor: auto; }
.hero-grid {
  width: 100%;
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: grid;
  grid-template-columns: minmax(0, 38rem) minmax(0, 1fr);
  gap: 2rem;
  align-items: center;
}
.role { margin-top: 1.4rem; font-weight: 500; font-size: 1.15rem; }
.lede { color: var(--chalk-2); }
.hint { margin-top: 2.2rem; font: 400 0.8rem/1.4 var(--mono); letter-spacing: 0.06em; color: var(--chalk-2); }
.hero-figure { position: relative; width: 100%; aspect-ratio: 1; max-height: 74svh; justify-self: center; }
.hero-annot { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.readout {
  position: absolute; right: 0; bottom: 0; margin: 0;
  display: grid; gap: 0.35rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--line); border-radius: 4px;
  background: rgba(10, 31, 56, 0.7);
  font: 400 0.72rem/1.3 var(--mono); letter-spacing: 0.06em; text-transform: uppercase;
}
.readout div { display: flex; justify-content: space-between; gap: 1.2rem; }
.readout dt { color: var(--chalk-2); }
.readout dd { margin: 0; color: var(--amber); font-variant-numeric: tabular-nums; }
.scroll-cue {
  position: absolute; left: 50%; bottom: 1.4rem; transform: translateX(-50%);
  margin: 0; font: 400 0.72rem/1 var(--mono); letter-spacing: 0.14em; text-transform: uppercase; color: var(--chalk-2);
}
.scroll-cue::after {
  content: ""; display: block; width: 1px; height: 28px; margin: 0.7rem auto 0;
  background: linear-gradient(var(--amber), transparent);
  animation: cue 1.8s ease-in-out infinite;
}
@keyframes cue { 0%, 100% { transform: scaleY(0.4); transform-origin: top; } 50% { transform: scaleY(1); transform-origin: top; } }

.ping {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  transform: translate(-50%, -120%);
  font: 500 0.8rem/1 var(--mono);
  color: var(--amber);
  white-space: pre;
  animation: ping-rise 1.2s ease-out forwards;
}
@keyframes ping-rise {
  from { opacity: 1; transform: translate(-50%, -120%); }
  to { opacity: 0; transform: translate(-50%, -260%); }
}

/* ===== Sheets: sticky drawing + scrolling story ===== */
.sheet { position: relative; padding: 4rem 0 2rem; }
.sheet-grid {
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: grid;
  grid-template-columns: minmax(17rem, 0.8fr) minmax(0, 1.2fr);
  grid-template-areas: "story figure";
  gap: clamp(1.5rem, 4vw, 4.5rem);
}
.story { grid-area: story; position: relative; z-index: 1; }
.figure {
  grid-area: figure;
  position: sticky;
  top: calc(var(--nav-h) + 12px);
  height: calc(100vh - var(--nav-h) - 36px);
  height: calc(100svh - var(--nav-h) - 36px);
  align-self: start;
}
.step {
  min-height: 64vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2.5rem 0;
  opacity: 0.32;
  transition: opacity 0.45s ease;
}
.step:first-child { min-height: calc(100svh - var(--nav-h) - 36px); }
.step:last-child { min-height: 80vh; }
.step.is-active { opacity: 1; }
.no-motion .step { transition: none; }
.step-big {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  font-weight: 800;
  font-stretch: 115%;
  line-height: 1.05;
  margin-bottom: 0.5em;
}
.step-cue { color: var(--chalk-2); font-size: 0.95rem; }
.step p:not(.sheet-no):not(.step-tag) { color: var(--chalk-2); }
.step h2 + p, .step .step-big + p { color: var(--chalk) !important; }

/* experience steps */
.job-company { font: 700 1.6rem/1.1 var(--display); font-stretch: 110%; margin-bottom: 0.25rem; }
.job-role { font-size: 0.95rem; margin-bottom: 0.9rem; }
.more { margin-top: 0.4rem; border-top: 1px solid var(--line); }
.more summary {
  cursor: pointer; list-style: none;
  padding: 0.7rem 0;
  font: 500 0.78rem/1 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--chalk-2);
}
.more summary::-webkit-details-marker { display: none; }
.more summary::before { content: "+ "; color: var(--amber); }
.more[open] summary::before { content: "− "; }
.more summary:hover { color: var(--chalk); }
.more ul { margin: 0 0 0.9rem; padding-left: 1.1rem; }
.more li { margin-bottom: 0.45rem; font-size: 0.97rem; }
.more li::marker { color: var(--amber); }
.job-stack { font-size: 0.88rem; color: var(--chalk-2); margin: 0 0 0.6rem; }

/* stack chips */
.stack-group { margin-bottom: 1.1rem; }
.stack-group h3 { font: 500 0.72rem/1.4 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--chalk-2); margin-bottom: 0.5rem; }
.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.chip {
  padding: 0.3em 0.75em;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: rgba(10, 31, 56, 0.6);
  color: var(--chalk);
  font: 400 0.92rem/1.4 var(--body);
  cursor: pointer;
}
.chip:hover { border-color: var(--chalk-2); }
.chip[aria-pressed="true"] { background: var(--amber); border-color: var(--amber); color: var(--ink); font-weight: 600; }
.stack-detail {
  margin: 1.4rem 0;
  padding: 0.2rem 0 0.2rem 1rem;
  border-left: 2px solid var(--amber);
  min-height: 3rem;
  color: var(--chalk-2);
}
.stack-detail strong { color: var(--chalk); }
.also { color: var(--chalk-2); font-size: 0.92rem; }

/* side projects */
.work { position: relative; padding-top: 4rem; }
.work-head { max-width: 1360px; margin: 0 auto; padding: 0 var(--gutter) 1rem; }
.work-head .intro { max-width: 46ch; }
.project-meta { font: 400 0.8rem/1.5 var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--chalk-2); }
.project-name { font: 800 clamp(1.7rem, 3vw, 2.3rem)/1.05 var(--display); font-stretch: 112%; margin-bottom: 0.6rem; }
.project-stack { font: 400 0.8rem/1.6 var(--mono); letter-spacing: 0.04em; color: var(--chalk-2); }

/* more side projects: a drawing schedule */
.more-projects { max-width: 1360px; margin: 0 auto; padding: 3rem var(--gutter) 2rem; }
.more-title { font: 700 clamp(1.4rem, 2.4vw, 1.9rem)/1.1 var(--display); font-stretch: 110%; margin-bottom: 1rem; }
.schedule { width: 100%; max-width: 44rem; border-collapse: collapse; font: 400 0.95rem/1.4 var(--body); }
.schedule th {
  text-align: left; padding: 0.6rem 0.8rem;
  font: 500 0.72rem/1 var(--mono); letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--amber); border-bottom: 1px solid var(--chalk-2);
}
.schedule td { padding: 0.7rem 0.8rem; border-bottom: 1px solid var(--line); color: var(--chalk-2); }
.schedule td:first-child { width: 5rem; font-family: var(--mono); color: var(--chalk); font-variant-numeric: tabular-nums; }
.schedule tr:hover td { background: rgba(245, 184, 65, 0.06); }

/* contact */
.email {
  display: inline-block;
  margin: 0.4rem 0 0.4rem;
  font: 700 clamp(1.2rem, 2.6vw, 1.9rem)/1.2 var(--display);
  font-stretch: 108%;
  color: var(--amber);
  text-decoration: none;
  overflow-wrap: anywhere;
  border-bottom: 2px solid transparent;
}
.email:hover { border-bottom-color: var(--amber); }
.foot { max-width: 1360px; margin: 0 auto; padding: 2rem var(--gutter) 3rem; color: var(--chalk-2); font: 400 0.78rem/1 var(--mono); letter-spacing: 0.08em; }

/* ===== Small screens: drawing pinned on top, story scrolls below ===== */
@media (max-width: 899px) {
  :root { --nav-h: 54px; }
  .hero { align-items: flex-start; padding-top: calc(var(--nav-h) + 0.25rem); }
  .hero-grid { grid-template-columns: minmax(0, 1fr); gap: 0.25rem; }
  .hero-figure { order: -1; width: min(100%, 32svh); max-height: none; }
  .hero-figure .readout, .hero-figure .hero-annot { display: none; }
  .sheet-grid { grid-template-columns: minmax(0, 1fr); grid-template-areas: "figure" "story"; gap: 0; }
  .figure {
    z-index: 2;
    height: 46vh;
    height: 46svh;
    padding-bottom: 0.8rem;
    background: linear-gradient(var(--blue) 92%, rgba(15, 42, 74, 0));
    pointer-events: none; /* the faded strip must not swallow taps on the chips below */
  }
  .figure .fig { pointer-events: auto; }
  .step { min-height: 50vh; min-height: 50svh; padding: 1.5rem 0; }
  .step:first-child { min-height: 50svh; }
  .step:last-child { min-height: 60svh; }
}
@media (max-width: 560px) {
  .nav-mark { display: none; }
  .nav { padding-left: 1rem; padding-right: 1rem; gap: 0.75rem; }
  .nav nav { margin-right: auto; gap: 0.75rem; }
  .nav nav a { font-size: 0.85rem; }
  .mt-label { display: none; }
  .motion-toggle { padding: 0.45rem; }
  .scroll-cue { display: none; }
}
