/*
 * panels.css
 *
 * The dashboard panels: where they sit, what they are made of, and how the
 * charts inside them are painted. Loaded after globe.css, which is where the
 * palette, the two typefaces and the globe stage itself are defined.
 *
 * The layout has exactly two states, and the screen chooses between them:
 *
 *   Wider than it is high   three panels down the left edge and three down the
 *                           right, each a third of the page wide and a third of
 *                           it high, over the outer thirds of the page.
 *
 *   Higher than it is wide  one strip along the bottom, a third of the page
 *                           high, scrolling left and right through all six.
 *
 * Nothing in JavaScript measures the window to decide that. The two aspect
 * ratio media queries below are the whole mechanism.
 *
 * The panels float over the globe rather than taking space from it, and nothing
 * here touches --globe-stage-width or --globe-stage-height. That is deliberate.
 * globe.js refits the planet to its container, so handing it a third of the page
 * would take the planet from 495 pixels across to 293 on a 1600 by 900 screen:
 * the Panels button would be a zoom control as well as a switch, and it would
 * throw away whatever zoom had been set by hand. Left alone, toggling the panels
 * changes nothing whatsoever about the globe's size. In portrait it is lifted,
 * which is a move and not a resize; see the rule for that below.
 *
 * What that costs is on landscape screens near square. The middle column is a
 * third of the page wide and the planet is 0.55 of the page's tighter dimension
 * across, so a screen wider than about 1.65:1 has the planet sitting inside that
 * column with room to spare, and anything squarer has its edge pass behind the
 * rails. A planet partly behind a panel is a dashboard; a planet that changes
 * size when a button is pressed is a bug.
 *
 * Portrait has no such trade, because of the lift. The planet is 0.55 of the
 * width there and the room above the strip is two thirds of the height, and the
 * width is the smaller of the two on any portrait screen, so it always clears.
 *
 * The panels are also switched off entirely by the Panels button, which puts
 * data-panels="off" on the body. In that state nothing here applies at all.
 */

/*
 * The status ramp for the choke point panel. Three steps, ordered by severity,
 * and separate from anything else on the page: a status colour means a state
 * and is never reused to tell one series apart from another.
 *
 * The pair that decides whether a ramp like this works is amber against green,
 * because that is the one red-green colour blindness collapses first. These
 * three were checked rather than picked: the closest pair separates by dE 8.0
 * under protanopia, and all three clear 3:1 contrast against the panel
 * background. Even so, every row that uses them also writes its state out as a
 * word, so the colour is the second thing carrying the reading rather than the
 * only thing.
 */
:root {
    --status-clear: #17c96b;
    --status-busy: #ffcf5c;
    --status-critical: #ff5555;
}

/* ------------------------------------------------------------------
 * Layout: portrait, and any screen that is not wider than it is high
 *
 * This is the base state, matching the resume's own mobile-first
 * stylesheet: the narrow layout is written plainly and the wide one is
 * the media query.
 * ------------------------------------------------------------------ */

/*
 * The strip covers the bottom third, so the middle of the window is no longer
 * the middle of what can be seen: a planet centred in the window sits with its
 * lower edge against the top of the strip. The stage is lifted to put the
 * planet back in the space that is left.
 *
 * A sixth of the page would centre it exactly in that space, at a third of the
 * way down. It sits a quarter of the way up instead, which is three quarters of
 * that: high enough to be clear of the strip and out of the way of the control
 * bar, and low enough not to look like it is being pushed off the top.
 *
 * This is a move and not a resize. The stage keeps its full height, so the
 * planet keeps its size and whatever zoom was set by hand, which is the whole
 * point of the panels not touching the stage variables. Relative positioning
 * rather than a negative margin, so there is no chance of the margin collapsing
 * through the body and taking the rest of the page with it.
 */
body[data-panels="on"] #globe-stage {
    top: -12.5vh;
}

@supports (height: 100dvh) {
    body[data-panels="on"] #globe-stage {
        top: -12.5dvh;
    }
}

#panel-region {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: 33.3333vh;
    z-index: 1;

    display: flex;
    flex-direction: row;
    gap: 8px;
    padding: 8px;

    /*
     * The strip scrolls sideways through all six panels. Snapping makes a flick
     * land on a panel rather than halfway between two, which on a tile carrying
     * a chart is the difference between reading it and nearly reading it.
     */
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;

    /*
     * The strip can be thrown with the mouse as well as with a finger, so it
     * says so. panels.js handles the drag itself, since a mouse has no native
     * way to drag a scroll container, and swaps this for the closed hand while
     * one is in progress.
     */
    cursor: grab;
}

#panel-region.is-dragging {
    cursor: grabbing;

    /*
     * A drag across a chart would otherwise sweep up the text in it and leave
     * the panel highlighted. Applied only while dragging, so text in a panel
     * can still be selected the rest of the time.
     */
    -webkit-user-select: none;
    user-select: none;
}

@supports (height: 100dvh) {
    #panel-region {
        height: 33.3333dvh;
    }
}

body[data-panels="off"] #panel-region {
    display: none;
}

#panel-region > .panel {
    /*
     * Not quite the full width: the sliver of the next panel showing past the
     * right edge is what says the strip scrolls at all. A panel that exactly
     * filled the screen would look like the only one there is.
     */
    flex: 0 0 calc(100% - 46px);
    scroll-snap-align: start;
}

/*
 * A thin scrollbar in the page's own greens rather than the platform's default
 * grey slab, which on a black page reads as a piece of another application.
 */
#panel-region {
    scrollbar-width: thin;
    scrollbar-color: var(--accent-dim) transparent;
}

#panel-region::-webkit-scrollbar {
    height: 6px;
}

#panel-region::-webkit-scrollbar-track {
    background: transparent;
}

#panel-region::-webkit-scrollbar-thumb {
    background: var(--accent-dim);
    border-radius: 3px;
}

/* ------------------------------------------------------------------
 * Layout: screens wider than they are high
 * ------------------------------------------------------------------ */

@media (min-aspect-ratio: 1/1) {

    /*
     * Nothing is covering the bottom of the page in this layout, so the planet
     * goes back to the middle of the window, which is also the middle of the
     * gap between the two rails.
     */
    body[data-panels="on"] #globe-stage {
        top: 0;
    }

    /*
     * The control bar is a third of the page wide and sits over the same middle
     * column the globe does, so it is squared off with the rails either side of
     * it: 8px is the panel region's padding, and therefore the distance from the
     * top of the page to the top of the first panel in each rail. The bar's top
     * edge lands on the same line.
     *
     * It is set here rather than in globe.css because this is the file that
     * knows what the panels are doing. Both rules name the same element at the
     * same specificity and this file is loaded second, so this one wins.
     */
    #globe-controls {
        top: 8px;
    }

    #panel-region {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        height: auto;

        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        grid-template-rows: 1fr 1fr 1fr;
        gap: 8px;
        padding: 8px;
        overflow: visible;

        /*
         * Nothing scrolls in the rail layout: the six panels are a grid that
         * fits the page exactly. The grab cursor from the strip would be a
         * promise there is nothing behind.
         */
        cursor: default;

        /*
         * The grid covers the whole page so that its outer columns land exactly
         * on the outer thirds, which means the empty middle column is lying
         * over the globe. Letting it take pointer events there would kill
         * dragging and zooming across the entire planet, so the region takes
         * none and the panels take their own back.
         */
        pointer-events: none;
    }

    #panel-region > .panel {
        pointer-events: auto;
        flex: none;
    }

    /*
     * Panels 1 to 3 fill the left column top to bottom, 4 to 6 the right. The
     * placement is by position in the source order, so reordering
     * DASHBOARD_PANELS reorders the rails and nothing here has to change.
     */
    #panel-region > .panel:nth-child(1) {
        grid-column: 1;
        grid-row: 1;
    }

    #panel-region > .panel:nth-child(2) {
        grid-column: 1;
        grid-row: 2;
    }

    #panel-region > .panel:nth-child(3) {
        grid-column: 1;
        grid-row: 3;
    }

    #panel-region > .panel:nth-child(4) {
        grid-column: 3;
        grid-row: 1;
    }

    #panel-region > .panel:nth-child(5) {
        grid-column: 3;
        grid-row: 2;
    }

    #panel-region > .panel:nth-child(6) {
        grid-column: 3;
        grid-row: 3;
    }

}

/* ------------------------------------------------------------------
 * The panel itself
 *
 * The resume's document panel is a dark warm panel colour inside a heavy green
 * rule, with a lighter elevated strip for its chrome and a VT323 tag naming the
 * section. A panel here is that shape at tile size: the same two backgrounds,
 * the same tag face, and a quieter border, because six of them at the resume's
 * 4px bright green would be six rectangles competing with the planet between
 * them.
 * ------------------------------------------------------------------ */

.panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;

    background: var(--bg-panel);
    border: 2px solid var(--accent-dim);
    border-radius: 4px;
    font-family: var(--font-mono);
    color: var(--text-primary);
}

.panel-head {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 5px 10px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-subtle);
}

/*
 * The muted text on a panel - the index in the head, the caption under a
 * headline reading, the source line in the foot - is the secondary text colour
 * held back with opacity, rather than the palette's dim green.
 *
 * The resume uses that dim green for its own muted text and it works there, at
 * 16px in a wide column. At 10px on the panel background it lands near 2:1
 * against it, which is under any threshold worth quoting and legible mostly to
 * somebody who already knows what it says.
 */
.panel-index {
    flex: none;
    font-size: 11px;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
    opacity: 0.55;
}

.panel-title {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    font-family: var(--font-console);
    font-size: 20px;
    line-height: 1.1;
    letter-spacing: 2px;
    color: var(--accent-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/*
 * SAMPLE against LIVE. It is meant to be read: the numbers under a SAMPLE badge
 * are invented, and a tile that shows invented numbers without saying so is
 * worse than an empty one.
 */
.panel-status {
    flex: none;
    padding: 1px 6px;
    border: 1px solid var(--accent-dim);
    border-radius: 2px;
    font-size: 9px;
    letter-spacing: 0.14em;
    color: var(--text-secondary);
}

.panel-status[data-status="sample"] {
    border-color: var(--status-busy);
    color: var(--status-busy);
}

.panel-status[data-status="live"] {
    border-color: var(--status-clear);
    color: var(--status-clear);
}

/*
 * Two ages after the LIVE badge: how long since the feed was fetched, and how
 * old the reading in it actually is. Deliberately quieter than the badge and
 * unboxed - the badge is a claim about what kind of number this is, the ages
 * are details about it, and giving all three the same weight would make the
 * head read as three competing labels.
 *
 * The label sits above the value rather than beside it. Beside it, the pair
 * came to about 55px each and two of them crowded the title off a 500px panel;
 * stacked, they are 26px wide and the head is no taller, because the title
 * beside them is taller than both lines together.
 *
 * A SAMPLE panel has no age elements at all, so nothing here needs to hide any.
 */
.panel-age {
    flex: none;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    align-self: center;
    line-height: 1.1;
}

.panel-age-label {
    font-size: 7px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text-secondary);
    opacity: 0.45;
}

.panel-age-value {
    font-size: 10px;
    letter-spacing: 0.02em;
    color: var(--text-secondary);
    opacity: 0.8;
    font-variant-numeric: tabular-nums;
}

.panel-body {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 10px;
    overflow: hidden;
}

.panel-foot {
    flex: none;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding: 3px 10px 4px 10px;
    border-top: 1px solid var(--border-subtle);
    font-size: 10px;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    opacity: 0.6;
}

.panel-source,
.panel-note {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.panel-note {
    text-align: right;
}

/*
 * The source credit, which is a link to how that service documents its feed.
 *
 * The foot is already the quietest part of the panel, at 60% opacity, and the
 * credit is deliberately not lifted out of it: it is an acknowledgement rather
 * than a call to action, and a bright link along the bottom of six tiles would
 * pull the eye away from the numbers the tiles exist for. It reads as text
 * until it is pointed at.
 *
 * The dotted underline is what marks it as followable at rest, at a weight that
 * survives the opacity above without competing with anything.
 */
.panel-source-link {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px dotted currentColor;
    transition: color 120ms ease;
}

/*
 * Gated for the same reason every other hover on this page is: a touchscreen
 * emulates hover and leaves it stuck on whatever was last tapped.
 */
@media (hover: hover) {
    .panel-source-link:hover {
        color: var(--accent-secondary);
    }
}

.panel-source-link:focus-visible {
    outline: 1px solid var(--accent-secondary);
    outline-offset: 2px;
}

.panel-source-separator {
    opacity: 0.7;
}

/* ------------------------------------------------------------------
 * The headline reading at the top of a panel
 * ------------------------------------------------------------------ */

.panel-hero {
    flex: none;
}

.panel-hero-line {
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
}

.panel-hero-value {
    font-size: clamp(22px, 4.2vh, 38px);
    font-weight: 700;
    line-height: 1.05;
    letter-spacing: 0.02em;
    color: var(--text-primary);
}

.panel-hero-unit {
    font-size: 11px;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.panel-hero-caption {
    margin-top: 2px;
    font-size: 10px;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    opacity: 0.6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ------------------------------------------------------------------
 * Indicator rows: a reading and its sparkline, side by side
 *
 * Two of these in the greenhouse gas panel and four in the resource panel, in
 * boxes of the same height, so the rows share the space rather than being sized
 * for either case.
 * ------------------------------------------------------------------ */

.panel-body-rows {
    justify-content: space-around;
}

.indicator-row {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 0;
    flex: 1 1 auto;
}

.indicator-reading {
    flex: 0 0 46%;
    min-width: 0;
}

.indicator-label {
    font-size: 11px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--accent-primary);
}

.indicator-value-line {
    display: flex;
    align-items: baseline;
    gap: 5px;
    min-width: 0;
}

.indicator-value {
    font-size: clamp(16px, 2.6vh, 24px);
    font-weight: 700;
    line-height: 1.15;
    color: var(--text-primary);
}

.indicator-unit {
    font-size: 10px;
    color: var(--text-secondary);
    white-space: nowrap;
}

/*
 * The delta is plain text in the ordinary muted colour, with no arrow and no
 * red or green on it. Which direction is the bad one is not the dashboard's
 * call to make: a rising wheat price and a rising methane concentration are not
 * the same kind of fact, and colouring both as alarm would be the editorial
 * layer these feeds were chosen for not having.
 */
.indicator-delta {
    margin-top: 1px;
    font-size: 10px;
    letter-spacing: 0.02em;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ------------------------------------------------------------------
 * Chart hosts
 *
 * A host is measured by panels.js and its SVG is built at that exact pixel
 * size, so the box is the chart's authority on how big it is. It is
 * position: relative because the tooltip is placed inside it.
 * ------------------------------------------------------------------ */

.chart-host {
    position: relative;
    min-width: 0;
    min-height: 0;
}

.chart-host-sparkline {
    flex: 1 1 auto;
    align-self: stretch;
    max-height: 64px;
}

.chart-host-plot {
    flex: 1 1 auto;
}

.chart-host svg {
    display: block;
}

/* ------------------------------------------------------------------
 * Chart marks
 *
 * Thin marks, recessive grid, and text in text colours rather than in the
 * colour of the thing it labels.
 * ------------------------------------------------------------------ */

.chart-line {
    fill: none;
    stroke: var(--accent-secondary);
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.chart-area {
    fill: var(--accent-primary);
    fill-opacity: 0.13;
    stroke: none;
}

.chart-end-dot {
    fill: var(--accent-secondary);
}

.chart-grid-line {
    stroke: var(--border-subtle);
    stroke-width: 1;
    stroke-opacity: 0.6;
}

.chart-axis-label {
    fill: var(--text-secondary);
    fill-opacity: 0.75;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.04em;
}

.chart-bar-value {
    fill: var(--text-primary);
    fill-opacity: 0.9;
}

.chart-bar {
    fill: var(--accent-primary);
    fill-opacity: 0.85;
    transition: fill-opacity 120ms ease;
}

.chart-bar.is-hovered {
    fill: var(--accent-secondary);
    fill-opacity: 1;
}

.chart-crosshair {
    stroke: var(--accent-secondary);
    stroke-width: 1;
    stroke-dasharray: 3 3;
    opacity: 0;
}

.chart-crosshair.is-visible {
    opacity: 0.7;
}

/*
 * The focus dot carries a 2px ring in the panel's own background colour, so it
 * stays a distinct object where it lands on top of the line it belongs to
 * rather than merging into it.
 */
.chart-focus-dot {
    fill: var(--text-primary);
    stroke: var(--bg-panel);
    stroke-width: 2;
    opacity: 0;
}

.chart-focus-dot.is-visible {
    opacity: 1;
}

.chart-tooltip {
    position: absolute;
    left: 0;
    top: 0;
    z-index: 2;
    padding: 3px 7px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 1.3;
    color: var(--text-primary);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 100ms ease;
}

.chart-tooltip.is-visible {
    opacity: 1;
}

/* ------------------------------------------------------------------
 * The event ticker
 * ------------------------------------------------------------------ */

.panel-body-ticker {
    gap: 4px;
}

.ticker-list {
    flex: 1 1 auto;
    min-height: 0;
    margin: 0;
    padding: 0;
    list-style: none;
    overflow: hidden;
}

.ticker-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
    border-bottom: 1px dotted var(--border-subtle);
    font-size: 11px;
}

.ticker-item:last-child {
    border-bottom: none;
}

.ticker-magnitude {
    flex: none;
    width: 38px;
    font-weight: 700;
    color: var(--text-primary);
}

/*
 * The bar is measured against a fixed ceiling of magnitude 8 rather than
 * against the largest event on the list, so a quiet day reads as a quiet day
 * instead of looking exactly like every other day.
 */
.ticker-bar-track {
    flex: none;
    width: 46px;
    height: 6px;
    background: var(--bg-elevated);
    border-radius: 3px;
    overflow: hidden;
}

.ticker-bar-fill {
    display: block;
    height: 100%;
    background: var(--accent-primary);
    border-radius: 0 3px 3px 0;
}

.ticker-place {
    flex: 1 1 auto;
    min-width: 0;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ticker-age {
    flex: none;
    color: var(--text-secondary);
    opacity: 0.6;
    white-space: nowrap;
}

/* ------------------------------------------------------------------
 * Status bars
 * ------------------------------------------------------------------ */

.panel-body-status {
    justify-content: space-between;
    gap: 4px;
}

.status-heading {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
    margin-bottom: 3px;
    font-size: 11px;
}

.status-label {
    flex: 1 1 auto;
    min-width: 0;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.status-value {
    flex: none;
    font-weight: 700;
    color: var(--text-primary);
}

.status-state {
    flex: none;
    font-size: 9px;
    letter-spacing: 0.12em;
    white-space: nowrap;
}

.status-bar-track {
    height: 8px;
    background: var(--bg-elevated);
    border-radius: 4px;
    overflow: hidden;
}

.status-bar-fill {
    height: 100%;
    border-radius: 0 4px 4px 0;
}

.status-row[data-state="clear"] .status-bar-fill {
    background: var(--status-clear);
}

.status-row[data-state="clear"] .status-state {
    color: var(--status-clear);
}

.status-row[data-state="busy"] .status-bar-fill {
    background: var(--status-busy);
}

.status-row[data-state="busy"] .status-state {
    color: var(--status-busy);
}

.status-row[data-state="congested"] .status-bar-fill {
    background: var(--status-critical);
}

.status-row[data-state="congested"] .status-state {
    color: var(--status-critical);
}

/* ------------------------------------------------------------------
 * Rows that point at a place
 *
 * A choke point row and an earthquake row both name somewhere on Earth, and
 * clicking one turns the globe to it. The class is applied by panels.js and
 * only to rows whose feed actually supplied coordinates, so nothing here
 * needs to decide which rows are clickable: a row that cannot be located
 * never gets the class and never advertises that it can be.
 *
 * The affordance is deliberately faint until it is wanted. Six rows all
 * outlined as buttons would turn a tile that is meant to be read at a glance
 * into a menu, so at rest a locatable row looks exactly like an ordinary one
 * and only the cursor gives it away.
 * ------------------------------------------------------------------ */

.status-row.is-locatable,
.ticker-item.is-locatable {
    cursor: pointer;

    /*
     * The negative margin cancels the padding, so turning a row into a target
     * gives it a hit area that reaches the edges of the tile without moving
     * anything or changing how tall the row is. Six rows each gaining a few
     * pixels of height is the difference between fitting a short screen and
     * being cut off at the bottom.
     */
    margin: 0 -4px;
    padding: 0 4px;
    border-radius: 2px;
    transition: background-color 120ms ease;
}

/*
 * Hover is asked for rather than assumed, for the same reason the control
 * buttons ask: a touchscreen has no hover, but browsers emulate one, and a tap
 * leaves the :hover state stuck on whatever was tapped until something else is.
 * Left ungated, every row tapped stayed lit afterwards, so the tile carried a
 * highlight that looked like a selection and was really just the last thing a
 * finger touched.
 */
@media (hover: hover) {
    .status-row.is-locatable:hover,
    .ticker-item.is-locatable:hover {
        background-color: rgba(23, 201, 107, 0.10);
    }
}

/*
 * What a touchscreen gets instead. :active lasts only as long as the finger is
 * down, which is exactly the acknowledgement a tap wants, and it works for a
 * mouse press too.
 */
.status-row.is-locatable:active,
.ticker-item.is-locatable:active {
    background-color: rgba(23, 201, 107, 0.16);
}

/*
 * Keyboard focus gets a real outline rather than the hover tint. A tint is
 * enough for a pointer, which the reader is already aiming, and not enough
 * for a tab stop, which they have to find.
 */
.status-row.is-locatable:focus-visible,
.ticker-item.is-locatable:focus-visible {
    outline: 1px solid var(--accent-secondary);
    outline-offset: 1px;
    background-color: rgba(23, 201, 107, 0.10);
}

/* ------------------------------------------------------------------
 * Short screens
 *
 * Every size above was set for a panel a third of a 1080 line screen high,
 * which is 360px. The trouble is that plenty of perfectly ordinary laptops
 * are wide and short: a 1536x695 viewport is a landscape screen by every
 * test this stylesheet applies, so it lays out three panels down each rail
 * and gives each of them 221px to do it in. That is 40% less room than the
 * chrome above was drawn for, and the chrome does not shrink, so it eats the
 * content instead.
 *
 * Measured on that viewport before this block existed: the panel body came
 * to 163px, the maritime rows needed 186px and the sixth was cut off, and
 * the ticker's sixth event was clipped by a pixel or two. The sparklines
 * were down to 32px, which is a line with no room to be a shape.
 *
 * The stylesheet did already have a rule for exactly this, further down, but
 * it triggered on max-width: 700px. A short laptop is not narrow, so it never
 * fired. Height is what is actually scarce here, so height is what this asks
 * about.
 *
 * 820px is the threshold because that is where a third of the viewport falls
 * below about 270px, which is the point at which six rows plus head and foot
 * stop fitting at the full sizes.
 * ------------------------------------------------------------------ */

@media (min-aspect-ratio: 1/1) and (max-height: 820px) {

    .panel-head {
        padding: 3px 10px;
    }

    .panel-title {
        font-size: 15px;
        letter-spacing: 1.5px;
    }

    .panel-body {
        gap: 4px;
        padding: 5px 8px;
    }

    .panel-foot {
        padding: 2px 8px 3px 8px;
        font-size: 9px;
    }

    /*
     * The ticker and the status rows are the two that overflowed, and both
     * overflowed by a few pixels per row rather than by a lot. Taking the
     * vertical padding off each row recovers more than enough without
     * touching the type size, so the numbers stay as readable as they were.
     */
    .ticker-item {
        padding: 1px 0;
    }

    .status-heading {
        margin-bottom: 1px;
    }

    .panel-body-status {
        gap: 2px;
    }

    /*
     * A sparkline squeezed under about 40px stops reading as a trend and
     * starts reading as a texture, so it is given a floor.
     *
     * A floor only. Capping it as well was a mistake worth recording: the
     * greenhouse panel has two rows where the resource panel has four, so its
     * sparklines had 64px and needed no help at all, and a max-height applied
     * to both took 12px off the one that was already fine to fix the one that
     * was not.
     */
    .chart-host-sparkline {
        min-height: 38px;
    }

    .panel-hero-caption {
        font-size: 9px;
    }

    /*
     * Three or four indicator rows sharing a 175px body get about 44px each,
     * and a row's label, value and delta stack to about 47px at the sizes
     * above. The three overlapped: the label sat across the top of the value,
     * which is the one failure on this panel that a measurement of the boxes
     * does not catch, because nothing overflows its container. They are all
     * the right height and drawn on top of each other.
     *
     * Only the crowded case is touched. Two rows have double the height and
     * are left alone.
     */
    .panel-body-rows[data-row-count="3"] .indicator-label,
    .panel-body-rows[data-row-count="4"] .indicator-label {
        font-size: 9px;
        letter-spacing: 0.06em;
    }

    .panel-body-rows[data-row-count="3"] .indicator-value,
    .panel-body-rows[data-row-count="4"] .indicator-value {
        font-size: clamp(14px, 2.1vh, 19px);
        line-height: 1.05;
    }

    .panel-body-rows[data-row-count="3"] .indicator-delta,
    .panel-body-rows[data-row-count="4"] .indicator-delta {
        margin-top: 0;
        font-size: 9px;
    }

    .panel-body-rows[data-row-count="3"] .indicator-row,
    .panel-body-rows[data-row-count="4"] .indicator-row {
        gap: 8px;
    }

}

/* ------------------------------------------------------------------
 * Small screens
 *
 * On a phone the panel is shorter again, and narrow as well, so the chrome
 * comes down further to leave the numbers and the charts the room.
 * ------------------------------------------------------------------ */

@media (max-width: 700px) {

    .panel-title {
        font-size: 17px;
        letter-spacing: 1px;
    }

    .panel-head {
        padding: 4px 8px;
    }

    .panel-body {
        padding: 6px 8px;
    }

    .panel-hero-caption,
    .panel-foot {
        font-size: 9px;
    }

    .indicator-reading {
        flex-basis: 44%;
    }

}
