/* Ladebedarfskarte on phones and the accordion controls behind it.
   Loaded after map.css (map.html). On desktop only the inert defaults at the
   top apply; everything else is inside the ≤760px block, which map.js
   ("Phone layout") drives with is-collapsed / aria-expanded. */

/* Accordion heads and phone-only controls are inert on desktop: the heads
   read as the plain section labels they replace, the rest is hidden. */
.phone-only {
  display: none !important;
}
.accordion-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
}
.accordion-head:disabled {
  cursor: default;
}
.accordion-head:disabled .chevron {
  display: none;
}
.chevron {
  flex: none;
  transition: transform 160ms ease-out;
}
/* Accordions open downwards: ^ when open, v when closed. The sheets open
   upwards, so their chevron is the other way round. */
[aria-expanded="false"] > .chevron,
.sheet-toggle[aria-expanded="true"] > .chevron,
.detail-collapse[aria-expanded="true"] > .chevron {
  transform: rotate(180deg);
}
.sheet-toggle[aria-expanded="false"] > .chevron,
.detail-collapse[aria-expanded="false"] > .chevron {
  transform: none;
}

/* ── Phones: the map keeps the screen ─────────────────────────────── */
/* The tool panel is a bottom sheet folded to its head (title + count +
   "Filter"); Legende and the season card are accordions inside it. Details
   open as a second sheet that folds to its head and hides the tool sheet
   while open. map.js "Phone layout" switches the states. */
@media (max-width: 760px) {
  .phone-only {
    display: flex !important;
  }
  .atlas-left,
  .atlas-right {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    border-radius: 20px 20px 0 0;
    border-bottom: 0;
    padding: 8px 18px calc(16px + env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  /* Grab handle */
  .atlas-left::before,
  .atlas-right::before {
    content: '';
    flex: none;
    align-self: center;
    width: 40px;
    height: 4px;
    margin-bottom: 4px;
    border-radius: 2px;
    background: #c5d3e0;
  }
  .atlas-left {
    max-height: 66vh;
    gap: 16px;
  }
  .atlas-left.is-collapsed {
    overflow: hidden;
  }
  /* !important: beats the phone-only display above (season accordion). */
  .atlas-left.is-collapsed > :not(.panel-head) {
    display: none !important;
  }
  .atlas-left .panel-head {
    display: grid;
    grid-template-columns: 1fr auto;
    column-gap: 12px;
    row-gap: 2px;
    align-items: center;
  }
  .atlas-left .panel-eyebrow,
  .atlas-left .panel-help {
    display: none;
  }
  .atlas-left .panel-title {
    grid-column: 1;
    font-size: 17px;
  }
  .atlas-left .panel-sub {
    grid-column: 1;
    font-size: 12.5px;
    line-height: 1.35;
  }
  .sheet-toggle {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid #c9dcea;
    border-radius: 999px;
    background: #ffffff;
    color: #0057a3;
    font: inherit;
    font-size: 13px;
    font-weight: 700;
  }
  .accordion-head {
    min-height: 32px;
  }
  .accordion-head .chevron {
    color: #556375;
  }

  /* Season card inside the sheet: no card of its own, the year grid scrolls
     sideways, the selected-Standort tile lives in the detail sheet. */
  #season-slot {
    flex-direction: column;
  }
  .atlas-left .atlas-season {
    position: static;
    transform: none;
    width: auto;
    max-width: none;
    padding: 4px 0 0;
    background: none;
    border: 0;
    box-shadow: none;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
  .atlas-left .atlas-season .season-head > .panel-label,
  .atlas-left .season-selected {
    display: none;
  }
  .atlas-left .atlas-season .season-head {
    flex-wrap: wrap;
    row-gap: 6px;
  }
  .atlas-left .atlas-season .season-rows {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Detail sheet: over the tool sheet, folds to its head. */
  .atlas-right {
    z-index: 1150;
    max-height: 58vh;
    gap: 14px;
  }
  .atlas:has(#detail-panel:not([hidden])) .atlas-left {
    display: none;
  }
  .atlas-right.is-collapsed {
    overflow: hidden;
  }
  .atlas-right.is-collapsed > :not(.detail-head):not(.detail-close):not(.detail-collapse) {
    display: none;
  }
  .atlas-right .detail-head {
    padding-right: 88px;
    gap: 4px;
  }
  .atlas-right .detail-name {
    font-size: 18px;
  }
  .detail-close,
  .detail-collapse {
    top: 14px;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #f1f7fb;
  }
  .detail-close {
    right: 14px;
    display: flex;
    font-size: 22px;
  }
  .detail-collapse {
    position: absolute;
    right: 60px;
    border: 0;
    color: #556375;
    cursor: pointer;
  }
  .stat-cards {
    gap: 7px;
  }
  .stat-card {
    padding: 9px 11px;
  }
  .stat-card-value {
    font-size: 18px;
  }

  /* Pinch zooms on a phone; the buttons would sit under the sheet. The
     credit moves up under the header, clear of both sheets. */
  body.bpme-map .leaflet-control-zoom {
    display: none;
  }
  .atlas-attribution {
    top: 84px;
    bottom: auto;
    right: 12px;
    font-size: 9.5px;
    padding: 2px 8px;
  }
  /* Loading card and update pill sit in the free map area at the top. */
  .map-loader.is-initial,
  .map-loader.is-update {
    top: 96px;
    bottom: auto;
    left: 0;
    right: 0;
    padding-bottom: 0;
    align-items: flex-start;
  }
  .map-loader-title,
  .map-loader-sub {
    white-space: normal;
  }
}

/* iOS Safari zooms into any focused field whose text is under 16px (and
   stays zoomed). Touch screens of any width – phones in landscape and
   tablets too – get 16px in the search and the year select. Zoom stays
   allowed: no maximum-scale in the viewport meta. */
@media (pointer: coarse) {
  .input-wrap input,
  .panel-select {
    font-size: 16px;
  }
}
