/* North Carolina flag palette */
:root {
  --flag-red: #a92633;
  --flag-gold: #efc643;
  --flag-navy: #0c2661;
  --flag-white: #f7f7f7;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: #222;
}

body {
  display: flex;
}

#sidebar {
  width: 320px;
  flex: 0 0 320px;
  height: 100%;
  overflow-y: auto;
  padding: 16px;
  background: #f7f8fa;
  border-right: 1px solid #ddd;
}

/* NC flag stripe across the top of the sidebar: blue, red, white, gold */
#sidebar::before {
  content: '';
  display: block;
  height: 6px;
  margin: -16px -16px 14px;
  border-bottom: 1px solid #ddd;
  background: linear-gradient(
    to right,
    var(--flag-navy) 0 35%,
    var(--flag-red) 35% 62%,
    var(--flag-white) 62% 82%,
    var(--flag-gold) 82% 100%
  );
}

#map {
  flex: 1;
  height: 100%;
}

h1 {
  font-size: 20px;
  margin: 0 0 4px;
  color: var(--flag-navy);
}

.subtitle {
  margin: 0 0 16px;
  color: #666;
  font-size: 12.5px;
}

.panel {
  background: #fff;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 14px;
}

.panel h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--flag-navy);
  margin: 0 0 8px;
  padding-bottom: 5px;
  border-bottom: 2px solid var(--flag-gold);
}

.chart-title {
  font-size: 12px;
  color: #555;
  margin: 12px 0 4px;
  font-weight: 600;
}

.chart-wrap {
  position: relative;
  height: 150px;
  margin-top: 8px;
}

.loading { color: #888; font-style: italic; }
.error { color: #b00020; }

#weather-summary .big {
  font-size: 22px;
  font-weight: 700;
}

#hydrology-note {
  margin-top: 8px;
  font-size: 12.5px;
  color: #444;
  line-height: 1.4;
}

#search-form {
  display: flex;
  gap: 6px;
}

#address-input {
  flex: 1;
  padding: 7px 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 13px;
}

#search-btn {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: var(--flag-navy);
  color: #fff;
  cursor: pointer;
}

#search-btn:hover { background: var(--flag-red); }

/* Drought severity banner (US Drought Monitor) */
#drought-banner {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 6px 0 14px;
}

.drought-chip {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 10px;
  white-space: nowrap;
}

/* "Use my location" icon button */
#locate-btn {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  padding: 0;
  border: 1px solid var(--flag-navy);
  border-radius: 4px;
  background: #fff;
  color: var(--flag-navy);
  cursor: pointer;
}

#locate-btn:hover { background: #eef2f8; }

/* Watering-day calculator + depth readout lines */
.watering-day {
  background: #f4f7eb;
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 12.5px;
  margin: 6px 0;
}

.depth-line { font-size: 12px; margin: 6px 0 0; }

/* Restrictions reference panel */
.panel-hint {
  font-size: 11.5px;
  color: #888;
  margin: 0 0 8px;
}

.restriction-entry {
  border-bottom: 1px solid #eee;
  padding: 4px 0;
}

.restriction-entry:last-child { border-bottom: none; }

.restriction-entry summary {
  cursor: pointer;
  font-size: 13px;
  padding: 3px 0;
}

.restriction-body { padding: 4px 0 6px 4px; font-size: 12.5px; }
.restriction-body .authority { margin: 4px 0; color: #444; }
.restriction-body ul, .rec-rules { margin: 4px 0; padding-left: 18px; }
.restriction-body li, .rec-rules li { margin-bottom: 3px; line-height: 1.35; }
.note-text { color: #666; font-size: 12px; margin: 4px 0; }
.links { margin: 6px 0 0; font-size: 12px; }
.links a { color: var(--flag-navy); }

.badge {
  display: inline-block;
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 9px;
  vertical-align: 1px;
}

/* Map popup with full restriction rules */
.restriction-popup { font-size: 12.5px; line-height: 1.4; }
.restriction-popup ul { margin: 6px 0; padding-left: 18px; }
.restriction-popup li { margin-bottom: 3px; }
.restriction-popup a { color: var(--flag-navy); }

/* Recommendation card */
#recommendation { margin-top: 10px; }

.rec-card {
  background: #f0f5fb;
  border-radius: 4px;
  padding: 10px;
  font-size: 13px;
  line-height: 1.45;
}

.rec-card.restricted { background: #fbf2df; }
.rec-card h3 { margin: 0 0 6px; font-size: 13.5px; color: var(--flag-navy); }
.rec-card .warn { color: var(--flag-red); margin-top: 6px; }
.rec-card .note { color: #33691e; margin-top: 6px; }

footer {
  font-size: 11.5px;
  color: #777;
  margin-top: 8px;
  line-height: 1.6;
}

footer h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--flag-navy);
  margin: 0 0 4px;
}

footer ul {
  margin: 0;
  padding-left: 16px;
}

footer a { color: var(--flag-navy); text-decoration: none; }
footer a:hover { text-decoration: underline; }

/* Map legend (bottom-right) */
.legend {
  background: rgba(255, 255, 255, 0.92);
  padding: 8px 10px;
  border-radius: 5px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  font-size: 12px;
  line-height: 1.3;
}

.legend h4 { margin: 0 0 5px; font-size: 12px; }

.legend .gradient-bar {
  width: 160px;
  height: 12px;
  border-radius: 2px;
  background: linear-gradient(to right, #08519c, #4292c6, #9ecae1, #fee08b, #d8b365, #8c510a);
  margin-bottom: 3px;
}

.legend .gradient-labels {
  display: flex;
  justify-content: space-between;
  color: #555;
  font-size: 11px;
}

/* ---------------------------------------------------------------------------
   Mobile layout: map on top, sidebar scrolls beneath it
   --------------------------------------------------------------------------- */
@media (max-width: 768px) {
  html, body {
    height: auto;
    min-height: 100%;
  }

  body {
    flex-direction: column;
  }

  #map {
    order: -1;                 /* map first, sidebar below */
    flex: none;
    width: 100%;
    height: 55vh;
    height: 55dvh;
  }

  #sidebar {
    width: 100%;
    flex: 1 0 auto;
    height: auto;
    overflow-y: visible;
    border-right: none;
    border-top: 1px solid #ddd;
  }

  h1 { font-size: 18px; }

  #address-input, #search-btn, #locate-btn {
    font-size: 16px;           /* prevents iOS zoom-on-focus */
  }

  .legend .gradient-bar { width: 120px; }
}
