/* ============================================================
   uwuFlights: base + theme tokens
   Glassmorphism, flat colours only (no gradients/orbs/blobs).
   ============================================================ */

* {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  font-family: "Jua", "Segoe UI", sans-serif;

  -webkit-user-select: none;
  -khtml-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
}

html, body {
  height: 100%;
}

input, textarea {
  user-select: text;
}

:link { color: var(--brand-ink); }
:visited { color: var(--brand-ink); }
a:hover { text-decoration: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---- Brand colour tokens (7 swatches) ---- */
:root,
:root[data-color-theme="classic"] {
  --brand: #ccffcc;
  --brand-rgb: 204, 255, 204;
}
:root[data-color-theme="not-green-1"] { --brand: #ffcccc; --brand-rgb: 255, 204, 204; }
:root[data-color-theme="not-green-2"] { --brand: #ccccff; --brand-rgb: 204, 204, 255; }
:root[data-color-theme="not-green-3"] { --brand: #ffffcc; --brand-rgb: 255, 255, 204; }
:root[data-color-theme="not-green-4"] { --brand: #ffccff; --brand-rgb: 255, 204, 255; }
:root[data-color-theme="not-green-5"] { --brand: #ccffff; --brand-rgb: 204, 255, 255; }
:root[data-color-theme="really-light-green"] { --brand: #ffffff; --brand-rgb: 255, 255, 255; }

/* ---- Light / dark surface tokens ---- */
:root,
:root[data-mode="light"] {
  --bg: #eef2f0;
  --surface: rgba(255, 255, 255, 0.55);
  --surface-strong: rgba(255, 255, 255, 0.78);
  --surface-border: rgba(255, 255, 255, 0.65);
  --ink: #121815;
  --muted: #5b665f;
  --shadow: 0 10px 30px rgba(20, 40, 30, 0.10);
  --brand-ink: #1f6b3d;
  --ok: #16a34a;
  --warn: #b45309;
  --busy: #64748b;
  --error: #b91c1c;
}

:root[data-mode="dark"] {
  --bg: #0c100e;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-strong: rgba(255, 255, 255, 0.11);
  --surface-border: rgba(255, 255, 255, 0.14);
  --ink: #eef2ef;
  --muted: #9aa7a0;
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.5);
  --brand-ink: #bff5cf;
  --ok: #4ade80;
  --warn: #fbbf24;
  --busy: #94a3b8;
  --error: #f87171;
}

body {
  /* flat, static colour derived from theme, no gradients */
  background-color: color-mix(in srgb, var(--brand) 10%, var(--bg));
  color: var(--ink);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color 0.25s ease, color 0.25s ease;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

/* ============================================================
   Glassmorphism primitive
   ============================================================ */
.glass {
  background: var(--surface);
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid var(--surface-border);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

/* ============================================================
   Layout
   ============================================================ */
#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 14px 14px 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.topbar {
  position: sticky;
  top: 10px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  font-size: 1.25rem;
  color: var(--brand-ink);
}

.brand-icon {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  object-fit: contain;
  border-radius: 6px;
}

.brand-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--surface-strong);
  border: 1px solid var(--surface-border);
  color: var(--ink);
  transition: transform 0.15s ease, background 0.15s ease;
}
.icon-btn:hover { transform: translateY(-1px); }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.small { width: 34px; height: 34px; }
.icon-btn.small svg { width: 16px; height: 16px; }

.coffee-btn {
  width: auto;
  padding: 0 14px 0 12px;
  gap: 8px;
  text-decoration: none;
  color: var(--brand-ink);
  background: color-mix(in srgb, var(--brand) 55%, var(--surface-strong));
  font-size: 0.85rem;
  white-space: nowrap;
}

/* ============================================================
   Status bar
   ============================================================ */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 14px;
  font-size: 0.9rem;
}
.status-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
#statusText {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--busy);
  flex-shrink: 0;
}
.status-dot[data-tone="ok"] { background: var(--ok); }
.status-dot[data-tone="warn"] { background: var(--warn); }
.status-dot[data-tone="busy"] { background: var(--busy); }

.status-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.text-btn {
  color: var(--brand-ink);
  font-size: 0.85rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}

/* ============================================================
   Tabs
   ============================================================ */
.tabs {
  display: flex;
  padding: 6px;
  gap: 4px;
}
.tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 8px;
  border-radius: 14px;
  color: var(--muted);
  font-size: 0.9rem;
  transition: background 0.15s ease, color 0.15s ease;
}
.tab svg { width: 18px; height: 18px; }
.tab.active {
  background: color-mix(in srgb, var(--brand) 45%, var(--surface-strong));
  color: var(--brand-ink);
}

.panel { display: none; flex-direction: column; gap: 12px; }
.panel.active {
  display: flex;
  animation: panel-in 0.22s ease;
}

@keyframes panel-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-title {
  font-size: 1rem;
  color: var(--muted);
  margin: 4px 2px 0;
}

/* ============================================================
   Radar
   ============================================================ */
.radar-card {
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.radar-card-head {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.radar-card-head h2 { font-size: 1.05rem; color: var(--brand-ink); }

.chip-btn {
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface-strong);
  border: 1px solid var(--surface-border);
  font-size: 0.82rem;
  white-space: nowrap;
}

.radar-ring {
  position: relative;
  width: min(70vw, 260px);
  height: min(70vw, 260px);
  border-radius: 50%;
  margin: 6px 0;
}
.radar-ring-track {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px dashed var(--surface-border);
}
.radar-ring-track.inner { inset: 25%; }
.radar-ring-line {
  position: absolute;
  background: var(--surface-border);
}
.radar-ring-line.n { top: 0; bottom: 0; left: 50%; width: 1px; }
.radar-ring-line.e { left: 0; right: 0; top: 50%; height: 1px; }

.radar-label {
  position: absolute;
  font-size: 0.7rem;
  color: var(--muted);
}
.radar-label.n { top: -18px; left: 50%; transform: translateX(-50%); }
.radar-label.s { bottom: -18px; left: 50%; transform: translateX(-50%); }
.radar-label.e { right: -18px; top: 50%; transform: translateY(-50%); }
.radar-label.w { left: -18px; top: 50%; transform: translateY(-50%); }

.radar-center {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 22px;
  height: 22px;
  transform: translate(-50%, -50%);
  color: var(--brand-ink);
}
.radar-center svg { width: 100%; height: 100%; }

.radar-markers {
  position: absolute;
  inset: 0;
  transition: transform 0.2s linear;
}
.radar-marker {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px;
  color: var(--brand-ink);
}
.radar-marker svg { width: 100%; height: 100%; }

.hint {
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
}

/* ============================================================
   Cards
   ============================================================ */
.list-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 10px 14px;
  font-size: 0.85rem;
  color: var(--muted);
}
.badge {
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--surface-strong);
  font-size: 0.75rem;
  white-space: nowrap;
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ac-card, .fav-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 16px;
}

.ac-card-main {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  text-align: left;
  cursor: pointer;
}

.ac-card-icon, .fav-card-icon {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  color: var(--brand-ink);
}
.ac-card-icon svg, .fav-card-icon svg { width: 100%; height: 100%; }

.ac-card-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.ac-card-text strong {
  font-size: 0.98rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.muted { color: var(--muted); font-size: 0.8rem; }

.ac-card-stats {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  font-size: 0.78rem;
  color: var(--muted);
  flex-shrink: 0;
}

.star-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  flex-shrink: 0;
}
.star-btn svg { width: 18px; height: 18px; }
.star-btn.active { color: var(--brand-ink); }

.empty-state {
  padding: 24px;
  text-align: center;
  font-size: 0.9rem;
}

/* ============================================================
   Modals
   ============================================================ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(10, 15, 12, 0.35);
  padding: 12px;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.2s ease, visibility 0s linear 0s;
}
.modal-backdrop.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.18s ease, visibility 0s linear 0.18s;
}

@media (min-width: 640px) {
  .modal-backdrop { align-items: center; }
}

.modal {
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface-strong);
  opacity: 1;
  transform: translateY(0) scale(1);
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.18s ease;
}
.modal-backdrop.hidden .modal {
  opacity: 0;
  transform: translateY(14px) scale(0.97);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-head h2 { font-size: 1.1rem; color: var(--brand-ink); }

.modal-subtitle {
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 4px;
}

.mode-toggle {
  display: flex;
  gap: 6px;
  padding: 4px;
  border-radius: 14px;
  background: var(--surface);
}
.mode-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px;
  border-radius: 10px;
  font-size: 0.85rem;
  color: var(--muted);
  transition: background 0.15s ease, color 0.15s ease;
}
.mode-btn svg { width: 16px; height: 16px; }
.mode-btn.active {
  background: color-mix(in srgb, var(--brand) 55%, var(--surface-strong));
  color: var(--brand-ink);
}

.swatch-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
.swatch {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--surface-border);
  font-size: 0.78rem;
  text-align: left;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.swatch.active {
  border-color: var(--swatch-color);
  box-shadow: 0 0 0 2px var(--swatch-color);
}
.swatch-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--swatch-color);
  border: 1px solid rgba(0,0,0,0.08);
  flex-shrink: 0;
}

.location-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.location-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.82rem;
  color: var(--muted);
}
.location-form input {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--surface-border);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.95rem;
}
.modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.btn {
  padding: 10px 18px;
  border-radius: 12px;
  background: var(--brand);
  color: var(--brand-ink);
  font-size: 0.9rem;
}

.detail-actions { margin-bottom: 8px; }
.detail-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  font-size: 0.88rem;
}
.detail-grid dt { color: var(--muted); }
.detail-grid dd { text-align: right; }

body.modal-open { overflow: hidden; }

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 0);
  z-index: 60;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--surface-strong);
  border: 1px solid var(--surface-border);
  backdrop-filter: blur(14px);
  font-size: 0.85rem;
  box-shadow: var(--shadow);
  opacity: 1;
  visibility: visible;
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0s linear 0s;
}
.toast.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
}
.toast[data-tone="error"] { color: var(--error); }
.toast[data-tone="ok"] { color: var(--ok); }

/* ============================================================
   Footer
   ============================================================ */
.site-footer {
  text-align: center;
  padding: 6px 8px 4px;
  font-size: 0.8rem;
  color: var(--muted);
}
.footer-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 4px 0;
}
.footer-heart {
  display: inline-flex;
  width: 15px;
  height: 15px;
  color: #34c759;
}
.footer-heart svg { width: 100%; height: 100%; }
.footer-sources a {
  color: var(--brand-ink);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ============================================================
   Small screens
   ============================================================ */
@media (max-width: 480px) {
  #app {
    padding: 10px 10px 32px;
    gap: 10px;
  }

  .topbar {
    padding: 10px 12px;
  }

  .brand {
    font-size: 1.1rem;
  }

  .brand-icon {
    width: 22px;
    height: 22px;
  }

  /* Coffee button collapses to icon-only so it can't force the topbar
     to overflow horizontally; the label remains for screen readers via
     aria-label on the link itself. */
  .coffee-btn {
    width: 42px;
    padding: 0;
    justify-content: center;
  }
  .coffee-label {
    display: none;
  }

  .status-bar {
    flex-wrap: wrap;
  }

  .tab {
    font-size: 0.8rem;
    padding: 9px 4px;
    gap: 4px;
  }
  .tab svg {
    width: 16px;
    height: 16px;
  }

  .radar-ring {
    width: min(78vw, 260px);
    height: min(78vw, 260px);
  }

  .ac-card, .fav-card {
    padding: 9px 10px;
    gap: 8px;
  }

  .ac-card-stats {
    font-size: 0.72rem;
  }

  .swatch-grid {
    grid-template-columns: 1fr;
  }
}
