/* UW–Madison brand tokens + layout for the static dashboard.
   Mirrors the design tokens in features/theme.py so the static site
   stays visually consistent with the Streamlit app. */

:root {
  --uw-red:       #C5050C;   /* Badger Red */
  --uw-anchor:    #9B0000;
  --ink:          #111827;
  --ink-muted:    #6B7280;
  --surface:      #FFFFFF;
  --surface-alt:  #F4F4F5;
  --border:       rgba(17, 24, 39, 0.12);
  --border-strong:rgba(17, 24, 39, 0.25);
  --radius:       8px;
  --shadow-sm:    0 1px 2px rgba(0, 0, 0, 0.04), 0 1px 3px rgba(0, 0, 0, 0.06);
  --font-stack:   Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-stack);
  color: var(--ink);
  background: var(--surface-alt);
  line-height: 1.45;
}

/* -------------------- Header -------------------- */

.site-header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 18px 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand-logo {
  height: 72px;
  width: auto;
  display: block;
}

.site-title h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  border-left: 4px solid var(--uw-red);
  padding-left: 12px;
}

.site-subtitle {
  margin: 4px 0 0 16px;
  color: var(--ink-muted);
  font-size: 0.95rem;
}

/* -------------------- Layout -------------------- */

main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 28px 64px;
}

/* -------------------- Controls -------------------- */

.controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.control {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.control select,
.control input[type="date"] {
  padding: 8px 12px;
  font-size: 1rem;
  font-weight: 500;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  min-width: 200px;
  font-family: inherit;
}
.control select { min-width: 260px; }
.control input[type="date"] { min-width: 160px; }
.control select:focus,
.control input[type="date"]:focus {
  outline: 2px solid var(--uw-red);
  outline-offset: 2px;
}
.control small { color: var(--ink-muted); font-weight: 400; }

.error-text   { color: var(--uw-anchor); font-weight: 600; }
.pending-text { color: #b45309; font-weight: 600; }   /* amber */
.success-text { color: #047857; font-weight: 600; }   /* emerald */

.run-btn {
  padding: 10px 20px;
  font-size: 1rem;
  font-weight: 700;
  background: var(--uw-red);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease;
  font-family: inherit;
}
.run-btn:hover  { background: var(--uw-anchor); }
.run-btn:active { transform: translateY(1px); }
.run-btn:focus  { outline: 2px solid var(--ink); outline-offset: 2px; }

.control-actions { justify-content: flex-end; }
.control-actions > span:first-child { display: none; }

.source-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}
.source-badge[data-source="bundled"]      { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.source-badge[data-source="proxy"]        { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.source-badge[data-source="direct"]       { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.source-badge[data-source="proxy-cache"]  { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
.source-badge[data-source="direct-cache"] { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
.source-badge:empty { display: none; }

.control-meta {
  text-align: right;
}
.control-meta > div:first-child {
  font-weight: 700;
  color: var(--ink);
}
.muted { color: var(--ink-muted); font-size: 0.85rem; }

/* -------------------- Metric tiles -------------------- */

.metrics {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.metric-tile {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.metric-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  line-height: 1.2;
}

.metric-value {
  font-size: 2rem;
  font-weight: 800;
  color: var(--ink);
  margin-top: 6px;
  line-height: 1.1;
}

/* -------------------- Map -------------------- */

.map-wrapper { margin-bottom: 16px; }

#map {
  width: 100%;
  height: 640px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  background: var(--surface-alt);
}

.station-marker {
  background: transparent;
  border: none;
}

.leaflet-popup-content-wrapper {
  border-radius: 8px;
}
.leaflet-popup-content {
  font-family: var(--font-stack);
  font-size: 0.9rem;
  margin: 10px 14px;
}
.popup-name { font-weight: 700; }
.popup-meta { color: var(--ink-muted); font-size: 0.82rem; margin: 2px 0 6px; }
.popup-class { font-weight: 700; }

/* -------------------- Model info / table -------------------- */

.model-info {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}
.model-info details { padding: 12px 0; }
.model-info summary {
  cursor: pointer;
  font-weight: 700;
  padding: 6px 0;
}
.model-info summary::marker { color: var(--uw-red); }
.model-info p, .model-info ul {
  margin: 8px 0;
  color: var(--ink);
}
.model-info code {
  background: var(--surface-alt);
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 0.85em;
}

.table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow-sm);
}
.table-wrapper summary {
  cursor: pointer;
  font-weight: 700;
  padding: 4px 0;
}
.table-wrapper summary::marker { color: var(--uw-red); }
.table-scroll {
  overflow-x: auto;
  margin-top: 12px;
}
.table-wrapper table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.table-wrapper th,
.table-wrapper td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table-wrapper th {
  background: var(--surface-alt);
  font-weight: 700;
  position: sticky; top: 0;
}
.table-wrapper tbody tr:hover { background: var(--surface-alt); }

.class-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 0.78rem;
  font-weight: 700;
  color: white;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* -------------------- Weather section -------------------- */

.weather-wrapper {
  margin-top: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow-sm);
}

.weather-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.weather-header h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  border-left: 4px solid var(--uw-red);
  padding-left: 10px;
}

.weather-chart-container {
  position: relative;
  height: 360px;
  width: 100%;
}
.weather-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* -------------------- Footer -------------------- */

.site-footer {
  margin-top: 24px;
  padding: 16px 28px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink-muted);
  font-size: 0.85rem;
}
.site-footer .sep { margin: 0 6px; }

/* -------------------- Responsive -------------------- */

@media (max-width: 900px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .site-header { flex-direction: column; align-items: flex-start; }
  .brand-logo { height: 56px; }
  #map { height: 480px; }
  .control select { min-width: 200px; }
}
