/* ── Reset ────────────────────────────────────────────────────────────────── */
[hidden], .hidden { display: none !important; }
* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html, body { min-height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f0f4f8;
  color: #1a1a2e;
}

:root {
  --navy:   #1e3a5f;
  --blue:   #2563eb;
  --green:  #16a34a;
  --orange: #ea580c;
  --muted:  #64748b;
  --border: #e2e8f0;
  --card:   #ffffff;
}

/* ── Phase 1: Setup (scrollable page) ─────────────────────────────────────── */
.phase { display: none; }
.phase.active { display: block; min-height: 100dvh; }

/* ── Overlay phases 2 & 3 ─────────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #f0f4f8;
  display: flex;
  flex-direction: column;
  transform: translateX(105%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
}
.overlay.visible { transform: translateX(0); }

#phase-signal { z-index: 200; }

/* ── Shared header ─────────────────────────────────────────────────────────── */
header, .overlay-header {
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: calc(52px + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 50;
}

.logo    { font-size: 18px; font-weight: 700; }
#status  { font-size: 12px; opacity: .75; max-width: 55%; text-align: right; }

.hdr-title { font-size: 15px; font-weight: 600; }

.hdr-btn {
  background: transparent;
  border: none;
  color: #60a5fa;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 0;
  font-family: inherit;
  min-width: 70px;
}
.hdr-btn.hdr-right { text-align: right; }

/* ── Intro ─────────────────────────────────────────────────────────────────── */
#intro {
  background: linear-gradient(160deg, #1e3a5f 0%, #0f2040 100%);
  color: #fff;
  padding: 28px 20px 24px;
}

#intro h1 {
  font-size: 24px; font-weight: 800; line-height: 1.25;
  margin-bottom: 12px; letter-spacing: -0.3px;
}

.intro-lead {
  font-size: 14px; line-height: 1.65;
  color: rgba(255,255,255,.82); margin-bottom: 20px;
}
.intro-lead strong { color: #60a5fa; }

.use-cases { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.use-case {
  display: flex; gap: 12px; align-items: flex-start;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px; padding: 12px 14px;
  font-size: 13px; line-height: 1.5; color: rgba(255,255,255,.8);
}
.use-case strong { display: block; color: #fff; font-size: 13px; margin-bottom: 1px; }
.uc-icon { font-size: 20px; flex-shrink: 0; margin-top: 2px; }

.how-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: rgba(255,255,255,.45); margin-bottom: 8px;
}
.how-steps {
  list-style: none; counter-reset: steps;
  display: flex; flex-direction: column; gap: 7px;
}
.how-steps li {
  counter-increment: steps;
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 13px; line-height: 1.5; color: rgba(255,255,255,.78);
}
.how-steps li::before {
  content: counter(steps);
  background: rgba(96,165,250,.2); color: #60a5fa;
  font-size: 10px; font-weight: 700;
  width: 20px; height: 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 2px;
}

/* ── Setup body ────────────────────────────────────────────────────────────── */
#setup-body { background: var(--card); }

/* Address row */
#addr-row {
  display: flex; gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
#addr-input {
  flex: 1; border: 1.5px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: 15px; font-family: inherit; outline: none; background: #f8fafc;
}
#addr-input:focus { border-color: var(--blue); background: #fff; }
#addr-go, #gps-btn {
  border: 1.5px solid var(--border); border-radius: 10px;
  padding: 10px 12px; font-size: 15px; font-weight: 700;
  cursor: pointer; background: #f8fafc; font-family: inherit;
}
#addr-go { color: var(--blue); }
#addr-go:active, #gps-btn:active { background: #e8f0fe; }

/* Square setup map */
#setup-map-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #e8f0f8;
  border-bottom: 1px solid var(--border);
}
#setup-map { position: absolute; inset: 0; }

#map-hint {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,.55); color: #fff;
  font-size: 12px; font-weight: 600; padding: 5px 12px;
  border-radius: 20px; pointer-events: none; white-space: nowrap;
  z-index: 500;
}

/* Setup controls */
#setup-controls {
  padding: 14px 16px 20px;
  display: flex; flex-direction: column; gap: 14px;
}
#antenna-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; color: var(--muted);
}
#antenna-row label { font-size: 14px; color: var(--muted); }
#antenna-m {
  width: 60px; padding: 6px 8px;
  border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 14px; text-align: center; font-family: inherit;
}

#find-btn {
  width: 100%; padding: 15px;
  background: var(--blue); color: #fff;
  border: none; border-radius: 13px;
  font-size: 16px; font-weight: 700; cursor: pointer; font-family: inherit;
  transition: opacity .15s;
}
#find-btn:active { opacity: .85; }

/* User pin */
.user-pin {
  width: 18px; height: 18px; border-radius: 50%;
  background: #2563eb; border: 3px solid white;
  box-shadow: 0 2px 8px rgba(0,0,0,.4); cursor: grab;
}
.user-pin:active { cursor: grabbing; }

/* ── Airport map ───────────────────────────────────────────────────────────── */
#airport-map-wrap {
  flex: 1; position: relative; min-height: 0;
}
#airport-map { position: absolute; inset: 0; }

#ap-sat-btn {
  position: absolute; top: 10px; right: 50px; z-index: 1000;
  background: white; border: 2px solid rgba(0,0,0,.2);
  border-radius: 6px; padding: 5px 10px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  box-shadow: 0 1px 5px rgba(0,0,0,.25);
}

/* Airport pins */
.ap-pin {
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.35); cursor: pointer; transition: transform .15s;
}
.ap-pin:hover { transform: scale(1.2); }

/* Airport list panel */
#airport-list-panel {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--card); min-height: 0;
}

.airport-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid #f0f4f8;
  cursor: pointer; background: var(--card); transition: background .1s;
}
.airport-row:active { background: #f8fafc; }
.ap-icon {
  width: 42px; height: 42px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.ap-icon.large  { background: rgba(37,99,235,.12); color: var(--blue); }
.ap-icon.medium { background: rgba(22,163,74,.12);  color: var(--green); }
.ap-icon.small  { background: rgba(234,88,12,.12);  color: var(--orange); }
.ap-info { flex: 1; min-width: 0; }
.ap-code { font-family: 'SF Mono','Courier New',monospace; font-weight: 700; font-size: 15px; }
.ap-iata { font-size: 12px; color: var(--muted); margin-left: 6px; font-family: inherit; }
.ap-name { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.ap-dist { text-align: right; flex-shrink: 0; }
.dist-km  { font-weight: 700; font-size: 15px; }
.dist-dir { font-size: 12px; color: var(--muted); margin-top: 2px; }
.hint { padding: 32px 20px; text-align: center; color: var(--muted); font-size: 15px; line-height: 1.6; }

/* Leaflet popup custom style */
.ap-popup { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; min-width: 200px; }
.ap-popup-code { font-family: 'SF Mono','Courier New',monospace; font-size: 17px; font-weight: 700; color: #1e3a5f; }
.ap-popup-iata { font-size: 13px; color: #64748b; font-family: inherit; margin-left: 4px; }
.ap-popup-name { font-size: 13px; color: #1a1a2e; font-weight: 600; margin: 4px 0 3px; }
.ap-popup-meta { font-size: 12px; color: #64748b; margin-bottom: 10px; }
.ap-popup-btn {
  width: 100%; padding: 9px; background: #2563eb; color: white;
  border: none; border-radius: 8px; font-size: 14px; font-weight: 700;
  cursor: pointer; font-family: inherit;
}
.ap-popup-btn:active { opacity: .85; }

/* ── Signal path ───────────────────────────────────────────────────────────── */
#sig-wrap {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 16px; display: flex; flex-direction: column; align-items: center;
}
#sig-wrap > * { width: 100%; max-width: 680px; }

#sig-header { text-align: center; margin-bottom: 8px; }
.sig-code { font-family: 'SF Mono',monospace; font-size: 26px; font-weight: 700; color: var(--blue); }
.sig-name { font-size: 15px; color: var(--muted); margin-top: 2px; }
.sig-meta { font-size: 12px; color: #94a3b8; margin-top: 3px; }

#antenna-display {
  text-align: center; font-size: 13px; color: var(--muted);
  margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border);
}

#sig-loading {
  display: flex; flex-direction: column; align-items: center;
  padding: 48px 0; gap: 16px; color: var(--muted); font-size: 15px;
}
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border); border-top-color: var(--blue);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

#chart { width: 100%; height: 300px; border-radius: 12px; background: #f8fafc; display: block; }

#los-badge {
  display: inline-block; margin: 12px auto 4px;
  padding: 8px 18px; border-radius: 20px; font-size: 14px; font-weight: 700;
}
.los-clear   { background: rgba(22,163,74,.12); color: var(--green); }
.los-blocked { background: rgba(220,38,38,.1);  color: #dc2626; }
.los-error   { background: rgba(234,88,12,.1);  color: var(--orange); }

#pickup-badge {
  font-size: 13px; font-weight: 600; color: var(--muted); text-align: center;
  padding: 6px 14px; background: rgba(100,116,139,.08); border-radius: 20px; margin-top: 6px;
}

#sig-legend {
  display: flex; gap: 20px; font-size: 11px; color: var(--muted);
  margin-top: 12px; justify-content: center;
}
.leg-item { display: flex; align-items: center; gap: 6px; }
.leg-line  { display: inline-block; width: 20px; height: 2px; background: var(--blue); }
.leg-block { display: inline-block; width: 16px; height: 10px; border-radius: 2px; background: rgba(22,163,74,.3); border: 1px solid rgba(22,163,74,.6); }

#sig-credit { font-size: 10px; color: #94a3b8; font-style: italic; text-align: center; margin-top: 10px; padding-bottom: 24px; }
