@import url("https://fonts.bunny.net/css?family=figtree:400,500,600,700&display=swap");

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  color-scheme: dark;
  --blue-50: #e8f0fe;
  --blue-100: #c5d8fc;
  --blue-200: #93b8f9;
  --blue-400: #4a90e8;
  --blue-500: #2a72d4;
  --blue-600: #1a57b0;
  --blue-700: #0e3d88;
  --blue-800: #072b66;
  --blue-900: #031844;

  --rain-from: #1a3e7a;
  --rain-to: #2a72d4;
  --clear-from: #1a3e7a;
  --clear-to: #2a72d4;

  --bg: #0a0f1e;
  --surface: #111827;
  --surface2: #1c2436;
  --text: #f0f4ff;
  --text-muted: #8fa3cc;
  --text-subtle: #4d6080;
  --bar-track: rgba(255, 255, 255, 0.15);
  --bar-fill: #93b8f9;
  --ring: #4a90e8;

  --font-sans:
    'Figtree', "TeX Gyre Heros", "Nimbus Sans", "SF Pro Display",
    "SF Pro Text", "SF Pro", "Helvetica Neue", Helvetica, Inter,
    -apple-system, Roboto, "Liberation Sans", Arimo, FreeSans,
    "DejaVu Sans", "Noto Sans", Arial, system-ui, sans-serif;
}

* {
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -o-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  background: var(--bg);
  color: var(--text);
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.app {
  width: 100%;
  max-width: 420px;
}

/* ── Header ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.logo svg {
  color: var(--blue-200);
  flex-shrink: 0;
}

.city-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 0.625rem 1rem;
  border-radius: 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.city-btn:hover {
  background: var(--surface2);
}
.city-btn svg {
  color: var(--text-muted);
}

/* ── Card ── */
.card {
  border-radius: 1.5rem;
  padding: 2.5rem 2rem;
  text-align: center;
  background: linear-gradient(140deg, var(--rain-from), var(--rain-to));
  transition: background 0.5s ease;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, 0.12);
  pointer-events: none;
}

.card.clear {
  --rain-from: #0e3a7a;
  --rain-to: #185cb8;
}

.card-icon {
  font-size: 5.5rem;
  line-height: 1;
  margin-bottom: 1.5rem;
  display: block;
}

.card-icon svg {
  width: 88px;
  height: 88px;
  display: block;
  margin: 0 auto;
  filter: drop-shadow(0 4px 16px rgba(0, 0, 0, 0.3));
}

.card-result {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.375rem;
  color: #ffffff;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.card-detail {
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 2rem;
}

.card-detail.loading {
  color: rgba(255, 255, 255, 0.5);
}

/* ── Bars ── */
.bars-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.7);
  margin-bottom: 0.5rem;
  padding: 0 0.25rem;
}

.bars {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 2rem;
}

.bar-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
  flex: 1;
}

.bar-track {
  width: 100%;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  height: 7rem;
  position: relative;
  overflow: hidden;
}

.bar-fill {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  background: rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  transition: height 0.7s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.bar-pct {
  font-size: 0.75rem;
  font-weight: 600;
  color: #ffffff;
}

.bar-label {
  font-size: 0.6875rem;
  color: rgba(255, 255, 255, 0.65);
}

/* ── Refresh button ── */
.refresh-btn {
  width: 100%;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #ffffff;
  padding: 1rem;
  border-radius: 1rem;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  transition: background 0.15s;
}

.refresh-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}
.refresh-btn:active {
  background: rgba(255, 255, 255, 0.08);
}
.refresh-btn svg {
  transition: transform 0.3s;
}
.refresh-btn.spinning svg {
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ── Footer ── */
.footer {
  text-align: center;
  margin-top: 2rem;
  font-size: 0.8125rem;
  color: var(--text-subtle);
}

.footer a {
  color: var(--text-muted);
  text-decoration: none;
}

.footer a:hover {
  color: var(--text);
}

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1.5rem;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 1.5rem;
  padding: 2rem;
  width: 100%;
  max-width: 22rem;
  animation: fadeInScale 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes fadeInScale {
  from {
    opacity: 0;
    transform: scale(0.88);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal h2 {
  font-size: 1.25rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 1.25rem;
  color: var(--text);
}

.city-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.city-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  padding: 0.875rem 1.125rem;
  border-radius: 0.875rem;
  background: var(--bg);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition:
    background 0.12s,
    border-color 0.12s;
}

.city-item:hover {
  background: var(--surface2);
}

.city-item.active {
  background: var(--surface2);
  border-color: var(--blue-400);
}

.city-item .check svg {
  color: var(--blue-200);
}

.cancel-btn {
  margin-top: 1.5rem;
  width: 100%;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9375rem;
  font-weight: 500;
  padding: 0.75rem;
  cursor: pointer;
  border-radius: 0.75rem;
  transition:
    color 0.12s,
    background 0.12s;
}

.cancel-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

/* ── Error state ── */
.error-text {
  color: #f9a8a8;
}
