/* ==========================================================================
   TIME & DATA — the two-mode time control (EP-22)
   --------------------------------------------------------------------------
   Every map screen used to ask one question of time: "what happens next?", answered by
   the TIME ANIMATION ladder. It could not answer the other one an operator has — "what
   was the air like at 14:00 on 10 April?" — because the ladder only offers leads from
   the current issue.

   The fix is two modes, never both at once. A date picker sitting next to a playing
   animation would leave the map ambiguous: the operator could not tell whether a
   province was red *now* or red *then*. So `#mb-time` becomes a mode selector plus
   exactly one visible pane, and a badge on the map always names what is on screen.

   Loaded after each page's own sheet (and before theme.css) because impact.css
   redeclares the neighbouring `.mb-*` classes against its own `--fs` density scale;
   these `.tm-*` names are new, so the order only matters for the few places below that
   reach back into `.mb-time` / `.time-steps`.
   ========================================================================== */

/* ---------------------------------------------------------------- shell -- */
.mb-time.tm-root { flex-wrap: nowrap; gap: 8px; }

/* Mode selector: a segmented control, so the two modes read as alternatives rather
   than as two independent widgets that might both be acting on the map. */
.tm-modes {
  display: flex; flex: 0 0 auto; gap: 2px; padding: 2px;
  background: rgba(9, 15, 24, 0.72); border: 1px solid var(--border-2); border-radius: 8px;
}
.tm-mode {
  display: inline-flex; align-items: center; gap: 5px;
  background: transparent; border: 0; border-radius: 6px; padding: 4px 9px;
  color: var(--muted); font-family: inherit; font-size: 11px; font-weight: 600;
  white-space: nowrap; cursor: pointer;
}
.tm-mode:hover { color: #dbe9f7; }
.tm-mode[aria-selected="true"] { background: var(--accent); color: #04121a; }
.tm-mode-ic { font-size: 11px; line-height: 1; }

/* the two panes. Only one is ever in the flow — `hidden` is not enough on a flex child,
   so the display is stated here rather than relying on the shell's [hidden] rule. */
.tm-pane { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tm-pane[hidden] { display: none; }

/* --------------------------------------------------------- pick-mode pane -- */
/* Two fields and a reset. No confirm step — see .tm-pane-pick.tm-loading below. */
.tm-field {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  background: rgba(17, 29, 44, 0.86); border: 1px solid var(--border-2); color: #dbe9f7;
  border-radius: 7px; padding: 4px 9px; font-family: inherit; font-size: 11.5px;
  font-weight: 600; white-space: nowrap; cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.tm-field:hover { border-color: var(--accent-dim); }
.tm-field[aria-expanded="true"] { border-color: var(--accent); }
.tm-field:disabled { opacity: 0.45; cursor: not-allowed; }
.tm-field-ic { font-size: 12px; filter: grayscale(0.15); }
.tm-field .pc-caret { margin-left: 1px; }

/* There is no confirm button: picking a date or an hour loads it. While that load is in
   flight the two fields say so themselves — a spinner elsewhere would leave the controls
   looking inert and invite a second click on the same day. */
.tm-pane-pick.tm-loading .tm-field { opacity: 0.6; cursor: progress; }
.tm-reset {
  background: rgba(17, 29, 44, 0.86); border: 1px solid var(--border-2); color: var(--muted);
  border-radius: 7px; width: 28px; height: 26px; cursor: pointer;
  font-family: inherit; font-size: 12px; flex: 0 0 auto;
}
.tm-reset:hover { color: var(--accent); border-color: var(--accent-dim); }

/* ------------------------------------------------------------- popovers -- */
.tm-pop {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 40;
  background: rgba(13, 23, 37, 0.98); border: 1px solid var(--border-2); border-radius: 10px;
  padding: 10px; box-shadow: 0 22px 50px -16px rgba(0, 0, 0, 0.9); backdrop-filter: blur(8px);
  color: var(--text); font-size: 12px; cursor: default;
}
.tm-pop[hidden] { display: none; }

/* calendar */
.tm-cal { width: 246px; }
.tm-cal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 8px;
}
.tm-cal-title { font-size: 12px; font-weight: 700; letter-spacing: 0.01em; }
.tm-nav {
  background: rgba(17, 29, 44, 0.9); border: 1px solid var(--border); color: #cfe0f0;
  border-radius: 6px; width: 24px; height: 24px; cursor: pointer; font-family: inherit;
  font-size: 11px; flex: 0 0 auto;
}
.tm-nav:hover:not(:disabled) { border-color: var(--accent-dim); color: var(--accent); }
.tm-nav:disabled { opacity: 0.3; cursor: not-allowed; }
.tm-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.tm-dow {
  text-align: center; font-size: 9px; color: var(--faint); padding: 2px 0 4px;
  letter-spacing: 0.04em;
}
.tm-day {
  background: transparent; border: 1px solid transparent; border-radius: 6px;
  color: #c6d8ea; font-family: inherit; font-size: 11.5px; padding: 5px 0; cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.tm-day:hover:not(:disabled) { background: #17273d; border-color: var(--border-2); }
.tm-day.tm-out { color: var(--faint); }
/* Out of the window the platform actually holds measurements for. Shown, not removed:
   a greyed-out 9 April tells the operator the data stops there — a blank cell would
   read as a rendering bug. */
.tm-day:disabled { opacity: 0.22; cursor: not-allowed; }
.tm-day.tm-today { border-color: var(--border-2); }
.tm-day.tm-sel { background: var(--accent); border-color: var(--accent); color: #04121a; font-weight: 700; }
.tm-cal-foot {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border);
}
.tm-hint { font-size: 9.5px; color: var(--faint); }
.tm-link {
  background: transparent; border: 0; color: var(--accent); font-family: inherit;
  font-size: 10.5px; font-weight: 600; cursor: pointer; padding: 0;
}
.tm-link:hover { text-decoration: underline; }

/* hour list */
.tm-hours { width: 132px; max-height: 232px; overflow-y: auto; }
.tm-hour {
  display: block; width: 100%; text-align: left; background: transparent;
  border: 1px solid transparent; border-radius: 6px; color: #c6d8ea; font-family: inherit;
  font-size: 11.5px; padding: 5px 8px; cursor: pointer; font-variant-numeric: tabular-nums;
}
.tm-hour:hover:not(:disabled) { background: #17273d; }
.tm-hour:disabled { opacity: 0.22; cursor: not-allowed; }
.tm-hour.tm-sel { background: var(--accent); color: #04121a; font-weight: 700; }

/* --------------------------------------------------------- status badge -- */
/* Bottom-centre of the map: the legend owns bottom-left, the quick pills bottom-right,
   and `#map-flag` owns top-centre. Always present — a badge that only appeared for
   historical data would make "no badge" mean both "live" and "not loaded yet". */
.tm-badge {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); z-index: 7;
  display: inline-flex; align-items: center; gap: 7px; max-width: min(92%, 560px);
  padding: 5px 12px; border-radius: 999px; font-size: 11px; line-height: 1.35;
  background: rgba(11, 17, 25, 0.88); border: 1px solid var(--border-2); color: var(--muted);
  backdrop-filter: blur(8px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  pointer-events: none;
}
.tm-badge-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; }
.tm-badge-kind { font-weight: 700; letter-spacing: 0.02em; color: #dbe9f7; }
.tm-badge-when { font-variant-numeric: tabular-nums; }
/* live/forecast reads in the platform accent; history reads amber, the same warning
   colour `#map-flag` uses for "this is not the ordinary picture" */
.tm-badge.tm-hist { border-color: rgba(230, 126, 34, 0.5); background: rgba(46, 30, 14, 0.9); }
.tm-badge.tm-hist .tm-badge-dot { background: #e67e22; }
.tm-badge.tm-hist .tm-badge-kind { color: #f0a860; }
.tm-badge.tm-err { border-color: rgba(231, 76, 60, 0.55); background: rgba(46, 18, 16, 0.92); }
.tm-badge.tm-err .tm-badge-dot { background: #e74c3c; }
.tm-badge.tm-err .tm-badge-kind { color: #f08a80; }
.tm-badge.tm-busy .tm-badge-dot { animation: tm-pulse 1s ease-in-out infinite; }
@keyframes tm-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* ------------------------------------------------------------ narrowing -- */
/* The bar sheds chrome as the viewport tightens, in the same order the ladder already
   does (see style.css): wording first, the controls themselves last. scripts/
   check_layout_fit.py is what turns a silent loss here into a failing check. */
@media (max-width: 1600px) {
  .mb-time.tm-root .mb-time-label { display: none; }
}
@media (max-width: 1440px) {
  .tm-mode-label { display: none; }
  .tm-mode { padding: 4px 8px; }
  .tm-mode-ic { font-size: 12px; }
}
@media (max-width: 1340px) {
  .mb-time.tm-root { gap: 6px; }
  .tm-pane { gap: 5px; }
  .tm-field { padding: 4px 7px; }
}

/* --------------------------------------------- live-only panel exceptions -- */
/* Marked in each page's markup with `data-live-only`; the tag only appears while a past
   hour is on screen, so the live view stays as uncluttered as it was. */
.tm-live-tag {
  display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 999px;
  border: 1px solid rgba(230, 126, 34, 0.45); background: rgba(230, 126, 34, 0.12);
  color: #f0a860; font-size: 9px; font-weight: 600; letter-spacing: 0; vertical-align: 1px;
  white-space: nowrap;
}
.tm-live-tag[hidden] { display: none; }

/* --------------------------------------------- why only the Overview has one -- */
/* The selector is built on the Overview alone (timemode.js, `historical: false` elsewhere),
   and `#map-controls` is the one time bar that *wraps* rather than clipping — every other
   screen keeps its ladder in an `overflow: hidden` row where a ~78px control would not push
   its neighbours aside but silently eat steps off the end. That is why nothing below needs
   to claw width back from the analysis screens: they never carry this control. */

/* Below the war-room widths the selector itself tightens — by then it is glyphs only, so
   the padding is the last thing left to give. */
@media (max-width: 1400px) {
  .tm-modes { padding: 1px; gap: 1px; }
  .tm-mode { padding: 4px 5px; }
}
