/* ============================================================================
   environment.css — Environment tab
   Grow-tent elevation view (plant + Front/Mid/Rear leaf-temp sensor tags)
   paired with a top-down canopy heat-grid. Driven by the leaf-temperature
   columns captured via the Environment tab of the Submit Data form.
   Baseline canvas: 1440px. Glass / dark-cosmic aesthetic.
   ========================================================================== */

.env-wrap {
  max-width: 1320px;
  margin: 0 auto;
  padding: 4px 4px 64px;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.env-header { margin: 4px 2px 22px; position: relative; }
/* "Need Help?" pill — top-right of the header (reuses .rooms-help-pill style). */
.env-help-pill { position: absolute; top: 2px; right: 2px; }
@media (max-width: 640px) {
  .env-help-pill { position: static; margin-bottom: 12px; }
}
.env-title {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #f1f5fb;
  margin: 6px 0 6px;
}
.env-sub {
  font-size: 13.5px;
  line-height: 1.5;
  color: rgba(203, 213, 225, 0.62);
  max-width: 620px;
}

/* Heat legend — the cold→hot scale that every tag / band colour maps onto. */
.env-legend {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding: 8px 14px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(6px);
}
.env-legend-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.7);
}
.env-legend-bar {
  width: 180px;
  height: 9px;
  border-radius: 6px;
  background: linear-gradient(90deg,
    hsl(205, 85%, 58%) 0%,
    hsl(160, 80%, 52%) 32%,
    hsl(95, 78%, 52%) 52%,
    hsl(45, 92%, 56%) 74%,
    hsl(8, 88%, 58%) 100%);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.25);
}
.env-legend-tick { font-size: 10.5px; font-variant-numeric: tabular-nums; color: rgba(203, 213, 225, 0.66); }

/* ── Filter bar (mirrors the Equipment tab pickers) ───────────────────────── */
.env-filterbar {
  position: sticky;
  top: 0;
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 12px 14px;
  margin-bottom: 22px;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 14px;
  background: rgba(11, 16, 32, 0.74);
  backdrop-filter: blur(12px);
}
.env-filter-row { display: flex; align-items: center; gap: 12px; }
.env-filter-label {
  flex: 0 0 58px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.74);
}
.env-filter-pills { display: flex; flex-wrap: wrap; gap: 7px; }
.env-filter-hint { font-size: 12px; color: rgba(148, 163, 184, 0.55); font-style: italic; }
.env-pill {
  appearance: none;
  border: 1px solid rgba(148, 163, 184, 0.2);
  background: rgba(30, 41, 59, 0.5);
  color: rgba(203, 213, 225, 0.82);
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.16s ease;
}
.env-pill:hover { border-color: rgba(167, 139, 250, 0.55); color: #e9e3ff; background: rgba(76, 51, 122, 0.32); }
.env-pill.is-on {
  border-color: rgba(167, 139, 250, 0.85);
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.42), rgba(56, 189, 248, 0.26));
  color: #fff;
  box-shadow: 0 0 16px rgba(124, 58, 237, 0.3);
}

/* ══ Climate board — wide thermal-strip card per room ═══════════════════════
   The Environment tab's signature view (deliberately distinct from the
   Equipment dot-grid): each room is a Front→Middle→Back leaf-temp heat strip
   with the room average, humidity and uniformity beside it. Click to open. */
.env-clim-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(440px, 1fr));
  gap: 16px;
}
.env-clim {
  position: relative;
  display: grid;
  grid-template-columns: minmax(112px, 0.8fr) minmax(0, 1.5fr) minmax(112px, 0.9fr);
  align-items: center;
  gap: 18px;
  padding: 16px 44px 16px 18px;
  text-align: left;
  cursor: pointer;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 18px;
  background:
    radial-gradient(130% 150% at 0% 0%, rgba(56, 189, 248, 0.06), transparent 55%),
    rgba(13, 19, 36, 0.66);
  backdrop-filter: blur(10px);
  color: inherit;
  font-family: 'Inter', sans-serif;
  overflow: hidden;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.22s ease;
}
.env-anim .env-clim {
  animation: env-clim-in 0.42s cubic-bezier(0.22, 1, 0.32, 1) both;
  animation-delay: calc(var(--i, 0) * 50ms);
}
@keyframes env-clim-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.env-clim:hover {
  transform: translateY(-2px);
  border-color: rgba(167, 139, 250, 0.5);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45), 0 0 22px rgba(124, 58, 237, 0.14);
}
.env-clim:focus-visible {
  outline: none;
  border-color: rgba(167, 139, 250, 0.75);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.30);
}
.env-clim.has-stale { border-color: rgba(251, 191, 36, 0.34); }
.env-clim.is-empty { grid-template-columns: 1fr; cursor: default; opacity: 0.5; }
.env-clim.is-empty:hover { transform: none; box-shadow: none; border-color: rgba(148, 163, 184, 0.14); }

/* Head — room name + system count */
.env-clim-head { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.env-clim-name {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 19px;
  font-weight: 600;
  color: #f1f5fb;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.env-clim-count {
  align-self: flex-start;
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.78);
  padding: 2px 8px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 999px;
}

/* Thermal strip — Front / Middle / Back heat blocks */
.env-clim-strip { display: flex; gap: 6px; min-width: 0; }
.env-clim-seg {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 58px;
  border-radius: 12px;
  background: var(--bg, rgba(148, 163, 184, 0.12));
  border: 1px solid var(--c, rgba(148, 163, 184, 0.40));
  box-shadow: inset 0 0 22px -8px var(--c, transparent);
}
.env-clim-seg.is-empty { box-shadow: none; }
.env-clim-seg-l {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: rgba(226, 232, 240, 0.6);
}
.env-clim-seg-v {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--t, #e8eef7);
}

/* Side — room average leaf, humidity, uniformity */
.env-clim-side { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; min-width: 0; }
.env-clim-avg {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: #e8eef7;
}
.env-clim-avg-u { font-size: 13px; font-weight: 600; opacity: 0.7; margin-left: 1px; }
.env-clim-sub { font-size: 10px; font-weight: 600; color: rgba(148, 163, 184, 0.7); }
.env-clim-k { text-transform: uppercase; letter-spacing: 0.08em; color: rgba(148, 163, 184, 0.6); }
.env-clim-hum { color: rgba(125, 211, 252, 0.92); }
.env-clim-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 3px; }
.env-clim-delta {
  font-size: 10px; font-weight: 700; font-variant-numeric: tabular-nums;
  padding: 2px 7px; border-radius: 6px;
  border: 1px solid rgba(148, 163, 184, 0.22); background: rgba(30, 41, 59, 0.5); color: rgba(226, 232, 240, 0.85);
}
.env-clim-delta.is-good { border-color: rgba(74, 222, 128, 0.4);  background: rgba(22, 101, 52, 0.22); color: #86efac; }
.env-clim-delta.is-warn { border-color: rgba(251, 191, 36, 0.42); background: rgba(120, 80, 6, 0.22);  color: #fcd34d; }
.env-clim-delta.is-bad  { border-color: rgba(248, 113, 113, 0.45);background: rgba(127, 29, 29, 0.24); color: #fca5a5; }
.env-clim-stale {
  font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 6px;
  border: 1px solid rgba(251, 191, 36, 0.42); background: rgba(120, 80, 6, 0.26); color: #fcd34d;
}
.env-clim-go {
  position: absolute;
  right: 16px; top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  color: rgba(167, 139, 250, 0.55);
  transition: color 0.18s ease, transform 0.18s ease;
}
.env-clim:hover .env-clim-go { color: rgba(221, 214, 254, 1); transform: translateY(-50%) translateX(3px); }
.env-clim-empty { font-size: 12px; color: rgba(148, 163, 184, 0.45); font-style: italic; }

/* ══ Drill-in back bar ═════════════════════════════════════════════════════ */
.env-backbar {
  position: sticky;
  top: calc(var(--banner-h, 0px) + var(--nav-h, 46px) + 8px);
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin-bottom: 22px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 14px;
  background: rgba(11, 16, 32, 0.78);
  backdrop-filter: blur(12px);
}
.env-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  padding: 7px 13px 7px 10px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(30, 41, 59, 0.5);
  color: rgba(226, 232, 240, 0.9);
  font-family: 'Inter', sans-serif;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}
.env-back:hover { border-color: rgba(167, 139, 250, 0.55); background: rgba(76, 51, 122, 0.32); color: #fff; }
.env-back:hover svg { transform: translateX(-2px); }
.env-back svg { transition: transform 0.16s ease; }
.env-back-room {
  flex-shrink: 0;
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: #f1f5fb;
}
.env-back-sys { margin-left: auto; }

/* ══ Board ⇄ detail view transition ════════════════════════════════════════ */
.env-wrap.env-leaving { animation: env-view-out 0.15s ease forwards; pointer-events: none; }
@keyframes env-view-out {
  to { opacity: 0; transform: translateY(-6px) scale(0.992); }
}
.env-wrap-detail.env-anim { animation: env-view-in 0.4s cubic-bezier(0.22, 1, 0.32, 1) both; }
.env-wrap-detail.env-anim .env-system { animation: env-view-in 0.46s cubic-bezier(0.22, 1, 0.32, 1) both; animation-delay: 0.07s; }
@keyframes env-view-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .env-clim { animation: none; }
  .env-clim:hover { transform: none; }
  .env-wrap.env-leaving,
  .env-wrap-detail,
  .env-wrap-detail .env-system { animation: none !important; }
}

/* ── System card ──────────────────────────────────────────────────────────── */
.env-system {
  position: relative;
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 20px;
  background:
    radial-gradient(120% 90% at 12% 0%, rgba(56, 189, 248, 0.06), transparent 60%),
    radial-gradient(120% 90% at 88% 100%, rgba(124, 58, 237, 0.07), transparent 60%),
    rgba(13, 19, 36, 0.66);
  backdrop-filter: blur(10px);
  padding: 20px 22px 22px;
  margin-bottom: 22px;
  overflow: hidden;
}
.env-system.is-stale { border-color: rgba(251, 191, 36, 0.32); }

.env-system-hdr {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.env-room-tag {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.7);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 7px;
  padding: 3px 9px;
}
.env-system-name {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 19px;
  font-weight: 600;
  color: #f1f5fb;
}
.env-system-meta { font-size: 12px; color: rgba(148, 163, 184, 0.6); }
.env-hdr-spacer { flex: 1 1 auto; }

/* Chips on the right of the header */
.env-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(30, 41, 59, 0.5);
  color: rgba(226, 232, 240, 0.9);
}
.env-chip-label { font-weight: 500; color: rgba(148, 163, 184, 0.78); }
.env-chip.is-good  { border-color: rgba(74, 222, 128, 0.4);  background: rgba(22, 101, 52, 0.22);  color: #86efac; }
.env-chip.is-warn  { border-color: rgba(251, 191, 36, 0.42); background: rgba(120, 80, 6, 0.22);   color: #fcd34d; }
.env-chip.is-bad   { border-color: rgba(248, 113, 113, 0.45);background: rgba(127, 29, 29, 0.24);  color: #fca5a5; }

.env-stale-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(251, 191, 36, 0.45);
  background: rgba(120, 80, 6, 0.28);
  color: #fcd34d;
}

/* ── Stage: elevation view | canopy grid ──────────────────────────────────── */
.env-stage {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}
.env-panel {
  position: relative;
  border: 1px solid rgba(148, 163, 184, 0.1);
  border-radius: 16px;
  background: rgba(8, 12, 26, 0.55);
  padding: 10px 12px 8px;
}
.env-panel-cap {
  position: absolute;
  top: 12px;
  left: 14px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.55);
  pointer-events: none;
}
.env-tent-svg {
  display: block;
  width: 100%;
  height: auto;
}

/* Right panel: readings column — Temp / Humidity / Leaf per position */
.env-panel-data { display: flex; padding: 40px 16px 16px; }
.env-data-col {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
  width: 100%;
}
.env-dc-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-left: 3px solid rgba(148, 163, 184, 0.5);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.45);
}
.env-dc-letter {
  flex: 0 0 30px;
  width: 30px;
  text-align: center;
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
}
.env-dc-body { flex: 1 1 auto; min-width: 0; }
.env-dc-name {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: rgba(148, 163, 184, 0.72);
  margin-bottom: 9px;
}
.env-dc-metrics { display: flex; gap: 10px; flex-wrap: wrap; }
.env-dc-metric {
  flex: 1 1 64px;   /* 4 metrics (Front/Back) fit a row at desktop, wrap on narrow */
  min-width: 64px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 7px 10px;
  border-radius: 9px;
  background: rgba(30, 41, 59, 0.42);
  border: 1px solid rgba(148, 163, 184, 0.1);
}
.env-dc-mk {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.62);
}
.env-dc-mv {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 16px;
  font-weight: 600;
  color: #e8eef7;
  font-variant-numeric: tabular-nums;
}

/* ── SVG element styling (tent elevation) ─────────────────────────────────── */
.env-tag-box {
  fill: rgba(8, 12, 26, 0.82);
  stroke-width: 1.6;
}
.env-tag-letter {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 23px;
  font-weight: 700;
  text-anchor: middle;
  dominant-baseline: central;
}
.env-tag-div {
  stroke-width: 1;
  opacity: 0.32;
}
.env-tag-name {
  font-family: 'Inter', sans-serif;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.12em;
  fill: rgba(148, 163, 184, 0.78);
}
.env-tag-temp {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 15.5px;
  font-weight: 600;
  fill: #f1f5fb;
}
.env-tag-temp.is-empty { fill: rgba(148, 163, 184, 0.5); }
.env-tag-sub {
  font-family: 'Inter', sans-serif;
  font-size: 7.5px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  fill: rgba(148, 163, 184, 0.55);
}

.env-leader { stroke-width: 1.6; stroke-dasharray: 4 3; opacity: 0.7; fill: none; }

.env-node-core { stroke: #0b1020; stroke-width: 1.6; }
.env-node-pulse { opacity: 0.55; }

/* Empty / loading states */
.env-empty {
  text-align: center;
  padding: 56px 20px;
  color: rgba(148, 163, 184, 0.6);
  font-size: 14px;
  border: 1px dashed rgba(148, 163, 184, 0.18);
  border-radius: 16px;
  background: rgba(13, 19, 36, 0.4);
}

/* ── Animations (motion-safe only) ────────────────────────────────────────── */
@media (prefers-reduced-motion: no-preference) {
  .env-node-pulse {
    transform-box: fill-box;
    transform-origin: center;
    animation: envPulse 2.6s ease-out infinite;
  }
  .env-node-pulse.n2 { animation-delay: 0.5s; }
  .env-node-pulse.n3 { animation-delay: 1s; }
  .env-leaf-sway {
    transform-box: fill-box;
    transform-origin: 50% 100%;
    animation: envSway 6s ease-in-out infinite;
  }
  .env-light-glow { animation: envGlow 5s ease-in-out infinite; }
}
@keyframes envPulse {
  0%   { transform: scale(0.55); opacity: 0.6; }
  70%  { transform: scale(2.3);  opacity: 0; }
  100% { transform: scale(2.3);  opacity: 0; }
}
@keyframes envSway {
  0%, 100% { transform: rotate(-1.3deg); }
  50%      { transform: rotate(1.3deg); }
}
@keyframes envGlow {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 0.85; }
}

/* ── Reflows ──────────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .env-stage { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .env-wrap { padding: 2px 2px 48px; }
  .env-title { font-size: 25px; }
  .env-legend-bar { width: 130px; }
}
/* Climate cards: drop to a single column + stack their internals on phones. */
@media (max-width: 620px) {
  .env-clim-board { grid-template-columns: 1fr; }
  .env-clim {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 16px 16px 16px;
  }
  .env-clim-head { flex-direction: row; align-items: center; justify-content: space-between; }
  .env-clim-side { flex-direction: row; align-items: baseline; flex-wrap: wrap; gap: 8px; }
  .env-clim-go { display: none; }
}
