/* celyrian.com styles. Colours, radii, motion and fonts come from tokens.css. */

/* Fonts */
@font-face {
  font-family: "Fredoka";
  src: url("/fonts/fredoka-var.6a3a3821.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
}
@font-face {
  font-family: "Zen Kaku Gothic New";
  src: url("/fonts/zen-regular.4e6a2358.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Zen Kaku Gothic New";
  src: url("/fonts/zen-medium.9d2cf4c5.woff2") format("woff2");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Zen Kaku Gothic New";
  src: url("/fonts/zen-bold.aa4182cd.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/jbm-regular.90b56724.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}

/* Site variables */
:root {
  --trail-2: rgb(255 255 255 / 0.22);
  --hi: rgb(255 255 255 / 0.07);
  --lift-shadow: 0 12px 34px rgb(0 0 0 / 0.6);
  --bar: 58px;
  --hint: 46px;
  --rim: 10px;
  --peek: 76px;
  --wrap-home: 1180px;
  --wrap-map: 780px;
  --wrap-meander: 1180px;
}
[data-theme="light"] {
  --trail-2: rgb(255 255 255 / 0.8);
  --hi: rgb(255 255 255 / 0.6);
  --lift-shadow: 0 12px 30px rgb(60 40 50 / 0.2);
}

/* Chapter colours: the dashboard's pastel order. Rose (--a4) is reserved for errors. */
:root {
  --coral: var(--a3);
  --apricot: var(--a2);
  --lemon: var(--note-lemon);
  --mint: var(--a5);
  --cyan-hue: var(--cyan);
  --sky: var(--blue);
  --lilac: color-mix(in srgb, var(--blue) 55%, var(--a4));
}
[data-theme="light"] {
  --lemon: #f1dc72;
  --cyan-hue: #8fcdc5;
  --sky: #93b8e6;
  --lilac: #c3b1e2;
}

[data-hue="coral"]   { --hue: var(--coral); }
[data-hue="apricot"] { --hue: var(--apricot); }
[data-hue="lemon"]   { --hue: var(--lemon); }
[data-hue="mint"]    { --hue: var(--mint); }
[data-hue="cyan"]    { --hue: var(--cyan-hue); }
[data-hue="sky"]     { --hue: var(--sky); }
[data-hue="lilac"]   { --hue: var(--lilac); }

/* Base */
* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

html { background: var(--paper); }
body {
  margin: 0;
  background: var(--paper) var(--pat-sprinkle) fixed;
  color: var(--ink);
  font-family: var(--f-ui);
  font-size: 1rem;
  line-height: 1.7;
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
}

.js body { padding-bottom: calc(var(--hint) + var(--rim)); }

/* The frame around the scrolling page: one fixed box whose spread shadow is the frame. */
body::after {
  content: "";
  position: fixed;
  inset: var(--bar) var(--rim) var(--rim);
  z-index: 9;
  border-radius: var(--r-panel);
  box-shadow: 0 0 0 100vmax var(--field), inset 0 2px 24px rgb(0 0 0 / 0.5);
  pointer-events: none;
}
[data-theme="light"] body::after { box-shadow: 0 0 0 100vmax var(--field), inset 0 2px 20px rgb(60 40 50 / 0.12); }

h1, h2 {
  font-family: var(--f-display);
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: 1.15;
  margin: 0;
}

p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
a { color: inherit; }
svg { display: block; }

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

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 20;
  padding: 12px 18px;
  background: var(--tile);
  border-radius: 0 0 var(--r-tile) 0;
}
.skip:focus { left: 0; }

/* Top bar */
.bar {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--bar);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding: 0 22px;
  background: var(--field);
}

.me {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 500;
  letter-spacing: 0.005em;
}

.ava {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  overflow: hidden;
  display: block;
  box-shadow: 0 0 0 2px var(--field), 0 0 0 3px var(--edge);
}
.ava img {
  display: block;
  width: 100%;
  height: 100%;
  transform: scale(1.22);
  transform-origin: 50% 46%;
}

.status {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 16px;
}

.here {
  justify-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  line-height: 1.2;
  text-align: center;
}
.clock {
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 1.2rem;
  line-height: 1.1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}
.tz {
  font-size: 0.6875rem;
  color: var(--ink-2);
  white-space: nowrap;
}
.tz-short { display: none; }

/* Theme toggle (shown only with JS) */
.pill {
  display: none;
  align-items: center;
  gap: 9px;
  border: 0;
  padding: 5px;
  background: none;
  color: var(--ink-2);
  font: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
  border-radius: var(--r-pill);
  transition: color var(--t) var(--out);
}
.js .pill { display: inline-flex; }
.pill:hover { color: var(--ink); }
.pill-track {
  width: 40px;
  height: 23px;
  border-radius: var(--r-pill);
  background: var(--tile-hi);
  border: 1px solid var(--rule);
  padding: 2px;
  display: block;
  transition: background var(--t) var(--out);
}
.pill-knob {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: var(--ink-2);
  display: block;
  transition: transform var(--t) var(--pop), background var(--t) var(--out);
}
.pill[aria-pressed="true"] .pill-track { background: var(--a1); border-color: var(--a1); }
.pill[aria-pressed="true"] .pill-knob {
  transform: translateX(17px);
  background: var(--on-accent);
}
.pill:active .pill-knob { transform: scale(0.9); }
.pill[aria-pressed="true"]:active .pill-knob { transform: translateX(17px) scale(0.9); }

/* Keyboard hint bar (shown only with JS, hidden on touch screens) */
.hints {
  display: none;
  position: fixed;
  right: 60px;
  bottom: 0;
  z-index: 10;
  height: var(--hint);
  align-items: center;
  gap: 24px;
  padding: 2px 22px 0;
  background: var(--field);
  border-radius: var(--r-panel) var(--r-panel) 0 0;
  color: var(--ink-2);
  font-size: 0.8125rem;
}
.hints::before,
.hints::after {
  content: "";
  position: absolute;
  bottom: var(--rim);
  width: var(--r-panel);
  height: var(--r-panel);
  pointer-events: none;
}
.hints::before {
  right: 100%;
  background: radial-gradient(circle at 0 0, transparent calc(var(--r-panel) - 0.5px), var(--field) var(--r-panel));
}
.hints::after {
  left: 100%;
  background: radial-gradient(circle at 100% 0, transparent calc(var(--r-panel) - 0.5px), var(--field) var(--r-panel));
}
.js .hints { display: flex; }
.hints span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.key {
  border: 0;
  padding: 0;
  margin: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  border-radius: 13px;
  -webkit-tap-highlight-color: transparent;
}
.key:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
kbd {
  font-family: var(--f-mono);
  font-size: 0.6875rem;
  min-width: 26px;
  height: 26px;
  padding: 0 9px;
  display: inline-grid;
  place-items: center;
  border-radius: 13px;
  background: var(--tile-hi);
  color: var(--ink);
  line-height: 1;
  border: 1px solid var(--rule);
  box-shadow: 0 2px 0 var(--drop);
  transition: transform var(--t-fast) var(--out), box-shadow var(--t-fast) var(--out), background var(--t) var(--out), border-color var(--t) var(--out);
}
.key:hover kbd { background: var(--rule); border-color: var(--edge); }
.key:active kbd { transform: translateY(2px); box-shadow: 0 0 0 var(--drop); }
.hints span .key + .key { margin-left: 3px; }

/* Home screen */
.home {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 30px;
  max-width: var(--wrap-home);
  margin: 0 auto;
  padding: 40px 22px 34px;
}

.deck {
  display: flex;
  flex-direction: column;
  gap: 30px;
  min-width: 0;
}

/* Selected chapter title above the tile row; JS sets --plate-h to the tallest text. */
.plate {
  display: none;
  min-height: var(--plate-h, 96px);
  max-width: 62ch;
  padding-left: 2px;
  --dir: 1;
  transition: opacity 0.09s var(--out), transform 0.09s var(--out);
}
.js .plate { display: block; }

.intro {
  display: none;
  padding-left: 2px;
  font-family: var(--f-display);
  font-weight: 500;
  font-size: 1.25rem;
  line-height: 1.3;
  color: var(--ink);
  max-width: 24ch;
}
.intro-kick {
  display: block;
  margin-bottom: 4px;
  font-family: var(--f-mono);
  font-weight: 400;
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
}

.row-kicker {
  font-family: var(--f-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-2);
  margin-bottom: 2px;
}
.row-title {
  font-family: var(--f-display);
  font-weight: 500;
  font-size: 1.55rem;
  line-height: 1.25;
  color: var(--ink);
}
.row-teaser {
  margin-top: 3px;
  color: var(--ink-2);
  font-size: 0.9375rem;
  line-height: 1.6;
}

.plate.out {
  opacity: 0;
  transform: translateX(calc(var(--dir) * -8px));
}
.plate.in { animation: plate-in 0.32s var(--pop) both; }
.plate.in .row-teaser { animation: plate-in 0.32s var(--pop) 0.05s both; }
.plate.dir-l { --dir: -1; }
@keyframes plate-in {
  from { opacity: 0; transform: translateX(calc(var(--dir) * 12px)); }
  to   { opacity: 1; transform: none; }
}

/* Tile row: a horizontal scroller below 900px. The padding leaves room for the
   focus ring and shadow, which a scroller would otherwise clip. */
.row {
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  min-width: 0;
  margin: -16px -22px -26px;
  padding: 30px 0 42px;
  scroll-snap-type: x proximity;
  scroll-padding-inline: 22px;
}
.row::-webkit-scrollbar { display: none; }
.row li { scroll-snap-align: start; }
.row ul {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 122px;
  gap: 15px;
  align-items: start;
  width: max-content;
  padding: 0 22px;
}

.row a {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 9px;
  text-decoration: none;
  color: var(--ink-2);
  font-size: 0.8125rem;
  -webkit-tap-highlight-color: transparent;
}

/* Tile transform is built from custom properties; JS sets the tilt (--rx, --ry). */
.row a .tile {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--r-tile);
  overflow: hidden;
  display: grid;
  place-items: center;
  --rx: 0deg;
  --ry: 0deg;
  --s: 1;
  --ty: 0px;
  --mx: 50%;
  --my: 40%;
  background: var(--hue);
  box-shadow: var(--drop-chip);
  transform:
    perspective(720px)
    rotateX(var(--rx))
    rotateY(var(--ry))
    translateY(var(--ty))
    scale(var(--s));
  transition:
    transform var(--t) var(--pop),
    box-shadow var(--t) var(--out);
}

.row a.tilt .tile { transition-duration: 0.09s; transition-timing-function: var(--out); }

.row a .tile .n {
  position: absolute;
  top: 8px;
  left: 11px;
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1;
  color: var(--on-accent);
  letter-spacing: -0.01em;
}

.row a .tile .art {
  width: 56%;
  height: 56%;
  fill: var(--on-accent);
  overflow: visible;
  transition: transform var(--t) var(--pop);
}

/* Light sweep when a tile becomes selected */
.row a .tile::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(105deg, transparent 32%, var(--hi) 46%, rgb(255 255 255 / 0.18) 50%, var(--hi) 54%, transparent 68%);
  transform: translateX(-110%);
}
.row a.is-on .tile::before { animation: sweep 0.6s var(--out) 1; }
@keyframes sweep {
  0%   { opacity: 1; transform: translateX(-110%); }
  100% { opacity: 1; transform: translateX(110%); }
}

.row a:hover .tile { --ty: var(--hover-lift); box-shadow: var(--drop-hover); }
.row a:hover .tile .art { transform: scale(1.06); }

/* Selected tile: .is-on is set by JS */
.row a.is-on .tile,
.row a:focus-visible .tile {
  --s: var(--select-scale);
  box-shadow: 0 0 0 3px var(--paper), 0 0 0 6px var(--ink);
  animation: ring var(--t-breathe) ease-in-out infinite;
}

@keyframes ring {
  50% {
    box-shadow:
      0 0 0 3px var(--paper),
      0 0 0 6px var(--a1),
      0 0 14px 6px color-mix(in srgb, var(--a1) 34%, transparent);
  }
}
.row a:focus-visible { outline: none; }
.row a.is-on, .row a:focus-visible, .row a.launch { z-index: 1; }

.row a:active .tile { --s: var(--press-scale); --ty: 1px; box-shadow: var(--drop-press); transition-duration: var(--t-fast); }
.row a.launch .tile { --s: 1.2; transition-duration: 0.24s; }

/* Chapter in progress */
.row a[data-state="now"] .tile::after {
  content: "";
  position: absolute;
  top: 10px;
  right: 10px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--on-accent);
  box-shadow: 0 0 0 3px var(--hue);
  animation: pip 2.4s ease-in-out infinite;
}
@keyframes pip {
  50% { box-shadow: 0 0 0 3px var(--hue), 0 0 0 6px color-mix(in srgb, var(--on-accent) 35%, transparent); }
}

/* Visually hidden. With JS the captions move into the title plate. */
.vh,
.js .cap {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Contact links */
.apps ul {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 22px;
}
.apps a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 72px;
  padding: 4px 2px;
  color: var(--ink-2);
  text-decoration: none;
  font-size: 0.75rem;
  line-height: 1.2;
  -webkit-tap-highlight-color: transparent;
}
.apps a:focus-visible { outline: none; }
.orb {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--tile);
  border: var(--edge-chip) solid var(--edge);
  color: var(--ink);
  box-shadow: var(--drop-chip);
  transition:
    transform var(--t) var(--pop),
    color var(--t) var(--out),
    border-color var(--t) var(--out),
    box-shadow var(--t) var(--out);
}
.orb svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
  overflow: visible;
}
:where(.apps a) { --hue: var(--a1); }
.apps a:hover .orb,
.apps a:focus-visible .orb {
  transform: translateY(var(--hover-lift));
  border-color: var(--hue);
  color: var(--hue);
  box-shadow: var(--drop-hover);
}
.apps a:focus-visible .orb { box-shadow: var(--drop-hover), 0 0 0 3px var(--paper), 0 0 0 6px var(--focus); }
.apps a:hover,
.apps a:focus-visible { color: var(--ink); }
.apps a:active .orb { transform: translateY(1px) scale(var(--press-scale)); box-shadow: var(--drop-press); transition-duration: var(--t-fast); }

/* Map */
.map {
  position: relative;
  margin: 0 22px;
  padding: 58px 22px 64px;
  background: var(--plaque);
  color: var(--ink);
  border-radius: 30px;
  box-shadow: var(--soft-shadow);
  --hue: var(--a3);
}
.defs { position: absolute; }

/* Route: JS draws it and adds .routed; without JS, .ch::before draws dotted beads. */
.route {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.route path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.route .road { stroke: var(--trail); stroke-width: 14px; opacity: 0.14; }
.route .beads { stroke: var(--trail); stroke-width: 5px; stroke-dasharray: 0 13; }
.route .beads.lit { stroke: var(--trail-2); stroke-width: 2px; }

/* Title card */
.title {
  position: relative;
  max-width: var(--wrap-map);
  margin: 0 auto;
  padding-bottom: 74px;
  display: grid;
  grid-template-columns: 46px 1fr;
}
.title-card {
  grid-column: 1 / -1;
  justify-self: center;
  position: relative;
  text-align: center;
  padding: 30px 48px 32px;
  background: var(--tile);
  border-radius: var(--r-panel);
  box-shadow: var(--soft-shadow);
}

.title-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 64px;
  height: 6px;
  transform: translateX(-50%);
  background: var(--a3);
  border-radius: 0 0 5px 5px;
}
.title h1 {
  font-size: clamp(2.3rem, 1.7rem + 2.4vw, 3.5rem);
  letter-spacing: -0.012em;
}
.title p {
  margin-top: 6px;
  color: var(--plaque-ink-2);
  font-size: clamp(1rem, 0.92rem + 0.4vw, 1.2rem);
  font-weight: 500;
}

/* Fallback route without JS */
.ch::before,
.title::before {
  content: "";
  position: absolute;
  left: 23px;
  top: 50px;
  bottom: 0;
  width: 28px;
  transform: translateX(-50%);
  --bead: var(--trail-2) 0, var(--trail) 1.7px, var(--trail) 3.7px, transparent 4.7px;
  background-image:
    radial-gradient(circle at 14px 9px, var(--bead)),
    radial-gradient(circle at 18.3px 27px, var(--bead)),
    radial-gradient(circle at 18.3px 45px, var(--bead)),
    radial-gradient(circle at 14px 63px, var(--bead)),
    radial-gradient(circle at 9.7px 81px, var(--bead)),
    radial-gradient(circle at 9.7px 99px, var(--bead));
  background-size: 28px 108px;
  background-repeat: repeat-y;
}
.title::before {
  top: auto;
  height: 66px;
}

.ch[data-state="now"]::before {
  opacity: 0.3;
  mask-image: linear-gradient(to bottom, #000 40%, transparent);
  -webkit-mask-image: linear-gradient(to bottom, #000 40%, transparent);
}
.routed .ch::before,
.routed .title::before { display: none; }

/* Chapters */
.ch {
  position: relative;
  max-width: var(--wrap-map);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 46px 1fr;
  gap: 0 24px;
  padding-bottom: 54px;
  scroll-margin-top: calc(var(--bar) + 24px);
}

.node {
  grid-column: 1;
  grid-row: 1;
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--tile);
  border: 3px solid var(--edge);
  display: grid;
  place-items: center;
  z-index: 1;
  box-shadow: var(--drop-chip);
  transition:
    transform var(--t) var(--pop),
    border-color var(--t) var(--out),
    box-shadow var(--t) var(--out);
}
.ch[data-state="clear"] .node { border-color: var(--hue); }

.node, .plaque { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.ch:hover .node,
.ch:focus-within .node { transform: scale(1.1); }

.ch:focus, .ch:focus-visible { outline: none; }

.num {
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 1.2rem;
  color: var(--ink);
}

.ch[data-state="now"] .node {
  border-color: var(--hue);
  box-shadow:
    var(--drop-chip),
    0 0 0 4px var(--plaque),
    0 0 0 7px var(--hue),
    0 0 0 7px transparent;
  animation: here 2.4s ease-in-out infinite;
}
@keyframes here {
  50% {
    box-shadow:
      var(--drop-chip),
      0 0 0 4px var(--plaque),
      0 0 0 8px var(--hue),
      0 0 20px 8px color-mix(in srgb, var(--hue) 32%, transparent);
  }
}

/* Pennant on finished chapters */
.pin {
  position: absolute;
  right: 52%;
  top: -25px;
  width: 30px;
  height: 34px;
  transform-origin: 50% 96%;
}
.flag {
  width: 30px;
  height: 34px;
  overflow: visible;
  transform: scaleX(-1);
  transform-origin: 50% 96%;
  animation: wave 3.6s ease-in-out infinite;
  color: var(--hue);
  --fsh: var(--drop);
  --fpole: var(--edge);
}
@keyframes wave {
  0%, 100% { rotate: 0deg; }
  50%      { rotate: -4deg; }
}

.ch:hover .flag,
.ch:focus-within .flag {
  animation: wave 3.6s ease-in-out infinite, flutter 0.6s var(--out) 1;
}
@keyframes flutter {
  0%   { rotate: 0deg; }
  30%  { rotate: -13deg; }
  65%  { rotate: 6deg; }
  100% { rotate: 0deg; }
}

/* Chapter card. --tilt and --lift keep hover rules from restating the transform. */
.plaque {
  grid-column: 2;
  grid-row: 1;
  position: relative;
  background: var(--tile);
  border-radius: var(--r-panel);
  padding: 26px 28px 26px;
  box-shadow: var(--soft-shadow);
  --tilt: -0.9deg;
  --lift: 0px;
  transform: rotate(var(--tilt)) translateY(var(--lift));
  transition:
    transform var(--t) var(--pop),
    box-shadow var(--t) var(--out);
}

.plaque::before {
  content: "";
  position: absolute;
  top: 0;
  left: 28px;
  width: 48px;
  height: 6px;
  background: var(--hue);
  border-radius: 0 0 5px 5px;
  transition: width var(--t) var(--pop);
}
.ch:nth-of-type(even) .plaque { --tilt: 0.9deg; }

.plaque::after {
  content: "";
  position: absolute;
  top: 14px;
  left: -13px;
  width: 14px;
  height: 24px;
  background: var(--tile);
  clip-path: polygon(100% 0, 0 50%, 100% 100%);
}

.ch .plaque:hover,
.ch:focus-within .plaque {
  --tilt: 0deg;
  --lift: -4px;
  box-shadow: var(--lift-shadow);
}
.ch .plaque:hover::before,
.ch:focus-within .plaque::before { width: 76px; }
.ch .plaque:active {
  --lift: -1px;
  box-shadow: var(--soft-shadow);
  transition-duration: var(--t-fast);
}

.plaque :is(h1, h2) {
  font-size: clamp(1.4rem, 1.15rem + 1.1vw, 1.95rem);
  margin-bottom: 12px;
}
.plaque p {
  color: var(--ink);
  max-width: 62ch;
}
.now {
  display: inline-block;
  vertical-align: 0.35em;
  margin-left: 8px;
  padding: 2px 9px;
  border-radius: var(--r-pill);
  background: var(--hue);
  color: var(--on-accent);
  font-family: var(--f-ui);
  font-weight: 700;
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.5;
}

/* Reveal on scroll: JS adds .rv below the fold and swaps it for .pop in view. */
.js .rv .plaque,
.js .rv .title-card,
.js .rv .mile,
.js .rv .deco,
.js .rv.close > * { opacity: 0; }
.js .rv .pin { scale: 0; }
.pop .plaque { animation: plaque-in 0.6s var(--pop) backwards; }
.pop .title-card { animation: card-in 0.6s var(--pop) backwards; }
.pop .mile { animation: card-in 0.5s var(--pop) 0.2s backwards; }
.pop .deco { animation: card-in 0.8s var(--out) 0.15s backwards; }
.pop.close > * { animation: card-in 0.55s var(--pop) backwards; }
.pop .pin { animation: plant 0.5s var(--pop) 0.28s backwards; }
.pop .node { animation: node-in 0.5s var(--pop) backwards; }
@keyframes plaque-in {
  from { opacity: 0; transform: rotate(var(--tilt)) translateY(22px) scale(0.94); }
  to   { opacity: 1; transform: rotate(var(--tilt)) translateY(var(--lift)); }
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(18px) scale(0.96); }
  to   { opacity: 1; transform: none; }
}
@keyframes node-in {
  from { transform: scale(0.6); }
  to   { transform: scale(1); }
}
@keyframes plant {
  from { scale: 0; }
  to   { scale: 1; }
}

/* Link chips */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}
.chips li { display: flex; }
.chips a {
  --hue-line: var(--hue);
  --out-arrow: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12 12 4M6 4h6v6'/%3E%3C/svg%3E");
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px 5px 14px;
  border: var(--edge-chip) solid var(--edge);
  border-radius: var(--r-pill);
  background: var(--plaque);
  box-shadow: var(--drop-chip);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform var(--t) var(--pop),
    border-color var(--t) var(--out),
    box-shadow var(--t) var(--out);
}
.chips a::after {
  content: "";
  flex: none;
  width: 10px;
  height: 10px;
  background: var(--hue-line);
  -webkit-mask: var(--out-arrow) center / contain no-repeat;
  mask: var(--out-arrow) center / contain no-repeat;
  transition: transform var(--t) var(--pop);
}
@media (hover: hover) {
  .chips a:hover {
    transform: translateY(var(--hover-lift));
    border-color: var(--hue-line);
    box-shadow: var(--drop-hover);
  }
  .chips a:hover::after { transform: translate(1px, -1px); }
}
.chips a:focus-visible {
  outline: none;
  border-color: var(--hue-line);
  box-shadow: var(--drop-hover), 0 0 0 3px var(--paper), 0 0 0 6px var(--focus);
}
.chips a:active { transform: translateY(1px) scale(var(--press-scale)); box-shadow: var(--drop-press); transition-duration: var(--t-fast); }
[data-theme="light"] .chips a { --hue-line: color-mix(in srgb, var(--hue) 55%, var(--ink)); }

@media (pointer: coarse) {
  .chips { gap: 10px; }
  .chips a { padding: 8px 14px 8px 16px; }
}

/* Milestones. JS sets --bx to place the badge on the route. */
.mile {
  grid-column: 1 / -1;
  grid-row: 2;
  justify-self: start;
  position: relative;
  z-index: 1;
  left: var(--bx, 0px);
  margin: 14px 0 0 13px;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 3px 13px 3px 3px;
  border: var(--edge-chip) solid var(--edge);
  border-radius: var(--r-pill);
  background: var(--tile);
  box-shadow: var(--drop-chip);
  color: var(--plaque-ink-2);
  font-family: var(--f-mono);
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1;
  white-space: nowrap;
  transition:
    transform var(--t) var(--pop),
    border-color var(--t) var(--out),
    box-shadow var(--t) var(--out),
    color var(--t) var(--out);
}
.mile:hover {
  transform: translateY(var(--hover-lift));
  border-color: var(--hue);
  box-shadow: var(--drop-hover);
  color: var(--ink);
}
.badge {
  flex: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--plaque);
  border: var(--edge-chip) solid var(--edge);
  color: inherit;
  transition: border-color var(--t) var(--out);
}
.badge svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  overflow: visible;
}
.mile:hover .badge { border-color: var(--hue); }

/* Scenery beside the route (wide screens only) */
.deco {
  display: none;
  grid-row: 1;
  align-self: stretch;
  position: relative;
  pointer-events: none;
  color: var(--trail);
}
.deco li {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: var(--s);
  height: var(--s);
  rotate: var(--r);
}
.deco svg { width: 100%; height: 100%; fill: currentColor; overflow: visible; }
.deco .s1 { --x: 6%;  --y: 6%;  --s: 38px; --r: -8deg; }
.deco .s2 { --x: 38%; --y: 3%;  --s: 28px; --r: 10deg; }
.deco .s3 { --x: 12%; --y: 44%; --s: 52px; --r: 5deg; }
.deco .s4 { --x: 32%; --y: 72%; --s: 34px; --r: -12deg; }
.deco .s5 { --x: 60%; --y: 86%; --s: 26px; --r: 8deg; }
.deco .s6 { --x: 66%; --y: 10%; --s: 30px; --r: -5deg; }
.deco .s7 { --x: 24%; --y: 22%; --s: 24px; --r: 14deg; }
.deco .s8 { --x: 48%; --y: 48%; --s: 36px; --r: -16deg; }

/* Hardware notes */
.notes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 24px;
  padding: 2px 4px 6px 2px;
}
.note {
  position: relative;
  padding: 17px 18px 15px;
  background: color-mix(in srgb, var(--plaque) 94%, var(--h));
  border: var(--edge-chip) solid color-mix(in srgb, var(--edge) 65%, var(--h));
  border-radius: var(--r-note);
  box-shadow: var(--drop-chip);
  --r: 0deg;
  transform: rotate(var(--r));
  transition: transform var(--t) var(--pop), box-shadow var(--t) var(--out);
}
.note::before {
  content: "";
  position: absolute;
  left: 10px;
  right: 26px;
  top: 3px;
  height: 4px;
  border-radius: 2px;
  background: var(--h);
}

.note::after {
  content: "";
  position: absolute;
  right: -2px;
  top: -2px;
  width: 16px;
  height: 16px;
  background: linear-gradient(225deg, var(--tile) 50%, var(--h) 50%);
  border-bottom-left-radius: 3px;
}
.note[data-note="lemon"] { --h: var(--note-lemon); --r: -1deg; }
.note[data-note="green"] { --h: var(--note-green); --r: 0.8deg; }
.note[data-note="sky"]   { --h: var(--note-sky);   --r: -0.6deg; }
.note:hover {
  transform: rotate(0deg) translateY(var(--hover-lift));
  box-shadow: var(--drop-hover);
  z-index: 1;
}
.note .where {
  color: var(--h);
  font-family: var(--f-ui);
  font-weight: 700;
  font-size: 0.6875rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1.4;
  margin: 2px 0 3px;
}
.note h3 {
  font-family: var(--f-display);
  font-weight: 600;
  font-size: 1.1rem;
  line-height: 1.2;
  letter-spacing: -0.005em;
  margin: 0 0 8px;
  color: var(--ink);
}
.note ul {
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--plaque-ink-2);
}
.note ul li {
  position: relative;
  padding-left: 14px;
}

[data-theme="light"] .note { --h-ink: color-mix(in srgb, var(--h) 35%, var(--ink)); }
[data-theme="light"] .note .where { color: var(--h-ink); }
[data-theme="light"] .note ul li::before { background: var(--h-ink); opacity: 0.5; }
.note ul li::before {
  content: "";
  position: absolute;
  left: 1px;
  top: 0.62em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--h);
  opacity: 0.8;
}

/* Closing section and footer */
.close {
  max-width: var(--wrap-map);
  margin: 0 auto;
  scroll-margin-top: calc(var(--bar) + 24px);
  padding: 14px 0 0 70px;
}
.close h2 {
  font-size: clamp(1.7rem, 1.25rem + 1.7vw, 2.4rem);
  margin-bottom: 14px;
}
.close p, .close blockquote { max-width: 62ch; }
.close blockquote {
  margin: 30px 0 0;
  padding: 4px 0 4px 22px;
  border-left: 5px solid var(--a3);
  font-family: var(--f-display);
  font-weight: 400;
  font-size: clamp(1.05rem, 0.95rem + 0.5vw, 1.32rem);
  line-height: 1.55;
}
.close .chips { margin-top: 18px; }

.foot {
  max-width: var(--wrap-meander);
  margin: 44px auto 0;
  padding: 0 22px 44px;
  color: var(--ink-2);
  font-size: 0.8125rem;
  line-height: 1.65;
  text-align: center;
}
.foot b { color: var(--ink); }
.foot p { max-width: 62ch; margin: 0 auto; }

/* Wide: full tile row, chapters alternate sides of the route.
   JS sets --sx to shift each row onto the route's wave. */
@media (min-width: 900px) {
  .home { min-height: calc(100svh - var(--bar) - var(--peek)); }
  .deck { width: fit-content; max-width: 100%; margin-inline: auto; }

  .row { overflow: visible; scroll-snap-type: none; margin: 0; padding: 14px 0 16px; }
  .row ul {
    grid-auto-flow: row;
    grid-template-columns: repeat(7, minmax(0, 122px));
    width: auto;
    padding: 0;
  }

  .ch, .title {
    max-width: var(--wrap-meander);
    grid-template-columns: 1fr 46px 1fr;
    gap: 0 32px;
  }
  .ch::before, .title::before { left: 50%; }
  .node { grid-column: 2; }
  .plaque { grid-column: 3; }
  .ch:nth-of-type(even) .plaque { grid-column: 1; }

  .pin { right: 100%; top: -21px; margin-right: 3px; }
  .ch:nth-of-type(even) .pin {
    right: auto;
    left: 100%;
    margin: 0 0 0 3px;
  }
  .ch:nth-of-type(even) .flag { transform: none; }

  .ch { --gap: 32px; left: var(--sx, 0px); }
  .close { position: relative; left: var(--sx, 0px); }
  .mile {
    grid-row: 1;
    align-self: center;
    margin: 0;
  }
  .ch:nth-of-type(odd) .mile {
    grid-column: 1;
    justify-self: end;
    flex-direction: row-reverse;
    padding: 3px 3px 3px 13px;
    margin-right: calc(-43px - var(--gap));
  }
  .ch:nth-of-type(even) .mile {
    grid-column: 3;
    justify-self: start;
    margin-left: calc(-43px - var(--gap));
  }
  .deco { display: block; grid-column: 1; }
  .ch:nth-of-type(even) .deco { grid-column: 3; }
  .ch:nth-of-type(even) .deco li { left: auto; right: var(--x); }
  .ch:nth-of-type(even) .plaque::after {
    left: auto;
    right: -14px;
    clip-path: polygon(0 0, 100% 50%, 0 100%);
  }

  .close {
    max-width: var(--wrap-meander);
    display: grid;
    grid-template-columns: 1fr 46px 1fr;
    gap: 0 32px;
    padding-left: 0;
  }
  .close > * { grid-column: 3; }
}

/* Large screens */
@media (min-width: 1600px) {
  :root {
    --wrap-home: 1420px;
    --wrap-meander: 1420px;
    --bar: 64px;
  }
  .row ul { grid-template-columns: repeat(7, minmax(0, 142px)); gap: 18px; }
  .row a .tile .n { font-size: 1.1rem; top: 10px; left: 13px; }
  .row-title { font-size: 1.7rem; }
  .row-teaser { font-size: 1rem; }
  .orb { width: 58px; height: 58px; }
  .ch, .title, .close { gap: 0 44px; }
  .ch { --gap: 44px; }
  .plaque { padding: 28px 32px; }
  .map { margin: 0 24px; }
}

@media (min-width: 2200px) {
  :root {
    --wrap-home: 1700px;
    --wrap-meander: 1640px;
  }
  .row ul { grid-template-columns: repeat(7, minmax(0, 164px)); gap: 22px; }
  .row a .tile .n { font-size: 1.2rem; }
  .row-title { font-size: 1.9rem; }
  .row-teaser { font-size: 1.0625rem; }
  .plaque { padding: 32px 36px; }
  .map { margin: 0 32px; }
}

/* Narrow: room under the title card for the route to bend into the node column */
@media (max-width: 899px) {
  .title { padding-bottom: 104px; }
  .title::before { height: 96px; }
}

/* Phones: tile grid with captions, map in one centred column, no hint bar */
@media (max-width: 720px) {
  .home { gap: 22px; padding: 22px 20px 30px; }
  .deck { gap: 18px; }
  .intro { display: block; }
  .js .plate { display: none; }

  .row { overflow: visible; margin: 0; padding: 0; scroll-snap-type: none; }
  .row ul {
    grid-auto-flow: row;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-columns: auto;
    gap: 16px 12px;
    width: auto;
    padding: 0;
  }
  .row li { scroll-snap-align: none; }
  .row a { gap: 7px; font-size: 0.75rem; }
  .row a .tile { border-radius: 12px; }
  .row a .tile .n { font-size: 0.8rem; top: 6px; left: 8px; }
  .row a[data-state="now"] .tile::after { top: 7px; right: 7px; width: 8px; height: 8px; }

  .cap, .js .cap {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip-path: none;
    white-space: normal;
    text-align: center;
    line-height: 1.25;
    color: var(--ink-2);
  }
  .row a.is-on .cap { color: var(--ink); }
  .row a.is-on .tile, .row a:focus-visible .tile { --s: 1.05; }

  .apps ul { gap: 6px 4px; }
  .apps a { min-width: 60px; max-width: 76px; padding: 4px 0; font-size: 0.7rem; }
  .lbl { white-space: normal; text-align: center; line-height: 1.2; }
  .orb { width: 50px; height: 50px; }
  .orb svg { width: 24px; height: 24px; }

  .bar { padding: 0 20px; gap: 10px; }

  :root { --rim: 0px; }
  body::after { border-radius: var(--r-panel) var(--r-panel) 0 0; }
  .clock { font-size: 1.05rem; }
  .tz-long { display: none; }
  .tz-short { display: inline; }

  .js .hints { display: none; }
  .js body { padding-bottom: 0; }

  .map {
    margin: 0 8px;
    padding: 34px 14px 40px;
    border-radius: 20px;
  }
  .title { grid-template-columns: 1fr; padding-bottom: 60px; }
  .title-card { padding: 22px 22px 22px; }
  .ch { grid-template-columns: 1fr; gap: 0; padding-bottom: 42px; justify-items: center; }
  .ch::before, .title::before {
    left: 50%;
    width: 20px;
    --bead: var(--trail-2) 0, var(--trail) 1.5px, var(--trail) 3.2px, transparent 4.2px;
    background-image:
      radial-gradient(circle at 10px 8px, var(--bead)),
      radial-gradient(circle at 13px 24px, var(--bead)),
      radial-gradient(circle at 13px 40px, var(--bead)),
      radial-gradient(circle at 10px 56px, var(--bead)),
      radial-gradient(circle at 7px 72px, var(--bead)),
      radial-gradient(circle at 7px 88px, var(--bead));
    background-size: 20px 96px;
  }
  .title::before { height: 54px; }
  .ch::before { top: 44px; }
  .node { grid-column: 1; grid-row: 1; justify-self: center; width: 44px; height: 44px; border-width: 3px; }
  .num { font-size: 1.1rem; }

  .pin { right: 100%; top: -13px; margin-right: 1px; width: 26px; height: 30px; }
  .ch:nth-of-type(even) .pin { right: auto; left: 100%; margin: 0 0 0 1px; }
  .ch:nth-of-type(even) .flag { transform: none; }
  .flag { width: 26px; height: 30px; }
  .plaque {
    grid-column: 1;
    grid-row: 2;
    width: 100%;
    margin-top: 16px;
    padding: 22px 20px 22px;
    --tilt: 0deg;
  }
  .ch:nth-of-type(even) .plaque { --tilt: 0deg; }

  .plaque::after {
    top: -12px;
    left: 50%;
    margin-left: -12px;
    width: 24px;
    height: 12px;
    clip-path: polygon(50% 0, 0 100%, 100% 100%);
  }

  .mile {
    grid-column: 1;
    grid-row: 3;
    left: 0;
    margin: 16px 0 0;
    max-width: calc(50% + 51px);
    white-space: normal;
    text-wrap: balance;
    line-height: 1.3;
    text-align: left;
  }
  .ch:nth-of-type(odd) .mile { justify-self: start; margin-left: calc(50% - 55px); }
  .ch:nth-of-type(even) .mile {
    justify-self: end;
    margin-right: calc(50% - 55px);
    flex-direction: row-reverse;
    padding: 3px 3px 3px 13px;
    text-align: right;
  }
  .badge { width: 28px; height: 28px; }
  .badge svg { width: 15px; height: 15px; }
  .notes { grid-template-columns: 1fr; gap: 18px; margin-top: 22px; }
  .note { padding: 16px 16px 14px; --r: 0deg; }
  .close { padding: 6px 4px 0; }
  .foot { margin-top: 36px; padding: 0 20px 40px; }
}

@media (hover: none) and (pointer: coarse) {
  .js .hints { display: none; }
  .js body { padding-bottom: var(--rim); }
}

/* Reduced motion: keep state changes visible, drop the movement. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation: none !important;
  }

  .row a:hover .tile,
  .row a:active .tile,
  .row a.launch .tile { --ty: 0px; --s: 1; }
  .row a.is-on .tile,
  .row a:focus-visible .tile { --s: 1; }
  .row a:hover .tile .art { transform: none; }
  .apps a:hover .orb, .apps a:focus-visible .orb, .apps a:active .orb { transform: none; }
  .plaque, .ch .plaque:hover, .ch:focus-within .plaque { --tilt: 0deg; --lift: 0px; }
  .chips a:hover, .chips a:active { transform: none; }
  .mile:hover { transform: none; }
  .note, .note:hover { transform: none; }
  .ch:hover .node, .ch:focus-within .node { transform: none; }
  .plate.out { opacity: 1; transform: none; }

  .js .rv .plaque, .js .rv .title-card, .js .rv .mile, .js .rv .deco, .js .rv.close > * { opacity: 1; }
  .js .rv .pin { scale: 1; }
}

/* Print */
@media print {
  .bar, .home, .hints, body::after { display: none; }
  .js body { padding-bottom: 0; }
  .map { background: none; padding: 0; margin: 0; box-shadow: none; }
  .plaque, .title-card, .note, .mile { box-shadow: none; transform: none; }
  .route { display: none; }
  .js .rv .plaque, .js .rv .title-card, .js .rv .mile, .js .rv .deco, .js .rv.close > * { opacity: 1; }
  .js .rv .pin { scale: 1; }
}

/* 404 page */
.lost { margin-top: 40px; min-height: 50vh; }
.lost .ch { padding-top: 10px; }
.lost .ch::before {
  top: auto;
  bottom: 0;
  height: 120px;
  opacity: 0.3;
  mask-image: linear-gradient(to bottom, #000, transparent);
  -webkit-mask-image: linear-gradient(to bottom, #000, transparent);
}
.lost .node { border-style: dashed; }
