/* === Pleasant Valley Garden — Mobile-First === */
:root {
  --bg: #faf8f0;
  --bg-card: #fff;
  --text: #3e3529;
  --text-muted: #8a7e6b;
  --green-dark: #4a7c3f;
  --green-light: #7cb342;
  --green-pale: #e8f5e9;
  --brown: #8d6e63;
  --brown-light: #d7ccc8;
  --gold: #fdd835;
  --blue: #90caf9;
  --red: #e57373;
  --orange: #ffb74d;
  --soil: #795548;
  --border: #d4cbb8;
  --shadow: rgba(62, 53, 41, 0.08);
  --font-hand: 'Caveat', cursive;
  --font-body: 'Patrick Hand', cursive;
  --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  font-size: 16px;
  line-height: 1.5;
  overflow-x: hidden;
  width: 100%;
}

/* === HEADER === */
header {
  text-align: center;
  padding: 20px 16px 12px;
  background: linear-gradient(180deg, #e8f5e9 0%, var(--bg) 100%);
}

header h1 {
  font-family: var(--font-hand);
  font-size: 2rem;
  font-weight: 700;
  color: var(--green-dark);
  letter-spacing: -0.5px;
}

header .subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* === NAV — horizontal scroll on mobile === */
nav {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 100;
  border-bottom: 2px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

nav::-webkit-scrollbar { display: none; }

.nav-btn {
  font-family: var(--font-hand);
  font-size: 1.1rem;
  padding: 6px 14px;
  border: 2px solid var(--border);
  border-radius: 20px;
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  flex-shrink: 0;
  -webkit-appearance: none;
}

.nav-btn:hover, .nav-btn:active {
  border-color: var(--green-light);
  color: var(--green-dark);
}

.nav-btn.active {
  background: var(--green-dark);
  color: #fff;
  border-color: var(--green-dark);
}

/* === SECTIONS === */
main {
  max-width: 100%;
  margin: 0 auto;
  padding: 12px;
  overflow-x: hidden;
}

.section { display: none; max-width: 100%; overflow-x: hidden; }
.section.active { display: block; }

/* === GARDEN MAP === */
.map-container {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  box-shadow: 0 2px 12px var(--shadow);
  overflow: hidden;
}

.map-container svg {
  width: 100%;
  height: auto;
  display: block;
}

.map-legend {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--text);
  display: inline-block;
}

.bed-detail {
  background: var(--bg-card);
  border: 2px solid var(--green-light);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-top: 12px;
  box-shadow: 0 2px 8px var(--shadow);
  overflow-x: auto;
}

.bed-detail.hidden { display: none; }

.bed-detail h3 {
  font-family: var(--font-hand);
  font-size: 1.3rem;
  color: var(--green-dark);
  margin-bottom: 6px;
}

.bed-detail table {
  font-size: 0.85rem;
  width: 100%;
}

.bed-detail td, .bed-detail th {
  padding: 3px 6px;
}

/* === SVG MAP STYLES === */
.bed {
  cursor: pointer;
  transition: filter 0.2s;
}

.bed:active {
  filter: brightness(1.15);
}

.bed-fill {
  stroke: var(--text);
  stroke-width: 2.5;
  stroke-linejoin: round;
  paint-order: stroke fill;
}

/* === WEATHER === */
.weather-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 16px;
  max-width: 100%;
}

.weather-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 6px;
  text-align: center;
  box-shadow: 0 1px 4px var(--shadow);
  overflow: hidden;
  word-break: break-word;
}

.weather-card .value {
  font-family: var(--font-hand);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--green-dark);
  line-height: 1.1;
}

.weather-card .label {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.weather-card.alert {
  border-color: var(--orange);
  background: #fff8e1;
}

.weather-card.danger {
  border-color: var(--red);
  background: #fce4ec;
}

.gdd-chart-container {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  margin-bottom: 16px;
  box-shadow: 0 1px 4px var(--shadow);
  width: 100%;
  box-sizing: border-box;
}

.gdd-chart-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.gdd-chart-scroll canvas {
  display: block;
}

.weather-table-container {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  overflow-y: auto;
  max-height: 400px;
  box-shadow: 0 1px 4px var(--shadow);
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

#weather-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

#weather-table th {
  background: var(--green-pale);
  color: var(--green-dark);
  font-family: var(--font-hand);
  font-size: 0.95rem;
  padding: 8px 6px;
  text-align: right;
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}

#weather-table th:first-child { text-align: left; }

#weather-table td {
  padding: 5px 6px;
  text-align: right;
  border-bottom: 1px solid #eee;
}

#weather-table td:first-child { text-align: left; }

#weather-table tbody tr:active {
  background: var(--green-pale);
}

#weather-table .precip-heavy {
  background: #e3f2fd;
  font-weight: 600;
}

/* === ALERTS === */
.alert-card {
  background: var(--bg-card);
  border-left: 4px solid var(--green-light);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 4px var(--shadow);
}

.alert-card.alert-warning {
  border-left-color: var(--orange);
  background: #fff8e1;
}

.alert-card.alert-danger {
  border-left-color: var(--red);
  background: #fce4ec;
}

.alert-card.alert-info {
  border-left-color: var(--blue);
  background: #e3f2fd;
}

.alert-card .alert-icon {
  font-size: 1.2rem;
  margin-right: 6px;
}

.alert-card .alert-title {
  font-family: var(--font-hand);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}

.alert-card .alert-body {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.alert-section-title {
  font-family: var(--font-hand);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--green-dark);
  margin: 16px 0 8px;
}

.alert-section-title:first-child {
  margin-top: 0;
}

/* === CROP FILTER === */
.crop-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
}

.crop-btn {
  font-family: var(--font-hand);
  font-size: 1rem;
  padding: 5px 12px;
  border: 2px solid var(--border);
  border-radius: 16px;
  background: var(--bg-card);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  -webkit-appearance: none;
}

.crop-btn.active {
  background: var(--green-dark);
  color: #fff;
  border-color: var(--green-dark);
}

.crop-btn:active {
  border-color: var(--green-light);
}

.crop-entry {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 10px;
  box-shadow: 0 1px 4px var(--shadow);
}

.crop-entry .crop-date {
  font-family: var(--font-hand);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--green-dark);
}

.crop-entry .crop-location {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.crop-entry .crop-activity {
  font-size: 0.9rem;
  margin-top: 4px;
}

.crop-entry .crop-activity strong {
  color: var(--brown);
}

.crop-entry .crop-note {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* === TIMELINE === */
.timeline {
  position: relative;
  padding-left: 28px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--green-light);
  border-radius: 2px;
}

.timeline-entry {
  position: relative;
  margin-bottom: 16px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  box-shadow: 0 1px 4px var(--shadow);
  overflow-x: auto;
}

.timeline-entry::before {
  content: '';
  position: absolute;
  left: -24px;
  top: 16px;
  width: 12px;
  height: 12px;
  background: var(--green-light);
  border: 2px solid var(--bg);
  border-radius: 50%;
}

.timeline-date {
  font-family: var(--font-hand);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--green-dark);
  margin-bottom: 6px;
}

.timeline-entry h4 {
  font-family: var(--font-hand);
  font-size: 1.05rem;
  color: var(--brown);
  margin: 8px 0 4px;
}

.timeline-entry table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  margin-bottom: 6px;
}

.timeline-entry th {
  text-align: left;
  padding: 3px 6px;
  background: var(--green-pale);
  font-family: var(--font-hand);
  font-size: 0.9rem;
  color: var(--green-dark);
}

.timeline-entry td {
  padding: 2px 6px;
  border-bottom: 1px solid #f0ebe0;
  font-size: 0.8rem;
}

.timeline-entry ul {
  list-style: none;
  padding: 0;
}

.timeline-entry li {
  padding: 2px 0;
  padding-left: 16px;
  position: relative;
  font-size: 0.9rem;
}

.timeline-entry li::before {
  content: '🌱';
  position: absolute;
  left: 0;
  font-size: 0.75rem;
}

/* === PHOTOS === */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.photo-grid img {
  width: 100%;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  box-shadow: 0 1px 4px var(--shadow);
}

.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-muted);
  font-size: 1rem;
}

/* === FOOTER === */
footer {
  text-align: center;
  padding: 16px 12px;
  color: var(--text-muted);
  font-size: 0.75rem;
  border-top: 2px solid var(--border);
  margin-top: 24px;
}

/* === TABLET+ (600px+) === */
@media (min-width: 600px) {
  header h1 { font-size: 2.6rem; }
  header { padding: 28px 20px 14px; }
  header .subtitle { font-size: 1rem; }

  nav {
    justify-content: center;
    overflow-x: visible;
  }

  .nav-btn {
    font-size: 1.2rem;
    padding: 8px 18px;
  }

  main { padding: 20px; }

  .map-container { padding: 16px; }

  .weather-cards {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
  }

  .weather-card { padding: 14px; }
  .weather-card .value { font-size: 2rem; }
  .weather-card .label { font-size: 0.85rem; }

  .gdd-chart-container { padding: 16px; }

  #weather-table { font-size: 0.9rem; min-width: auto; }
  #weather-table th { padding: 8px 10px; font-size: 1rem; }
  #weather-table td { padding: 5px 10px; }

  .timeline { padding-left: 36px; }
  .timeline-entry { padding: 14px 18px; }
  .timeline-entry::before { left: -30px; width: 14px; height: 14px; }
  .timeline-entry table { font-size: 0.85rem; }
  .timeline-entry td { font-size: 0.85rem; }

  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
}

/* === DESKTOP (900px+) === */
@media (min-width: 900px) {
  header h1 { font-size: 3rem; }

  main {
    max-width: 1100px;
    padding: 24px 20px;
  }

  .nav-btn {
    font-size: 1.3rem;
    padding: 8px 20px;
  }

  .map-container { padding: 20px; }

  .weather-card .value { font-size: 2.2rem; }
  .weather-card .label { font-size: 0.9rem; }

  .gdd-chart-container { padding: 20px; }

  .weather-table-container { max-height: 500px; }

  #weather-table { font-size: 0.95rem; }
  #weather-table th { padding: 10px 12px; font-size: 1.1rem; }
  #weather-table td { padding: 6px 12px; }

  .timeline { padding-left: 40px; }
  .timeline-entry { padding: 16px 20px; margin-bottom: 24px; }
  .timeline-entry table { font-size: 0.9rem; }
  .timeline-entry td { font-size: 0.9rem; }

  .photo-grid { grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
}
