/* ==========================================================================
   sondre.me — a trail from summit to base camp
   ========================================================================== */

/* ---------- Tokens ---------------------------------------------------- */

:root {
  color-scheme: light dark;

  /* Nordic palette */
  --paper: #F7F7F5;
  --card: #F7F7F5;
  --bg: #F1F1EE;
  --slate: #D9DEDF;
  --topo: rgba(38, 52, 60, 0.11);
  --ink: #111111;
  --ink-2: #7A7A7A;          /* two-tone headline grey (large text only) */
  --muted: #5E6265;          /* small text, AA on paper */
  --line: #DEDED9;
  --line-strong: #CACAC4;
  --spruce: #243B34;
  --moss: #5E6B3A;
  --lichen: #A7AE8A;
  --granite: #8B8F8C;
  --code-bg: #EFEFEC;

  /* One quiet accent: DNT trail-marker orange */
  --accent: #C8622D;
  --accent-text: #A34B1C;    /* darker for AA on light backgrounds */
  --marker: var(--accent);

  /* Photo treatment (shifted by weather) */
  --photo-filter: none;
  --photo-tint: transparent;

  /* Type */
  --font-sans: "Geist", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-head: var(--font-sans);
  --font-mono: "Geist Mono", "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --fs-display: clamp(2.75rem, 1.4rem + 5.6vw, 6rem);
  --fs-h2: clamp(2rem, 1.2rem + 3.4vw, 4.25rem);
  --fs-h3: clamp(1.25rem, 1.1rem + 0.6vw, 1.625rem);
  --fs-body: clamp(0.9375rem, 0.9rem + 0.18vw, 1.0625rem);
  --fs-small: 0.875rem;
  --fs-mono: 0.75rem;

  /* Space */
  --gutter: clamp(1rem, 0.5rem + 2.4vw, 2.5rem);
  --section: clamp(5rem, 3rem + 7vw, 10rem);
  --radius-lg: clamp(20px, 1rem + 1.2vw, 32px);
  --radius: 14px;
  --max: 1360px;
  --head-h: 4.25rem;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* Weather moods — mostly a shift in light, never a costume change */
:root[data-weather="sun"] {
  --slate: #E2DED4;
  --topo: rgba(92, 70, 30, 0.11);
  --marker: #C99A3E;
  --photo-filter: saturate(1.08) brightness(1.04) contrast(1.02) sepia(0.05);
  --photo-tint: linear-gradient(200deg, rgba(255, 196, 110, 0.22), transparent 55%);
}
:root[data-weather="rain"] {
  --slate: #D2DADF;
  --topo: rgba(30, 55, 75, 0.12);
  --marker: #6F8795;
  --photo-filter: saturate(0.9) brightness(0.96) contrast(1.03);
  --photo-tint: linear-gradient(180deg, rgba(60, 86, 106, 0.28), rgba(40, 56, 70, 0.12));
}
:root[data-weather="snow"] {
  --slate: #DDE3E7;
  --topo: rgba(40, 70, 95, 0.1);
  --marker: #8FA9BB;
  --photo-filter: saturate(0.8) brightness(1.07) contrast(0.96);
  --photo-tint: linear-gradient(180deg, rgba(226, 236, 245, 0.42), rgba(210, 224, 236, 0.2));
}
:root[data-weather="fog"] {
  --slate: #DDE0E0;
  --topo: rgba(50, 58, 62, 0.09);
  --marker: #8B9396;
  --photo-filter: saturate(0.82) brightness(1.03) contrast(0.95);
  --photo-tint: linear-gradient(180deg, rgba(235, 238, 238, 0.28), rgba(235, 238, 238, 0.08));
}

/* Dusk in the mountains */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #14171A;
    --card: #1A1E22;
    --bg: #14171A;
    --slate: #0E1113;
    --topo: rgba(200, 214, 222, 0.07);
    --ink: #ECECE8;
    --ink-2: #83898E;
    --muted: #A2A7AA;
    --line: #262B30;
    --line-strong: #353B41;
    --code-bg: #20252A;
    --accent: #D9743F;
    --accent-text: #E58A58;
  }
  :root:not([data-theme="light"])[data-weather="sun"] { --slate: #15130F; --topo: rgba(230, 200, 150, 0.07); --marker: #D2A24A; }
  :root:not([data-theme="light"])[data-weather="rain"] { --slate: #0C1114; --topo: rgba(160, 196, 216, 0.08); --marker: #7D98A8; }
  :root:not([data-theme="light"])[data-weather="fog"] { --slate: #121517; --marker: #8E979B; }
  :root:not([data-theme="light"])[data-weather="snow"] { --slate: #0F1418; --topo: rgba(190, 214, 232, 0.08); --marker: #8FA9BB; }
}

/* A chosen theme wins over the system setting */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
/* (dark rules mirrored from the media queries (same rules as the media queries above and below) */
  :root[data-theme="dark"] {
    --paper: #14171A;
    --card: #1A1E22;
    --bg: #14171A;
    --slate: #0E1113;
    --topo: rgba(200, 214, 222, 0.07);
    --ink: #ECECE8;
    --ink-2: #83898E;
    --muted: #A2A7AA;
    --line: #262B30;
    --line-strong: #353B41;
    --code-bg: #20252A;
    --accent: #D9743F;
    --accent-text: #E58A58;
  }
  :root[data-theme="dark"][data-weather="sun"] { --slate: #15130F; --topo: rgba(230, 200, 150, 0.07); --marker: #D2A24A; }
  :root[data-theme="dark"][data-weather="rain"] { --slate: #0C1114; --topo: rgba(160, 196, 216, 0.08); --marker: #7D98A8; }
  :root[data-theme="dark"][data-weather="fog"] { --slate: #121517; --marker: #8E979B; }
  :root[data-theme="dark"][data-weather="snow"] { --slate: #0F1418; --topo: rgba(190, 214, 232, 0.08); --marker: #8FA9BB; }
  :root[data-theme="dark"] .theme-spruce { --paper: #182620; --card: #1E2E27; --slate: #13201A; }
  :root[data-theme="dark"] .theme-mist { --paper: #181C1F; }
  :root[data-theme="dark"] .theme-white { --paper: #1C2024; --ink: #EDEDE9; --ink-2: #8FA394; --muted: #B4B9BC; --line: #2A2F34; --line-strong: #394047; --head: #B9CBB0; }
  :root[data-theme="dark"] pre.code .k { color: var(--lichen); }

/* ---------- Base ------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--head-h) + 1rem);
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.5;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  transition: background-color 0.8s var(--ease), color 0.8s var(--ease);
}

img, svg, video { display: block; max-width: 100%; }
img { height: auto; }

h1, h2, h3, p, ul, ol, dl, dd, figure, blockquote { margin: 0; }
ul, ol { padding: 0; list-style: none; }
h1, h2, h3 { font-weight: 400; }

a { color: inherit; text-decoration: none; }

[hidden] { display: none !important; }

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

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

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: var(--gutter);
  top: -100px;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--ink);
  color: var(--paper);
  border-radius: 999px;
  font-size: var(--fs-small);
}
.skip-link:focus { top: 1rem; }

.mono {
  font-family: var(--font-mono);
  font-size: var(--fs-mono);
  letter-spacing: 0.02em;
  font-feature-settings: "zero" 0;
}

.muted { color: var(--muted); }

/* Headings share one font, so it can be swapped in one place (see fonts.html) */
h1, h2, h3, .two-tone, .hero-title, .note-title, .map-peaks .nm, .stat .n, .hero-stat .num, .mail, .next-trail .two-tone {
  font-family: var(--font-head);
}
/* Serifs want looser tracking than a tight grotesk */
:root[data-head-kind="serif"] :is(h1, h2, h3, .two-tone, .hero-title, .note-title, .map-peaks .nm, .where-line) { letter-spacing: -0.012em; }
.font-chip {
  position: fixed; left: 1rem; bottom: 1rem; z-index: 70;
  display: inline-flex; gap: 0.75rem; align-items: center;
  padding: 0.5rem 0.8rem; border-radius: 999px;
  background: var(--ink); color: var(--paper);
  font-family: var(--font-mono); font-size: 0.6875rem;
}
.font-chip a { text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Layout ---------------------------------------------------- */

.wrap {
  width: 100%;
  max-width: var(--max);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  column-gap: var(--gutter);
}

.section { padding-block: var(--section); }

/* Two-tone headings */
.two-tone {
  font-size: var(--fs-h2);
  line-height: 1.02;
  letter-spacing: -0.035em;
  font-weight: 400;
  text-wrap: balance;
}
.two-tone span { display: block; }
.two-tone .quiet { color: var(--ink-2); }

/* Section marker: "02 — Selected work · 1 420 m" */
.marker {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  margin-bottom: clamp(2.5rem, 2rem + 2vw, 4.5rem);
}
.marker::before {
  content: "";
  width: 7px; height: 7px;
  flex: none;
  background: var(--marker);
  clip-path: polygon(50% 0, 100% 100%, 0 100%); /* tiny summit */
  transition: background-color 0.8s var(--ease);
}
.marker .elev { margin-left: auto; }
.marker .rule {
  flex: 1;
  height: 1px;
  background: var(--line);
}

/* Contour-line divider */
.contour {
  height: 1px;
  border: 0;
  margin: 0;
  background: var(--line);
  position: relative;
}

/* Text link with a thin arrow */
.link {
  display: inline-flex;
  align-items: center;
  gap: 0.55em;
  color: var(--accent-text);
  font-size: var(--fs-body);
  line-height: 1.2;
  padding-block: 0.25em;
  background-image: linear-gradient(currentColor, currentColor);
  background-size: 0% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size 0.5s var(--ease), color 0.3s;
}
.link:hover { background-size: 100% 1px; }
.arrow {
  width: 1.15em; height: 0.7em;
  flex: none;
  transition: transform 0.45s var(--ease);
}
.link:hover .arrow,
a:hover > .arrow,
a:focus-visible .arrow { transform: translateX(4px); }

/* Topographic backdrop — uses the SVG as a mask so it can be recoloured */
.topo { position: relative; isolation: isolate; background: var(--slate); transition: background-color 0.8s var(--ease); }
.topo::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--topo);
  -webkit-mask: url("../img/topo.svg") center / cover no-repeat;
          mask: url("../img/topo.svg") center / cover no-repeat;
  transition: background-color 0.8s var(--ease);
  pointer-events: none;
}

/* ---------- Header (sticky, blurs what scrolls under it) ------------- */

.site-head {
  position: sticky;
  top: 0;
  z-index: 60;
  height: var(--head-h);
  display: flex;
  align-items: center;
  transition: background-color 0.4s var(--ease), box-shadow 0.4s var(--ease),
              -webkit-backdrop-filter 0.4s var(--ease), backdrop-filter 0.4s var(--ease);
}
.site-head.is-stuck {
  background: color-mix(in srgb, var(--paper) 68%, transparent);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
          backdrop-filter: blur(18px) saturate(1.3);
  box-shadow: 0 1px 0 color-mix(in srgb, var(--ink) 9%, transparent);
}
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }

/* "You are here": a small pill in the corner once you've left the summit */
.where {
  position: fixed;
  right: var(--gutter);
  bottom: 1.25rem;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0;
  padding: 0.5rem 0.9rem 0.5rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--card) 78%, transparent);
  -webkit-backdrop-filter: blur(12px);
          backdrop-filter: blur(12px);
  color: var(--ink);
  font-size: 0.75rem;
  line-height: 1;
  opacity: 0;
  translate: 0 8px;
  transition: opacity 0.6s var(--ease), translate 0.6s var(--ease);
  pointer-events: none;
}
.where.is-on { opacity: 1; translate: 0 0; }
/* On touch screens it shows while you move, then gets out of the way of the text */
@media (hover: none) {
  .where.is-on.is-idle { opacity: 0; translate: 0 8px; transition-duration: 0.9s; }
}
.where-lbl { color: var(--muted); }
.where-dot {
  width: 6px; height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 50%, transparent);
  animation: here-pulse 2.4s ease-out infinite;
}
@keyframes here-pulse {
  70%, 100% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--accent) 0%, transparent); }
}
.where-line {
  position: relative;
  display: inline-flex;
  height: 1.2em;
  line-height: 1.2em;
  overflow: hidden;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  letter-spacing: -0.01em;
}
.where-name {
  display: inline-block;
  white-space: nowrap;
  transition: transform 0.55s var(--ease), opacity 0.55s var(--ease);
}
.where-name.is-leaving { position: absolute; left: 0; top: 0; }
.where-name.from-below, .where-name.to-below { transform: translateY(100%); opacity: 0; transition-duration: 0s; }
.where-name.from-above, .where-name.to-above { transform: translateY(-100%); opacity: 0; }
.where-name.to-below { transition-duration: 0.55s; }
.where-alt { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
/* The hero's slate backdrop runs up behind the header */
.summit { margin-top: calc(-1 * var(--head-h)); padding-top: var(--head-h); }

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  line-height: 1;
}
.logo svg { width: 28px; height: 28px; flex: none; transition: transform 0.5s var(--ease); }
a.logo:hover svg { transform: translateY(-2px); }
.logo .wm { font-size: 1.1875rem; font-weight: 500; letter-spacing: -0.035em; }
.logo .tld {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  font-weight: 400;
  letter-spacing: 0;
  color: var(--muted);
  margin-left: 0.1em;
}

.menu-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  height: 2.5rem;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: var(--fs-small);
  cursor: pointer;
  transition: border-color 0.3s, background-color 0.3s;
}
.menu-btn:focus-visible { outline-offset: 6px; }
.head-actions { display: flex; align-items: center; gap: 1.75rem; }

/* NO / EN: the current language quiet and highlighted, the other one a link */
.lang-switch { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.75rem; letter-spacing: 0.04em; }
.lang-switch a { color: var(--muted); padding: 0.4rem 0.1rem; transition: color 0.25s; }
.lang-switch a:hover { color: var(--accent-text); }
.lang-switch [aria-current] { color: var(--ink); padding: 0.4rem 0.1rem; }
.lang-switch .sep { color: var(--muted); opacity: 0.5; }

/* Day / Dusk: a sun that sets behind the ridge */
.theme-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  height: 2.5rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}
.theme-btn:focus-visible { outline-offset: 6px; }
.theme-btn .lbl { font-size: 0.75rem; letter-spacing: 0.04em; }
.theme-ico { width: 22px; height: 20px; overflow: hidden; }
.theme-ico .sun {
  fill: var(--accent);
  transition: transform 0.7s var(--ease), fill 0.5s;
}
.theme-ico .ridge { fill: var(--paper); stroke: currentColor; stroke-width: 1.3; stroke-linejoin: round; transition: fill 0.8s var(--ease); }
.theme-ico .star { fill: currentColor; opacity: 0; transition: opacity 0.5s var(--ease) 0.2s; }
.is-dusk .theme-ico .sun { transform: translateY(9px); fill: #E6B25A; }
.is-dusk .theme-ico .star { opacity: 1; }
.theme-btn:hover .theme-ico .sun { transform: translateY(-1.5px); }
.is-dusk.theme-btn:hover .theme-ico .sun { transform: translateY(7px); }
/* A folded trail map with a pin: obviously "the map" */
.menu-btn .lbl { font-size: 0.75rem; letter-spacing: 0.04em; }
/* "Menu" rolls over to "Map" on hover */
.roll { display: inline-grid; height: 1.2em; line-height: 1.2em; overflow: hidden; text-align: right; }
.roll span { transition: transform 0.5s var(--ease); }
.menu-btn:hover .roll span, .menu-btn:focus-visible .roll span { transform: translateY(-100%); }
.map-ico { width: 22px; height: 20px; overflow: visible; }
.map-ico .sheet, .map-ico .fold {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
  stroke-linejoin: round;
  transition: transform 0.5s var(--ease);
}
.map-ico .fold { stroke-width: 1; opacity: 0.55; }
.map-ico .pin { fill: var(--accent); transform-box: fill-box; transform-origin: 50% 100%; transition: transform 0.45s var(--ease); }
.menu-btn:hover .map-ico .pin { transform: translateY(-2.5px) scale(1.15); }
.menu-btn:hover .map-ico .sheet { transform: scaleX(1.06); transform-origin: 50% 50%; transform-box: fill-box; }
.x-ico { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; transition: transform 0.45s var(--ease); }
.is-close:hover .x-ico { transform: rotate(90deg); }

/* Weather toggle */
.weather-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.15rem;
  padding: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: color-mix(in srgb, var(--card) 55%, transparent);
}
.weather-toggle button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.02em;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.3s, color 0.3s;
}
.weather-toggle button svg { width: 13px; height: 13px; }
.weather-toggle button:hover { color: var(--ink); }
.weather-toggle button[aria-pressed="true"] {
  background: var(--ink);
  color: var(--paper);
}

/* ---------- Hero ------------------------------------------------------ */

.summit { padding-bottom: clamp(1.5rem, 1rem + 2vw, 3rem); }

.hero-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: clamp(1.25rem, 0.5rem + 3vw, 3.5rem);
  transition: background-color 0.8s var(--ease);
}

.hero-top {
  container-type: inline-size;
  align-items: start;
  margin-bottom: clamp(1.25rem, 0.5rem + 2.2vw, 2.75rem);
}

.hero-title {
  grid-column: 1 / span 10;
  /* Sized to the space beside the clip thumbnail, so each line stays one line */
  font-size: clamp(2.5rem, calc((100cqi - 12rem) / 12.6), 6rem);
  line-height: 0.98;
  letter-spacing: -0.04em;
  font-weight: 400;
}
.hero-title span { display: block; text-wrap: balance; }
.hero-title:only-child, .case-title { font-size: clamp(2.5rem, calc(100cqi / 12.6), 6rem); }
.hero-title .quiet { color: var(--ink-2); }

.hero-sub .employer { color: var(--ink); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 60%, transparent); text-underline-offset: 3px; transition: color 0.25s; }
.hero-sub .employer:hover { color: var(--accent-text); }
.hero-sub .home-base {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.35rem;
  opacity: 0.75;
}
.hero-sub .home-base svg { width: 9px; height: 12px; color: var(--accent); flex: none; }
.hero-sub {
  grid-column: 1 / span 10;
  margin-top: 1.1rem;
  color: var(--muted);
  font-size: var(--fs-small);
}

/* Looping clip thumbnail */
.loop {
  grid-column: 11 / span 2;
  grid-row: 1 / span 2;
  justify-self: end;
  position: relative;
  width: clamp(88px, 4rem + 5vw, 148px);
  aspect-ratio: 1;
  border-radius: 16px;
  overflow: hidden;
  background: var(--slate);
}
.loop img, .loop video {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  filter: var(--photo-filter);
  transition: filter 0.8s var(--ease);
}
.loop .drift { /* stand-in motion until a real clip is added */
  animation: slow-zoom 18s ease-in-out infinite alternate;
}
.loop::after { /* moving fog inside the thumbnail */
  content: "";
  position: absolute;
  inset: -20% -60%;
  background: radial-gradient(40% 30% at 30% 55%, rgba(255,255,255,0.45), transparent 70%),
              radial-gradient(35% 25% at 70% 40%, rgba(255,255,255,0.35), transparent 70%);
  animation: fog-drift 14s linear infinite;
  pointer-events: none;
}
.loop.is-paused .drift, .loop.is-paused::after { animation-play-state: paused; }
.loop.has-video::after { display: none; } /* a real clip doesn't need the pretend fog */
.loop-open { position: absolute; inset: 0; z-index: 1; border: 0; background: none; cursor: zoom-in; }
/* Hover the mood window: it grows toward the headline (and a real clip gets its sound) */
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .loop {
    transform-origin: top right;
    transition: scale 0.55s var(--ease), box-shadow 0.55s var(--ease);
  }
  .loop:hover, .loop.is-hover {
    scale: 2;
    z-index: 6;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  }
  /* keep the controls their normal size while the window is zoomed */
  .loop .loop-btn, .loop .loop-label, .loop .loop-cap, .loop .loop-hint {
    transition: scale 0.55s var(--ease), opacity 0.3s var(--ease);
  }
  .loop:hover .loop-btn, .loop.is-hover .loop-btn { scale: 0.5; transform-origin: bottom left; }
  .loop:hover :is(.loop-label, .loop-cap, .loop-hint), .loop.is-hover :is(.loop-label, .loop-cap, .loop-hint) { scale: 0.5; }
}
.loop-cap, .loop-hint {
  position: absolute;
  z-index: 2;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  background: rgba(8, 10, 12, 0.62);
  -webkit-backdrop-filter: blur(8px);
          backdrop-filter: blur(8px);
  color: #fff;
  font-size: 0.75rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
}
.loop-cap { left: 10px; top: 10px; transform-origin: top left; }
.loop-hint { right: 10px; top: 10px; transform-origin: top right; }
.loop.is-hover .loop-cap, .loop:hover .loop-cap, .loop:focus-within .loop-cap { opacity: 1; }
.loop.needs-click .loop-hint { opacity: 1; }
/* a soft shade top and bottom while hovering, so the labels read on bright footage */
.loop > video + .loop-open, .loop::before { border-radius: inherit; }
.loop::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.45), transparent 32%, transparent 62%, rgba(0, 0, 0, 0.5));
  opacity: 0;
  transition: opacity 0.4s var(--ease);
}
.loop:hover::before, .loop.is-hover::before { opacity: 1; }
.loop:hover .loop-label, .loop.is-hover .loop-label {
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  background: rgba(8, 10, 12, 0.62);
  font-size: 0.75rem;
  color: #fff;
}
.loop-label { transform-origin: bottom right; }

/* The clip, bigger */
.clip-view {
  max-width: none; max-height: none;
  width: 100%; height: 100%;
  margin: 0; padding: var(--gutter);
  border: 0;
  background: color-mix(in srgb, #07090A 88%, transparent);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 1rem;
  opacity: 0;
  transition: opacity 0.3s var(--ease);
  cursor: zoom-out;
}
.clip-view::backdrop { background: transparent; }
.clip-view.is-open { opacity: 1; }
.clip-view video {
  max-width: min(100%, 1100px);
  max-height: 78vh;
  border-radius: var(--radius);
  scale: 0.96;
  transition: scale 0.4s var(--ease);
}
.clip-view.is-open video { scale: 1; }
.clip-cap { color: #ECECE8; }
.clip-close { color: #A2A7AA; }
.loop-btn {
  position: absolute;
  left: 10px; bottom: 10px;
  width: 34px; height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,0.7);
  border-radius: 50%;
  background: rgba(17,17,17,0.18);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: #fff;
  cursor: pointer;
  z-index: 2;
  transition: background-color 0.3s, transform 0.3s var(--ease);
}
.loop-btn:hover { background: rgba(17,17,17,0.35); transform: scale(1.06); }
.loop-btn svg { width: 12px; height: 12px; }
.loop-btn .i-play { display: none; }
.loop.is-paused .loop-btn .i-play { display: block; }
.loop.is-paused .loop-btn .i-pause { display: none; }
.loop-label {
  position: absolute;
  right: 10px; bottom: 12px;
  z-index: 2;
  color: rgba(255,255,255,0.9);
  font-size: 0.625rem;
}

/* The big photo */
.hero-photo {
  position: relative;
  border-radius: calc(var(--radius-lg) - 8px);
  overflow: hidden;
  width: 100%;
  height: clamp(460px, 62vh, 720px);
  background: #2b3236;
  color: #fff;
  isolation: isolate;
}
.hero-photo > picture img,
.photo-fill {
  position: absolute;
  inset: -6% 0 0 0;
  width: 100%;
  height: 112%;
  object-fit: cover;
  filter: var(--photo-filter);
  transition: filter 1s var(--ease);
  will-change: transform;
}
.hero-photo::before { /* weather tint */
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: var(--photo-tint);
  transition: background 1s var(--ease);
  pointer-events: none;
}
.hero-photo::after { /* legibility gradients, top-right and bottom */
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  background:
    linear-gradient(to top, rgba(10,14,16,0.72) 0%, rgba(10,14,16,0.28) 32%, transparent 58%),
    radial-gradient(60% 55% at 100% 0%, rgba(10,14,16,0.42), transparent 70%);
  pointer-events: none;
}

.hero-intro {
  position: absolute;
  z-index: 4;
  left: clamp(1.25rem, 0.5rem + 3vw, 3rem);
  bottom: clamp(1.25rem, 0.5rem + 3vw, 3rem);
  max-width: 34ch;
}
.hero-intro p {
  font-size: clamp(1rem, 0.92rem + 0.4vw, 1.25rem);
  line-height: 1.45;
  letter-spacing: -0.005em;
  margin-bottom: 1.1rem;
  text-shadow: 0 1px 12px rgba(0,0,0,0.25);
}
.hero-intro .link { color: #fff; }

.hero-stat {
  position: absolute;
  z-index: 4;
  right: clamp(1.25rem, 0.5rem + 3vw, 3rem);
  top: clamp(1.25rem, 0.5rem + 3vw, 3rem);
  text-align: right;
}
.hero-stat .num {
  font-size: clamp(2.5rem, 1.6rem + 3.4vw, 4.75rem);
  line-height: 1;
  letter-spacing: -0.04em;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
}
.hero-stat .num small {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  margin-left: 0.35rem;
  opacity: 0.85;
}
.hero-stat p { margin-top: 0.5rem; opacity: 0.88; }

.hero-coords {
  position: absolute;
  z-index: 4;
  right: clamp(1.25rem, 0.5rem + 3vw, 3rem);
  bottom: clamp(1.25rem, 0.5rem + 3vw, 3rem);
  color: rgba(255,255,255,0.85);
}

/* ---------- Hero weather (layers are built by weather.js) ----------- */


/* Parallax: scroll (--py) and tilt (--tx/--ty) combine on one transform */
[data-parallax] { transform: translate3d(var(--tx, 0px), calc(var(--py, 0%) + var(--ty, 0px)), 0); }
/* No dragging the photo off the page (right-click still opens it) */
.hero-photo { -webkit-user-select: none; user-select: none; }
.hero-photo img { -webkit-user-drag: none; }
.hero-photo .hero-intro p { -webkit-user-select: text; user-select: text; }

/* The scene tilts inside a frame that doesn't move */
.hero-photo [data-parallax] {
  transform:
    perspective(1200px)
    rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg))
    translate3d(var(--tx, 0px), calc(var(--py, 0%) + var(--ty, 0px)), 0)
    scale(1.09);
}
/* the text on the photo stays put; only the scene behind it tilts */

.wx {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  overflow: hidden;
  transition: opacity 1.4s var(--ease), visibility 0s 1.4s;
}
:root[data-weather="sun"] .wx-sun,
:root[data-weather="fog"] .wx-fog,
:root[data-weather="snow"] .wx-frost { opacity: 1; visibility: visible; transition-delay: 0s; }

.wx-canvas {
  position: absolute;
  inset: -16px;
  width: calc(100% + 32px);
  height: calc(100% + 32px);
  z-index: 2;
  pointer-events: none;
}

/* Sun: warm bloom and slow, shifting rays from the top-right */
.wx-sun {
  mix-blend-mode: screen;
  background: radial-gradient(60% 70% at 86% 6%, rgba(255, 214, 150, 0.28), transparent 70%);
}
.wx-sun::before {
  content: "";
  position: absolute;
  inset: -30%;
  background: repeating-conic-gradient(from 190deg at 72.5% 22.5%,
    rgba(255, 236, 200, 0) 0deg, rgba(255, 236, 200, 0.14) 2.5deg, rgba(255, 236, 200, 0) 6deg,
    rgba(255, 236, 200, 0.07) 8deg, rgba(255, 236, 200, 0) 13deg);
  -webkit-mask: radial-gradient(55% 60% at 72.5% 22.5%, #000, transparent 80%);
          mask: radial-gradient(55% 60% at 72.5% 22.5%, #000, transparent 80%);
  transform-origin: 72.5% 22.5%;
  animation: rays 26s ease-in-out infinite alternate;
}
@keyframes rays {
  from { transform: rotate(-3deg); opacity: 0.65; }
  to   { transform: rotate(3deg); opacity: 1; }
}

/* Fog: tileable noise banks at three speeds; the cursor wipes a clear patch */
.wx-fog {
  -webkit-mask-image: radial-gradient(circle var(--fr, 1px) at var(--mx, 50%) var(--my, 50%), rgba(0,0,0,0.12) 20%, #000 100%);
          mask-image: radial-gradient(circle var(--fr, 1px) at var(--mx, 50%) var(--my, 50%), rgba(0,0,0,0.12) 20%, #000 100%);
}
.wx-fog::before { /* general haze, thickest in the valley */
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(236,240,241,0.28), rgba(236,240,241,0.08) 45%, rgba(236,240,241,0.3));
}
.wx-fog i {
  position: absolute;
  left: 0;
  width: 200%;
  background-repeat: repeat;
  will-change: transform;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 35%, #000 70%, transparent);
          mask-image: linear-gradient(to bottom, transparent, #000 35%, #000 70%, transparent);
}
.wx-fog i:nth-child(1) { top: 35%; bottom: -8%; background-size: 50% 100%; opacity: 0.85; animation: fog-a 90s linear infinite; }
.wx-fog i:nth-child(2) { top: -5%; bottom: 30%; background-size: 50% 100%; background-position: 30% 0; opacity: 0.45; animation: fog-b 150s linear infinite; }
.wx-fog i:nth-child(3) { top: 55%; bottom: -15%; background-size: 25% 100%; opacity: 0.6; animation: fog-a 60s linear infinite; }
@keyframes fog-a { from { transform: translate3d(0, 0, 0); } to { transform: translate3d(-50%, 0, 0); } }
@keyframes fog-b { from { transform: translate3d(-50%, 0, 0); } to { transform: translate3d(0, 0, 0); } }

/* Snow: a rime of frost creeping in from the edges of the glass */
.wx-frost {
  background:
    radial-gradient(ellipse 75% 70% at 50% 45%, transparent 55%, rgba(236, 244, 250, 0.45) 100%),
    var(--noise, none) 0 0 / 22% auto repeat;
  -webkit-mask-image: radial-gradient(ellipse 75% 70% at 50% 45%, transparent 52%, #000 100%);
          mask-image: radial-gradient(ellipse 75% 70% at 50% 45%, transparent 52%, #000 100%);
}

/* Lightning */
.wx-flash {
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  mix-blend-mode: screen;
  background: radial-gradient(120% 90% at 30% 0%, rgba(225, 235, 255, 0.95), rgba(200, 215, 240, 0.4) 60%, rgba(180, 200, 230, 0.25));
}

/* A soft glare that follows the cursor */
.hero-glare {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: var(--hover, 0);
  mix-blend-mode: soft-light;
  background: radial-gradient(700px circle at var(--mx, 50%) var(--my, 50%), rgba(255, 255, 255, 0.35), transparent 50%);
}

/* The weather toggle lives on the photo */
.hero-photo .weather-toggle {
  position: absolute;
  z-index: 5;
  left: clamp(1.25rem, 0.5rem + 3vw, 3rem);
  top: clamp(1.25rem, 0.5rem + 3vw, 3rem);
  border-color: rgba(255, 255, 255, 0.3);
  background: rgba(14, 18, 20, 0.28);
  -webkit-backdrop-filter: blur(12px);
          backdrop-filter: blur(12px);
}
.hero-photo .weather-toggle button { color: rgba(255, 255, 255, 0.82); }
.hero-photo .weather-toggle button:hover { color: #fff; }
.hero-photo .weather-toggle button[aria-pressed="true"] { background: #fff; color: #111; }
.hero-photo .weather-toggle button:focus-visible { outline-color: #fff; }

@keyframes fog-drift {
  from { transform: translate3d(-18%, 0, 0); }
  to   { transform: translate3d(18%, 0, 0); }
}
@keyframes slow-zoom {
  from { transform: scale(1); }
  to   { transform: scale(1.12) translate3d(-3%, 1%, 0); }
}

/* Live weather line under the hero */
.hero-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  padding-top: 1.1rem;
  color: var(--muted);
}
.wx-line { display: inline-flex; align-items: center; gap: 0.5rem; }
.wx-line svg { width: 14px; height: 14px; }
:root[data-weather="sun"] .wx-line svg { color: var(--accent); }
/* "Live": a pulsing dot while the reading is fresh, and when it was taken */
.live-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.5rem 0.2rem 0.4rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--ink);
  font-size: 0.625rem;
  letter-spacing: 0.06em;
}
.live-tag i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.wx-line.is-live .live-tag i {
  background: var(--accent);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 50%, transparent);
  animation: here-pulse 2.4s ease-out infinite;
}
.wx-time { color: var(--muted); opacity: 0.7; }
.wx-time:empty { display: none; }

/* ---------- Intro statement ------------------------------------------ */

.statement .two-tone {
  grid-column: 3 / span 9;
  font-size: clamp(2rem, 1.1rem + 3.8vw, 4.5rem);
}

/* Trailhead as a short walk: the section holds still while you scroll through it */
.scene { position: relative; height: 240vh; padding-block: 0; }
.scene-sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  display: flex;
  align-items: center;
}
.scene-inner { position: relative; z-index: 2; width: 100%; }
.scene-map { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; }
.scene-map .ring { fill: none; stroke: var(--ink); stroke-opacity: 0.16; stroke-width: 1; stroke-dasharray: 1; stroke-dashoffset: 1; }
.scene-map .ring.major { stroke-opacity: 0.3; stroke-width: 1.3; }
.scene-map .is-top .ring.major { stroke: var(--accent); stroke-opacity: 0.8; transition: stroke 0.4s var(--ease); }
.scene-map .scene-ghost { fill: none; stroke: var(--ink); stroke-opacity: 0.07; stroke-width: 2; stroke-dasharray: 1 9; stroke-linecap: round; }
.scene-map .scene-trail { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-dasharray: 0.5 9; stroke-linecap: round; }
.scene-map .scene-draw { fill: none; stroke: #fff; stroke-width: 14; }
.scene-text .l1, .scene-text .l2 { display: block; --p: 1; } /* fully written without JS */
.scene-text .w { display: inline-block; white-space: nowrap; }
/* Each letter's progress: a soft wave --k letters wide, travelling along the line with the scroll */
.scene-text .c {
  --k: 7;
  --t: clamp(0, calc((var(--p) * (var(--n) + var(--k)) - var(--i)) / var(--k)), 1);
  display: inline-block;
}
.scene-text .l1 .c { opacity: calc(0.16 + var(--t) * 0.84); color: var(--ink-2); }
.scene-text .l2 { margin-top: 0.1em; color: var(--ink); }
.scene-text .l2 .c {
  opacity: var(--t);
  translate: 0 calc((1 - var(--t)) * 0.45em);
  filter: blur(calc((1 - var(--t)) * 5px));
}
/* words marked with *asterisks* in Sanity get the dotted trail, drawn at the same pace */
.scene-text .mark { position: relative; }
.scene-text .mark::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: 0.02em;
  height: 3px;
  width: calc(clamp(0, calc((var(--p) * (var(--n) + 7) - var(--a)) / (var(--b) - var(--a) + 7)), 1) * 100%);
  background: radial-gradient(circle, var(--accent) 1.4px, transparent 1.8px) 0 50% / 9px 3px repeat-x;
}
.scene-walker {
  position: absolute;
  left: 0; top: 0;
  z-index: 3;
  pointer-events: none;
  will-change: transform;
}
.scene-walker i {
  position: absolute;
  left: -6px; top: -6px;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent);
}
.scene-walker i::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  animation: here-pulse-ring 2s ease-out infinite;
}
@keyframes here-pulse-ring { from { transform: scale(0.6); opacity: 1; } to { transform: scale(2.4); opacity: 0; } }
.scene-walker b {
  position: absolute;
  left: 14px; top: -26px;
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--ink);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 720px) {
  .scene { height: 210vh; }
}
@media (prefers-reduced-motion: reduce) {
  .scene { height: auto; }
  .scene-sticky { position: relative; height: auto; min-height: 80vh; }
  .scene-text .l1, .scene-text .l2 { --p: 1 !important; }
  .scene-map .ring { stroke-dashoffset: 0; }
}

/* ---------- Work ------------------------------------------------------ */

.work-head { align-items: end; margin-bottom: clamp(3rem, 2rem + 3vw, 6rem); }
.work-head .two-tone { grid-column: 1 / span 7; }
.work-head p { grid-column: 8 / span 3; color: var(--muted); max-width: 38ch; }
.work-head .rail-ctrl { grid-column: 11 / span 2; justify-self: end; display: flex; gap: 0.5rem; }

/* Projects scroll sideways, still staggered like an elevation profile */
.projects {
  grid-auto-columns: clamp(270px, 25vw, 400px);
  align-items: start;
  padding-bottom: 1rem;
}
.project:nth-child(4n + 2) { margin-top: clamp(2rem, 4vw, 5rem); }
.project:nth-child(4n + 3) { margin-top: clamp(0.75rem, 1.5vw, 2rem); }
.project:nth-child(4n + 4) { margin-top: clamp(3rem, 5.5vw, 7rem); }

.project a, .project .project-inner { display: block; }
.project figure {
  position: relative;
  aspect-ratio: 4 / 5;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--code-bg);
}
.project figure img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 1s var(--ease);
}
.project a:hover figure img,
.project a:focus-visible figure img { transform: scale(1.018); }
.waypoint {
  position: absolute;
  left: 1rem; top: 1rem;
  padding: 0.3rem 0.55rem;
  border-radius: 6px;
  background: color-mix(in srgb, var(--paper) 82%, transparent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  color: var(--ink);
}
.project-meta {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 1rem;
  padding-top: 1.25rem;
}
.project h3 {
  font-size: var(--fs-h3);
  letter-spacing: -0.02em;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}
.project h3 .arrow { width: 1.1rem; color: var(--accent-text); }
.project .year { color: var(--muted); align-self: center; }
.project .desc { grid-column: 1 / -1; color: var(--muted); max-width: 46ch; }
.project .role { grid-column: 1 / -1; margin-top: 0.35rem; color: var(--ink); opacity: 0.8; line-height: 1.5; }
.project h3 .arrow.out { rotate: -45deg; }
.tags { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0.35rem 1rem; margin-top: 0.4rem; color: var(--muted); }
.tags li::before { content: "#"; color: var(--marker); margin-right: 0.15em; }
.soon { color: var(--muted); font-size: var(--fs-mono); font-family: var(--font-mono); }

/* ---------- About ----------------------------------------------------- */

.about .grid { align-items: start; }
.about-photo {
  grid-column: 1 / span 5;
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 4 / 5;
  background: var(--slate);
}
.about-photo img {
  position: absolute;
  inset: -5% 0 0;
  width: 100%;
  height: 110%;
  object-fit: cover;
  filter: var(--photo-filter);
  transition: filter 1s var(--ease);
  will-change: transform;
}
.about-photo figcaption {
  position: absolute;
  left: 1rem; bottom: 1rem;
  color: rgba(255,255,255,0.9);
  z-index: 1;
}
.about-photo::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.45), transparent 35%);
}
.about-body { grid-column: 7 / span 6; padding-top: clamp(0rem, 4vw, 4rem); }
.about-body .two-tone { font-size: clamp(1.75rem, 1.1rem + 2.4vw, 3rem); margin-bottom: 2rem; }
.prose { max-width: 58ch; }
.prose p + p { margin-top: 1.1em; }
.prose p { color: color-mix(in srgb, var(--ink) 82%, var(--paper)); }

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gutter);
  margin-top: clamp(2.5rem, 2rem + 2vw, 4rem);
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}
.stat .n {
  display: block;
  font-size: clamp(2.25rem, 1.6rem + 2.4vw, 3.75rem);
  line-height: 1;
  letter-spacing: -0.04em;
  font-weight: 300;
  font-variant-numeric: tabular-nums;
}
.stat .l { display: block; margin-top: 0.6rem; color: var(--muted); }
.stats .stat + .stat { padding-left: var(--gutter); border-left: 1px solid var(--line); }
.stats { column-gap: 0; }
.stats .stat { padding-right: 1rem; }

/* Small pictures of each stat */
.viz { display: block; height: 2.9rem; width: auto; max-width: 100%; margin-bottom: 1.25rem; overflow: visible; }
.viz text { font-family: var(--font-mono); font-size: 8px; fill: var(--muted); }
.viz .base { stroke: var(--line-strong); stroke-width: 1; }
.viz-years rect { fill: var(--ink); opacity: 0; transition: opacity 0.5s var(--ease) calc(var(--i) * 18ms); }
.viz-years rect.hot { fill: var(--accent); }
.is-counted .viz-years rect { opacity: var(--o); }
.is-counted .viz-years rect.hot { opacity: calc(var(--o) + 0.45); }
/* hover: each box flares up and fades slowly, so a sweep leaves a trail */
.viz-years { pointer-events: auto; }
.viz-years rect { cursor: crosshair; }
.is-counted .viz-years rect { transition: opacity 1.4s var(--ease), filter 1.4s var(--ease), fill 1.4s var(--ease); transition-delay: 0s; }
.is-counted .viz-years rect { transition-duration: 1.8s; }
.is-counted .viz-years rect.col-on { opacity: calc(var(--o) + 0.3); transition-duration: 0.25s; }
.is-counted .viz-years rect.glow {
  opacity: 1;
  fill: var(--accent);
  filter: drop-shadow(0 0 3px var(--accent)) drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 60%, transparent));
  transition-duration: 0.08s;
}
.is-counted .viz-years rect.hot.glow { fill: #FFB37A; }
.viz-years .yr-now { fill: var(--accent-text); opacity: 0; transition: opacity 0.2s; }
.viz-years.is-scrubbing .yr-now { opacity: 1; }
.viz-years.is-scrubbing .yr-end { opacity: 0; }
.viz-years .yr-end { transition: opacity 0.2s; }
.viz-summits .sky { fill: none; stroke: var(--ink); stroke-width: 1.1; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; opacity: 0.75; }
.is-counted .viz-summits .sky { animation: draw-line 1.8s var(--ease) forwards; }
.viz-summits .peak { fill: var(--accent); opacity: 0; transition: opacity 0.4s var(--ease) 1.5s; }
.is-counted .viz-summits .peak { opacity: 1; }
/* skyline marker */
.viz-summits { pointer-events: auto; cursor: crosshair; }
.viz-summits .cursor-peak { opacity: 0; transition: opacity 0.2s; pointer-events: none; }
.viz-summits.is-scrubbing .cursor-peak { opacity: 1; }
.viz-summits .cursor-peak circle { fill: var(--accent); filter: drop-shadow(0 0 3px var(--accent)); }
.viz-summits .cursor-peak .stem { stroke: var(--accent); stroke-width: 0.8; stroke-dasharray: 1.5 2; }
.viz-summits .cursor-peak text { fill: var(--accent-text); font-size: 7.5px; }
.viz-summits.is-scrubbing .peak { opacity: 0.35; }
/* boot prints walk on hover */
.viz-boots { pointer-events: auto; cursor: pointer; }
/* while hovered, the prints keep walking: each foot lands in turn, left to right, on a loop */
.viz-boots .step path { transition: fill 0.4s var(--ease), opacity 0.4s var(--ease); }
@media (prefers-reduced-motion: no-preference) {
  .viz-boots:hover .step path { animation: foot-land 1.8s linear infinite both; }
  .viz-boots:hover .step path:nth-child(1) { animation-delay: calc(var(--i) * 0.4s); }
  .viz-boots:hover .step path:nth-child(2) { animation-delay: calc(var(--i) * 0.4s + 0.2s); }
}
@keyframes foot-land {
  0% { opacity: 0.12; fill: var(--ink); }
  6% { opacity: 1; fill: var(--accent); filter: drop-shadow(0 0 3px var(--accent)); }
  30% { opacity: 0.85; fill: var(--ink); filter: none; }
  75% { opacity: 0.5; }
  100% { opacity: 0.12; fill: var(--ink); }
}
.viz-boots .step { fill: var(--ink); opacity: 0; translate: -6px 0; transition: opacity 0.5s var(--ease), translate 0.6s var(--ease); transition-delay: calc(0.25s + var(--i) * 0.3s); }
.viz-boots .step.hot { fill: var(--accent); }
.is-counted .viz-boots .step { opacity: 0.8; translate: 0 0; }
.viz-seasons .dawn { fill: none; stroke: var(--ink); stroke-width: 1.2; stroke-linecap: round; opacity: 0; translate: 0 10px; transition: opacity 0.7s var(--ease), translate 0.9s var(--ease); transition-delay: calc(0.3s + var(--i) * 0.35s); }
.viz-seasons .dawn:last-child { stroke: var(--accent); }
.is-counted .viz-seasons .dawn { opacity: 0.85; translate: 0 0; }
.viz-seasons { clip-path: inset(-10px -10px 5px -10px); }
.stat:hover .viz-summits .peak { animation: pk-arrive 0.5s var(--ease); }

/* About photo: Photo · Map · Code */
.about-photo .lens {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 1;
  clip-path: circle(0% at calc(100% - 3rem) 3rem);
  transition: clip-path 0.9s cubic-bezier(0.65, 0, 0.25, 1);
}
.about-photo[data-mode="map"] .lens-map,
.about-photo[data-mode="code"] .lens-code { clip-path: circle(150% at calc(100% - 3rem) 3rem); }
.about-photo[data-mode="code"] .lens-map { transition-delay: 0.9s; }
.about-photo[data-mode="map"] .lens-code { transition-delay: 0.9s; }
.about-photo::after { z-index: 0; }
.about-photo figcaption { z-index: 3; transition: color 0.6s var(--ease); }
.about-photo[data-mode="map"] figcaption { color: var(--ink); }
.about-photo[data-mode="map"]::after { opacity: 0; }
.about-photo::after { transition: opacity 0.6s var(--ease); }
.about-photo .lens-toggle { position: absolute; z-index: 3; top: 1rem; right: 1rem; }

/* Map view: a real contour map of where the photo was taken */
.lens-map { background: var(--paper); color: var(--ink); }
.lens-map svg { width: 100%; height: 100%; display: block; }
.lens-map text { font-family: var(--font-mono); font-size: 17px; fill: var(--muted); }
.map-c, .map-ci { fill: none; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 1; }
.map-c { stroke: var(--ink); stroke-opacity: 0.32; stroke-width: 1.1; }
.map-ci { stroke: var(--accent); stroke-opacity: 0.8; stroke-width: 1.7; }
.is-drawn .map-c { animation: draw-line 2.4s var(--ease) forwards; }
.is-drawn .map-ci { animation: draw-line 2.4s var(--ease) 0.25s forwards; }
.map-water { fill: color-mix(in srgb, #6F8795 30%, var(--paper)); }
.map-water-hatch { opacity: 0.5; }
.map-hatch { stroke: #6F8795; stroke-width: 0.8; }
.lens-map .map-lake { font-family: var(--font-sans); font-style: italic; font-size: 26px; letter-spacing: 0.06em; fill: #58717F; }
.map-spot path { fill: var(--ink); }
.lens-map .map-spot text { fill: var(--ink); font-size: 18px; }
.map-cone { stroke: none; }
.cone-s0 { stop-color: var(--accent); stop-opacity: 0.42; }
.cone-s1 { stop-color: var(--accent); stop-opacity: 0; }
.map-cone-edge { fill: none; stroke: var(--accent); stroke-width: 1.6; stroke-opacity: 0.8; stroke-linejoin: round; }
.map-cone-axis { fill: none; stroke: var(--accent); stroke-width: 2; stroke-dasharray: 3 9; stroke-linecap: round; animation: view-flow 1.4s linear infinite; }
@keyframes view-flow { to { stroke-dashoffset: -12; } }
.map-cone-head { fill: none; stroke: var(--accent); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.lens-map .map-cone-label { font-size: 15px; letter-spacing: 0.08em; fill: var(--accent-text); }
.map-pin-dot { fill: var(--accent); stroke: var(--paper); stroke-width: 2.5; }
.map-pin-ring { fill: none; stroke: var(--accent); stroke-width: 1.5; transform-box: fill-box; transform-origin: center; animation: pin-ring 2.4s ease-out infinite; }
@keyframes pin-ring { from { transform: scale(0.4); opacity: 1; } to { transform: scale(2.2); opacity: 0; } }
.map-pin, .map-view { opacity: 0; }
.is-drawn .map-pin { animation: pin-drop 0.7s var(--ease) 0.9s both; }
.is-drawn .map-view { animation: vt-fade-in 0.8s var(--ease) 1.3s both; }
@keyframes pin-drop { from { opacity: 0; transform: translateY(-24px); } to { opacity: 1; transform: none; } }
@keyframes vt-fade-in { to { opacity: 1; } }
.lens-map .map-pin-label { font-family: var(--font-sans); font-size: 30px; letter-spacing: -0.01em; fill: var(--ink); }
.lens-map .map-pin-sub { fill: var(--accent-text); font-size: 18px; }
.map-scale path { fill: none; stroke: var(--ink); stroke-width: 1.4; }
.map-north path { fill: var(--ink); }
.map-missing { position: absolute; inset: auto 1rem 3rem; color: var(--muted); }
.about-photo[data-mode="map"] figcaption { color: var(--ink); }

/* Code view: the page's own source for this photo */
.lens-code { background: #07090A; }
.lens-code canvas { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0.13; }
.lens-src {
  position: absolute;
  inset: 4rem 0 3rem;
  margin: 0;
  padding: 0.5rem 1.25rem 1.5rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
  cursor: text;
  -webkit-user-select: text;
          user-select: text;
  color: #C9D1CC;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  -webkit-mask-image: linear-gradient(to bottom, transparent, #000 1rem, #000 calc(100% - 1.5rem), transparent);
          mask-image: linear-gradient(to bottom, transparent, #000 1rem, #000 calc(100% - 1.5rem), transparent);
}
.lens-src::-webkit-scrollbar { width: 6px; }
.lens-src::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.18); border-radius: 3px; }
.lens-src .t { color: #A7B89A; }
.lens-src .a { color: #8C9A92; }
.lens-src .s { color: #EE9A6C; }
.lens-src .c { color: #6B7670; }
.lens-src .k { color: #C9B7E8; }
.lens-src .n { color: #E2C878; }
.lens-src .cur { display: inline-block; width: 0.6em; height: 1.1em; margin-left: 1px; vertical-align: text-bottom; background: #EE9A6C; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.about-photo[data-mode="code"] figcaption { color: #C9D1CC; }

/* Frosted pill toggles that sit on photos */
.glass-toggle {
  display: inline-flex;
  gap: 0.15rem;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  background: rgba(14, 18, 20, 0.3);
  -webkit-backdrop-filter: blur(12px);
          backdrop-filter: blur(12px);
}
.glass-toggle button {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  font: inherit;
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.02em;
  padding: 0.35rem 0.7rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.3s, color 0.3s;
}
.glass-toggle button:hover { color: #fff; }
.glass-toggle button[aria-pressed="true"] { background: #fff; color: #111; }
.glass-toggle button:focus-visible { outline-color: #fff; }

/* ---------- Field notes ---------------------------------------------- */

.notes-head { align-items: end; margin-bottom: clamp(2.5rem, 2rem + 2vw, 4rem); }
.notes-head .two-tone { grid-column: 1 / span 7; }
.notes-head .notes-ctrl { grid-column: 10 / span 3; justify-self: end; display: flex; gap: 0.5rem; }
.rail-ctrl button {
  appearance: none;
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.3s, background-color 0.3s;
}
.rail-ctrl button:hover { border-color: var(--ink); }
.rail-ctrl button:disabled { opacity: 0.35; cursor: default; }
.rail-ctrl svg { width: 16px; height: 10px; }
.rail-ctrl .prev svg { transform: scaleX(-1); }

.rail {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: clamp(250px, 22vw, 320px);
  gap: clamp(1rem, 0.5rem + 1.2vw, 1.75rem);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: max(var(--gutter), calc((100vw - var(--max)) / 2 + var(--gutter)));
  padding-inline: max(var(--gutter), calc((100vw - var(--max)) / 2 + var(--gutter)));
  padding-bottom: 1.5rem;
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }

/* Progress track under a carousel */
.rail-bar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-top: 1.5rem;
}
.rail-track {
  position: relative;
  flex: 1;
  height: 28px;            /* generous hit area, thin line */
  cursor: grab;
  touch-action: none;
}
.rail-track:active { cursor: grabbing; }
.rail-track::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 50%;
  height: calc(1px + var(--grow, 0) * 3px);
  translate: 0 -50%;
  border-radius: 3px;
  background: var(--line-strong);
  transition: height 0.18s var(--ease);
}
.rail-thumb {
  position: absolute;
  top: 50%;
  height: calc(3px + var(--grow, 0) * 9px);
  translate: 0 -50%;
  border-radius: 6px;
  background: var(--accent);
  transition: height 0.18s var(--ease);
}
.rail-track:hover .rail-thumb { height: 12px; }
.rail-count { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 7ch; text-align: right; }
.rail > li { scroll-snap-align: start; }
.rail:focus-visible { outline-offset: -2px; }
@media (hover: hover) and (pointer: fine) {
  .rail { cursor: grab; }
  .rail.is-dragging { cursor: grabbing; scroll-snap-type: none; }
  .rail.is-dragging * { pointer-events: none; }
}
.entry { display: flex; flex-direction: column; height: 100%; }
.entry figure {
  aspect-ratio: 4 / 5;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--slate);
  margin-bottom: 1rem;
}
.entry figure img {
  width: 100%; height: 100%;
  object-fit: cover;
  filter: saturate(1.12) contrast(1.04);
  transition: filter 1s var(--ease), transform 1s var(--ease);
}
.entry:hover figure img { transform: scale(1.02); }
.entry-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  flex-wrap: wrap;
}
.entry-meta svg { width: 14px; height: 14px; flex: none; }
.entry-meta .sep { opacity: 0.5; }
.entry h3 { font-size: 1.0625rem; letter-spacing: -0.01em; margin-top: 0.5rem; }
.entry p { margin-top: 0.35rem; color: var(--muted); font-size: var(--fs-small); }

/* Dev notes: same shape as a trip entry, but the "photo" is a bit of code */
.dev-code {
  position: relative;
  aspect-ratio: 4 / 5;
  margin: 0 0 1rem;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background: color-mix(in srgb, #000 22%, var(--paper));
  transition: border-color 0.4s var(--ease);
}
.entry-link:hover .dev-code { border-color: var(--line-strong); }
.dev-file {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
}
.dev-file::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.dev-code pre {
  margin: 0;
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: clamp(0.6875rem, 0.62rem + 0.2vw, 0.8125rem);
  line-height: 1.7;
  color: var(--accent-text);
  white-space: pre-wrap;
  word-break: break-word;
}
.dev-code .dc { color: var(--muted); }
.dev-code .dd { color: color-mix(in srgb, var(--accent-text) 45%, var(--muted)); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }
.entry--dev code { font-family: var(--font-mono); font-size: 0.85em; color: var(--accent-text); }
/* opened large in the detail view */
.note-figure .dev-code { aspect-ratio: auto; height: 100%; margin: 0; border: 0; border-radius: 0; }
.note-figure .dev-code pre { font-size: clamp(0.875rem, 0.7rem + 0.6vw, 1.125rem); padding: clamp(1.25rem, 1rem + 1.5vw, 2.5rem); }
.note-figure .dev-file { padding: 1.1rem clamp(1.25rem, 1rem + 1.5vw, 2.5rem); }

/* Says what a click will do, right at the cursor */
.cursor-tip {
  position: fixed;
  left: 0; top: 0;
  z-index: 200;
  padding: 0.4rem 0.65rem;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.6875rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  scale: 0.9;
  transition: opacity 0.18s var(--ease), scale 0.18s var(--ease);
}
.cursor-tip.is-on { opacity: 1; scale: 1; }
.cursor-tip.is-go { background: var(--accent); color: #fff; }

/* Little explanations on hover */
.tip { position: relative; display: inline-flex; align-items: center; }
.tip::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 9px);
  translate: -50% 4px;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.01em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s var(--ease), translate 0.25s var(--ease);
  z-index: 5;
}
.tip::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 4px);
  translate: -50% 4px;
  border: 5px solid transparent;
  border-top-color: var(--ink);
  border-bottom: 0;
  opacity: 0;
  transition: opacity 0.2s var(--ease), translate 0.25s var(--ease);
}
.tip:hover::after, .tip:hover::before { opacity: 1; translate: -50% 0; }
.logbook { padding-top: 2.5rem; margin-top: -2.5rem; } /* room for tooltips inside the scroller */

/* ---------- Logbook: open an entry in place -------------------------- */

.entry-link { display: block; height: 100%; border-radius: var(--radius); }
.entry-link:focus-visible { outline-offset: 6px; }
.entry-link .entry--dev { transition: border-color 0.4s var(--ease); }
.entry-link:hover .entry--dev { border-color: var(--line-strong); }

.pill-back {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 1.05rem 0.55rem 0.9rem;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font: inherit;
  font-size: var(--fs-small);
  cursor: pointer;
}
.pill-back .arrow { width: 1rem; }
.pill-back:hover .arrow { transform: translateX(-3px); }

.notes.is-open .notes-head { display: flex; align-items: center; gap: 1.5rem; }
.notes.is-open .notes-head .two-tone .quiet,
.notes.is-open .notes-ctrl { display: none; }
.notes.is-open .pill-back { display: inline-flex; }
.notes.is-open .rail-bar { display: none; }

.note-detail { align-items: start; row-gap: 2.5rem; }
.note-figure {
  grid-column: 1 / span 6;
  position: relative;
  margin: 0;
  aspect-ratio: 4 / 5;
  max-height: 84vh;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--slate);
  cursor: zoom-out;
}
.note-figure img {
  width: 100%; height: 100%;
  object-fit: cover;
  filter: saturate(1.12) contrast(1.04);
  transition: filter 1s var(--ease);
}
.note-figure--dev { cursor: zoom-out; }

.note-text { grid-column: 8 / span 5; view-transition-name: note-text; }
.note-all {
  appearance: none; border: 0; background-color: transparent; padding-inline: 0;
  font: inherit; cursor: pointer;
  margin-bottom: 1.75rem;
}
.note-all:hover .arrow, .note-nav [data-note-step="-1"]:hover .arrow { transform: translateX(-4px); }
.note-count {
  display: flex;
  justify-content: space-between;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line-strong);
  color: var(--muted);
}
.note-title {
  margin: 1.4rem 0 2rem;
  font-size: clamp(2.25rem, 1.4rem + 2.8vw, 4rem);
  line-height: 1.02;
  letter-spacing: -0.035em;
  text-wrap: balance;
}
.note-title:focus { outline: none; }
.note-body dl div {
  display: grid;
  grid-template-columns: 7.5rem 1fr;
  gap: 1rem;
  padding-block: 0.8rem;
  border-top: 1px solid var(--line);
  font-size: var(--fs-small);
}
.note-body dl div:last-child { border-bottom: 1px solid var(--line); }
.note-body dt { color: var(--muted); }
.note-body p {
  margin-top: 1.1em;
  max-width: 52ch;
  font-size: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
}
.note-body dl + p { margin-top: 2rem; }
.note-body code { font-family: var(--font-mono); font-size: 0.85em; }
.note-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line-strong);
}
.note-nav button {
  appearance: none; border: 0; background: none; padding: 0.25rem 0;
  font: inherit; color: var(--ink); cursor: pointer;
  display: inline-flex; align-items: baseline; gap: 0.75rem;
  text-align: left;
}
.note-nav button .dir { display: inline-flex; align-items: center; gap: 0.5rem; }
.note-nav button .mono { color: var(--muted); }
.note-nav button:hover .dir { color: var(--accent-text); }

/* The morph (View Transitions API; browsers without it just swap) */
::view-transition-group(note-photo) { animation-duration: 0.7s; animation-timing-function: cubic-bezier(0.65, 0, 0.25, 1); }
::view-transition-old(note-photo),
::view-transition-new(note-photo) { height: 100%; animation-duration: 0.45s; }
::view-transition-old(root),
::view-transition-new(root) { animation-duration: 0.4s; }
::view-transition-new(note-text) { animation: vt-rise 0.6s 0.15s cubic-bezier(0.22, 0.61, 0.36, 1) both; }
::view-transition-old(note-text) { animation: vt-fade 0.2s both; }
::view-transition-group(note-text) { animation: none; }
@keyframes vt-rise { from { opacity: 0; transform: translateY(18px); } }
@keyframes vt-fade { to { opacity: 0; } }
.theme-vt::view-transition-old(root) { animation: none; }
.theme-vt::view-transition-new(root) { animation: dusk-fall 0.9s cubic-bezier(0.65, 0, 0.25, 1) both; }
@keyframes dusk-fall {
  from { clip-path: circle(0 at var(--vt-x, 100%) var(--vt-y, 0)); }
  to   { clip-path: circle(150vmax at var(--vt-x, 100%) var(--vt-y, 0)); }
}
.note-detail.is-entering { animation: vt-rise 0.5s var(--ease) both; }

/* ---------- Section colours: white, spruce, a little mist ------------ */

.theme-spruce {
  --paper: #25382F;
  --card: #2B4036;
  --ink: #F2F1EC;
  --ink-2: #93A69B;
  --muted: #B3C0B8;
  --line: rgba(242, 241, 236, 0.13);
  --line-strong: rgba(242, 241, 236, 0.26);
  --code-bg: rgba(242, 241, 236, 0.06);
  --slate: #1E2E27;
  --accent-text: #EE9A6C;
  --marker: #E07A45;
}
.theme-mist { --paper: #EEF0EA; }
/* White with spruce headings and black body text */
.theme-white {
  --paper: #FFFFFF;
  --ink: #111111;
  --ink-2: #7C917F;
  --muted: #3F4447;
  --line: #E6E7E3;
  --line-strong: #D2D4CE;
  --head: #25382F;
}
.theme-white .two-tone,
.theme-white h3 { color: var(--head); }
.theme-white .two-tone .quiet { color: var(--ink-2); }
.theme-spruce, .theme-mist, .theme-white {
  background: var(--paper);
  color: var(--ink);
  transition: background-color 0.8s var(--ease);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-spruce { --paper: #182620; --card: #1E2E27; --slate: #13201A; }
  :root:not([data-theme="light"]) .theme-mist { --paper: #181C1F; }
  :root:not([data-theme="light"]) .theme-white { --paper: #1C2024; --ink: #EDEDE9; --ink-2: #8FA394; --muted: #B4B9BC; --line: #2A2F34; --line-strong: #394047; --head: #B9CBB0; }
}

/* ---------- Stack / gear --------------------------------------------- */

.kit .two-tone { grid-column: 1 / span 6; margin-bottom: clamp(3rem, 2rem + 3vw, 5rem); }
.kit-col { grid-column: span 6; }
.kit-col:first-of-type { grid-column: 1 / span 5; }
.kit-col:last-of-type { grid-column: 7 / span 5; }
.kit-col h3 {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: var(--fs-h3);
  letter-spacing: -0.02em;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line-strong);
}
.kit-col h3 .mono { color: var(--muted); }
.kit-col li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 0.8rem;
  border-bottom: 1px solid var(--line);
}
.kit-col li span:last-child { color: var(--muted); text-align: right; }

/* ---------- Contact / base camp -------------------------------------- */

.basecamp { padding-block: var(--section) 0; }
.basecamp .two-tone { grid-column: 1 / span 10; font-size: clamp(2.25rem, 1.2rem + 4.4vw, 5.5rem); }
.contact-row {
  margin-top: clamp(2.5rem, 2rem + 3vw, 5rem);
  align-items: end;
}
.mail {
  grid-column: 1 / span 7;
  font-size: clamp(1.5rem, 1.1rem + 1.8vw, 2.5rem);
  letter-spacing: -0.03em;
  color: var(--ink);
}
.mail .arrow { color: var(--accent); }
.mail:hover { color: var(--accent-text); }
.socials { grid-column: 9 / span 4; display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; justify-content: flex-end; }
.socials a { font-size: var(--fs-small); color: var(--ink); opacity: 0.8; display: inline-flex; gap: 0.35rem; align-items: center; }
.socials a:hover { opacity: 1; color: var(--accent-text); }
.socials .arrow { width: 0.8rem; transform: rotate(-45deg); }
.socials a:hover .arrow { transform: rotate(-45deg) translateX(3px); }

.site-foot {
  margin-top: clamp(4rem, 3rem + 5vw, 8rem);
  padding-block: 1.75rem;
  border-top: 1px solid color-mix(in srgb, var(--ink) 12%, transparent);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 2rem;
  color: var(--muted);
}
.site-foot .foot-live { display: inline-flex; gap: 1.5rem; flex-wrap: wrap; }
.site-foot .bottom { color: var(--ink); display: inline-flex; align-items: center; gap: 0.5rem; }
.site-foot .bottom::before {
  content: "";
  width: 7px; height: 7px;
  background: var(--accent);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

/* ---------- Case study ----------------------------------------------- */

.case-hero .hero-photo { height: clamp(360px, 55vh, 640px); }
.case-title { grid-column: 1 / span 10; }
.back { display: inline-flex; gap: 0.5rem; align-items: center; color: var(--muted); margin-bottom: 2rem; }
.back .arrow { transform: scaleX(-1); }
.back:hover .arrow { transform: scaleX(-1) translateX(4px); }

.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--gutter);
  padding-block: 1.75rem;
  border-block: 1px solid var(--line);
}
.summary dt { color: var(--muted); margin-bottom: 0.5rem; }
.summary dd { font-size: var(--fs-small); }
.summary a { color: var(--accent-text); }

.chapter { padding-block: clamp(4rem, 3rem + 4vw, 7.5rem); }
.chapter .grid { align-items: start; }
.chapter .label { grid-column: 1 / span 3; color: var(--muted); display: flex; gap: 0.75rem; }
.chapter .label b { font-weight: 400; color: var(--accent-text); }
.chapter .body { grid-column: 5 / span 7; }
.chapter h2 { font-size: clamp(1.75rem, 1.2rem + 2vw, 2.75rem); line-height: 1.08; letter-spacing: -0.03em; margin-bottom: 1.75rem; text-wrap: balance; }
.chapter h2 .quiet { color: var(--ink-2); }

.figure-wide {
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--code-bg);
}
.figure-wide { background: #E3E6E2; }
.figure-wide img { width: 100%; aspect-ratio: 16 / 10; object-fit: contain; padding-block: 2rem; }
.figure-cap { margin-top: 0.75rem; color: var(--muted); }

pre.code {
  margin: 2rem 0 0;
  padding: 1.5rem;
  border-radius: 12px;
  background: var(--code-bg);
  color: color-mix(in srgb, var(--ink) 80%, var(--paper));
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  line-height: 1.7;
  overflow-x: auto;
  tab-size: 2;
}
pre.code .c { color: var(--muted); font-style: normal; }
pre.code .k { color: var(--moss); }
pre.code .s { color: var(--accent-text); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) pre.code .k { color: var(--lichen); }
}

.results {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gutter);
  margin-top: 2.5rem;
}

.next-trail {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 1rem;
  padding-block: 2.5rem;
  border-top: 1px solid var(--line);
}
.next-trail .two-tone { grid-column: auto; font-size: clamp(1.75rem, 1.2rem + 2.4vw, 3.25rem); }

/* ---------- Menu: the terrain as a trail map --------------------------- */

:where(body > :not(dialog)) {
  transition: opacity 0.32s var(--ease), filter 0.32s var(--ease), transform 0.4s var(--ease);
}
html.menu-open { overflow: hidden; }
html.menu-open body > :not(dialog) { opacity: 0; filter: blur(8px); transform: scale(0.985); }

.trail-map {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  background: var(--slate);
  color: var(--ink);
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
.trail-map::backdrop { background: transparent; }
.trail-map.is-open { opacity: 1; }
.trail-map::before { /* the same faint terrain as the hero, now the whole world */
  content: "";
  position: absolute;
  inset: 0;
  background: var(--topo);
  opacity: 0.55;
  -webkit-mask: url("../img/topo.svg") center / cover no-repeat;
          mask: url("../img/topo.svg") center / cover no-repeat;
}

.map-head .theme-btn { color: var(--ink); }
.map-head { position: relative; z-index: 2; height: var(--head-h); display: flex; align-items: center; }
.map-head .head-row { display: flex; justify-content: space-between; }
.map-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.map-svg .ring {
  fill: none;
  stroke: var(--ink);
  stroke-opacity: 0.17;
  stroke-width: 1;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-opacity 0.4s var(--ease);
}
.map-svg .ring.major { stroke-opacity: 0.32; stroke-width: 1.35; }
.trail-map.is-open .ring { animation: draw-line 1.1s var(--ease) var(--d, 0s) forwards; }
.map-svg .peak-rings { transition: opacity 0.4s var(--ease); }
.map-svg.has-hot .peak-rings:not(.is-hot) { opacity: 0.4; }
.map-svg .peak-rings.is-hot .ring { stroke-opacity: 0.5; }
.map-svg .peak-rings.is-hot .ring.major { stroke: var(--accent); stroke-opacity: 0.8; }
.map-svg .trail {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-dasharray: 0.5 9;
}
.map-svg .trail-draw { fill: none; stroke: #fff; stroke-width: 10; stroke-dasharray: 1; stroke-dashoffset: 1; }
.trail-map.is-open .trail-draw { animation: draw-line var(--dur, 1s) cubic-bezier(0.45, 0, 0.55, 1) var(--delay, 0s) forwards; }
.map-svg.no-anim .ring, .map-svg.no-anim .trail-draw { animation: none !important; stroke-dashoffset: 0; }
@keyframes draw-line { to { stroke-dashoffset: 0; } }

.map-peaks ol { position: absolute; inset: 0; z-index: 1; }
.map-peaks li {
  position: absolute;
  left: calc(var(--x) * 100%);
  top: calc(var(--y) * 100%);
  opacity: 0;
  translate: 0 12px;
  transition: opacity 0.45s var(--ease), translate 0.45s var(--ease);
}
.trail-map.is-open .map-peaks li {
  opacity: 1;
  translate: 0 0;
  transition-delay: var(--arrive, calc(0.35s + var(--i) * 0.09s));
}
/* each summit's marker pops when the trail arrives */
.trail-map.is-open .pk { animation: pk-arrive 0.45s var(--ease) var(--arrive, 0s) both; }
@keyframes pk-arrive {
  0% { scale: 0.2; }
  55% { scale: 1.5; }
  100% { scale: 1; }
}
.map-peaks a {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  translate: -8px -8px; /* marker sits exactly on the summit */
}
.map-peaks .flip a { flex-direction: row-reverse; text-align: right; translate: calc(-100% + 8px) -8px; }
.map-peaks a::before { /* a generous, invisible hit area */
  content: "";
  position: absolute;
  inset: -1.25rem -1.75rem -1.25rem -1.75rem;
  border-radius: 1rem;
}
.map-svg { cursor: default; }
.trail-map.near-peak, .trail-map.near-peak * { cursor: pointer; }
.pk {
  position: relative;
  flex: none;
  width: 16px; height: 16px;
  margin-top: 0.1rem;
  background: var(--ink);
  clip-path: polygon(50% 4%, 100% 96%, 0 96%);
  transition: transform 0.4s var(--ease), background-color 0.3s;
}
.map-peaks .txt { display: grid; gap: 0.3rem; margin-top: -0.35rem; }
.map-peaks .no { color: var(--muted); }
/* plain-language line under each summit, so the names never leave anyone guessing */
.map-peaks .sub {
  font-size: clamp(0.875rem, 0.82rem + 0.2vw, 1rem);
  line-height: 1.3;
  color: color-mix(in srgb, var(--ink) 72%, transparent);
  max-width: 24ch;
}
.map-peaks .flip .sub { justify-self: end; }
.map-peaks .nm {
  font-size: clamp(1.75rem, 1rem + 2.6vw, 3.5rem);
  line-height: 1;
  letter-spacing: -0.035em;
  transition: color 0.3s;
}
.map-peaks .here {
  display: none;
  width: max-content;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
}
.map-peaks .flip .here { justify-self: end; }
.map-peaks .is-here .here { display: block; }
.map-peaks .is-here .pk { background: var(--accent); }
.map-peaks .is-near .pk { transform: scale(1.35); background: var(--accent); }
.map-peaks .is-near .nm { color: var(--accent-text); }

.map-legend {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 1;
  padding-block: 1.5rem;
  color: var(--muted);
}
.map-legend .wrap { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.map-legend span { display: inline-flex; align-items: center; gap: 0.6rem; }
.map-legend .north { width: 10px; height: 14px; }

/* Portrait screens get their own route */
@media (orientation: portrait), (max-width: 720px) {
  .map-peaks li { left: calc(var(--px) * 100%); top: calc(var(--py) * 100%); }
  .map-peaks .flip a { flex-direction: row; text-align: left; translate: -8px -8px; }
  .map-legend .esc { display: none; }
}

/* ---------- Page-load entrance ---------------------------------------
   Layers arrive back to front: the terrain, then the photo, then the words,
   then the things closest to you. Farther layers are slower and softer. */
html.intro .topo::before { animation: intro-fade 2.2s ease 0s both; }
html.intro [data-intro] { animation: intro-near 0.85s cubic-bezier(0.22, 0.61, 0.36, 1) var(--in, 0s) both; }
html.intro [data-intro="mid"] { animation-name: intro-mid; animation-duration: 1.15s; }
html.intro [data-intro="far"] { animation-name: intro-far; animation-duration: 1.6s; }
html.intro [data-intro="card"] { animation-name: intro-card; animation-duration: 1.1s; }
@keyframes intro-fade { from { opacity: 0; } }
@keyframes intro-near { from { opacity: 0; translate: 0 14px; filter: blur(3px); } }
@keyframes intro-mid  { from { opacity: 0; translate: 0 10px; filter: blur(8px); } }
@keyframes intro-far  { from { opacity: 0; scale: 1.035; filter: blur(10px); } }
@keyframes intro-card { from { opacity: 0; scale: 0.99; } }
.hero-title > span { display: block; }

/* ---------- Reveal on scroll ----------------------------------------- */

.js .reveal {
  opacity: 0;
  transform: translate3d(0, 24px, 0);
  transition: opacity 1.1s var(--ease), transform 1.1s var(--ease);
  transition-delay: var(--d, 0s);
}
.js .reveal.is-in { opacity: 1; transform: none; }

/* ---------- Responsive ----------------------------------------------- */

@media (max-width: 960px) {
  .hero-title { grid-column: 1 / span 9; }
  .loop { grid-column: 10 / span 3; }
  .hero-title { font-size: clamp(2.5rem, calc((100cqi - 9rem) / 13), 6rem); }
  .statement .two-tone { grid-column: 1 / -1; }
  .work-head .two-tone { grid-column: 1 / -1; }
  .work-head p { grid-column: 1 / span 8; margin-top: 1.5rem; }
  .work-head .rail-ctrl { grid-column: 9 / span 4; }
  .about-photo { grid-column: 1 / span 5; }
  .about-body { grid-column: 6 / span 7; padding-top: 0; }
  .kit .two-tone { grid-column: 1 / -1; }
  .kit-col:first-of-type, .kit-col:last-of-type { grid-column: span 6; }
  .chapter .label { grid-column: 1 / -1; margin-bottom: 1.5rem; }
  .chapter .body { grid-column: 1 / span 11; }
  .note-figure { grid-column: 1 / span 6; }
  .note-text { grid-column: 7 / span 6; }
}

@media (max-width: 720px) {
  .hero-top { row-gap: 1.25rem; }
  .hero-title { grid-column: 1 / -1; }
  .hero-sub { grid-column: 1 / -1; }
  .loop { grid-row: auto; grid-column: 1 / -1; justify-self: start; order: -1; width: 76px; border-radius: 12px; }
  .loop-btn { width: 28px; height: 28px; left: 6px; bottom: 6px; }
  .loop-label { display: none; }
  .hero-photo { height: 580px; }
  .hero-title, .case-title { font-size: clamp(2.5rem, 11cqi, 3.5rem); }
  .hero-stat { left: clamp(1.25rem, 0.5rem + 3vw, 3rem); right: auto; top: 4.5rem; text-align: left; }
  .hero-coords { left: clamp(1.25rem, 0.5rem + 3vw, 3rem); right: auto; bottom: auto; top: 11.25rem; }
  .weather-toggle .lbl { display: none; }
  .weather-toggle button { padding: 0.45rem 0.6rem; }
  .projects { grid-auto-columns: 78vw; padding-bottom: 1.5rem; margin-bottom: 0; }
  .project:nth-child(n) { margin-top: 0; }
  .work-head .rail-ctrl { display: none; }
  .about-photo, .about-body { grid-column: 1 / -1; }
  .about-body { margin-top: 2.5rem; }
  .stats { grid-template-columns: 1fr 1fr 1fr; }
  .viz { height: 2.2rem; }
  .notes-head .two-tone { grid-column: 1 / -1; }
  .notes-head .notes-ctrl { display: none; }
  .logbook { grid-auto-columns: 78vw; }
  .kit-col:first-of-type, .kit-col:last-of-type { grid-column: 1 / -1; }
  .kit-col + .kit-col { margin-top: 3rem; }
  .basecamp .two-tone, .mail, .socials { grid-column: 1 / -1; }
  .socials { justify-content: flex-start; margin-top: 2rem; }
  .summary { grid-template-columns: 1fr 1fr; }
  .chapter .body { grid-column: 1 / -1; }
  .results { grid-template-columns: 1fr; }
  .where-lbl { display: none; }
  .hide-sm { display: none; }
  .menu-btn .lbl, .theme-btn .lbl { display: none; }
  .head-actions { gap: 1.25rem; }
  .logo .tld { display: none; }
  .note-figure, .note-text { grid-column: 1 / -1; }
  .note-figure { max-height: 70vh; }
  .note-nav { flex-direction: column; }
  .note-nav button:last-child { align-self: flex-end; text-align: right; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
  .js .reveal { opacity: 1; transform: none; }
  html.menu-open body > :not(dialog) { filter: none; transform: none; }
  .map-svg .ring, .map-svg .trail-draw, .map-c, .map-ci { stroke-dashoffset: 0; }
  .map-pin, .map-view { opacity: 1; }
  .map-cone-axis { animation: none; }
  .viz-years rect { opacity: var(--o); }
  .viz-summits .sky { stroke-dashoffset: 0; }
  .viz-summits .peak, .viz-seasons .dawn, .viz-boots .step { opacity: 1; translate: 0 0; }
}
