/* Dakota Weather Archive — Prairie-inspired, polished */

:root {
  --color-bg: #f5f3ef;
  --color-surface: #ffffff;
  --color-text: #1c1917;
  --color-text-muted: #57534e;
  --color-border: #e7e5e4;
  --color-accent: #0c4a6e;
  --color-accent-hover: #075985;
  --color-accent-muted: #0e7490;
  --color-chart-line: #0c4a6e;
  --color-chart-fill: rgba(12, 74, 110, 0.08);
  --color-header-bg: linear-gradient(180deg, #0c4a6e 0%, #0e7490 100%);
  --font-sans: "DM Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "Consolas", "Monaco", monospace;
  --shadow-sm: 0 1px 3px rgba(28, 25, 23, 0.06);
  --shadow-md: 0 4px 12px rgba(28, 25, 23, 0.08);
  --shadow-lg: 0 8px 24px rgba(28, 25, 23, 0.1);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* Header */
.site-header {
  background: var(--color-header-bg);
  padding: 2rem 0;
  color: #fff;
}

.site-title {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.site-tagline {
  margin: 0.35rem 0 0;
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.85);
}

/* Intro */
.intro {
  padding: 1.75rem 0;
}

.intro-text {
  margin: 0;
  max-width: 50ch;
  font-size: 1.05rem;
  color: var(--color-text-muted);
}

.data-notes {
  margin-top: 1.25rem;
  padding: 0.75rem 1rem;
  background: rgba(12, 74, 110, 0.04);
  border: 1px solid rgba(12, 74, 110, 0.12);
  border-radius: var(--radius-sm);
}

.data-notes summary {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-accent);
  cursor: pointer;
  list-style: none;
}

.data-notes summary::-webkit-details-marker {
  display: none;
}

.data-notes summary::before {
  content: "▶";
  display: inline-block;
  margin-right: 0.4rem;
  font-size: 0.65rem;
  transition: transform 0.2s;
}

.data-notes[open] summary::before {
  transform: rotate(90deg);
}

.data-notes-content {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(12, 74, 110, 0.1);
}

.data-notes-content p {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

.data-notes-content p:last-child {
  margin-bottom: 0;
}

/* Station selector */
.station-selector {
  padding: 1rem 0;
}

.selector-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: flex-end;
}

.selector-group {
  flex: 0 0 auto;
  min-width: 0;
}

@media (max-width: 600px) {
  .selector-row {
    flex-direction: column;
    gap: 1rem;
  }

  .selector-group {
    flex: 1 1 100%;
    width: 100%;
  }

  #station-search,
  #station-search-2 {
    min-width: 0;
    width: 100%;
  }
}

.selector-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.compare-group label {
  display: inline;
  margin-right: 0.5rem;
}

#station-search,
#station-search-2 {
  font-size: 1rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  min-width: 260px;
  max-width: 100%;
  box-sizing: border-box;
  transition: border-color 0.15s, box-shadow 0.15s;
}

#station-search:focus,
#station-search-2:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(12, 74, 110, 0.15);
}

#station-search-2:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  margin-top: 2px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  max-height: 240px;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
}

.search-results:empty {
  display: none;
}

.search-results .result-item {
  padding: 0.5rem 0.75rem;
  cursor: pointer;
  font-size: 0.95rem;
}

.search-results .result-item:hover {
  background: var(--color-bg);
}

.selector-group {
  position: relative;
}

.selector-actions {
  margin-top: 1rem;
}

.btn {
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn:hover {
  background: var(--color-bg);
}

.btn-secondary {
  color: var(--color-accent);
  border-color: var(--color-accent);
}

.btn-secondary:hover {
  background: rgba(12, 74, 110, 0.06);
  border-color: var(--color-accent-hover);
}

/* Map */
.map-section {
  padding: 1rem 0;
}

.map-container {
  position: relative;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

#map {
  height: 360px;
  width: 100%;
}

.map-hint {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  background: rgba(255, 255, 255, 0.95);
  padding: 0.3rem 0.6rem;
  border-radius: var(--radius-sm);
  pointer-events: none;
  box-shadow: var(--shadow-sm);
}

/* Dashboard modules */
.dashboard {
  padding: 1rem 0 3rem;
}

/* Summary card */
.summary-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.summary-title {
  margin: 0 0 1rem;
  font-size: 1.25rem;
  font-weight: 600;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
}

.summary-stat {
  padding: 0.75rem;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  text-align: center;
}

.summary-stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  margin-bottom: 0.25rem;
}

.summary-stat-value {
  font-size: 1.25rem;
  font-weight: 600;
}

/* Module toolbar */
.module-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.view-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.view-btn {
  padding: 0.35rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  background: var(--color-surface);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.view-btn:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.view-btn.active {
  background: var(--color-accent);
  color: #fff;
}

/* Data tables */
.data-table-wrapper {
  overflow-x: auto;
  max-height: 320px;
  overflow-y: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.data-table th {
  background: var(--color-bg);
  font-weight: 600;
  position: sticky;
  top: 0;
}

.data-table tbody tr:hover {
  background: var(--color-bg);
}

.data-table-wrapper::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.data-table-wrapper::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}

/* Wettest years */
.precip-extras {
  margin-bottom: 1rem;
}

.wettest-table {
  display: inline-block;
  padding: 0.75rem 1rem;
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

.wettest-table h3 {
  margin: 0 0 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.wettest-table ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

.wettest-table li {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
}

.module {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.module h2 {
  margin: 0 0 0.25rem;
  font-size: 1.25rem;
  font-weight: 600;
}

.module-desc {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.module-empty {
  padding: 1.5rem;
  text-align: center;
  font-size: 0.95rem;
  color: var(--color-text-muted);
  background: var(--color-bg);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--color-border);
}

.module-empty[hidden] {
  display: none !important;
}

.chart-container {
  position: relative;
  height: 280px;
  margin-bottom: 0.75rem;
}

.chart-controls {
  font-size: 0.875rem;
}

.chart-controls label {
  margin-right: 1rem;
  cursor: pointer;
}

.chart-controls input {
  margin-right: 0.35rem;
}

/* Footer */
.site-footer {
  padding: 1.5rem 0 2rem;
  margin-top: 0.5rem;
  border-top: 1px solid var(--color-border);
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.site-footer a {
  color: var(--color-accent);
  text-decoration: none;
}

.site-footer a:hover {
  text-decoration: underline;
  color: var(--color-accent-hover);
}

.footer-note {
  margin-top: 0.75rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  opacity: 0.9;
}

/* Loading / empty states */
.dashboard.loading .module {
  opacity: 0.6;
  pointer-events: none;
}

.no-data {
  color: var(--color-text-muted);
  font-style: italic;
  padding: 2rem;
  text-align: center;
}

/* Compare mode */

/* Cluster pin icons */
.cluster-pin-wrapper {
  background: none !important;
  border: none !important;
}

.cluster-pin {
  position: relative;
  width: 32px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-accent);
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.25));
}

.cluster-pin-svg {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
}

.cluster-pin-small .cluster-pin-svg { color: #0e7490; }
.cluster-pin-medium .cluster-pin-svg { color: #0c4a6e; }
.cluster-pin-large .cluster-pin-svg { color: #075985; }

.cluster-count {
  position: relative;
  z-index: 1;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  line-height: 1;
  margin-top: -4px;
}

/* Leaflet overrides */
.leaflet-popup-content {
  margin: 0.5rem 0.75rem;
  font-size: 0.9rem;
}

.leaflet-popup-content strong {
  display: block;
  margin-bottom: 0.25rem;
}
