/* Weather Locator — main stylesheet */

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

/* ─── Design tokens ──────────────────────────────────────────────────────── */
:root {
  --primary:       #0d5c5c;
  --primary-light: #1a7a7a;
  --primary-dark:  #083d3d;
  --accent:        #f0a500;
  --accent-dark:   #c98800;
  --bg:            #f0f4f0;
  --surface:       #ffffff;
  --border:        #cdd8cd;
  --text:          #1a1a1a;
  --text-muted:    #4a5e4a;
  --error:         #c0392b;
  --error-bg:      #fdecea;
  --warn:          #8a6200;
  --warn-bg:       #fff8e1;
  --radius:        8px;
}

/* ─── Base ───────────────────────────────────────────────────────────────── */
html, body { height: 100%; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
}

a { color: var(--primary); }
a:hover { color: var(--primary-dark); }

/* ─── Skip link ──────────────────────────────────────────────────────────── */
.skip-link {
  position: absolute; top: -100%; left: 0;
  padding: 0.5rem 1rem;
  background: #1a1a1a; color: #fff;
  z-index: 9999; text-decoration: none; font-weight: bold;
}
.skip-link:focus { top: 0; }

/* ─── Focus ──────────────────────────────────────────────────────────────── */
:focus-visible { outline: 3px solid #005fcc; outline-offset: 2px; }

/* ─── Header ─────────────────────────────────────────────────────────────── */
header {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-light) 100%);
  color: #fff;
  padding: 1.25rem 1.25rem 1rem;
  flex-shrink: 0;
}

header h1 {
  font-size: clamp(1.5rem, 5vw, 2rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

header h1::before { content: '🧭'; font-size: 1.4em; }

.tagline {
  font-size: clamp(0.9rem, 2.5vw, 1rem);
  margin-top: 0.4rem;
  opacity: 0.9;
  font-weight: 500;
  line-height: 1.4;
}

.sub-copy {
  font-size: 0.8125rem;
  margin-top: 0.25rem;
  opacity: 0.7;
}

/* ─── Layout ─────────────────────────────────────────────────────────────── */
#main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

#search-panel {
  background: var(--surface);
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  overflow-y: auto;
  flex-shrink: 0;
}

#map-section {
  flex: 1;
  min-height: 55dvh;
  display: flex;
  flex-direction: column;
}

#results-map {
  flex: 1;
  width: 100%;
  min-height: 300px;
}

@media (min-width: 768px) {
  #main-content {
    flex-direction: row;
    flex: 1;
    min-height: 0;
  }

  #search-panel {
    width: 360px;
    min-width: 280px;
    border-bottom: none;
    border-right: 1px solid var(--border);
    flex-shrink: 0;
    height: 100%;
  }

  #map-section {
    flex: 1;
    min-height: 0;
    min-width: 0;
    height: 100%;
  }

  #results-map {
    min-height: 0;
  }
}

/* ─── Empty state ────────────────────────────────────────────────────────── */
#results-map {
  position: relative;
}

#empty-state {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 1rem;
  background: rgba(240,244,240,.88);
  pointer-events: none;
  z-index: 10;
}

#empty-state:not([hidden]) { display: flex; }

/* ─── Footer ─────────────────────────────────────────────────────────────── */
#page-footer {
  background: var(--bg);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.attribution {
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  text-align: center;
  line-height: 1.6;
}

.attribution a { color: var(--primary); }

/* ─── Status bar ─────────────────────────────────────────────────────────── */
.status-bar {
  font-size: 0.8125rem;
  padding: 0.35rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  background: var(--bg);
}

.status-bar__timestamp { color: var(--text-muted); }

.status-bar__error {
  width: 100%;
  background: var(--error-bg);
  color: var(--error);
  border-left: 3px solid var(--error);
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.status-bar__stale {
  width: 100%;
  background: var(--warn-bg);
  color: var(--warn);
  border-left: 3px solid var(--accent);
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.status-bar__loading {
  color: var(--primary);
  font-style: italic;
  align-items: center;
  gap: 0.4rem;
}

.status-bar__loading:not([hidden]) { display: flex; }

.status-bar__loading::before {
  content: '';
  display: inline-block;
  width: 0.75rem; height: 0.75rem;
  border: 2px solid var(--primary);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}

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

/* ─── Fieldsets ──────────────────────────────────────────────────────────── */
fieldset {
  border: none;
  padding: 0;
  margin: 0;
  min-width: 0;
}

/* ─── Section headers — visually hidden, kept for screen readers ─────────── */
legend {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ─── Condition groups ───────────────────────────────────────────────────── */
.condition-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.condition-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ─── Checkboxes ─────────────────────────────────────────────────────────── */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.2rem;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  font-size: 0.8125rem;
  cursor: pointer;
  user-select: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.25rem 0.65rem;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.checkbox-label:has(input:checked) {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.checkbox-label input[type="checkbox"] { display: none; }

/* ─── Inputs & selects ───────────────────────────────────────────────────── */
input[type="number"],
select {
  width: 100%;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.12s, box-shadow 0.12s;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%234a5e4a' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.65rem center;
  padding-right: 2rem;
}

input[type="number"]:focus,
select:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(13,92,92,.15);
}

/* ─── Date range ─────────────────────────────────────────────────────────── */
.date-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.date-group label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.date-range-error {
  color: var(--error);
  font-size: 0.8rem;
  margin-top: 0.3rem;
}

/* ─── Search button ──────────────────────────────────────────────────────── */
#search-btn {
  width: 100%;
  padding: 0.75rem 1.25rem;
  background: var(--accent);
  color: #1a1a1a;
  font-size: 1rem;
  font-weight: 700;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  box-shadow: 0 2px 6px rgba(240,165,0,.35);
  letter-spacing: 0.02em;
}

#search-btn:hover:not(:disabled) {
  background: var(--accent-dark);
  box-shadow: 0 4px 12px rgba(240,165,0,.4);
}

#search-btn:active:not(:disabled) { transform: scale(0.98); }

#search-btn:disabled {
  background: #d0d8d0;
  color: #7a8a7a;
  cursor: not-allowed;
  box-shadow: none;
}

/* ─── Search prompt ──────────────────────────────────────────────────────── */
#search-prompt {
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: center;
  min-height: 1.2rem;
}

/* ─── More filters toggle ────────────────────────────────────────────────── */
.more-filters-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-top: 0.875rem;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, border-color 0.12s;
}

.more-filters-toggle:hover {
  background: var(--border);
  border-color: var(--primary);
}

.more-filters-toggle[aria-expanded="true"] {
  border-color: var(--primary);
  color: var(--primary);
}

.more-filters-arrow {
  color: var(--text-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}

.more-filters-toggle[aria-expanded="true"] .more-filters-arrow {
  transform: rotate(180deg);
  color: var(--primary);
}

.extra-filters:not([hidden]) { display: block; }

/* ─── Forecast badge popup ───────────────────────────────────────────────── */
.forecast-badge {
  max-width: 280px;
  font-size: 0.8rem;
  line-height: 1.4;
}

.forecast-badge__name {
  display: block;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.5rem;
}

.forecast-badge__table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
}

.forecast-badge__table th,
.forecast-badge__table td {
  padding: 0.2rem 0.3rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.forecast-badge__table th {
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.forecast-badge__table tr:last-child td { border-bottom: none; }
