/* ===========================================================================
   Owen Tharp — resume site
   Visual system: "control room / blueprint". Dark by default, light supported.
   =========================================================================== */

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
* { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
img, svg, video, canvas { display: block; max-width: 100%; }
/* The width/height attributes (kept to reserve layout space) would otherwise
   make the box definite and defeat every aspect-ratio rule below. */
img { height: auto; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
ul, ol { list-style: none; padding: 0; }
:target { scroll-margin-top: 6rem; }

/* ---------- tokens ---------- */
:root {
  --bg:        #0a0c12;
  --bg-deep:   #06080d;
  --surface:   #11151e;
  --surface-2: #161b26;
  --line:      #232a39;
  --line-soft: #1a202c;
  --text:      #e9ecf3;
  --muted:     #8a93a8;
  --faint:     #767f93;  /* 4.87:1 on --bg — small mono labels stay AA */
  --accent:    #ff8a3d;
  --on-accent: #0a0c12;  /* text sitting on an accent fill */
  --accent-dim:#8a4a1e;
  --accent-2:  #5ee9d0;
  --accent-2-dim: #1f5c53;
  --grid:      rgba(255, 138, 61, 0.055);
  --glow:      rgba(255, 138, 61, 0.16);
  --glow-2:    rgba(94, 233, 208, 0.13);
  --shadow:    0 20px 60px -20px rgba(0, 0, 0, .75);

  --font-display: "Space Grotesk", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace;

  --wrap: 1200px;
  --pad: clamp(1.15rem, 4vw, 3rem);
  --radius: 14px;
  --ease: cubic-bezier(.22, 1, .36, 1);
}

[data-theme="light"] {
  --bg:        #f5f2ec;
  --bg-deep:   #ece8df;
  --surface:   #ffffff;
  --surface-2: #faf8f4;
  --line:      #ddd6c9;
  --line-soft: #e8e2d7;
  --text:      #12161d;
  --muted:     #5d6472;
  --faint:     #686f7e;  /* 4.51:1 on --bg, 5.04:1 on --surface */
  --accent:    #b8490a;  /* 4.7:1 on --bg — the eyebrow/link text is small */
  --on-accent: #ffffff;  /* the light accent is dark, so flip to white */
  --accent-dim:#f0c6a5;
  --accent-2:  #0b7d6d;
  --accent-2-dim: #a9dcd4;
  --grid:      rgba(18, 40, 90, 0.055);
  --glow:      rgba(201, 83, 10, 0.10);
  --glow-2:    rgba(11, 125, 109, 0.09);
  --shadow:    0 18px 44px -22px rgba(30, 30, 40, .35);
}

/* ---------- base ---------- */
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: clamp(1rem, .96rem + .18vw, 1.075rem);
  line-height: 1.62;
  overflow-x: hidden;
}

/* blueprint grid + ambient glow, fixed behind everything */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(ellipse 120% 90% at 50% 0%, #000 35%, transparent 88%);
  -webkit-mask-image: radial-gradient(ellipse 120% 90% at 50% 0%, #000 35%, transparent 88%);
  pointer-events: none;
}
body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -3;
  background:
    radial-gradient(60rem 40rem at 78% -8%, var(--glow), transparent 62%),
    radial-gradient(46rem 34rem at 8% 12%, var(--glow-2), transparent 60%);
  pointer-events: none;
}

h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 700; line-height: 1.08; letter-spacing: -.02em; }

::selection { background: var(--accent); color: var(--on-accent); }

:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 3px;
  border-radius: 4px;
}

.wrap { width: min(100% - var(--pad) * 2, var(--wrap)); margin-inline: auto; }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 200;
  background: var(--accent); color: var(--on-accent); padding: .7rem 1.1rem;
  border-radius: 0 0 8px 0; font-weight: 600;
}
.skip:focus { left: 0; }

/* ---------- shared bits ---------- */
.mono { font-family: var(--font-mono); }

.eyebrow {
  font-family: var(--font-mono);
  font-size: .72rem;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: .7rem;
}
.eyebrow::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, var(--line), transparent);
}

.section { padding-block: clamp(4.5rem, 9vw, 8.5rem); position: relative; }
.section-head { margin-bottom: clamp(2.2rem, 4vw, 3.4rem); }
.section-head h2 {
  font-size: clamp(2rem, 1.3rem + 3.2vw, 3.6rem);
  margin-top: .85rem;
  max-width: 22ch;
}
.section-head p {
  color: var(--muted);
  max-width: 62ch;
  margin-top: 1rem;
  font-size: 1.02rem;
}

.chip {
  display: inline-flex; align-items: center; gap: .45rem;
  font-family: var(--font-mono);
  font-size: .76rem;
  letter-spacing: .04em;
  padding: .32rem .7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  transition: border-color .25s var(--ease), color .25s var(--ease), background .25s var(--ease);
}
.chip:hover { color: var(--text); border-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .6rem;
  padding: .82rem 1.4rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 600;
  font-size: .94rem;
  text-decoration: none;
  cursor: pointer;
  transition: transform .22s var(--ease), border-color .22s var(--ease), background .22s var(--ease), color .22s var(--ease);
}
.btn:hover { transform: translateY(-2px); border-color: var(--accent); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.btn-primary:hover { filter: brightness(1.08); }

/* ---------- nav ---------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 90;
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  /* safe-area insets keep the bar clear of notches / dynamic island */
  padding-top: max(.85rem, env(safe-area-inset-top));
  padding-bottom: .85rem;
  padding-left: max(var(--pad), env(safe-area-inset-left));
  padding-right: max(var(--pad), env(safe-area-inset-right));
  background: color-mix(in srgb, var(--bg) 72%, transparent);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border-bottom: 1px solid transparent;
  transition: border-color .3s var(--ease), background .3s var(--ease);
}
.nav.scrolled { border-bottom-color: var(--line-soft); }
.nav-brand {
  display: flex; align-items: center; gap: .65rem;
  font-family: var(--font-display); font-weight: 700;
  letter-spacing: -.01em; text-decoration: none; font-size: 1.02rem;
}
.nav-brand svg { width: 26px; height: 26px; flex: none; }
.nav-links { display: flex; gap: .25rem; align-items: center; }
.nav-links a {
  padding: .45rem .78rem;
  border-radius: 8px;
  font-size: .88rem;
  color: var(--muted);
  text-decoration: none;
  transition: color .2s var(--ease), background .2s var(--ease);
}
.nav-links a:hover, .nav-links a.active { color: var(--text); background: var(--surface); }
.nav-tools { display: flex; align-items: center; gap: .5rem; }
.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .2s var(--ease), color .2s var(--ease), transform .2s var(--ease);
}
.icon-btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.icon-btn svg { width: 17px; height: 17px; }
.kbd-hint {
  display: flex; align-items: center; gap: .35rem;
  font-family: var(--font-mono); font-size: .72rem;
  color: var(--faint);
  border: 1px solid var(--line);
  background: var(--surface);
  padding: .42rem .6rem;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .2s var(--ease), color .2s var(--ease);
}
.kbd-hint:hover { border-color: var(--accent); color: var(--text); }
.kbd-ico { width: 15px; height: 15px; display: none; }

/* Below the nav-link breakpoint the palette becomes the only navigation, so it
   stays put and collapses to an icon rather than disappearing. */
@media (max-width: 940px) {
  .nav-links { display: none; }
  .kbd-label, .kbd-key { display: none; }
  .kbd-ico { display: block; }
  .kbd-hint { width: 38px; height: 38px; justify-content: center; padding: 0; border-radius: 9px; }
}

/* ---------- hero ---------- */
.hero {
  min-height: 100svh;
  display: flex; align-items: center;
  padding-top: 6rem; padding-bottom: 3rem;
  position: relative;
}
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(0, 1fr);
  gap: clamp(2rem, 4vw, 4rem);
  align-items: center;
  /* no width here: .wrap owns the measure, and setting it would override the cap */
}
/* On stacked layouts the sim no longer needs to fill the viewport — letting
   the hero take its natural height keeps "See the work" reachable quickly. */
@media (max-width: 980px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero { min-height: auto; padding-top: 7rem; }
}

.hero-name {
  font-size: clamp(2.9rem, 1.2rem + 7.6vw, 6.6rem);
  line-height: .92;
  letter-spacing: -.045em;
  margin: 1rem 0 0;
}
.hero-name .ln { display: block; overflow: hidden; }
.hero-name .ln > span {
  display: block;
  background: linear-gradient(180deg, var(--text) 55%, color-mix(in srgb, var(--text) 45%, var(--bg)));
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.hero-role {
  margin-top: 1.35rem;
  font-size: clamp(1.05rem, .95rem + .5vw, 1.3rem);
  color: var(--muted);
  max-width: 46ch;
}
.hero-role strong { color: var(--text); font-weight: 600; }
.hero-meta { display: flex; flex-wrap: wrap; gap: .55rem; margin-top: 1.6rem; }
.hero-meta a { text-decoration: none; }
.hero-cta { display: flex; flex-wrap: wrap; gap: .75rem; margin-top: 2rem; }

.scroll-cue {
  position: absolute; bottom: 1.6rem; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: .5rem;
  font-family: var(--font-mono); font-size: .68rem; letter-spacing: .2em;
  color: var(--faint); text-transform: uppercase;
}
.scroll-cue span.rail {
  width: 1px; height: 42px;
  background: linear-gradient(var(--accent), transparent);
  animation: cue 2.1s var(--ease) infinite;
  transform-origin: top;
}
@keyframes cue { 0%, 100% { transform: scaleY(.35); opacity: .4 } 50% { transform: scaleY(1); opacity: 1 } }
@media (max-width: 980px) { .scroll-cue { display: none; } }

/* ---------- pendulum panel ---------- */
.rig {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(180deg, var(--surface), var(--bg-deep));
  box-shadow: var(--shadow);
  overflow: hidden;
}
.rig::before {
  content: "";
  position: absolute; inset: 0;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: .8;
  pointer-events: none;
}
.rig-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem;
  padding: .7rem .95rem;
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--font-mono); font-size: .72rem;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--faint);
  position: relative;
}
.rig-title { display: flex; align-items: center; gap: .55rem; }
.dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 0 0 var(--accent-2);
  animation: pulse 2.4s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent-2) 55%, transparent); }
  70% { box-shadow: 0 0 0 8px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.mode-badge {
  padding: .2rem .55rem; border-radius: 5px;
  border: 1px solid var(--accent-2-dim);
  color: var(--accent-2);
  background: color-mix(in srgb, var(--accent-2) 10%, transparent);
  font-size: .68rem;
  transition: color .3s, border-color .3s, background .3s;
}
.mode-badge[data-mode="SWING-UP"] {
  border-color: var(--accent-dim); color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

/* The pendulum's reachable envelope is near square, so 4:3 wasted width;
   5:4 lets the drawing scale up without making the hero panel much taller. */
.rig-canvas-wrap { position: relative; aspect-ratio: 5 / 4; }
#pendulum { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#pendulum:active { cursor: grabbing; }

.rig-hint {
  position: absolute; left: 50%; bottom: .85rem; transform: translateX(-50%);
  font-family: var(--font-mono); font-size: .68rem; color: var(--faint);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border: 1px solid var(--line-soft);
  padding: .3rem .65rem; border-radius: 999px;
  pointer-events: none;
  white-space: nowrap;
  transition: opacity .4s var(--ease);
}

.telemetry {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line-soft);
  position: relative;
}
.tele {
  padding: .6rem .5rem .65rem;
  text-align: center;
  border-right: 1px solid var(--line-soft);
}
.tele:last-child { border-right: 0; }
.tele dt {
  font-family: var(--font-mono); font-size: .62rem;
  letter-spacing: .12em; text-transform: uppercase; color: var(--faint);
}
.tele dd {
  font-family: var(--font-mono); font-size: .96rem;
  margin-top: .18rem; font-variant-numeric: tabular-nums;
  color: var(--text);
}
.tele dd em { font-style: normal; color: var(--faint); font-size: .7rem; margin-left: .1rem; }

.rig-foot {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  padding: .65rem .8rem;
  border-top: 1px solid var(--line-soft);
  position: relative;
}
.rig-foot .spacer { flex: 1; }

/* narrow screens: let the hint wrap and pull the telemetry in */
@media (max-width: 560px) {
  .rig-hint {
    white-space: normal;
    text-align: center;
    max-width: calc(100% - 1.6rem);
    line-height: 1.45;
  }
  .tele dd { font-size: .84rem; }
  .tele dd em { font-size: .62rem; }
  .tele dt { font-size: .58rem; letter-spacing: .08em; }
  #scope { width: 100%; }
}
.mini-btn {
  font-family: var(--font-mono); font-size: .72rem;
  padding: .38rem .7rem; border-radius: 7px;
  border: 1px solid var(--line); background: var(--surface);
  cursor: pointer;
  transition: border-color .2s var(--ease), color .2s var(--ease), background .2s var(--ease);
}
.mini-btn:hover { border-color: var(--accent); color: var(--accent); }
.mini-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
#scope { border-radius: 5px; opacity: .95; }

/* ---------- marquee ---------- */
.marquee {
  border-block: 1px solid var(--line-soft);
  background: color-mix(in srgb, var(--surface) 55%, transparent);
  overflow: hidden;
  padding: .8rem 0;
  mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent);
}
.marquee-track { display: flex; width: max-content; animation: slide 46s linear infinite; }
.marquee:hover .marquee-track { animation-play-state: paused; }
.marquee-track span {
  font-family: var(--font-mono); font-size: .8rem;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--faint); padding-inline: 1.3rem;
  display: inline-flex; align-items: center; gap: 1.3rem;
}
.marquee-track span::after { content: "◆"; color: var(--accent); font-size: .5rem; }
@keyframes slide { to { transform: translateX(-50%); } }

/* ---------- metrics ---------- */
.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 165px), 1fr));
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: hidden;
}
.metric {
  background: var(--bg);
  padding: 1.5rem 1.15rem;
  position: relative;
  transition: background .3s var(--ease);
}
.metric:hover { background: var(--surface); }
.metric-val {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(1.9rem, 1.4rem + 1.8vw, 2.7rem);
  letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  display: flex; align-items: baseline; gap: .1rem;
}
.metric-val .suf { color: var(--accent); font-size: .55em; }
.metric-label {
  font-family: var(--font-mono); font-size: .7rem;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); margin-top: .4rem;
}
.metric-note { font-size: .78rem; color: var(--faint); margin-top: .3rem; }

/* ---------- about ---------- */
.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 300px) minmax(0, 1fr);
  gap: clamp(1.8rem, 4vw, 3.5rem);
  align-items: start;
}
@media (max-width: 860px) {
  .about-grid { grid-template-columns: 1fr; }
  /* stacked portrait at full column width reads as a banner; keep it card-sized */
  .portrait { max-width: 280px; }
  /* below desktop the facts grid can break 2+1; a lone last item stretches
     full-width instead of leaving an empty cell beside it */
  .about-facts div:nth-child(odd):last-child { grid-column: 1 / -1; }
}
.portrait {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
}
.portrait img { width: 100%; aspect-ratio: 4/5; object-fit: cover; }
.portrait::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 55%, color-mix(in srgb, var(--bg) 80%, transparent));
  pointer-events: none;
}
.about-body p + p { margin-top: 1.05rem; }
.about-body p { color: var(--muted); }
.about-body strong { color: var(--text); font-weight: 600; }
.about-facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  gap: 1px; background: var(--line-soft);
  border: 1px solid var(--line-soft); border-radius: 12px;
  overflow: hidden; margin-top: 1.8rem;
}
.about-facts div { background: var(--bg); padding: .95rem 1.05rem; }
.about-facts dt {
  font-family: var(--font-mono); font-size: .66rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--faint);
}
.about-facts dd { margin-top: .25rem; font-size: .92rem; }

/* ---------- timeline ---------- */
.timeline { position: relative; }
.timeline::before {
  content: "";
  position: absolute; left: 11px; top: 6px; bottom: 6px;
  width: 2px;
  background: var(--line);
}
.timeline-progress {
  position: absolute; left: 11px; top: 6px;
  width: 2px; height: 0;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  transition: height .12s linear;
}
@media (max-width: 700px) { .timeline::before, .timeline-progress { left: 7px; } }

.tl-item { position: relative; padding-left: 3.1rem; padding-bottom: clamp(2.4rem, 4vw, 3.6rem); }
.tl-item:last-child { padding-bottom: 0; }
@media (max-width: 700px) { .tl-item { padding-left: 2.2rem; } }

.tl-node {
  position: absolute; left: 0; top: .3rem;
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid var(--line);
  background: var(--bg);
  display: grid; place-items: center;
  transition: border-color .4s var(--ease), box-shadow .4s var(--ease);
}
.tl-node::after {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--faint);
  transition: background .4s var(--ease);
}
@media (max-width: 700px) { .tl-node { width: 16px; height: 16px; } .tl-node::after { width: 5px; height: 5px; } }
.tl-item.in .tl-node { border-color: var(--accent); box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 12%, transparent); }
.tl-item.in .tl-node::after { background: var(--accent); }

.tl-when {
  font-family: var(--font-mono); font-size: .74rem;
  letter-spacing: .1em; text-transform: uppercase; color: var(--accent);
}
.tl-role { font-size: clamp(1.25rem, 1.05rem + .8vw, 1.7rem); margin-top: .4rem; }
.tl-org { color: var(--muted); margin-top: .3rem; font-size: .95rem; }
.tl-org .sep { color: var(--faint); margin-inline: .45rem; }
.tl-points { margin-top: 1.1rem; display: grid; gap: .7rem; }
.tl-points li {
  position: relative; padding-left: 1.3rem;
  color: var(--muted); font-size: .96rem;
}
.tl-points li::before {
  content: ""; position: absolute; left: 0; top: .62em;
  width: 6px; height: 1px; background: var(--accent);
}
.tl-points li strong { color: var(--text); font-weight: 600; }
.tl-tags { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: 1.1rem; }

.tl-media {
  margin-top: 1.3rem;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: .8rem;
}
.tl-media figure {
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background: var(--surface);
  /* a lone figure would otherwise stretch to the full row and dwarf the
     two-up entries (and outrun its source resolution on retina) */
  max-width: 560px;
}
.tl-media img { width: 100%; aspect-ratio: 16/10; object-fit: cover; }
.tl-media figcaption {
  font-family: var(--font-mono); font-size: .68rem; color: var(--faint);
  padding: .5rem .65rem; border-top: 1px solid var(--line-soft);
}

/* ---------- projects ---------- */
.projects { display: grid; gap: clamp(1.5rem, 3vw, 2.4rem); }
.project {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  transition: border-color .35s var(--ease), transform .35s var(--ease), box-shadow .35s var(--ease);
}
.project:hover { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); box-shadow: var(--shadow); }
.project.flip > .project-media { order: 2; }
@media (max-width: 900px) {
  .project { grid-template-columns: 1fr; }
  .project.flip > .project-media { order: 0; }
}
.project-media { position: relative; background: var(--bg-deep); }
.project-media img, .project-media video { width: 100%; height: 100%; min-height: 240px; object-fit: cover; }
.project-media .badge {
  position: absolute; top: .8rem; left: .8rem;
  font-family: var(--font-mono); font-size: .66rem; letter-spacing: .12em;
  text-transform: uppercase;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border: 1px solid var(--line);
  color: var(--accent);
  padding: .3rem .6rem; border-radius: 6px;
  backdrop-filter: blur(6px);
}
.project-body { padding: clamp(1.4rem, 2.6vw, 2.2rem); display: flex; flex-direction: column; }
.project-title { font-size: clamp(1.3rem, 1.1rem + .9vw, 1.85rem); margin-top: .5rem; }
.project-sub { color: var(--muted); font-size: .93rem; margin-top: .45rem; }
.project-points { margin-top: 1.15rem; display: grid; gap: .65rem; }
.project-points li { position: relative; padding-left: 1.3rem; color: var(--muted); font-size: .94rem; }
.project-points li::before {
  content: ""; position: absolute; left: 0; top: .62em;
  width: 6px; height: 1px; background: var(--accent-2);
}
.project-points li strong { color: var(--text); font-weight: 600; }
.project-tags { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: auto; padding-top: 1.3rem; }

.project-thumbs {
  display: grid;
  /* low enough minimum that all three thumbs share one row on a phone
     (~340px content width) instead of wrapping 2 + 1 */
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 96px), 1fr));
  gap: .6rem;
  margin-top: 1.25rem;
}
.project-thumbs figure {
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  background: var(--bg-deep);
}
.project-thumbs img { width: 100%; aspect-ratio: 16/10; object-fit: cover; }
.project-thumbs figcaption {
  font-family: var(--font-mono); font-size: .64rem; color: var(--faint);
  padding: .42rem .55rem; border-top: 1px solid var(--line-soft);
}

.project-links { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1.1rem; }
.link-arrow {
  display: inline-flex; align-items: center; gap: .4rem;
  font-family: var(--font-mono); font-size: .78rem;
  color: var(--accent); text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color .2s var(--ease), gap .2s var(--ease);
}
.link-arrow:hover { border-bottom-color: var(--accent); gap: .65rem; }

/* ---------- skills ---------- */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 290px), 1fr));
  gap: 1px;
  background: var(--line-soft);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: hidden;
}
.skill-group { background: var(--bg); padding: clamp(1.3rem, 2.4vw, 1.9rem); }
.skill-group h3 {
  font-size: 1.02rem;
  display: flex; align-items: center; gap: .6rem;
}
.skill-group h3 .num {
  font-family: var(--font-mono); font-size: .7rem; color: var(--accent);
  border: 1px solid var(--accent-dim); border-radius: 5px;
  padding: .1rem .38rem; font-weight: 500;
}
.skill-list { display: flex; flex-wrap: wrap; gap: .42rem; margin-top: 1.1rem; }
.skill {
  font-family: var(--font-mono); font-size: .78rem;
  padding: .34rem .68rem;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: var(--surface);
  cursor: default;
  transition: color .22s var(--ease), border-color .22s var(--ease), transform .22s var(--ease), background .22s var(--ease);
}
.skill[data-uses] { cursor: pointer; }
.skill:hover, .skill.lit {
  color: var(--accent); border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  transform: translateY(-1px);
}
.skill.dim { opacity: .32; }

.skill-readout {
  margin-top: 1.4rem;
  min-height: 2.7rem;          /* reserves two lines so the card stops jumping */
  font-family: var(--font-mono); font-size: .8rem;
  color: var(--faint);
  transition: color .3s var(--ease);
}
/* The rule lives on the inner block so it is as tall as the text itself,
   not as tall as the space reserved above. */
.skill-readout span {
  display: block;
  border-left: 2px solid var(--line);
  padding-left: .85rem;
  transition: border-color .3s var(--ease);
}
.skill-readout.on { color: var(--muted); }
.skill-readout.on span { border-left-color: var(--accent); }
.skill-readout b { color: var(--accent); font-weight: 500; }

/* ---------- education / honors ---------- */
.two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 330px), 1fr));
  gap: clamp(1.4rem, 3vw, 2.4rem);
}
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: clamp(1.4rem, 2.6vw, 2rem);
  position: relative;
  transition: border-color .3s var(--ease), transform .3s var(--ease);
}
.card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); transform: translateY(-3px); }
.card h3 { font-size: 1.22rem; }
.card .sub { color: var(--muted); font-size: .9rem; margin-top: .35rem; }
.card-rows { margin-top: 1.25rem; display: grid; gap: .8rem; }
.card-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
  padding-bottom: .8rem;
  border-bottom: 1px solid var(--line-soft);
}
.card-rows .card-row:last-child { border-bottom: 0; padding-bottom: 0; }
.card-row dt { color: var(--muted); font-size: .92rem; }
.card-row dd {
  font-family: var(--font-mono); font-weight: 500;
  font-size: .95rem; color: var(--text); white-space: nowrap;
}
.course-list { display: flex; flex-wrap: wrap; gap: .42rem; margin-top: 1.15rem; }

.honor-list { display: grid; gap: .9rem; }
.honor {
  display: grid; grid-template-columns: auto 1fr; gap: .9rem; align-items: start;
  padding: 1rem 1.15rem;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface);
  transition: border-color .3s var(--ease), transform .3s var(--ease);
}
.honor:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); transform: translateX(3px); }
.honor-mark {
  width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center;
  border: 1px solid var(--accent-dim);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  font-family: var(--font-mono); font-size: .7rem;
}
.honor h4 { font-size: .99rem; font-family: var(--font-body); font-weight: 600; letter-spacing: 0; }
.honor p { color: var(--muted); font-size: .88rem; margin-top: .22rem; }

/* ---------- contact ---------- */
.contact-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(150deg, var(--surface), var(--bg-deep));
  padding: clamp(2rem, 5vw, 4rem);
  text-align: center;
  position: relative;
  overflow: hidden;
}
.contact-card::before {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(30rem 18rem at 50% 0%, var(--glow), transparent 70%);
  pointer-events: none;
}
.contact-card h2 { font-size: clamp(1.9rem, 1.3rem + 3vw, 3.2rem); position: relative; }
.contact-card p { color: var(--muted); margin: 1rem auto 0; max-width: 52ch; position: relative; }
.contact-actions {
  display: flex; flex-wrap: wrap; gap: .8rem; justify-content: center;
  margin-top: 2rem; position: relative;
}

.footer {
  border-top: 1px solid var(--line-soft);
  padding: 2.2rem 0 calc(3rem + env(safe-area-inset-bottom));
  margin-top: clamp(3rem, 6vw, 5rem);
}
.footer-inner {
  display: flex; flex-wrap: wrap; gap: 1rem;
  justify-content: space-between; align-items: center;
  font-family: var(--font-mono); font-size: .75rem; color: var(--faint);
}
.footer a { color: var(--muted); text-decoration: none; }
.footer a:hover { color: var(--accent); }

/* ---------- command palette ---------- */
.palette {
  position: fixed; inset: 0; z-index: 120;
  display: grid; place-items: start center;
  padding-top: min(18vh, 9rem);
  background: color-mix(in srgb, var(--bg-deep) 72%, transparent);
  backdrop-filter: blur(6px);
  opacity: 0; visibility: hidden;
  transition: opacity .2s var(--ease), visibility .2s var(--ease);
}
.palette[open], .palette.show { opacity: 1; visibility: visible; }
.palette-box {
  width: min(100% - 2rem, 520px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow: hidden;
  transform: translateY(-8px) scale(.99);
  transition: transform .22s var(--ease);
}
.palette.show .palette-box { transform: none; }
.palette input {
  width: 100%; padding: 1rem 1.15rem;
  background: transparent; border: 0;
  border-bottom: 1px solid var(--line-soft);
  /* 16px floor: iOS Safari zooms the page when an input is smaller */
  font-family: var(--font-mono); font-size: 1rem;
  outline: none;
}
.palette input::placeholder { color: var(--faint); }
.palette ul { max-height: 320px; overflow-y: auto; overscroll-behavior: contain; padding: .4rem; }
.palette li {
  display: flex; align-items: center; gap: .7rem;
  padding: .62rem .8rem; border-radius: 8px;
  cursor: pointer; font-size: .9rem;
}
.palette li .hintk {
  margin-left: auto; font-family: var(--font-mono);
  font-size: .68rem; color: var(--faint);
}
.palette li[aria-selected="true"] { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.palette li .ico { color: var(--faint); display: grid; place-items: center; }
.palette li[aria-selected="true"] .ico { color: var(--accent); }
.palette .empty { padding: 1.1rem; color: var(--faint); font-family: var(--font-mono); font-size: .82rem; }

/* ---------- reveal animation ----------
   Content is visible by default. The hidden start state only applies once the
   inline head script has confirmed JS is alive (.js-reveal on <html>), so a
   script failure can never leave the page blank. */
.js-reveal .reveal { opacity: 0; transform: translateY(18px); }
.js-reveal .reveal.in {
  opacity: 1; transform: none;
  transition: opacity .7s var(--ease), transform .7s var(--ease);
}
.js-reveal .reveal.d1 { transition-delay: .06s } .js-reveal .reveal.d2 { transition-delay: .12s }
.js-reveal .reveal.d3 { transition-delay: .18s } .js-reveal .reveal.d4 { transition-delay: .24s }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .js-reveal .reveal { opacity: 1; transform: none; }
  .marquee-track { animation: none; }
}

/* ---------- touch input ----------
   pointer: coarse  -> fingers need ~44px targets (WCAG / Material minimum)
   hover: none      -> taps leave :hover stuck; never let it move layout */
@media (pointer: coarse) {
  .icon-btn, .kbd-hint { width: 44px; height: 44px; }
  .mini-btn { padding: .6rem .95rem; font-size: .8rem; }
  .link-arrow { padding-block: .45rem; }
  .footer a { display: inline-block; padding: .5rem 0; }
  .palette li { padding: .85rem .8rem; }
}
@media (hover: none) {
  .btn:hover, .card:hover, .honor:hover, .metric:hover,
  .project:hover, .chip:hover { transform: none; }
  .skill:hover:not(.lit) {
    color: var(--muted); border-color: var(--line);
    background: var(--surface); transform: none;
  }
}

/* ---------- mobile tab bar ---------- */
.tabbar { display: none; }

/* ===========================================================================
   MOBILE UI — below 700px the site becomes a distinct, app-like layout:
   thumb-reachable tab bar, bottom-sheet command palette, full-width CTAs,
   two-up data grids, tamed portrait media, compact hero. Everything above
   this block still governs tablet and desktop; nothing here leaks upward.
   =========================================================================== */
@media (max-width: 700px) {
  :root { --radius: 10px; }

  /* reserve room for the fixed tab bar */
  body { padding-bottom: calc(74px + env(safe-area-inset-bottom)); }
  :target { scroll-margin-top: 4.25rem; }

  /* ---- rhythm & type ---- */
  .section { padding-block: 3.4rem; }
  .section-head h2 { font-size: clamp(1.7rem, 7.5vw, 2.1rem); max-width: none; }
  .section-head p { font-size: .95rem; }

  /* ---- hero: compact and action-first ---- */
  .hero { padding-top: 5.75rem; padding-bottom: 2rem; }
  .hero-grid { gap: 1.6rem; }
  .hero-name { font-size: clamp(3rem, 16vw, 4rem); margin-top: .8rem; }
  .hero-role { margin-top: 1rem; }
  .chip { max-width: 100%; }
  .hero-meta { margin-top: 1.2rem; gap: .45rem; }
  .hero-cta { flex-direction: column; margin-top: 1.5rem; }
  .hero-cta .btn { width: 100%; }

  /* ---- pendulum panel: shorter canvas, 2x2 telemetry ---- */
  .rig-canvas-wrap { aspect-ratio: 16 / 10; }
  .telemetry { grid-template-columns: repeat(2, 1fr); }
  .tele {
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
    padding-block: .55rem;
  }
  .tele:nth-child(even) { border-left: 1px solid var(--line-soft); }
  .tele:nth-child(n+3) { border-bottom: 0; }
  .tele dd { font-size: 1rem; }
  #scope { display: none; }  /* the scope trace reads as noise at this size */

  /* ---- data grids lock to two-up ---- */
  .metrics { grid-template-columns: repeat(2, 1fr); }
  /* two columns + an odd count = stranded cell; let the lone one span */
  .metric:nth-child(odd):last-child { grid-column: 1 / -1; }
  .metric { padding: 1.15rem 1rem; }
  .two-col { grid-template-columns: 1fr; }

  /* ---- project cards: portrait media gets cropped wide, not full-height.
     In a stacked grid the percentage height falls back to intrinsic size,
     so the 720x1080 clip would otherwise render over 500px tall. ---- */
  .project-media img,
  .project-media video {
    height: auto;
    aspect-ratio: 16 / 10;
    min-height: 0;
  }
  .project-body { padding: 1.25rem 1.1rem 1.35rem; }
  .project-thumbs figcaption { font-size: .6rem; }

  /* ---- contact & footer ---- */
  .contact-card { padding: 2rem 1.25rem; text-align: left; }
  .contact-card p { margin-inline: 0; }
  .contact-actions { flex-direction: column; }
  .contact-actions .btn { width: 100%; }
  .footer-inner { flex-direction: column; align-items: flex-start; gap: .8rem; }

  /* ---- command palette becomes a bottom sheet ---- */
  .palette {
    place-items: end center;
    padding-top: 0;
    padding-bottom: calc(86px + env(safe-area-inset-bottom));
  }
  .palette-box {
    width: 100%;
    border-radius: 16px 16px 0 0;
    transform: translateY(16px);
  }
  .palette.show .palette-box { transform: none; }

  /* ---- tab bar: five thumb targets, active section lit ---- */
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 95;
    display: grid; grid-template-columns: repeat(5, 1fr);
    background: color-mix(in srgb, var(--bg) 86%, transparent);
    -webkit-backdrop-filter: blur(16px) saturate(1.3);
    backdrop-filter: blur(16px) saturate(1.3);
    border-top: 1px solid var(--line-soft);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a {
    min-height: 58px;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    gap: .25rem;
    padding-block: .4rem;
    font-family: var(--font-mono); font-size: .58rem;
    letter-spacing: .09em; text-transform: uppercase;
    color: var(--faint); text-decoration: none;
    transition: color .2s var(--ease);
  }
  .tabbar a svg { width: 21px; height: 21px; flex: none; }
  .tabbar a.active, .tabbar a:active { color: var(--accent); }
}

/* ---------- print: collapse to a clean document ---------- */
@media print {
  :root {
    --bg: #fff; --bg-deep: #fff; --surface: #fff; --surface-2: #fff;
    --text: #000; --muted: #222; --faint: #555;
    --line: #bbb; --line-soft: #ddd; --accent: #000; --accent-2: #000;
    --shadow: none;
  }
  body { font-size: 10.5pt; line-height: 1.42; }
  body::before, body::after { display: none; }
  .nav, .scroll-cue, .marquee, .rig, .palette, .kbd-hint, .tabbar,
  .contact-actions, .hero-cta, .tl-media, .project-media, .project-thumbs,
  .skill-readout, .icon-btn { display: none !important; }
  .hero { min-height: auto; padding: 0 0 .6rem; }
  .hero-name { font-size: 26pt; }
  .hero-role { font-size: 10.5pt; }
  .section { padding-block: .7rem; break-inside: avoid; }
  .section-head { margin-bottom: .7rem; }
  .section-head h2 { font-size: 15pt; }
  .project { grid-template-columns: 1fr; border-color: #ccc; break-inside: avoid; }
  .project-body { padding: .5rem 0; }
  .card, .honor, .metric, .skill-group { break-inside: avoid; }
  .tl-item { padding-left: 1rem; padding-bottom: .8rem; break-inside: avoid; }
  .timeline::before, .timeline-progress, .tl-node { display: none; }
  a { text-decoration: none; }
  .js-reveal .reveal { opacity: 1 !important; transform: none !important; }
  .footer { border: 0; }
}
