/* Kan News rain radar widget. Orange (#ff3300) is reserved for the measured
   datum: the played part of the timeline and the latest-frame time. */

@font-face {
  font-family: 'SimplerPro';
  src: url('../brand/fonts/SimplerPro_HLAR-Regular.otf') format('opentype');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'SimplerPro';
  src: url('../brand/fonts/SimplerPro_HLAR-Bold.otf') format('opentype');
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #ffffff;
  --ink: #111111;
  --muted: #5f6b76;
  --rule: #dfe3e7;
  --sea: #dfe8ee;
  --land: #f4f3ef;
  --orange: #ff3300;
  --stale: #c92a2a;
  --pad: 16px;
  --font: 'SimplerPro', Arial, sans-serif;
}

[hidden] { display: none !important; }

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-text-size-adjust: 100%;
}

.widget {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-width: 0;
}

button, select, input { font: inherit; color: inherit; }

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* ---- Headline ---- */

.head { padding: 14px var(--pad) 10px; }

#headline {
  margin: 0;
  font-size: clamp(20px, 3.4vw, 28px);
  font-weight: 700;
  line-height: 1.25;
}

#place {
  appearance: none;
  -webkit-appearance: none;
  max-width: 100%;
  margin: 0;
  padding: 0 0 0 0.85em;
  border: 0;
  border-bottom: 2px solid var(--rule);
  border-radius: 0;
  background: transparent url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 6"%3E%3Cpath d="M0 0h10L5 6z" fill="%235f6b76"/%3E%3C/svg%3E') no-repeat left 0.1em center / 0.5em auto;
  font-weight: 700;
  line-height: inherit;
  cursor: pointer;
  vertical-align: baseline;
}
#place:hover { border-bottom-color: var(--muted); }

.measure {
  position: absolute;
  visibility: hidden;
  white-space: pre;
  font-size: clamp(20px, 3.4vw, 28px);
  font-weight: 700;
}

.sub {
  margin: 4px 0 0;
  font-size: 15px;
  color: var(--muted);
}

/* ---- Alerts strip ---- */

.alerts { border-top: 1px solid var(--rule); }

.alerts-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  padding: 8px var(--pad);
  border: 0;
  background: transparent;
  font-size: 14px;
  line-height: 1.4;
  text-align: start;
  cursor: pointer;
}
.alerts-toggle:hover .alert-text { text-decoration: underline; text-underline-offset: 3px; }
.alerts-toggle:focus-visible { outline-offset: -2px; }

.alert-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.alerts.is-open .alert-text { white-space: normal; }

.alerts-more {
  flex-shrink: 0;
  color: var(--muted);
  white-space: nowrap;
}
.alerts-more::after {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-inline-start: 6px;
  border-left: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: translateY(-2px) rotate(-45deg);
  transition: transform 0.15s;
}
.alerts.is-open .alerts-more::after { transform: translateY(1px) rotate(135deg); }

.alerts-list {
  margin: 0;
  padding: 0 var(--pad) 10px;
  list-style: none;
  font-size: 14px;
  line-height: 1.4;
}
.alerts-list li { display: flex; gap: 8px; padding: 6px 0; border-top: 1px solid var(--rule); }
.alerts-list .dot { margin-top: 0.35em; }

.dot {
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #adb5bd;
}
.dot.red { background: #e03131; }
.dot.orange { background: #f08c00; }
.dot.yellow { background: #fcc419; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15); }
.dot.gray { background: #adb5bd; }

/* ---- Map ---- */

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 220px;
  border-top: 1px solid var(--rule);
}

#map {
  position: absolute;
  inset: 0;
  background: var(--sea);
  font-family: var(--font);
}
#map.is-loading { visibility: hidden; }

.leaflet-container { background: var(--sea); outline: none; }

.city { position: relative; }
.city span {
  position: absolute;
  top: -8px;
  right: -3px;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  font-size: 12px;
  line-height: 16px;
  color: #3d4750;
  text-shadow: 0 0 2px #fff, 0 0 2px #fff, 0 0 3px #fff;
  pointer-events: none;
}
.city span::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #6c7781;
  box-shadow: 0 0 0 1px #fff;
}
.city.major span { font-size: 13px; font-weight: 700; color: var(--ink); }
.city.is-hidden { display: none; }

.stale {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 1000;
  margin: 0;
  padding: 8px var(--pad);
  background: var(--stale);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}

.zoom {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 44px;
}
.stale:not([hidden]) ~ .zoom { top: 48px; }

.zoom button {
  height: 32px;
  padding: 0;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: var(--bg);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.zoom #home { font-size: 12px; }
.zoom button:hover { border-color: var(--muted); }

.legend {
  position: absolute;
  bottom: 10px;
  right: 10px;
  z-index: 1000;
  width: 240px;
  padding: 6px 8px 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 0 0 1px var(--rule);
}
.legend-bar { display: flex; height: 8px; border-radius: 2px; overflow: hidden; }
.legend-bar span { flex: 1; }
.legend-words { display: flex; margin-top: 3px; font-size: 11px; color: var(--muted); }
.legend-words span { text-align: center; }

/* ---- Control bar ---- */

.bar {
  margin-top: auto;
  padding: 10px var(--pad) 12px;
  border-top: 1px solid var(--rule);
}

.player {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

#play {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: var(--bg);
  cursor: pointer;
}
#play svg { width: 14px; height: 14px; fill: var(--ink); }
#play .icon-pause, #play[aria-pressed='true'] .icon-play { display: none; }
#play[aria-pressed='true'] .icon-pause { display: block; }
#play:disabled { opacity: 0.4; cursor: default; }

.track {
  position: relative;
  flex: 1;
  min-width: 0;
  padding-top: 8px;
}

#timeline {
  --p: 1;
  --thumb: 14px;
  --done: calc(var(--thumb) / 2 + var(--p) * (100% - var(--thumb)));
  display: block;
  width: 100%;
  height: 20px;
  margin: 0;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
#timeline::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--orange) var(--done), var(--rule) var(--done));
}
#timeline::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--orange) var(--done), var(--rule) var(--done));
}
#timeline::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: var(--thumb);
  height: var(--thumb);
  margin-top: -5px;
  border: 2px solid var(--bg);
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 0 1px var(--ink);
}
#timeline::-moz-range-thumb {
  width: var(--thumb);
  height: var(--thumb);
  border: 2px solid var(--bg);
  border-radius: 50%;
  background: var(--ink);
}
#timeline:disabled { cursor: default; }

.ticks {
  position: relative;
  height: 14px;
  margin: 0 7px;
  font-size: 11px;
  line-height: 14px;
  color: var(--muted);
}
.ticks span { position: absolute; top: 0; transform: translateX(-50%); }

.time {
  flex-shrink: 0;
  min-width: 3em;
  padding-top: 7px;
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.time.is-latest { color: var(--orange); }

.credit-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 8px;
}
.credit {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
}
.logo { flex-shrink: 0; display: block; height: 22px; width: auto; }

@media (max-width: 599px) {
  :root { --pad: 12px; }
  .head { padding-top: 10px; padding-bottom: 8px; }
  .legend { width: 180px; bottom: 8px; right: 8px; }
  .zoom { top: 8px; left: 8px; }
  .bar { padding-top: 8px; padding-bottom: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}
