/* Stage 3: refined interactions, mobile sheet, accessible targets.
   The route colors, map geometry, fleet symbols and basemap stay unchanged. */
:root { --stage3-ease: cubic-bezier(.22,1,.36,1); }

/* Soft interactions that communicate selection without distracting from the map. */
.route-card { transition: transform .24s var(--stage3-ease), border-color .22s ease, background .22s ease, box-shadow .24s var(--stage3-ease); transform-origin: center; }
.route-card:hover { transform: translateY(-2px) scale(1.006); box-shadow: 0 12px 26px #1a392a17; }
.route-card:active { transform: scale(.988); transition-duration: .09s; }
.route-card.stage3-route-pulse { animation: stage3-route-pulse .46s var(--stage3-ease) both; }
.filter-chip { transition: color .2s ease, background .22s var(--stage3-ease), border-color .2s ease, box-shadow .2s ease, transform .18s var(--stage3-ease); }
.filter-chip:active { transform: scale(.96); }
.filter-chip.active { box-shadow: 0 3px 11px color-mix(in srgb,var(--mode-accent,#146c57) 18%,transparent); }
.filter-chip.stage3-filter-selected { animation: stage3-filter-selected .3s var(--stage3-ease) both; }
.nav-tab,.round-btn,.map-controls button,.route-focus-close,.route-focus-center,.plan-submit { transition: background .2s ease, color .2s ease, box-shadow .2s ease, transform .18s var(--stage3-ease); }
.nav-tab:hover,.round-btn:hover,.map-controls button:hover,.route-focus-center:hover { transform: translateY(-1px); }
.nav-tab:active,.round-btn:active,.map-controls button:active,.route-focus-center:active { transform: scale(.97); }
.selected-route-panel:not([hidden]) { animation: stage3-panel-enter .35s var(--stage3-ease) both; }

@keyframes stage3-route-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb,var(--route-accent,#146c57) 30%,transparent); }
  60% { box-shadow: 0 0 0 4px color-mix(in srgb,var(--route-accent,#146c57) 12%,transparent); }
  100% { box-shadow: 0 0 0 1px color-mix(in srgb,var(--route-accent,#146c57) 12%,transparent); }
}
@keyframes stage3-filter-selected {
  from { transform: scale(.95); opacity: .82; }
  to { transform: scale(1); opacity: 1; }
}
@keyframes stage3-panel-enter {
  from { opacity: .72; translate: 0 7px; }
  to { opacity: 1; translate: 0 0; }
}

/* Keyboard focus should remain clear over white and colored surfaces. */
button:focus-visible,input:focus-visible,select:focus-visible,summary:focus-visible,.leaflet-interactive:focus-visible,.stage3-sheet-grip:focus-visible {
  outline: 3px solid #0e7f67 !important;
  outline-offset: 3px !important;
}
.filter-chip:focus-visible,.route-card:focus-visible { outline-offset: 2px !important; }
.map-controls button:focus-visible { box-shadow: 0 0 0 5px #e6f4eb !important; }
.stage3-sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* Contrast and comfortable targets; no changes to colors defining transport lines. */
.hero-copy p,.route-desc,.route-detail-note,.stage2-route-cue { color: #52625c; }
.section-kicker,.count-row,.route-focus-operator,.route-focus-category small,.stage2-search-feedback,.plan-hint { color: #596c62; }
.brand-sub,.side-foot,.route-focus-data small,.stage2-detail-cell small,.meta-pill { color: #5e7067; }
.map-legend { color: #43564c; }
.map-layer-title small { color: #587164; }
.nav-tab { min-height: 44px; }
.round-btn { min-width: 44px; min-height: 44px; }
.filter-chip { min-height: 42px; }
.stage2-filter-arrow { min-width: 35px; min-height: 42px; flex-basis: 35px; }
.stage2-search-clear { min-width: 36px; min-height: 36px; }
.map-controls button { min-width: 44px; min-height: 44px; }
.route-focus-close { width: 38px; height: 38px; }
.route-focus-center,.plan-submit { min-height: 44px; }
.route-card { min-height: 78px; }
.stage3-sheet-grip { display: none; }

/* Portrait phone: a genuinely draggable, three-height bottom sheet. */
@media (max-width: 820px) and (orientation: portrait) {
  .sidebar {
    height: var(--stage3-sheet-height,min(47dvh,430px));
    transition: height .3s var(--stage3-ease), transform .3s var(--stage3-ease);
    will-change: auto;
  }
  .sidebar[data-sheet-state="closing"] { pointer-events: none; }
  .sidebar.stage3-dragging { transition: none !important; }
  .app .mobile-panel-toggle { display: none !important; }
  .stage3-sheet-grip {
    flex: 0 0 39px;
    min-height: 39px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 4px 12px;
    border: 0;
    border-bottom: 1px solid #eef2ef;
    width: 100%;
    background: #fff;
    color: #587164;
    cursor: grab;
    touch-action: none;
    user-select: none;
  }
  .stage3-sheet-grip:active { cursor: grabbing; }
  .stage3-sheet-handle { display: block; width: 40px; height: 5px; border-radius: 999px; background: #a9bdb3; }
  .sidebar .nav-tabs { margin-top: 8px; }
  .sidebar .side-foot { font-size: 9px; line-height: 1.4; }
  .mobile-panel-toggle {
    min-height: 44px;
    bottom: calc(var(--stage3-sheet-height,min(47dvh,430px)) + 14px + var(--safe-bottom));
    transition: bottom .32s var(--stage3-ease), box-shadow .2s ease;
  }
  .app.stage3-sheet-hidden .mobile-panel-toggle { bottom: calc(14px + var(--safe-bottom)); }
  .app.stage3-sheet-expanded .mobile-panel-toggle { bottom: calc(var(--stage3-sheet-height,min(47dvh,430px)) + 14px + var(--safe-bottom)); }
  .app .map-legend { bottom: calc(var(--stage3-sheet-height,min(47dvh,430px)) + 18px + var(--safe-bottom)); transition: bottom .32s var(--stage3-ease), opacity .18s ease; }
  .app.stage3-sheet-hidden .map-legend { bottom: calc(70px + var(--safe-bottom)); }
  .app.stage3-sheet-expanded .map-legend { opacity: 0; pointer-events: none; }
  .sidebar.stage3-dragging ~ .mobile-panel-toggle,.sidebar.stage3-dragging ~ .map-shell .map-legend { transition: none !important; }
  .stage2-filter-arrow { min-width: 33px; flex-basis: 33px; height: 42px; }
  .stage2-search-clear { min-height: 36px; }
  .map-controls button { min-height: 42px; min-width: 42px; }
}

/* The existing landscape sidebar remains a side panel, not a bottom sheet. */
@media (max-width: 820px) and (orientation: landscape) {
  .map-controls button { min-width: 42px; min-height: 42px; }
}

@media (prefers-reduced-motion: reduce) {
  .route-card,.filter-chip,.nav-tab,.round-btn,.map-controls button,.route-focus-close,.route-focus-center,.plan-submit,.sidebar,.mobile-panel-toggle,.map-legend { animation: none !important; transition: none !important; }
  .selected-route-panel:not([hidden]) { animation: none !important; }
  .route-card:hover { transform: none; }
}
