@font-face {
  font-family: "Geologica";
  src: url("fonts/geologica-cyrillic.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: "Geologica";
  src: url("fonts/geologica-latin.woff2") format("woff2");
  font-weight: 300 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  /* night sky and chart paper */
  --ground: #0b1220;
  --ground-raised: #111a2b;
  --plate: #141c2b;
  --grid: rgba(150, 175, 220, .07);
  --grid-strong: rgba(150, 175, 220, .14);
  --rule: rgba(190, 205, 235, .16);
  /* ink */
  --ink: #c9d3e3;
  --ink-strong: #eef2f8;
  --ink-soft: #8d9ab0;
  /* emission lines: colour only ever as a hairline or a swatch */
  --o-557: #5ff2a0;
  --o-630: #ff6b6b;
  --n2-428: #8f86ff;

  --face: "Geologica", ui-sans-serif, "Segoe UI", Roboto, Arial, sans-serif;
  --rail: 11rem;
  --measure: 68ch;
  --margin: 6.5rem;
  --spine: calc(var(--margin) + var(--space-3) / 2);  /* the altitude spine, in the gutter after the margin column */
  --space-1: .5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --space-4: 2.5rem;
  --space-5: 4rem;
  --space-6: 6rem;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--ground); color-scheme: dark; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 300 1.0625rem/1.65 var(--face);
  font-variation-settings: normal;
  font-feature-settings: "kern", "liga";
  text-rendering: optimizeLegibility;
}
::selection { background: rgba(201, 211, 227, .24); color: var(--ink-strong); }  /* chart ink, not an emission colour */
html { scrollbar-color: #2a3650 var(--ground); scrollbar-width: thin; }
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--ground); }
::-webkit-scrollbar-thumb { background: #2a3650; border-radius: 10px; border: 2px solid var(--ground); }

a { color: var(--ink-strong); text-decoration-color: rgba(95, 242, 160, .55); text-decoration-thickness: 1px; text-underline-offset: .22em; }
a:hover { text-decoration-color: var(--o-557); }
:focus-visible { outline: 2px solid var(--o-557); outline-offset: 3px; border-radius: 2px; }

.skip { position: absolute; left: var(--space-2); top: -4rem; padding: .5rem .9rem; background: var(--ink-strong); color: var(--ground); z-index: 10; text-decoration: none; border-radius: 4px; }
.skip:focus { top: var(--space-2); }

/* --- masthead: the chart's frame ---------------------------------------- */
.masthead {
  position: relative;
  border-bottom: 1px solid var(--rule);
  background-color: var(--ground-raised);
  background-image:
    linear-gradient(var(--grid-strong) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-strong) 1px, transparent 1px),
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 120px 52px, 120px 52px, 24px 13px, 24px 13px;
  background-position: -1px -1px;
  overflow: hidden;
}
.masthead-inner { position: relative; max-width: 84rem; margin: 0 auto; padding: var(--space-4) clamp(1rem, 4vw, 3rem) var(--space-3); min-height: clamp(13rem, 32vw, 18rem); }
.brand { position: relative; z-index: 1; margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: .35rem 1.25rem; }
.brand-name { font-weight: 650; font-size: clamp(2.6rem, 7vw, 4.6rem); letter-spacing: .14em; text-transform: uppercase; color: var(--ink-strong); line-height: 1; }
.brand-line { font-weight: 400; font-size: .95rem; letter-spacing: .04em; color: var(--ink-soft); }
.sounding { position: absolute; inset: 0; width: 100%; height: 100%; }
.trace { fill: none; stroke-width: 1.4; vector-effect: non-scaling-stroke; stroke-linecap: round; }
.trace-o { stroke: var(--o-557); }
.trace-x { stroke: var(--ink-soft); opacity: .5; }  /* the second (X-mode) echo: chart ink, not an emission colour */
.axis-y { position: absolute; right: clamp(1rem, 4vw, 3rem); top: 0; bottom: 0; margin: 0; padding: 0; list-style: none; font-size: .72rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.axis-y li { position: absolute; right: 0; top: var(--y); transform: translateY(-50%); white-space: nowrap; }
.axis-x { position: absolute; left: clamp(1rem, 4vw, 3rem); right: clamp(1rem, 4vw, 3rem); bottom: .55rem; margin: 0; padding: 0; list-style: none; display: flex; justify-content: space-between; font-size: .72rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; letter-spacing: .04em; }

/* --- sheet: rail + column -------------------------------------------------- */
.sheet { max-width: 84rem; margin: 0 auto; padding: 0 clamp(1rem, 4vw, 3rem); display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); gap: clamp(1.5rem, 4vw, 4rem); }

.rail { position: sticky; top: 0; align-self: start; max-height: 100vh; padding: var(--space-4) 0; }
.rail-title { margin: 0 0 var(--space-2); font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
.rail-ticks { list-style: none; margin: 0; padding: 0 0 0 1px; position: relative; border-left: 1px solid var(--rule); }
.rail-ticks li { position: relative; }
.rail-ticks a {
  position: relative; display: grid; gap: .05rem; padding: .55rem 0 .55rem 1rem;
  text-decoration: none; color: var(--ink-soft); transition: color .3s var(--ease-out);
}
.rail-ticks a::before { /* the tick on the height axis */
  content: ""; position: absolute; left: -1px; top: 1.05rem; width: .55rem; height: 1px; background: var(--rule);
  transition: width .45s var(--ease-out), background-color .3s var(--ease-out);
}
.rail-ticks .km { font-size: .95rem; font-weight: 500; font-variant-numeric: tabular-nums; color: var(--ink); }
.rail-ticks .tick-name { font-size: .8rem; }
.rail-ticks a:hover { color: var(--ink); }
.rail-ticks a:hover::before { width: .8rem; background: var(--ink-soft); }
.rail-ticks a[aria-current="location"] { color: var(--ink-strong); }
.rail-ticks a[aria-current="location"] .km { color: var(--o-557); }
.rail-ticks a[aria-current="location"]::before { width: 1.6rem; left: -1.6rem; background: var(--o-557); }
.rail-gap { margin-top: var(--space-3); }
.rail-flag { margin: var(--space-3) 0 0; }
.flag-button {
  font: inherit; font-size: .8rem; color: var(--ink); background: transparent; cursor: pointer;
  border: 1px solid var(--rule); border-radius: 3px; padding: .45rem .6rem; text-align: left; line-height: 1.35;
  transition: border-color .25s var(--ease-out), color .25s var(--ease-out);
}
.flag-button:hover { border-color: var(--o-630); color: var(--ink-strong); }
.flag-km { font-variant-numeric: tabular-nums; color: var(--o-630); }

/* --- reading column -------------------------------------------------------- */
.column {
  /* a margin column for the altitude, then the reading column */
  min-width: 0; padding: var(--space-4) 0 var(--space-6);
  display: grid; grid-template-columns: var(--margin) minmax(0, var(--measure)); column-gap: var(--space-3);
}
.column > section { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; align-content: start; }
.column > section > * { grid-column: 2; }
.intro h1 {
  margin: 0 0 var(--space-3); max-width: 18ch; font-weight: 600; font-size: clamp(2rem, 4.4vw, 3.2rem);
  line-height: 1.08; letter-spacing: -.02em; color: var(--ink-strong); text-wrap: balance;
}
.lead { font-size: 1.2rem; line-height: 1.6; color: var(--ink-strong); font-weight: 300; }
p { margin: 0 0 var(--space-2); text-wrap: pretty; }
dfn { font-style: normal; font-weight: 500; color: var(--ink-strong); }

.layer { padding-top: var(--space-5); }
.column > section > .opener {
  grid-column: 1 / -1; position: relative; display: grid; grid-template-columns: subgrid; align-items: baseline;
  margin: 0 0 var(--space-3); padding: var(--space-2) 0;
  border-top: 1px solid var(--rule);
  background-image: linear-gradient(90deg, var(--grid) 1px, transparent 1px), linear-gradient(var(--grid) 1px, transparent 1px);
  background-size: 24px 13px;
}
.opener::after { /* the echo trace crossing each opener at its height */
  content: ""; position: absolute; left: 0; right: 0; top: -1px; height: 1px;
  background: linear-gradient(90deg, transparent 0 var(--spine), var(--o-557) var(--spine) calc(var(--spine) + 4.5rem), transparent calc(var(--spine) + 4.5rem));
  opacity: .85;
}
.alt { margin: 0; text-align: right; font-size: .95rem; font-weight: 500; color: var(--ink-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }
.alt span { color: var(--ink-strong); }
.opener h2 { margin: 0; font-weight: 600; font-size: clamp(1.35rem, 2.4vw, 1.75rem); line-height: 1.2; letter-spacing: -.01em; color: var(--ink-strong); text-wrap: balance; }
.layer-aurora .opener::after { background: linear-gradient(90deg, transparent 0 var(--spine), var(--o-557) var(--spine) calc(var(--spine) + 2.8rem), var(--o-630) calc(var(--spine) + 2.8rem) calc(var(--spine) + 4.6rem), var(--n2-428) calc(var(--spine) + 4.6rem) calc(var(--spine) + 6rem), transparent calc(var(--spine) + 6rem)); }

/* --- figures: tables set on the chart's grid ------------------------------ */
figure { margin: var(--space-3) 0 var(--space-4); }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
caption { caption-side: top; text-align: left; padding-bottom: .6rem; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); }
th, td { padding: .55rem .75rem .55rem 0; text-align: left; vertical-align: top; border-bottom: 1px solid var(--rule); }
thead th { font-weight: 500; font-size: .8rem; color: var(--ink-soft); border-bottom-color: var(--grid-strong); }
tbody tr:last-child td { border-bottom: 0; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--ink-strong); font-weight: 400; }
.swatch { display: inline-block; width: 1.4rem; height: 2px; margin: 0 .55rem .3rem 0; vertical-align: middle; }
.swatch-green { background: var(--o-557); }
.swatch-red { background: var(--o-630); }
.swatch-violet { background: var(--n2-428); }
.scale { overflow-x: auto; }
.scale table { min-width: 34rem; }

.sources { padding-top: var(--space-5); }
.sources h2 { margin: 0 0 var(--space-2); font-weight: 500; font-size: 1rem; color: var(--ink-soft); letter-spacing: .02em; }
.sources ul { margin: 0; padding: 0; list-style: none; display: grid; gap: .5rem; font-size: .95rem; }

.foot { border-top: 1px solid var(--rule); padding: var(--space-3) clamp(1rem, 4vw, 3rem) var(--space-4); max-width: 84rem; margin: 0 auto; display: flex; flex-wrap: wrap; justify-content: space-between; gap: .5rem 2rem; font-size: .85rem; color: var(--ink-soft); }
.foot p { margin: 0; }


/* --- the altitude spine: one continuous section from the ground up, broken once ---------- */
.column > .layer, .column > .axis-break { position: relative; }
.column > .layer::before { content: ""; position: absolute; left: var(--spine); top: 0; bottom: 0; width: 1px; background: var(--rule); }
.column > .layer > .opener::before { /* where the trace meets the spine */
  content: ""; position: absolute; left: calc(var(--spine) - 2px); top: -3px; width: 5px; height: 5px; border-radius: 50%; background: var(--o-557);
}
.layer-aurora > .opener::before { background: var(--ink-strong); }
.column > .layer-kp::before, .layer-kp > .opener::before { display: none; }
.axis-break { grid-column: 1 / -1; display: grid; grid-template-columns: subgrid; height: 4.5rem; align-items: center; }
.break-mark { grid-column: 1; position: relative; height: 100%; }
.break-mark::before, .break-mark::after { /* two slashes across the spine: the scale jumps */
  content: ""; position: absolute; left: calc(var(--spine) - 7px); width: 15px; height: 1px; background: var(--ink-soft); transform: rotate(-28deg);
}
.break-mark::before { top: calc(50% - 4px); }
.break-mark::after { top: calc(50% + 4px); }
.break-label { grid-column: 2; font-size: .8rem; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* --- emission figure: wavelength across, height up, on the page's km axis ------------------ */
.emission { max-width: 34rem; }
.emission svg { display: block; width: 100%; height: auto; overflow: visible; }
.em-grid line { stroke: var(--grid-strong); stroke-width: 1; }
.em-axis text { fill: var(--ink-soft); font: 400 12px var(--face); text-anchor: end; font-variant-numeric: tabular-nums; }
.em-label text { fill: var(--ink); font: 400 12px var(--face); text-anchor: middle; font-variant-numeric: tabular-nums; }
.em-line { stroke-width: 2; stroke-linecap: round; }
.em-green { stroke: var(--o-557); }
.em-red { stroke: var(--o-630); }
.em-violet { stroke: var(--n2-428); }
figcaption { margin-top: .6rem; font-size: .8rem; letter-spacing: .04em; color: var(--ink-soft); }
.lines td.num { white-space: normal; }

.flag-close { font: inherit; font-size: .75rem; margin-top: .4rem; display: block; background: none; border: 0; padding: .2rem 0; color: var(--ink-soft); cursor: pointer; text-decoration: underline; text-underline-offset: .2em; }
.flag-close:hover { color: var(--ink); }

/* --- phones: tables become labelled rows ------------------------------------------------ */
@media (max-width: 600px) {
  .lines table, .scale table { min-width: 0; }
  .lines thead, .scale thead { display: none; }
  .em-axis text, .em-label text { font-size: 19px; }  /* the figure scales down ~0.6x on phones */
  .lines tr, .scale tr { display: grid; grid-template-columns: 7.5rem minmax(0, 1fr); column-gap: .75rem; padding: .7rem 0; border-bottom: 1px solid var(--rule); }
  .lines td, .scale td { border: 0; padding: .1rem 0; display: contents; }
  .lines td:first-child, .scale td:first-child { display: block; grid-column: 1 / -1; font-weight: 500; color: var(--ink-strong); padding-bottom: .25rem; }
  .lines td:not(:first-child)::before, .scale td:not(:first-child)::before { content: attr(data-label); font-size: .78rem; color: var(--ink-soft); }
}

/* --- the one authored moment: the sounding draws once ---------------------- */
.js .trace { stroke-dasharray: 1600; stroke-dashoffset: 0; }
.js.sounding-ready .trace { animation: trace 2.4s var(--ease-out) both; }
.js.sounding-ready .trace-x { animation-delay: .35s; }
@keyframes trace { from { stroke-dashoffset: 1600; } to { stroke-dashoffset: 0; } }

/* --- 404 -------------------------------------------------------------------- */
.lost { max-width: 84rem; margin: 0 auto; padding: var(--space-5) clamp(1rem, 4vw, 3rem) var(--space-6); }
.lost h1 { margin: 0 0 var(--space-2); font-weight: 600; font-size: clamp(1.8rem, 4vw, 2.6rem); color: var(--ink-strong); letter-spacing: -.015em; }
.lost p { max-width: var(--measure); }

/* --- narrow: the rail turns into a strip of heights ------------------------ */
@media (max-width: 860px) {
  .sheet { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .rail {
    position: sticky; top: 0; z-index: 5; max-height: none; padding: 0; margin: 0 calc(-1 * clamp(1rem, 4vw, 3rem));
    background: rgba(11, 18, 32, .94); border-bottom: 1px solid var(--rule);
  }
  .rail-title, .tick-name { display: none; }
  .rail-flag { margin: 0; padding: 0 clamp(1rem, 4vw, 3rem) .6rem; display: flex; gap: 1rem; align-items: baseline; }
  .rail-flag[hidden] { display: none; }
  .flag-close { margin-top: 0; }
  .rail-ticks { display: flex; overflow-x: auto; border-left: 0; padding: 0 clamp(1rem, 4vw, 3rem); scrollbar-width: none; }
  .rail-ticks::-webkit-scrollbar { display: none; }
  .rail-ticks a { padding: .7rem .9rem .75rem 0; }
  .rail-ticks a::before { left: 0; top: auto; bottom: 0; width: 0; height: 2px; }
  .rail-ticks a[aria-current="location"]::before { left: 0; width: calc(100% - .9rem); }
  .rail-ticks .km { font-size: .85rem; white-space: nowrap; }
  .rail-gap { margin-top: 0; margin-right: 3rem; }
  .rail-ticks { -webkit-mask-image: linear-gradient(90deg, #000 90%, transparent); mask-image: linear-gradient(90deg, #000 90%, transparent); }
  /* once scrolled away from the ground tick, the start fades too */
  .rail-ticks.is-scrolled { -webkit-mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent); mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent); }
  /* the strip reads left to right from the ground up, the storm scale last */
  .rail-ticks li:nth-child(1) { order: 6; }
  .rail-ticks li:nth-child(2) { order: 5; }
  .rail-ticks li:nth-child(3) { order: 4; }
  .rail-ticks li:nth-child(4) { order: 3; }
  .rail-ticks li:nth-child(5) { order: 2; }
  .rail-ticks li:nth-child(6) { order: 1; }
  .rail-ticks li:nth-child(7) { order: 7; }
  .column { grid-template-columns: minmax(0, 1fr); }
  .column > section > * { grid-column: 1; }
  .column > section > .opener { grid-column: 1; grid-template-columns: minmax(0, 1fr); row-gap: .35rem; }
  .column > section > .opener h2 { grid-row: 1; }
  .alt { grid-row: 2; justify-self: end; }
  .column > .layer::before, .column > .layer > .opener::before { display: none; }
  .axis-break { display: flex; align-items: center; gap: .6rem; height: 3rem; }
  .break-mark { flex: 0 0 15px; height: 1.2rem; }
  .break-mark::before, .break-mark::after { left: 0; }
  .axis-y { top: 40%; bottom: 2.2rem; }
  .axis-y li:nth-child(2), .axis-y li:nth-child(4) { display: none; }
  .opener::after { background: linear-gradient(90deg, var(--o-557) 0 3.5rem, transparent 3.5rem); }
  .layer-aurora .opener::after { background: linear-gradient(90deg, var(--o-557) 0 2.2rem, var(--o-630) 2.2rem 4rem, var(--n2-428) 4rem 5.4rem, transparent 5.4rem); }
  /* the sounding sits under the name on narrow screens instead of crossing it */
  .masthead-inner { min-height: 15rem; }
  .sounding { top: 40%; height: calc(60% - 2.2rem); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .js.sounding-ready .trace { animation: none; }
  *, *::before, *::after { transition-duration: 0s !important; }
}
