/* Time bar, live layer rows, readout panels and value tags.
   Owned by the live foundation. Modules may use these classes; a module
   that needs more styling injects its own <style> scoped under its
   [data-live="<id>"] attribute. */

/* ---------------------------------------------------------------- time bar */
.motion.has-timebar {
  flex-wrap: wrap;
  max-width: min(560px, calc(100% - 90px));
  row-gap: 6px;
}
.timebar {
  flex: 1 0 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  border-top: 1px solid #dfe5d9;
  padding-top: 6px;
}
.timebar-read {
  display: flex;
  flex-direction: column;
  min-width: 128px;
}
.timebar-kicker {
  font:
    650 0.58rem ui-monospace,
    Menlo,
    monospace;
  letter-spacing: 1.3px;
  color: #667767;
}
.timebar-when {
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.timebar.is-future .timebar-when {
  color: #7a4f12;
}
.motion .timebar-live {
  border: 1px solid #cfdbca;
  border-radius: 3px;
  font:
    600 0.7rem ui-monospace,
    monospace;
  letter-spacing: 0.6px;
  padding: 5px 7px;
  text-transform: uppercase;
  color: #4d5d50;
}
.motion .timebar-live[aria-pressed="true"] {
  background: #28533d;
  border-color: #28533d;
  color: #fff;
}
.timebar-track {
  flex: 1 1 150px;
  min-width: 120px;
  display: flex;
  flex-direction: column;
}
.timebar-range {
  width: 100%;
  margin: 0;
  accent-color: #28533d;
}
.timebar-scale {
  display: flex;
  justify-content: space-between;
  font:
    0.56rem ui-monospace,
    monospace;
  color: #7a887b;
  /* Equal windows on either side of the present. */
  position: relative;
  height: 0.8rem;
}
.timebar-scale .timebar-now {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}
.timebar-offset {
  font:
    600 0.7rem ui-monospace,
    monospace;
  color: #7a4f12;
  white-space: nowrap;
  min-width: 0;
}
.timebar-offset:empty {
  display: none;
}

/* ------------------------------------------------------------- layer rows */
.live-item .layer-row .live-label {
  flex: 0 1 auto;
}
.live-sub .layer-row {
  padding-left: 18px;
  font-size: 0.84rem;
}
.live-status {
  font-size: 0.74rem;
  color: #5b6b5e;
  padding: 0 2px 8px 22px;
  margin-top: -4px;
}
.live-status[data-state="loading"] {
  color: #6b7a6c;
}
.live-status[data-state="stale"] {
  color: #8a5a12;
}
.live-status[data-state="error"] {
  color: #9c3b2b;
}
.live-body {
  padding: 0 2px 10px 22px;
  font-size: 0.78rem;
  display: grid;
  gap: 6px;
}
.live-body label {
  display: flex;
  align-items: center;
  gap: 8px;
}
.live-body input[type="range"] {
  flex: 1;
  accent-color: #477551;
}
.layer-row.live-broken {
  opacity: 0.55;
}

/* -------------------------------------------------------------- value tags */
.live-tag {
  display: inline-block;
  font:
    650 0.6rem ui-monospace,
    Menlo,
    monospace;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  padding: 1px 5px;
  border-radius: 3px;
  vertical-align: 1px;
  border: 1px solid currentColor;
}
.live-tag-observed {
  color: #1f6a3a;
}
.live-tag-modelled {
  color: #2d5f86;
}
.live-tag-predicted {
  color: #7a4f12;
}
.live-tag-nominal {
  color: #6b6b6b;
}

/* ----------------------------------------------------------------- panels */
.live-panels {
  position: absolute;
  z-index: 3;
  top: 18px;
  right: 68px;
  width: min(320px, calc(100% - 100px));
  max-height: calc(100% - 150px);
  overflow: auto;
  display: grid;
  gap: 10px;
  pointer-events: none;
}
.live-panel {
  pointer-events: auto;
  background: #f8faf2f7;
  color: #193d31;
  border: 1px solid #cbd6c7;
  border-radius: 8px;
  box-shadow: 0 3px 16px #142d3533;
  font-size: 0.8rem;
}
/* display rules above beat the hidden attribute, so restate it (track A). */
.live-body[hidden],
.live-tag[hidden],
.live-panel[hidden] {
  display: none;
}
.live-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 8px 5px 11px;
  border-bottom: 1px solid #dfe5d9;
}
.live-panel-head b {
  font-size: 0.82rem;
}
.live-panel-close {
  font-size: 1.1rem;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  color: #4d5d50;
}
.live-panel-close:hover {
  background: #e2ecd9;
}
.live-panel-body {
  padding: 8px 11px 10px;
  display: grid;
  gap: 6px;
}

/* --------------------------------------------------------------- credits */
.map-footer .credits a {
  color: inherit;
}
#live-credit[hidden] {
  display: none;
}

@media (max-width: 760px), (orientation: landscape) and (max-height: 520px) and (max-width: 1000px) {
  .motion.has-timebar {
    max-width: calc(100% - 16px - var(--safe-left) - var(--safe-right));
  }
  .live-panel-close {
    min-width: 44px;
    min-height: 44px;
  }
  .timebar {
    flex-wrap: wrap;
  }
  .timebar-track {
    flex-basis: 100%;
  }
  .live-panels {
    top: 58px;
    left: calc(8px + var(--safe-left));
    right: calc(58px + var(--safe-right));
    width: auto;
    max-height: 45%;
  }
  .map-footer .credits span {
    display: inline;
    width: auto;
  }
  /* With several live layers on the credit line runs to five lines and
     covers the time bar. Keep it to two lines; the rest scrolls (track G). */
  .map-footer .credits {
    line-height: 1.25;
    max-height: 2.5em;
    overflow-y: auto;
  }
  /* The taller bar would cover the scale. Lift the scale above it. */
  .stage:has(.motion.has-timebar) .maplibregl-ctrl-bottom-right {
    bottom: calc(61px + var(--safe-bottom) + var(--timebar-height, 128px)) !important;
  }
}

.strike-history-panel summary, .strike-history-panel button { cursor: pointer; }
.strike-history-panel summary { padding-block: 3px; }
.strike-history-panel button { color: #234f39; background: #e5ecdf; padding: 4px 8px; border-radius: 4px; }
.strike-history-panel a { color: #24563d; }
.strike-timeline { padding: 3px 0 9px; border-bottom: 1px solid #d7dfd1; }
.strike-readout, .strike-actions, .strike-key, .strike-scale {
  display: flex; align-items: center; justify-content: space-between;
}
.strike-readout label, .strike-mode, .strike-scale, .strike-key { font-size: .72rem; }
.strike-readout label { color: #4a6053; }
.strike-mode { color: #345740; font-weight: 650; }
.strike-mode[data-live="true"]::before {
  display: inline-block; content: ""; background: #2c794e; width: 7px; height: 7px;
  border-radius: 50%; margin-right: 5px;
}
.strike-stamp { display: block; font-size: 1.08rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.strike-scrubber { display: grid; grid-template-columns: 44px minmax(0,1fr) 44px; gap: 6px; margin: 10px 0; }
.strike-history-panel .strike-scrubber button { align-self: start; min-height: 35px; font-size: .72rem; font-weight: 600; padding-inline: 2px; }
.strike-scrubber input { display: block; width: 100%; min-height: 32px; margin: 0; accent-color: #275b42; cursor: pointer; }
.strike-scale { color: #526657; font-variant-numeric: tabular-nums; }
.strike-history-panel button:disabled { opacity: .45; cursor: default; }
.strike-actions { justify-content: start; gap: 7px; }
.strike-history-panel .strike-actions button { min-height: 33px; padding-inline: 12px; }
.strike-history-panel .strike-play { color: white; background: #28533d; font-weight: 650; }
.strike-play::before { content: ""; display: inline-block; margin-right: 7px; border-block: 4px solid transparent; border-left: 7px solid currentColor; }
.strike-play[aria-pressed="true"]::before { width: 7px; height: 9px; border: 0; border-inline: 2px solid currentColor; }
.strike-time { margin-top: 10px; font-size: .77rem; }
.strike-key { margin-top: 5px; justify-content: start; gap: 7px; color: #526657; }
.strike-key[hidden], .strike-live[hidden] { display: none; }
.strike-key > div { display: flex; gap: 4px; }
.strike-key i { width: 9px; height: 9px; border: 1px solid #675846; border-radius: 50%; }
.strike-distance { font-weight: 600; }
.strike-address { display: grid; gap: 4px; }
.strike-address label { display: grid; }
.strike-address input { width: 100%; padding: 4px; color: #1c3b2d; background: #fff; border: 1px solid #899987; }
.strike-address-result { font-size: .76rem; }
.strike-property-pin { display: block; width: 16px; height: 16px; border: 3px solid #123f52; border-radius: 50%; background: #9ae3ff; box-shadow: 0 0 0 2px white; pointer-events: none; }
.strike-network iframe { display: block; width: 100%; height: 205px; border: 0; }

.maplibregl-canvas.strike-picking { cursor: crosshair; }

.strike-observation dl { margin: 9px 0; }
.strike-observation dt { font-size: 12px; color: #516b5a; }
.strike-observation dd { margin: 2px 0 7px; font-variant-numeric: tabular-nums; }

.motion .timebar[hidden], .motion .radar-replay[hidden],
.motion .timebar-actions [hidden] { display: none; }
.timebar { flex-wrap: wrap; }
.timebar-actions { display: flex; gap: 5px; }
.timebar-actions button, .radar-replay button {
  border: 1px solid #c3d2c3; border-radius: 5px; padding: 5px 9px;
  background: #f5f8f0; color: #224c36; font-size: .76rem; white-space: nowrap;
}
.radar-replay {
  flex: 1 0 100%; min-width: 0; border-top: 1px solid #d6dfd2; padding-top: 7px;
}
.rain-heading, .rain-controls { display: flex; align-items: center; gap: 10px; }
.rain-heading { justify-content: space-between; }
.rain-heading strong, .rain-heading span { display: block; }
.rain-heading strong { font-size: .88rem; font-variant-numeric: tabular-nums; }
.rain-controls { margin-top: 6px; }
.rain-track { flex: 1; min-width: 85px; }
.rain-track .timebar-scale { font-size: .65rem; height: 1rem; }
.rain-track input { display: block; width: 100%; margin: 0; accent-color: #28533d; cursor: pointer; }
.radar-replay .rain-play { background: #28533d; color: white; min-width: 84px; }
.radar-replay button:disabled { opacity: .55; }
.rain-latest[aria-pressed="true"] { background: #e1ecd9; }
.rain-status { display: block; color: #506353; font-size: .68rem; margin-top: 4px; min-height: 1.25em; }

.rain-legend { margin-top: 5px; color: #425d50; font-size: .67rem; }
.rain-bands { display: grid; grid-template-columns: repeat(10, 1fr); gap: 1px; margin-top: 2px; }
.rain-bands span { border-top: 5px solid var(--rain-colour); font-variant-numeric: tabular-nums; }
.rain-footer { display: flex; justify-content: space-between; align-items: baseline; gap: 7px; }
.rain-bom { color: #27583f; font-size: .73rem; white-space: nowrap; }

.strike-selected-dot {
  width: 13px; height: 13px; border: 2px solid #302d29; border-radius: 50%;
  box-shadow: 0 0 0 2px white; pointer-events: none;
}
.strike-zoom {
  margin-top: 8px; padding: 5px 9px; border-radius: 4px;
  background: #28533d; color: white; cursor: pointer;
}

.strike-accuracy { margin-top: 6px; }
.strike-accuracy summary { cursor: pointer; color: #365943; }

@media (max-width: 760px), (orientation: landscape) and (max-height: 520px) and (max-width: 1000px) {
  /* Dock the detail on small screens so it stays readable while the dot moves. */
  .maplibregl-popup.strike-detail-popup {
    top: 62px;
    left: calc(10px + var(--safe-left, 0px));
    width: min(270px, calc(100% - 80px - var(--safe-left, 0px) - var(--safe-right, 0px)));
    max-height: calc(100% - 74px - var(--safe-bottom, 0px));
    transform: none !important;
    will-change: auto;
    z-index: 5;
  }
  aside.open ~ .stage .strike-detail-popup { visibility: hidden; }
  .strike-detail-popup .maplibregl-popup-tip { display: none; }
  .strike-detail-popup .maplibregl-popup-content {
    width: 100%; overflow: auto; overscroll-behavior: contain;
    box-shadow: 0 2px 14px #142d3540; border: 1px solid #bdcbbd; border-radius: 8px;
    padding: 10px 12px !important;
  }
  .strike-detail-popup .maplibregl-popup-close-button {
    width: 44px; height: 44px; color: #284b36; font-size: 22px !important;
  }
  .strike-observation > strong { display: block; margin-right: 32px; }
  .strike-observation dl { margin: 6px 0; }
  .strike-observation dd { margin: 1px 0 5px; }
  .strike-observation .strike-zoom { min-height: 44px; margin: 0; padding-inline: 12px; }
  .strike-accuracy { margin: 0; }
  .strike-accuracy summary { min-height: 44px; padding-block: 12px; font-size: 12px; }
}

@media (orientation: landscape) and (max-height: 300px) and (max-width: 1000px) {
  .strike-observation { display: flex; flex-direction: column; }
  .strike-observation .strike-zoom { order: -1; align-self: start; margin-bottom: 4px; }
}

.motion .timebar.strike-collapsed, .motion:has(.timebar[hidden]) .strike-map-toggle { display: none; }
.motion .strike-map-toggle {
  color: #28533d; border: 1px solid #c3d0c3; border-radius: 4px;
  padding: 5px 7px; font-size: .73rem;
}

@media (orientation: landscape) and (max-height: 520px) and (max-width: 1000px) {
  .motion.has-timebar {
    max-width: min(560px, calc(100% - 16px - var(--safe-left) - var(--safe-right)));
    bottom: calc(38px + var(--safe-bottom));
  }
  .timebar-track {
    flex: 1 1 130px;
  }
  .live-panels {
    left: auto;
    right: calc(8px + var(--safe-right));
    width: min(300px, 45%);
    max-height: calc(100% - 96px - var(--safe-bottom));
  }
  .map-footer {
    flex-wrap: nowrap;
    align-items: center;
  }
  .map-footer > span {
    width: auto;
  }
  .stage:has(.motion.has-timebar) .maplibregl-ctrl-bottom-right {
    bottom: calc(33px + var(--safe-bottom)) !important;
  }
}
