/* trends — see public/css/app.css for tokens. Use tokens only; every rule must work in both themes.

   The charts (components/charts.js) are styled here too: Trends is where they
   live. They are drawn at their real pixel width, so every size below is a
   CSS pixel on every screen. Motion: none — a chart that animates on every
   background refresh reads as the numbers changing. */

/* ------------------------------------------------------------------ screen */
.trends-screen .num,
.outcome-numbers.num { font-family: var(--font-display); font-variant-numeric: tabular-nums; }

.trend-range-seg { margin: var(--sp-1) 0 var(--sp-4); }

.trend-card { margin-bottom: var(--sp-3); }
.trend-card .card-head { margin-bottom: var(--sp-1); align-items: flex-start; }
.trend-card .card-head h2 {
  flex: 1 1 12em; min-width: 0;
  font-size: var(--fs-h3); font-weight: 650; line-height: 1.3; padding-top: 2px;
}
/* The range the card covers: a caption, not a sentence. */
.trend-range {
  margin-bottom: var(--sp-3);
  font-size: var(--fs-caption); color: var(--ink-3); font-variant-numeric: tabular-nums;
}
.trends-screen .card-note { font-size: var(--fs-note); }

/* Provenance: a tag that is also a button. The 44px hit area and the focus
   ring come from `button.tag` in components.css — only the dotted underline
   that marks it as tappable is Trends' own. */
.prov-tags { display: inline-flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.prov-tag {
  font-size: var(--fs-caption); font-weight: 600; letter-spacing: .02em;
  text-decoration: underline dotted; text-underline-offset: 2px;
  text-decoration-color: color-mix(in srgb, currentColor 55%, transparent);
}

/* What a card needs before it can answer, and the button that provides it. */
.trend-need {
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--sp-3);
  padding: var(--sp-4); border: 1px dashed var(--line-strong); border-radius: var(--r);
  background: var(--surface-2);
}
.trend-need p { font-size: var(--fs-body); line-height: 1.5; color: var(--ink-2); }
.trend-quiet { padding: var(--sp-4) 0; font-size: var(--fs-note); color: var(--ink-3); text-align: center; }

.trend-first {
  margin-top: var(--sp-3); padding: var(--sp-3);
  border-radius: var(--r); background: var(--seaglass-wash);
  font-size: var(--fs-note); line-height: 1.5; color: var(--ink);
}

.trend-actions { margin-top: var(--sp-3); }
.trend-actions .btn svg,
.trend-add svg { margin-left: -2px; }
.trend-add { flex: none; color: var(--accent-text); }

.trend-toggle { margin-bottom: var(--sp-3); }

/* A row of choices that may be longer than the card: it scrolls sideways
   rather than hiding the ones that do not fit. */
.chip-scroll {
  display: flex; gap: 7px; margin: 0 calc(-1 * var(--pad)) var(--sp-3); padding: 2px var(--pad);
  overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.chip-scroll::-webkit-scrollbar { display: none; }
.chip-scroll .chip { flex: none; scroll-snap-align: start; }
.chip-count { font-size: var(--fs-caption); font-weight: 500; color: var(--ink-3); }
.chip[aria-pressed="true"] .chip-count { color: inherit; opacity: .8; }

/* Rows bleed to the card's edges, like an item-group, but mid-card. */
.trend-bleed { margin: 0 calc(-1 * var(--pad)); }
.trend-bleed > .item:first-child,
.trend-bleed > .item:last-child { border-radius: 0; }
.trend-card .empty { padding: var(--sp-3) 0 var(--sp-2); }
.trend-card .empty .trend-bleed { margin: 0; }

/* ------------------------------------------------------------------ stats */
/* Two across: four tiles make a square, and an odd last tile takes the row
   rather than sitting beside a hole. */
.tstats-head {
  margin-top: var(--sp-4); font-size: var(--fs-overline); font-weight: 650;
  text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3);
}
.tstats {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-2);
  margin-top: var(--sp-3);
}
.tstats-head + .tstats { margin-top: var(--sp-2); }
.tstats > :last-child:nth-child(odd) { grid-column: 1 / -1; }
.tstat {
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
  padding: 10px 12px; border-radius: var(--r);
  background: var(--surface-2); border: 1px solid var(--line-soft);
  color: var(--ink); text-align: left;
}
.tstat b {
  font-size: 1.25rem; line-height: 1.2; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tstat-label { font-size: var(--fs-caption); font-weight: 600; color: var(--ink-2); line-height: 1.35; }
.tstat-sub { font-size: var(--fs-caption); color: var(--ink-3); line-height: 1.35; }

/* Recovery: the tiles choose what the chart shows. */
button.tstat {
  appearance: none; font: inherit; cursor: pointer; min-height: var(--tap-min);
  transition: background var(--dur-2) var(--ease), border-color var(--dur-2) var(--ease), transform var(--dur-1) var(--ease);
}
button.tstat:active { transform: scale(.98); }
button.tstat[aria-pressed="true"] {
  background: var(--seaglass-wash);
  border-color: color-mix(in srgb, var(--seaglass) 55%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--seaglass) 55%, transparent);
}
button.tstat:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }
.tstats.is-picker { margin: 0 0 var(--sp-4); }

/* ----------------------------------------------------------------- charts */
.chart-block { margin-top: var(--sp-1); }
.chart-caption { margin-bottom: var(--sp-1); font-size: var(--fs-caption); font-weight: 600; color: var(--ink-3); }
.coverage-caption { margin-top: var(--sp-4); }
.chart-host { position: relative; }
.chart-plot { width: 100%; }
/* pan-y: a vertical drag scrolls the page as usual; a sideways one past the
   6px dead-zone (charts.js) scrubs through the days. */
.chart-plot { touch-action: pan-y; }
.chart-host .chart {
  display: block; width: 100%; height: auto; overflow: visible;
  cursor: pointer; touch-action: pan-y; -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none;
}
.chart-host.is-scrubbing .chart { cursor: ew-resize; }
.chart-host .chart:focus { outline: none; }
.chart-host .chart:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 3px; border-radius: var(--r-xs); }

.chart-readout {
  display: block; min-height: 1.5em; margin-top: 2px;
  font-size: var(--fs-note); line-height: 1.5; color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.chart-host.is-band .chart-readout { margin-top: 0; }

/* The readout and, beside it, the door to that day's day sheet. */
/* Side by side while the words are short; a long readout takes the full
   width and the button drops under it, at the right. */
.chart-readout-row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0 var(--sp-2); margin-top: 2px; }
.chart-readout-row .chart-readout { flex: 1 1 18em; min-width: 0; margin-top: 0; padding: 11px 0 4px; }
.chart-open { flex: none; margin: 2px 0 0 auto; }
.chart-open[hidden] { display: none; }

.chart .axis-label { font-size: 11px; fill: var(--ink-2); font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart .axis-label.sel { fill: var(--ink); font-weight: 650; }
.chart .value-label { fill: var(--ink-3); }
.chart .grid-line { stroke: var(--line-soft); stroke-width: 1; }
.chart .grid-line.base { stroke: var(--line); }

.chart .bar-rect { fill: var(--seaglass); transition: none; }
/* Still under way: lighter and dashed, so it never reads as a short week. */
.chart .bar-rect.progress {
  fill: color-mix(in srgb, var(--seaglass) 32%, var(--surface));
  stroke: var(--seaglass); stroke-width: 1.5; stroke-dasharray: 3 3;
}
/* The crewmate's minutes, stacked on mine: a different hue AND a lighter
   value, so the two segments are still two in greyscale. */
.chart .bar-extra { fill: color-mix(in srgb, var(--plum) 55%, var(--surface)); }
.chart .bar-extra.progress {
  fill: color-mix(in srgb, var(--plum) 22%, var(--surface));
  stroke: color-mix(in srgb, var(--plum) 70%, var(--surface)); stroke-width: 1.5; stroke-dasharray: 3 3;
}
.chart .bar-extra.sel { stroke: var(--ink); stroke-width: 1.5; }
.chart .bar-rect.sel { stroke: var(--ink); stroke-width: 1.5; }
.chart .bar-rect.progress.sel { stroke: var(--ink); }
.chart .bar-none { stroke: var(--line-strong); stroke-width: 1.5; stroke-dasharray: 2 3; stroke-linecap: round; }

.chart .ref-line { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 5 4; }
.chart .ref-label { fill: var(--accent-text); font-weight: 650; }
.chart .mean-line { stroke: var(--ink-3); stroke-width: 1; stroke-dasharray: 5 4; }
.chart .mean-label {
  fill: var(--ink-2);
  paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round;
}

.chart .line-path { fill: none; stroke: var(--seaglass); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.chart .point { fill: var(--surface); stroke: var(--seaglass); stroke-width: 2; }
.chart .point.sel { fill: var(--seaglass); stroke: var(--surface); stroke-width: 2.5; }
.chart .raw-point { fill: none; stroke: var(--seaglass); stroke-width: 1.2; opacity: .45; }
/* The selection guide is a cursor, not a data state, so it is solid and faint:
   dashed means provisional and nothing else (charts.js). */
.chart .guide { stroke: color-mix(in srgb, var(--ink) 22%, transparent); stroke-width: 1; }

.chart .cov-measured { fill: var(--seaglass); }
.chart .cov-pending { fill: var(--surface); stroke: var(--pending); stroke-width: 1.2; stroke-dasharray: 2 1.5; }
/* Calibrating is a neutral fill, not the dashed "on its way": the band did
   measure, WHOOP is still learning what it means. Not scorable is a short
   neutral bar — nothing is coming. */
.chart .cov-calibrating { fill: color-mix(in srgb, var(--line-strong) 45%, var(--surface)); }
.chart .cov-unscorable { fill: var(--line-strong); }
.chart .cov-none { fill: var(--line); }
.chart .cov-sel { fill: none; stroke: var(--ink); stroke-width: 1.5; }

/* Your usual range: a soft wash, never dashed (dashed means provisional). */
.chart .usual-band { fill: var(--seaglass-wash); stroke: color-mix(in srgb, var(--seaglass) 28%, transparent); stroke-width: 1; }
.chart .usual-label {
  fill: var(--ink-3);
  paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round;
}

/* The pill that rides above the selected point. */
.chart .callout-pill {
  fill: var(--surface); stroke: var(--line-strong); stroke-width: 1;
  filter: drop-shadow(0 1px 2px rgba(6,37,52,.12));
}
.chart .callout-text {
  font-size: 12px; font-weight: 650; fill: var(--ink);
  font-family: var(--font-display); font-variant-numeric: tabular-nums;
}

/* A day with a state but no number, at the foot of a strip. */
.chart .st-pending { fill: var(--surface); stroke: var(--pending); stroke-width: 1.2; stroke-dasharray: 2 1.5; }
.chart .st-calibrating { fill: color-mix(in srgb, var(--line-strong) 45%, var(--surface)); }
.chart .st-unscorable { fill: var(--line-strong); }
.chart .point.calibrating { fill: var(--surface); stroke: var(--line-strong); }
.chart .point.sel.calibrating { fill: var(--line-strong); stroke: var(--surface); }

/* ---------------------------------------------------------------- logbook */
/* Aligned strips, each its own scale, the coverage band as their axis. */
.logbook { margin-top: var(--sp-1); }
.strip + .strip { margin-top: var(--sp-2); padding-top: var(--sp-2); border-top: 1px solid var(--line-soft); }
.strip.is-axis { border-top-color: var(--line); }
.strip-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-2);
  flex-wrap: wrap; min-height: 22px;
}
.strip-name { font-size: var(--fs-note); font-weight: 650; color: var(--ink); }
.strip-read { font-size: var(--fs-caption); color: var(--ink-2); text-align: right; font-variant-numeric: tabular-nums; }
.strip-value { font-size: var(--fs-body); font-weight: 700; color: var(--ink); }
.strip-place { color: var(--ink-2); }
.strip-caption { margin: 1px 0 2px; font-size: var(--fs-note); line-height: 1.4; color: var(--ink-3); }
.chart-host.is-strip .chart { cursor: pointer; }
.logbook .chart-readout-row { margin-top: var(--sp-2); }
.logbook-readout { min-height: 3em; }

/* ---------------------------------------------------------- night rhythm */
.chart .tide-night { fill: var(--seaglass); }
.chart .tide-night.pending { fill: var(--surface); stroke: var(--pending); stroke-width: 1.4; stroke-dasharray: 3 2.5; }
.chart .tide-night.unscorable { fill: color-mix(in srgb, var(--line-strong) 40%, var(--surface)); }
.chart .tide-night.sel { stroke: var(--ink); stroke-width: 1.6; }
.chart .tide-night.pending.sel { stroke: var(--ink); }
.chart .tide-none { fill: var(--line); }
.chart .tide-nap { fill: var(--seaglass-2); stroke: var(--seaglass); stroke-width: 1; }
.chart .tide-nap.sel { stroke: var(--ink); stroke-width: 1.5; }
.chart .tide-ship { fill: color-mix(in srgb, var(--sand) 85%, transparent); stroke: var(--sand-deep); stroke-width: 1; }
.chart .tide-ship-label { fill: var(--ink-2); font-weight: 600; }

.chart-legend {
  display: flex; flex-wrap: wrap; gap: 4px var(--sp-4); margin-top: var(--sp-1);
  font-size: var(--fs-caption); color: var(--ink-3);
}
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.sw { flex: none; display: inline-block; width: 14px; height: 10px; border-radius: 3px; }
.sw-bar, .sw-measured { background: var(--seaglass); }
.sw-extra { background: color-mix(in srgb, var(--plum) 55%, var(--surface)); }
.sw-progress {
  background: color-mix(in srgb, var(--seaglass) 32%, var(--surface));
  border: 1.5px dashed var(--seaglass);
}
.sw-pending { background: var(--surface); border: 1.5px dashed var(--pending); }
.sw-none { height: 3px; background: var(--line); align-self: flex-end; margin-bottom: 4px; }
.sw-ref, .sw-mean { height: 0; border-radius: 0; border-top: 1.5px dashed var(--ink-3); }
.sw-raw { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--seaglass); opacity: .6; }
.sw-usual { background: var(--seaglass-wash); border: 1px solid color-mix(in srgb, var(--seaglass) 40%, transparent); }
.sw-calibrating { background: color-mix(in srgb, var(--line-strong) 45%, var(--surface)); }
.sw-unscorable { height: 3px; background: var(--line-strong); }
.sw-night { width: 8px; height: 14px; border-radius: 4px; background: var(--seaglass); }
.sw-night-unscorable { width: 8px; height: 14px; border-radius: 4px; background: color-mix(in srgb, var(--line-strong) 40%, var(--surface)); }
.sw-nap { width: 9px; height: 9px; border-radius: 50%; background: var(--seaglass-2); border: 1px solid var(--seaglass); }
.sw-ship { background: color-mix(in srgb, var(--sand) 85%, transparent); border: 1px solid var(--sand-deep); }

.sample-note { margin-top: var(--sp-1); font-size: var(--fs-note); line-height: 1.5; color: var(--ink-3); }
.coverage-block { margin-top: var(--sp-1); }

/* ------------------------------------------------------------ private card */
/* Body measurements: closed until the person opens it, with a lock that says
   why before any number is on screen. */
.private-card { padding-top: var(--sp-2); padding-bottom: var(--sp-2); }
.private-disclosure > summary { min-height: 56px; color: var(--ink); font-size: var(--fs-md); }
.private-sum { display: flex; align-items: center; gap: var(--sp-3); }
.private-lock {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: color-mix(in srgb, var(--plum) 14%, var(--surface)); color: var(--plum-text);
}
.private-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.private-title { font-family: var(--font-display); font-size: var(--fs-h3); font-weight: 650; line-height: 1.3; }
.private-sub { font-size: var(--fs-note); font-weight: 500; color: var(--ink-3); line-height: 1.4; }
.private-disclosure .disclosure-chev { color: var(--ink-3); }
.private-body { padding: var(--sp-2) 0 var(--sp-2); }
.private-tags { display: flex; justify-content: flex-end; margin-bottom: var(--sp-2); }
.private-tags:empty { display: none; }

/* The entries behind the private line, newest first, each one removable. */
.body-recent:empty { display: none; }
.body-recent .item-title { font-variant-numeric: tabular-nums; }
.measure-remove { flex: none; color: var(--ink-3); }

/* ------------------------------------------------------------ outcomes */
.outcome-kind { font-size: var(--fs-body); color: var(--ink-2); margin-bottom: var(--sp-2); }
.outcome-numbers { font-size: var(--fs-h3); color: var(--ink); margin-bottom: var(--sp-2); }
.outcome-who { margin-bottom: var(--sp-4); line-height: 1.5; }
.outcome-evidence { margin-bottom: var(--sp-3); }
.outcome-number-row { gap: var(--sp-2); }
.outcome-number-row input { min-width: 0; }
.inline-check { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--seaglass); }
.sheet-note { margin-bottom: var(--sp-4); line-height: 1.5; }

/* ------------------------------------------------------------------ foot */
.trends-foot {
  padding: var(--sp-4) var(--sp-3) var(--sp-1); text-align: center;
  font-size: var(--fs-note); line-height: 1.6; color: var(--ink-3);
}
.link-btn {
  appearance: none; border: 0; background: none; cursor: pointer; font: inherit;
  color: var(--accent-text); font-weight: 600;
  padding: 12px 2px; margin: -12px -2px;
  text-decoration: underline; text-underline-offset: 3px;
  text-decoration-color: color-mix(in srgb, var(--accent-text) 45%, transparent);
}
.link-btn:focus-visible { outline: 2px solid var(--accent-text); outline-offset: -6px; border-radius: var(--r-xs); }
