/* stress-picture.css — the Stress Picture (GLOSSARY.md, ADR-0124).
 *
 * The picture is painted only by the Pronunciation Bank, through a Picture
 * Handle, and it is styled only here: these rules were split between
 * `speaking-feedback-card.css` (named for a module the picture does not belong
 * to) and `word-pronunciation.css` (which overrode them), so a Task adopting
 * the Pronunciation Popover would have lost the picture's styling. Every page
 * that links either popover's stylesheet links this one after both, because
 * this sheet owns what those two used to override.
 *
 * The picture answers for its own state with its own attributes, written by
 * the handle or the drawing module: `data-prompt` (the prompt side, so the Try
 * it stroke wears the Speaking colour rather than the Issue Popover's red),
 * `data-fit` (a respelling that would otherwise be clipped), `data-sample-heard`,
 * `data-turn` and `data-sounding`. No ancestor's class decides anything here.
 */

/* The Stress Picture's three voices. The coach orbs immediately below are its
   legend; lettering is canonical and belongs directly to the Sample curve.

   `--stress-picture-ink` is the picture's own token for its lettering and
   marker, and is the one a host that links this sheet alone should set. It
   falls back to the Feedback Card's `--sfc-mark-ink` — the open issue's trait
   colour, written by the card's renderer and defined in
   `speaking-feedback-card.css` — so the Issue Popover keeps wearing the trait
   without setting anything new, and to `--ink` where neither is given. The
   fallback is written once, here, as the picture's own `color`: everything
   else the ink dresses takes it as `currentColor`. */
.stress-picture {
    display: flex;
    width: 100%;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    color: var(--stress-picture-ink, var(--sfc-mark-ink, var(--ink)));
}

.stress-picture svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

/* The gap band belongs to the picked take: it is on the picture only while a
   retake that missed is picked, so its presence is its own answer and no
   verdict elsewhere on the sheet decides whether it shows. */
.stress-picture-gap {
    fill: color-mix(in srgb, var(--rubric) 20%, transparent);
    opacity: 1;
}

.stress-picture-sample-line,
.stress-picture-yours-line,
.stress-picture-retry-line {
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.stress-picture-sample-line {
    fill: none;
    stroke: var(--good);
    stroke-width: 2.5;
    stroke-linejoin: round;
}

.stress-picture-sample-marker-path {
    fill: none;
    stroke: none;
    pointer-events: none;
}

.stress-picture-yours-line {
    stroke: var(--brand-purple-mid);
    stroke-width: 2.2;
    stroke-dasharray: 1 6;
}

.stress-picture-retry-line {
    stroke: var(--rubric);
    stroke-width: 2.5;
}

.stress-picture-sample-fill {
    fill: color-mix(in srgb, var(--good) 13%, transparent);
}

.stress-picture-retry-fill {
    fill: color-mix(in srgb, var(--rubric) 13%, transparent);
}

.stress-picture-sample-dot {
    fill: var(--good);
    stroke: var(--surface);
    stroke-width: 1.8;
}

.stress-picture-respelling {
    fill: var(--good);
    stroke: var(--surface);
    stroke-width: 5px;
    stroke-linejoin: round;
    paint-order: stroke;
    font-family: var(--font-ui);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-anchor: middle;
}

.stress-picture-respelling.stress-picture-syllable--primary {
    font-size: 18px;
    font-weight: 900;
    letter-spacing: 0.06em;
}

.stress-picture-marker {
    fill: currentColor;
    opacity: 0;
    pointer-events: none;
    transition: r 120ms ease;
}

.stress-picture[data-sounding] .stress-picture-marker { opacity: 1; }
.stress-picture[data-sounding="yours"] .stress-picture-marker { fill: var(--brand-purple-mid); }
.stress-picture[data-sounding="sample"] .stress-picture-marker { fill: var(--good); }
.stress-picture[data-sounding="retry"] .stress-picture-marker { fill: var(--rubric); }
.stress-picture-marker.is-arriving { animation: stress-picture-arrival 220ms ease-out; }

@keyframes stress-picture-arrival {
    50% { r: 7; }
}

.stress-picture-sample-layer,
.stress-picture-yours-layer,
.stress-picture-retry-layer,
.stress-picture-sample-line,
.stress-picture-yours-line {
    transition: opacity 180ms ease;
}

/* The Sample arrives only with its first hearing, then remains as the target. */
.stress-picture[data-sample-heard="false"] .stress-picture-sample-layer { opacity: 0; }

/* The sounding voice brings its contour forward without hiding the comparison.
   The shared reading aid changes colour with that same turn. */
.stress-picture[data-turn="yours"] .stress-picture-sample-layer {
    opacity: 0.48;
}

.stress-picture[data-turn="yours"] .stress-picture-sample-line {
    opacity: 0.68;
}

.stress-picture[data-turn="sample"] .stress-picture-yours-layer {
    opacity: 0.58;
}

.stress-picture[data-turn="sample"] .stress-picture-yours-line {
    opacity: 0.42;
}

.stress-picture[data-turn="retry"] .stress-picture-yours-layer { opacity: 0.38; }
.stress-picture[data-turn="retry"] .stress-picture-sample-layer { opacity: 0.68; }
.stress-picture[data-turn="retry"] .stress-picture-retry-layer { opacity: 1; }

/* Respelling belongs to Sample: it stays at rest once heard and steps out of
   the way only while Yours is sounding. */
.stress-picture[data-turn="yours"] .stress-picture-respelling { opacity: 0; }
.stress-picture[data-sample-heard="false"] .stress-picture-respelling { opacity: 0; }
.stress-picture[data-sample-heard="false"] .stress-picture-sample-layer { opacity: 0; }

/* ── The prompt side ─────────────────────────────────────────────────────────
   The Pronunciation Popover's picture says it is the prompt's with
   `data-prompt`, so what used to be that card's overrides is the picture's own
   second palette and lives here beside the first. */

/* Crop only the picture's horizontal viewBox gutters, so the SVG's green fill
   lands directly against the matching footer field below it. */
.stress-picture[data-prompt="true"] svg {
    width: 126%;
    max-width: none;
    margin: 0 0 0 -13%;
}

/* The picture says for itself whether its respelling fits (ADR-0124): a long
   edge syllable needs the cropped gutters back before the card's hidden
   overflow cuts it off. Only the SVG is restyled — the host is the card's.
   The fit is the picture's own measurement on either side, so this rule is not
   keyed on `data-prompt`: on the coaching side there is no crop to undo and it
   restates the base width, so the Issue Popover is free to grow a long
   respelling too without a second rule (#1045, Story 21). */
.stress-picture[data-fit="true"] svg {
    width: 100%;
    margin-left: 0;
}

/* The Try it take's stroke is drawn in the Speaking skill colour — the colour
   the Try it pill already wears — so the line is read as "yours" against the
   green Sample. The gap band keeps the verdict's red: it marks the miss, not
   the learner. */
.stress-picture[data-prompt="true"] .stress-picture-retry-line {
    stroke: var(--skill-color, var(--skill-speaking));
}

.stress-picture[data-prompt="true"] .stress-picture-retry-fill {
    fill: color-mix(in srgb, var(--skill-color, var(--skill-speaking)) 13%, transparent);
}

.stress-picture[data-prompt="true"][data-sounding="retry"] .stress-picture-marker {
    fill: var(--skill-color, var(--skill-speaking));
}
