/**
 * Wayzuno Route Map — dark aviation-chart re-skin.
 * Tokens are scoped to .route-map-shell / .routes-toolbar so they don't
 * leak into the rest of the (light) site.
 */

#result-status, #route-inspector-mount { padding: 16px; color: #e2e8f0; }
#route-map-mount .route-map-svg { position: relative; inset: auto; transform: none; width: 100%; height: auto; min-height: 0; }
#route-map-mount button { padding: 8px 12px; border: 1px solid #475569; border-radius: 6px; background: #1e293b; color: #e2e8f0; cursor: pointer; }
#route-map-mount button:focus-visible, .airport-dot:focus-visible { outline: 2px solid #67e8f9; }
.flight-arc { fill: none; stroke: #22d3ee; stroke-width: 1.5; }
.airport-dot .hit-target { fill: transparent; }
.airport-dot .dot { fill: #38bdf8; }
.airport-dot text { fill: #e2e8f0; font-size: 11px; }
.airport-dot { cursor: pointer; }
#route-inspector-mount a { color: #67e8f9; }

.route-map-shell {
  --map-ocean: #070b14;
  --map-land: #111827;
  --map-coast: #1e293b;
  --map-grid: rgba(148, 163, 184, 0.05);
  --map-ink: #e2e8f0;
  --map-muted: #94a3b8;
  --map-faint: #64748b;
  --map-cyan: #22d3ee;
  --map-blue: #38bdf8;
  --map-emerald: #34d399;
  --map-glass: rgba(15, 23, 42, 0.72);
  --map-glass-border: rgba(148, 163, 184, 0.16);
  --map-radius: 16px;
  font-family: Geist, -apple-system, BlinkMacSystemFont, sans-serif;

  position: relative;
  width: 100%;
  border-radius: var(--map-radius);
  overflow: hidden;
  background: var(--map-ocean);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.route-map-viewport {
  position: relative;
  width: 100%;
}

.route-map-svg {
  width: 100%;
  height: auto;
  display: block;
  touch-action: none;
  cursor: grab;
}

.route-map-svg:active {
  cursor: grabbing;
}

.landmass-fill {
  fill: var(--map-land);
  stroke: var(--map-coast);
  stroke-width: 0.6;
}

/* ---- Airport hub hierarchy ---- */

.airport-node {
  cursor: pointer;
  transition: transform 0.15s ease;
}

.airport-node:hover .airport-circle {
  filter: brightness(1.25);
}

.airport-node.tier-mega:hover .airport-circle { r: 7; }
.airport-node.tier-hub:hover .airport-circle { r: 5.5; }
.airport-node.tier-regional:hover .airport-circle { r: 4; fill: var(--map-blue) !important; }

.airport-ring {
  stroke: var(--map-cyan);
  stroke-width: 1;
  opacity: 0.55;
  animation: hub-ring-pulse 2.6s ease-in-out infinite;
}

@keyframes hub-ring-pulse {
  0%, 100% { opacity: 0.35; r: 9.5; }
  50% { opacity: 0.7; r: 10.5; }
}

.airport-label {
  fill: var(--map-muted);
  font-size: 10px;
  font-weight: 600;
  text-anchor: middle;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.tier-mega .airport-label {
  fill: #f1f5f9;
  font-size: 11px;
  font-weight: 700;
}

/* Regional outstations stay quiet until hovered or the map is zoomed in. */
.tier-regional .airport-label {
  opacity: 0;
}

.tier-regional:hover .airport-label {
  opacity: 1;
}

.map-zoomed-in .tier-regional .airport-label {
  opacity: 0.85;
}

/* ---- Flight arcs: weighted for decluttering ---- */

.route-flight-arc {
  transition: stroke-width 0.15s ease, opacity 0.15s ease;
  cursor: pointer;
}

.weight-trunk .route-flight-arc {
  stroke-dasharray: 6 9;
  animation: route-dash-flow 1.8s linear infinite;
}

.weight-regular .route-flight-arc {
  stroke-dasharray: 4 7;
  animation: route-dash-flow 2.4s linear infinite;
}

.route-flight-arc:hover {
  stroke-width: 3.5 !important;
  opacity: 1 !important;
}

.route-flight-arc-glow {
  pointer-events: none;
}

.flow-particle {
  pointer-events: none;
  filter: drop-shadow(0 0 3px currentColor);
}

@keyframes route-dash-flow {
  to { stroke-dashoffset: -30; }
}

@media (prefers-reduced-motion: reduce) {
  .weight-trunk .route-flight-arc,
  .weight-regular .route-flight-arc,
  .airport-ring {
    animation: none;
  }
}

/* ---- Zoom controls ---- */

.map-zoom-controls {
  position: absolute;
  left: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 12;
}

.zoom-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--map-glass-border);
  background: var(--map-glass);
  color: var(--map-ink);
  font-size: 17px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: background 0.15s ease, transform 0.1s ease;
}

.zoom-btn:hover {
  background: rgba(56, 189, 248, 0.25);
}

.zoom-btn:active {
  transform: scale(0.94);
}

.zoom-btn-fit, .zoom-btn-reset {
  font-size: 15px;
}

/* ---- Details drawer / Network Inspector ---- */

.route-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 340px;
  max-width: 88%;
  background: rgba(9, 14, 26, 0.94);
  backdrop-filter: blur(14px) saturate(140%);
  border-left: 1px solid var(--map-glass-border);
  box-shadow: -12px 0 30px rgba(0, 0, 0, 0.45);
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 20;
  overflow-y: auto;
  color: var(--map-ink);
  font-family: Geist, -apple-system, BlinkMacSystemFont, sans-serif;
}

.route-drawer.open {
  transform: translateX(0);
}

.drawer-backdrop {
  /* On desktop the drawer is a 340px side panel; the map stays fully usable
     beside it, so the backdrop stays inert and invisible until the mobile
     bottom-sheet breakpoint below turns it into a real dimmed overlay. */
  display: none;
  pointer-events: none;
}

.drawer-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: var(--map-muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}

.drawer-close:hover {
  color: #fff;
}

.drawer-content {
  padding: 20px 20px 24px;
}

.drawer-accent {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 5px;
}

.drawer-kicker {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--map-blue);
  margin-top: 10px;
}

.drawer-head h3 {
  margin: 6px 0 2px;
  font-size: 19px;
  font-weight: 700;
}

.drawer-arrow {
  color: var(--map-faint);
}

.drawer-sub {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--map-muted);
}

.inspector-badge-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.inspector-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 28px;
  padding: 0 8px;
  border-radius: 8px;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.inspector-alliance-pill {
  --pill-color: var(--map-blue);
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  color: var(--pill-color);
  border: 1px solid var(--pill-color);
  background: color-mix(in srgb, var(--pill-color) 14%, transparent);
}

.inspector-alliance-pill-independent {
  --pill-color: #64748b;
}

.fleet-consistency {
  margin-top: 14px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--map-glass-border);
  border-radius: 10px;
}

.fleet-consistency-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--map-muted);
}

.fleet-consistency-head strong {
  font-size: 14px;
  color: var(--map-ink);
}

.fleet-consistency-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  margin: 6px 0;
  overflow: hidden;
}

.fleet-consistency-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

.fleet-consistency small {
  color: var(--map-faint);
  font-size: 11px;
}

.drawer-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.drawer-stat {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  padding: 10px 6px;
  text-align: center;
}

.drawer-stat strong {
  display: block;
  font-size: 15px;
  font-weight: 700;
}

.drawer-stat span {
  display: block;
  font-size: 10px;
  color: var(--map-faint);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.drawer-section {
  margin-bottom: 16px;
}

.drawer-section h4 {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--map-faint);
}

.drawer-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.drawer-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--map-glass-border);
  background: rgba(255, 255, 255, 0.05);
  white-space: nowrap;
}

/* Tabbed route list */

.inspector-tabs {
  display: flex;
  gap: 4px;
  margin: 4px 0 10px;
  padding: 3px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
}

.inspector-tab {
  flex: 1;
  padding: 7px 8px;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--map-muted);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.inspector-tab.active {
  background: var(--map-blue);
  color: #05131f;
}

.inspector-search {
  display: block;
  margin-bottom: 10px;
}

.inspector-search-input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--map-glass-border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--map-ink);
  font-size: 12px;
  font-family: inherit;
}

.inspector-search-input::placeholder {
  color: var(--map-faint);
}

.inspector-search-input:focus {
  outline: none;
  border-color: var(--map-blue);
}

.inspector-empty {
  padding: 16px 4px;
  color: var(--map-faint);
  font-size: 12px;
  text-align: center;
}

.drawer-route-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 4px 0 18px;
  max-height: 260px;
  overflow-y: auto;
}

.drawer-route-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  font-size: 12px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.04);
  border: none;
  border-radius: 8px;
  color: var(--map-ink);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease;
}

.drawer-route-row:hover {
  background: rgba(56, 189, 248, 0.16);
}

.drawer-route-row .row-carrier {
  color: var(--map-cyan);
  margin-right: 2px;
}

.drawer-route-row small {
  color: var(--map-faint);
}

.drawer-cta {
  display: block;
  margin-top: 10px;
  padding: 11px 14px;
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  border-radius: 8px;
  transition: filter 0.15s ease, background 0.15s ease;
}

.drawer-cta-primary {
  background: #0284c7;
}

.drawer-cta-primary:hover {
  filter: brightness(1.1);
}

.drawer-cta-secondary {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--map-glass-border);
}

.drawer-cta-secondary:hover {
  background: rgba(255, 255, 255, 0.14);
}

/* ---- Command bar (toolbar) ---- */

.routes-toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-start;
  margin: 16px 0;
  padding: 16px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  font-family: Geist, -apple-system, BlinkMacSystemFont, sans-serif;
}

.routes-toolbar select, .routes-toolbar input {
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}

.toolbar-sheet-handle {
  display: none;
}

.command-field-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #475569;
  margin-bottom: 4px;
}

/* Instant-search airline/airport pickers */

.command-search-field {
  position: relative;
}

.command-search-input {
  width: 220px;
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}

.command-suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 40;
  max-height: 280px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.16);
}

.command-suggestion {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: none;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.command-suggestion:hover, .command-suggestion.active {
  background: #eff6ff;
}

.command-suggestion strong {
  font-size: 13px;
  color: #172033;
}

.command-suggestion small {
  font-size: 11px;
  color: #64748b;
}

/* Scope + aircraft family filter toggles */

.filter-toggle-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.filter-toggle {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1.5px solid #cbd5e1;
  background: #fff;
  color: #334155;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.filter-toggle[aria-pressed="true"] {
  background: #172033;
  border-color: #172033;
  color: #fff;
}

.aircraft-family-select {
  padding: 8px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  color: #334155;
}

/* ---- Alliance filters ---- */

.alliance-toggle-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
  margin-top: 4px;
}

.alliance-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--alliance-color, #cbd5e1);
  background: #fff;
  color: var(--alliance-color, #334155);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.alliance-toggle .alliance-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--alliance-color, #94a3b8);
}

.alliance-toggle[aria-pressed="true"] {
  background: var(--alliance-color, #172033);
  color: #fff;
}

.alliance-toggle[aria-pressed="true"] .alliance-dot {
  background: var(--alliance-accent, #fff);
}

/* ---- Mobile & touch responsive design ---- */

@media (max-width: 1024px) {
  .route-drawer {
    width: 320px;
  }
}

@media (max-width: 768px) {
  .route-map-shell {
    border-radius: 0;
  }

  .route-map-viewport {
    height: 72vh;
    min-height: 380px;
  }

  .route-map-svg {
    height: 100%;
    width: 100%;
    position: absolute;
    inset: 0;
  }

  .map-zoom-controls {
    left: 10px;
    bottom: 14px;
  }

  .zoom-btn {
    width: 40px;
    height: 40px;
    font-size: 19px;
  }

  .route-drawer {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 72vh;
    border-left: none;
    border-top: 1px solid var(--map-glass-border);
    border-radius: 18px 18px 0 0;
    transform: translateY(100%);
  }

  .route-drawer.open {
    transform: translateY(0);
  }

  .drawer-backdrop:not([hidden]) {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 16, 0.45);
    pointer-events: auto;
    z-index: 19;
  }

  .routes-toolbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 30;
    margin: 0;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.18);
    flex-direction: column;
    align-items: stretch;
    max-height: 42px;
    overflow: hidden;
    transition: max-height 0.25s ease;
  }

  .routes-toolbar.expanded {
    max-height: 70vh;
    overflow-y: auto;
  }

  .command-search-input {
    width: 100%;
  }

  .toolbar-sheet-handle {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 10px 0 6px;
    background: none;
    border: none;
    font-size: 13px;
    font-weight: 700;
    color: #334155;
    order: -1;
  }

  .toolbar-sheet-handle .sheet-caret {
    transition: transform 0.2s ease;
  }

  .routes-toolbar.expanded .toolbar-sheet-handle .sheet-caret {
    transform: rotate(180deg);
  }
}
