/* EARTH WATCH · next · shell.css — everything that is not the globe's own pixels (card W2, the look).
 * Stands on ink.css. Components: the bar · the as-of line · the thumb row · the SINCE ribbon · THE DECK card in
 * three tiers · the FOCUS strip · the lens key. Layout: phone = globe on top, deck below (thumb reach);
 * desktop (>= 900 px) = the globe takes the stage, the deck is a column on the RIGHT.
 *
 * Laws kept here: no gradient, shadow, blur or filter in the chrome (the lens key's bar is data, not chrome);
 * nothing below 15 px; every target 48 px; labels sit in fixed seats (one-liners never wrap, they end in an
 * ellipsis; two-line seats hold two lines whatever the text); numbers are tabular; nothing depends on hover;
 * everything can be selected and copied.
 */

:root {
  /* component tokens a take may turn (defaults = the One Ink reading of ink.css) */
  --chip-bg: transparent;
  --chip-line: var(--rule-ink);
  --chip-edge: var(--edge);
  --card-bg: var(--surface);
  --card-line: var(--rule);
  --card-edge: var(--hair);
  --stage-bg: var(--ground);
  --title-font: var(--f-display);
  --title-weight: 400;
  --title-track: 0;
  --mark-font: var(--f-display);
  --mark-weight: 400;
  --bar-h: 64px;
  --deck-w: 420px;
}

/* ── the frame ─────────────────────────────────────────────────────────────── */
.ew {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "bar" "stage" "deck";
  grid-template-rows: auto auto 1fr;   /* a tall screen gives its spare height to the deck, never to the bar */
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--ground);
}

/* ── the bar ───────────────────────────────────────────────────────────────── */
.ew-bar {
  grid-area: bar;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "mark tools" "asof asof";
  align-items: center;
  column-gap: var(--gap);
  padding: 8px var(--pad) 0;
  border-bottom: var(--hair) solid var(--rule);
}
.ew-mark {
  grid-area: mark;
  margin: 0;
  font-family: var(--mark-font);
  font-weight: var(--mark-weight);
  font-size: var(--t-mark);
  letter-spacing: var(--track-mark);
  line-height: var(--tap);
  white-space: nowrap;
  text-transform: uppercase;
}
.ew-tools { grid-area: tools; display: flex; gap: 8px; }
.ew-asof {
  grid-area: asof;
  margin: 0;
  height: 36px;
  line-height: 36px;
  font-size: var(--t-cap);
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ew-asof b { color: var(--ink); font-weight: 700; }

/* ── chips (the bar's tools, the thumb row, a card's actions) ─────────────── */
.ew-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: var(--tap);
  min-width: var(--tap);
  padding: 0 18px;
  border: var(--chip-edge) solid var(--chip-line);
  border-radius: var(--r-chip);
  background: var(--chip-bg);
  color: var(--ink);
  font-size: var(--t-cap);
  font-weight: var(--w-label);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  flex: none;
}
.ew-chip svg { width: 22px; height: 22px; flex: none; }
.ew-chip[aria-pressed="true"], .ew-chip.is-on, .ew-chip--go {
  background: var(--hi);
  color: var(--on-hi);
  border-color: var(--hi-edge, var(--hi));   /* a take whose highlight is faint on its ground gives it an ink edge */
}
.ew-ico { fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* ── the stage: the globe ──────────────────────────────────────────────────── */
.ew-stage {
  grid-area: stage;
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto;
  background: var(--stage-bg);
  min-width: 0;
}
.ew-globe {
  margin: 0;
  height: 330px;
  min-width: 0;
  overflow: hidden;
}
.ew-globe img, .ew-globe canvas { width: 100%; height: 100%; object-fit: contain; display: block; }

/* ── the thumb row ─────────────────────────────────────────────────────────── */
.ew-thumbs {
  display: flex;
  gap: 8px;
  padding: 8px var(--pad);
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  scroll-padding-inline: var(--pad);
}
.ew-thumbs::-webkit-scrollbar { display: none; }
.ew-thumbs .ew-chip { scroll-snap-align: start; }

/* ── the lens key: a colour bar with its source and valid time (data colour) ─ */
.ew-key {
  width: 320px;
  max-width: calc(100% - 2 * var(--pad));
  padding: 10px 14px 8px;
  background: var(--card-bg);
  border: var(--card-edge) solid var(--card-line);
  border-radius: 12px;
  font-variant-numeric: tabular-nums;
}
.ew-key-bar {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--t-m40) 0%, var(--t-m25) 18.75%, var(--t-m10) 37.5%, var(--t-0) 50%,
    var(--t-8) 60%, var(--t-16) 70%, var(--t-24) 80%, var(--t-32) 90%, var(--t-40) 100%);
}
.ew-key-ticks {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: var(--t-cap);
  font-weight: 700;
  line-height: 20px;
}
.ew-key-src {
  margin: 2px 0 0;
  font-size: var(--t-cap);
  color: var(--ink-2);
  line-height: 20px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── the deck ──────────────────────────────────────────────────────────────── */
.ew-deck { grid-area: deck; min-width: 0; padding: 0 0 var(--pad); }

/* the SINCE ribbon: three fixed cells, numbers change, nothing moves */
.ew-since {
  margin: 4px var(--pad) var(--gap);
  padding: 10px 14px 12px;
  border: var(--card-edge) solid var(--card-line);
  border-radius: var(--r-card);
  background: var(--card-bg);
}
.ew-since-head {
  margin: 0 0 6px;
  font-size: var(--t-cap);
  font-weight: var(--w-label);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  line-height: 20px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.ew-since-cells { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 0; }
.ew-since-cells div { min-width: 0; }
.ew-since-cells dd {
  margin: 0;
  font-family: var(--title-font);
  font-weight: var(--title-weight);
  font-size: 30px;
  line-height: 36px;
  font-variant-numeric: tabular-nums;
}
.ew-since-cells dt {
  font-size: var(--t-cap);
  line-height: 18px;
  height: 36px;              /* a two-line seat */
  color: var(--ink-2);
  overflow: hidden;
}
.ew-since-cells .is-alarm dd { display: flex; align-items: center; gap: 8px; }
.ew-since-cells .is-alarm dd::after {
  content: "";
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--alarm);
}

/* THE DECK: on a phone a row of cards you swipe (the next one peeks); on a desktop a column */
.ew-cards {
  list-style: none;
  margin: 0;
  padding: 0 var(--pad);
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: calc(100% - 2 * var(--pad) - 24px);
  gap: var(--gap);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding: 0 var(--pad);
  scrollbar-width: none;
}
.ew-cards::-webkit-scrollbar { display: none; }
.ew-cards > li { scroll-snap-align: start; min-width: 0; }

/* the card: kind and tier · count · bold title · one plain-words line · source and time · actions */
.ew-card {
  position: relative;
  display: grid;
  grid-template-rows: 32px auto auto auto auto;
  row-gap: 6px;
  padding: 14px 16px 16px;
  background: var(--card-bg);
  border: var(--card-edge) solid var(--card-line);
  border-radius: var(--r-card);
  min-width: 0;
}
.ew-card[data-tier="alarm"] { border: var(--edge) solid var(--alarm); padding: 13px 15px 15px; }
.ew-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-width: 0; }
.ew-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 12px 0 10px;
  border-radius: var(--r-chip);
  font-size: var(--t-cap);
  font-weight: var(--w-label);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--ink);
  border: var(--hair) solid var(--rule);
  min-width: 0;
  overflow: hidden;
}
.ew-tag[data-tier="alarm"] { background: var(--alarm); color: var(--on-tier); border-color: var(--alarm); }
.ew-tag[data-tier="active"] { background: var(--active); color: var(--on-active); border-color: var(--active); }
.ew-kind { width: 12px; height: 12px; border-radius: 50%; flex: none; background: var(--k, var(--ink));
  outline: 2px solid var(--card-bg); }
.ew-tag[data-tier="alarm"] .ew-kind, .ew-tag[data-tier="active"] .ew-kind { display: none; } /* the fill already speaks */
.ew-count {
  font-size: var(--t-cap);
  font-weight: 700;
  color: var(--ink-2);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.ew-card-title {
  margin: 4px 0 0;
  font-family: var(--title-font);
  font-weight: var(--title-weight);
  letter-spacing: var(--title-track);
  font-size: var(--t-title);
  line-height: 34px;
  height: 34px;              /* one line, fixed */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ew-card-line {
  margin: 0;
  font-size: var(--t-line);
  line-height: 25px;
  height: 50px;              /* a two-line seat */
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.ew-card-src {
  margin: 0;
  font-size: var(--t-cap);
  line-height: 21px;
  height: 42px;              /* a two-line seat */
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.ew-card-acts { display: flex; gap: 8px; margin-top: 6px; overflow: hidden; }
.ew-card-acts .ew-chip { padding: 0 14px; }
/* a narrow card (the phone's swiped deck) keeps its first action whole and turns the rest into 48 px icons;
 * the label stays in the page for a screen reader */
.ew-card { container: card / inline-size; }
@container card (max-width: 315px) {
  .ew-card-acts .ew-chip:not(.ew-chip--go) { width: var(--tap); padding: 0; justify-content: center; }
  .ew-card-acts .ew-chip:not(.ew-chip--go) .ew-chip-label {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
}

/* ── the FOCUS strip: the card shrunk to one line, at the foot of a focused globe ──
 * the tier is the strip's left bar, the kind is the dot; the line is the card's title and its plainest fact */
.ew-focus {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) var(--tap);
  align-items: center;
  gap: 10px;
  height: 64px;
  padding: 0 4px 0 14px;
  background: var(--card-bg);
  border: var(--card-edge) solid var(--card-line);
  border-left: 8px solid var(--tier, var(--card-line));
  border-radius: var(--r-card);
  color: var(--ink);
  text-decoration: none;
}
.ew-focus[data-tier="alarm"] { --tier: var(--alarm); }
.ew-focus[data-tier="active"] { --tier: var(--active); }
.ew-focus .ew-kind { width: 14px; height: 14px; outline: 0; }
.ew-focus-text { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: var(--t-body); }
.ew-focus-text b { font-family: var(--title-font); font-weight: var(--title-weight); font-size: 20px; margin-right: 4px; }
.ew-focus .ew-ico { width: 26px; height: 26px; justify-self: center; }

/* ── focus view: the globe fills the screen; BACK · LENS on top; the key and the strip at the foot ──
 * data-view="focus" may sit on .ew or on any ancestor (the look sheet pins it on <html>). */
:is(.ew[data-view="focus"], [data-view="focus"] .ew) { grid-template-areas: "bar" "stage"; grid-template-rows: auto 1fr; height: 100vh; height: 100dvh; }
[data-view="focus"] .ew-bar { grid-template-areas: "back tools"; border-bottom: 0; padding-bottom: 8px; }
[data-view="focus"] .ew-asof { display: none; }
[data-view="focus"] .ew-stage { grid-template-rows: minmax(0, 1fr); }
[data-view="focus"] .ew-globe { height: 100%; min-height: 0; }
[data-view="focus"] .ew-globe img { object-fit: cover; }
.ew-foot { display: grid; gap: 10px; padding: 10px var(--pad) var(--pad); }
[data-view="focus"] .ew-foot { position: absolute; left: 0; right: 0; bottom: 0; }
[data-view="focus"] .ew-foot .ew-key { width: auto; max-width: none; }

/* ── desktop: the globe takes the stage, the deck is a column on the right ── */
@media (min-width: 900px) {
  .ew {
    height: 100vh;
    grid-template-columns: minmax(0, 1fr) var(--deck-w);
    grid-template-rows: var(--bar-h) minmax(0, 1fr);
    grid-template-areas: "bar bar" "stage deck";
  }
  .ew-bar {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "mark asof tools";
    column-gap: 24px;
    padding: 0 24px;
    height: var(--bar-h);
  }
  .ew-mark { font-size: 22px; }
  .ew-asof { height: auto; line-height: 1.4; }
  /* the thumb row heads the stage, the globe fills the middle, the lens key sits at the foot (never on a wing) */
  .ew-stage { grid-template-rows: auto minmax(0, 1fr) auto; }
  .ew-stage-foot { display: contents; }
  .ew-thumbs { grid-row: 1; padding: 16px 24px 0; overflow: visible; flex-wrap: nowrap; }
  .ew-globe { grid-row: 2; height: auto; min-height: 0; padding: 8px 24px; }
  .ew-stage .ew-key { grid-row: 3; justify-self: start; margin: 0 24px 20px; }
  .ew-deck {
    border-left: var(--hair) solid var(--rule);
    overflow-y: auto;
    padding: 16px 0 24px;
  }
  .ew-since { margin: 0 20px 16px; }
  .ew-cards {
    grid-auto-flow: row;
    grid-auto-columns: auto;
    overflow: visible;
    padding: 0 20px;
    gap: 14px;
  }
}

/* ── CLASSIC (W6): one tap to the old page, quiet ink on paper, never the highlight ─────────────────────────
 * It lives in the bar. On a narrow phone the bar has no room for the mark, LENS and CLASSIC in one row (they need
 * about 447 px), so there the bar's chip steps aside for its twin in the stage, laid over the globe's own grid cell
 * and flush to its bottom right corner (the zoom buttons' seat, empty in the home view). On a short phone the globe
 * is at its 240 px floor and the right wing's rounded edge comes down to 36 px above the cell's foot, so the chip you
 * see is 36 px tall and covers no part of the planet; its touch target is 48 px all the same: a 72 x 48 box in the
 * very corner (::after), clear of the wing, the disc and the ways-in row under it. It is filled like the zoom buttons,
 * and it is the globe's sibling, not its child, so a tap on it is never a drag. In a focused event it waits at home:
 * BACK, then CLASSIC. scripts/classic_chip_probe.py counts the globe pixels under both boxes at 375x667 and 360x640. */
#classic-stage { display: none; }
@media (max-width: 459px) {
  .ew-bar #classic { display: none; }
  .ew[data-view="home"] .ew-globe { grid-row: 1; grid-column: 1; }
  .ew[data-view="home"] #classic-stage {
    display: inline-flex; grid-row: 1; grid-column: 1; align-self: end; justify-self: end;
    position: relative; height: 36px; margin: 0; z-index: 2; background: var(--card-bg);
  }
  .ew[data-view="home"] #classic-stage::after {
    content: ""; position: absolute; right: calc(-1 * var(--chip-edge)); bottom: calc(-1 * var(--chip-edge));
    width: 72px; height: 48px;
  }
}
