/* Natural Disaster Alert - app styles */
:root {
  --ink: #13262b;
  --muted: #56696d;
  --chrome: #0f2e35;
  --chrome-2: #18454f;
  --mist: #eef3f2;
  --paper: #ffffff;
  --line: #d4dfdd;
  --act: #0b7a75;
  --act-ink: #ffffff;
  --l0: #5f8f80;
  --l1: #f2c200;
  --l2: #f07f00;
  --l3: #d3202f;
  --l1-ink: #2b2300;
  --l2-ink: #2a1400;
  --l3-ink: #ffffff;
  --radius-s: 6px;
  --radius-m: 12px;
  --tabs-h: 64px;
  --top-h: 54px;
  --font: "Noto Sans", "Noto Sans Sinhala", "Noto Sans Tamil", system-ui, sans-serif;
}
:root:lang(si) { --font: "Noto Sans Sinhala", "Noto Sans", system-ui, sans-serif; }
:root:lang(ta) { --font: "Noto Sans Tamil", "Noto Sans", system-ui, sans-serif; }

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e6efee;
    --muted: #9fb3b4;
    --mist: #0c1d21;
    --paper: #132a2f;
    --line: #24434a;
    --act: #3fb7ae;
    --act-ink: #062a28;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--mist);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--act); }
svg.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 3px solid var(--act); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.top {
  height: calc(var(--top-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0;
  display: flex; align-items: center; gap: 10px;
  background: var(--chrome); color: #fff;
  position: relative; z-index: 1001;
}
.brand { display: flex; align-items: center; gap: 8px; color: #fff; text-decoration: none; font-weight: 800; font-size: 17px; min-width: 0; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.langs { margin-left: auto; display: flex; background: var(--chrome-2); border-radius: 999px; padding: 3px; }
.langs button {
  border: 0; background: transparent; color: #cfe3e2; padding: 5px 9px; border-radius: 999px; cursor: pointer; font-size: 13px; min-height: 32px;
}
.langs button.on { background: #fff; color: var(--chrome); font-weight: 600; }
.sos {
  display: flex; align-items: center; gap: 6px; background: var(--l3); color: #fff; text-decoration: none;
  font-weight: 800; padding: 0 12px; height: 38px; border-radius: 999px; white-space: nowrap; font-size: 14px;
}
.sos svg { width: 16px; height: 16px; fill: #fff; stroke: none; }
@media (max-width: 420px) { .sos span { display: none; } .sos { width: 44px; justify-content: center; padding: 0; } }

/* ---------- island-wide banner ---------- */
.banner {
  position: relative; z-index: 1000;
  display: flex; gap: 10px; align-items: center; padding: 10px 14px;
  font-weight: 600; cursor: pointer; border: 0; width: 100%; text-align: left;
}
.banner.lv1 { background: var(--l1); color: var(--l1-ink); }
.banner.lv2 { background: var(--l2); color: var(--l2-ink); }
.banner.lv3 { background: var(--l3); color: var(--l3-ink); }

/* ---------- shell ---------- */
.shell { position: relative; height: calc(100% - var(--top-h) - env(safe-area-inset-top)); }
body.has-banner .shell { height: calc(100% - var(--top-h) - env(safe-area-inset-top) - 46px); }
.map-view { position: absolute; inset: 0 0 var(--tabs-h) 0; }
#map { position: absolute; inset: 0; background: #dfe8e7; }
.pane {
  position: absolute; inset: 0 0 var(--tabs-h) 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--mist); padding: 16px 16px 32px; display: none;
}
.pane.is-active { display: block; }
.pane > * { max-width: 640px; margin-left: auto; margin-right: auto; }

.panel { position: absolute; inset: 0; pointer-events: none; }
.panel > * { pointer-events: auto; }
.tabs {
  position: absolute; left: 0; right: 0; bottom: 0; height: calc(var(--tabs-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--paper); border-top: 1px solid var(--line); z-index: 1000;
}
.tabs button {
  border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: 12px; cursor: pointer; position: relative; min-height: 44px; padding: 4px 2px;
}
.tabs button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tabs button.on { color: var(--act); font-weight: 600; }
.tabs button.on::before { content: ""; position: absolute; top: 0; left: 25%; right: 25%; height: 3px; background: var(--act); border-radius: 0 0 3px 3px; }
.count {
  position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--l3); color: #fff; font-size: 11px; line-height: 18px; font-weight: 800;
}

/* wide screens: map left, panel right */
@media (min-width: 960px) {
  .map-view { inset: 0 420px 0 0; display: block !important; }
  .panel { left: auto; width: 420px; background: var(--mist); border-left: 1px solid var(--line); pointer-events: auto; }
  .tabs { position: absolute; top: 0; bottom: auto; height: 60px; padding: 0; grid-template-columns: repeat(3, 1fr); border-top: 0; border-bottom: 1px solid var(--line); }
  .tabs .tab-map { display: none; }
  .tabs button.on::before { top: auto; bottom: 0; border-radius: 3px 3px 0 0; }
  .pane { inset: 60px 0 0 0; }
}
@media (max-width: 959px) {
  .map-view { display: none; }
  .map-view.is-active { display: block; }
}

/* ---------- map overlays ---------- */
.chips {
  position: absolute; top: 10px; left: 10px; right: 10px; z-index: 500;
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  padding: 6px 12px; border-radius: 999px; font-size: 13px; cursor: pointer; min-height: 36px;
  display: flex; align-items: center; gap: 6px; box-shadow: 0 1px 2px rgba(15, 46, 53, .18);
}
.chip i { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.chip.on { background: var(--chrome); color: #fff; border-color: var(--chrome); }
.chip.on i { background: #fff; }
.chip[disabled] { opacity: .45; cursor: default; }
.legend {
  position: absolute; left: 10px; bottom: 26px; z-index: 500; background: var(--paper); border-radius: var(--radius-s);
  padding: 6px 8px; font-size: 12px; display: flex; flex-direction: column; gap: 3px; box-shadow: 0 1px 3px rgba(15, 46, 53, .22);
}
.legend div { display: flex; align-items: center; gap: 6px; }
.legend b { width: 14px; height: 10px; border-radius: 2px; display: inline-block; }
.stamp {
  position: absolute; right: 58px; bottom: 26px; z-index: 500; font-size: 12px; color: var(--muted);
  background: var(--paper); padding: 3px 8px; border-radius: 999px; box-shadow: 0 1px 3px rgba(15, 46, 53, .2);
}
.stamp.stale { color: var(--l3); font-weight: 600; }
.leaflet-container { font-family: var(--font); }
.leaflet-popup-content { margin: 12px 14px; font-size: 14px; line-height: 1.45; }
.leaflet-popup-content h4 { margin: 0 0 4px; font-size: 15px; }
.ev-icon {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; color: #fff;
  border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.35);
}
.ev-icon svg { width: 16px; height: 16px; }

/* ---------- level colours ---------- */
.lv0 { --lv: var(--l0); --lv-ink: #fff; }
.lv1 { --lv: var(--l1); --lv-ink: var(--l1-ink); }
.lv2 { --lv: var(--l2); --lv-ink: var(--l2-ink); }
.lv3 { --lv: var(--l3); --lv-ink: var(--l3-ink); }
.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 999px; font-size: 13px; font-weight: 600;
  background: var(--lv); color: var(--lv-ink); white-space: nowrap;
}

/* The warning board: the one loud element */
.board {
  position: relative; background: var(--lv); color: var(--lv-ink); border-radius: var(--radius-m);
  padding: 14px 16px 14px 34px; margin-bottom: 14px; overflow: hidden;
}
.board::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 18px;
  background: repeating-linear-gradient(135deg, rgba(0,0,0,.82) 0 8px, transparent 8px 16px);
}
.board.lv0::before { background: repeating-linear-gradient(135deg, rgba(255,255,255,.35) 0 8px, transparent 8px 16px); }
.board .place { font-size: 15px; font-weight: 600; opacity: .9; }
.board .word { font-size: clamp(30px, 8vw, 40px); font-weight: 800; line-height: 1.1; letter-spacing: -.01em; }
.board .what { font-size: 15px; margin-top: 2px; }

/* ---------- content blocks ---------- */
h2 { font-size: 20px; line-height: 1.3; margin: 4px 0 12px; }
h3 { font-size: 16px; margin: 0 0 8px; }
.block { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 14px 16px; margin-bottom: 12px; }
.muted { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.stat .n { font-size: 22px; font-weight: 800; line-height: 1.2; }
.stat .n small { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 2px; }
.stat .k { font-size: 13px; color: var(--muted); }
.hz-list { list-style: none; margin: 0; padding: 0; }
.hz-list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.hz-list li:first-child { border-top: 0; }
.hz-list .name { flex: 1; font-weight: 600; }
.hz-list .val { color: var(--muted); font-size: 14px; }
.hz-ico { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--lv, var(--mist)); color: var(--lv-ink, var(--ink)); }
.hz-ico svg { width: 18px; height: 18px; }

.bars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; align-items: end; height: 120px; margin-top: 8px; }
.bar { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; font-size: 13px; }
.bar i { display: block; width: 100%; max-width: 54px; border-radius: 4px 4px 0 0; background: #5aa0c8; min-height: 2px; }
.bar i.lv1 { background: var(--l1); } .bar i.lv2 { background: var(--l2); } .bar i.lv3 { background: var(--l3); }
.bar b { font-size: 14px; }
.spark { width: 100%; height: 70px; display: block; margin-top: 6px; }

/* alerts */
.alert { background: var(--paper); border: 1px solid var(--line); border-left: 8px solid var(--lv); border-radius: var(--radius-m); padding: 12px 14px; margin-bottom: 12px; }
.alert .head { display: flex; gap: 10px; align-items: flex-start; }
.alert .title { font-size: 17px; font-weight: 800; line-height: 1.3; }
.alert .where { font-size: 14px; color: var(--muted); }
.alert p { margin: 8px 0; }
.alert .foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.tag { border: 1px solid var(--line); border-radius: 999px; padding: 0 8px; }
.tag.off { background: var(--chrome); color: #fff; border-color: var(--chrome); }
.alert.focus { box-shadow: 0 0 0 3px var(--act); }
.empty { text-align: center; padding: 28px 10px; color: var(--muted); }
.empty svg { width: 40px; height: 40px; color: var(--l0); margin-bottom: 8px; }

/* forms and buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border-radius: 999px; border: 1px solid var(--act); background: var(--act); color: var(--act-ink); font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn.ghost { background: transparent; color: var(--act); }
.btn.wa { background: #1f9d55; border-color: #1f9d55; color: #fff; min-height: 36px; padding: 0 12px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn.block-w { width: 100%; }
select, input[type=email] {
  width: 100%; min-height: 44px; border: 1px solid var(--line); border-radius: var(--radius-s); padding: 0 12px; background: var(--paper);
}
label.f { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
.note { font-size: 14px; padding: 10px 12px; background: var(--mist); border-radius: var(--radius-s); margin-top: 10px; }
.ok { color: #1f7a4a; font-weight: 600; }

/* bottom sheet (district details on the map) */
.sheet { position: absolute; left: 0; right: 0; bottom: var(--tabs-h); z-index: 1002; padding: 0 8px 8px; pointer-events: none; }
.sheet-card {
  pointer-events: auto; position: relative; background: var(--mist); border-radius: 16px 16px var(--radius-m) var(--radius-m);
  max-height: 62vh; overflow-y: auto; padding: 14px; box-shadow: 0 -4px 20px rgba(15, 46, 53, .28); max-width: 560px; margin: 0 auto;
  animation: up .2s ease-out;
}
@keyframes up { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-close { position: absolute; top: 18px; right: 18px; z-index: 2; border: 0; background: rgba(0,0,0,.18); color: inherit; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; }
.sheet-close svg { width: 18px; height: 18px; }
@media (min-width: 960px) {
  .sheet { right: 420px; bottom: 0; top: auto; }
}
@media (prefers-reduced-motion: reduce) { .sheet-card { animation: none; } }

dl.src { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 14px; }
dl.src dt { font-weight: 600; }
dl.src dd { margin: 0; color: var(--muted); }
.links a { display: block; padding: 8px 0; border-top: 1px solid var(--line); text-decoration: none; }
.links a:first-child { border-top: 0; }
