/* ── BED STATUS CHIPS (action surface) ──────────────────────────────── */
/* redesign.md §3.3: dot + name + one-word state, no numbers. Calm chips
   recede; chips needing action get a soft tint + ring so they're louder
   without relying on color alone (dot goes ringed, not just recolored). */

.bed-chip-row {
  display: flex;
  gap: 12px;
  padding: 16px 24px 20px;
}

/* 640-1023px (redesign.md §8): chips stay a single row, scrolling horizontally
   if they don't all fit rather than shrinking past legibility. */
@media (max-width: 1023px) and (min-width: 641px) {
  .bed-chip-row { overflow-x: auto; }
  .bed-chip { flex: 0 0 160px; }
}

/* <640px (redesign.md §8): chips become a 2x2 grid instead of scrolling. */
@media (max-width: 640px) {
  .bed-chip-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    padding: 12px 16px 16px;
    gap: 8px;
  }
}

.bed-chip {
  position: relative;
  z-index: 0;
  overflow: hidden;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: box-shadow 0.18s ease, background 0.18s ease, border-color 0.18s ease;
}
.bed-chip:hover { box-shadow: var(--shadow-sm); }

/* Moisture-level fill: a soft horizontal wash showing % of the chip filled,
   colored by how far the reading is from the crop's healthy band. Sits
   behind the dot/name/state content (negative z-index, own stacking
   context from the chip's z-index:0 above). */
.bed-chip-fill {
  position: absolute;
  z-index: -1;
  top: 0;
  bottom: 0;
  left: 0;
  opacity: 0.32;
  transition: width 0.3s ease, background 0.3s ease;
  pointer-events: none;
}

/* Live marker at the fill's leading edge (level == current reading) -- a
   separate sibling, not .bed-chip-fill::after, so its blink isn't dimmed by
   the wash's own 0.32 opacity. `left` tracks the same % as the fill's width;
   `color` carries the fill's color so background/box-shadow below can both
   reference it via currentColor without repeating the value inline. */
.bed-chip-fill-edge {
  position: absolute;
  z-index: -1;
  top: 2px;
  bottom: 2px;
  left: 0;
  width: 2px;
  border-radius: 1px;
  transform: translateX(-1px);
  background: currentColor;
  box-shadow: 0 0 6px 1px currentColor;
  transition: left 0.3s ease, color 0.3s ease;
  animation: bed-chip-edge-blink 1.4s ease-in-out infinite;
  pointer-events: none;
}

@keyframes bed-chip-edge-blink {
  0%, 100% { opacity: 0.3; }
  50%      { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .bed-chip-fill-edge { animation: none; opacity: 0.85; }
}

.bed-chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  flex-shrink: 0;
}

.bed-chip-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
}

.bed-chip-state {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: auto;
}

/* calm / all-clear: quiet, recedes */
.bed-chip.is-ok .bed-chip-dot { background: var(--ok); }

/* needs action: amber tint + ring so contrast does the talking, not a banner */
.bed-chip.is-warn {
  background: var(--warn-soft);
  border-color: var(--warn);
  box-shadow: 0 0 0 1px var(--warn) inset;
}
.bed-chip.is-warn .bed-chip-dot {
  background: none;
  border: 2px solid var(--warn);
  width: 6px;
  height: 6px;
}
.bed-chip.is-warn .bed-chip-state { color: var(--warn); font-weight: 700; }

/* genuine problem only: sensor dead / critical battery / offline */
.bed-chip.is-offline {
  background: var(--crit-soft);
  border-color: var(--crit);
}
.bed-chip.is-offline .bed-chip-dot { background: var(--crit); }
.bed-chip.is-offline .bed-chip-state { color: var(--crit); font-weight: 700; }

/* ── LOADING SKELETONS (redesign.md §9) ─────────────────────────────── */
/* Soft, muted placeholders shown for the brief window before the first
   /api/latest + /api/insights response lands. Calm pulse, not a spinner. */
.bed-chip.is-skeleton {
  background: var(--surface-2);
  border-color: var(--hairline);
  cursor: default;
  min-height: 40px;
}
.climate-stat.is-skeleton {
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  min-width: 64px;
  min-height: 34px;
}
@media (prefers-reduced-motion: no-preference) {
  .bed-chip.is-skeleton, .climate-stat.is-skeleton {
    animation: g-skeleton-pulse 1.6s ease-in-out infinite;
  }
}
@keyframes g-skeleton-pulse {
  0%, 100% { opacity: 0.6; }
  50%       { opacity: 1; }
}

/* ── CLIMATE STRIP (region C) ───────────────────────────────────────── */
/* redesign.md §5: the only always-on numeric surface. One low-elevation
   surface, hairline divider from the hero, verdict left (most prominent),
   3 headline stats right. */

.climate-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px 32px;
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin: 0 24px;
  box-shadow: var(--shadow-sm);
}

.climate-verdict {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
  flex: 1 1 260px;
}

.climate-stats {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
}

.climate-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  min-width: 84px;
}

.climate-stat-label {
  font-size: 0.6875rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
}

.climate-stat-value {
  font-variant-numeric: tabular-nums;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.climate-stat-unit {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

.climate-stat-sub {
  font-size: 0.6875rem;
  color: var(--text-faint);
}

.climate-stat-trend {
  font-size: 0.75rem;
  font-weight: 600;
}
.climate-stat-trend.is-up   { color: var(--warn); }
.climate-stat-trend.is-down { color: var(--accent); }
.climate-stat-trend.is-flat { color: var(--text-faint); }

@media (max-width: 1023px) {
  .climate-strip { flex-direction: column; align-items: flex-start; }
  .climate-verdict { flex: 0 1 auto; }
  .climate-stats { width: 100%; justify-content: space-between; gap: 16px; }
}

@media (max-width: 640px) {
  .climate-strip { padding: 16px; margin: 0 16px; }
  .climate-stats { gap: 12px; }
  .climate-stat  { min-width: 0; flex: 1 1 30%; }
}

/* ── TRENDS SECTION (region D) — redesign.md §6 ────────────────────────── */
/* Demoted below the fold behind a quiet header; always visible — the
   time-range control + the small-multiples moisture row + grouped charts. */


.trends-header {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 16px 24px;
  color: var(--text-muted);
  font: inherit;
  text-align: left;
}

.trends-title {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.trends-controls {
  display: flex;
  gap: 4px;
  padding: 0 24px 16px;
}

.trends-range-btn {
  padding: 5px 12px;
  border-radius: var(--radius-sm, 10px);
  border: 1px solid var(--hairline);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.trends-range-btn:hover { color: var(--text); }
.trends-range-btn.is-active {
  background: var(--accent-soft);
  color: var(--accent);
}

.trends-climate-grid {
  grid-template-columns: repeat(2, 1fr);
}
@media (max-width: 720px) {
  .trends-climate-grid { grid-template-columns: 1fr; }
}

/* ── CHARTS GRID ────────────────────────────────────────────────────── */

.charts {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  padding: 24px;
  flex: 1;
}

@media (max-width: 720px) {
  .charts { grid-template-columns: 1fr; padding: 16px; gap: 12px; }
}

.chart-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 18px 18px 14px;
  transition: box-shadow 0.18s ease, transform 0.18s ease;
  min-width: 0; /* prevent grid cell blowout on mobile */
}
.chart-card:hover {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.10);
  transform: translateY(-1px);
}
[data-theme="dark"] .chart-card:hover {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.chart-title {
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 14px;
}

.chart-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 220px;
}

/* Radar needs more vertical room than a line chart to keep the 4-bed
   legend + spoke labels legible. flex:1 above already lets it fill a
   taller card (e.g. sharing a grid row with this one); the higher
   min-height just raises its floor when it's on its own / a short row. */
.chart-wrap.is-radar {
  min-height: 340px;
}

/* Spans both trends-climate-grid columns — used by the 7-day water outlook
   card, which needs the extra width for its day-tile strip. */
.chart-card.is-wide {
  grid-column: 1 / -1;
}

/* ── 7-DAY WATER OUTLOOK ──────────────────────────────────────────────── */
/* Lives inside a .chart-card.is-wide in #trends-climate-grid (garden.js
   renderOutlook): an icon/hi-lo/rain% strip above a combo chart of daily
   ET0 demand vs forecast rain supply. Hidden entirely (not rendered empty)
   when weather is unavailable — see renderOutlook's forecast.daily guard. */

.outlook-strip {
  display: flex;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.outlook-tile {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-align: center;
}

.outlook-tile-day {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
}

.outlook-tile-emoji {
  font-size: 1.1rem;
  line-height: 1.2;
}

.outlook-tile-temp {
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.outlook-tile-rain {
  font-size: 0.6875rem;
  color: var(--accent);
}

@media (max-width: 640px) {
  .outlook-tile-day  { font-size: 9px; }
  .outlook-tile-temp { font-size: 0.6875rem; }
}

/* ── SOIL MOISTURE VS. BAND ──────────────────────────────────────────── */
/* Lives inside a regular .chart-card in #trends-climate-grid, same slot the
   day-count "When to water next" projection used to occupy — pure live
   snapshot (garden.js renderMoistureBandCard), no forecasting. */

.moistband-forecast {
  flex: 1 1 auto;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.moistband-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-top: 1px solid var(--hairline);
}
.moistband-row:first-of-type { border-top: none; }

.moistband-bed-name {
  flex: 0 0 52px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
}

.moistband-track {
  position: relative;
  flex: 1;
  height: 8px;
  border-radius: 4px;
  background: var(--surface-2);
}

.moistband-zone {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 4px;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
}

/* Near-dry buffer: faint amber sliver just below the healthy band, so a
   reading that's only slightly under min reads as "approaching dry" rather
   than blending into the plain track. */
.moistband-buffer {
  position: absolute;
  top: 0;
  height: 100%;
  border-radius: 4px 0 0 4px;
  background: var(--warn-soft);
}

.moistband-marker {
  position: absolute;
  top: 50%;
  width: 3px;
  height: 14px;
  border-radius: 2px;
  transform: translate(-50%, -50%);
  transition: left 0.3s ease, background 0.3s ease;
}

.moistband-value {
  flex: 0 0 auto;
  font-size: 0.8125rem;
  font-weight: 700;
  min-width: 34px;
  text-align: right;
}

.moistband-label {
  flex: 0 0 auto;
  font-size: 0.75rem;
  font-weight: 600;
  min-width: 96px;
  text-align: right;
}

.bed-moisture-row {
  grid-template-columns: repeat(4, 1fr);
  padding-bottom: 0;
}

@media (max-width: 900px) {
  .bed-moisture-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .bed-moisture-row { grid-template-columns: 1fr; }
}

/* ── EMPTY STATE ────────────────────────────────────────────────────── */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  padding: 80px 24px;
  gap: 8px;
  text-align: center;
}

.empty-icon {
  font-size: 36px;
  margin-bottom: 4px;
  opacity: 0.4;
}

.empty-label {
  font-family: 'Bitter', Georgia, serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}

.empty-hint {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── FOOTER ─────────────────────────────────────────────────────────── */

footer {
  color: var(--text-muted);
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: center;
  padding: 13px 24px;
  border-top: 1px solid var(--hairline);
  letter-spacing: 0.01em;
}

/* ── BED DETAIL (inline expand) ─────────────────────────────────────── */
/* redesign.md §4.1, reworked: shown directly beneath the bed chip row
   instead of a side drawer. Only one bed open at a time. The old drawer's
   Climate tab was dropped entirely -- Trends already covers that ground. */

.bed-chip.is-open { box-shadow: 0 0 0 2px var(--accent) inset; }

.bed-detail {
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow-sm);
  margin: 0 24px 20px;
  padding: 16px;
}

.bed-detail-line {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.bed-detail-metric {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.bed-detail-metric-val {
  font-variant-numeric: tabular-nums;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
}

.bed-detail-metric-band {
  font-size: 0.75rem;
  color: var(--text-faint);
}

.bed-detail-metric-range {
  font-size: 0.75rem;
  color: var(--text-faint);
}

.bed-detail-rate {
  font-size: 0.75rem;
  font-weight: 600;
  margin-left: auto;
}
.bed-detail-rate.is-up   { color: var(--warn); }
.bed-detail-rate.is-down { color: var(--accent); }
.bed-detail-rate.is-flat { color: var(--text-faint); }

.bed-detail-chart {
  position: relative;
  height: 84px;
  margin: 10px 0 14px;
}

.bed-detail-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.bed-detail-verdict {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--hairline);
}

/* Rain-aware "dry in ~N days" projection (garden.js _wateringLabel /
   garden.main._bed_watering_forecast) — a rain-relief day reads as covered
   (accent blue), an urgent "water today" reads as a warning; the default
   (learning/holding steady/dry-in-N-days) is a quiet neutral line. */
.bed-outlook {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 8px;
}
.bed-outlook.is-relief { color: var(--accent); }
.bed-outlook.is-urgent { color: var(--warn); font-weight: 600; }

@media (max-width: 640px) {
  .bed-detail { margin: 0 16px 16px; }
}


/* ── LIGHT-MODE PANEL POLISH (§8) ───────────────────────────────────────── */
/* In light mode .chart-card uses a cream card-bg that blends into the page
   background. Override to a translucent white (frosted-glass over the sky
   backdrop) with a clear border and a soft shadow so cards separate
   visually the way dark-mode cards do. */

[data-theme="light"] .chart-card {
  background:    rgba(255, 255, 255, 0.82);
  border:        1px solid #e5e7eb;
  box-shadow:    0 1px 4px rgba(0, 0, 0, 0.07);
}

/* Fallback for browsers without backdrop-filter support: fall back to a
   solid (opaque) card so text stays legible over whatever's behind it. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .bed-chip, .climate-strip, .chart-card, .bed-detail {
    background: var(--surface-2);
  }
  [data-theme="light"] .chart-card {
    background: #ffffff;
  }
}

[data-theme="light"] .chart-card:hover {
  box-shadow:    0 4px 16px rgba(0, 0, 0, 0.10);
}

[data-theme="light"] .sky-banner {
  filter: saturate(0.92) brightness(1.02);
}

/* ── WATER GAUGES (§2) ──────────────────────────────────────────────────── */

/* ── BATTERY BADGE (§4) ─────────────────────────────────────────────────── */
/* Reused by the bed detail's per-bed battery indicator (§4.1). */

.battery-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  line-height: 1;
}
