/**
 * public/css/components/nursery-chart.css
 * Canopy v2 component - Nursery detail sheet and history charts (#591).
 * Built from the approved mockup docs/design/mockups/nursery-detail-sheet-mockup.html
 * (minus the D-0016 changes: no Signal row, battery sub-line "Air and soil sensors").
 * Consumes ONLY --v2-* tokens. The sheet rides the app's .modal-overlay / .modal-sheet shell
 * (openModal/closeModal); reuses .section-group (settings-drawer.css); its glass controls are the shared .glass and .glass-seg (glass.css). The .nur-banner look belongs to nursery-card.css.
 */

/* ===== Sheet shell ===== */
.nur-sheet {
  background: var(--v2-bg-panel);
  border-radius: var(--v2-radius-xl) var(--v2-radius-xl) 0 0;
  font-family: var(--v2-font-body);
  color: var(--v2-text-primary);
}
@media (min-width: 768px) {
  .nur-sheet { max-width: 520px; }
}

.nur-sheet-top {
  display: flex;
  align-items: center;
  gap: var(--v2-space-sm);
  padding: var(--v2-space-xs) var(--v2-space-sm) var(--v2-space-sm) var(--v2-space-md);
  flex-shrink: 0;
}
.nur-sheet-heading { flex: 1; min-width: 0; }
.nur-sheet-title { margin: 0; font: var(--v2-type-h3); }
.nur-sheet-sub { margin: 0; font: var(--v2-type-caption); color: var(--v2-text-secondary); }
.nur-sheet-close {
  width: var(--v2-space-touch);
  height: var(--v2-space-touch);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--v2-text-secondary);
  cursor: pointer;
}
.nur-sheet-close:focus-visible { outline: 2px solid var(--v2-accent-botanical); outline-offset: 2px; }

.nur-sheet-body { padding: 0 var(--v2-space-md) var(--v2-space-lg); }

.nur-ic {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.nur-sec-label {
  margin: var(--v2-space-lg) 4px var(--v2-space-sm);
  font-size: var(--v2-font-size-caption2);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--v2-text-support);
}
[data-nur-top] > .nur-sec-label:first-child { margin-top: var(--v2-space-sm); }

/* ===== Readings rows (inside a canonical .section-group) ===== */
/* Several tags under one value (Driest, Too dry) stack on separate lines. */
.nur-rd {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  min-height: 52px;
  border-bottom: 1px solid var(--v2-border-soft);
}
.nur-rd:last-child { border-bottom: none; }
.nur-rd-main { flex: 1; min-width: 0; }
.nur-rd-label { font-size: 15px; font-weight: 500; color: var(--v2-text-primary); }
.nur-rd-limit { font-size: 12px; color: var(--v2-text-secondary); margin-top: 1px; }
.nur-rd-val {
  font-weight: 600;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  color: var(--v2-text-primary);
  text-align: right;
}
.nur-rd-val small { font-size: 12px; font-weight: 500; color: var(--v2-text-secondary); }
.nur-rd-tag {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: right;
  color: var(--v2-pop-sage);
}
.nur-rd.bad { background: var(--v2-pop-coral-bg); }
.nur-rd.bad .nur-rd-val,
.nur-rd.bad .nur-rd-tag { color: var(--v2-pop-coral-text); }
.nur-rd.stale .nur-rd-val,
.nur-rd.stale .nur-rd-val small { color: var(--v2-text-tertiary); }
.nur-rd.stale .nur-rd-tag,
.nur-rd.info .nur-rd-tag { color: var(--v2-text-secondary); }

/* ===== History controls (Liquid Glass) ===== */
/* The glass surface and the segmented control are the shared .glass and .glass-seg (glass.css). */
.nur-menu-btn:focus-visible, .nur-opt:focus-visible { outline: 2px solid var(--v2-accent-text); outline-offset: 2px; }
.nur-sec-label + .glass-seg { margin-top: 0; }

/* One control row per card: reading segment + sensor menu button. */
.nur-controls { position: relative; display: flex; align-items: center; gap: var(--v2-space-sm); margin-top: var(--v2-space-sm); }
.nur-controls > .glass-seg { flex: 1; min-width: 0; }
.nur-menu-btn {
  flex: none;
  max-width: 55%;
  height: var(--v2-seg-height);
  padding: 0 var(--v2-space-md);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: var(--v2-radius-full);
  color: var(--v2-glass-label);
  font: 600 13px var(--v2-font-body);
  white-space: nowrap;
  cursor: pointer;
}
.nur-menu-btn > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nur-menu-btn.is-wide { flex: 1; max-width: none; justify-content: space-between; font-size: 15px; }
.nur-menu-btn svg, .nur-opt svg { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.nur-menu-btn[aria-expanded="true"] { background: var(--v2-glass-raised); }
.nur-menu-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.nur-menu {
  position: absolute;
  z-index: 5;
  top: calc(100% + 6px);
  right: 0;
  min-width: 200px;
  max-width: 100%;
  max-height: 50vh;
  overflow-y: auto;
  padding: 6px;
  border-radius: var(--v2-radius-md);
}
.nur-opt {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: var(--v2-space-touch);
  padding: 0 12px;
  border: none;
  border-radius: var(--v2-radius-sm);
  background: transparent;
  color: var(--v2-glass-label);
  font: 400 15px var(--v2-font-body);
  text-align: left;
  cursor: pointer;
}
.nur-opt > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nur-opt[aria-selected="true"] { background: var(--v2-glass-raised); font-weight: 700; box-shadow: inset 0 1px 0 var(--v2-glass-highlight); }
.nur-opt small { margin-left: auto; font-size: 13px; font-weight: 500; color: var(--v2-text-secondary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.nur-menu-btn, .nur-opt { transition: transform var(--v2-transition-slow) var(--v2-ease-spring), background var(--v2-transition-fast) var(--v2-ease-out); }
.nur-menu-btn:active, .nur-opt:active { transform: scale(0.96); transition-duration: var(--v2-transition-fast); transition-timing-function: var(--v2-ease-out); }
@media (prefers-reduced-motion: reduce) {
  .nur-menu-btn, .nur-opt { transition: none; }
  .nur-menu-btn:active, .nur-opt:active { transform: none; }
}

/* ===== Chart card ===== */
.nur-chart-card {
  background: var(--v2-bg-card);
  border: 1px solid var(--v2-border-soft);
  border-radius: var(--v2-radius-md);
  padding: var(--v2-space-md);
  margin-top: var(--v2-space-sm);
}
.nur-chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.nur-chart-title { font-size: 15px; font-weight: 600; }
.nur-chart-now { font-size: 13px; color: var(--v2-text-secondary); font-variant-numeric: tabular-nums; }
.nur-chart-note { margin: var(--v2-space-md) 0 0; font-size: 13px; color: var(--v2-text-secondary); }
/* Chart rules (#732, D-0022.1): value axis on the right, gridlines at 14% ink, dashed limit lines over a
 * tint band, a plate naming the range, coral only on out-of-range segments and the newest dot. */
.nur-chart { --nur-ch-surface: var(--v2-bg-primary); display: block; width: 100%; height: auto; margin-top: var(--v2-space-sm); overflow: visible; }
.nur-chart-card .nur-chart { --nur-ch-surface: var(--v2-bg-card); }

.nur-ch-band { fill: var(--v2-text-primary); fill-opacity: 0.07; }
.nur-ch-night { fill: var(--v2-text-primary); fill-opacity: 0.09; }
.nur-ch-grid { stroke: var(--v2-text-primary); stroke-opacity: 0.14; stroke-width: 1; }
.nur-ch-base, .nur-ch-xt { stroke: var(--v2-border-strong); stroke-width: 1; }
.nur-ch-limit { stroke: var(--v2-text-secondary); stroke-width: 1.5; stroke-dasharray: 5 4; }
/* #745: a limit off the fitted axis, named at that edge with a chevron. */
.nur-ch-off path { fill: none; stroke: var(--v2-text-secondary); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.nur-ch-plate { fill: var(--nur-ch-surface); }
.nur-ch-lab { font: 600 13px var(--v2-font-body); fill: var(--v2-text-primary); }
.nur-ch-line { fill: none; stroke: var(--v2-text-primary); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.nur-ch-pt { fill: var(--v2-text-primary); }
.nur-ch-pt.is-out { fill: var(--v2-pop-coral); }
.nur-ch-out { fill: none; stroke: var(--v2-pop-coral); stroke-width: 3.5; stroke-linejoin: round; stroke-linecap: round; }
.nur-ch-cal { stroke: var(--v2-pop-slate); stroke-width: 1.5; stroke-dasharray: 3 3; }
.nur-ch-gapbox { fill: var(--v2-bg-secondary); stroke: var(--v2-border-strong); stroke-width: 1; stroke-dasharray: 2 3; }
.nur-ch-hatch { stroke: var(--v2-border-strong); stroke-width: 1; }
.nur-ch-axis, .nur-ch-ytick { font: 500 13px var(--v2-font-body); fill: var(--v2-text-secondary); font-variant-numeric: tabular-nums; }
.nur-ch-nl { font-weight: 600; }
.nur-ch-gaplabel { font: 600 12px var(--v2-font-body); fill: var(--v2-text-secondary); }
.nur-ch-halo { fill: var(--nur-ch-surface); }
.nur-ch-dot { fill: var(--v2-text-primary); }
.nur-ch-dot.is-out { fill: var(--v2-pop-coral); }

/* View as table: a quiet link under the chart, the table opens in place. */
.nur-ch-tbl { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0; border: 0; background: none; color: var(--v2-text-secondary); font: 600 13px var(--v2-font-body); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.nur-ch-tbl .nur-ic { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.nur-ch-tablewrap { max-height: 280px; overflow-y: auto; margin-bottom: var(--v2-space-sm); }
.nur-ch-table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
.nur-ch-table th { position: sticky; top: 0; background: var(--v2-bg-card); text-align: left; font-weight: 600; color: var(--v2-text-secondary); padding: 6px 8px 6px 0; }
.nur-ch-table td { padding: 6px 8px 6px 0; border-top: 0.5px solid var(--v2-border-strong); color: var(--v2-text-primary); }

.nur-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: var(--v2-space-sm);
  font-size: 12px;
  color: var(--v2-text-secondary);
}
.nur-chart-legend i { display: inline-block; width: 14px; height: 8px; border-radius: 2px; margin-right: 5px; vertical-align: baseline; }
.nur-lg-band { background: color-mix(in srgb, var(--v2-text-primary) 7%, transparent); border: 1px dashed var(--v2-text-secondary); }
.nur-lg-out { background: var(--v2-pop-coral); height: 3px; }
.nur-lg-gap { background: var(--v2-bg-secondary); border: 1px dashed var(--v2-border-strong); }

/* #589 fills this slot; nothing shows until it has content. */
[data-nursery-warnings]:empty { display: none; }

/* ===== Finger readout (#619, slot per #732) ===== */
/* The slot sits right above the plot at a fixed height so nothing jumps when the finger lands. At rest it
 * names the time window the chart shows; a finger replaces it with the slice under it. */
.nht-readout { height: 48px; margin-top: var(--v2-space-sm); display: flex; flex-direction: column; justify-content: center; overflow: hidden; }
.nht-readout-when { font-size: 13px; font-weight: 500; color: var(--v2-text-secondary); font-variant-numeric: tabular-nums; }
.nht-readout-main { display: flex; align-items: baseline; gap: 8px; }
.nht-readout-val { font-size: 17px; font-weight: 600; line-height: 1.25; font-variant-numeric: tabular-nums; color: var(--v2-text-primary); }
.nht-readout-none { font-size: 15px; font-weight: 500; color: var(--v2-text-secondary); }
.nht-readout-rng { font-size: 13px; font-weight: 500; color: var(--v2-text-secondary); font-variant-numeric: tabular-nums; }
.nht-readout-tag { margin-left: auto; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--v2-pop-coral-text); }
.nht-readout.is-out .nht-readout-val { color: var(--v2-pop-coral-text); }
.nht-readout-hint { font-size: 15px; font-weight: 500; color: var(--v2-text-secondary); font-variant-numeric: tabular-nums; }
.nht-readout + .nur-chart { margin-top: 0; }
/* pan-y: the browser keeps vertical pans (sheet swipe-to-dismiss, scroll); a sideways drag reaches the scrub. */
.nur-chart--scrub { touch-action: pan-y; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.nur-chart--scrub:focus-visible { outline: 2px solid var(--v2-text-primary); outline-offset: 2px; border-radius: var(--v2-radius-sm); }
.nht-scrub-slice { fill: var(--v2-text-primary); opacity: 0.08; }
.nht-scrub-line { stroke: var(--v2-text-primary); stroke-width: 1; }
.nht-scrub-range { stroke: var(--v2-text-primary); stroke-width: 6; stroke-linecap: round; opacity: 0.22; }
.nht-scrub-dot { fill: var(--v2-text-primary); stroke: var(--nur-ch-surface); stroke-width: 3; }
.nht-scrub-dot.is-out { fill: var(--v2-pop-coral); }
