/* ---------- tokens ---------- */
@font-face { font-family:"Inter"; font-style:normal; font-weight:100 900; font-display:swap;
  src:url("/_vendor/inter/inter-latin-wght-normal.woff2") format("woff2"); }   /* self-hosted (D-15) */
:root { --paper:#f6f4ef; --ink:#2b2b2b; }          /* tools/build.mjs checks line colours against both papers */
@media (prefers-color-scheme: dark) { :root { --paper:#1c1c1e; --ink:#e8e8e8; } }
html, body { margin:0; height:100%; background:var(--paper); color:var(--ink);
  font-family: Inter, "Helvetica Neue", Helvetica, Arial, sans-serif; }
.visually-hidden { position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; }
.skip { position:fixed; left:1rem; top:-3rem; z-index:10; padding:.45rem .8rem; border-radius:999px;
  background:var(--ink); color:var(--paper); font-size:.8rem; font-weight:600; }
.skip:focus { top:1rem; }                            /* appears only for keyboard users (A11Y-09) */
.boot-failure { margin:1rem; font-weight:600; }
.boot-failure ~ :is(#map, #key, .journey, #minimap, .skip) { display:none; }

/* ---------- map ---------- */
/* dvh: the height actually visible on iOS, where 100vh hides behind the address bar (R-42) */
#map { display:block; width:100vw; height:100vh; height:100dvh; touch-action:none; cursor:grab; }
.edge  { fill:none; stroke-width:8; stroke-linecap:round; transition:stroke-width .15s, filter .15s; }
.bridge path { fill:none; stroke-linecap:butt; transition:stroke-width .15s, filter .15s; }
.bridge .casing { stroke:var(--paper); stroke-width:16; }  /* cuts a gap in the line below */
.bridge .deck   { stroke:currentColor; stroke-width:8; }
/* Hovering a line marks the whole line: wider, and a deeper shade of its colour. */
.edge.hot, .bridge.hot .deck { stroke-width:11; filter:saturate(1.4) brightness(.85); }
.bridge.hot .casing { stroke-width:19; }
@media (prefers-color-scheme: dark) { .edge.hot, .bridge.hot .deck { filter:saturate(1.4) brightness(1.2); } }
.glyph { fill:var(--paper); stroke:currentColor; stroke-width:3.5; }
.branch .glyph { stroke-width:5; }
.hub .glyph    { fill:none; stroke:none; }      /* the logo is drawn instead; the circle is its focus ring */
.hub.no-logo .glyph { fill:var(--ink); }        /* logo missing: the plain hub of D-22 */
.hub .backdrop { fill:var(--paper); }           /* opaque only inside the logo's ring */
.hub .logo image { pointer-events:none; }       /* its transparent margin must not catch clicks */
@media (prefers-color-scheme: dark) { .hub .logo image { filter:invert(1); } }   /* black lines turn light */
.hub .logo     { transform-box:view-box; }      /* transform-origin (set by map.js) is in hub px */
/* The idle bounce (FR-MAP-18): 3 bounces, then 5 s still, over and over until the hub is opened.
   Each bounce falls to a floor 50 px below, speeding up like a dropped ball, squashes for a moment,
   and rises back to the same height. One bounce is 0.9 s, so a burst and its rest take 7.7 s;
   the percentages below are those times. */
.hub.bounce .logo { animation:bounce 7.7s infinite; }
@keyframes bounce {
  0% { transform:translateY(0);    animation-timing-function:cubic-bezier(.5,0,1,.5); }   /* falling */
  5.38% { transform:translateY(50px); animation-timing-function:ease-out; }
  5.84% { transform:translateY(50px) scale(1.12,.88); animation-timing-function:ease-in; }   /* landing */
  6.31% { transform:translateY(50px); animation-timing-function:cubic-bezier(0,.5,.5,1); }   /* rising */
  11.69% { transform:translateY(0);    animation-timing-function:cubic-bezier(.5,0,1,.5); }
  17.06% { transform:translateY(50px); animation-timing-function:ease-out; }
  17.53% { transform:translateY(50px) scale(1.12,.88); animation-timing-function:ease-in; }
  18% { transform:translateY(50px); animation-timing-function:cubic-bezier(0,.5,.5,1); }
  23.38% { transform:translateY(0);    animation-timing-function:cubic-bezier(.5,0,1,.5); }
  28.75% { transform:translateY(50px); animation-timing-function:ease-out; }
  29.22% { transform:translateY(50px) scale(1.12,.88); animation-timing-function:ease-in; }
  29.69% { transform:translateY(50px); animation-timing-function:cubic-bezier(0,.5,.5,1); }
  35.06%, 100% { transform:translateY(0); }   /* resting */
}
.visited:not(.branch):not(.hub) .glyph { fill:currentColor; }        /* read = filled */
.pax        { fill:var(--ink); }
.pax.branch { fill:none; stroke:var(--ink); stroke-width:1.5; }
.station { cursor:pointer; outline:none; }
.station .hit { fill:transparent; }                  /* transparent, not none: it must still catch the pointer */
.station:focus-visible .glyph { stroke:var(--ink) !important; stroke-width:6; }
.station text { font-size:13px; font-weight:500; fill:var(--ink); pointer-events:none;
  paint-order:stroke; stroke:var(--paper); stroke-width:4px; }
/* Beside a station in a band: title, a post's date, and its summary cut at three lines (§15.5).
   Faded with color-mix, never opacity: WebKit (every iOS browser) draws an element with opacity
   inside a foreignObject in its own layer that ignores the map's transform, at the map's top-left. */
.station foreignObject { overflow:visible; pointer-events:none; color:var(--ink); }   /* not the line colour */
/* The text itself answers to the pointer, not the empty rest of its box, which can lie over a gutter line. */
.label :is(.title, .date, .summary) { pointer-events:auto; width:fit-content; max-width:100%; }
.label > div    { height:100%; display:flex; flex-direction:column; justify-content:center; }   /* centred on the station */
/* Hovering a station or its text shades the label, to show it all answers to the click. The shade is
   the div's background over its 6px padding (PAD in map.js), never a box-shadow: WebKit repaints a
   foreignObject only inside its box, so anything drawn outside it leaves trails on zoom and drag.
   In dark mode the ink is light, so the shade lightens instead. */
.label > div { border-radius:6px; padding:6px; box-sizing:border-box; transition:background-color .15s; }
.station:is(:hover, :focus-visible) .label > div { background:color-mix(in srgb, var(--ink) 7%, transparent); }
.branch .label > div { height:calc(50% + 6px); justify-content:flex-end; padding-bottom:calc(.35rem + 6px); }   /* a lone title: above its stub */
.label .title   { font-size:15px; font-weight:650; line-height:1.3; letter-spacing:-.005em;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.label .date    { display:block; margin-top:1px; font-size:12px; line-height:1.4; color:color-mix(in srgb, var(--ink) 62%, transparent); font-variant-numeric:tabular-nums; }
.label .summary { margin-top:4px; font-size:13px; line-height:1.4; color:color-mix(in srgb, var(--ink) 78%, transparent); overflow:hidden;
  display:-webkit-box; -webkit-box-orient:vertical; -webkit-line-clamp:3; line-clamp:3; }
[data-zoom="far"] .station:not(.hub) .label,
[data-zoom="mid"] :is(.post, .project) .label { display:none; }          /* semantic zoom */
#map .station:is(:hover, :focus-visible) .label { display:inline; }      /* any zoom (FR-NAV-07) */
.station .more { font-size:10px; font-weight:600; }   /* "+n" hidden passengers */
.station .hint        { font-size:12px; font-style:italic; text-anchor:middle; opacity:.6; }
.new .glyph, .pax.new { animation:blink 1.6s ease-in-out 3; }
@keyframes blink { 50% { opacity:.3; } }

/* ---------- journey footer ---------- */
.journey { position:fixed; left:1rem; bottom:1rem; display:flex; gap:.75rem; align-items:center;
  font-size:.75rem; color:var(--ink); opacity:.8; }
#reset { font-family:inherit; font-size:.8rem; font-weight:500; line-height:1; padding:.45rem .8rem;
  border:2px solid var(--ink); border-radius:999px; background:var(--paper); color:var(--ink); cursor:pointer; }
#reset[hidden] { display:none; }

/* ---------- key (legend) ---------- */
#key { position:fixed; left:1rem; top:1rem; max-width:16rem; padding:.6rem .8rem; font-size:.75rem;
  background:var(--paper); border:2px solid var(--ink); border-radius:12px; outline:none; }
#key.collapsed { padding:0; border:0; background:none; }
#key.collapsed #key-body { display:none; }
.key-toggle { font:inherit; font-weight:700; letter-spacing:.06em; text-transform:uppercase; padding:.3rem .7rem;
  border:2px solid var(--ink); border-radius:999px; background:var(--paper); color:var(--ink); cursor:pointer; }
#key:not(.collapsed) .key-toggle { border:0; padding:0 0 .4rem; }
.legend { list-style:none; margin:0 0 .5rem; padding:0; display:grid; gap:.3rem; }
.legend li { display:flex; gap:.5rem; align-items:center; }
.legend svg { width:16px; height:16px; flex:none; }
.k-post, .k-new { fill:var(--paper); stroke:var(--ink); stroke-width:1.75; }
.k-branch { fill:var(--paper); stroke:var(--ink); stroke-width:2.5; }
.k-read { fill:var(--ink); stroke:var(--ink); stroke-width:1.75; }
.k-new { animation:blink 1.6s ease-in-out infinite; }
#key .pages { margin:0; }
#key .pages a { color:inherit; font-weight:600; text-underline-offset:3px; }
#key .rights { margin:.4rem 0 0; opacity:.7; }
/* Who this is: always shown, even with the key collapsed (FR-MAP-01, review D-27). */
#key .site { margin:0 0 .5rem; }
#key .site h1 { margin:0; font-size:1.05rem; line-height:1.2; }
#key .site p { margin:.15rem 0 0; font-size:.8rem; opacity:.75; }
#key.collapsed .site { padding:.4rem .6rem; background:var(--paper); border-radius:8px; }

/* ---------- minimap ---------- */
#minimap { position:fixed; right:1rem; bottom:1rem; width:200px; height:140px; overflow:hidden;
  background:var(--paper); border:2px solid var(--ink); border-radius:12px;
  transition:width .25s, height .25s, border-radius .25s; }
#minimap svg { display:block; cursor:crosshair; touch-action:none; }
.mm-edge { fill:none; stroke-width:2.5; stroke-linecap:round; stroke-linejoin:round; }
.mm-node { fill:var(--paper); stroke:currentColor; stroke-width:1; }
.mm-node.visited, .mm-node.hub { fill:currentColor; }
.mm-view { fill:color-mix(in srgb, var(--ink) 8%, transparent); stroke:var(--ink); stroke-width:1.5; cursor:grab; }
.mm-toggle { position:absolute; top:2px; right:2px; width:1.5rem; height:1.5rem; border:0; border-radius:50%;
  background:var(--paper); color:var(--ink); font-family:inherit; font-size:1rem; line-height:1; cursor:pointer; }
#minimap.collapsed { width:2.25rem; height:2.25rem; border-radius:50%; }
#minimap.collapsed svg { display:none; }
#minimap.collapsed .mm-toggle { inset:0; margin:auto; }

/* ---------- reader overlay ---------- */
#reader { width:min(72ch, 100vw); max-height:90vh; max-height:90dvh; padding:0; border:0; border-radius:12px;
  background:var(--paper); color:var(--ink); overflow:auto; overscroll-behavior:contain; }
#reader::backdrop { background:color-mix(in srgb, var(--paper) 70%, transparent); backdrop-filter:blur(2px); }
/* sticky, so the way out stays on screen while a long post scrolls (R-42) */
.close { position:sticky; top:.5rem; float:right; z-index:1; width:2rem; height:2rem; margin:.5rem .75rem 0 0;
  font-size:1.5rem; line-height:1; border:0; border-radius:50%; background:var(--paper); color:inherit; cursor:pointer; }
.route { display:flex; list-style:none; margin:0; padding:1.25rem 1.5rem 0; font-size:.8rem; }
.route li { position:relative; flex:1; padding-top:18px; }
.route li::before { content:""; position:absolute; top:6px; left:0; right:0; height:4px; background:var(--line); }
.route li::after  { content:""; position:absolute; top:2px; left:0; width:8px; height:8px;
  border:2px solid var(--line); border-radius:50%; background:var(--paper); }
.route li:last-child::before { right:auto; width:12px; }

/* ---------- post typography ---------- */
#reader article { max-width:68ch; margin:0 auto; padding:1rem 1.5rem 3rem; font-size:1.0625rem; line-height:1.65; }
#reader h1 { font-size:2rem; line-height:1.15; letter-spacing:-.01em; margin:.25rem 0 .4rem; outline:none; }
#reader .meta { font-size:.8rem; opacity:.7; font-variant-numeric:tabular-nums; margin:0 0 2rem; }
#reader :is(h2,h3,h4) { line-height:1.25; margin:2.2em 0 .6em; scroll-margin-top:1rem; }
#reader h2::before { content:""; display:inline-block; width:.5em; height:.5em; margin-right:.5em;
  border:3px solid var(--line); border-radius:50%; vertical-align:.08em; }
#reader a { color:inherit; text-decoration-color:var(--line); text-decoration-thickness:2px; text-underline-offset:3px; }
#reader a[target="_blank"]::after { content:"↗"; font-size:.75em; margin-left:.15em; }
#reader blockquote { margin:1.5em 0; padding:.1em 1em; border-left:4px solid var(--line); opacity:.85; }
#reader code, #reader pre { font-family:ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
#reader :not(pre) > code { font-size:.9em; padding:.1em .3em; border-radius:4px;
  background:color-mix(in srgb, var(--ink) 7%, transparent); }
#reader pre { position:relative; overflow:auto; padding:1rem; border-radius:8px; font-size:.875rem;
  background:color-mix(in srgb, var(--ink) 5%, transparent); }
#reader .hljs { background:transparent; padding:0; }
#reader img { display:block; max-width:100%; height:auto; margin:1.5em auto; border-radius:8px; }
#reader table { display:block; overflow-x:auto; border-collapse:collapse; font-size:.9rem; }
#reader :is(th,td) { padding:.4em .8em; border-bottom:1px solid color-mix(in srgb, var(--ink) 20%, transparent); text-align:left; }
#reader hr { width:3rem; height:4px; margin:2.5em auto; border:0; border-radius:2px; background:var(--line); }

/* ---------- callouts, loading, failure ---------- */
.callout { margin:1.5em 0; padding:.75rem 1rem; border-left:6px solid var(--line); border-radius:0 8px 8px 0;
  background:color-mix(in srgb, var(--line) 8%, transparent); }
.callout.warning { border-color:#f9a825; background:color-mix(in srgb, #f9a825 10%, transparent); }
.callout-title { margin:0 0 .25rem; font-size:.75rem; font-weight:700; letter-spacing:.06em; text-transform:uppercase; }
.transit { position:relative; width:min(240px, 60%); height:4px; margin:4rem auto; border-radius:2px;
  background:color-mix(in srgb, var(--line) 30%, transparent); }
.transit::after { content:""; position:absolute; top:-4px; left:0; width:12px; height:12px; border-radius:50%;
  background:var(--line); animation:run 1.2s ease-in-out infinite alternate; }
@keyframes run { to { left:calc(100% - 12px); } }
.failure { margin:3rem 0; text-align:center; }
#reader article:has(.failure) h1 { text-align:center; }   /* over its centred message (R-58) */
.failure :is(button, .button) { display:inline-block; text-decoration:none; padding:.45rem .9rem; border:2px solid var(--ink); border-radius:999px;
  background:var(--paper); color:var(--ink); font:inherit; cursor:pointer; }

/* ---------- extensions ---------- */
#reader .math.display { overflow-x:auto; overflow-y:hidden; margin:1.5em 0; }
#reader .embed { display:block; aspect-ratio:16/9; margin:1.5em 0; border-radius:8px; overflow:hidden;
  background:color-mix(in srgb, var(--ink) 6%, transparent); }
#reader .embed iframe { width:100%; height:100%; border:0; }
/* Iframely cards (iframely.js): embed.js sets the width and height inside these wrappers. */
#reader .iframely-embed { margin:1.5em 0; }
#reader .iframely-embed iframe { border-radius:8px; }
#reader :is(video, audio) { display:block; width:100%; margin:1.5em 0; border-radius:8px; }

/* ---------- reduced motion & small screens ---------- */
@media (prefers-reduced-motion: reduce) {
  .new .glyph, .pax.new, .k-new, .hub.bounce .logo { animation:none; }
  #minimap, .edge, .bridge path, .label > div { transition:none; }
  .transit::after { animation:none; left:calc(50% - 6px); }
}
@media (max-width:600px) {
  #minimap { display:none; }
  #reader { width:100vw; height:100vh; height:100dvh; max-height:100vh; max-height:100dvh; border-radius:0; }
}
