/* ═══════════ Flightz app (map) ═══════════ */

html, body.app-body { height: 100%; overflow: hidden; }
#map { position: fixed; inset: 0; }
.maplibregl-canvas { outline: none; }

/* subtle theme tint on basemap */
[data-theme="night"] #map .maplibregl-canvas-container { filter: saturate(0.9); }
[data-theme="day"] #map .maplibregl-canvas-container { filter: saturate(1.02); }

/* ---------- app bar ---------- */
.appbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  display: flex; align-items: center; gap: 0.8rem;
  padding: 0.6rem clamp(0.7rem, 2.5vw, 1.4rem);
  background: color-mix(in srgb, var(--background) 78%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}
.brand {
  display: flex; align-items: center; gap: 0.5rem;
  font-weight: 800; letter-spacing: 0.28em; font-size: 0.8rem;
  text-decoration: none; white-space: nowrap;
}
.brand-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent-glow); }

.searchbox { position: relative; flex: 1; max-width: 380px; }
.searchbox svg { position: absolute; left: 0.8rem; top: 50%; transform: translateY(-50%); color: var(--muted-foreground); pointer-events: none; }
.searchbox .input { height: 2.25rem; padding-left: 2.3rem; font-size: 0.85rem; background: color-mix(in srgb, var(--card) 82%, transparent); }

.appbar-right { display: flex; align-items: center; gap: 0.45rem; margin-left: auto; }

.mode-switch {
  display: flex; padding: 3px; gap: 2px;
  background: var(--muted); border-radius: 999px; border: 1px solid var(--border);
}
.mode-btn {
  border: 0; background: transparent; color: var(--muted-foreground);
  font-size: 0.76rem; font-weight: 700; letter-spacing: 0.04em;
  padding: 0.32rem 0.85rem; border-radius: 999px;
  transition: background 160ms, color 160ms;
}
.mode-btn.active { background: var(--accent); color: var(--primary-foreground); box-shadow: var(--shadow-glow); }

.emg-badge { gap: 0.4rem; color: var(--danger); font-weight: 800; font-size: 0.8rem; }
.pulse {
  width: 9px; height: 9px; border-radius: 50%; background: var(--danger); display: inline-block;
  animation: pulse 1.4s ease-out infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 hsl(0 72% 51% / 0.55); }
  100% { box-shadow: 0 0 0 10px hsl(0 72% 51% / 0); }
}

[data-theme="night"] .icon-sun { display: none; }
[data-theme="day"] .icon-moon { display: none; }

/* ---------- flight panel ---------- */
.panel {
  position: fixed; z-index: 25;
  top: calc(3.6rem + 0.7rem); left: 0.9rem; bottom: 2.6rem;
  width: min(370px, calc(100vw - 1.8rem));
  overflow-y: auto; overscroll-behavior: contain;
  padding: 1rem 1rem 1.2rem;
  scrollbar-width: thin;
}
.panel-close { position: absolute; top: 0.5rem; right: 0.5rem; z-index: 2; }

.fp-head { display: flex; align-items: baseline; gap: 0.6rem; margin: 0.1rem 2rem 0.15rem 0; flex-wrap: wrap; }
.fp-callsign { font-size: 1.45rem; font-weight: 800; letter-spacing: 0.03em; }
.fp-photo {
  width: 100%; aspect-ratio: 16/7.5; object-fit: cover;
  border-radius: var(--radius); border: 1px solid var(--border);
  margin: 0.6rem 0 0.2rem; background: var(--muted);
}
.fp-photo-credit { font-size: 0.62rem; text-align: right; margin: 2px 0 0; }
.fp-route {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 0.4rem;
  margin: 0.7rem 0; padding: 0.7rem 0.6rem;
  background: var(--muted); border-radius: var(--radius);
}
.fp-route .apt { text-align: center; }
.fp-route .iata { font-size: 1.25rem; font-weight: 800; font-family: var(--font-mono); }
.fp-route .city { font-size: 0.68rem; color: var(--muted-foreground); line-height: 1.25; }
.fp-route .arrow { color: var(--accent); }

.statgrid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.45rem;
  margin: 0.6rem 0;
}
.stat {
  background: var(--muted); border-radius: var(--radius-sm);
  padding: 0.5rem 0.55rem;
}
.stat .k { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted-foreground); }
.stat .v { font-size: 0.92rem; font-weight: 700; font-family: var(--font-mono); margin-top: 1px; }
.stat .u { font-size: 0.62rem; color: var(--muted-foreground); font-weight: 400; }

.kv { display: flex; justify-content: space-between; gap: 1rem; padding: 0.32rem 0; border-bottom: 1px dashed var(--border); font-size: 0.8rem; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--muted-foreground); }
.kv .v { font-family: var(--font-mono); text-align: right; }

.fp-section-title {
  margin: 0.9rem 0 0.35rem; font-size: 0.68rem; font-weight: 800;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent);
}

/* trail timeline scrubber */
.timeline { margin: 0.55rem 0 0.2rem; }
.timeline input[type="range"] { width: 100%; accent-color: var(--accent); }
.timeline .tl-meta { display: flex; justify-content: space-between; font-size: 0.66rem; color: var(--muted-foreground); font-family: var(--font-mono); }

/* ---------- agency analysis ---------- */
.agency-box {
  border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--border));
  border-radius: var(--radius); padding: 0.75rem 0.8rem; margin-top: 0.8rem;
  background: color-mix(in srgb, var(--danger) 6%, var(--card));
}
.agency-box h4 { margin: 0 0 0.4rem; font-size: 0.78rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--danger); display: flex; gap: 0.45rem; align-items: center; }
.risk-row { display: flex; justify-content: space-between; gap: 0.8rem; padding: 0.3rem 0; font-size: 0.8rem; border-bottom: 1px dashed color-mix(in srgb, var(--danger) 25%, var(--border)); }
.risk-row:last-child { border-bottom: 0; }
.risk-row .k { color: var(--muted-foreground); }
.risk-row .v { font-family: var(--font-mono); font-weight: 700; text-align: right; }
.risk-row .v.danger { color: var(--danger); }
.methodology { font-size: 0.66rem; line-height: 1.5; color: var(--muted-foreground); margin: 0.6rem 0 0; }
.agency-spinner { display: flex; align-items: center; gap: 0.5rem; font-size: 0.78rem; color: var(--muted-foreground); padding: 0.4rem 0; }
.spin {
  width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid var(--border); border-top-color: var(--accent);
  animation: rot 0.8s linear infinite;
}
@keyframes rot { to { transform: rotate(360deg); } }

/* ---------- emergency drawer ---------- */
.drawer {
  position: fixed; z-index: 26;
  top: calc(3.6rem + 0.7rem); right: 0.9rem;
  width: min(330px, calc(100vw - 1.8rem));
  max-height: min(60vh, 520px);
  display: flex; flex-direction: column;
  padding: 0.9rem 0.9rem 0.6rem;
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; }
.drawer-head h3 { margin: 0; font-size: 0.9rem; display: flex; align-items: center; gap: 0.5rem; color: var(--danger); }
.drawer-sub { font-size: 0.68rem; margin: 0.3rem 0 0.6rem; }
.emg-list { overflow-y: auto; display: flex; flex-direction: column; gap: 0.4rem; }
.emg-item {
  display: flex; justify-content: space-between; align-items: center; gap: 0.6rem;
  padding: 0.5rem 0.6rem; border: 1px solid color-mix(in srgb, var(--danger) 40%, var(--border));
  border-radius: var(--radius-sm); background: color-mix(in srgb, var(--danger) 7%, var(--card));
  cursor: pointer; transition: transform 140ms var(--ease-out);
}
.emg-item:hover { transform: translateX(-3px); }
.emg-item .cs { font-weight: 800; font-family: var(--font-mono); font-size: 0.85rem; }
.emg-item .meta { font-size: 0.64rem; color: var(--muted-foreground); }
.emg-empty { font-size: 0.75rem; color: var(--muted-foreground); padding: 0.6rem 0.2rem; }

/* ---------- status bar ---------- */
.statusbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; gap: 1.4rem; align-items: center;
  padding: 0.28rem clamp(0.7rem, 2.5vw, 1.4rem);
  font-size: 0.66rem; letter-spacing: 0.05em;
  background: color-mix(in srgb, var(--background) 80%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}
.st-src { margin-left: auto; }

/* ---------- toasts ---------- */
.toasts { position: fixed; bottom: 2.6rem; right: 0.9rem; z-index: 60; display: flex; flex-direction: column; gap: 0.5rem; }
.toast {
  background: var(--popover); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  color: var(--popover-foreground);
  border-radius: var(--radius); padding: 0.65rem 0.9rem; font-size: 0.8rem;
  box-shadow: var(--shadow-lg); max-width: 320px;
  animation: toastIn 300ms var(--ease-out);
}
.toast.danger { border-left-color: var(--danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } }

/* ---------- search results dropdown ---------- */
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--popover); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); overflow: hidden; z-index: 40;
}
.sr-item { padding: 0.55rem 0.8rem; font-size: 0.8rem; cursor: pointer; display: flex; justify-content: space-between; gap: 0.6rem; }
.sr-item:hover { background: var(--muted); }
.sr-item .mono { color: var(--muted-foreground); }

/* ---------- mobile ---------- */
@media (max-width: 700px) {
  .appbar { flex-wrap: wrap; gap: 0.5rem; padding-bottom: 0.5rem; }
  .searchbox { order: 3; max-width: none; flex-basis: 100%; }
  .panel {
    top: auto; left: 0; right: 0; bottom: 0; width: 100%;
    max-height: 62vh; border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding-bottom: 2.4rem;
  }
  .drawer { top: auto; bottom: 2.6rem; right: 0.5rem; max-height: 46vh; }
  .statusbar { font-size: 0.6rem; gap: 0.8rem; }
  .statgrid { grid-template-columns: repeat(3, 1fr); }
}
