/* EARTH WATCH · the new page's own seams (card W3). The look is ink.css (tokens) + shell.css (components);
   this file only places the live globe, the lens tray, the zoom buttons and the views in that shell.
   Tokens only: no literal colour here. No gradient, shadow, blur or filter. */

html, body { overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }

/* the globe: two canvases filling the stage's globe box, which sets the size main.js draws at */
.ew-globe { position: relative; touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
.ew-globe:active { cursor: grabbing; }
#ground, #marks { position: absolute; left: 0; top: 0; display: block; }
#ground { touch-action: none; }
#marks { pointer-events: none; }
.ew-globe canvas { object-fit: fill; }

/* THE WAYS IN (card W5): HERE · TOP · SINCE · BUSIEST · TOUR. The row is filled by the page before any data, and
   a button never changes width when its words change (TOUR/STOP/NEXT and SINCE's time share one seat each), never
   wraps, never reflows the row. Ink on paper with a hairline; the one orange highlight is the way in use. */
.ew-thumbs { align-items: center; }
.ew-way { justify-content: center; flex: 1 1 auto; font-variant-numeric: tabular-nums; }
.ew-way[data-say="run"] .ew-say, .ew-way[data-say="next"] .ew-say { visibility: hidden; }
.ew-way[data-say="run"] .ew-say[data-say="run"], .ew-way[data-say="next"] .ew-say[data-say="next"] { visibility: visible; }
.ew-since-t { display: inline-grid; }
.ew-since-hold, .ew-since-time { grid-area: 1 / 1; text-align: left; }
.ew-since-hold { visibility: hidden; }
.ew-way[data-way="since"]:not([data-t]) .ew-since-t { display: none; }
.ew-way[aria-busy="true"] { border-style: dashed; }
/* NEW (SINCE): a new card wears an ink label in the seat of its "n of N" count, which stays for a screen reader */
.ew-new { font-size: var(--t-cap); font-weight: 700; letter-spacing: var(--track-label); text-transform: uppercase; white-space: nowrap;
          padding: 3px 10px; border-radius: var(--r-chip); background: var(--ink); color: var(--ground); }
.ew-card-head:has(.ew-new) .ew-count { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

/* the deck's head */
.ew-deck-head {
  margin: 8px var(--pad) 10px; height: 20px; line-height: 20px;
  font-size: var(--t-cap); font-weight: var(--w-label); letter-spacing: var(--track-label);
  text-transform: uppercase; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* the selected card: an ink ring outside it (the orange ring is the keyboard's focus; they never look alike) */
.ew-card[aria-current="true"] { outline: 3px solid var(--rule-ink); outline-offset: 3px; }
.ew-card { cursor: pointer; }
.ew-card-title, .ew-card-line, .ew-card-src { cursor: text; }
.ew-cards { padding-top: 6px; padding-bottom: 6px; }
.ew-copied { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; margin: 0; }
.ew-chip[data-done] { background: var(--ink); color: var(--ground); border-color: var(--ink); }
.ew-chip-label { display: inline-grid; }
/* the actions' row clips (fixed seats); give the keyboard's focus ring room inside it */
.ew-card-acts { padding: 5px; margin: 1px -5px -5px; }
.ew-say { grid-area: 1 / 1; text-align: center; }
.ew-say:not([data-say="idle"]) { visibility: hidden; }
.ew-chip[data-done] .ew-say { visibility: hidden; }
.ew-chip[data-done="done"] .ew-say[data-say="done"], .ew-chip[data-done="fail"] .ew-say[data-say="fail"] { visibility: visible; }

/* the as-of line: a feed that is stale or silent says so; the warning is words, the colour only underlines them */
.ew-asof[data-warn] { color: var(--ink); }

/* the lens tray (W4 fills it): opens under the bar on the right; a tap outside or Escape closes it */
.ew-lens {
  position: fixed; z-index: 5; right: var(--pad); top: calc(var(--bar-h) + 8px);
  width: min(360px, calc(100vw - 2 * var(--pad))); max-height: calc(100dvh - var(--bar-h) - 24px); overflow: auto;
  padding: 14px 16px 16px; background: var(--card-bg); border: var(--edge) solid var(--rule-ink); border-radius: var(--r-card);
}
.ew-lens[hidden] { display: none; }
/* the open tray's button is ink, not the highlight: the chosen lens chip inside the tray is the one highlight */
#lens-btn[aria-expanded="true"] { background: var(--ink); color: var(--ground); border-color: var(--ink); }

/* THE LENS KEY's seat (#lens-key; W4 puts its key here). While a lens is on, its key (ramp, unit, source, valid
   time) stays on screen whether the tray is open or shut: colour on the globe is a number, and a number shows
   its source and time. The seat is always there, the same size, empty with no lens, so nothing moves when a lens
   goes on, off or changes. It never sits on the globe: on a phone it is its own row under the globe (home and
   focus); on a desktop it is the foot of the deck column, so the globe keeps the whole stage at every zoom.
   Its height is W4's key at its tallest everyday size (measured 29 Nov with lens.css: rain's three-line source on
   a phone, 131 px; two lines on a desktop, 111 px). W4's key says every state (waiting, OLD DATA, NO DATA) in
   that same text seat, so no state makes it taller (measured on the W3+W4 join, 29 Nov: 131 px in all four on a
   phone, 111 px on a desktop). The seat is overflow: visible, so if a later key ever grew, it would spill down
   over the deck's head (phone) or up over the deck's last lines (desktop), never onto the globe, and move
   nothing.
   On a phone the seat is SHUT while no lens is on (the fold, below): W4's lens.js sets data-lens-on on it at the
   visitor's own lens tap, before the lens's grid arrives, and takes it off at OFF. So the page moves only on the
   visitor's own tap, never when data lands, and keeps one height for as long as any lens is on. */
.ew-lens-key { position: relative; z-index: 3; height: var(--key-seat); overflow: visible; padding: 0 var(--pad) 8px;
               display: flex; flex-direction: column; }
.ew-lens-key > * { min-height: 100%; flex: none; }
:root { --key-seat: 139px; }

/* zoom: W1's buttons, at the foot of the stage, inside the margin beside the wings */
.zoom { position: absolute; right: 12px; bottom: 12px; display: flex; flex-direction: column; gap: 8px; z-index: 2; }
.zoom[hidden] { display: none; }
.zoom button { width: var(--tap); height: var(--tap); border-radius: var(--r-chip); border: var(--edge) solid var(--rule-ink);
  background: var(--card-bg); color: var(--ink); font: 700 24px/1 var(--f-body); padding: 0; cursor: pointer; touch-action: manipulation; }
.zoom button:active { background: var(--hi); color: var(--on-hi); border-color: var(--hi); }

.nogl { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); margin: 0;
  max-width: 22em; padding: 20px 24px; border: var(--hair) solid var(--rule); border-radius: var(--r-card);
  background: var(--card-bg); text-align: center; }

/* home and focus: which parts show in which view */
.ew[data-view="home"] .only-focus, .ew[data-view="focus"] .only-home { display: none !important; }
.ew-back { grid-area: back; justify-self: start; }
.ew-foot .ew-focus { width: 100%; font: inherit; text-align: left; cursor: pointer; }

/* phone, home: bar, globe, the thumb seat, the deck; the zoom buttons wait for focus (pinch is the phone's zoom) */
@media (max-width: 899px) {
  /* THE FOLD (Kris: the main action is above the fold at every phone size): with no lens on, the first card's
     FLY ME THERE and COPY LINK are on screen without scrolling. The globe takes what the screen has left over
     once everything under it, down to those buttons, has its room:
       the bar 105 + the ways-in row 58 + the cards' top 6 + the first card down to its buttons 255 + 3 spare = 427
     (the row takes the seat the deck's head had, see below), plus the lens key while a lens is on (that one may
     push the buttons down: the visitor asked for the key). 390x844: a 417 px globe; 375x667: 240 px, the floor
     (it was 261 px before the row). Below 667 px of height the floor wins and the buttons dip under the fold.
     scripts/next_probe.py --assert-fold holds both sizes. */
  .ew { --fold-rest: 427px; }
  .ew-globe { height: clamp(240px, calc(100dvh - var(--fold-rest)), 560px); }
  /* THE WAYS IN take the deck head's seat (W5): the row is one tap high between the globe and the cards, in the
     thumb's reach, and costs 26 px more than the head did. The head keeps its words for a screen reader (it labels
     the cards); what a way in says goes in the as-of line (role=status). */
  .ew-thumbs { height: 58px; padding: 5px var(--pad); gap: 6px; }
  .ew-deck-head { position: absolute; width: 1px; height: 1px; margin: 0; overflow: hidden; clip-path: inset(50%); }
  .ew-way { padding: 0 8px; }
  /* with a last-look time, SINCE stacks its two words so it is no wider than BUSIEST: five buttons fit 375 px */
  .ew-way[data-way="since"][data-t] { flex-direction: column; justify-content: center; gap: 0; line-height: 1.1; }
  .ew-way[data-way="since"][data-t] .ew-since-t { display: block; }
  .ew-way[data-way="since"][data-t] .ew-since-hold { display: none; }
  /* the lens key's seat: shut with no lens on; one full height while any lens is on */
  .ew-lens-key:not([data-lens-on]) { height: 0; padding-bottom: 0; overflow: hidden; }
  .ew[data-view="home"] .zoom { display: none; }
  /* the as-of line: a fixed two-line seat, so the bar is the same height whatever the feed or a way in says (nothing
     reflows when data lands); while the feed is old or a source stale its own words lead (events.js asOfLine) */
  .ew-asof { height: 40px; padding: 0; margin: 4px 0; line-height: 20px; white-space: normal;   /* margin, not padding: the clip is at the padding edge, so a third line must not peek into it */
             display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  .ew-lens { top: 112px; }
  /* focus: the globe takes the screen, the deck shrinks to the strip at its foot; the key's seat and the strip
     are rows under the globe, never over it */
  .ew[data-view="focus"] .ew-thumbs { display: none; }
  .ew[data-view="focus"] .ew-stage { grid-template-rows: minmax(0, 1fr) auto auto; }
  .ew[data-view="focus"] .ew-globe { height: 100%; }
  .ew[data-view="focus"] .ew-foot { position: static; padding-top: 0; }
  .ew[data-view="focus"] .ew-lens { top: 72px; }
}

/* desktop: the deck column scrolls; the globe never sits under it */
@media (min-width: 900px) {
  /* the key's seat is the deck column's foot: the column's cards end above it */
  .ew-deck { margin-bottom: var(--key-seat); }
  .ew-lens-key { position: fixed; right: 0; bottom: 0; width: var(--deck-w); padding: 12px 20px 16px;
                 border-left: var(--hair) solid var(--rule); background: var(--ground); justify-content: flex-end; }
  .ew-globe { padding: 0; margin: 0; }
  .ew-deck-head { margin: 0 20px 12px; }
  /* the ways in are a quiet row under the globe, never over it */
  .ew-thumbs { grid-row: 3; padding: 4px 24px 18px; gap: 8px; }
  .ew-way { flex: 0 0 auto; padding: 0 18px; }
}
