/* ============================================================
   RADAR SECTION — append to styles.css
   Uses existing tokens: --surface, --border, --accent, --r-card, --sp-*
   ============================================================ */

.radar-sec {
  background: var(--panel-grad);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: var(--sp-md);
  margin-bottom: var(--sp-lg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--panel-glow);
  position: relative;
  overflow: hidden;
  /* Header je sticky — bez ovoga naslov zavuce pod njega pri skoku na sekciju */
  scroll-margin-top: 90px;
}
.radar-sec::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(99,207,255,.28), transparent);
}

/* ---------- Header ---------- */
.radar-hdr {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-sm);
  flex-wrap: wrap;
  margin-bottom: var(--sp-sm);
}
.radar-src {
  font-size: 10px;
  color: var(--muted);
  opacity: .7;
  letter-spacing: .3px;
}
.radar-src a { color: inherit; text-decoration: none; border-bottom: 1px solid rgba(255,255,255,.14); }
.radar-src a:hover { color: var(--accent); }

/* ---------- Readout: the answer, before the map ---------- */
.radar-readout {
  display: flex;
  align-items: center;
  gap: clamp(10px, 2vw, 16px);
  padding: 12px 14px;
  margin-bottom: var(--sp-sm);
  border-radius: 16px;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.06);
  flex-wrap: wrap;
}
.radar-clock {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.radar-time {
  font-family: 'Syne', sans-serif;
  font-size: clamp(24px, 4.4vw, 32px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.5px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.radar-rel {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.radar-kind {
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  background: rgba(126,190,255,.12);
  border: 1px solid rgba(126,190,255,.2);
  color: #a7e6ff;
  white-space: nowrap;
}
.radar-kind.is-forecast {
  background: rgba(200,168,255,.14);
  border-color: rgba(200,168,255,.26);
  color: #d9c4ff;
}

/* ---------- Controls ---------- */
.radar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.radar-btn {
  width: 42px;
  height: 42px;
  min-width: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 13px;
  border: 1px solid rgba(116,190,255,.18);
  background: rgba(10,25,48,.72);
  color: var(--text);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: background .2s, border-color .2s, transform .15s;
  -webkit-tap-highlight-color: transparent;
}
.radar-btn:hover { background: rgba(15,33,62,.92); border-color: var(--border2); }
.radar-btn:active { transform: scale(.94); }
.radar-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.radar-btn-play {
  background: linear-gradient(180deg, rgba(74,170,245,.24), rgba(50,126,210,.16));
  border-color: rgba(99,207,255,.28);
  color: #cbeeff;
}

/* ---------- Timeline scrubber ---------- */
.radar-timeline {
  position: relative;
  margin-bottom: var(--sp-sm);
  padding: 4px 0 2px;
}
.radar-track {
  display: flex;
  gap: 2px;
  height: 22px;
  align-items: flex-end;
  pointer-events: none;
}
.radar-tick {
  flex: 1;
  height: 8px;
  border-radius: 2px;
  background: rgba(255,255,255,.07);
  transition: height .18s ease, background .18s ease;
}
.radar-tick.is-passed { background: rgba(126,190,255,.24); }
.radar-tick.is-forecast { background: rgba(200,168,255,.12); }
.radar-tick.is-forecast.is-passed { background: rgba(200,168,255,.3); }
.radar-tick.is-active {
  height: 20px;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(99,207,255,.4);
}
.radar-tick.is-forecast.is-active {
  background: var(--purple);
  box-shadow: 0 0 12px rgba(200,168,255,.4);
}

/* Range input sits invisibly on top of the ticks for scrubbing */
.radar-slider {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}
.radar-slider:focus-visible + .radar-track { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.radar-slider::-webkit-slider-thumb { -webkit-appearance: none; width: 30px; height: 30px; }
.radar-slider::-moz-range-thumb { width: 30px; height: 30px; border: 0; }

/* ---------- Map shell ---------- */
.radar-shell { position: relative; }
#radarMap {
  width: 100%;
  height: clamp(300px, 46vw, 440px);
  border-radius: calc(var(--r-card) - 6px);
  overflow: hidden;
  background: rgba(255,255,255,.03);
  border: 1px solid rgba(255,255,255,.06);
  box-shadow: inset 0 2px 12px rgba(0,0,0,.3);
  z-index: 0;
}

/* Loading / error overlay */
.radar-status {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  padding: var(--sp-md);
  border-radius: calc(var(--r-card) - 6px);
  background: rgba(6,14,28,.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 500;
}
.radar-shell.is-loading .radar-status,
.radar-shell.is-error .radar-status { display: flex; }
.radar-status strong {
  font-family: 'Syne', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
.radar-status span { font-size: 13px; color: var(--muted); }
.radar-spinner {
  width: 30px;
  height: 30px;
  border: 2.5px solid rgba(99,207,255,.16);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.radar-shell.is-error .radar-spinner { display: none; }

/* Pag home marker.
   NEMA transform: translate() — Leaflet vec pozicionira preko iconAnchor.
   Dvostruki pomak bi maknuo tockicu ~25 km na zoom 7. */
.radar-home {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 18px;
  white-space: nowrap;
}
.radar-home-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(99,207,255,.45), 0 0 12px rgba(99,207,255,.7);
  flex-shrink: 0;
}
.radar-home-label {
  font-family: 'Syne', sans-serif;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .6px;
  color: #fff;
  text-shadow: 0 1px 6px rgba(0,0,0,.9);
}

/* ---------- Legend ---------- */
.radar-legend {
  display: flex;
  align-items: center;
  gap: clamp(8px, 2vw, 16px);
  flex-wrap: wrap;
  margin-top: var(--sp-sm);
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255,255,255,.02);
  border: 1px solid rgba(255,255,255,.04);
}
.radar-legend-lbl {
  font-size: 10px;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.radar-scale { display: flex; align-items: center; gap: 6px; }
.radar-scale-bar {
  width: clamp(90px, 22vw, 150px);
  height: 8px;
  border-radius: 4px;
  /* RainViewer Universal Blue — actual dBZ ramp from their colour table.
     tan ~10 dBZ · cyan 15 · blue 20-34 · yellow 35 · orange 40 · red 45-50 */
  background: linear-gradient(90deg,
    #ded097 0%,
    #88ddee 14%,
    #00a3e0 28%,
    #005588 44%,
    #ffee00 60%,
    #ffaa00 74%,
    #ff4400 88%,
    #c10000 100%);
}
.radar-scale-txt { font-size: 11px; color: var(--muted); }
.radar-rings-note {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
  opacity: .8;
}

/* ---------- Responsive ---------- */
@media (max-width: 700px) {
  .radar-sec { padding: 14px; border-radius: 22px; }

  /* Readout kao grid: red 1 = vrijeme + badge, red 2 = gumbi punom sirinom.
     Prije su gumbi padali u drugi red gurnuti desno pa je lijevo ostajala rupa. */
  .radar-readout {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 12px;
    row-gap: 12px;
    padding: 12px;
    align-items: center;
  }
  .radar-clock { grid-column: 1; grid-row: 1; }
  .radar-kind  { grid-column: 2; grid-row: 1; justify-self: start; }
  .radar-controls {
    grid-column: 1 / -1;
    grid-row: 2;
    margin-left: 0;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
  }
  .radar-btn {
    width: 100%;
    min-width: 0;
    height: 46px;
  }

  .radar-rings-note { margin-left: 0; width: 100%; }
  #radarMap { height: clamp(280px, 62vw, 360px); }
}

@media (max-width: 400px) {
  .radar-time { font-size: 22px; }
  .radar-kind { font-size: 9px; padding: 4px 9px; }
}

/* ---------- Light theme ---------- */
html.light .radar-sec {
  background: linear-gradient(180deg, rgba(255,255,255,.95), rgba(249,251,254,.94));
  border-color: rgba(20,28,44,.09);
  box-shadow: 0 12px 30px rgba(18,30,51,.09);
}
html.light .radar-readout,
html.light .radar-legend,
html.light .radar-tick { background: rgba(244,248,253,.92); border-color: rgba(20,28,44,.08); }
html.light .radar-tick { background: rgba(20,28,44,.08); }
html.light .radar-tick.is-passed { background: rgba(2,136,209,.28); }
html.light .radar-tick.is-active { background: #0288d1; box-shadow: 0 0 10px rgba(2,136,209,.3); }
html.light .radar-time { color: #1f2d45; }
html.light .radar-kind { background: rgba(2,136,209,.1); border-color: rgba(2,136,209,.18); color: #0b4d83; }
html.light .radar-kind.is-forecast { background: rgba(123,31,162,.08); border-color: rgba(123,31,162,.16); color: #6a1b9a; }
html.light .radar-btn {
  background: rgba(255,255,255,.9);
  border-color: rgba(20,28,44,.11);
  color: rgba(20,28,44,.88);
}
html.light .radar-btn:hover { background: #fff; border-color: rgba(2,136,209,.24); }
html.light .radar-btn-play {
  background: linear-gradient(180deg, rgba(2,136,209,.18), rgba(2,136,209,.1));
  border-color: rgba(2,136,209,.28);
  color: #0b4d83;
}
html.light .radar-status { background: rgba(244,248,253,.92); }
html.light .radar-home-label { color: #12263d; text-shadow: 0 1px 4px rgba(255,255,255,.9); }
html.light .radar-home-dot { background: #0288d1; box-shadow: 0 0 0 3px rgba(2,136,209,.25); }
html.light #radarMap { border-color: rgba(20,28,44,.08); box-shadow: inset 0 2px 8px rgba(0,0,0,.06); }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .radar-tick, .radar-btn { transition: none !important; }
  .radar-spinner { animation: none; border-top-color: rgba(99,207,255,.4); }
}

/* ============================================================
   VERDICT — recenica koja odgovara "dolazi li i kad"
   Stoji IZNAD karte jer je karta dokaz, a recenica je odgovor.
   ============================================================ */
.radar-verdict {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: var(--sp-sm);
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.08);
  background: rgba(255,255,255,.03);
  border-left: 3px solid rgba(255,255,255,.14);
  transition: border-color .3s, background .3s;
}
.radar-verdict-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-top: 6px;
  flex-shrink: 0;
  background: var(--muted);
  box-shadow: 0 0 10px currentColor;
}
.radar-verdict-body { min-width: 0; flex: 1; }
.radar-verdict-title {
  font-family: 'Syne', sans-serif;
  font-size: clamp(17px, 2.5vw, 20px);
  font-weight: 800;
  /* Syne 800 ima neobicno duboke repove (g, j, p, y).
     1.2 ih je rezao, 1.34 nije bilo dovoljno — 1.5 + padding je sigurno. */
  line-height: 1.5;
  padding-bottom: 6px;
  margin-top: -2px;
  overflow: visible;
  color: var(--text);
  letter-spacing: -.1px;
  text-wrap: balance;
}
.radar-verdict-detail {
  font-size: clamp(13px, 1.9vw, 14.5px);
  line-height: 1.5;
  color: var(--muted);
  margin-top: 5px;
}
.radar-verdict-meta {
  font-size: 10.5px;
  color: var(--muted);
  opacity: .6;
  margin-top: 6px;
  letter-spacing: .2px;
}

/* Stanja — mirno / pratiti / uskoro / pada */
.radar-verdict.is-calm { border-left-color: rgba(118,239,194,.5); }
.radar-verdict.is-calm .radar-verdict-dot { background: var(--green); }

.radar-verdict.is-watch {
  border-left-color: rgba(99,207,255,.6);
  background: rgba(99,207,255,.05);
}
.radar-verdict.is-watch .radar-verdict-dot { background: var(--accent); }

.radar-verdict.is-soon {
  border-left-color: rgba(255,224,138,.75);
  background: rgba(255,224,138,.07);
}
.radar-verdict.is-soon .radar-verdict-dot { background: var(--lightning); }
.radar-verdict.is-soon .radar-verdict-title { color: #ffe38b; }

.radar-verdict.is-now {
  border-left-color: rgba(255,143,151,.8);
  background: rgba(255,143,151,.08);
}
.radar-verdict.is-now .radar-verdict-dot {
  background: var(--bura);
  animation: verdictPulse 2s ease-in-out infinite;
}
.radar-verdict.is-now .radar-verdict-title { color: #ffb3b8; }

@keyframes verdictPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: .55; transform: scale(.82); }
}

@media (max-width: 700px) {
  .radar-verdict { padding: 13px 14px; gap: 10px; border-radius: 16px; }
}

html.light .radar-verdict {
  background: rgba(244,248,253,.92);
  border-color: rgba(20,28,44,.08);
}
html.light .radar-verdict.is-watch { background: rgba(2,136,209,.06); }
html.light .radar-verdict.is-soon  { background: rgba(227,156,34,.08); }
html.light .radar-verdict.is-soon .radar-verdict-title { color: #8a6400; }
html.light .radar-verdict.is-now   { background: rgba(211,47,47,.06); }
html.light .radar-verdict.is-now .radar-verdict-title { color: #a53737; }

@media (prefers-reduced-motion: reduce) {
  .radar-verdict.is-now .radar-verdict-dot { animation: none; }
}

/* Natpis "ćelija" uz žuti krug na karti */
.radar-cell-tag {
  font-family: 'Syne', sans-serif;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .4px;
  color: #ffe08a;
  text-shadow: 0 1px 5px rgba(0,0,0,.95), 0 0 3px rgba(0,0,0,.9);
  white-space: nowrap;
  pointer-events: none;
}
html.light .radar-cell-tag {
  color: #8a6400;
  text-shadow: 0 1px 4px rgba(255,255,255,.95);
}

/* Objašnjenje žutog kruga — vidljivo samo dok se prati ćelija */
.radar-cell-note {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 8px;
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(255,224,138,.07);
  border: 1px solid rgba(255,224,138,.18);
  font-size: 12px;
  line-height: 1.4;
  color: var(--muted);
}
.radar-cell-note[hidden] { display: none !important; }
.radar-cell-swatch {
  width: 12px; height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid #ffd54f;
  background: rgba(255,213,79,.35);
}
html.light .radar-cell-note {
  background: rgba(227,156,34,.08);
  border-color: rgba(227,156,34,.2);
}
