:root {
  color-scheme: dark;
  --bg: #131312;
  --text: #f2f0eb;
  --muted: #b3afa7;
  --faint: #85817a;
  --rule: #363431;
  --accent: #f0a63a;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);

  /* Fluid sizing: everything in rem scales with the screen, from 15px on phones to 18px on large monitors */
  --gutter: clamp(1.25rem, 4vw, 3rem);
  --side: 12.5rem;
  --content: 46rem;
  --date-col: 7rem;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  font-size: clamp(15px, 13.6px + 0.2vw, 18px);
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 1.0625rem;
  line-height: 1.7;
}

.mono { font-family: var(--mono); }

/* Links: a faint underline, with an accent underline that sweeps in on hover */
a {
  color: var(--text);
  text-decoration: none;
  background:
    linear-gradient(var(--accent), var(--accent)) 0 100% / 0 1px no-repeat,
    linear-gradient(var(--faint), var(--faint)) 0 100% / 100% 1px no-repeat;
  padding-bottom: 2px;
  transition: background-size 0.35s var(--ease), color 0.2s;
}
a:hover { color: var(--accent); background-size: 100% 1px, 100% 1px; }

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

/* Scroll progress along the top edge */
.progress {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 20;
  height: 2px;
  background: var(--accent);
  transform: scaleX(var(--progress, 0));
  transform-origin: left;
}

/* ---------- Header with globe ---------- */

.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100svh;
  padding: 0 var(--gutter);
  border-bottom: 1px solid var(--rule);
  overflow: hidden;
}

.hero-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: min(72rem, 100%);
  margin: 0 auto;
  padding: 1.25rem 0;
  font-size: 0.8rem;
  color: var(--muted);
}
.hero-mark {
  padding: 0.2rem 0.45rem;
  border: 1px solid var(--accent);
  border-radius: 3px;
  color: var(--text);
  font-weight: 500;
  letter-spacing: 0.06em;
}

.hero-inner {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  align-items: center;
  gap: clamp(2rem, 5vw, 4rem);
  width: min(72rem, 100%);
  margin: 0 auto;
  padding: 2rem 0 5rem;
}

.hero-text > * { animation: rise-in 0.8s var(--ease) both; }
.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; }
@keyframes rise-in { from { opacity: 0; transform: translateY(16px); } }

.hero-name {
  margin: 0.25rem 0 0;
  font-size: clamp(3rem, 8vw, 6rem);
  font-weight: 600;
  line-height: 0.98;
  letter-spacing: -0.035em;
}
.hero-lead { margin: 1.5rem 0 0; max-width: 34ch; font-size: clamp(1.1rem, 1.6vw, 1.3rem); line-height: 1.55; color: var(--muted); }

.hero-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 2rem; }
.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.65rem 1.15rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: none;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 500;
  transition: border-color 0.2s, background 0.2s, color 0.2s, transform 0.2s var(--ease);
}
.btn:hover { border-color: var(--accent); color: var(--accent); background: none; transform: translateY(-1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--bg); }
.btn.primary:hover { background: #f5b85c; color: var(--bg); }

.hero-places { list-style: none; margin: 2.25rem 0 0; padding: 0; display: grid; gap: 0.25rem; }
.place {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.25rem 0.75rem;
  padding: 0.35rem 0;
  border: 0;
  background: none;
  color: var(--text);
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
}
.place .dot {
  align-self: center;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(240, 166, 58, 0.2);
  transition: box-shadow 0.2s;
}
.place-what { color: var(--muted); }
.place:hover .dot, .place:focus-visible .dot { box-shadow: 0 0 0 5px rgba(240, 166, 58, 0.3); }
.place:hover, .place:focus-visible { color: var(--accent); }
.place:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; }

.hero-globe { position: relative; display: flex; flex-direction: column; align-items: center; }
#globe {
  display: block;
  width: 100%;
  max-width: 34rem;
  aspect-ratio: 1;
  cursor: grab;
  touch-action: pan-y;
  opacity: 0;
  transition: opacity 1s ease;
}
#globe.ready { opacity: 1; }
#globe.dragging { cursor: grabbing; }
.globe-hint { margin: 0.75rem 0 0; font-size: 0.75rem; color: var(--faint); }
.globe-stage { position: relative; width: 100%; max-width: 34rem; }
.globe-stage #globe { max-width: none; }

/* Info card that opens under a marker when you zoom in on it */
.globe-card {
  position: absolute;
  left: var(--x, 50%);
  top: var(--y, 50%);
  width: min(16rem, 88%);
  padding: 0.75rem 0.9rem 0.8rem;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: rgba(19, 19, 18, 0.94);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  font-size: 0.85rem;
  line-height: 1.45;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 1.6rem);
  transition: opacity 0.25s ease, transform 0.35s var(--ease), visibility 0s linear 0.25s;
  pointer-events: none;
}
.globe-card.open {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 1.25rem);
  transition: opacity 0.25s ease, transform 0.35s var(--ease);
  pointer-events: auto;
}
.globe-card p { margin: 0; }
.globe-card p + p { margin-top: 0.45rem; }
.globe-card span { color: var(--muted); }
.card-place { padding-right: 1.5rem; margin-bottom: 0.4rem !important; color: var(--accent); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; }
.card-close {
  position: absolute;
  top: 0.3rem;
  right: 0.4rem;
  width: 1.6rem;
  height: 1.6rem;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}
.card-close:hover, .card-close:focus-visible { color: var(--accent); }
.place[aria-pressed="true"] { color: var(--accent); }
.place[aria-pressed="true"] .dot { box-shadow: 0 0 0 5px rgba(240, 166, 58, 0.35); }
.hero.no-globe .hero-globe { display: none; }
.hero.no-globe .hero-inner { grid-template-columns: 1fr; }

.scroll-cue {
  position: absolute;
  left: 50%;
  bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  transform: translateX(-50%);
  background: none;
  color: var(--faint);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.scroll-cue i { position: relative; width: 1px; height: 2.5rem; background: var(--rule); overflow: hidden; }
.scroll-cue i::after {
  content: "";
  position: absolute;
  left: 0;
  top: -40%;
  width: 1px;
  height: 40%;
  background: var(--accent);
  animation: scroll-line 2.2s var(--ease) infinite;
}
@keyframes scroll-line { to { top: 100%; } }
.scroll-cue:hover { color: var(--accent); background: none; }

@media (max-width: 960px) {
  .hero-inner { grid-template-columns: 1fr; padding: 1rem 0 5rem; gap: 1.5rem; }
  .hero-globe { order: -1; }
  .globe-stage { max-width: min(22rem, 86vw); }
  .hero-lead { max-width: none; }
}
@media (max-width: 560px) {
  .place-what { flex-basis: 100%; padding-left: 1.3rem; }
}

/* ---------- Layout: sticky sidebar + content ---------- */

.layout {
  display: grid;
  grid-template-columns: var(--side) minmax(0, var(--content));
  justify-content: center;
  gap: clamp(2.5rem, 5vw, 5rem);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.side {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  scrollbar-width: none;
  display: flex;
  flex-direction: column;
  padding: clamp(2rem, 9vh, 4.5rem) 0 clamp(1.5rem, 6vh, 3rem);
}
.side::-webkit-scrollbar { display: none; }

/* Sidebar pieces slide in one after another on load */
.side > * { animation: enter 0.7s var(--ease) both; }
.side > :nth-child(2) { animation-delay: 0.08s; }
.side > :nth-child(3) { animation-delay: 0.16s; }
.side > :nth-child(4) { animation-delay: 0.24s; }
.side > :nth-child(5) { animation-delay: 0.32s; }
.toc a { animation: enter 0.6s var(--ease) both; }
.toc a:nth-child(1) { animation-delay: 0.3s; }
.toc a:nth-child(2) { animation-delay: 0.36s; }
.toc a:nth-child(3) { animation-delay: 0.42s; }
.toc a:nth-child(4) { animation-delay: 0.48s; }
.toc a:nth-child(5) { animation-delay: 0.54s; }
.toc a:nth-child(6) { animation-delay: 0.6s; }
@keyframes enter { from { opacity: 0; transform: translateX(-12px); } }

h1, .side-name { margin: 0; font-size: 1.7rem; font-weight: 600; letter-spacing: -0.01em; line-height: 1.15; }
.title { margin: 0.5rem 0 0; color: var(--text); }
.meta { margin: 0.4rem 0 0; color: var(--muted); font-size: 0.85rem; }
.colon { animation: blink 2s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0.2; } }

.toc { display: flex; flex-direction: column; margin-top: clamp(1.5rem, 7vh, 3.5rem); }
.toc a {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.3rem 0;
  color: var(--muted);
  background: none;
  font-size: 0.95rem;
  transition: color 0.2s, transform 0.25s var(--ease);
}
.toc a span { font-size: 0.78rem; color: var(--faint); transition: color 0.2s; }
.toc a::after {
  content: "";
  height: 1px;
  width: 0;
  background: var(--accent);
  transition: width 0.35s var(--ease);
}
.toc a:hover { color: var(--text); transform: translateX(4px); }
.toc a.active { color: var(--text); }
.toc a.active span { color: var(--accent); }
.toc a.active::after { width: 2rem; }

.links { list-style: none; margin: auto 0 0; padding: 2rem 0 0; font-size: 0.9rem; }
.links li + li { margin-top: 0.4rem; }
.links a { color: var(--muted); }
.links a:hover { color: var(--accent); }

/* Section menu for phones and tablets (hidden on desktop, where the sidebar has it) */
.mobile-nav { display: none; }

main { padding: clamp(2.5rem, 9vh, 4.5rem) 0 4rem; min-width: 0; }

section { padding-bottom: clamp(2.5rem, 6vw, 4rem); scroll-margin-top: 1rem; }

/* Section headings: the rule underneath draws itself when it scrolls into view */
h2 {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  margin: 0 0 1.75rem;
  padding-bottom: 0.625rem;
  font-size: 0.85rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}
h2::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, var(--accent) 0 3rem, var(--rule) 3rem);
  transform-origin: left;
  transition: transform 1s var(--ease);
}
.js h2:not(.drawn)::after { transform: scaleX(0); }
h2 .mono { color: var(--accent); font-size: 0.8rem; }

p { margin: 0 0 0.875rem; }
.lead { font-size: 1.15rem; line-height: 1.6; }
#about p:not(.lead) { color: var(--muted); }

/* ---------- Key figures ---------- */

.figures {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 1.75rem 0 0;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.figures div { padding: 0.875rem 0 0.875rem 1rem; }
.figures div:first-child { padding-left: 0; }
.figures div + div { border-left: 1px dashed var(--rule); }
.figures dt { color: var(--muted); font-size: 0.78rem; line-height: 1.4; text-transform: uppercase; letter-spacing: 0.06em; }
.figures dd { margin: 0.25rem 0 0; font-size: 1.8rem; font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; }

/* ---------- Entries: date column + body ---------- */

.entry {
  position: relative;
  display: grid;
  grid-template-columns: var(--date-col) minmax(0, 1fr);
  gap: 1.5rem;
  padding: 1.125rem 0;
}
.entry + .entry { border-top: 1px dashed var(--rule); }
.entry::before {
  content: "";
  position: absolute;
  left: -1rem;
  top: 1.25rem;
  bottom: 1.25rem;
  width: 2px;
  background: var(--accent);
  transform: scaleY(0);
  transform-origin: top;
  transition: transform 0.35s var(--ease);
}

.when { margin: 0.2rem 0 0; color: var(--muted); font-size: 0.85rem; white-space: nowrap; transition: color 0.2s; }

@media (hover: hover) {
  .entry:hover::before { transform: scaleY(1); }
  .entry:hover .when { color: var(--accent); }
  .specs div:hover dt { color: var(--accent); }
}

h3 { margin: 0; font-size: 1.12rem; font-weight: 600; line-height: 1.4; }
.where { margin: 0.15rem 0 0.5rem; color: var(--muted); font-size: 0.95rem; }
.entry p:last-child { margin-bottom: 0; }

.entry ul { margin: 0.75rem 0 0; padding-left: 1.125rem; }
.entry li { padding-left: 0.25rem; }
.entry li + li { margin-top: 0.4rem; }
.entry li::marker { color: var(--faint); content: "– "; }

.stack { margin-top: 0.875rem; color: var(--muted); font-size: 0.85rem; }

.subhead {
  margin: 2.25rem 0 0.25rem;
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--faint);
}


/* Expandable panels (simulations, roadmap, details): a clear bar with a +/− button */
.expand {
  margin-top: 1rem;
  border: 1px solid var(--rule);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.02);
  transition: border-color 0.2s, background 0.2s;
}
.expand + .expand { margin-top: 0.625rem; }
.expand:hover, .expand[open] { border-color: rgba(240, 166, 58, 0.45); }
.expand > summary {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.8rem 1rem;
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.expand > summary::-webkit-details-marker { display: none; }
.expand > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.expand-icon {
  position: relative;
  flex: none;
  width: 1.6rem;
  height: 1.6rem;
  border: 1px solid var(--accent);
  border-radius: 4px;
  transition: background 0.2s;
}
.expand-icon::before, .expand-icon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0.7rem;
  height: 1.5px;
  background: var(--accent);
  transform: translate(-50%, -50%);
  transition: transform 0.3s var(--ease), background 0.2s;
}
.expand-icon::after { transform: translate(-50%, -50%) rotate(90deg); }
.expand[open] .expand-icon::after { transform: translate(-50%, -50%) rotate(0deg); }
.expand > summary:hover .expand-icon { background: var(--accent); }
.expand > summary:hover .expand-icon::before,
.expand > summary:hover .expand-icon::after { background: var(--bg); }

.expand-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.35; }
.expand-title { font-weight: 600; color: var(--text); }
.expand-sub { margin-top: 0.15rem; font-size: 0.85rem; color: var(--muted); }

.expand-tag {
  flex: none;
  padding: 0.15rem 0.5rem;
  border: 1px solid var(--rule);
  border-radius: 999px;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.expand-body { padding: 0 1rem 1rem; }
.expand[open] .expand-body { animation: expand-open 0.35s var(--ease); }
@keyframes expand-open { from { opacity: 0; transform: translateY(-6px); } }
.expand-body > ul { margin-top: 0; }
.expand-body strong { font-weight: 600; color: var(--text); }

/* Diagrams inside a panel don't need their own frame */
.expand .diagram { margin: 0; padding: 0; border: 0; border-radius: 0; }

/* Project roadmap: done / next / planned along a vertical line */
.roadmap { list-style: none; margin: 0; padding: 0; position: relative; }
.roadmap::before {
  content: "";
  position: absolute;
  left: 4px;
  top: 0.7rem;
  bottom: 0.7rem;
  width: 1px;
  background: var(--rule);
}
.roadmap li {
  position: relative;
  display: grid;
  grid-template-columns: 4.5rem minmax(0, 1fr);
  gap: 0.5rem;
  padding: 0.3rem 0 0.3rem 1.5rem;
  color: var(--muted);
}
.roadmap li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.75rem;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid var(--faint);
  background: var(--bg);
}
.roadmap .state { font-size: 0.75rem; padding-top: 0.2rem; color: var(--faint); text-transform: uppercase; letter-spacing: 0.06em; }
.roadmap li.done { color: var(--text); }
.roadmap li.done::before { background: var(--accent); border-color: var(--accent); }
.roadmap li.done .state { color: var(--muted); }
.roadmap li.next { color: var(--text); }
.roadmap li.next::before { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(240, 166, 58, 0.18); }
.roadmap li.next .state { color: var(--accent); }

/* Portrait in the sidebar: shows public/photo.jpg, or the initials until a photo is added */
.portrait {
  position: relative;
  display: grid;
  place-items: center;
  width: 7.5rem;
  aspect-ratio: 1;
  margin-bottom: 1.25rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  overflow: hidden;
  background: #1b1a19;
}
.portrait span { color: var(--faint); font-size: 1.6rem; letter-spacing: 0.08em; }
.portrait img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }

.kicker { margin: 0 0 0.25rem; color: var(--accent); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; }

/* ---------- Diagrams ---------- */

.diagram { margin: 1.25rem 0 0.5rem; padding: 1rem; border: 1px solid var(--rule); border-radius: 4px; }
.diagram svg { display: block; width: 100%; height: auto; color: var(--muted); }
.diagram figcaption { margin-top: 0.625rem; color: var(--muted); font-size: 0.8rem; line-height: 1.55; }

.diagram .line, .diagram .box, .diagram .tube, .diagram .wire, .diagram .dim { fill: none; stroke-width: 1.5; }
.diagram .line { stroke: var(--muted); }
.diagram .box { stroke: var(--muted); }
.diagram .box.accent { stroke: var(--accent); }
.diagram .box.screen { stroke: var(--faint); stroke-dasharray: 2 3; }
.diagram .tube { stroke: var(--text); stroke-width: 2; }
.diagram .wire { stroke: var(--faint); }
.diagram .dim { stroke: var(--faint); stroke-width: 1; }
.diagram .liquid { fill: var(--accent); opacity: 0.1; }
.diagram .surface { stroke: var(--accent); stroke-width: 1.5; opacity: 0.7; }
.diagram .label { fill: var(--muted); font: 14px var(--mono); }
.diagram .readout tspan[id] { fill: var(--accent); }
.diagram .data { stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 3 5; animation: flow 1s linear infinite; }
.diagram .bubble { fill: none; stroke: var(--text); stroke-width: 1; opacity: 0.85; }
.js .diagram .bubble.static { display: none; }

@keyframes flow { to { stroke-dashoffset: -8; } }

/* Driveline diagram (thesis) */
.diagram .label.small { font-size: 12px; fill: var(--muted); }
.diagram .label.mode { fill: var(--muted); }
.diagram .label.temp { fill: var(--text); }
.diagram .bus { fill: none; stroke: var(--accent); stroke-width: 1.5; stroke-dasharray: 6 4; opacity: 0.6; }
.diagram .fins { fill: none; stroke: var(--rule); stroke-width: 1.5; }
.diagram .shaft-base { stroke: var(--rule); stroke-width: 8; }
.diagram .shaft { fill: none; stroke: var(--muted); stroke-width: 8; stroke-dasharray: 2 6; }
.diagram .sensor { fill: var(--bg); }

/* Simulation slider */
.sim-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.875rem;
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--muted);
}
html:not(.js) .sim-controls { display: none; }
.sim-hint { color: var(--faint); }

.sim-controls input[type="range"] {
  flex: 1 1 10rem;
  height: 1.25rem;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
.sim-controls input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: var(--rule); }
.sim-controls input[type="range"]::-moz-range-track { height: 2px; background: var(--rule); }
.sim-controls input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 12px;
  margin-top: -5px;
  border-radius: 0;
  background: var(--accent);
  border: 0;
}
.sim-controls input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 0; background: var(--accent); border: 0; }
.sim-controls input[type="range"]:focus-visible { outline: 1px solid var(--accent); outline-offset: 4px; }

/* Rig controls: label | slider | value, one row per setting */
.sim-controls.rig {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 5.5rem;
  gap: 0.4rem 1rem;
}
.sim-controls.rig output { color: var(--accent); text-align: right; font-variant-numeric: tabular-nums; }
.sim-controls.rig #drv-hint { grid-column: 1 / -1; }

/* Bigger slider handle for fingers */
@media (pointer: coarse) {
  .sim-controls input[type="range"] { height: 2.25rem; }
  .sim-controls input[type="range"]::-webkit-slider-thumb { width: 22px; height: 22px; margin-top: -10px; }
  .sim-controls input[type="range"]::-moz-range-thumb { width: 22px; height: 22px; }
}

/* ---------- Skills ---------- */

.specs { margin: 0; }
.specs div {
  display: grid;
  grid-template-columns: var(--date-col) minmax(0, 1fr);
  gap: 1.5rem;
  padding: 0.75rem 0;
}
.specs div + div { border-top: 1px dashed var(--rule); }
.specs dt { color: var(--muted); font-size: 0.85rem; padding-top: 0.2rem; transition: color 0.2s; }
.specs dd { margin: 0; }

/* ---------- Contact ---------- */

.contact-line { display: flex; flex-wrap: wrap; gap: 0.5rem 1.75rem; }

footer { color: var(--faint); font-size: 0.8rem; }

/* ---------- Scroll reveal (only when JS runs) ---------- */

.js .reveal { opacity: 0; transform: translateY(24px); transition: opacity 0.8s ease, transform 0.9s var(--ease); }
.js .reveal.visible { opacity: 1; transform: none; }

/* Where supported, reveals follow the scroll position itself instead of firing once:
   things ease in as they enter the screen and ease back out if you scroll up again. */
.sda .reveal {
  opacity: 1;
  transform: none;
  transition: none;
  animation: reveal-scroll linear both;
  animation-timeline: view();
  animation-range: entry 0% cover 30%;
}
@keyframes reveal-scroll {
  from { opacity: 0; transform: translateY(48px); }
  to { opacity: 1; transform: none; }
}
.sda h2::after {
  transition: none;
  animation: rule-draw linear both;
  animation-timeline: view();
  animation-range: entry 20% cover 35%;
}
@keyframes rule-draw { from { transform: scaleX(0); } to { transform: scaleX(1); } }

/* Smooth scrolling (Lenis) takes over from the browser's own smooth scroll */
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-stopped { overflow: hidden; }

/* Header: text drifts up and fades, globe sinks and shrinks a little as you scroll past */
.hero-bar { opacity: calc(1 - var(--hp, 0) * 2); }
.hero-text { transform: translate3d(0, calc(var(--hp, 0) * -7rem), 0); opacity: calc(1 - var(--hp, 0) * 1.5); }
.hero-globe { transform: translate3d(0, calc(var(--hp, 0) * 6rem), 0) scale(calc(1 - var(--hp, 0) * 0.15)); opacity: calc(1 - var(--hp, 0) * 1.2); }
.scroll-cue { opacity: calc(1 - var(--hp, 0) * 6); }

/* ================= Screen sizes ================= */

/* Large monitors: wider content so diagrams get more room */
@media (min-width: 1600px) {
  :root { --side: 14rem; --content: 52rem; }
}

/* Small laptops: tighter sidebar */
@media (max-width: 1180px) {
  :root { --side: 11rem; --date-col: 6rem; }
  .layout { gap: 2.5rem; }
  .side-name { font-size: 1.5rem; }
}

/* Short screens (e.g. laptops with a small window): compact sidebar */
@media (max-height: 760px) and (min-width: 961px) {
  .portrait { width: 5rem; margin-bottom: 0.875rem; }
  .portrait span { font-size: 1.1rem; }
  .side { padding-top: 1.5rem; }
  .toc { margin-top: 1rem; }
  .toc a { padding: 0.15rem 0; }
  .links { padding-top: 1rem; }
}

/* Tablets and phones: one column, section menu pinned to the top */
@media (max-width: 960px) {
  .layout { display: block; max-width: calc(var(--content) + 2 * var(--gutter)); }
  .side { position: static; height: auto; overflow: visible; padding: 2.5rem 0 0; }
  .toc { display: none; }
  .side-name { font-size: 2rem; }
  .links { margin-top: 1.25rem; padding-top: 0; display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; }
  .links li + li { margin-top: 0; }

  .mobile-nav {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    gap: 0.25rem;
    margin-top: 1.5rem;
    margin-inline: calc(-1 * var(--gutter));
    padding: 0 var(--gutter);
    overflow-x: auto;
    scrollbar-width: none;
    background: rgba(19, 19, 18, 0.92);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--rule);
    border-bottom: 1px solid var(--rule);
  }
  .mobile-nav::-webkit-scrollbar { display: none; }
  .mobile-nav a {
    flex: none;
    padding: 0.7rem 0.6rem;
    background: none;
    color: var(--muted);
    font-size: 0.85rem;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-color 0.2s;
  }
  .mobile-nav a.active { color: var(--text); border-bottom-color: var(--accent); }

  main { padding-top: 2rem; }
  section { scroll-margin-top: 3.5rem; }
  .entry::before { left: -0.75rem; }
}

/* Phones */
@media (max-width: 560px) {
  :root { --date-col: 1fr; }
  .entry, .specs div { grid-template-columns: 1fr; gap: 0.25rem; }
  .entry::before { display: none; }
  .lead { font-size: 1.08rem; }

  /* Panels use the full screen width so diagrams and their labels stay legible */
  .expand { margin-inline: calc(-1 * var(--gutter)); border-inline: 0; border-radius: 0; }
  .expand > summary { padding: 0.8rem var(--gutter); gap: 0.75rem; }
  .expand-body { padding: 0 var(--gutter) 1rem; }
  .expand-body:has(.diagram) { padding: 0 0.5rem 1rem; }
  .expand .diagram figcaption, .expand .diagram .sim-controls { padding: 0 calc(var(--gutter) - 0.5rem); }
  .expand-sub { font-size: 0.8rem; }
  .diagram .label { font-size: 15px; }
  .diagram .label.small { font-size: 12.5px; }

  .figures dd { font-size: 1.5rem; }
  .figures dt { font-size: 0.68rem; letter-spacing: 0.03em; }
  .figures div { padding-left: 0.625rem; }
  .contact-line { flex-direction: column; gap: 0.5rem; }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .js .reveal { opacity: 1; transform: none; }
  .sda .reveal, .sda h2::after { animation: none; }
  .js h2:not(.drawn)::after { transform: none; }
}

/* ---------- Print: clean light version ---------- */

@media print {
  :root { --bg: #fff; --text: #000; --muted: #444; --faint: #777; --rule: #ccc; --accent: #000; }
  html { font-size: 14px; }
  body { font-size: 10.5pt; }
  .no-print { display: none !important; }
  .layout { display: block; padding: 0; }
  .side { position: static; height: auto; overflow: visible; padding: 0 0 12px; }
  .side > *, .toc a { animation: none; }
  .links { display: flex; gap: 16px; margin-top: 8px; padding: 0; }
  .links li + li { margin-top: 0; }
  main { padding: 0; }
  section { padding-bottom: 16px; }
  .js .reveal { opacity: 1; transform: none; }
  .sda .reveal, .sda h2::after { animation: none; }
  .js h2:not(.drawn)::after { transform: none; }
  .diagram, .figures { display: none; }
  .expand { border: 0; margin: 0.5rem 0 0; }
  .expand > summary { padding: 0; }
  .expand-icon, .expand-tag, .expand-sub { display: none; }
  .expand-title { font-weight: 600; }
  .expand-body { padding: 0; }
  .portrait { width: 3.5cm; border: 0; }
  .portrait:not(:has(img)) { display: none; }
  .entry { padding: 8px 0; break-inside: avoid; }
  a { background: none; }
}
