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

/* ─── Theme ──────────────────────────────────────────────────────────── */
:root {
  --bg:       #0d1117;
  --surface:  #161b22;
  --surface2: #1c2128;
  --border:   #21262d;
  --border2:  #30363d;
  --accent:   #58a6ff;
  --green:    #3fb950;
  --amber:    #e3b341;
  --red:      #f85149;
  --text:     #c9d1d9;
  --muted:    #8b949e;
}

/* ─── Base ───────────────────────────────────────────────────────────── */
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica,
               Arial, sans-serif;
  min-height: 100vh;
}

/* ─── Header ─────────────────────────────────────────────────────────── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.25rem;
}
.header h1 {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.header-icon {
  width: 22px; height: 22px;
  fill: none; stroke: var(--accent);
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}
.live-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--green);
  background: rgba(63, 185, 80, 0.1);
  border: 1px solid rgba(63, 185, 80, 0.3);
  border-radius: 20px;
  padding: 3px 10px;
  flex-shrink: 0;
}
.live-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: blink 2s ease-in-out infinite;
}
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:0.3} }
.live-badge.offline {
  color: var(--red);
  background: rgba(248, 81, 73, 0.1);
  border-color: rgba(248, 81, 73, 0.3);
}
.live-badge.offline .live-dot {
  background: var(--red);
  animation: none;
}

/* ─── Cards ──────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
}
.card-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1.1rem;
}

/* ─── Wind Speed display ─────────────────────────────────────────────── */
.speed-display {
  display: flex;
  align-items: flex-end;
  gap: 0.4rem;
  margin-bottom: 0.35rem;
}
.speed-value {
  font-size: 5rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  text-shadow: 0 0 40px rgba(88, 166, 255, 0.25);
}
.speed-unit {
  font-size: 1.3rem;
  font-weight: 400;
  color: var(--muted);
  padding-bottom: 0.65rem;
}
.speed-sub { font-size: 0.9rem; color: var(--muted); }
.speed-sub strong { color: var(--text); font-weight: 500; }

/* ─── Compass ────────────────────────────────────────────────────────── */
.compass-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
}
#compass-svg {
  width: 100%;
  max-width: 195px;
  height: auto;
  aspect-ratio: 1;
}
.compass-info { text-align: center; line-height: 1.4; }
.compass-deg {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.04em;
}
.compass-dir { font-size: 0.85rem; color: var(--muted); }

/* ─── Chart cards ────────────────────────────────────────────────────── */
.chart-wrap { margin-bottom: 1rem; }
.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}
.chart-header .card-label { margin-bottom: 0; }
.chart-canvas-wrap { position: relative; height: 220px; }

/* ─── Range toggle ───────────────────────────────────────────────────── */
.range-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
}
.range-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.5;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.13s ease, color 0.13s ease;
}
.range-btn:hover  { color: var(--text); }
.range-btn.active { background: var(--accent); color: #0d1117; }

/* ─── Footer ─────────────────────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  margin-top: 0.25rem;
  padding-top: 0.6rem;
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
}
footer #last-updated { color: var(--text); }

/* Countdown progress bar (sits at top of footer) */
.refresh-bar-track {
  width: 100%;
  height: 2px;
  background: var(--border);
  border-radius: 1px;
  overflow: hidden;
  margin-bottom: 0.6rem;
}
.refresh-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 1px;
  width: 100%;
  transition: width 0s linear;
}

/* ─── Fetch indicator ───────────────────────────────────────────────── */
.fetch-spinner {
  display: inline-block;
  width: 10px; height: 10px;
  border: 1.5px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  vertical-align: middle;
  margin-left: 0.5em;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
}
.fetch-spinner.active {
  opacity: 1;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Chart controls wrapper ─────────────────────────────────────────── */
.chart-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* ─── View toggle ────────────────────────────────────────────────────── */
.view-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
}
.view-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.5;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.13s ease, color 0.13s ease;
}
.view-btn:hover  { color: var(--text); }
.view-btn.active { background: var(--accent); color: #0d1117; }

/* ─── History table ──────────────────────────────────────────────────── */
.table-scroll {
  overflow-x: auto;
  max-height: 440px;
  overflow-y: auto;
  border-radius: 6px;
  border: 1px solid var(--border2);
}
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.history-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface2);
  padding: 0.5rem 0.9rem;
  text-align: left;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 2px solid var(--border2);
  border-right: 1px solid var(--border2);
  white-space: nowrap;
}
.history-table th:last-child { border-right: none; }
.history-table td {
  padding: 0.45rem 0.9rem;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.history-table td:last-child { border-right: none; }
.history-table tr:last-child td { border-bottom: none; }
.history-table tbody tr:nth-child(even) td { background: var(--surface2); }
.history-table tbody tr:hover td { background: rgba(88, 166, 255, 0.07); }

/* ─── Responsive (shared breakpoints) ───────────────────────────────── */
@media (max-width: 600px) {
  .speed-value       { font-size: 4rem; }
  .chart-canvas-wrap { height: 175px; }
}
