/* coach.css — the Sunday verdict and the coach's record (js/coach.js,
 * docs/V35-PLAN.md §3.4, §3.5; round 2, move 2). Prefixed coach-.
 *
 * The kit (pills, the screen) is base.css's and is only placed here. Colours
 * are the tokens. Nothing is red: a coach's miss is not past a limit, so it
 * reads in ink with the word "outside". The two option cards sit side by side
 * where the column is wide enough and stack where it is not; the grid answers
 * to its container, never to the viewport. No text under 13px.
 */

.coach { display: grid; gap: 14px; min-width: 0; }

/* ------------------------------------------------------------ the cover --
 * The verdict takes the whole screen: the router's pushed screen, lifted over
 * the tab bar and the header, with its own close. It rises once, 360ms on the
 * settle curve, and scrolls inside itself; the coach's pick waits at the foot
 * over the ground. */
.screen.coach-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: block;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: env(safe-area-inset-top) 0 0;
  /* The ground with the person's glow in it (round 13): the cover sits over
   * the shell's glow layer, so it carries its own slice of it. */
  background: var(--ground-glow), var(--bg);
}
.screen.coach-screen > .screen-head,
.screen.coach-screen > .screen-title,
.screen.coach-screen > .screen-sub { display: none; }
.screen.coach-screen > .screen-body {
  width: 100%;
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 var(--pad);
}
/* On wide the verdict opens in the pane beside the face, as every pushed
 * screen does there (§3.4). The pane is a size container, so a `fixed`
 * cover inside it was laid out in the pane's own box and stacked under the
 * horizon's header and fades (z 2 and 3 in the page's own context): the
 * horizon's chrome painted over the verdict. In the pane it is the pane's
 * screen, in flow, the pane's own ground under it. */
@container pane (min-width: 1px) {
  .screen.coach-screen {
    position: static;
    inset: auto;
    z-index: auto;
    overflow: visible;
    padding: 0;
    background: none;
  }
  .screen.coach-screen > .screen-body { max-width: none; padding: 0; }
}
.screen.coach-screen.is-entering { animation: coach-rise var(--dur-settle) var(--ease-settle) both; }
@keyframes coach-rise { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }

.coach-verdict { gap: 0; padding-top: 10px; }
.coach-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: var(--tap);
  margin-bottom: 18px;
}
/* The kicker is Calibre's label line: what this is in the person's ink, the
 * week it judges in mono after a dot. */
.coach-kicker { margin: 0; font: var(--t-label); color: var(--accent-ink); }
.coach-kicker-date { color: var(--ink-2); }
.coach-kicker-date::before { content: " · "; color: var(--ink-2); }
.coach-close {
  position: relative;
  flex: none;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: var(--quiet-bg);
  color: var(--ink-2);
  cursor: pointer;
}
.coach-close::before { content: ""; position: absolute; inset: -4px; }
.coach-close .icon { width: 18px; height: 18px; stroke-width: 2.25; }
.coach-close:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }

/* The verdict: one line from the closed vocabulary, at 44, Geist's title
 * weight tracked as tight as a readout. */
.coach-headline {
  margin: 0;
  font: 600 calc(44 * var(--fz-xl))/1.02 var(--font);
  letter-spacing: -.035em;
  color: var(--ink);
  text-wrap: balance;
}
.coach-said { margin: 14px 0 0; font: 400 calc(16 * var(--fz))/1.42 var(--font); color: var(--ink-2); text-wrap: pretty; }
.coach-author { margin: 6px 0 0; font: var(--t-cap); color: var(--ink-3); }
.coach-question { margin: 12px 0 0; font: var(--t-body); color: var(--ink); text-wrap: pretty; }

/* The rate: the screen's one glass card (round 13). The honest figure at
 * Geist 200 with its unit in mono, the band beside it, and both on the
 * ruler under them. */
.coach-hero {
  --chart-ground: var(--surface);
  display: grid;
  gap: var(--s-3);
  margin-top: 22px;
  padding: var(--s-4);
}
.coach-rate {
  display: flex;
  flex-wrap: wrap;            /* a narrow card puts the band under the rate, never over it */
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--s-3) 16px;
}
.coach-rate-side { display: grid; gap: 6px; min-width: 0; }
.coach-rate-side.is-band { justify-items: end; text-align: right; }
.coach-rate-k { margin: 0; font: var(--t-label); color: var(--ink-2); }
.coach-rate-v {
  margin: 0;
  font: var(--num-figure);
  letter-spacing: var(--track-readout);
  color: var(--ink);
  white-space: nowrap;
}
.coach-rate-side.is-band .coach-rate-v { font: var(--num-cell); letter-spacing: var(--track-readout); }
.coach-rate-v .honest-unit { margin-left: 6px; font: var(--t-label); letter-spacing: 0; color: var(--ink-2); }
.coach-rate-none { margin: 0; font: var(--t-row); color: var(--ink-2); }

/* The ruler: never wider than the card; its scale said under it in mono. */
.coach-scale { display: grid; gap: 2px; min-width: 0; padding-top: var(--s-2); }
.coach-scale .ruler { justify-self: center; }
.coach-scale-cap { margin: 0; font: var(--t-label); color: var(--ink-2); text-align: right; }

/* Sections: a title and a quiet aside on one line. */
.coach-sec { display: grid; gap: 10px; min-width: 0; margin-top: 28px; }
.coach-sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.coach-sec-title { margin: 0; font: var(--t-head); letter-spacing: -.01em; color: var(--ink); }
.coach-sec-aside { font: var(--t-label); color: var(--ink-2); white-space: nowrap; }

/* The last call: the band as a fan with dashed edges in the mark, the trend
 * in ink drawn through it, its end dot, and the word it landed on. */
.coach-last-wrap { position: relative; margin: 4px 0 2px; }
.coach-last-plot { display: block; width: 100%; height: auto; overflow: visible; }
.coach-last-band { fill: var(--accent-fan); }
.coach-last-edge { fill: none; stroke: var(--accent-mark); stroke-width: 1.2; stroke-dasharray: 3 3; }
.coach-last-line {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.coach-last-end { fill: var(--ink); }
.coach-last-pill {
  position: absolute;
  right: 4px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 26px;
  padding: 0 11px;
  border-radius: 13px;
  background: var(--ink);
  color: var(--bg);
  font: 600 var(--t-cap-size)/1 var(--font);
  white-space: nowrap;
}
.coach-last-pill.is-inside { padding-left: 8px; }
.coach-last-pill .icon { width: 14px; height: 14px; stroke-width: 2.6; }
.coach-last-cap { margin: 0; font: var(--t-sub); color: var(--ink-2); text-wrap: pretty; }
.coach-last-cap b,
.coach-ribbon-cap b { color: var(--ink); font-weight: 600; }

/* The record ribbon: one capsule per graded call. Its band is the inner bar;
 * the measured value a dot, filled when inside, a ring at the capsule's end
 * when outside; the newest graded call's dot in the mark. The open call is
 * dashed, its band in the accent's band tint. */
.coach-ribbon { display: flex; flex-wrap: wrap; gap: 8px; }
.coach-cap {
  position: relative;
  flex: none;
  width: 26px;
  height: 52px;
  border-radius: 13px;
  background: var(--surface-2);
}
.coach-cap-band {
  position: absolute;
  left: 5px;
  top: 15px;
  width: 16px;
  height: 22px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--ink) 16%, transparent);
}
.coach-cap-dot {
  position: absolute;
  left: 50%;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--ink);
  transform: translate(-50%, -50%);
}
.coach-cap-dot.is-out { width: 10px; height: 10px; background: var(--bg); box-shadow: inset 0 0 0 2px var(--ink); }
.coach-cap-dot.is-new { background: var(--accent-mark); }
.coach-cap-dot.is-out.is-new { background: var(--bg); box-shadow: inset 0 0 0 2px var(--accent-mark); }
.coach-cap.is-open { background: transparent; border: 1.5px dashed var(--edge); }
.coach-cap.is-open .coach-cap-band { left: 3.5px; top: 13.5px; background: var(--accent-band); }
.coach-ribbon-labels {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font: var(--t-label);
  color: var(--ink-2);
}
.coach-ribbon-cap { margin: 0; font: var(--t-sub); color: var(--ink-2); text-wrap: pretty; }

/* The next two weeks: two priced options, side by side where they fit. The
 * coach's pick is ringed in ink, not the accent: an option is a choice, not
 * a person. The one the owner chose wears the wash. */
.coach-options { display: grid; gap: 10px; grid-template-columns: minmax(0, 1fr); }
.coach-options.is-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.coach-option {
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
  padding: 12px 14px 14px;
  border-radius: var(--r-tile);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line);
}
.coach-option.is-recommended { box-shadow: inset 0 0 0 2px var(--ink); }
.coach-option.is-chosen { background: var(--accent-wash); }
.coach-option-title { margin: 0; font: 600 calc(16 * var(--fz))/1.25 var(--font); color: var(--ink); overflow-wrap: anywhere; }
.coach-option-range {
  margin: 2px 0 0;
  font: var(--num-cell);
  letter-spacing: var(--track-readout);
  color: var(--ink);
}
.coach-option-unit { font: var(--t-label); letter-spacing: 0; color: var(--ink-2); }
.coach-option-pick { margin: 0; font: 600 var(--t-cap-size)/1.35 var(--font); color: var(--ink); }
.coach-option-pred,
.coach-option-gov { margin: 0; font: var(--t-cap); color: var(--ink-2); text-wrap: pretty; }

.coach-status,
.coach-notice { margin: 18px 0 0; font: var(--t-sub); color: var(--ink); text-wrap: pretty; }
.coach-notice:empty { display: none; }
.coach-why { margin: 14px 0 0; font: 400 var(--t-body-size)/1.45 var(--font); color: var(--ink-2); text-wrap: pretty; }
.coach-said + .coach-why { margin-top: 8px; font-size: var(--t-sub-size); }
.coach-math-note { margin: 0 0 10px; font: var(--t-sub); color: var(--ink-2); text-wrap: pretty; }

/* Show the math: collapsed, a full tap target with a chevron that turns. */
.coach-math { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 4px; }
.coach-math-head {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  cursor: pointer;
  font: 500 var(--t-sub-size)/1.2 var(--font);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
.coach-math-head::-webkit-details-marker { display: none; }
.coach-math-chev { display: inline-flex; margin-left: auto; color: var(--ink-3); transition: transform var(--dur-move) var(--ease-settle); }
.coach-math-chev svg { width: 18px; height: 18px; }
.coach-math[open] .coach-math-chev { transform: rotate(90deg); }
.coach-math-head:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; border-radius: 6px; }
.coach-math-list { display: grid; gap: 8px; margin: 4px 0 0; }
.coach-math-row { display: grid; grid-template-columns: minmax(96px, 30%) 1fr; gap: 10px; min-width: 0; }
.coach-math-k { font: var(--t-label); line-height: 1.4; color: var(--ink-2); }
.coach-math-v { margin: 0; font: var(--t-sub); color: var(--ink-2); text-wrap: pretty; overflow-wrap: anywhere; }

/* The action bar, at the foot under the last option: the coach's pick
 * filled, the other way quiet, Not now in words. Not sticky (UX audit F5-b):
 * pinned over the page it covered half of the first priced option, which is
 * the point of the screen; under the options it is where the reading ends. */
.coach-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px 10px;
  margin: 10px 0 0;
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
}
.coach-actions.is-pair { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.coach-actions .pill-btn { height: 56px; min-height: 56px; font-size: calc(17 * var(--fz)); }
.coach-actions .pill-btn.coach-later {
  grid-column: 1 / -1;
  height: var(--tap);
  min-height: var(--tap);
  background: transparent;
  box-shadow: none;
  color: var(--ink-2);
  font-size: var(--t-body-size);
}
.coach-actions:empty { display: none; }

/* The first showing (once per check-in): the trend draws into the band over
 * 900ms, its end dot follows, the word rises 4px into place, and this call's
 * capsule slides up into the ribbon. Every later open is still. */
.coach-verdict.is-first .coach-last-line {
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: draw var(--dur-draw) var(--ease-settle) 300ms forwards;
}
.coach-verdict.is-first .coach-last-end { opacity: 0; animation: coach-show var(--dur-move) var(--ease-settle) 1150ms forwards; }
.coach-verdict.is-first .coach-last-pill {
  opacity: 0;
  transform: translateY(4px);
  animation: coach-land var(--dur-settle) var(--ease-settle) 1250ms forwards;
}
.coach-verdict.is-first .coach-cap.is-newest {
  opacity: 0;
  transform: translateY(10px);
  animation: coach-land var(--dur-settle) var(--ease-settle) 1550ms forwards;
}
@keyframes coach-show { to { opacity: 1; } }
@keyframes coach-land { to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .screen.coach-screen.is-entering,
  .coach-verdict.is-first .coach-last-line,
  .coach-verdict.is-first .coach-last-end,
  .coach-verdict.is-first .coach-last-pill,
  .coach-verdict.is-first .coach-cap.is-newest { animation: none; opacity: 1; transform: none; stroke-dashoffset: 0; }
  .coach-math-chev { transition: none; }
}

/* The record. Its head: the live calls inside their band as one Geist 200
 * readout ("2 of 3"), the label in mono, the verdict's ribbon under it. */
.coach-record-head {
  display: grid;
  gap: var(--s-2);
  padding: var(--s-2) 0 var(--s-5);
  border-bottom: 1px solid var(--line);
}
.coach-record-k { margin: 0; font: var(--t-label); color: var(--ink-2); }
.coach-record-fig {
  margin: 0 0 var(--s-2);
  font: var(--t-display);
  letter-spacing: var(--track-readout);
  color: var(--ink);
}
.coach-record-of { margin-left: 4px; font: var(--t-label); letter-spacing: 0; }
/* Under ten graded: a tally, not a verdict. The figure goes quiet and says
 * why beside it. */
.coach-record-head.is-few .coach-record-fig { color: var(--ink-2); }
.coach-record-few { margin-left: var(--s-3); font: var(--t-label); letter-spacing: 0; color: var(--ink-2); }

.coach-record-sec { display: grid; gap: 8px; }
.coach-record-line { margin: 0; font: var(--t-body); color: var(--ink-2); text-wrap: pretty; }
.coach-record-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.coach-record-row {
  display: grid;
  /* The week column is one width down the list (the longest week, "28 Sep
   * to 4 Oct", in mono), so the calls line up as a table. */
  grid-template-columns: 10px 8.6em minmax(0, 1fr) auto;
  gap: 10px;
  align-items: baseline;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  font: var(--t-sub);
}
/* The grade as the ribbon draws it: a dot inside, a ring outside, a dashed
 * ring still open; all in ink (a miss is not past a limit). */
.coach-record-mark {
  align-self: center;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.5px var(--ink-2);
}
.coach-record-row.is-inside .coach-record-mark { background: var(--ink); box-shadow: none; }
.coach-record-row.is-open .coach-record-mark { box-shadow: none; border: 1.5px dashed var(--edge); }
.coach-record-week { font: var(--t-label); line-height: 1.4; color: var(--ink-2); white-space: nowrap; }
.coach-record-what { color: var(--ink); min-width: 0; overflow-wrap: anywhere; }
.coach-record-grade { color: var(--ink-2); white-space: nowrap; }

@container (max-width: 300px) {
  /* A zoomed card: the band takes its own line, read from the left, and a
   * figure may wrap its unit under it. */
  .coach-rate-side.is-band { justify-items: start; text-align: left; }
  .coach-rate-v { white-space: normal; }
  .coach-options.is-pair,
  .coach-actions.is-pair { grid-template-columns: minmax(0, 1fr); }
  .coach-math-row { grid-template-columns: 1fr; gap: 2px; }
  .coach-record-row { grid-template-columns: 10px minmax(0, 1fr); gap: 2px 10px; }
  .coach-record-row > :not(.coach-record-mark) { grid-column: 2; }
}

/* ---- the proactive coach (cli/noticed.py, cli/ask_why.py) ----
 * "Why?" under the author line, and its answer in the why's own voice;
 * "What I noticed", the week's reading, in ink: the coach's reading is not a
 * measurement and nothing in it is past a limit, so nothing here is red. */
.coach-whyask { margin: 10px 0 0; }
.coach-whyask-btn { min-height: 44px; }
.coach-whyask.is-said { display: grid; gap: 4px; padding-left: var(--s-3); border-left: 2px solid var(--line); }
.coach-whyask-said { margin: 0; font: 400 var(--t-sub-size)/1.45 var(--font); color: var(--ink); text-wrap: pretty; }
.coach-whyask-by { margin: 0; font: var(--t-cap); color: var(--ink-3); }

.coach-noticed { display: grid; gap: var(--s-3); margin: 0; padding: 0; list-style: none; }
.coach-noticed-item { display: grid; gap: 6px; min-width: 0; padding: 0 0 var(--s-3); border-bottom: 1px solid var(--line); }
.coach-noticed-item:last-child { padding-bottom: 0; border-bottom: 0; }
.coach-noticed-claim { margin: 0; font: 500 var(--t-body-size)/1.4 var(--font); color: var(--ink); text-wrap: pretty; }
.coach-noticed-ev { margin: 0; font: var(--t-sub); color: var(--ink-2); text-wrap: pretty; }
.coach-noticed-try { margin: 0; font: var(--t-sub); color: var(--ink); text-wrap: pretty; }
.coach-noticed-k { display: block; margin-bottom: 2px; font: var(--t-label); color: var(--ink-3); }
.coach-noticed-conf { margin: 0; font: var(--t-cap); color: var(--ink-3); }
.coach-noticed-cap { margin: 0; font: var(--t-cap); color: var(--ink-3); }
