/*
 * Atlas dossier tab ownership.
 *
 * This file intentionally loads after atlas-dossier.css. It owns the primary / Life
 * navigation (Station / Life From Here for Rail, Walk Area / Daily Life for Walk),
 * the tab-driven panel split, and the responsive ordering needed to keep that split
 * coherent in the mobile sheet. Keep general card and sheet chrome in their surface
 * owners rather than growing another override layer here.
 */

.atlas-dossier-tabs {
  position: sticky;
  top: 0;
  z-index: 12;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  padding: 3px 4px 0;
  border: 1px solid rgba(17, 16, 14, 0.22);
  border-radius: 4px;
  background: rgba(248, 243, 232, 0.97);
  box-shadow: inset 0 -1px 0 rgba(17, 16, 14, 0.09);
  backdrop-filter: blur(8px);
}

.atlas-dossier-tabs[hidden] {
  display: none;
}

.atlas-dossier-tabs > button {
  min-height: 38px;
  padding: 8px 10px;
  border: 0;
  border-radius: 2px;
  background: transparent;
  box-shadow: none;
  color: var(--ink-label);
  font: 780 var(--panel-label)/1.1 var(--font-rail-label, var(--font-main));
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
}

.atlas-dossier-tabs > button:is(.is-active, [aria-selected="true"]) {
  border-color: transparent;
  background: transparent;
  color: var(--ink);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.atlas-dossier-tabs > button:not([aria-selected="true"]):hover {
  background: rgba(17, 16, 14, 0.035);
  color: var(--ink);
}

.atlas-dossier-tabs > button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

body.is-map-active.is-reach-mode.has-origin:not(.is-comparison-surface) .side-panel > :is(
  .briefing-masthead,
  .atlas-dossier-tabs,
  #stationDetailsCard,
  .score-card,
  #reachDetailsCard,
  #stationDataNoteCard
) {
  order: initial;
}

body.is-map-active.is-reach-mode.has-origin:not(.is-car-surface):not(.is-comparison-surface) .side-panel[data-atlas-tab="station"] #reachDetailsCard,
body.is-map-active.is-reach-mode.has-origin:not(.is-car-surface):not(.is-comparison-surface) .side-panel[data-atlas-tab="life"] :is(#stationRoleCard, #stationDetailsCard, .score-card, #stationDataNoteCard) {
  display: none;
}

/* Walk Area owns the primary pane until the reader explicitly opens a station.
   The controller applies the same ownership through `hidden`; this rule keeps
   Rail-only supporting cards out of the initial paint while preserving the
   selected-station drilldown represented by `.has-station-focus`. */
body.is-map-active.is-reach-mode.has-origin.is-walking-surface:not(.has-station-focus) .side-panel[data-atlas-tab="station"] :is(#stationRoleCard, #stationDataNoteCard) {
  display: none;
}

@media (max-width: 980px) {
  body.is-map-active .mobile-sheet[data-snap="full"] > .atlas-dossier-tabs.is-mobile {
    position: relative;
    top: auto;
    order: 3;
  }

  body.is-map-active.is-reach-mode.has-origin:not(.is-car-surface):not(.is-comparison-surface) .mobile-sheet[data-snap="full"][data-atlas-tab="station"] > :is(#mobileReachDetails, .mobile-surface-story-toggle) {
    display: none;
  }

  body.is-map-active.is-reach-mode.has-origin:not(.is-car-surface):not(.is-comparison-surface) .mobile-sheet[data-snap="full"][data-atlas-tab="life"] > :is(#mobilePrimarySummary, #mobileInspector, #mobileCompassSummary) {
    display: none;
  }

  body.is-map-active .mobile-sheet[data-atlas-tab="life"] > #mobileCompassSummary {
    display: none;
  }
}

@media (max-width: 760px), (max-width: 980px) and (orientation: portrait), (max-width: 980px) and (max-height: 599px) {
  body.is-map-active .atlas-dossier-tabs:not(.is-mobile),
  body.is-map-active .mobile-sheet:not([data-snap="full"]) > .atlas-dossier-tabs.is-mobile {
    display: none;
  }

  body.is-map-active .mobile-sheet[data-snap="full"] > .atlas-dossier-tabs.is-mobile {
    display: grid;
    margin: 0 12px;
  }
}

/* Saved stations are a secondary utility, not the opening chapter of the
   station story. Keep the count easy to find while comparison and management
   stay behind a native, keyboard-operable disclosure at the end of the flow. */
body.is-map-active .side-panel > .station-shortlist-panel {
  order: 40;
  padding: 0;
}

body.is-map-active #mobileSheet > #mobileShortlistPanel {
  order: 8;
  padding: 0;
}

.station-shortlist-disclosure { min-width: 0; }

.station-shortlist-summary {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 14px;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  padding: 8px 10px;
  list-style: none;
  color: var(--ink);
  cursor: pointer;
}

.station-shortlist-summary::-webkit-details-marker { display: none; }

.station-shortlist-summary > span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.station-shortlist-summary strong {
  font: 700 var(--panel-body, 0.875rem)/1.15 var(--font-ui, var(--font-main));
}

.station-shortlist-summary small {
  color: var(--ink-label, var(--ink-soft));
  font: 500 var(--panel-label, 0.6875rem)/1.2 var(--font-ui, var(--font-main));
}

.station-shortlist-summary > b {
  display: grid;
  place-items: center;
  box-sizing: border-box;
  min-width: 24px;
  height: 24px;
  padding-inline: 5px;
  border: 1px solid rgba(17, 16, 14, 0.22);
  border-radius: 999px;
  background: rgba(255, 253, 247, 0.62);
  font: 700 0.6875rem/1 var(--font-metric, var(--font-ui));
}

.station-shortlist-summary::after {
  width: 7px;
  height: 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  content: "";
  opacity: 0.62;
  transform: rotate(45deg) translate(-1px, -1px);
  transition: transform var(--motion-duration-base, 220ms) var(--motion-ease-standard, ease);
}

.station-shortlist-disclosure[open] > .station-shortlist-summary::after {
  transform: rotate(225deg) translate(-1px, -1px);
}

.station-shortlist-summary:hover { background: rgba(255, 253, 247, 0.5); }

.station-shortlist-summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.station-shortlist-body {
  display: grid;
  gap: 9px;
  padding: 9px 10px 11px;
  border-top: 1px solid rgba(17, 16, 14, 0.12);
}

@media (max-width: 760px) {
  body.is-map-active #mobileSheet > #mobileShortlistPanel.station-shortlist-panel.is-mobile {
    margin: 4px 0 0;
    border-top: 1px solid rgba(17, 16, 14, 0.14);
  }

  .station-shortlist-summary {
    min-height: 48px;
    padding-inline: 12px;
  }

  .station-shortlist-body { padding-inline: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .station-shortlist-summary::after { transition: none; }
}
