/* ===== Ambient backdrop ===== */
.aurora {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(60% 50% at 20% 10%, color-mix(in oklab, var(--accent) 14%, transparent), transparent 70%),
    radial-gradient(50% 50% at 85% 90%, color-mix(in oklab, var(--gold) 12%, transparent), transparent 70%);
  filter: blur(20px);
  opacity: 0.8;
  animation: drift 18s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: translate3d(-2%, -1%, 0) scale(1.05); }
  to   { transform: translate3d(3%, 2%, 0) scale(1.12); }
}

/* ===== Top bar ===== */
.topbar {
  position: relative;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) clamp(var(--space-4), 4vw, var(--space-10));
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: var(--space-3); }
.logo { width: 38px; height: 38px; color: var(--color-text); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-lg);
  letter-spacing: -0.01em;
}
.brand-sub { font-size: var(--text-xs); color: var(--color-text-muted); }

.controls { display: flex; align-items: center; gap: var(--space-3); }

.seg {
  display: inline-flex;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 3px;
}
.seg-btn {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-text-muted);
  border-radius: var(--radius-full);
  white-space: nowrap;
}
.seg-btn[aria-pressed="true"] {
  background: var(--accent);
  color: #04140c;
  font-weight: 700;
  box-shadow: var(--glow);
}
.seg-btn:not([aria-pressed="true"]):hover { color: var(--color-text); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ===== Layout ===== */
.layout {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: var(--space-4);
  height: calc(100dvh - 84px);
  padding: 0 clamp(var(--space-4), 4vw, var(--space-10)) var(--space-6);
}

/* ===== Globe stage ===== */
/* The globe is an immersive space scene — keep the stage dark in both themes
   so the 3D sphere and hero text stay legible. */
.stage {
  position: relative;
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: radial-gradient(120% 120% at 50% 0%, #0d1a15, #07100d 70%);
  border: 1px solid var(--color-border);
  color-scheme: dark;
}
.stage .next-label { color: #8fae9f; }
.stage .next-city { color: #e7f3ec; }
.stage .hint { color: #5a7568; }
#globe { width: 100%; height: 100%; cursor: grab; }
#globe:active { cursor: grabbing; }

.next-hero {
  position: absolute;
  left: 50%;
  bottom: var(--space-8);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  pointer-events: none;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.55);
}
.next-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--color-text-muted);
}
.next-city {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-xl);
  margin-top: var(--space-1);
}
.next-count {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-2xl);
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}
.next-when {
  font-size: var(--text-sm);
  color: var(--gold);
  font-weight: 700;
  letter-spacing: 0.04em;
}
.hint {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  pointer-events: none;
}

/* ===== Side panel ===== */
.panel {
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  overflow: hidden;
}
.panel-head {
  padding: var(--space-5) var(--space-5) var(--space-3);
  border-bottom: 1px solid var(--color-border);
}
.panel-head h2 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
}
.panel-sub { font-size: var(--text-xs); color: var(--color-text-muted); display: block; }
.search {
  margin-top: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--color-text);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.search::placeholder { color: var(--color-text-faint); }
.search:focus-visible { border-color: var(--accent); outline: none; }
.no-results {
  padding: var(--space-6);
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.city-list {
  overflow-y: auto;
  flex: 1;
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
}
.city-row[hidden] { display: none !important; }
.city-row {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-3);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition-interactive);
}
.city-row:hover { background: var(--color-surface-2); }
.city-row.active {
  background: color-mix(in oklab, var(--accent) 14%, transparent);
}
.city-row.blazing {
  background: color-mix(in oklab, var(--gold) 22%, transparent);
  animation: pulse 1.2s ease-in-out infinite;
}
@keyframes pulse {
  50% { background: color-mix(in oklab, var(--gold) 38%, transparent); }
}
.rank {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.city-meta { min-width: 0; }
.city-name {
  font-weight: 700;
  font-size: var(--text-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.city-info {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.city-count {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.cc-time {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-base);
  color: var(--accent);
}
.cc-when {
  font-size: 0.7rem;
  color: var(--color-text-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.blazing .cc-time, .blazing .cc-when { color: var(--gold); }
.blazing .cc-when::after { content: " · blaze it"; }

/* ===== Responsive ===== */
@media (max-width: 880px) {
  body { overflow: auto; }
  .layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .stage { height: 56vh; min-height: 360px; }
  .panel { max-height: 60vh; }
  .city-list { max-height: 48vh; }
}
@media (max-width: 520px) {
  .brand-sub { display: none; }
  .seg-btn { padding: var(--space-2) var(--space-3); }
}

/* ---------------- Secret easter-egg mode ---------------- */
body.secret-on .next-count {
  background: linear-gradient(90deg, var(--gold), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: secretPulse 1.6s ease-in-out infinite;
}
body.secret-on .stage {
  box-shadow: inset 0 0 120px rgba(255, 200, 96, 0.18);
}
@keyframes secretPulse {
  0%, 100% { filter: drop-shadow(0 0 6px rgba(255, 200, 96, 0.35)); }
  50% { filter: drop-shadow(0 0 18px rgba(255, 200, 96, 0.7)); }
}
