:root {
  color-scheme: light;
  --ink: #102a43;
  --muted: #52677c;
  --line: #d9e2ec;
  --surface: #ffffff;
  --surface-soft: #f2f6fa;
  --advisory: #ffda2f;
  --warning: #c1121f;
  --danger: #7024a8;
  --emergency: #111111;
  --shadow: 0 12px 32px rgba(16, 42, 67, 0.09);
}

* {
  box-sizing: border-box;
}

html {
  font-family:
    -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI",
    "Yu Gothic", sans-serif;
  color: var(--ink);
  background: #eaf0f5;
  line-height: 1.6;
}

body {
  margin: 0;
  min-width: 320px;
}

.photo-hero {
  position: relative;
  min-height: 380px;
  overflow: hidden;
  color: #fff;
  background: #102a43;
}

.photo-hero::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    rgba(7, 24, 40, 0.88) 0%,
    rgba(7, 24, 40, 0.55) 46%,
    rgba(7, 24, 40, 0.14) 78%,
    rgba(7, 24, 40, 0.3) 100%
  );
  content: "";
}

.photo-hero img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.photo-hero-content {
  position: relative;
  z-index: 1;
  display: flex;
  width: min(1180px, calc(100% - 32px));
  min-height: 380px;
  margin-inline: auto;
  justify-content: center;
  flex-direction: column;
}

.photo-hero-content p {
  margin-bottom: 8px;
  color: #b8ebef;
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.photo-hero-content h2 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1.25;
  letter-spacing: 0.02em;
  text-shadow: 0 3px 18px rgba(0, 0, 0, 0.45);
}

button,
a {
  font: inherit;
}

.site-header {
  color: #fff;
  background:
    linear-gradient(120deg, rgba(22, 78, 99, 0.95), rgba(16, 42, 67, 0.99)),
    radial-gradient(circle at 80% 10%, #2f80a3, transparent 36%);
  border-bottom: 5px solid #4fb3bf;
}

.header-inner,
main,
footer p {
  width: min(1180px, calc(100% - 32px));
  margin-inline: auto;
}

.header-inner {
  min-height: 148px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 4px;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.eyebrow {
  color: #b8ebef;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.65rem, 4vw, 2.45rem);
  line-height: 1.28;
  letter-spacing: 0.02em;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.35rem, 3vw, 1.85rem);
  line-height: 1.35;
}

.refresh-button {
  flex: 0 0 auto;
  min-height: 48px;
  padding: 10px 18px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 10px;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  font-weight: 800;
  cursor: pointer;
}

.refresh-button:hover,
.refresh-button:focus-visible {
  background: rgba(255, 255, 255, 0.2);
  outline: 3px solid rgba(184, 235, 239, 0.55);
  outline-offset: 2px;
}

.refresh-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

main {
  padding: 28px 0 48px;
}

.status-panel,
.map-section,
.list-section,
.safety-note {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.map-section {
  margin-top: 24px;
  padding: clamp(18px, 4vw, 30px);
}

.map-heading {
  margin-bottom: 14px;
}

.weather-map {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(250px, 0.9fr);
  grid-template-rows: repeat(2, minmax(170px, auto));
  gap: 12px;
}

.map-panel {
  position: relative;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.76), rgba(255, 255, 255, 0.76)),
    repeating-linear-gradient(
      0deg,
      transparent 0,
      transparent 23px,
      rgba(47, 128, 163, 0.08) 24px
    ),
    repeating-linear-gradient(
      90deg,
      transparent 0,
      transparent 23px,
      rgba(47, 128, 163, 0.08) 24px
    ),
    #e9f4f8;
}

.map-panel-main {
  grid-row: 1 / 3;
}

.map-panel h3 {
  position: absolute;
  z-index: 2;
  top: 12px;
  left: 14px;
  margin: 0;
  padding: 4px 9px;
  border-radius: 6px;
  color: #fff;
  background: rgba(16, 42, 67, 0.9);
  font-size: 0.82rem;
}

.map-panel svg {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 210px;
}

.map-panel-main svg {
  min-height: 440px;
}

.municipality-shape {
  stroke: #fff;
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
  cursor: pointer;
  transition:
    opacity 120ms ease,
    stroke-width 120ms ease;
}

.municipality-shape:hover,
.municipality-shape.is-selected {
  stroke: #102a43;
  stroke-width: 3;
  opacity: 0.78;
}

.map-level-none {
  fill: #cbd5df;
}

.map-level-advisory {
  fill: var(--advisory);
}

.map-level-warning {
  fill: var(--warning);
}

.map-level-danger {
  fill: var(--danger);
}

.map-level-emergency {
  fill: var(--emergency);
}

.map-loading,
.map-error {
  grid-column: 1 / -1;
  margin: 0;
  padding: 42px 20px;
  border: 1px dashed #9fb3c4;
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
}

.map-error {
  color: #7d0710;
  background: #fff1f2;
}

.map-selection {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-height: 52px;
  margin-top: 12px;
  padding: 12px 14px;
  border-left: 5px solid #2f80a3;
  background: #edf7fa;
}

.map-selection strong {
  flex: 0 0 auto;
}

.map-selection span {
  color: var(--muted);
  font-size: 0.88rem;
}

.status-panel {
  padding: clamp(18px, 4vw, 30px);
}

.status-topline {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
}

.connection-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 5px;
  color: #0d6b55;
  font-size: 0.9rem;
  font-weight: 800;
}

.connection-state::before {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #16a085;
  content: "";
  box-shadow: 0 0 0 4px rgba(22, 160, 133, 0.13);
}

.connection-state.loading::before {
  background: #4f83a3;
  animation: pulse 1.2s infinite;
}

.connection-state.error {
  color: #a11622;
}

.connection-state.error::before {
  background: #c1121f;
  box-shadow: 0 0 0 4px rgba(193, 18, 31, 0.13);
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

.timestamps {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 12px;
  margin: 0;
}

.timestamps div {
  padding: 8px 12px;
  border-left: 3px solid #4fb3bf;
  background: var(--surface-soft);
}

.timestamps dt {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.timestamps dd {
  margin: 1px 0 0;
  font-size: 0.94rem;
  font-weight: 800;
}

.headline {
  margin: 22px 0 18px;
  padding: 14px 16px;
  border-left: 4px solid #2f80a3;
  background: #edf7fa;
  font-weight: 700;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.legend-item,
.alert-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(0, 0, 0, 0.14);
  border-radius: 999px;
  font-weight: 800;
}

.legend-item {
  min-height: 34px;
  padding: 5px 12px;
  font-size: 0.86rem;
}

.level-advisory {
  color: #2d2700;
  background: var(--advisory);
}

.level-warning {
  color: #fff;
  background: var(--warning);
}

.level-danger {
  color: #fff;
  background: var(--danger);
}

.level-emergency {
  color: #fff;
  background: var(--emergency);
}

.level-none {
  color: #425466;
  background: #edf1f4;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.summary-card {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-top-width: 5px;
  border-radius: 10px;
  background: #fff;
}

.summary-card strong {
  margin-right: 4px;
  font-size: 1.8rem;
  line-height: 1;
}

.summary-card > span:last-child {
  color: var(--muted);
  font-size: 0.85rem;
}

.summary-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.advisory-card {
  border-top-color: var(--advisory);
}

.warning-card {
  border-top-color: var(--warning);
}

.danger-card {
  border-top-color: var(--danger);
}

.emergency-card {
  border-top-color: var(--emergency);
}

.list-section {
  margin-top: 24px;
  padding: clamp(18px, 4vw, 30px);
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.section-heading > p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.section-kicker {
  color: #2f718c;
}

.municipality-groups {
  display: grid;
  gap: 24px;
}

.region-block h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
  font-size: 1.07rem;
}

.region-block h3::after {
  flex: 1;
  height: 1px;
  background: var(--line);
  content: "";
}

.municipality-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.municipality-card {
  min-height: 116px;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 6px solid #9fb3c4;
  border-radius: 10px;
  background: #fff;
}

.municipality-card.is-advisory {
  border-color: #debc15;
  border-left-color: #9b8100;
  background: var(--advisory);
  color: #2d2700;
}

.municipality-card.is-warning {
  border-color: var(--warning);
  border-left-color: #7d0710;
  background: var(--warning);
  color: #fff;
}

.municipality-card.is-danger {
  border-color: var(--danger);
  border-left-color: #441269;
  background: var(--danger);
  color: #fff;
}

.municipality-card.is-emergency {
  border-color: #000;
  border-left-color: #777;
  background: #111;
  color: #fff;
}

.municipality-name {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 900;
  line-height: 1.4;
}

.municipality-code {
  margin-left: 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
}

.municipality-card:not(.is-none) .municipality-code {
  color: currentColor;
  opacity: 0.72;
}

.no-alerts {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.87rem;
  font-weight: 700;
}

.alert-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.alert-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid currentColor;
  font-size: 0.82rem;
}

.municipality-card:not(.is-none) .alert-item {
  border-top-color: rgba(255, 255, 255, 0.42);
}

.municipality-card.is-advisory .alert-item {
  border-top-color: rgba(45, 39, 0, 0.25);
}

.alert-name {
  font-weight: 900;
}

.alert-time {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  opacity: 0.9;
}

.error-card {
  grid-column: 1 / -1;
  padding: 22px;
  border: 2px solid #c1121f;
  border-radius: 12px;
  color: #7d0710;
  background: #fff1f2;
}

.error-card strong {
  display: block;
  margin-bottom: 6px;
  font-size: 1.05rem;
}

.error-card p {
  margin-bottom: 0;
}

.safety-note {
  margin-top: 24px;
  padding: 20px 22px;
  border-left: 6px solid #2f80a3;
}

.safety-note strong {
  display: block;
  margin-bottom: 5px;
}

.safety-note p {
  margin-bottom: 8px;
  color: var(--muted);
}

.safety-note a {
  color: #075985;
  font-weight: 800;
}

footer {
  padding: 20px 0 34px;
  color: #5d7285;
  font-size: 0.8rem;
  text-align: center;
}

footer p {
  margin-bottom: 0;
}

@media (max-width: 900px) {
  .municipality-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .status-topline {
    flex-direction: column;
  }

  .timestamps {
    width: 100%;
  }
}

@media (max-width: 600px) {
  .photo-hero,
  .photo-hero-content {
    min-height: 300px;
  }

  .photo-hero::after {
    background: linear-gradient(
      90deg,
      rgba(7, 24, 40, 0.86),
      rgba(7, 24, 40, 0.38)
    );
  }

  .photo-hero img {
    object-position: 62% center;
  }

  .photo-hero-content h2 {
    max-width: 330px;
    font-size: clamp(1.8rem, 9vw, 2.55rem);
  }

  .header-inner {
    min-height: 0;
    padding: 24px 0;
    align-items: stretch;
    flex-direction: column;
  }

  .refresh-button {
    width: 100%;
  }

  main {
    padding-top: 16px;
  }

  .status-panel,
  .map-section,
  .list-section,
  .safety-note {
    border-radius: 12px;
  }

  .timestamps,
  .municipality-grid {
    grid-template-columns: 1fr;
  }

  .weather-map {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
  }

  .map-panel-main {
    grid-row: auto;
  }

  .map-panel-main svg {
    min-height: 320px;
  }

  .map-panel svg {
    min-height: 230px;
  }

  .map-selection {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  .summary-grid {
    gap: 8px;
  }

  .summary-card {
    padding: 12px;
  }

  .summary-card strong {
    font-size: 1.55rem;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .municipality-card {
    min-height: 100px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
