/* Weather225 Roads & Weather */

:root {
  --w225-navy: #0b1e33;
  --w225-sky: #2aa8ff;
  --w225-sky-dark: #1688d9;
  --w225-ink: #eaf2fb;
  --w225-muted: #9db4cc;
  --w225-line: rgba(255, 255, 255, 0.14);
  --w225-radius: 10px;
  --w225-font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: var(--w225-navy);
  font-family: var(--w225-font);
  color: var(--w225-ink);
}

#map {
  position: fixed;
  inset: 0;
  background: #1c2128;
}

.leaflet-container { font-family: var(--w225-font); }
.leaflet-control-zoom a { color: #12263a; }

/* ---------- Floating card ---------- */

.card {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 1000;
  width: 340px;
  max-height: calc(100% - 24px);
  overflow-y: auto;
  padding: 14px 16px 12px;
  background: rgba(11, 30, 51, 0.94);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border: 1px solid var(--w225-line);
  border-radius: var(--w225-radius);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.count-block { display: flex; align-items: center; gap: 12px; min-width: 0; }

.alert-count {
  min-width: 48px;
  font-size: 40px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: #fff;
}

.alert-count.has-alerts { color: #ffb347; }
.alert-count.all-clear { color: #52d68a; }

.head-text { min-width: 0; }

.brand {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--w225-sky);
}

.title {
  margin: 2px 0 0;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.2;
  color: #fff;
}

.sub { margin-top: 2px; font-size: 12.5px; color: var(--w225-muted); }

.icon-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid var(--w225-line);
  border-radius: 8px;
  background: transparent;
  color: var(--w225-ink);
  cursor: pointer;
}

.icon-btn:hover { background: rgba(255, 255, 255, 0.08); }
.icon-btn svg { transition: transform 0.15s ease; }
.card.collapsed .icon-btn svg { transform: rotate(180deg); }

.card-body { margin-top: 12px; }
.card.collapsed .card-body { display: none; }

.meta { margin: 0; padding: 0; }

.meta-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  border-top: 1px solid var(--w225-line);
  font-size: 13px;
}

.meta-row[hidden] { display: none; }
.meta-row dt { color: var(--w225-muted); }
.meta-row dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.status-msg { margin: 8px 0 0; font-size: 12.5px; line-height: 1.4; color: var(--w225-muted); }
.status-msg:empty { display: none; }
.status-msg.is-error { color: #ff9b8f; }
.status-msg.is-warn { color: #ffd37a; }
.status-msg.is-good { color: #7be0a4; }

.group { margin: 14px 0 0; padding: 0; border: 0; }

.group legend {
  padding: 0;
  margin-bottom: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--w225-muted);
}

.note { margin: 4px 4px 0; font-size: 12px; line-height: 1.4; color: var(--w225-muted); }
.note:empty { display: none; }
.note.is-warn { color: #ffd37a; }

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 4px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}

.check-row:hover { background: rgba(255, 255, 255, 0.07); }

.check-row input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--w225-sky);
  cursor: pointer;
}

.check-row.is-disabled { opacity: 0.55; cursor: default; }
.check-row.is-sub { padding-left: 22px; }

.row-name { flex: 1 1 auto; }

.row-count {
  min-width: 20px;
  text-align: right;
  font-size: 13px;
  color: var(--w225-muted);
  font-variant-numeric: tabular-nums;
}

.actions { display: flex; gap: 8px; margin-top: 12px; }

.btn {
  flex: 1 1 0;
  padding: 9px 12px;
  border: 1px solid var(--w225-line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--w225-ink);
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}

.btn:hover { background: rgba(255, 255, 255, 0.12); }

.btn-primary { background: var(--w225-sky); border-color: var(--w225-sky); color: #05131f; }
.btn-primary:hover { background: var(--w225-sky-dark); border-color: var(--w225-sky-dark); }
.btn[disabled] { opacity: 0.6; cursor: progress; }

button:focus-visible,
input:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.segmented { display: flex; border: 1px solid var(--w225-line); border-radius: 8px; overflow: hidden; }

.segmented button {
  flex: 1 1 0;
  padding: 8px 6px;
  border: 0;
  background: transparent;
  color: var(--w225-ink);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.segmented button + button { border-left: 1px solid var(--w225-line); }
.segmented button:hover { background: rgba(255, 255, 255, 0.08); }

.segmented button[aria-pressed="true"] {
  background: var(--w225-sky);
  color: #05131f;
  font-weight: 700;
}

/* Alert list */

.alert-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--w225-line);
  border-radius: 8px;
}

.alert-list:empty { display: none; }

.alert-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-top: 1px solid var(--w225-line);
  font-size: 13px;
  cursor: pointer;
}

.alert-list li:first-child { border-top: 0; }
.alert-list li:hover { background: rgba(255, 255, 255, 0.08); }

.alert-list .a-dot {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.6);
}

.alert-list .a-info { flex: 1 1 auto; min-width: 0; }
.alert-list .a-event { font-weight: 600; }
.alert-list .a-area { color: var(--w225-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-list .list-more { cursor: default; color: var(--w225-muted); font-size: 12px; }

.foot {
  margin: 12px 0 0;
  padding-top: 8px;
  border-top: 1px solid var(--w225-line);
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--w225-muted);
}

/* ---------- Legend ---------- */

.legend {
  position: fixed;
  left: 12px;
  bottom: 28px;
  z-index: 1000;
  width: 280px;
  max-height: 55%;
  overflow-y: auto;
  padding: 8px 12px;
  background: rgba(11, 30, 51, 0.94);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border: 1px solid var(--w225-line);
  border-radius: var(--w225-radius);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
  font-size: 12px;
}

.legend:empty { display: none; }

.legend h2 {
  margin: 8px 0 4px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--w225-muted);
}

.legend h2:first-child { margin-top: 0; }

.legend-row { display: flex; flex-wrap: wrap; gap: 3px 12px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }

.sw-line { display: inline-block; width: 18px; height: 5px; border-radius: 3px; }
.sw-box { display: inline-block; width: 12px; height: 12px; border-radius: 3px; border: 1px solid rgba(255, 255, 255, 0.6); }

/* ---------- Popups ---------- */

.w225-popup .leaflet-popup-content-wrapper { border-radius: var(--w225-radius); padding: 0; overflow: hidden; }

.w225-popup .leaflet-popup-content {
  margin: 0;
  font-family: var(--w225-font);
  font-size: 13px;
  line-height: 1.45;
  color: #12263a;
}

.pop-head { padding: 10px 14px; background: var(--w225-navy); color: #fff; }
.pop-event { margin: 0 0 4px; font-size: 15px; font-weight: 700; line-height: 1.25; }

.pop-chip {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  color: #111;
}

.pop-body { padding: 10px 14px 12px; }
.pop-body p { margin: 0 0 8px; }
.pop-label { display: block; font-size: 11.5px; font-weight: 700; color: #4b627a; }

.pop-desc {
  max-height: 150px;
  overflow-y: auto;
  padding: 8px 10px;
  border-radius: 6px;
  background: #eef3f8;
  white-space: pre-line;
  font-size: 12.5px;
}

/* ---------- Mobile ---------- */

@media (max-width: 640px) {
  .card {
    top: calc(8px + env(safe-area-inset-top, 0px));
    right: calc(8px + env(safe-area-inset-right, 0px));
    left: calc(8px + env(safe-area-inset-left, 0px));
    width: auto;
    max-height: 68%;
    padding: 10px 12px;
  }

  .alert-count { font-size: 32px; min-width: 38px; }
  .title { font-size: 17px; }
  .card-body { margin-top: 8px; }
  .group { margin-top: 10px; }
  .foot { display: none; }
  .alert-list { max-height: 180px; }

  .legend {
    left: calc(8px + env(safe-area-inset-left, 0px));
    right: calc(8px + env(safe-area-inset-right, 0px));
    bottom: calc(26px + env(safe-area-inset-bottom, 0px));
    width: auto;
    max-height: 32%;
    padding: 6px 10px;
    font-size: 11px;
  }

  .leaflet-control-zoom { display: none; }
}

@media (max-width: 380px) {
  .actions { flex-direction: column; }
}

@media (pointer: coarse) {
  .btn,
  .segmented button { min-height: 44px; }
  .check-row { min-height: 44px; }
  .icon-btn { width: 44px; height: 44px; }
  .alert-list li { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  .icon-btn svg { transition: none; }
}
