/* Follow Craig and Laura — flight-tracker inspired dark theme.
   Brand: amber primary (#ffb703), cyan accent (#38bdf8), radar green "live" (#22c55e),
   on a deep navy-black. Layout fits the viewport and reflows to mobile (single column). */

:root {
  --bg: #070b12;
  --bg-2: #0d1420;
  --panel: #111b2b;
  --panel-2: #16233a;
  --border: #23334d;
  --text: #e7eef8;
  --muted: #8ba0bd;
  --amber: #ffb703;
  --amber-dim: #b9860a;
  --cyan: #38bdf8;
  --green: #22c55e;
  --red: #ef4444;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  --mono: "SFMono-Regular", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--sans);
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(56, 189, 248, 0.08), transparent 60%),
    radial-gradient(900px 500px at 10% 110%, rgba(255, 183, 3, 0.06), transparent 55%),
    var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--cyan); }

/* ---------------- Header ---------------- */
header.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 22px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(13, 20, 32, 0.95), rgba(7, 11, 18, 0.9));
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 500;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand img { width: 40px; height: 40px; }

.brand .titles { min-width: 0; }

.brand h1 {
  font-size: 1.05rem;
  letter-spacing: 0.14em;
  margin: 0;
  text-transform: uppercase;
  font-weight: 800;
  white-space: nowrap;
}
.brand h1 .amp { color: var(--amber); }

.brand .tag {
  font-size: 0.72rem;
  color: var(--muted);
  font-family: var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: var(--green);
  border: 1px solid rgba(34, 197, 94, 0.4);
  background: rgba(34, 197, 94, 0.08);
  padding: 4px 10px;
  border-radius: 999px;
  text-transform: uppercase;
}
.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.6); }
  70% { box-shadow: 0 0 0 8px rgba(34, 197, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

.spacer { flex: 1; }

button.primary {
  background: linear-gradient(180deg, var(--amber), var(--amber-dim));
  color: #1a1204;
  border: none;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 10px 18px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(255, 183, 3, 0.25);
  transition: transform 0.08s ease, filter 0.15s ease;
}
button.primary:hover { filter: brightness(1.08); }
button.primary:active { transform: translateY(1px); }

/* ---------------- Stats strip ---------------- */
.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
  background: var(--border);
  border-bottom: 1px solid var(--border);
}
.stat {
  flex: 1 1 160px;
  min-width: 0;
  background: var(--bg-2);
  padding: 12px 20px;
}
.stat .label {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.stat .value {
  font-size: 1.5rem;
  font-weight: 800;
  margin-top: 2px;
  line-height: 1.1;
}
.stat .value.small { font-size: 1.05rem; font-weight: 700; }
.stat .value .unit { font-size: 0.8rem; color: var(--muted); font-weight: 600; }

/* ---------------- Main layout ---------------- */
main {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 380px;
  min-height: 0;
}

#map {
  width: 100%;
  height: 100%;
  min-height: 420px;
  background: #0b1220;
}

/* Timeline sidebar */
.timeline {
  border-left: 1px solid var(--border);
  background: var(--bg-2);
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100vh - 66px - 89px); /* header + stats approx; scroll internally */
}
.timeline .th {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.timeline .feed {
  overflow-y: auto;
  padding: 8px 0;
  flex: 1;
}

.entry {
  padding: 12px 18px;
  border-bottom: 1px solid rgba(35, 51, 77, 0.5);
  cursor: pointer;
  transition: background 0.12s ease;
  position: relative;
}
.entry:hover { background: var(--panel); }
.entry.active { background: var(--panel-2); }
.entry::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: transparent;
}
.entry.latest::before { background: var(--amber); }

.entry .place {
  font-weight: 700;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.entry .when {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 2px;
}
.entry .note {
  font-size: 0.85rem;
  color: #c6d3e6;
  margin-top: 6px;
  overflow-wrap: anywhere;
}
.entry .meta {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.badge {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  text-transform: uppercase;
}
.badge.reporter { color: var(--cyan); border-color: rgba(56, 189, 248, 0.35); }
.crowd-quiet  { color: #94a3b8; border-color: #33415580; }
.crowd-steady { color: #38bdf8; border-color: #38bdf860; }
.crowd-busy   { color: #ffb703; border-color: #ffb70360; }
.crowd-packed { color: #ef4444; border-color: #ef444460; background: rgba(239,68,68,0.08); }

.empty {
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
}
.empty h3 { color: var(--text); margin: 0 0 8px; }

/* ---------------- Map popups & markers ---------------- */
.leaflet-popup-content-wrapper {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.leaflet-popup-tip { background: var(--panel); border: 1px solid var(--border); }
.leaflet-popup-content { margin: 12px 14px; font-family: var(--sans); }
.leaflet-container a.leaflet-popup-close-button { color: var(--muted); }
.popup-place { font-weight: 700; font-size: 0.95rem; }
.popup-meta { font-family: var(--mono); font-size: 0.72rem; color: var(--muted); margin-top: 4px; }
.popup-note { font-size: 0.85rem; margin-top: 6px; }

.pin {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid #0a0e14;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.5);
  background: var(--cyan);
}
.pin.latest {
  background: var(--amber);
  box-shadow: 0 0 0 2px rgba(255, 183, 3, 0.5);
  animation: ping 1.8s ease-out infinite;
}
@keyframes ping {
  0% { box-shadow: 0 0 0 2px rgba(255, 183, 3, 0.6), 0 0 0 0 rgba(255, 183, 3, 0.5); }
  70% { box-shadow: 0 0 0 2px rgba(255, 183, 3, 0.3), 0 0 0 22px rgba(255, 183, 3, 0); }
  100% { box-shadow: 0 0 0 2px rgba(255, 183, 3, 0.3), 0 0 0 0 rgba(255, 183, 3, 0); }
}

/* ---------------- Modal ---------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 12, 0.72);
  backdrop-filter: blur(3px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  width: min(560px, 100%);
  max-height: 92vh;
  overflow-y: auto;
}
.modal .mh {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal .mh h2 { margin: 0; font-size: 1.1rem; }
.modal .mh p { margin: 4px 0 0; color: var(--muted); font-size: 0.82rem; }
.modal .close {
  background: none; border: none; color: var(--muted);
  font-size: 1.6rem; cursor: pointer; line-height: 1;
}
.modal form { padding: 18px 22px 22px; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 5px;
}
.field input, .field select, .field textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 0.9rem;
  font-family: var(--sans);
}
.field textarea { resize: vertical; min-height: 64px; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--amber);
  box-shadow: 0 0 0 2px rgba(255, 183, 3, 0.2);
}
.row { display: flex; gap: 12px; }
.row .field { flex: 1; }

.geo-row { display: flex; gap: 8px; }
.geo-row input { flex: 1; }
button.ghost {
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 0 14px;
  cursor: pointer;
  font-size: 0.85rem;
  white-space: nowrap;
}
button.ghost:hover { border-color: var(--cyan); }

.coord-hint {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 6px;
}
.coord-hint.set { color: var(--green); }

.form-msg {
  font-size: 0.82rem;
  margin-bottom: 12px;
  min-height: 1em;
}
.form-msg.error { color: var(--red); }
.form-msg.ok { color: var(--green); }

.modal .actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }

/* ---------------- Footer ---------------- */
footer {
  border-top: 1px solid var(--border);
  padding: 14px 22px;
  color: var(--muted);
  font-size: 0.78rem;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-2);
}
footer .disclaimer { max-width: 640px; }
footer .ver {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--amber);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 6px;
}

/* ---------------- Responsive ---------------- */
@media (max-width: 900px) {
  main {
    grid-template-columns: 1fr;
    grid-template-rows: 55vh auto;
  }
  #map { min-height: 0; }
  .timeline {
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: none;
  }
  .timeline .feed { max-height: 60vh; }
  .brand .tag { display: none; }
}
@media (max-width: 560px) {
  .stat .value { font-size: 1.2rem; }
  header.topbar { padding: 10px 14px; gap: 10px; }
  .live-pill { display: none; }
}
