/* ------------------------------------------------------------------
   Victorian transmission network, geographic to schematic.
   Voltage hues are the AEMO 2010 diagram's own CMYK strokes,
   converted to RGB.
   ------------------------------------------------------------------ */
:root {
    --kv500: #FFFF00;
    --kv330: #FF7D21;
    --kv275: #9933FF;
    --kv220: #0066FF;
    --kv132: #FF0033;
    --kv66: #430707;

    --ground: #080C12;
    --panel: #0F151D;
    --line: #1E2833;
    --ink: #C8D3DF;
    --ink-dim: #6B7A8C;
    --ink-bright: #F2F6FA;
    --signal: #40E0C0;
    --track: #2A3440;
    /* unfilled slider track */

    --rail-w: 296px;
}

/* the rail folds away: everything placed against it reads --rail-w, so
   zeroing the token on the body moves the map pane, the legend strip,
   the scale bar and the error box over in one go */
body.rail-hidden {
    --rail-w: 0px;
}

body.rail-hidden #rail {
    display: none;
}

#railToggle {
    position: absolute;
    z-index: 6;
    top: 12px;
    left: var(--rail-w);
    width: 20px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--line);
    border-left: 0;
    background: var(--panel);
    color: var(--ink-dim);
    font: 500 15px/1 "Inter", system-ui, sans-serif;
    letter-spacing: 0;
    text-transform: none;
    cursor: pointer;
}

#railToggle:hover {
    color: var(--ink-bright);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0
}

html,
body {
    height: 100%
}

body {
    background: var(--ground);
    color: var(--ink);
    font: 400 14px/1.5 "Inter", system-ui, sans-serif;
    overflow: hidden;
}

#map {
    position: absolute;
    inset: 0;
    bottom: var(--key-h, 36px);
    /* the legend strip's height, measured by app.js */
}

.maplibregl-ctrl-bottom-right,
.maplibregl-ctrl-bottom-left {
    bottom: 0;
    /* the controls live inside #map, which already ends above the strip */
}

.pane .maplibregl-ctrl-bottom-left {
    left: var(--rail-w);
    /* the pane map runs under the rail; its left controls must not */
}

.maplibregl-ctrl-attrib {
    font-size: 10px;
    background: rgba(8, 12, 18, .7) !important
}

.maplibregl-ctrl-attrib a {
    color: var(--ink-dim) !important
}

/* ---------- rail ---------- */
#rail {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--rail-w);
    z-index: 5;
    background: var(--panel);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overscroll-behavior: contain;
}

#rail header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--line)
}

.eyebrow {
    font: 500 10px/1 "Inter", system-ui, sans-serif;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--ink-dim);
    margin-bottom: 8px;
}

h1 {
    font: 600 20px/1.15 "Inter", system-ui, sans-serif;
    letter-spacing: -.02em;
    color: var(--ink-bright);
}

h1 span {
    display: block;
    color: var(--ink-dim);
    font-weight: 400
}

#rail section {
    padding: 18px 20px;
    border-bottom: 1px solid var(--line)
}

#rail section.last {
    border-bottom: 0
}

h2,
details.acc>summary {
    font: 500 10px/1 "Inter", system-ui, sans-serif;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--ink-dim);
    margin-bottom: 14px;
}

/* the ⓘ buttons and their popover: the rule text lives behind them */
.info {
    display: inline-flex;
    width: 14px;
    height: 14px;
    margin-left: 4px;
    border-radius: 50%;
    border: 1px solid var(--ink-dim);
    background: none;
    color: var(--ink-dim);
    font: 600 9px/1 "Inter", system-ui, sans-serif;
    letter-spacing: 0;
    text-transform: none;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    cursor: help;
    padding: 0;
}

.info:hover,
.info.on {
    border-color: var(--ink-bright);
    color: var(--ink-bright);
}

.pop {
    position: fixed;
    z-index: 7;
    max-width: 260px;
    padding: 9px 11px;
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: 0 4px 18px #0008;
    font: 400 11.5px/1.45 "Inter", system-ui, sans-serif;
    color: var(--ink);
    pointer-events: none;
}

.pop b {
    display: block;
    margin-bottom: 3px;
    font-weight: 600;
    color: var(--ink-bright);
}

/* the hazard icon before a card's name, in the ink colour */
.front-name {
    display: flex;
    align-items: center;
}

.front-name .fi {
    width: 15px;
    height: 15px;
    margin-right: 7px;
    stroke: var(--ink);
    fill: var(--ink);
    stroke-width: 1.6;
    stroke-linejoin: round;
}

/* collapsible section: the heading carries a small triangle */
details.acc>summary {
    cursor: pointer;
    list-style: none;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 6px
}

details.acc>summary::-webkit-details-marker {
    display: none
}

details.acc>summary::before {
    content: "";
    width: 0;
    height: 0;
    border-left: 5px solid currentColor;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    transition: transform .15s ease;
}

details.acc[open]>summary::before {
    transform: rotate(90deg)
}

/* ---------- sliders ---------- */
/* one body for every range input: a 2 px track and a thin bar thumb */
input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 22px;
    background: transparent;
    cursor: ew-resize;
}

input[type=range]::-webkit-slider-runnable-track {
    height: 2px;
    background: var(--track);
}

input[type=range]::-moz-range-track {
    height: 2px;
    background: var(--track);
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 2px;
    height: 22px;
    background: var(--ink-bright);
    border: 0;
    border-radius: 0;
    margin-top: -10px;
}

input[type=range]::-moz-range-thumb {
    width: 2px;
    height: 22px;
    background: var(--ink-bright);
    border: 0;
    border-radius: 0;
}

input[type=range]:focus-visible {
    outline: 1px solid var(--signal);
    outline-offset: 4px
}

/* the morph slider alone carries the ramp: map at the left, sheet at the right */
#t::-webkit-slider-runnable-track {
    background: linear-gradient(90deg, var(--kv220), var(--signal))
}

#t::-moz-range-track {
    background: linear-gradient(90deg, var(--kv220), var(--signal))
}

/* buffer sliders: a neutral fill up to the value (the fill is the distance);
   time sliders: a progress fill in the signal colour. --p is the slider's
   position as a percentage, set by weather.js. */
input.fill-neutral,
input.fill-progress {
    --p: 0%;
    --fill: var(--ink-dim)
}

input.fill-progress {
    --fill: var(--signal)
}

input.fill-neutral::-webkit-slider-runnable-track,
input.fill-progress::-webkit-slider-runnable-track {
    background: linear-gradient(90deg, var(--fill) 0 var(--p), var(--track) var(--p) 100%)
}

input.fill-neutral::-moz-range-track,
input.fill-progress::-moz-range-track {
    background: linear-gradient(90deg, var(--fill) 0 var(--p), var(--track) var(--p) 100%)
}

/* ---------- the time scrubber ---------- */
/* a full width slider with the current time in a bubble riding the thumb,
   tick marks beneath (the chart times for a front, six hourly for a storm)
   and the play button at the right. --p is the thumb position, set by
   sliderFill on the track wrapper as well as the input. */
.scrub {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 30px;
    /* room for the bubble above the track */
}

.scrub-track {
    position: relative;
    flex: 1;
    min-width: 0;
    --p: 0%;
}

.scrub-track input[type=range] {
    display: block;
    margin: 0;
    height: 16px;
}

/* a shorter thumb on the scrubber and the buffer, so the weather cards'
   sliders match; the morph slider keeps the tall one */
.scrub-track input[type=range]::-webkit-slider-thumb,
.buffer input[type=range]::-webkit-slider-thumb {
    height: 14px;
    margin-top: -6px;
}

.scrub-track input[type=range]::-moz-range-thumb,
.buffer input[type=range]::-moz-range-thumb {
    height: 14px
}

.bubble {
    position: absolute;
    bottom: 100%;
    /* rides the thumb, but slides under itself at the ends so a wide
       bubble (a date and a time) never leaves the track */
    left: var(--p);
    transform: translateX(calc(-1 * var(--p)));
    margin-bottom: 4px;
    padding: 3px 7px;
    background: var(--line);
    color: var(--ink-bright);
    font: 500 11px/1.2 "Inter", system-ui, sans-serif;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    pointer-events: none;
}

.bubble::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -4px;
    border: 4px solid transparent;
    border-top-color: var(--line);
}

/* the ticks sit on the track itself, crossing it, with the labels beneath;
   the box overlaps the slider, so it must not catch the pointer */
.ticks {
    position: relative;
    height: 22px;
    margin-top: -11px;
    pointer-events: none;
    font: 400 9.5px/1 "Inter", system-ui, sans-serif;
    font-variant-numeric: proportional-nums;
    /* tabular digits spread the short labels */
    color: var(--ink-dim);
}

.tick {
    position: absolute;
    top: 0;
    width: 1px;
    height: 7px;
    background: var(--ink-dim);
    transform: translateX(-50%);
}

/* minor ticks: shorter and fainter, never labelled */
.tick.minor {
    top: 1.5px;
    height: 4px;
    opacity: .55
}

.tick-label {
    position: absolute;
    top: 11px;
    white-space: nowrap;
    transform: translateX(-50%);
}

.tick-label.first {
    transform: none
}

.tick-label.last {
    transform: translateX(-100%)
}

.play {
    flex: 0 0 auto;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--signal);
    color: var(--ground);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* the buffer: value above, full width slider, range beneath at the right */
.buffer {
    display: block;
    margin-top: 10px;
    font-size: 12px;
}

.buffer-label {
    display: block;
    margin-bottom: 2px
}

.buffer input[type=range] {
    height: 16px
}

.buffer-max {
    display: block;
    text-align: right;
    font-size: 10px;
    color: var(--ink-dim);
    margin-top: -2px;
}

.picker {
    display: block;
    font-size: 12px;
    font-style: italic;
}

.picker select {
    font-style: normal
}

/* the stretch lens: a band slider made of two stacked range inputs */
.lens-f {
    display: block;
    font-size: 12px;
    color: var(--ink-dim);
    margin-top: 10px
}

.dual-label {
    font-size: 12px;
    margin: 8px 0 2px;
    color: var(--ink-dim)
}

.dual {
    position: relative;
    height: 26px
}

.dual::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 12px;
    height: 2px;
    background: var(--track);
}

.dual-fill {
    position: absolute;
    top: 12px;
    height: 2px;
    background: var(--signal);
    left: 35%;
    right: 35%;
}

.dual input {
    position: absolute;
    left: 0;
    top: 2px;
    width: 100%;
    pointer-events: none;
}

.dual input::-webkit-slider-runnable-track {
    background: transparent
}

.dual input::-moz-range-track {
    background: transparent
}

.dual input::-webkit-slider-thumb {
    pointer-events: auto
}

.dual input::-moz-range-thumb {
    pointer-events: auto
}

/* ---------- morph control ---------- */
/* the percentage rides in the heading, small; the two views are one segmented control under the slider */
.h2-note {
    margin-left: 6px;
    font-weight: 400;
    letter-spacing: .04em;
    text-transform: none;
    color: var(--ink-dim);
    font-variant-numeric: tabular-nums;
}

.btnrow.seg {
    gap: 2px;
    padding: 2px;
    border: 1px solid var(--line);
}

.btnrow.seg button {
    border: 0;
}

/* ---------- buttons and checks ---------- */
.btnrow {
    display: flex;
    gap: 6px;
    margin-top: 10px
}

button {
    flex: 1;
    padding: 7px 0;
    background: transparent;
    color: var(--ink-dim);
    border: 1px solid var(--line);
    cursor: pointer;
    font: 500 10px/1 "Inter", system-ui, sans-serif;
    letter-spacing: .1em;
    text-transform: uppercase;
}

button:hover {
    color: var(--ink-bright);
    border-color: var(--ink-dim)
}

button:focus-visible {
    outline: 1px solid var(--signal);
    outline-offset: 2px
}

button[aria-pressed=true] {
    color: var(--ground);
    background: var(--signal);
    border-color: var(--signal)
}

/* parked controls: visible, so the panel still reads as a whole, but inert */
button:disabled {
    opacity: .4;
    cursor: not-allowed
}

button:disabled:hover {
    color: var(--ink-dim);
    border-color: var(--line)
}

button[aria-pressed=true]:disabled:hover {
    color: var(--ground);
    border-color: var(--signal)
}

input[type=range]:disabled {
    cursor: not-allowed;
    opacity: .4
}

input[type=range]:disabled::-webkit-slider-thumb {
    background: var(--ink-dim)
}

input[type=range]:disabled::-moz-range-thumb {
    background: var(--ink-dim)
}

label.check {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 5px 0;
    cursor: pointer;
    font-size: 13px;
}

label.check input {
    accent-color: var(--signal);
    width: 13px;
    height: 13px
}

select {
    width: 100%;
    font: inherit;
    font-size: 12px;
    color: var(--ink);
    background: var(--panel);
    border: 1px solid var(--line);
    padding: 4px 6px;
    margin-top: 4px;
}

/* ---------- weather front cards ---------- */
/* each front is a card: its name and an on/off switch in the header, its
   controls beneath while on; the left edge carries the front's colour */
.front-card {
    border: 1px solid var(--line);
    border-left: 3px solid var(--front-colour, var(--ink-dim));
    padding: 10px 12px 12px;
    margin-top: 10px;
}

.front-head {
    display: flex;
    align-items: center;
    justify-content: space-between
}

.front-name {
    font: 500 10px/1 "Inter", system-ui, sans-serif;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--ink);
}

.front-body {
    margin-top: 10px
}

.front-card.off .front-body {
    display: none
}

.switch {
    position: relative;
    width: 30px;
    height: 16px;
    display: inline-block;
    cursor: pointer
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute
}

.switch .knob {
    position: absolute;
    inset: 0;
    border-radius: 8px;
    background: var(--track);
    transition: background .15s
}

.switch .knob::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--ink-bright);
    transition: transform .15s;
}

.switch input:checked+.knob {
    background: var(--front-colour, var(--signal))
        /* a front's switch takes the front's colour */
}

.switch input:checked+.knob::after {
    transform: translateX(14px)
}

/* ---------- hover card ---------- */
#tip {
    position: absolute;
    z-index: 6;
    pointer-events: none;
    display: none;
    background: var(--panel);
    border: 1px solid var(--line);
    padding: 9px 11px;
    max-width: 250px;
}

#tip h3 {
    font: 600 13px/1.2 "Inter", system-ui, sans-serif;
    color: var(--ink-bright);
    margin-bottom: 3px;
}

#tip dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 9px;
    font: 400 11.5px/1.4 "Inter", system-ui, sans-serif;
    font-variant-numeric: tabular-nums;
}

#tip dt {
    color: var(--ink-dim)
}

/* the hazard row: one icon per front that is on, in the halo's language */
#tip .hz-row {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--line);
}

#tip .hz-ico {
    width: 20px;
    height: 20px;
    stroke-width: 1.6;
    stroke-linejoin: round;
}

#tip .hz-ico.none,
#tip .hz-ico.off {
    stroke: var(--track);
    fill: none;
}

/* nothing from this hazard, or the front is off */
#tip .hz-ico.next {
    stroke: var(--ink-bright);
    fill: none;
}

/* the ring: coming within the look ahead */
#tip .hz-ico.on {
    stroke: var(--ink-bright);
    fill: var(--ink-bright);
}

/* the band: on the line */
#tip .hz-ico.past {
    stroke: var(--ink-dim);
    fill: var(--ink-dim);
}

/* easing back */

/* ---------- the geographic window ---------- */
/* two maps, one pane and one floating frame: whichever map has the pane
   class fills the pane, whichever has win sits in the frame (its box is
   set inline by layoutWindow in app.js) */
#map.pane,
#miniMap.pane {
    position: absolute;
    inset: 0;
    bottom: var(--key-h, 36px);
    z-index: 0;
}

#miniMap {
    display: none;
}

#miniMap.on {
    display: block;
}

#map.win,
#miniMap.win {
    position: absolute;
    inset: auto;
    z-index: 6;
}

/* the frame: a title bar above the map and a grip at its corner; the rest
   lets the pointer through to the map */
#float {
    position: absolute;
    z-index: 7;
    pointer-events: none;
    border: 1px solid var(--line);
    box-shadow: 0 4px 18px #0008;
    box-sizing: border-box;
}

#float .fl-bar {
    pointer-events: auto;
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 26px;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 6px 0 10px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    cursor: grab;
    font-size: 10px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--ink-dim);
    user-select: none;
}

body.fl-dragging,
body.fl-dragging * {
    cursor: grabbing !important;
}

#float .fl-title {
    color: var(--ink-bright);
    font-weight: 600;
}

#float .fl-clock {
    text-transform: none;
    letter-spacing: 0;
    font-size: 11px;
}

#float .fl-sp {
    flex: 1;
}

#float .fl-bar button {
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid var(--line);
    border-radius: 3px;
    color: var(--ink);
    font: 12px/1 Inter, system-ui, sans-serif;
    letter-spacing: 0;
    text-transform: none;
    cursor: pointer;
}

#float .fl-bar button:hover {
    color: var(--ink-bright);
    border-color: var(--ink-dim);
}

#float .fl-grip {
    pointer-events: auto;
    position: absolute;
    right: 0;
    bottom: 0;
    width: 14px;
    height: 14px;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 50%, var(--ink-dim) 50%, var(--ink-dim) 58%, transparent 58%, transparent 72%, var(--ink-dim) 72%, var(--ink-dim) 80%, transparent 80%);
}

/* ---------- map controls ---------- */
/* the fit button rides under the zoom buttons in the map's own control group */
.maplibregl-ctrl button.ctrl-fit {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    text-transform: none;
    letter-spacing: 0;
}

/* the scale bar: the distance above a bracket with end ticks, in the
   page's ink; fades with the morph since the diagram has no scale */
.scalebar {
    margin: 0 0 10px 14px !important;
    font: 400 10px/1 "Inter", system-ui, sans-serif;
    font-variant-numeric: tabular-nums;
    letter-spacing: .04em;
    color: var(--ink);
    transition: opacity .2s;
    pointer-events: none;
}

.scalebar-label {
    display: block;
    margin-bottom: 3px;
}

.scalebar-bar {
    height: 6px;
    border: 1px solid var(--ink);
    border-top: 0;
    box-sizing: border-box;
}

/* ---------- legend strip ---------- */
/* a strip docked along the bottom of the map pane, in the manner of the
   AEMO sheet's key: one line with a KEY tab, the voltages and, while a
   front is on, the weather key. The symbol rows fold up above the strip
   when the tab is open. The map pane ends above the strip (--key-h,
   measured by app.js), so nothing on the map is ever under it. */
#legendBar {
    position: absolute;
    left: var(--rail-w);
    right: 0;
    bottom: 0;
    z-index: 4;
    display: flex;
    flex-direction: column;
    background: var(--panel);
    border-top: 1px solid var(--line);
    font: 400 11.5px/1 "Inter", system-ui, sans-serif;
    font-variant-numeric: tabular-nums;
    color: var(--ink-dim);
}

#legendBar .key-main {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    /* a narrow window wraps the weather key under the voltages */
    gap: 6px 0;
    min-height: 36px;
    padding: 0 16px;
}

/* the tab that folds the symbol rows out: the first thing on the strip */
#legendBar .key-tab {
    flex: 0 0 auto;
    margin-right: 16px;
    padding: 4px 8px;
    border: 1px solid var(--line);
    background: none;
    color: var(--ink-dim);
    font: 500 9.5px/1 "Inter", system-ui, sans-serif;
    letter-spacing: .12em;
    text-transform: uppercase;
    cursor: pointer;
}

#legendBar .key-tab:hover,
#legendBar.open .key-tab {
    color: var(--ink-bright);
    border-color: var(--ink-dim);
}

/* the symbol row: one line under the voltages, only while the tab is
   open; the strip grows and the map pane shrinks to match */
#legendBar .key-more {
    display: none;
    padding: 2px 16px 8px calc(16px + var(--tab-w, 52px) + 16px);
    min-height: 30px;
    align-items: center;
}

#legendBar.open .key-more {
    display: flex;
}

#legendBar .row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    align-items: center;
}


#legendBar .item {
    display: flex;
    align-items: center;
    white-space: nowrap
}

#legendBar .sw {
    display: inline-block;
    width: 26px;
    height: 0;
    border-top: 3px solid currentColor;
    vertical-align: middle;
    margin-right: 6px;
}

#legendBar .sw.dashed {
    border-top-style: dashed
}

/* a voltage in the key is a switch: the strip ignores the pointer, the switches take it */
#legendBar .toggle {
    pointer-events: auto;
    cursor: pointer;
    background: none;
    border: 0;
    padding: 0;
    margin: 0;
    flex: 0 0 auto;
    font: inherit;
    color: inherit;
    text-transform: none;
    /* the rail's buttons are uppercase; the key is not */
    letter-spacing: 0;
    display: flex;
    align-items: center;
    white-space: nowrap;
}

#legendBar .toggle:hover {
    color: var(--ink);
}

#legendBar .toggle.off {
    opacity: .55;
}

#legendBar .toggle.off .sw {
    color: #39414A !important;
    /* the switched off grey, as on the map */
}

#legendBar .toggle.off .sym {
    opacity: .5;
    /* a switched off symbol kind dims, as on the map */
}

/* the line has two halves: the network key (the voltages) and, while a
   front is on, the weather key to its right behind a divider, under a
   small heading, all on the same line */
#legendBar .net-key {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
}

#legendBar .hz-key {
    display: none;
    flex: 0 0 auto;
    align-items: center;
    gap: 12px;
    margin-left: 16px;
    padding-left: 16px;
    border-left: 1px solid var(--line);
    min-height: 22px;
}

#legendBar.weather .hz-key {
    display: flex
}

#legendBar .hz-head {
    font: 500 9.5px/1 "Inter", system-ui, sans-serif;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--ink-dim);
    margin-right: 2px;
}

/* each card's one line source link, in place of a caption; the sentence lives behind the card's ⓘ */
.source {
    display: inline-block;
    margin-top: 10px;
    font: 400 10.5px/1 "Inter", system-ui, sans-serif;
    letter-spacing: .04em;
    color: var(--ink-dim);
    text-decoration: none;
}

.source:hover {
    color: var(--ink);
}

#legendBar .hz {
    margin-right: 6px;
    color: var(--kv220);
    vertical-align: middle;
}

#legendBar .hz-item {
    color: var(--ink-dim);
}

#legendBar .sym {
    width: 18px;
    height: 18px;
    margin-right: 6px;
    filter: invert(1);
    /* the symbol files are black */
}


/* ---------- failure ---------- */
#err {
    position: absolute;
    z-index: 30;
    inset: auto 20px 20px calc(var(--rail-w) + 20px);
    background: var(--panel);
    border: 1px solid var(--kv132);
    padding: 14px 16px;
    color: var(--ink);
    font-size: 13px;
    line-height: 1.45;
}

#err[hidden] {
    display: none
}

#err b {
    display: block;
    color: var(--kv132);
    font: 500 11px/1 "Inter", system-ui, sans-serif;
    letter-spacing: .1em;
    text-transform: uppercase;
    margin-bottom: 6px;
}

#err p {
    margin-top: 8px;
    color: var(--ink-dim)
}

#err code {
    font: 400 12px ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--ink-bright);
    background: #0A0F16;
    padding: 1px 4px;
}

/* ---------- light basemaps ---------- */
body[data-basemap=light],
body[data-basemap=streets] {
    --ground: #EEF1F4;
    --panel: #F7F9FB;
    --line: #D3DBE3;
    --ink: #26313D;
    --ink-dim: #54646F;
    --ink-bright: #121A22;
    --track: #CFD6DD;
}

body[data-basemap=light] #legendBar,
body[data-basemap=light] #legendBar .key-more,
body[data-basemap=streets] #legendBar,
body[data-basemap=streets] #legendBar .key-more {
    background: var(--panel)
}

body[data-basemap=light] #legendBar .sym,
body[data-basemap=streets] #legendBar .sym {
    filter: none
}

/* ---------- narrow ---------- */
@media (max-width:720px) {
    #rail {
        width: 100%;
        height: 47%;
        bottom: auto;
        border-right: 0;
        border-bottom: 1px solid var(--line)
    }

    #map {
        top: 47%
    }

    #err {
        inset: auto 12px 12px 12px
    }

    #legendBar {
        left: 0
    }
}

@media (prefers-reduced-motion:reduce) {
    * {
        transition: none !important;
        animation: none !important
    }
}

/* ---------- diagram matching report ---------- */
.diag p {
    font-size: 11.5px;
    line-height: 1.4;
    color: var(--ink-dim);
    margin-bottom: 8px
}