/* Radar (live map) */

/* Aircraft colour tokens — kept in lockstep with the iOS asset catalog
   (MapAirplaneColor / MapAirplaneSpottedColor / MapAirplaneSelectedColor).
   Update both sides together if either changes. */
:root {
  --marker-new:      #F9D301; /* yellow — default / not yet spotted */
  --marker-spotted:  #73CCF0; /* blue   — confirmed spotted on PlaneSpot */
  --marker-selected: #3DD77C; /* green  — selected & not spotted */
}

body.radar-body {
  /* Let the map fill the viewport below the nav */
  overflow: hidden;
}

.radar-page {
  position: fixed;
  top: var(--nav-h);
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr;
}

#radar-map {
  width: 100%;
  height: 100%;
  background: #0d1117;
}

/* Floating chrome — status pill, controls, legend, help */
.radar-status {
  position: absolute;
  top: 16px; left: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: color-mix(in srgb, var(--background) 88%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: 13px;
  color: var(--text);
  box-shadow: var(--shadow-md);
  z-index: 5;
}
.radar-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 60%, transparent);
  animation: radar-pulse 2s infinite;
}
@keyframes radar-pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 60%, transparent); }
  70%  { box-shadow: 0 0 0 10px color-mix(in srgb, var(--success) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--success) 0%, transparent); }
}

/* Map controls — top-left below the status pill */
.radar-controls {
  position: absolute;
  top: 64px;
  left: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: color-mix(in srgb, var(--background) 92%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px;
  box-shadow: var(--shadow-md);
  z-index: 5;
}
.radar-ctrl-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 0;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color 0.15s var(--ease), color 0.15s var(--ease);
}
.radar-ctrl-btn:hover { background: color-mix(in srgb, var(--unique) 10%, transparent); color: var(--text); }
.radar-ctrl-btn[aria-pressed="true"] {
  background: color-mix(in srgb, var(--unique) 14%, transparent);
  color: var(--unique);
}
.radar-ctrl-btn.is-loading { color: var(--unique); animation: radar-spin 1s linear infinite; }
@keyframes radar-spin { to { transform: rotate(360deg); } }

/* Legend — bottom-left */
.radar-legend {
  position: absolute;
  bottom: 68px; left: 16px;
  display: flex;
  gap: 14px;
  background: color-mix(in srgb, var(--background) 92%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 11px;
  color: var(--text-muted);
  box-shadow: var(--shadow-md);
  z-index: 5;
}
.radar-legend .legend-item { display: inline-flex; align-items: center; gap: 6px; }
.radar-legend .legend-swatch {
  width: 14px; height: 14px;
  display: inline-grid;
  place-items: center;
  font-size: 10px;
  line-height: 1;
}
.radar-legend .legend-swatch.new     { color: var(--marker-new); }
.radar-legend .legend-swatch.spotted { color: var(--marker-spotted); }

.radar-help {
  position: absolute;
  bottom: 16px; left: 16px;
  background: color-mix(in srgb, var(--background) 88%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-muted);
  z-index: 5;
  box-shadow: var(--shadow-md);
}
.radar-help a { color: var(--unique); }
.radar-help a:hover { color: color-mix(in srgb, var(--unique) 80%, black); }

/* Aircraft marker.
   MapLibre owns the button's `transform` (translate + rotateZ via
   Marker.setRotation). Any CSS transforms here MUST stay on the inner <svg>,
   not on the button — otherwise we clobber MapLibre's translate and every
   marker snaps to screen (0,0). Scale-on-hover/select lives on the <svg>
   for exactly that reason. */
.aircraft-marker {
  width: 28px; height: 28px;
  display: inline-block;
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
}
.aircraft-marker svg {
  display: block;
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.45));
  transform-origin: center center;
  transition: transform 0.15s ease;
}
/* Default = yellow ("new"). Blue overrides when confirmed spotted. Selected
   without a spotting goes green; selected + spotted stays blue (matches iOS). */
.aircraft-marker .ac-path                          { fill: var(--marker-new); transition: fill 0.15s ease; }
.aircraft-marker.is-spotted .ac-path               { fill: var(--marker-spotted); }
.aircraft-marker.is-selected .ac-path              { fill: var(--marker-selected); }
.aircraft-marker.is-selected.is-spotted .ac-path   { fill: var(--marker-spotted); }
.aircraft-marker.is-on-ground                      { opacity: 0.65; }
.aircraft-marker.is-selected svg { transform: scale(1.2); }
.aircraft-marker:hover svg       { transform: scale(1.1); }

/* User-location marker */
.user-location-marker {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--unique);
  border: 2px solid #fff;
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--unique) 25%, transparent),
              0 1px 4px rgba(0,0,0,0.4);
}

/* Detail sheet (bottom on mobile, side panel on desktop) */
.flight-sheet {
  position: absolute;
  z-index: 10;
  background: var(--surface-raised);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
}
.flight-sheet.is-open { display: flex; }

@media (min-width: 768px) {
  .flight-sheet {
    top: 16px; right: 16px;
    width: 360px;
    max-height: calc(100% - 32px);
    border-radius: var(--radius-lg);
  }
}
@media (max-width: 767px) {
  .flight-sheet {
    left: 0; right: 0; bottom: 0;
    max-height: 70vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-bottom: 0;
  }
  .radar-controls { top: auto; bottom: 100px; }
  .radar-legend   { display: none; }
}

/* ---------------------------------------------------------------------------
   Flight-detail sheet — visual parity with iOS FlightDetailSheet.
   Structure (built by radar.js):
     • Header  (airline logo + airline name + flight no + callsign/type chips)
     • Route   (departure leg | duration divider | arrival leg)
     • Sightings (spotter row + hero photo + see-on-PlaneSpot button)
     • Aircraft (rounded surface card of detailRows)
     • Live Position (rounded surface card of detailRows)
--------------------------------------------------------------------------- */

.flight-sheet-close {
  position: absolute;
  top: 8px; right: 8px;
  width: 32px; height: 32px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 22px;
  line-height: 1;
  color: var(--text-muted);
  background: transparent;
  border: 0;
  cursor: pointer;
  z-index: 2;
}
.flight-sheet-close:hover { background: var(--surface); color: var(--text); }

.flight-sheet-scroll {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 8px 0 28px;
}

/* Loading skeleton */
.fd-loading {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 16px;
}
.fd-skeleton {
  background: color-mix(in srgb, var(--text) 6%, transparent);
  border-radius: var(--radius-sm);
  animation: fd-pulse 1.4s ease-in-out infinite;
}
.fd-skeleton.row { height: 18px; }
.fd-skeleton.title { height: 24px; width: 60%; }
.fd-skeleton.block { aspect-ratio: 16 / 9; }
@keyframes fd-pulse {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}

/* Header — airline logo / airline name / flight number + chips */
.fd-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 44px 16px 16px;
  border-bottom: 1px solid var(--border);
}
.fd-airline-logo {
  width: 50px; height: 50px;
  flex: 0 0 50px;
  display: grid; place-items: center;
  overflow: hidden;
}
.fd-airline-logo img { width: 100%; height: 100%; object-fit: contain; }
.fd-airline-logo-fallback {
  width: 100%; height: 100%;
  display: grid; place-items: center;
  color: color-mix(in srgb, var(--text) 15%, transparent);
  font-size: 32px;
}
.fd-header-text { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.fd-airline-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fd-flight-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fd-flight-number {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.fd-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  background: color-mix(in srgb, var(--unique) 12%, transparent);
  color: var(--unique);
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Section titles */
.fd-section-title {
  padding: 8px 16px;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}

/* Route */
.fd-route {
  padding: 0 16px;
  display: flex;
  flex-direction: column;
}
.fd-leg {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 0;
}
.fd-leg-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.fd-leg-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.fd-plane-departure {
  width: 22px; height: 22px;
  flex: 0 0 22px;
  border-radius: 50%;
  background: var(--text);
  color: var(--background);
  display: grid; place-items: center;
  font-size: 10px;
}
.fd-leg-iata {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
}
.fd-leg-iata.is-missing { color: color-mix(in srgb, var(--text) 40%, transparent); }
.fd-leg-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 100%;
  min-width: 0;
}
.fd-leg-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.fd-leg-dot {
  color: var(--text-muted);
  font-size: 15px;
}
.fd-leg-chevron {
  color: color-mix(in srgb, var(--text) 35%, transparent);
  font-size: 10px;
}
.fd-leg-time {
  font-size: 34px;
  font-weight: 700;
  color: #2BAA56;
  letter-spacing: -0.02em;
  line-height: 1;
}
.fd-leg-time.is-missing { color: color-mix(in srgb, var(--text) 28%, transparent); }
.fd-leg-status {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}
.fd-leg-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  padding-top: 2px;
  flex: 0 0 auto;
}
.fd-gate-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--text) 8%, transparent);
  color: color-mix(in srgb, var(--text) 40%, transparent);
  font-size: 14px;
  font-weight: 700;
}
.fd-gate-pill.has-gate { background: color-mix(in srgb, var(--unique) 14%, transparent); color: var(--text); }
.fd-gate-pill i { font-size: 10px; }
.fd-terminal {
  font-size: 13px;
  color: var(--text-muted);
}
.fd-duration {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 0 10px 32px;
  color: color-mix(in srgb, var(--text) 45%, transparent);
  font-size: 12px;
  font-weight: 500;
}
.fd-duration i { font-size: 11px; }
.fd-duration .fd-duration-line {
  flex: 1;
  height: 1px;
  background: color-mix(in srgb, var(--text) 12%, transparent);
}

/* Sightings */
.fd-sightings {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.fd-spotter {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  text-decoration: none;
  color: inherit;
}
.fd-spotter-avatar {
  width: 37px; height: 37px;
  flex: 0 0 37px;
  border-radius: 50%;
  background: var(--surface);
  overflow: hidden;
  display: grid; place-items: center;
  font-size: 16px;
}
.fd-spotter-avatar img { width: 100%; height: 100%; object-fit: cover; }
.fd-spotter-meta { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.fd-spotter-name {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
}
.fd-spotter-verified {
  color: #E4B82C; /* iOS yellow checkmark.seal.fill */
  font-size: 13px;
}
.fd-spotter-time {
  font-size: 13px;
  color: color-mix(in srgb, var(--text) 50%, transparent);
}
/* Hero photo. The aspect-ratio lives on the <img> rather than the wrapper so
   the box has a real layout height before the image finishes loading — putting
   `aspect-ratio` on a margin'd flex item doesn't reliably establish a height
   in all browsers and the photo would otherwise collapse to 0. */
.fd-hero {
  margin: 0 14px;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
.fd-hero img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  background: var(--surface);
}
.fd-hero.is-broken { display: none; }
.fd-hero-disclaimer {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 18px 0;
  font-size: 11px;
  font-weight: 500;
  color: color-mix(in srgb, var(--text) 35%, transparent);
}
.fd-see-on-ps {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 14px 0;
  padding: 16px;
  background: var(--surface);
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  color: var(--unique);
  text-decoration: none;
}
.fd-see-on-ps i.fa-image,
.fd-see-on-ps i.fa-images { font-size: 15px; }
.fd-see-on-ps .fd-see-on-ps-text { flex: 1; }
.fd-see-on-ps .fd-see-on-ps-chev {
  color: color-mix(in srgb, var(--text) 28%, transparent);
  font-size: 12px;
}

/* Aircraft / Live Position rounded cards */
.fd-card {
  margin: 0 16px;
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
}
.fd-card-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  font-size: 15px;
}
.fd-card-row + .fd-card-row {
  border-top: 1px solid color-mix(in srgb, var(--text) 6%, transparent);
}
.fd-card-key {
  color: color-mix(in srgb, var(--text) 45%, transparent);
}
.fd-card-val {
  font-weight: 500;
  color: var(--text);
  text-align: right;
  overflow-wrap: anywhere;
}
.fd-card-val.is-missing { color: color-mix(in srgb, var(--text) 22%, transparent); }
.fd-card-val.mono { font-family: var(--font-mono); }

/* Divider between major sections (Aircraft / Live Position). */
.fd-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

/* Inline error/empty state. */
.fd-error {
  margin: 16px;
  padding: 14px 16px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--text) 4%, transparent);
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}
