/* Skip links: visually hidden until keyboard-focused. */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 1300;
  padding: 0.6rem 1rem;
  background: var(--accent);
  color: var(--accent-contrast);
  border-radius: 0 0 8px 0;
  text-decoration: none;
  font-weight: 600;
}

.skip-link:focus {
  left: 0;
}

/* Results list: the text-first presentation of the same filtered results the
   map shows — paginated cards instead of thousands of markers. */
.results-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem 1.25rem 1.5rem;
  background: var(--background);
}

.results-list[hidden] {
  display: none;
}

.results-list__controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.5rem;
}

.results-list__controls select {
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--surface);
  color: var(--text);
}

.results-list__status {
  margin: 0 0 0.75rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.results-list__items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.results-card {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--surface);
  padding: 0.85rem 1rem;
  display: grid;
  gap: 0.3rem;
}

.results-card--selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

.results-card h3 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--accent);
}

.results-card__meta,
.results-card__facts {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.results-card__details {
  justify-self: start;
  margin-top: 0.35rem;
  /* 44px: the card's primary action (opens the lake sheet on mobile). */
  min-height: 2.75rem;
  padding: 0.45rem 0.9rem;
  font-size: 0.9rem;
}

.results-list__pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
}

.results-list__pagination button {
  /* 44px: primary paging actions, tapped repeatedly on mobile. */
  min-height: 2.75rem;
}

.results-list__pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.results-list__page-label {
  font-size: 0.9rem;
  color: var(--text-muted);
}

@media (min-width: 1025px) {
  /* The fixed-height application shell must begin exactly where the two-column
     row layout does. `main` stays a vertical column through max-width:1024px
     (below), so a shell any earlier than 1025px re-clips that column and lets
     the footer overlap the map (the 901–1024px seam). At >=1025px `main` is a
     flex row, so the shell lets the map fill and the filters sidebar scroll
     internally instead of the whole page scrolling. */
  body {
    height: 100vh;
  }

  #map {
    min-height: 400px;
  }
}

.filter-group {
  margin: 0;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--surface-alt);
  box-shadow: 0 10px 30px -24px var(--shadow);
}

.filter-group:not([data-filter-title]) {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.6rem 0.75rem;
}

.filter-group[data-filter-title] {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
}

.filter-group__toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  /* 44px: these disclosures are the only route into each filter group. */
  min-height: 2.75rem;
  padding: 0.75rem 0.85rem;
  border: none;
  background: transparent;
  color: var(--text);
  font-weight: 600;
  font-size: 0.95rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s ease;
}

.filter-group__toggle,
.filter-group__toggle:hover,
.filter-group__toggle:focus {
  border: none;
  color: var(--text);
  transform: none;
}

.filter-group__toggle:hover,
.filter-group__toggle:focus {
  background: var(--surface);
}

.filter-group__toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.filter-group__title {
  flex: 1;
}

.filter-group__chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1rem;
  height: 1.1rem;
}

.filter-group__chevron::before {
  content: '';
  display: block;
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
}

.filter-group[data-filter-title] .filter-group__body {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.6rem 0.75rem 0.75rem;
}

.filter-group__body[hidden] {
  display: none !important;
}

.filter-group--collapsed .filter-group__body {
  display: none;
}

.filter-group--collapsed .filter-group__chevron::before {
  transform: rotate(-45deg);
}

.filter-group--full {
  grid-column: 1 / -1;
}

.filter-group--split > .filter-group__body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.9rem;
}

.filter-group--split .select {
  margin: 0;
}

.filter-group--split label {
  font-size: 0.9rem;
}

.filter-group--actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.filter-group--actions button {
  width: 100%;
  /* 44px: Reset filters is a primary drawer action. */
  min-height: 2.75rem;
}

.view-mode-toggle {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--surface-alt);
  padding: 0.2rem;
  gap: 0.2rem;
}

.view-mode-toggle__option {
  display: inline-flex;
  cursor: pointer;
}

.view-mode-toggle__option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.view-mode-toggle__option span {
  display: inline-flex;
  align-items: center;
  /* 44px: Lakes/Boat launches and Map/List are primary mode switches, so
     they get the full primary target, not the dense-secondary floor. */
  min-height: 2.75rem;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  font-size: 0.9rem;
  line-height: 1;
  color: var(--text-muted);
  user-select: none;
  transition: background 0.2s ease, color 0.2s ease;
}

.view-mode-toggle__option input:checked + span {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.view-mode-toggle__option input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.view-mode-toggle__option:hover input:not(:checked) + span {
  color: var(--text);
}

.access-popup {
  font-family: inherit;
  max-width: 280px;
}

.access-popup h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  color: var(--accent);
}

.access-popup p {
  margin: 0.3rem 0;
  font-size: 0.875rem;
  line-height: 1.4;
}

.access-popup p strong {
  color: var(--text);
  font-weight: 600;
}

.filter-group label,
.filter-group legend {
  font-weight: 600;
  font-size: 0.85rem; /* Smaller text */
}

.select {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.select select {
  font-weight: 400;
}

.filter-group select {
  width: 100%;
  padding: 0.35rem; /* Reduced padding */
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--surface);
  font-size: 0.85rem; /* Smaller text */
  color: var(--text);
}

.filter-group select[multiple] {
  min-height: 5rem; /* Reduced height */
  max-height: 8rem; /* Reduced max height */
  overflow-y: auto;
}

.filter-group fieldset {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.75rem 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--surface);
}

.filter-group fieldset label {
  font-weight: 400;
  font-size: 0.9rem;
}

.range-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.5rem;
}

.range-inputs label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-weight: 500;
  font-size: 0.85rem;
}

.range-inputs input[type='number'] {
  padding: 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--surface);
  font-size: 0.95rem;
  color: var(--text);
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
  font-size: 0.95rem;
}

.filter-error {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: #b3261e;
}

body.theme-dark .filter-error {
  color: #ffb4ab;
}

.helper-text {
  font-size: 0.8rem;
  color: var(--text-muted);
}

@media (max-width: 1024px) {
  main {
    flex-direction: column;
    /* Flow instead of clipping: the column stacks the (inline) filters panel
       and the map, and the page (body height:auto below 1025px) scrolls.
       Base sets min-height:0 + overflow:hidden, which let the grid's 1fr
       middle row collapse below the tall filters panel so main overflowed
       onto the footer across the 901–1024px band. min-height:auto lets the
       row grow to the column's content; overflow:visible stops the clip. */
    height: auto;
    min-height: auto;
    overflow: visible;
  }

  #filters {
    /* flex-basis:auto (its own content height), NOT 100%: main is a flex
       COLUMN here, so basis:100% meant 100% of main's HEIGHT — the panel ate
       the whole column and pushed the map out below the footer. */
    flex: 0 0 auto;
    width: 100%;
    padding: 1.25rem 1.5rem 2rem;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    box-shadow: none;
    grid-template-columns: 1fr 1fr;
  }

  .filter-group--full {
    grid-column: span 2;
  }

  #map {
    /* Own height in the column (not flex-grow), so it stacks after the
       filters panel and the footer follows it in flow. */
    flex: 0 0 auto;
    height: auto;
    min-height: 420px;
  }

  /* Iframe embeds keep a fixed-height shell (body.in-iframe below), so in the
     column layout the fixed middle row would clip the stacked filters+map and
     push the footer past the bottom of a short iframe. Make main the internal
     scroll region instead: the row stays fixed, its content scrolls, and the
     footer remains visible. Filters flow naturally so there is a single scroll
     region rather than a nested one. */
  body.in-iframe main {
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  /* The filters panel flows naturally (single scroll region — see the
     max-height:none override placed AFTER the generic body.in-iframe #filters
     rule below, so it wins the cascade at equal specificity). */
}

@media (max-width: 768px) {
  #filters {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .filter-group--full {
    grid-column: 1;
  }  .filter-group:not([data-filter-title]) {
    padding: 0.85rem 0.95rem;
  }

  .filter-group[data-filter-title] .filter-group__body {
    padding: 0.85rem 0.95rem 1rem;
  }
}

button {
  padding: 0.6rem 0.9rem;
  border-radius: 6px;
  border: 1px solid transparent;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease, border-color 0.2s ease;
}

button:hover,
button:focus {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  transform: translateY(-1px);
}

#results-summary {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.4;
}

