/* MaverickWX — the Map frame (decision 20, 2026-12-04; docs/plan/map-frame-usability-brief.md § The frame).

   One layout contract around Map's four renderers: Warnings (the server's SVG page), Radar (MapLibre), Satellite
   (one still picture) and Models (the server's pictures). Each view keeps its own drawing code and its own
   stylesheet; this file owns where the shared parts sit and how big they are, so a reader meets one layout in
   every view. It is CSS only: nothing in it needs script, and a view that is whole without script stays whole.

   Loaded by all four views after the site's shared sheets (fonts, tokens, shell, styles), and before each view's
   own sheet. Sizes are declared once, here, as custom properties; a view never redeclares them.

   The slots (desktop: 1024 px and wider, and at least 600 px tall):

     masthead     the site's bar
     .mapframe-bar     the view bar: the view switch, then the view's place control, then one status chip    44 px
     .mapframe-tools   the tool row: the view's title, its product chooser, its tools                       ≤ 56 px
     .mapframe-dock    the panel at the left, collapsible: lists and choices                                360 px
     .mapframe-stage   the map or the picture, which fills what is left
     .mapframe-zoom    top right of the stage, "+" above "−", 40 × 40 px buttons
     .mapframe-key     bottom right of the stage: a "Key" button that opens a card
     .mapframe-time    only on a view that has time (Radar, Models): play, step, scrubber, the frame's time     64 px

   On a phone (below 1024 px wide, or shorter than 600 px) the dock is a bottom sheet opened from the tool row, the
   tool row is 52 px, the time bar 56 px and every control is at least 44 × 44 px.

   The few controls that need script (the dock's tool and its Close) are `map-frame.mjs`; each arrives `hidden`.

   Slice 1 builds the view bar and these declarations; the tool row, dock, stage, zoom, Key and time bar are taken
   up view by view in slices 2–5. Satellite (slice 2) is the first to use the tool row, the dock, the stage and the zoom. Never a scientific colour here: the map room's grounds stay the views' own
   (`--sv-room-*` in severe-live.css, `--radar-*` in radar.css), dark in both themes. */

:root {
  --mf-bar-h: 44px;
  --mf-tools-h: 56px;
  --mf-dock-w: 360px;
  --mf-time-h: 64px;
  --mf-zoom: 40px;
}

@media (max-width: 1023.98px), (max-height: 599.98px) {
  /* The tool row is 52 px on a phone, within the brief's 56 px, so a 101 px masthead, the 44 px view bar and the row put
     the stage's top edge at 197 px, inside the 200 px the brief allows (the owner's answer, 2026-12-04, slice 2). */
  :root { --mf-tools-h: 52px; --mf-time-h: 56px; --mf-zoom: 44px; }
}

/* ---------------------------------------------------------------------------------------
   The view bar (slice 1): the same top, height, left edge and type in all four views.
   Its content sits on the masthead's edges (`--masthead-width`, `--hub-gutter`, as `body .masthead
   .shell-inner` in shell.css), so the first view's left edge is the logo's. The switch is
   `mapViews()`'s markup, the section row's (`.sectionnav` in shell.css): its look, weight and
   current mark are kept, and only its box is the frame's.
   ------------------------------------------------------------------------------------- */

.mapframe-bar { background: color-mix(in srgb, var(--intro) 68%, var(--surface)); }
.mapframe-bar-inner {
  display: flex; align-items: stretch; gap: var(--sp-3);
  max-width: var(--masthead-width); width: calc(100% - 2 * var(--hub-gutter)); margin-inline: auto;
  min-height: var(--mf-bar-h);
}
.mapframe-bar .mapviews { flex: 0 1 auto; min-width: 0; background: none; border: 0; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; }
/* `body` makes this as specific as the title strip's `.shell-inner` rules in shell.css (Radar's switch sits inside its
   strip), and this file is later, so the switch's box is the frame's on every layout. */
body .mapframe-bar .mapviews .shell-inner { max-width: none; width: max-content; margin: 0; padding: 0; gap: 0; flex-wrap: nowrap; align-items: stretch; border: 0; }
.mapframe-bar .mapviews a {
  flex: none; min-height: var(--mf-bar-h); padding: 0 var(--sp-3);
  font-size: var(--fs-bulletin); white-space: nowrap;
}
.mapframe-bar .mapviews a:first-child { padding-inline-start: 0; }
.mapframe-bar .mapviews a:first-child[aria-current="page"]::after { left: 0; }
.mapframe-place { display: flex; align-items: center; min-width: 0; }
.mapframe-status { display: flex; align-items: center; margin: 0 0 0 auto; min-width: 0; }
/* A view that has joined the frame wraps its first screen in `.mapframe-screen` (slice 2): the masthead, the view bar and the
   frame. On a phone its view bar has room for the switch alone, and a second row would push the stage below 200 px, so the
   status chip sits at the top left of the stage, over the stage's own ground, clear of the zoom at its right. It stays in the
   bar's markup, so it is read after the switch and before the tool row, as on a desktop. */
@media (max-width: 1023.98px), (max-height: 599.98px) {
  .mapframe-screen .mapframe-bar { position: relative; }
  .mapframe-screen .mapframe-status {
    position: absolute; z-index: 20;
    top: calc(100% + var(--mf-tools-h) + var(--sp-2));
    left: var(--sp-2); right: calc(var(--mf-zoom) + 2 * var(--sp-2));
    margin: 0; justify-content: flex-start;
    pointer-events: none;
  }
  .mapframe-screen .mapframe-status > * { pointer-events: auto; }
}

/* The first screen (slice 2): `.mapframe-screen` is the screen's height, and the frame takes what the masthead and the view bar
   leave, so the stage (the grid's `1fr` row) starts at the tool row's foot and ends at the screen's. Never below 480 px, so a
   short window scrolls rather than squeezing the stage to nothing. On a phone without script the dock is in the flow after the
   stage, so there the screen only grows: the stage keeps at least the screen less 200 px (its top edge's budget). */
.mapframe-screen { display: flex; flex-direction: column; height: 100svh; min-height: 480px; }
.mapframe-screen > .mapframe { flex: 1 1 auto; min-height: 0; }
@media (max-width: 1023.98px), (max-height: 599.98px) {
  @media (scripting: none) {
    .mapframe-screen { height: auto; min-height: 100svh; }
    .mapframe-screen .mapframe-stage { min-height: max(280px, calc(100svh - 200px)); }
  }
}

/* ---------------------------------------------------------------------------------------
   The frame's grid: tool row over dock and stage, the time bar at the foot.
   ------------------------------------------------------------------------------------- */

.mapframe {
  display: grid;
  grid-template-columns: var(--mf-dock-w) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas: "tools tools" "dock stage" "time time";
  min-height: 0;
}
/* The tool row (slice 2): one row, `--mf-tools-h` tall in every view, its content on the view bar's edges (the masthead's),
   so the title starts under the first view. Left the view's `<h1>` at 21 px, then its product chooser; right its tools.
   What does not fit goes to the dock or a "More" menu, never to a second row. Only text enlarged by the reader (200% text, WCAG
   1.4.4 and 1.4.10) may wrap it, so the row is at least, not exactly, its height, and nothing is cut or pushed off the screen.
   On a phone the tools go behind "More" (below), so the row holds the title, the chooser and "More" down to 320 px. */
.mapframe-tools {
  grid-area: tools;
  display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--sp-3);
  box-sizing: border-box;
  min-height: var(--mf-tools-h);
  padding-inline: max(var(--hub-gutter), calc((100% - var(--masthead-width)) / 2));
  background: var(--paper); border-bottom: 1px solid var(--line);
  min-width: 0;
}
.mapframe-tools h1 {
  flex: none; margin: 0;
  font-family: var(--font-body); font-size: var(--fs-subhead); font-weight: 800; line-height: 1.2; letter-spacing: 0;
  color: var(--ink);
}
/* The chooser: the one thing drawn. A labelled group of links; the current option filled `--enamel` with `--on-enamel` text
   and a heavier weight, and marked `aria-current`, so the choice is never colour alone (brief § The five kinds of control). */
.mapframe-chooser { display: flex; flex: none; gap: var(--sp-1); align-items: center; }
.mapframe-chooser a {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 var(--sp-3);
  border: 1px solid var(--edge); border-radius: var(--radius-control);
  font-size: var(--fs-bulletin); font-weight: 650; color: var(--ink); text-decoration: none; white-space: nowrap;
}
.mapframe-chooser a:hover { border-color: var(--ink); }
.mapframe-chooser a[aria-current] { background: var(--enamel); border-color: var(--enamel); color: var(--on-enamel); font-weight: 800; }
@media (pointer: coarse) { .mapframe-chooser a { min-height: 44px; } }
/* The tools, at the row's right: quiet buttons and links, no fill and no border at rest, a border on hover and focus. A one-shot
   action or a panel, never the view's main task, so never the filled primary button. */
.mapframe-toolset { display: flex; align-items: center; gap: var(--sp-1); margin-inline-start: auto; min-width: 0; }
.mapframe-tool {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-1);
  min-height: 40px; padding: 0 var(--sp-3);
  border: 1px solid transparent; border-radius: var(--radius-control);
  background: none; color: var(--link);
  font: inherit; font-size: var(--fs-bulletin); font-weight: 650; line-height: 1.2;
  text-decoration: none; white-space: nowrap; cursor: pointer;
}
.mapframe-tool:hover, .mapframe-tool:focus-visible { border-color: var(--edge); }
.mapframe-tool[aria-expanded="true"] { border-color: var(--edge); background: var(--wash); }
.mapframe-tool[hidden] { display: none; }
@media (pointer: coarse) { .mapframe-tool { min-height: 44px; } }
/* "More" (slice 2 step 6): the tools a phone's row has no room for. On a desktop, and on a phone without script, they are in the
   row (`display: contents`) and "More" is not drawn; on a phone with script "More" opens them as a menu under the row's right
   end, clear of the zoom below it (`map-frame.mjs` sets `data-open`), closed by Escape, by a press outside it, or by using one
   of its tools. */
.mapframe-toolset { position: relative; }
.mapframe-more { display: contents; }
.mapframe-more-toggle { display: none; }
.mapframe-more-toggle::after { content: "▾"; margin-inline-start: var(--sp-1); }
.mapframe-more-toggle[aria-expanded="true"]::after { content: "▴"; }
@media (max-width: 1023.98px), (max-height: 599.98px) {
  @media (scripting: enabled) {
    .mapframe-more-toggle:not([hidden]) { display: inline-flex; }
    .mapframe-more-toggle:not([hidden]) + .mapframe-more {
      display: none; position: absolute; z-index: 40; top: calc(100% + var(--sp-1));
      right: max(0px, calc(var(--mf-zoom) + var(--sp-3) + var(--sp-2) - var(--hub-gutter)));
      flex-direction: column; align-items: stretch; min-width: 14rem; padding: var(--sp-1);
      background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-control);
      box-shadow: 0 4px 16px rgb(0 0 0 / 0.16);
    }
    .mapframe-more-toggle:not([hidden]) + .mapframe-more[data-open] { display: flex; }
    .mapframe-more-toggle:not([hidden]) + .mapframe-more .mapframe-tool { justify-content: flex-start; }
  }
}
/* Tighter below 420 px. On a phone without script the full-size link is in the row itself (there is no "More"), and the title,
   the chooser and the link need about 400 px, so there the row may take a second line: the stage stays most of the screen. */
@media (max-width: 419.98px) {
  .mapframe-tools { gap: 0 var(--sp-2); }
  .mapframe-tool { padding-inline: var(--sp-2); }
}
/* The dock: lists and choices, at the left, 360 px. `data-dock` on the frame says whether it is open; only with script can it be
   closed, so a reader without script has it open and the page whole. Its head is one style in every view: a heading, then Close. */
.mapframe-dock {
  grid-area: dock;
  box-sizing: border-box; width: var(--mf-dock-w); min-width: 0; overflow: auto;
  padding: var(--sp-3) var(--sp-4) var(--sp-5);
  background: var(--paper); border-right: 1px solid var(--line);
}
.mapframe-dock-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); min-height: 44px; margin-bottom: var(--sp-2); }
.mapframe-dock-head h2 { margin: 0; font-family: var(--font-body); font-size: var(--fs-lead); font-weight: 800; letter-spacing: 0; color: var(--ink); }
@media (scripting: enabled) {
  .mapframe[data-dock="closed"] { grid-template-columns: 0 minmax(0, 1fr); }
  .mapframe[data-dock="closed"] .mapframe-dock { display: none; }
}
/* The stage: edge to edge, on the map room's dark ground, which a view may set (`--mf-stage-ground`). A picture in it is shown
   whole (`object-fit: contain`, the view's own rule); the stage is a box, never a crop. */
.mapframe-stage { grid-area: stage; position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--mf-stage-ground, transparent); }
.mapframe-zoom {
  position: absolute; top: var(--sp-3); right: var(--sp-3);
  display: flex; flex-direction: column; gap: var(--sp-1);
}
.mapframe-zoom > * { width: var(--mf-zoom); height: var(--mf-zoom); }
/* The zoom's buttons (slice 2): on the paper, over any stage, "+" and "−" in the body face. The one at its limit stays a button
   that says it can do no more (`aria-disabled`), quieter, rather than vanishing. */
.mapframe-zoom { z-index: 10; }
.mapframe-zoom[hidden] { display: none; }
.mapframe-zoom > button {
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
  border: 1px solid var(--edge); border-radius: var(--radius-control);
  background: var(--paper); color: var(--ink); box-shadow: 0 2px 8px rgb(0 0 0 / 0.2);
  font: inherit; font-size: var(--fs-lead); font-weight: 800; line-height: 1; cursor: pointer;
}
.mapframe-zoom > button:hover { border-color: var(--ink); }
.mapframe-zoom > button[aria-disabled="true"] { color: var(--muted); border-color: var(--line); cursor: default; }
/* A pannable box (`[data-mapframe-pan]`): fitted it shows its picture whole; zoomed (`is-actual` on the stage) it scrolls, and a
   mouse or pen drags it. Its focus ring is drawn inside it, since it fills the stage. */
.mapframe-stage.is-actual [data-mapframe-pan] { overflow: auto; overscroll-behavior: contain; cursor: grab; }
.mapframe-stage [data-mapframe-pan].is-panning { cursor: grabbing; user-select: none; }
.mapframe-stage [data-mapframe-pan]:focus-visible { outline: var(--focus-ring); outline-offset: -3px; }
.mapframe-key { position: absolute; right: var(--sp-3); bottom: var(--sp-3); }
.mapframe-time {
  grid-area: time;
  display: flex; align-items: center; gap: var(--sp-2);
  min-height: var(--mf-time-h);
  padding-inline: var(--gutter);
  background: var(--paper); border-top: 1px solid var(--line);
}

@media (max-width: 1023.98px), (max-height: 599.98px) {
  /* One column. Without script the dock follows the stage, open, in the page's flow. */
  .mapframe {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    grid-template-areas: "tools" "stage" "time" "dock";
  }
  .mapframe-dock { width: auto; border-right: 0; border-top: 1px solid var(--line); }
  /* With script the dock is a bottom sheet, opened from its tool: it peeks at no more than 40% of the screen and never covers
     the selected point. */
  @media (scripting: enabled) {
    .mapframe[data-dock] { grid-template-columns: minmax(0, 1fr); }
    .mapframe-dock {
      position: fixed; inset: auto 0 0 0; z-index: 30;
      max-height: 40svh;
      border-radius: var(--radius-surface) var(--radius-surface) 0 0;
      box-shadow: 0 -4px 16px rgb(0 0 0 / 0.18);
    }
  }
}
