@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url(/fonts/inter-latin.woff2) format("woff2");
}

:root {
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;

  --bg-from: var(--slate-50);
  --bg-to: var(--slate-100);
  --surface: #fff;
  --surface-hover: var(--slate-50);
  --surface-solid: #fff;
  --border: var(--slate-200);
  --border-hover: var(--slate-300);
  --divider: var(--slate-100);
  --text: var(--slate-900);
  --text-2: var(--slate-700);
  --muted: var(--slate-500);
  --faint: var(--slate-400);
  --header-bg: rgb(255 255 255 / 0.9);
  --positive: #059669;
  --negative: #ea580c;
  --tone-mix: white;
  --tone-bg: 8%;
  --tone-border: 30%;
  --tone-badge: 18%;
  --tone-text: color-mix(in srgb, var(--tone) 70%, black);

  color-scheme: light;
}

:root.dark {
  --bg-from: var(--slate-900);
  --bg-to: var(--slate-800);
  --surface: rgb(30 41 59 / 0.6);
  --surface-hover: rgb(30 41 59 / 0.8);
  --surface-solid: var(--slate-800);
  --border: rgb(51 65 85 / 0.5);
  --border-hover: var(--slate-600);
  --divider: var(--slate-700);
  --text: var(--slate-100);
  --text-2: var(--slate-300);
  --muted: var(--slate-400);
  --faint: var(--slate-500);
  --header-bg: rgb(15 23 42 / 0.9);
  --positive: #34d399;
  --negative: #fb923c;
  --tone-mix: transparent;
  --tone-bg: 15%;
  --tone-border: 35%;
  --tone-badge: 30%;
  --tone-text: color-mix(in srgb, var(--tone) 50%, white);

  color-scheme: dark;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, sans-serif;
  font-feature-settings: "rlig" 1, "calt" 1;
  line-height: 1.5;
  color: var(--text);
  background: linear-gradient(to bottom right, var(--bg-from), var(--bg-to)) fixed;
  -webkit-font-smoothing: antialiased;
}

html {
  scroll-behavior: smooth;
}

h1, h2, h3, p, dl, dd {
  margin: 0;
}

button {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
}

.icon {
  width: 0.875rem;
  height: 0.875rem;
  flex-shrink: 0;
}

.icon-sm {
  width: 0.75rem;
  height: 0.75rem;
}

.muted {
  color: var(--faint);
  font-weight: 400;
  font-size: 0.75rem;
}

.faint {
  color: var(--faint);
  font-weight: 400;
  font-size: 0.75rem;
  margin-left: 0.25rem;
}

.text-positive {
  color: var(--positive);
}

.text-negative {
  color: var(--negative);
}

/* Layout */

.container {
  width: 100%;
  margin-inline: auto;
  padding-inline: 1rem;
}

@media (min-width: 640px) { .container { max-width: 640px; } }
@media (min-width: 768px) { .container { max-width: 768px; } }
@media (min-width: 1024px) { .container { max-width: 1024px; } }
@media (min-width: 1280px) { .container { max-width: 1280px; } }
@media (min-width: 1536px) { .container { max-width: 1536px; } }

main.container {
  padding-block: 1.25rem;
}

.status {
  display: grid;
  place-items: center;
  gap: 0.75rem;
  min-height: 200px;
  align-content: center;
  font-size: 0.875rem;
  color: var(--faint);
}

.status .error {
  color: #ef4444;
}

.primary-button {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
  color: #fff;
  background: #3b82f6;
  border: 0;
  border-radius: 0.25rem;
  cursor: pointer;
}

.primary-button:hover {
  background: #2563eb;
}

/* Header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-block: 0.625rem;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.header-brand h1 {
  font-size: 1rem;
  font-weight: 600;
  white-space: nowrap;
}

.header-subtitle {
  font-size: 0.75rem;
  color: var(--faint);
}

.header-status {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--positive);
}

.header-status .icon {
  width: 0.75rem;
  height: 0.75rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  height: 1.75rem;
  padding-inline: 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  background: none;
  border: 0;
  border-radius: 0.375rem;
  cursor: pointer;
}

.ghost-button:hover {
  background: var(--slate-100);
}

.dark .ghost-button:hover {
  background: var(--slate-800);
}

.icon-button {
  width: 1.75rem;
  padding: 0;
  justify-content: center;
}

@media (max-width: 639px) {
  .header-subtitle,
  .header-status span,
  .lang-name {
    display: none;
  }
}

.menu {
  position: fixed;
  inset: auto;
  margin: 0;
  min-width: 8rem;
  padding: 0.25rem;
  background: var(--surface-solid);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

.menu button {
  display: block;
  width: 100%;
  padding: 0.375rem 0.5rem;
  font-size: 0.875rem;
  text-align: left;
  background: none;
  border: 0;
  border-radius: 0.25rem;
  cursor: pointer;
}

.menu button:hover,
.menu button[aria-current] {
  background: var(--slate-100);
}

.dark .menu button:hover,
.dark .menu button[aria-current] {
  background: var(--slate-700);
}

/* Footer */

.site-footer {
  margin-top: 2rem;
  min-height: 52px;
  border-top: 1px solid var(--border);
}

.site-footer p {
  padding-block: 1rem;
  text-align: center;
  font-size: 0.75rem;
  color: var(--faint);
}

/* Grid */

weather-grid {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.section-header::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
}

@media (min-width: 640px) { .card-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .card-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .card-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); } }

@keyframes fade-in {
  from { opacity: 0; }
}

.card {
  display: block;
  padding: 0.625rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  animation: fade-in 200ms ease-out both;
}

.card.clickable {
  cursor: pointer;
}

.card.clickable:hover {
  background: var(--surface-hover);
  border-color: var(--border-hover);
}

.card:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  min-width: 0;
  font-size: 0.75rem;
  color: var(--muted);
}

.card-title span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.trend {
  width: 0.75rem;
  height: 0.75rem;
}

.trend-flat { color: var(--slate-300); }
.dark .trend-flat { color: var(--slate-600); }
.trend-up { color: #10b981; }
.trend-down { color: #f87171; }

.card-value {
  display: flex;
  align-items: baseline;
  gap: 0.25rem;
  margin-top: 0.125rem;
}

.card-value .value {
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.25;
}

.dark .card-value .value {
  color: #fff;
}

.card-unit {
  font-size: 0.75rem;
  color: var(--faint);
}

.card-stats {
  margin-top: 0.125rem;
  font-size: 0.75rem;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.card-stats .card-unit {
  margin-left: 0.125rem;
}

/* Power system card */

power-system-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.power-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.power-badge {
  display: inline-flex;
  padding: 0.5rem;
  color: #10b981;
  background: color-mix(in srgb, #10b981 10%, transparent);
  border-radius: 0.5rem;
}

.power-badge .icon {
  width: 1.25rem;
  height: 1.25rem;
}

.power-title {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
}

.power-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.power-section + .power-section,
.power-updated {
  padding-top: 0.5rem;
  border-top: 1px solid var(--divider);
}

.power-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.power-label {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-2);
}

.power-level {
  font-size: 1rem;
  font-weight: 600;
}

.meter {
  height: 0.375rem;
  overflow: hidden;
  background: var(--slate-200);
  border-radius: 999px;
}

.dark .meter {
  background: var(--slate-700);
}

.meter div {
  height: 100%;
  border-radius: 999px;
  transition: width 500ms;
}

.power-stats {
  display: grid;
  gap: 0.125rem;
  font-size: 0.75rem;
}

.power-stats div {
  display: flex;
  justify-content: space-between;
}

.power-stats dt {
  color: var(--muted);
}

.power-stats dd {
  font-weight: 500;
  color: var(--text-2);
}

.pill {
  padding: 0.125rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--muted);
  background: var(--slate-100);
  border-radius: 999px;
}

.dark .pill {
  background: var(--slate-700);
}

.pill-active {
  --tone: #10b981;
  color: var(--tone-text);
  background: color-mix(in srgb, var(--tone) var(--tone-badge), var(--tone-mix));
}

.power-updated {
  font-size: 0.75rem;
  color: var(--muted);
}

/* Nowcast */

nowcast-card {
  --tone: var(--slate-500);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  background: color-mix(in srgb, var(--tone) var(--tone-bg), var(--tone-mix));
  border: 1px solid color-mix(in srgb, var(--tone) var(--tone-border), var(--tone-mix));
  border-radius: 0.375rem;
}

.nowcast-icon {
  width: 1.25rem;
  height: 1.25rem;
  margin-top: 0.125rem;
  color: var(--tone);
}

.nowcast-body {
  flex: 1;
  min-width: 0;
}

.nowcast-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.eyebrow {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--faint);
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.nowcast-message {
  font-size: 0.875rem;
  font-weight: 600;
}

.nowcast-horizon {
  margin-left: auto;
  padding: 0.125rem 0.375rem;
  font-size: 0.75rem;
  color: var(--tone-text);
  background: color-mix(in srgb, var(--tone) var(--tone-badge), var(--tone-mix));
  border-radius: 0.25rem;
}

.nowcast-detail {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--text-2);
}

.nowcast-factors {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--faint);
}

/* Warnings */

weather-warnings {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

weather-warnings:empty {
  display: none;
}

.warning {
  padding: 0.25rem 0 0.25rem 0.625rem;
  border-left: 2px solid var(--level);
  border-radius: 0 0.125rem 0.125rem 0;
}

.warning:hover {
  background: var(--surface-hover);
}

.warning summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  cursor: pointer;
  list-style: none;
}

.warning summary::-webkit-details-marker {
  display: none;
}

.warning summary .icon {
  color: var(--faint);
}

.warning-title {
  font-weight: 500;
  color: var(--text-2);
}

.warning-level {
  color: var(--faint);
}

.warning p {
  margin-top: 0.25rem;
  padding-left: 1.25rem;
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--muted);
}

/* History dialog */

.history-dialog {
  width: calc(100% - 2rem);
  max-width: 36rem;
  padding: 1.5rem;
  color: var(--text);
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

.dark .history-dialog {
  background: var(--slate-900);
}

.history-dialog::backdrop {
  background: rgb(0 0 0 / 0.6);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.dialog-title {
  font-size: 0.875rem;
  font-weight: 600;
}

.chart {
  position: relative;
  height: 13rem;
  margin-top: 0.5rem;
}

.chart svg {
  display: block;
  overflow: visible;
}

.chart .axis text {
  font-size: 10px;
  fill: var(--slate-400);
}

.chart .grid-lines line {
  stroke: var(--border);
}

.chart-message {
  display: grid;
  place-items: center;
  height: 100%;
  font-size: 0.875rem;
  color: var(--faint);
}

.chart-message.error {
  color: #f87171;
}

.chart-tooltip {
  position: absolute;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  white-space: nowrap;
  pointer-events: none;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.1);
}

.dialog-explanation {
  margin-top: 1rem;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--text-2);
}

/* Scrollbar */

::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--slate-100);
}

::-webkit-scrollbar-thumb {
  background: var(--slate-300);
  border-radius: 999px;
}

.dark ::-webkit-scrollbar-track {
  background: var(--slate-800);
}

.dark ::-webkit-scrollbar-thumb {
  background: var(--slate-600);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card { animation: none; }
}
