/* ---- the palette ---------------------------------------------------------------------
   Every colour of the site is one of these, by what it is for; no page and no script has
   one of its own (scripts ask header.js: tone()). Each has two values, light-dark(on
   paper, on the dark ground), and the root's color-scheme says which holds: the system's,
   or the one the visitor chose (data-theme, which each page's head sets before the first
   paint; the control is header.js's).

   The tones are Flexoki's (Steph Ango, stephango.com/flexoki, MIT), the steps named
   beside them. Two things are the site's own. The dark ground lies between Flexoki's
   black (#100F0F) and its base 950, at grey 20. And text is a step or two stronger than
   Flexoki's themes have it, because all of it lies over drawn lines: the faintest that
   says something (--ink-3) keeps 6.8 : 1 on the ground in either theme, and it and the
   accent keep 4.5 : 1 over the strongest line the map may have under them (--rule-2). */
:root {
  color-scheme: light dark;
  --ground:  light-dark(#FFFCF0, #151413);   /* paper | between black and base 950: the page */
  --surface: light-dark(#F2F0E5, #1C1B1A);   /* base 50 | 950: what is raised from it */
  --grain:   none;                           /* the ground's surface: a tile of specks toward the ink ("the grain", below) */
  --grain-level: 0.5;                        /* ... and how much of it shows */
  /* lines that divide or lie under something; none of them is text */
  --rule:    light-dark(#E6E4D9, #282726);   /* 100 | 900: the faintest, a base line */
  --rule-2:  light-dark(#DAD8CE, #343331);   /* 150 | 850: a divider */
  --rule-3:  light-dark(#CECDC3, #403E3C);   /* 200 | 800: a link's line at rest, a border */
  --rule-4:  light-dark(#878580, #6F6E69);   /* 500 | 600: a line that is itself the drawing (a profile, a tick, a hatch) */
  /* what is written, and what is drawn to be read */
  --ink:     light-dark(#100F0F, #CECDC3);   /* black | 200: the name, titles, what stands out */
  --ink-2:   light-dark(#403E3C, #B7B5AC);   /* 800 | 300: sentences, the navigation */
  --ink-3:   light-dark(#575653, #9F9D96);   /* 700 | 400: labels, dates, the footer: the faintest text */
  --ink-4:   light-dark(#6F6E69, #878580);   /* 600 | 500: marks beside text (the route not yet flown); 5 : 1 on bare ground, no text over lines */
  --ink-hi:  light-dark(#100F0F, #FFFCF0);   /* black | paper: under the pointer, where there is no accent */
  /* the scene's lines at full strength: ink on paper, light on the dark ground (terrain-gl.js) */
  --line:    light-dark(#100F0F, #F2F0E5);   /* black | 50 */
}
:root[data-theme="light"] { color-scheme: light; --grain: url(grain/fine-light.webp); }   /* (a tile is fetched for the theme in use only) */
:root[data-theme="dark"]  { color-scheme: dark; --grain: url(grain/fine-dark.webp); }
:root.switching *, :root.switching *::before, :root.switching *::after { transition: none !important; }   /* while the theme changes (header.js) */
/* A change of theme as one motion of the whole window (header.js: "the change of theme"; `?themefx=`). Where the
   browser's view transition carries it, the page as it was is a picture and the page as it is comes in over it by
   an animation header.js gives it: none of the browser's own cross-fade then. The front (ridge) cuts the two a
   line's width apart, and what shows between them is this ground: the last light, as a line on the front. */
:root[data-themefx]:not(.turning)::view-transition-group(root), :root[data-themefx]:not(.turning)::view-transition-old(root), :root[data-themefx]:not(.turning)::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
:root[data-themefx]:not(.turning)::view-transition-image-pair(root) { isolation: auto; }
:root[data-themefx]:not(.turning)::view-transition-new(root) { opacity: 0; }   /* (it shows by header.js's animation alone) */
:root[data-themefx="ridge"]:not(.turning)::view-transition-image-pair(root) { background: var(--accent-glow, var(--ink-hi)); }
/* (:not(.turning): never a page turn's transition, which has its own rules in pages.css; the two do not run at once: pages.js) */
/* `?tx=flexoki`, to compare: the faintest text as Flexoki's own themes have it (their tx-2: base 600 | 500). The map
   under the text may then have a third of its lines' strength. */
:root[data-tx="flexoki"] { --ink-3: var(--ink-4); }
/* a browser from before 2024 does not know light-dark(): it has the dark theme alone (and no control for the other) */
@supports not (color: light-dark(#000, #fff)) {
  :root {
    color-scheme: dark;
    --ground: #151413; --surface: #1C1B1A; --grain: none;
    --rule: #282726; --rule-2: #343331; --rule-3: #403E3C; --rule-4: #6F6E69;
    --ink: #CECDC3; --ink-2: #B7B5AC; --ink-3: #9F9D96; --ink-4: #878580; --ink-hi: #FFFCF0;
    --line: #F2F0E5;
  }
}

html { overscroll-behavior: none; }   /* no rubber-band at the ends, which drags the fixed header along */
* { margin: 0; box-sizing: border-box; }

/* moving between pages cross-fades them where the browser can (Chrome 126+,
   Safari 18.2+); elsewhere it is a plain navigation */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
}
::view-transition { pointer-events: none; }      /* the new page takes clicks while it fades in */

:focus-visible { outline: 1px solid var(--ink); outline-offset: 3px; }
:target { scroll-margin-top: 90px; }             /* clear of the fixed header */
body {
  position: relative; min-height: 100vh; min-height: 100svh;   /* (the grain's layer is as tall as the document) */
  background: var(--ground);
  color: var(--ink);
  font-family: 'IBM Plex Mono', 'Menlo as Plex', 'Consolas as Plex', Menlo, Consolas, monospace;
  line-height: 1.16;       /* spelled out: "normal" differs by engine and by typeface */
}

/* IBM Plex Mono, served from fonts/ (SIL Open Font License, fonts/LICENSE.txt):
   IBM's own files and unicode-range splits from the @ibm/plex-mono release,
   unmodified. Every page needs Latin 1 in two weights and preloads them; Pi
   holds the arrows and is fetched only by a page that shows one. */
@font-face {
  font-family: 'IBM Plex Mono'; font-weight: 400; font-display: swap;
  src: url(fonts/IBMPlexMono-Regular-Latin1.woff2) format('woff2');
  unicode-range: U+0020-007E, U+00A0-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2013-2014, U+2018-201A, U+201C-201E, U+2020-2022, U+2026, U+2030, U+2039-203A, U+2044, U+20AC, U+2122, U+2212, U+FB01-FB02;
}
@font-face {
  font-family: 'IBM Plex Mono'; font-weight: 500; font-display: swap;
  src: url(fonts/IBMPlexMono-Medium-Latin1.woff2) format('woff2');
  unicode-range: U+0020-007E, U+00A0-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2013-2014, U+2018-201A, U+201C-201E, U+2020-2022, U+2026, U+2030, U+2039-203A, U+2044, U+20AC, U+2122, U+2212, U+FB01-FB02;
}
@font-face {
  font-family: 'IBM Plex Mono'; font-weight: 400; font-display: swap;
  src: url(fonts/IBMPlexMono-Regular-Pi.woff2) format('woff2');
  unicode-range: U+03C0, U+0E3F, U+2000-200D, U+2010-2012, U+2015, U+2028-2029, U+202F, U+2032-2033, U+203E, U+205F, U+2070, U+2074-2079, U+2080-2089, U+2113, U+2116, U+2126, U+212E, U+2150-2151, U+2153-215E, U+2190-2199, U+21A9-21AA, U+21B0-21B3, U+21B6-21B7, U+21BA-21BB, U+21C4, U+21C6, U+2202, U+2206, U+220F, U+2211, U+2215, U+2219-221A, U+221E, U+222B, U+2236, U+2248, U+2260, U+2264-2265, U+2400-2421, U+2500-259F, U+25CA, U+2713, U+274C, U+2B0E-2B11, U+3000, U+FEFF, U+FFFD;
}
/* Until the files arrive, and for the one glyph Plex lacks (the ▾ of the
   summit labels): the system's monospace under Plex's metrics, scaled to its
   advance of 0.6 em and given its ascent and descent, so that nothing moves
   when the face swaps in. The root asks for it by itself because Firefox does
   not start on a later family of a list while an earlier one is loading. */
@font-face {
  font-family: 'Menlo as Plex'; src: local('Menlo Regular'), local('Menlo-Regular'), local('DejaVu Sans Mono');
  size-adjust: 99.66%; ascent-override: 102.85%; descent-override: 27.59%; line-gap-override: 0%;
}
@font-face {
  font-family: 'Consolas as Plex'; src: local('Consolas');
  size-adjust: 109.13%; ascent-override: 93.92%; descent-override: 25.2%; line-gap-override: 0%;
}
html { font-family: 'Menlo as Plex', 'Consolas as Plex', monospace; }

/* ---- the grain ------------------------------------------------------------------------
   The ground has the surface of a printed sheet: single specks toward the ink, a pixel of a 2x
   display each (bake_grain.py; the tiles are 448 px, shown at 224). It is a layer over what
   lies on the ground, never part of a background, so that everything that covers something
   with "the ground" (the stage, the seam's fill, a scrim, the header's fade, the scene's clear
   canvas) is under the same surface and no edge shows where one of them begins. The layer
   belongs to the ground it lies on: over a document it is as tall as the document and scrolls
   with it; where the ground stands in the window (the band of the main page: home.css; a page
   whose scene fills the window) it stands with it. Nothing is drawn for it per frame or on a
   scroll. `?grain=fine|laid|coarse|fibre|0`, `?grainlevel=<0..1>` (0.5), `?grainfix=1`: one
   layer that stands in the window, on every page (header.js). */
body::before, #sitehead::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: var(--grain) 0 0 / 224px 224px; opacity: var(--grain-level);
}
body::before { z-index: 4; }                     /* over the page's text and what lies under it; under the stage and the header */
body:has(> canvas.layer)::before, :root[data-grainfix] body::before { position: fixed; z-index: 30; }   /* the ground stands in the window: so does its surface, over everything */
/* the header's fade covers what passes under it with the ground: it has the surface that takes away, as much as it covers */
#sitehead::after {
  z-index: -1;
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,0.9), rgba(0,0,0,0.5) 60%, transparent);
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0.9), rgba(0,0,0,0.5) 60%, transparent);
}
body:has(> canvas.layer) #sitehead::after, :root[data-grainfix] #sitehead::after { display: none; }   /* (it is under the one layer then) */
:root[data-grain="laid"][data-theme="light"] { --grain: url(grain/laid-light.webp); }
:root[data-grain="laid"][data-theme="dark"] { --grain: url(grain/laid-dark.webp); }
:root[data-grain="coarse"][data-theme="light"] { --grain: url(grain/coarse-light.webp); }
:root[data-grain="coarse"][data-theme="dark"] { --grain: url(grain/coarse-dark.webp); }
:root[data-grain="fibre"][data-theme="light"] { --grain: url(grain/fibre-light.webp); }
:root[data-grain="fibre"][data-theme="dark"] { --grain: url(grain/fibre-dark.webp); }
:root[data-grain="0"] { --grain: none; }

#sitehead {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; align-items: baseline; gap: 24px;
  padding: 18px 28px;
  font-size: 12px; letter-spacing: 0.1em;
}
/* The fade behind the header is the page's ground under a gradient mask.
   Written as a gradient of that colour made translucent it is not a no-op
   over the page: Chrome and Safari round it into faint bands in the sky. */
#sitehead::before {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: var(--ground);
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,0.9), rgba(0,0,0,0.5) 60%, transparent);
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0.9), rgba(0,0,0,0.5) 60%, transparent);
}
#sitehead .brand { color: var(--ink); text-decoration: none; }
#sitehead .mode {
  display: inline-flex; align-items: baseline; gap: 6px;   /* baseline, so the label lines up with the brand */
  color: var(--ink-3); text-decoration: none;
  padding-left: 16px; border-left: 1px solid var(--rule-2);
  transition: color 0.2s;
}
#sitehead .mode:hover { color: var(--ink-hi); }
#sitehead .mode svg { display: block; transform: translateY(2px); }   /* icon sits on the baseline; centre it on the x-height */
/* the other theme (header.js): a button dressed as a link, behind the rule after the name; it names what it leads to */
#sitehead button.mode {
  appearance: none; -webkit-appearance: none; background: none; border-block: 0; border-right: 0; padding-block: 0; padding-right: 0; margin: 0;
  font: inherit; letter-spacing: inherit; cursor: pointer;
}
:root[data-theme="light"] #sitehead .theme .sun, :root:not([data-theme="light"]) #sitehead .theme .moon { display: none; }
#sitehead nav { display: flex; gap: 22px; margin-left: auto; }
#sitehead nav a { color: var(--ink-2); text-decoration: none; transition: color 0.2s; }
#sitehead nav a:hover, #sitehead nav a.active { color: var(--ink-hi); }

.layer { position: fixed; inset: 0; width: 100%; height: 100%; }

#peaks { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.peak {
  position: absolute; left: 0; top: 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 10px; letter-spacing: 0.08em; white-space: nowrap;
  color: var(--ink); text-shadow: 0 0 8px var(--ground);
  transition: opacity 0.25s; will-change: transform;
}
.peak i { font-style: normal; color: var(--ink-2); font-size: 9px; line-height: 1; }

#telemetry {
  position: fixed; bottom: 14px; right: 24px; z-index: 20;
  color: var(--ink-3); font-size: 11px; letter-spacing: 0.08em;
  text-shadow: 0 0 8px var(--ground); pointer-events: none;
}

#links { display: flex; gap: 18px; margin-top: 1.8rem; }
#links a { color: var(--ink-2); transition: color 0.2s, filter 0.2s; }
#links a:hover { color: var(--ink-hi); }
:root[data-theme="dark"] #links a:hover { filter: drop-shadow(0 0 6px color-mix(in srgb, var(--ink-hi) 50%, transparent)); }   /* light glows; ink does not */
#links svg {
  width: 20px; height: 20px; display: block;
  fill: none; stroke: currentColor; stroke-width: 1.4;
  stroke-linecap: round; stroke-linejoin: round;
}
#links .draw {
  stroke-dasharray: 80; stroke-dashoffset: 80;
  animation: draw-in 900ms ease-out forwards;
  animation-delay: var(--d, 1.6s);
}
@keyframes draw-in { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) {
  #links .draw { animation: none; stroke-dashoffset: 0; }
}

/* small links take a pointer or a finger over a larger area than they draw */
#sitehead a, #sitehead button, #sitefoot a, #links a, .fly .more { position: relative; }
#sitehead a::after, #sitehead button::after, #sitefoot a::after, #links a::after, .fly .more::after {
  content: ''; position: absolute; inset: -10px -6px;
}
#links a::after { inset: -8px; }

main.page { max-width: 760px; margin: 0 auto; padding: 140px 28px 80px; }
main.page h1 { font-size: 1.6rem; font-weight: 500; letter-spacing: 0.06em; margin-bottom: 1.2rem; }
main.page p { color: var(--ink-2); line-height: 1.7; }
main.page a { color: var(--ink); }

#sitefoot {
  position: relative; z-index: 1;
  max-width: 760px; margin: 0 auto; padding: 0 28px 28px;
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 18px;
  color: var(--ink-3); font-size: 10px; letter-spacing: 0.08em; line-height: 1.6;
  text-shadow: 0 0 8px var(--ground);             /* sits over the backdrop's lines */
}
#sitefoot a { color: var(--ink-2); text-decoration: none; transition: color 0.2s; }
#sitefoot a:hover { color: var(--ink-hi); }

@media (max-width: 720px) {
  #sitehead { padding: calc(12px + env(safe-area-inset-top)) 16px 12px; gap: 12px; font-size: 11px; letter-spacing: 0.06em; }
  #sitehead nav { gap: 12px; }
  #telemetry { right: 16px; bottom: calc(10px + env(safe-area-inset-bottom)); font-size: 10px; }
  #sitefoot { padding: 0 22px calc(20px + env(safe-area-inset-bottom)); }
  #sitehead .mode { padding-left: 10px; }
  #sitehead .mode span { display: none; }
  #links { gap: 16px; }
}
/* the header on one line, down to a 320 px phone */
@media (max-width: 400px) {
  #sitehead { padding-left: 14px; padding-right: 14px; gap: 9px; }
  #sitehead nav { gap: 9px; }
}
@media (max-width: 368px) {
  #sitehead { letter-spacing: 0.02em; }
}
@media (max-width: 356px) {
  #sitehead { padding-left: 12px; padding-right: 12px; gap: 8px; font-size: 10px; letter-spacing: 0; }
  #sitehead nav { gap: 8px; }
  #sitehead .mode { padding-left: 8px; }
}

/* ---- the accent ------------------------------------------------------------------
   One colour beside the inks, and it stands for one thing: what is lit, live or here.
   It is a pair, as every tone is: a light on the dark ground, an ink on paper. --accent
   is its one definition; the scene and the map ask header.js for it (tone('accent')).
   Picked from the address (`?accent=<name>`); without one there is no accent and every
   rule below is idle. `?accentink=<name>` sets the paper half alone, to compare. */
html[data-accent] { --accent: light-dark(var(--accent-ink), var(--accent-glow)); }
/* On paper the accent is an ink, and an ink has two strengths: as a line or as text it is the dark step (--accent-ink,
   Flexoki's 700: what keeps 4.5 : 1 over the map's lines), as an area it is the light one (--accent-plate, the 400 of
   the same hue): the plate the scene prints on its high ground (terrain-gl.js), as a map's tint is lighter than its line. */
html[data-accent="alpenglow"] { --accent-glow: #ff9377; --accent-ink: #9D4310; --accent-plate: #E8821E; }   /* last light on high snow | the same light as a print has it: Flexoki's orange 700 as the line, and as the plate an orange of the site's own, yellower and fuller than the 400 */
html[data-accent="glacier"]   { --accent-glow: #6dd0f3; --accent-ink: #1A4F8C; --accent-plate: #4385BE; }   /* ice in shade, the hour before sunrise | the same blue */
html[data-accent="orange"]    { --accent-glow: #DA702C; --accent-ink: #BC5215; --accent-plate: #DA702C; }   /* Flexoki's own, 400 | 600, to compare */
html[data-accent="red"]       { --accent-glow: #D14D41; --accent-ink: #AF3029; --accent-plate: #D14D41; }
html[data-accent="cyan"]      { --accent-glow: #3AA99F; --accent-ink: #24837B; --accent-plate: #3AA99F; }
html[data-accent="blue"]      { --accent-glow: #4385BE; --accent-ink: #205EA6; --accent-plate: #4385BE; }
html[data-accent][data-ink="blue"]   { --accent-ink: #205EA6; --accent-plate: #4385BE; }
html[data-accent][data-ink="cyan"]   { --accent-ink: #24837B; --accent-plate: #3AA99F; }
html[data-accent][data-ink="orange"] { --accent-ink: #BC5215; --accent-plate: #DA702C; }
html[data-accent][data-ink="red"]    { --accent-ink: #AF3029; --accent-plate: #D14D41; }
html[data-accent][data-ink="blue7"]  { --accent-ink: #1A4F8C; --accent-plate: #4385BE; }   /* (the 700s, each with its 400 as the plate) */
html[data-accent][data-ink="red7"]   { --accent-ink: #942822; --accent-plate: #D14D41; }
html[data-accent][data-ink="orange7"] { --accent-ink: #9D4310; --accent-plate: #DA702C; }
html[data-accent][data-ink="print"]  { --accent-ink: #9D4310; --accent-plate: #E8821E; }   /* (orange 700, and as the plate an orange as a two-colour print has it: yellower and fuller than the 400) */
html[data-accent][data-plate="ink"]  { --accent-plate: var(--accent-ink); }                /* `?plateink=ink`: the plate in the line's own step, to compare */
@supports not (color: light-dark(#000, #fff)) { html[data-accent] { --accent: var(--accent-glow); } }
html[data-accent] ::selection { background: var(--accent); color: var(--ground); }
html[data-accent] :focus-visible { outline-color: var(--accent); }
html[data-accent] #sitehead nav a.active { color: var(--accent); }
html[data-accent] :is(#sitehead .mode, #sitehead nav a, #sitefoot a, main.page a):hover { color: var(--accent); }
html[data-accent] #links a:hover { color: var(--accent); }
html[data-accent][data-theme="dark"] #links a:hover { filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 50%, transparent)); }
