:root {
  --caa-navy: #002c77;
  --caa-yellow: #fcb515;
  --slate: #1F2937;
  --red: #D72638;
  --red-ring: #991B1B;
  --row-hover: #F3F4F6;
  --row-selected: #FEE2E2;
  --row-selected-hover: #FECACA;
  --muted: #6b7280;
  --border: #E5E7EB;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; padding: 0; }

/* The HTML `hidden` attribute should always win over explicit display rules
   (e.g. .state-overlay's display:flex). */
[hidden] { display: none !important; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--slate);
  background: var(--caa-navy);
  line-height: 1.4;
}

#root {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.intro {
  margin: 0;
  padding: 10px 16px;
  background: var(--caa-navy);
  color: white;
  font-size: 14px;
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 65% 35%;
  min-height: 0;
}

#map {
  background: var(--caa-navy);
  min-height: 0;
  position: relative;
}

/* Leaflet overrides */
.leaflet-container {
  background: var(--caa-navy) !important;
  font: inherit;
  outline: none;
}

.leaflet-tooltip {
  background: white;
  border: none;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  font-size: 13px;
  padding: 6px 10px;
}
.leaflet-tooltip-top:before { border-top-color: white; }

.leaflet-popup-content-wrapper {
  border-radius: 6px;
  padding: 4px;
}
.leaflet-popup-content {
  margin: 8px 12px;
  font-size: 14px;
  max-height: 380px;
  overflow-y: auto;
}
.popup-title {
  margin: 0 0 8px 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--slate);
}
.popup-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
.popup-list li { margin: 4px 0; }
.popup-list a {
  color: var(--red);
  text-decoration: none;
}
.popup-list a:hover { text-decoration: underline; }

/* List panel */
#list-panel {
  background: white;
  overflow-y: auto;
  border-left: 1px solid var(--border);
  min-height: 0;
}

.list-header {
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: white;
  position: sticky;
  top: 0;
  z-index: 1;
}
.clear-link {
  font-size: 13px;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
}
.clear-link:hover { color: var(--slate); }

#issue-list {
  margin: 0;
  padding: 0;
  list-style: none;
}
#issue-list li { border-bottom: 1px solid var(--border); }
#issue-list a {
  display: block;
  padding: 12px 16px;
  text-decoration: none;
  color: inherit;
  transition: background 0.1s ease;
}
#issue-list a:hover { background: var(--row-hover); }
#issue-list li.selected a { background: var(--row-selected); }
#issue-list li.selected a:hover { background: var(--row-selected-hover); }
.issue-title { font-weight: 600; color: var(--slate); margin-bottom: 4px; }
.issue-jurisdiction { font-size: 13px; color: var(--muted); }

.empty-message {
  padding: 24px 16px;
  color: var(--muted);
  font-style: italic;
  text-align: center;
}

/* State overlay */
.state-overlay {
  position: absolute;
  inset: 0;
  background: var(--caa-navy);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--caa-yellow);
  z-index: 1000;
  text-align: center;
  padding: 16px;
}
.state-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(252, 181, 21, 0.25);
  border-top-color: var(--caa-yellow);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.retry-btn {
  background: var(--caa-yellow);
  color: var(--caa-navy);
  border: none;
  border-radius: 4px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.retry-btn:hover { background: #FFC832; }

/* Mobile */
@media (max-width: 768px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  #map { aspect-ratio: 4 / 3; min-height: 240px; }
  #list-panel {
    border-left: 0;
    border-top: 1px solid var(--border);
  }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  *, *::before, *::after {
    transition-duration: 0s !important;
    animation-duration: 0s !important;
  }
}
