*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #1a1a1a;
  background: #f5f5f5;
}

/* ---- Skip link ---- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 10000;
  background: #1a1a1a;
  color: #fff;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
}

.skip-link:focus {
  left: 0;
}

/* ---- Header ---- */
header {
  background: #1b4332;
  color: #fff;
  padding: 1rem 1.25rem;
}

header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.35rem;
}

header p {
  margin: 0;
  font-size: 0.9rem;
  opacity: 0.85;
}

/* ---- Filter controls ---- */
#filter-controls {
  background: #fff;
  border-bottom: 1px solid #ddd;
  padding: 0.5rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

#filter-controls fieldset {
  border: none;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

#filter-controls legend {
  font-weight: 600;
  font-size: 0.9rem;
  margin-right: 0.5rem;
  float: left;
  padding-top: 0.1rem;
}

#filter-controls label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
  cursor: pointer;
}

#filter-project {
  font-size: 0.9rem;
  padding: 0.25rem 0.4rem;
  max-width: 280px;
}

#filter-search {
  font-size: 0.9rem;
  padding: 0.25rem 0.4rem;
  width: 220px;
}

.status-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid #666;
}

.status-swatch.status-open {
  background-color: #27ae60;
}

.status-swatch.status-closed {
  /* background-color: #27ae60; */
  background-color: #c0392b;
}

.count {
  color: #666;
  font-size: 0.85rem;
}

/* ---- Map help ---- */
#map-container {
  position: relative;
}

.map-help-toggle {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  z-index: 1000;
  font-size: 0.875rem;
  padding: 0.25rem 0.5rem;
  background: white; /* or your panel/page background color */
  border: 1px solid currentColor;
  border-radius: 4px;
  cursor: pointer;
}

#map-help-panel {
  font-size: 0.875rem;
  margin-top: 0.25rem;
  position: absolute;
  top: 2.5rem;
  right: 0.5rem;
  z-index: 1000;
  background: white;
  border: 1px solid currentColor;
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  max-width: 260px;

  /* roll up/down animation */
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.3s ease, opacity 0.2s ease;
}

#map-help-panel.is-open {
  max-height: 300px; /* tall enough to fit all content */
  opacity: 1;
}

.map-legend-toggle {
  position: absolute;
  bottom: 1.0rem;
  right: 0.5rem;
  z-index: 1000;
  font-size: 0.875rem;
  padding: 0.25rem 0.5rem;
  background: white; /* or your panel/page background color */
  border: 1px solid currentColor;
  border-radius: 4px;
  cursor: pointer;
}

#map-legend-panel {
  font-size: 0.875rem;
  margin-top: 0.25rem;
  position: absolute;
  bottom: 2.7rem;
  right: 0.5rem;
  z-index: 1000;
  background: #5e5e5e;
  color: #ffffff;
  border: 1px solid currentColor;
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  max-width: 260px;

  /* roll up/down animation */
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.3s ease, opacity 0.2s ease;
}

#map-legend-panel.is-open {
  max-height: 300px; /* tall enough to fit all content */
  opacity: 1;
}

/* ---- Content layout ---- */
#content-wrapper {
  display: flex;
  flex-direction: column;
}

#map-container {
  width: 100%;
  height: 60vh;
}

#map {
  width: 100%;
  height: 100%;
}

#list-container {
  width: 100%;
  max-height: 40vh;
  overflow-y: auto;
  padding: 0 0 1rem;
  background: #fff;
}

#list-heading {
  margin: 0;
  padding: 0.75rem 1.25rem 0.25rem;
  font-size: 1.1rem;
}

#list-summary {
  padding: 0 1.25rem 0.5rem;
  font-size: 0.85rem;
  color: #555;
}

#closure-list {
  list-style-type: none;
  padding: 0;
  margin: 0;
  scroll-margin-bottom: calc(100vh - 130px);
}

/* ---- Project groups ---- */
.project-group {
  border-top: 1px solid #e0e0e0;
}

.project-heading {
  margin: 0;
  padding: 0.6rem 1.25rem 0.3rem;
  font-size: 0.95rem;
  background: #f0f0f0;
  position: sticky;
  top: 0;
  z-index: 1;
}

ul.project-list {
  list-style-type: none;
  padding: 0;
  margin: 0;
}

/* ---- Closure list items ---- */
.closure-item {
  padding: 0.6rem 1.25rem;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1.4;
}

.closure-item:hover,
.closure-item:focus-within {
  background-color: #eef4ff;
  outline: 2px solid #c0392b;
  outline-offset: -2px;
}

.closure-item .no-geometry {
  font-style: italic;
  color: #888;
  font-size: 0.8rem;
  margin-left: 0.5rem;
}

.listitem-action-button {
  background: none;
  color: inherit;
  border: none;
  padding: 0;
  font: inherit;
  cursor: pointer;
  outline: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-badge {
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 0.25em 0.5em;
}

.closure-desc {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
  overflow-wrap: break-word;
}

/* ---- Status badges ---- */
.status-badge {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 3px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  vertical-align: middle;
  margin-right: 0.35rem;
}

.status-badge.open {
  background-color: #18AA52;
}

.status-badge.closed {
  background-color: #c0392b;
}

/* ---- Leaflet popup ---- */
.popup-content h3 {
  margin: 0 0 0.4rem;
  font-size: 0.95rem;
}

.popup-content p {
  margin: 0.25rem 0;
  font-size: 0.85rem;
}

/* ---- Leaflet legend control ---- */
.legend {
  /* background: #fff; */
  background: #5e5e5e;
  padding: 8px 12px;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  line-height: 1.8;
  font-size: 0.82rem;
  color: #ffffff;
}

.legend strong {
  display: block;
  margin-bottom: 2px;
}

.legend i {
  width: 14px;
  height: 14px;
  display: inline-block;
  margin-right: 6px;
  vertical-align: middle;
  border: 1px solid #666;
  border-radius: 2px;
}

/* ---- Footer ---- */
footer {
  background: #fff;
  border-top: 1px solid #ddd;
  padding: 0.75rem 1.25rem;
  font-size: 0.8rem;
  color: #666;
  text-align: center;
}

/* ---- Desktop layout ---- */
@media (min-width: 768px) {
  #content-wrapper {
    flex-direction: row;
    height: calc(100vh - 130px);
  }

  #map-container {
    flex: 2;
    height: 100%;
  }

  #list-container {
    flex: 1;
    max-width: 420px;
    max-height: 100%;
    border-left: 1px solid #ddd;
    overflow-y: auto;
  }
}

/* ---- Helper classes ---- */
.visually-hidden {
  border: 0;
  clip: rect(0 0 0 0);
  height: auto;
  margin: 0;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
  white-space: nowrap;
}
