/* ---- Lake bottom sheet ---------------------------------------------------
   The lake-detail surface for small screens (replacing Leaflet popups, which
   cannot fit a phone viewport) and for the results list's "View details" at
   any width. Fixed to the viewport bottom, opens collapsed (~38%), expands
   to ~85%, scrolls internally under a sticky name + close header, and keeps
   the content behind it visible. */
.lake-sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  /* Above Leaflet's panes/controls (max 1000), below the filter drawer
     (1150/1200). */
  z-index: 1100;
  max-height: 38vh;
  max-height: 38dvh;
  background: var(--surface);
  border-top: 1px solid var(--border-color);
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -14px 36px -14px rgba(0, 0, 0, 0.45);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.lake-sheet[hidden] {
  display: none;
}

.lake-sheet--expanded {
    max-height: 85vh;
    max-height: 85dvh;
    height: 85vh;
    height: 85dvh;
  }

  .lake-sheet__header {
    flex: none;
    border-bottom: 1px solid var(--border-color);
    padding: 0 1rem 0.6rem;
  }

  .lake-sheet__expand {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    /* 44px: primary sheet action (expand/collapse); the visible grip stays a
       slim pill, only the tap area grows. */
    min-height: 2.75rem;
    padding: 0.35rem 0;
    margin: 0;
    background: none;
    border: none;
    cursor: pointer;
  }

  .lake-sheet__expand:hover,
  .lake-sheet__expand:focus {
    background: none;
    border-color: transparent;
    transform: none;
  }

  .lake-sheet__grip {
    display: block;
    width: 2.75rem;
    height: 0.3rem;
    margin: 0 auto;
    border-radius: 999px;
    background: var(--border-color);
  }

  .lake-sheet__expand:focus-visible .lake-sheet__grip {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
  }

  .lake-sheet__title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
  }

  .lake-sheet__title {
    margin: 0;
    font-size: 1.1rem;
    color: var(--accent);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .lake-sheet__close {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* 44px: primary dismiss action for the mobile lake sheet. */
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--surface-alt);
    color: var(--text);
    font-size: 1.2rem;
    line-height: 1;
  }

  .lake-sheet__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 0.75rem 1rem 1rem;
  }

  /* The article was sized for a popup; let it fill the sheet. Its own h2 is
     hidden because the name lives in the sticky sheet header. */
  .lake-sheet__body .lake-popup {
    min-width: 0;
    max-width: none;
    width: 100%;
  }

  .lake-sheet__body .stocking-history__tooltip {
    left: 0;
    right: auto;
    min-width: 0;
    width: min(240px, calc(100vw - 2rem));
    max-width: calc(100vw - 2rem);
  }

  .lake-sheet__body .lake-popup header h2 {
    display: none;
  }

.lake-popup .stocking-species-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  width: 100%;
}

.lake-popup .stocking-species-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.lake-popup .stocking-species-frequency {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: right;
  max-width: 60%;
  font-weight: 400;
}

.stocking-history {
  position: relative;
  display: inline-flex;
  margin-top: 0.25rem;
}

.stocking-history__trigger {
  border: 1px solid var(--border-color);
  background: var(--surface);
  color: var(--accent);
  border-radius: 0.5rem;
  font-size: 0.7rem;
  line-height: 1;
  padding: 0.2rem 0.5rem;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  cursor: pointer;
  box-shadow: 0 2px 6px -4px rgba(0, 0, 0, 0.35);
}

.stocking-history__trigger:hover,
.stocking-history__trigger:focus-visible {
  background: var(--accent-soft);
  border-color: var(--accent);
  outline: none;
}

.stocking-history__trigger-icon {
  font-size: 0.9rem;
}

.stocking-history__tooltip {
  position: absolute;
  top: calc(100% + 0.4rem);
  left: 0;
  right: auto;
  min-width: min(220px, calc(100vw - 5rem));
  max-width: min(240px, calc(100vw - 5rem));
  padding: 0.75rem;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border-color);
  box-shadow: 0 18px 36px -20px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  z-index: 20;
}

.stocking-history__tooltip[hidden] {
  display: none;
}

.stocking-history__row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.7rem;
}

.stocking-history__year {
  width: 3rem;
  color: var(--text-muted);
}

.stocking-history__bar-track {
  position: relative;
  height: 0.45rem;
  border-radius: 0.3rem;
  background: var(--surface-alt);
  overflow: hidden;
}

.stocking-history__bar-fill {
  position: absolute;
  inset: 0;
  width: var(--stocking-bar, 0%);
  background: linear-gradient(90deg, var(--accent) 0%, rgba(20, 92, 168, 0.25) 100%);
  border-radius: inherit;
}

.stocking-history__value {
  white-space: nowrap;
  color: var(--text-muted);
}


.popup-expand {
  margin: 0.6rem 0 0.2rem;
  border-top: 1px solid var(--border-color);
  padding-top: 0.5rem;
}

.popup-expand summary {
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--accent);
  user-select: none;
  /* 44px touch target. Padding (not flex centering) so the summary keeps
     display:list-item and with it the native disclosure triangle. */
  box-sizing: border-box;
  min-height: 2.75rem;
  padding-block: 0.7rem;
}

.popup-expand summary:hover,
.popup-expand summary:focus-visible {
  text-decoration: underline;
}

.popup-expand__body {
  margin-top: 0.4rem;
}

.popup-expand__facts {
  margin: 0.25rem 0 0.4rem;
  font-size: 0.825rem;
  color: var(--text-muted);
}

.popup-expand__fish {
  list-style: none;
  margin: 0.25rem 0 0.4rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.popup-expand__fish li {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  font-size: 0.825rem;
}

.popup-expand__empty {
  margin: 0.25rem 0 0.4rem;
  font-size: 0.825rem;
  color: var(--text-muted);
}

.launch-list {
  list-style: none;
  margin: 0.4rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  max-height: 220px;
  overflow-y: auto;
}

.launch-item {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  background: var(--surface-alt);
}

.launch-item__title {
  font-size: 0.85rem;
  font-weight: 600;
}

.launch-item__meta {
  margin-top: 0.15rem;
  font-size: 0.775rem;
  color: var(--text-muted);
}

.launch-item__directions {
  margin-top: 0.2rem;
  font-size: 0.775rem;
  line-height: 1.35;
}

.launch-item__action {
  margin-top: 0.35rem;
  /* 32px: dense secondary action inside the scrolling launch list. */
  min-height: 2rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-size: 0.775rem;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.launch-item__action:hover,
.launch-item__action:focus-visible {
  background: var(--accent);
  color: #fff;
}

/* Boat launch clusters use a blue range to stay distinct from the green/orange lake clusters */
.access-cluster--small {
  background-color: rgba(147, 196, 240, 0.6);
}

.access-cluster--small div {
  background-color: rgba(96, 160, 220, 0.75);
  color: #0b3a66;
}

.access-cluster--medium {
  background-color: rgba(96, 156, 216, 0.6);
}

.access-cluster--medium div {
  background-color: rgba(45, 118, 190, 0.8);
  color: #ffffff;
}

.access-cluster--large {
  background-color: rgba(45, 110, 180, 0.6);
}

.access-cluster--large div {
  background-color: rgba(20, 92, 168, 0.85);
  color: #ffffff;
}

.access-cluster span {
  font-weight: 600;
}

.popup-action {
  display: inline-block;
  margin: 0.5rem 0 0.1rem;
  padding: 0.3rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.popup-action:hover,
.popup-action:focus-visible {
  background: var(--accent);
  color: #fff;
}

.filter-subsection + .filter-subsection {
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--border-color);
}

#species-select optgroup,
#stocking-species-select optgroup {
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--accent);
  background: var(--surface-alt);
}

#species-select optgroup > option,
#stocking-species-select optgroup > option {
  font-weight: 400;
  color: var(--text);
  background: var(--surface);
  padding-left: 1rem;
}

.native-select-hidden {
  display: none;
}

.species-tree {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--surface);
  max-height: 260px;
  overflow-y: auto;
  padding: 0.25rem 0;
}

.species-tree__group + .species-tree__group {
  border-top: 1px solid var(--border-color);
}

.species-tree__header {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.5rem 0.2rem 0.25rem;
}

.species-tree__chevron {
  flex: 0 0 auto;
  /* 32×32 hit area (the drawn glyph stays small): WCAG 2.2 wants 24px
     minimum without spacing exceptions; these sit in a dense tree, so 32px
     is the dense-secondary floor rather than the 44px primary target. */
  width: 2rem;
  height: 2rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  position: relative;
}

.species-tree__chevron::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0.4rem;
  height: 0.4rem;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translate(-60%, -60%) rotate(-45deg);
  transition: transform 0.15s ease;
}

.species-tree__chevron[aria-expanded='true']::before {
  transform: translate(-50%, -70%) rotate(45deg);
}

.species-tree__chevron:hover,
.species-tree__chevron:focus-visible {
  background: var(--accent-soft);
  color: var(--accent);
  outline: none;
}

.species-tree__group-label {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex: 1;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
}

.species-tree__group--active .species-tree__group-name {
  color: var(--accent);
}

.species-tree__count {
  margin-left: auto;
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.species-tree__group--active .species-tree__count {
  color: var(--accent);
  font-weight: 600;
}

.species-tree__members {
  /* Left indent tracks the wider chevron so members align under group names. */
  padding: 0.1rem 0.5rem 0.4rem 2.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

/* display: flex above overrides the UA [hidden] rule, so restate it */
.species-tree__members[hidden] {
  display: none;
}

.species-tree__member {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0.1rem 0.25rem;
  border-radius: 4px;
}

.species-tree__member:hover {
  background: var(--accent-soft);
}

.species-tree input[type='checkbox'] {
  accent-color: var(--accent);
  margin: 0;
  cursor: pointer;
}

