/* speaking-feedback-card.css — the Speaking Feedback Card (PRD #721).
 *
 * One component, two states: `.sfc--compact` is the row in the attempt list,
 * `.sfc--expanded` the full card it morphs into. The same nodes wear both — the
 * card grows, it is not rebuilt — so nearly every rule below is a size or a
 * tint that `.sfc--expanded` restates, and the morph (in the JS) is a plain
 * FLIP over what changed. Geometry ported from the mockup
 * (`docs/feedback-ui-(re)design/speaking-feedback-card/`), colours from tokens.
 *
 * Local custom properties the renderer writes inline:
 *   --sfc-bar-height / --sfc-bar-weight / --sfc-bar-colour   one waveform bar
 *   --sfc-orb-arc / --sfc-orb-colour                         one ring's share
 *                                                            of the turn, and
 *                                                            the Trait's hue
 *   --sfc-passage-size                                       expanded passage
 */

.speaking-attempt-history {
    display: flex;
    width: 100%;
    flex-direction: column;
    gap: 12px;
}

/* The frame's tactile buttons paint a raised base below their layout box.
   Keep the first attempt clear of that painted edge as well as the control
   row's nominal box. */
.attempt-history-region:has(> .speaking-attempt-history) {
    padding-top: 12px;
}

/* The open or in-flight attempt is the review workbench. Earlier takes recede
   as context without competing for attention.

   Opacity only: this is a closed accordion row saying it is closed, which is
   what a dim already says. The blur that used to sit here contradicted the
   word "legible" in this comment's earlier draft, and it animated a filter on
   every open and close — the expensive way to say a cheap thing (ADR-0091).
   Removing it leaves these rows sharper at the same 0.42, which is the number
   to revisit first if the list now reads too busy. */
.speaking-attempt-history.is-attempt-focused > .sfc:not(.sfc--expanded):not(.sfc--pending) {
    opacity: 0.42;
    transition: opacity 180ms ease;
}

/* ── The in-flight attempt ──────────────────────────────────────────────── */

.sfc.sfc--pending {
    display: flex;
    min-height: 152px;
    flex-direction: column;
    gap: 16px;
    padding: 16px;
    border-color: color-mix(in srgb, var(--rubric) 24%, var(--border));
    border-radius: var(--radius);
    background: color-mix(in srgb, var(--surface) 94%, var(--rubric));
    box-shadow: var(--shadow);
    animation: sfc-attempt-arrive 280ms cubic-bezier(0.19, 1, 0.22, 1);
}

.sfc-pending-status {
    display: flex;
    align-items: baseline;
    justify-content: flex-start;
    gap: 8px;
    color: var(--ink);
}

.sfc--pending .sfc-orb {
    pointer-events: none;
}

/* A reserved row's rings wait in the shared breath: `.score-ring.is-waiting`
   in main.css, which the renderer asks for by class. A full flat track that
   breathes — no arc, so nothing reads as a low score; one duration and no
   per-ring delay, so the four start together and stay together (#936 stories
   11-12); a still track under `prefers-reduced-motion` (story 13). What used
   to be here was a sweep crawling round the rim at 1.8s, which said the wait
   was measurable and drew four rims chasing each other.

   The figure is withheld the card's own way, because the figure is the card's
   own: `.sfc-orb-number`, not the shared `.score-ring-figure` the waiting rule
   hides. */
.sfc--pending .sfc-orb-number {
    opacity: 0;
}

.sfc-pending-title {
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 700;
}

.sfc-pending-copy {
    font-family: var(--font-ui);
    font-size: 13px;
    line-height: 1.4;
    color: var(--ink-muted);
}

.sfc--arriving {
    animation: sfc-attempt-arrive 360ms cubic-bezier(0.19, 1, 0.22, 1);
}

@keyframes sfc-attempt-arrive {
    from { opacity: 0; transform: translateY(12px) scale(0.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 768px) {
    .sfc.sfc--pending {
        min-height: 132px;
        padding: 16px;
    }

    .sfc.sfc--pending .sfc-head {
        align-items: flex-start;
        gap: 12px;
    }

    .sfc-pending-status {
        align-items: center;
        flex-direction: column;
        gap: 4px;
    }
}

/* The waiting ring's own stillness is `.score-ring.is-waiting`'s to declare,
   next to the breath it stills; what is left here is the card's arrival. */
@media (prefers-reduced-motion: reduce) {
    .sfc--pending,
    .sfc--arriving {
        animation: none;
    }
}

/* ── The row ─────────────────────────────────────────────────────────────── */

.sfc {
    position: relative;
    display: flex;
    box-sizing: border-box;
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    background: var(--surface);
    font-family: var(--font-ui);
    transition: box-shadow 0.2s;
}

.sfc--compact {
    align-items: stretch;
    gap: 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.sfc--compact:hover {
    box-shadow: var(--shadow-sm);
}

.sfc--expanded {
    flex-direction: column;
    gap: 24px;
    padding: 16px;
    border-radius: var(--radius);
    cursor: default;
}

/* The head is the numeral alone on a row, and the numeral beside the HUD pill
   on the card — the pill is the one node that changes parent. */
.sfc-head {
    display: flex;
    flex: none;
    align-items: center;
    gap: 20px;
}

.sfc--expanded .sfc-head {
    margin-right: 32px;
}

/* ── The way out (PRD story 4) ───────────────────────────────────────────── */

.sfc-close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    box-sizing: border-box;
    border: 1px solid var(--score-divider);
    border-radius: 50%;
    background: color-mix(in srgb, var(--surface-sunken) 78%, var(--surface));
    color: var(--ink-muted);
    font-family: var(--font-ui);
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 1px 2px color-mix(in srgb, var(--ink) 8%, transparent);
    transition:
        color 0.15s,
        background 0.15s,
        border-color 0.15s,
        box-shadow 0.15s,
        transform 0.15s;
}

/* The card's ✕ is the icon set's close mark (#832). It tints with the button,
   so the white-on-rubric hover below needs no rule of its own. */
.sfc-close .nav-icon {
    --nav-icon-size: 11px;
}

.sfc-close:hover {
    border-color: var(--rubric);
    background: var(--rubric);
    color: var(--surface);
    box-shadow: 0 3px 8px color-mix(in srgb, var(--rubric) 24%, transparent);
    transform: translateY(-1px);
}

.sfc-close:active {
    border-color: var(--rubric);
    background: color-mix(in srgb, var(--rubric) 88%, var(--ink));
    color: var(--surface);
    box-shadow: none;
    transform: translateY(0);
}

.sfc-close:focus-visible {
    outline: 2px solid var(--rubric);
    outline-offset: 2px;
}

/* ── Attempt number and date ─────────────────────────────────────────────── */

.sfc-attempt {
    display: flex;
    flex: none;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
    padding: 4px 20px;
    border-right: 1px solid var(--border);
}

.sfc--expanded .sfc-attempt {
    padding: 4px 28px 4px 16px;
}

.sfc-attempt-caption {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--ink-faint);
}

.sfc-attempt-number {
    display: flex;
    align-items: baseline;
    gap: 1px;
    font-family: var(--font-passage);
    font-size: 42px;
    font-weight: 600;
    line-height: 0.86;
    letter-spacing: -0.03em;
    font-variant-numeric: lining-nums tabular-nums;
}

.sfc-attempt-hash {
    font-size: 0.52em;
    font-weight: 500;
    letter-spacing: 0;
    color: var(--ink-faint);
    transform: translateY(-0.16em);
}

.sfc-attempt-date {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
    letter-spacing: 0.05em;
    white-space: nowrap;
    color: var(--ink-muted);
}

/* ── Body: player + HUD above, passage below ─────────────────────────────── */

.sfc-body {
    display: flex;
    flex: 1;
    min-width: 0;
    flex-direction: column;
    gap: 12px;
}

.sfc-top {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* On the card the passage leads and the player sits under it (audioPosition
   below, the design's default); `above` puts the player back on top. */
.sfc--expanded .sfc-body {
    gap: 24px;
}

.sfc--expanded .sfc-body[data-audio-position="below"] .sfc-passage {
    order: 1;
}

.sfc--expanded .sfc-body[data-audio-position="below"] .sfc-top {
    order: 2;
}

/* ── Mini voice-note player ──────────────────────────────────────────────── */

.sfc-audio {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
    box-sizing: border-box;
    padding: 8px 20px 8px 8px;
    border: 1px solid var(--score-divider);
    border-radius: var(--radius-sm);
    background: var(--surface-sunken);
}

.sfc-play {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    box-sizing: border-box;
    border: 1.5px solid var(--ink);
    border-radius: 50%;
    background: transparent;
    color: var(--ink);
    line-height: 1;
    cursor: pointer;
}

/* The transport mark is the icon set's (#832), at the 12px the glyph before it
   was set to. The ink is the button's and reaches the artwork through
   `currentColor`, so the disabled fade below dims the mark with it. */
.sfc-play .nav-icon {
    --nav-icon-size: 12px;
}

.sfc-play[disabled] {
    opacity: 0.35;
    cursor: default;
}

.sfc-wave {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1px;
    height: 18px;
    flex: 1 1 auto;
    min-width: 60px;
    overflow: hidden;
}

.sfc-wave-bar {
    flex: none;
    width: var(--sfc-bar-weight, 2.5px);
    border-radius: var(--sfc-bar-weight, 2.5px);
    height: var(--sfc-bar-height, 30%);
    /* Unplayed grey → played ink is the voice-note idiom; a marked bar carries
       its Trait's colour instead, muted until the playhead reaches it. */
    min-height: 2px;
    background: color-mix(in srgb, var(--ink-muted) 24%, var(--surface));
    transition: background 0.12s linear;
}

.sfc-wave-bar[data-trait] {
    background: color-mix(in srgb, var(--sfc-bar-colour) 45%, var(--surface));
}

.sfc-wave-bar.is-played {
    background: var(--trait-overall);
}

.sfc-wave-bar[data-trait].is-played {
    background: var(--sfc-bar-colour);
}

.sfc-wave-bar.is-silent {
    opacity: 0.72;
}

/* Expanded, the prototype's voice-note trace is deliberately dense. Compact
   rows keep every second column hidden so the same DOM can shrink without the
   bars closing into a solid block. */
.sfc--compact .sfc-wave-bar:nth-child(even) {
    display: none;
}

.sfc-time {
    flex: none;
    white-space: nowrap;
    font-family: var(--font-mono);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    color: var(--ink-muted);
}

.sfc-audio-element {
    display: none;
}

/* Full size on the card: a bigger button, a taller wave, and the tinted panel
   the design asks for (audioChrome tinted). */
.sfc--expanded .sfc-audio {
    gap: 16px;
    padding: 8px 20px 8px 12px;
}

.sfc--expanded[data-audio-chrome="plain"] .sfc-audio {
    border-color: transparent;
    background: transparent;
}

.sfc--expanded .sfc-play {
    width: 36px;
    height: 36px;
    font-size: 12px;
}

.sfc--expanded .sfc-wave {
    height: 32px;
}

/* Even a quiet recording is a continuous signal, not a handful of isolated
   coloured ticks. A fine centre line anchors the trace while the neutral bars
   remain visible around the scored peaks. */
.sfc--expanded .sfc-wave::before {
    content: "";
    position: absolute;
    right: 0;
    left: 0;
    top: 50%;
    height: 1px;
    background: color-mix(in srgb, var(--ink-muted) 16%, transparent);
}

.sfc--expanded .sfc-wave-bar {
    position: relative;
    z-index: 1;
    width: max(2px, var(--sfc-bar-weight, 2.5px));
}

/* ── Mini orb HUD ────────────────────────────────────────────────────────── */

.sfc-hud {
    display: flex;
    flex: none;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: var(--pill);
    background: var(--surface-sunken);
}

/* A history row gives the recording and its score summary equal billing.
   Without an explicit share the HUD sizes itself from all four labels and
   squeezes the waveform down to a token sliver. */
.sfc--compact .sfc-audio,
.sfc--compact .sfc-hud {
    flex: 1 1 calc(50% - 4px);
    width: calc(50% - 4px);
}

.sfc--compact .sfc-hud {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    justify-items: stretch;
    min-width: 0;
    gap: 2px;
    padding: 4px 6px;
}

.sfc--compact .sfc-orb {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    gap: 3px;
    padding: 4px 2px;
    text-align: center;
}

.sfc--compact .sfc-orb--overall {
    margin-right: 0;
    padding-right: 4px;
}

/* The compact tier's ring, and the tier rule that has to outrank the base
   opt-in below: that one now names `.score-ring` too, so this one does the
   same to stay above it. Specificity, not source order — the same settlement
   `.score-orb.score-ring` made in css/main.css. */
.sfc--compact .sfc-orb-ring.score-ring {
    --ring-size: 32px;
    --ring-thickness: 4px;
}

.sfc--compact .sfc-orb--overall:not(.sfc-orb--verdict) .sfc-orb-ring {
    --ring-size: var(--sfc-orb-overall-compact);
    --ring-thickness: 4px;
}

.sfc--compact .sfc-orb-label,
.sfc--compact .sfc-orb-delta {
    max-width: 100%;
    font-size: clamp(9px, 1.05vw, 11px);
    line-height: 1.15;
    white-space: normal;
    overflow-wrap: anywhere;
}

.sfc--compact .sfc-orb-label,
.sfc--compact .sfc-orb-delta {
    align-self: center;
}

.sfc--compact .sfc-orb-delta {
    margin-top: 0;
}

.sfc-orb {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px 4px 4px;
    border-radius: var(--pill);
}

/* Overall is the total, not a fourth Trait. Its ring is drawn larger than a
   Trait's in every state, which is how #835 is answered: nothing is
   re-parented, Overall keeps its place in the pill and its separator, and the
   Card Morph's keys and choreography carry on unchanged (#936 stories 8-9,
   17).

   The two sizes are written here, once, and read by the compact tier, the
   expanded tier and the phone tier below — the three places that each used to
   equalise Overall with the Traits on their own. Each hole is its ring less
   8px, the 4px stroke a Trait ring already wears on both sides at both sizes,
   so the hole follows the ring instead of being a number kept in step by
   hand.

   Answer Short Question's verdict orb wears `--overall` for this stand-off and
   for its hand-written morph key, but it is not a total: it has no arc and no
   figure, and it gains nothing here (#936 story 18). Every rule that grows
   Overall steps around `.sfc-orb--verdict`. */
.sfc-orb--overall {
    --sfc-orb-overall-compact: 36px;
    --sfc-orb-overall-expanded: 60px;
    margin-right: 8px;
    padding-right: 12px;
    border-right: 1px solid var(--score-divider);
}

/* The compact row always reads as the Overall view, whatever Trait the
   expanded card left selected, so two rows are comparable (PRD story 16).

   Selection is drawn as a raised chip ONLY where it can change: the expanded
   and pending tiers below, where a Trait is picked by click. This rule used to
   paint the same white chip and shadow on every `.is-selected` orb, so the
   compact pill — where Overall is always the selected orb and nothing can be
   picked — wore it too: a white surround squeezed into the compact orb's
   4px 2px padding around a 36px ring, cramped against its own label and the
   divider (owner, 2026-10-29). Overall is already told apart in that row by
   its larger ring and its divider, so the compact pill draws no chip. */

/* The card's readouts are Scores, so they are drawn in the one ring form
   (`.score-ring` in main.css, ADR-0108) rather than in this file's own copy of
   it. What used to be here was the geometry, the conic arc and a `.sfc-orb-hole`
   node — the same idea main.css draws for the Profile Home and the Marks orbs,
   restated a fourth time, which is the arrangement ADR-0009 records drifting on
   six properties in a week with every suite green.

   Opting in is the class plus these tokens. The hole comes with the form: it is
   drawn behind the figure rather than cut out of the ring, "so a family can
   adopt the form without adding a node to its markup", so the node this card
   used to nest is gone and the number sits straight in the ring.

   What stays the card's is what is genuinely the card's: the figure below and
   its per-state typography, the Trait's hue, the selection, and the withheld
   dash. The half-pixel holes the mockup pinned (DECISIONS §7) went with the
   node — every state this card actually renders is compact or expanded and
   wears an even 4px stroke from its own tier. The 4.25px here and the 4.75px
   below are what is left of them: the defaults an orb in neither tier would
   read, which is no orb this card draws today. Answer Short Question's verdict
   is not that orb — it is compact-only, so it takes the compact tier's 32px
   like any other ring in that row.

   The selector names BOTH classes, and has to, for the reason
   `.score-orb.score-ring` gives in css/main.css: `.score-ring` sets these same
   tokens as the form's own defaults at (0,1,0), so a bare `.sfc-orb-ring`
   here won only because this stylesheet's <link> comes after main.css. Three
   families held their sizes that way and one of them had already lost its hue
   to it. tests/unit/js/orb-vocabulary.test.js works the cascade out, over the
   sheets concatenated in load order. */
.sfc-orb-ring.score-ring {
    --ring-size: 38px;
    --ring-thickness: 4.25px;
    --ring-color: var(--sfc-orb-colour);
    --ring-track: var(--score-placeholder);
    /* The arc's share, still under the card's own name because the card is
       what computes it — and because Answer Short Question's page sets it to a
       whole turn for a verdict, which has no percentage to draw
       (`Speaking/Answer_Short_Question.css`). It is read into the shared token
       rather than copied into a second gradient, so there is one number. */
    --ring-fill: var(--sfc-orb-arc, 0deg);
    /* Every hole on this card is the card's own ground, in every state and
       whether the orb is selected or not. */
    --ring-hole: var(--surface);
}

/* The verdict is stepped around here as it is in the compact and expanded
   tiers. Left off, this rule was the ONE Overall-growing rule that did not:
   at (0,2,0) it tied the compact tier's ring and sat later in the file, so
   Answer Short Question's verdict — a compact-only orb, so this is its only
   state — rendered at 42px where main renders 32px (#936 story 18). */
.sfc-orb--overall:not(.sfc-orb--verdict) .sfc-orb-ring {
    --ring-size: 42px;
    --ring-thickness: 4.75px;
}

.sfc-orb-number {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: -0.02em;
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    color: var(--sfc-orb-colour);
}

.sfc-orb-label {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ink-muted);
}

/* The improvement a passed Content retry earned (#732, story 45). It sits
   under the label, in the Trait's own colour, and never touches the number in
   the ring: the Score of the attempt is the Score of the attempt (story 46). */
.sfc-orb-delta {
    margin-top: 4px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--good);
    white-space: nowrap;
}

.sfc-orb.is-withheld .sfc-orb-number {
    color: var(--ink-faint);
}

/* ── The expanded HUD: Home's score capsule ────────────────────────── */
/* Like Home, the four scores read as one rounded instrument. Wide cards keep
   each label beside its ring; the phone tier below keeps them on the same
   line and lets the line scroll. The stronger rule after Overall separates
   the aggregate from the three scoring Traits.

   The instrument is a `.score-ring-row` (main.css, ADR-0108): four rings on
   one line, and where they cannot all fit the line scrolls sideways with part
   of the next ring showing and settles near a ring rather than snapping hard
   (#936 stories 15-16). It used to fold into a 2×2 grid under 640px, which
   story 15 forbids — a wrapped row stops reading as a row, and these four are
   read as one comparison. The row supplies the direction, the no-wrap, the
   scrollport, the peek and the snap; what is set here is the pill this card
   draws round them.

   The pill was kept over the transparent row of #897 on 2026-09-05, because
   Home's own `.profile-scores` is a sunken pill with a hairline and a shadow
   and this row claims that rhyme; the mobile feature step asserts it. */

:is(.sfc--expanded, .sfc--pending) .sfc-hud {
    flex: 1 1 100%;
    min-width: 0;
    width: 100%;
    align-items: center;
    gap: 0;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-sunken);
    box-shadow: var(--shadow-sm);
}

/* Above the phone tier the four always fit, so there is nothing to scroll to —
   and a scrollport here would clip the Card Morph, which flies each orb across
   the card from where it stood in the other state's pill (story 17). So this
   tier, and only this tier, keeps the HUD open and shares its width out four
   ways, which is what the grid it replaced was for. */
@media (min-width: 641px) {
    .sfc-hud {
        overflow: visible;
    }

    :is(.sfc--expanded, .sfc--pending) .sfc-orb {
        flex: 1 1 0;
    }
}

:is(.sfc--expanded, .sfc--pending) .sfc-orb {
    flex-direction: row;
    justify-content: center;
    min-width: 0;
    gap: 8px;
    margin: 0;
    padding: 4px 12px;
    border: 0;
    border-radius: 0;
    text-align: left;
    cursor: pointer;
}

/* The active Trait gets Home's inset control treatment inside the shared
   capsule; the shell stays put while the selected orb lifts from it. */
:is(.sfc--expanded, .sfc--pending) .sfc-orb.is-selected {
    border-radius: 999px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    transform: none;
}

:is(.sfc--expanded, .sfc--pending) .sfc-orb--overall {
    margin: 0;
    padding: 4px 12px;
    border-right: 2px solid color-mix(in srgb, var(--ink) 34%, var(--border));
}

:is(.sfc--expanded, .sfc--pending) .sfc-orb--overall .sfc-orb-label {
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

:is(.sfc--expanded, .sfc--pending) .sfc-orb-ring.score-ring {
    --ring-size: 54px;
    --ring-thickness: 4px;
}

:is(.sfc--expanded, .sfc--pending) .sfc-orb--overall:not(.sfc-orb--verdict) .sfc-orb-ring {
    --ring-size: var(--sfc-orb-overall-expanded);
}

/* An unselected ring in the open card sets its remainder against the panel's
   line rather than the placeholder grey — the one thing that differs from the
   ring at rest, and so the one token this state sets. */
.sfc--expanded .sfc-orb:not(.is-selected) .sfc-orb-ring {
    --ring-track: var(--border);
}

:is(.sfc--expanded, .sfc--pending) .sfc-orb-number,
:is(.sfc--expanded, .sfc--pending) .sfc-orb--overall .sfc-orb-number {
    font-size: 21px;
}

:is(.sfc--expanded, .sfc--pending) .sfc-orb-label {
    font-size: 13px;
    white-space: nowrap;
}

/* At rest an orb reads in the HUD's own ink; selected, it takes the Trait's
   colour, which is what makes the selection legible without a second badge. */
.sfc--expanded .sfc-orb:not(.is-selected) .sfc-orb-number,
.sfc--expanded .sfc-orb:not(.is-selected) .sfc-orb-label {
    color: var(--ink-muted);
}

.sfc--expanded .sfc-orb.is-selected .sfc-orb-label {
    color: var(--sfc-orb-colour);
}

/* ── Passage ─────────────────────────────────────────────────────────────── */

.sfc-passage {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 8px;
    margin: 0;
    padding: 0 4px;
    font-family: var(--font-passage);
    font-size: 18px;
    font-weight: 500;
    line-height: 1.2;
    letter-spacing: -0.015em;
    color: var(--ink);
}

.sfc-chunk {
    display: inline-block;
    box-sizing: border-box;
    padding: 0 4px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
}

.sfc-chunk--run {
    display: inline-flex;
    align-items: baseline;
    gap: 8px;
}

/* A mark's Trait names two colours: the ink an underline is drawn in, and the
   fill a tinted box takes. One rule per Trait, both roles at once, so the two
   mark styles never drift apart. The popover is in the list because as a bottom
   sheet it is moved out of the mark it belongs to (#733) and cannot inherit the
   Trait any more; it carries `data-trait` either way. */
.sfc-chunk[data-trait="content"],
.sfc-word[data-trait="content"],
.sfc-pop[data-trait="content"] {
    --sfc-mark-ink: var(--trait-content);
    --sfc-mark-fill: color-mix(in srgb, var(--trait-content) 20%, var(--surface));
}

.sfc-chunk[data-trait="pronunciation"],
.sfc-word[data-trait="pronunciation"],
.sfc-pop[data-trait="pronunciation"] {
    --sfc-mark-ink: var(--trait-pronunciation);
    --sfc-mark-fill: color-mix(in srgb, var(--trait-pronunciation) 16%, var(--surface));
}

.sfc-chunk[data-trait="fluency"],
.sfc-word[data-trait="fluency"],
.sfc-pop[data-trait="fluency"] {
    --sfc-mark-ink: var(--trait-fluency);
    --sfc-mark-fill: color-mix(in srgb, var(--trait-fluency) 16%, var(--surface));
}

/* Compact marks are faint underlines: the row stays quiet, the expanded card
   gets tinted boxes (PRD story 19).

   One line per mark, so one owner per mark. A word issue is the word's, and a
   fluency run's is the run's — the chunk only draws when it is a run. Listing
   the plain `.sfc-chunk` here drew twice under a single-word chunk, because
   `paintMarks` mirrors a lone word's mark onto the chunk around it: the word's
   line, and the chunk's 4px wider one under it (#760). */
.sfc-passage[data-mark-style="underline"] .sfc-chunk--run.is-marked,
.sfc-passage[data-mark-style="underline"] .sfc-word.is-marked {
    border-bottom: 2px solid color-mix(in srgb, var(--sfc-mark-ink) 38%, transparent);
}

.sfc-word.is-miss {
    color: var(--ink-faint);
    text-decoration: line-through;
    text-decoration-color: var(--trait-content);
}

/* ── The expanded passage: serif at the design size, tinted boxes ────────── */

/* The passage is a paragraph — annotated and stylised, but still prose, so the
   air between two words has to read as a word-space and not as a list bullet.
   Three things paid into that space and only one of them was visible: the
   column gap, the chunk's padding and, nested inside it, the word's own. That
   came to 46px between two words at a 26px face — seven word-spaces (#760).
   The column gap goes, the chunk keeps a box worth of padding, and a word that
   is its own chunk stops paying twice (below). */
.sfc--expanded .sfc-passage {
    gap: 4px 0;
    padding: 16px 0;
    font-size: var(--sfc-passage-size, 26.4px);
    line-height: 1.12;
    letter-spacing: -0.008em;
}

/* `medium` is the design's default and the base rule's 500 already; only the
   other two weights have anything to say. */
.sfc--expanded[data-passage-weight="regular"] .sfc-passage {
    font-weight: 400;
}

.sfc--expanded[data-passage-weight="semibold"] .sfc-passage {
    font-weight: 600;
}

.sfc--expanded .sfc-chunk {
    padding: 0 4px;
    border-width: 1px;
    border-radius: var(--radius);
}

/* A run keeps its padding and its border width whether or not it is marked, so
   switching Trait re-tints the box and never moves a baseline (story 20). */
.sfc--expanded .sfc-chunk--run {
    gap: 4px;
    padding: 0 4px;
}

.sfc--expanded .sfc-word {
    display: inline-block;
    padding: 0 4px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
}

.sfc--expanded .sfc-chunk--run .sfc-word {
    padding: 0;
}

/* A word that is its own chunk is inside a box it does not draw: the chunk
   around it carries the same tint, so the word's own side padding is only air.
   Dropping it is what closes the line up without touching either box's inset
   or the 44px a chunk has to stay (#760). The vertical padding stays — that is
   part of the height a finger needs. A word inside a run is the exception
   above: there the run is one box and each word inside it can be marked on its
   own, so it keeps a little of its own. */
.sfc--expanded .sfc-chunk:not(.sfc-chunk--run) > .sfc-word {
    padding-left: 0;
    padding-right: 0;
}

.sfc-passage[data-mark-style="box"] .sfc-chunk.is-marked,
.sfc-passage[data-mark-style="box"] .sfc-word.is-marked {
    background: color-mix(in srgb, var(--sfc-mark-fill) 88%, var(--surface));
    border-color: transparent;
}

/* A run holding a marked word draws the wide box; the word inside it draws the
   narrow one, and #731's open state takes the run's tint away. */
.sfc-passage[data-mark-style="box"] .sfc-chunk--run.is-marked {
    background: color-mix(in srgb, var(--sfc-mark-fill) 72%, var(--surface));
}

/* Consecutive marks of one Trait are one phrase visually. Their DOM remains
   word-addressable for coaching, but the adjoining fills lose the pill seams
   that made a sentence look like a bag of tags. */
.sfc--expanded .sfc-chunk[data-trait="content"]:has(+ .sfc-chunk[data-trait="content"]),
.sfc--expanded .sfc-chunk[data-trait="pronunciation"]:has(+ .sfc-chunk[data-trait="pronunciation"]),
.sfc--expanded .sfc-chunk[data-trait="fluency"]:has(+ .sfc-chunk[data-trait="fluency"]) {
    border-top-right-radius: 2px;
    border-bottom-right-radius: 2px;
}

.sfc--expanded .sfc-chunk[data-trait="content"] + .sfc-chunk[data-trait="content"],
.sfc--expanded .sfc-chunk[data-trait="pronunciation"] + .sfc-chunk[data-trait="pronunciation"],
.sfc--expanded .sfc-chunk[data-trait="fluency"] + .sfc-chunk[data-trait="fluency"] {
    margin-left: -1px;
    border-top-left-radius: 2px;
    border-bottom-left-radius: 2px;
}

.sfc-passage[data-mark-style="box"] .sfc-word.is-miss.is-marked {
    border: 1.5px dashed color-mix(in srgb, var(--trait-content) 30%, transparent);
}

/* An issue the filter hides is plain text — including a word the learner
   never said, whose strike-through would otherwise still shout (story 22).
   Plain means the passage's own ink and no strike: the placeholder grey this
   used to take left the word at 1.31:1, gone from the sentence rather than
   quiet in it (#1140). */
.sfc-word.is-faded {
    color: inherit;
    text-decoration: none;
}

/* A Healed Issue keeps its mark and changes its colour: a soft green underline
   that stays on the passage in both mark styles, so a heal reads as a victory
   still there to revisit rather than as a mark that vanished (#957). The green
   is the app's `--good`, the one the popover's pass flood settles to; the box
   style's tint is dropped, because a healed mark is a line, not a fill. */
.sfc-passage[data-mark-style] .sfc-chunk.is-marked.is-healed,
.sfc-passage[data-mark-style] .sfc-word.is-marked.is-healed {
    background: none;
    border-color: transparent;
}

/* One line per mark, as everywhere else: the run draws it, or the word does —
   a lone word inside a plain chunk never draws both (#760). */
.sfc-passage[data-mark-style] .sfc-chunk--run.is-marked.is-healed,
.sfc-passage[data-mark-style] .sfc-word.is-marked.is-healed {
    border-bottom: 2px solid color-mix(in srgb, var(--good) 55%, transparent);
}

/* ── The missed key points (story 26) ────────────────────────────────────── */
/*
   The Open-ended four's other half of Content: points the response never made,
   and so points with nowhere on the passage to be marked. They read as a list
   under it, in the Content colour the orb beside them carries — one Trait, one
   hue — and nothing about them is clickable, because there is no span to open
   and nothing to say again.
*/

.sfc-keypoints {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px 16px;
    border-left: 3px solid var(--trait-content);
    border-radius: var(--radius-sm);
    background: color-mix(in srgb, var(--trait-content) 8%, var(--surface));
}

.sfc-keypoints-title {
    margin: 0;
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: color-mix(in srgb, var(--trait-content) 70%, var(--ink));
}

.sfc-keypoints-list {
    margin: 0;
    padding-left: 20px;
    list-style: disc;
}

.sfc-keypoints-item {
    font-family: var(--font-ui);
    font-size: 14px;
    line-height: 1.5;
    /* The Content colour, darkened to body-text contrast: the point is read as
       prose, and the hue is what ties it to the orb (story 26). */
    color: color-mix(in srgb, var(--trait-content) 55%, var(--ink));
}

/* Phone (#733, PRD stories 49–50): under 640px — the chrome's own narrow
   breakpoint, so the card changes shape on the same window the page does — the
   compact row stacks into bands (the meta line, then the player, then the
   orbs, then the passage), the attempt numeral sits inline with its date, the
   HUD wraps into a 2×2 grid of orbs and the passage drops one size step.
   Everything a finger has to hit is 44px (docs/STYLE_GUIDE.md). */
@media (max-width: 640px) {
    .sfc--compact {
        flex-wrap: wrap;
        gap: 12px;
    }

    /* A band is a whole line, and that has to be said in flex-basis. `flex-wrap`
       alone never wrapped this row: the head is `flex: none` and the body
       `flex: 1` — basis 0 — so every line "fits" by definition, and the head
       (a ~200px meta line once it goes horizontal below) simply ate the row,
       leaving the body ~100px to squeeze a player, four orbs and the passage
       into. One word per line, and the orbs off the edge. */
    .sfc--compact .sfc-head,
    .sfc--compact .sfc-body {
        flex-basis: 100%;
        min-width: 0;
    }

    /* The card's head stacks too: a numeral inline with its date, then the
       pill under it, because 80px of pill and a 42px numeral do not share a
       390px line. */
    .sfc--expanded {
        gap: 16px;
    }

    /* Only the meta line has to clear the close button — it is the one thing
       beside it. Keeping the margin on the whole head stole those 32px from
       the HUD below too, and the second column of orbs lost its label off the
       right edge. */
    .sfc--expanded .sfc-head {
        flex-wrap: wrap;
        margin-right: 0;
    }

    .sfc--expanded .sfc-attempt {
        padding-right: 44px;
    }

    .sfc--expanded .sfc-hud {
        flex-basis: 100%;
        height: auto;
    }

    /* Desktop's orbs carry 32px of trailing air and a 54px ring beside the
       label. Half a phone is ~150px, and a ring plus "Pronunciation" on one
       line does not fit in it — the label ran over the orb next to it. So on a
       phone the label sits under its ring instead, where it has the whole
       caption line to be printed in, and the rings step down. The 44px touch
       target below is what sets the floor, not the ring.

       A reserved row is shaped by the same tier, because its HUD is the scored
       HUD with nothing in it yet: a row that changed shape when its score
       landed would be the promotion moving the card, which is exactly what
       reserving it in place avoids. */
    :is(.sfc--expanded, .sfc--pending) .sfc-orb,
    :is(.sfc--expanded, .sfc--pending) .sfc-orb--overall {
        flex-direction: column;
        gap: 4px;
        margin-right: 0;
        padding: 4px 8px;
        text-align: center;
    }

    /* The rings themselves are not restated here at all any more. This tier
       used to carry its own 54px — and Overall's alongside it, which undid the
       size relationship on a phone and nowhere else — but the open card's ring
       is the same size at every width, so it is set once, above. */

    .sfc-attempt {
        flex-direction: row;
        align-items: baseline;
        padding: 0;
        border-right: 0;
    }

    .sfc-attempt-number {
        font-size: 28px;
    }

    .sfc-top {
        flex-wrap: wrap;
    }

    .sfc-audio {
        flex-basis: 100%;
    }

    .sfc-close {
        top: 8px;
        right: 8px;
    }

    .sfc-close .nav-icon {
        --nav-icon-size: 14px;
    }

    /* The HUD stays one line here and scrolls when it runs out of room — the
       shared row's whole job. It used to become a 2×2 grid, which read as two
       rows of two rather than as one comparison and put the four rings on two
       tops (#936 story 15). Overall keeps its divider, because a rule beside
       it means something again in a row. */
    .sfc-hud {
        /* Its own line inside `.sfc-top`, and one that shrinks: `flex: none`
           left the row at max-content, which is wider than a phone. */
        flex: 1 1 100%;
        min-width: 0;
        width: 100%;
        border-radius: var(--radius-sm);
    }

    :is(.sfc--expanded, .sfc--pending) .sfc-hud {
        gap: 0;
        padding: 10px 8px;
        border-radius: 28px;
    }

    /* The passage drops one step at each size so a phone line holds more of
       the sentence. The expanded step is a fraction of the configured size,
       not a number of its own, so a Task that sets `passageSize` still gets
       the size it asked for — one step smaller. */
    .sfc-passage {
        font-size: 16px;
    }

    .sfc--expanded .sfc-passage {
        font-size: calc(var(--sfc-passage-size, 26.4px) * 0.8);
        /* Same closing-up as the desktop rule, at a 21px face: the chunk's own
           padding is the whole of the word-space, and a 309px line gets to
           hold a sentence rather than two words and a lot of white. */
        gap: 4px 0;
        padding: 8px 0;
    }
}

/* Touch targets, at the style guide's own phone/tablet boundary of 768px —
   not the 640px the block above re-shapes the card at. The two answer
   different questions: 640px is where the chrome runs out of room for a row,
   while whether a finger is the pointer is settled a tier earlier, and a
   tablet held in portrait needs the 44px as much as a phone does
   (docs/STYLE_GUIDE.md). */
@media (max-width: 768px) {
    /* The card's only exit gesture on touch, and its play control. */
    .sfc-play,
    .sfc-close {
        width: 44px;
        height: 44px;
    }

    /* The orbs are the Trait filter on the card, so there they are targets a
       finger has to hit. On the row nothing is aimed at but the row itself,
       and a taller mini HUD would only make two rows harder to compare
       (story 16). */
    .sfc--expanded .sfc-orb {
        min-height: 44px;
    }
}

/* ── Compact-only rows (#735) ─────────────────────────────────────────────
   A Task whose declaration says `compactOnly` has no expanded state to open,
   so its row must not offer one: no hover lift, no pointer. Appended as its
   own block; nothing above is changed. */

.sfc--no-expand {
    cursor: default;
}

.sfc--no-expand:hover {
    box-shadow: none;
}

/* ── Unscored rows (#337, ADR-0133) ───────────────────────────────────────
   Personal Introduction's list is this card's row without a Score, so it has
   no HUD. The row's rule above gives the player half the width and leaves the
   other half for the HUD, so with no HUD the player takes the whole line.
   Everything else is the compact row as the scored Tasks draw it. */

.sfc--unscored .sfc-audio {
    flex-basis: 100%;
    width: 100%;
}

/* No passage sits under the player, so the player is centred on the attempt
   block beside it instead of sitting at the top of the row. */
.sfc--unscored .sfc-body {
    justify-content: center;
}

/* ── The issue popover: the coach flow (#731, PRD stories 31–42) ───────────
   Clicking a mark opens one issue under it: a 298px card with a caret into the
   word, over a scrim that blurs the page, with the words that are not this
   issue's dimmed away. Geometry and choreography ported from the mockup
   (DECISIONS §7); every colour is a token.

   Local custom properties the renderer writes: --sfc-mark-ink is the open
   issue's Trait, inherited from the chunk the popover sits in. */

.sfc-scrim {
    position: fixed;
    inset: 0;
    z-index: 10;
    background: color-mix(in srgb, var(--surface-page) 42%, transparent);
    backdrop-filter: blur(2.5px);
}

/* The open mark and its popover stand above the scrim; everything else on the
   card stays behind it. */
.sfc-chunk.is-open,
.sfc-word.is-open {
    position: relative;
    z-index: 30;
}

/* The open issue's Trait orb stands with the popover, above the scrim: it is
   what says which skill the learner is working on (story 15). */
.sfc--issue-open .sfc-orb.is-selected {
    position: relative;
    z-index: 30;
}

/* Focus dim (story 32): the words this issue is not about recede. A run raised
   above the scrim blurs its own off-topic words instead, so it matches the
   page behind it whatever the setting says. */
.sfc-passage.is-focusing .sfc-word:not(.is-involved) {
    opacity: 0.38;
}

.sfc-chunk--run.is-raised .sfc-word:not(.is-involved) {
    opacity: 0.42;
    filter: blur(2.5px);
}

.sfc-passage .sfc-word {
    transition: opacity 0.2s, filter 0.2s;
}

.sfc-pop {
    position: absolute;
    top: calc(100% + 15px);
    left: 50%;
    z-index: 30;
    display: flex;
    box-sizing: border-box;
    width: 298px;
    flex-direction: column;
    align-items: stretch;
    padding: 12px 16px;
    border: 1px solid var(--border);
    /* The design's own corner (DECISIONS §7), derived from the card radius
       rather than written down beside it. */
    border-radius: calc(var(--radius) * 3);
    background: var(--surface);
    box-shadow: var(--shadow);
    cursor: default;
    font-family: var(--font-ui);
    transform: translateX(-50%);
    animation: sfc-popin 0.3s cubic-bezier(0.19, 1, 0.22, 1);
}

.sfc-pop[data-verdict="pass"] { --sfc-verdict: var(--good); }
.sfc-pop[data-verdict="miss"] { --sfc-verdict: var(--rubric); }
.sfc-pop[data-verdict="error"] { --sfc-verdict: var(--score-grammar); }

.sfc-pop[data-verdict] {
    background: color-mix(in srgb, var(--sfc-verdict) 4%, var(--surface));
    animation: sfc-pop-flood 0.9s ease-out;
}

.sfc-pop[data-verdict] .sfc-pop-step[data-step="retry"] .sfc-pop-step-icon {
    animation: sfc-verdict-nod 0.52s ease-out;
}

.sfc-word:is(.is-verdict-pass, .is-verdict-miss, .is-verdict-error) {
    animation: sfc-word-flood 0.82s ease-out;
}

.sfc-word.is-verdict-pass { --sfc-word-verdict: var(--good); background: color-mix(in srgb, var(--good) 9%, var(--surface)); }
.sfc-word.is-verdict-miss { --sfc-word-verdict: var(--rubric); background: color-mix(in srgb, var(--rubric) 9%, var(--surface)); }
.sfc-word.is-verdict-error { --sfc-word-verdict: var(--score-grammar); background: color-mix(in srgb, var(--score-grammar) 9%, var(--surface)); }

@keyframes sfc-pop-flood {
    45% {
        border-color: color-mix(in srgb, var(--sfc-verdict) 42%, var(--border));
        background: color-mix(in srgb, var(--sfc-verdict) 8%, var(--surface));
        box-shadow: var(--shadow), 0 0 0 5px color-mix(in srgb, var(--sfc-verdict) 7%, transparent);
    }
}

@keyframes sfc-word-flood {
    45% {
        background: color-mix(in srgb, var(--sfc-word-verdict) 17%, var(--surface));
        box-shadow: 0 0 0 4px color-mix(in srgb, var(--sfc-word-verdict) 7%, transparent);
    }
}

@keyframes sfc-verdict-nod {
    45% {
        transform: scale(1.045);
        box-shadow: 0 0 0 4px color-mix(in srgb, var(--sfc-verdict) 8%, transparent);
    }
}

@keyframes sfc-popin {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(7px) scale(0.965);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(1);
    }
}

/* The caret into the word the popover belongs to. */
.sfc-pop-caret {
    position: absolute;
    top: -7px;
    left: 50%;
    width: 12px;
    height: 12px;
    border-top: 1px solid var(--border);
    border-left: 1px solid var(--border);
    border-radius: 3px 0 0;
    background: var(--surface);
    transform: translateX(-50%) rotate(45deg);
}

.sfc-pop-note {
    display: block;
    font-size: 14px;
    line-height: 1.4;
    color: var(--ink-muted);
    text-align: center;
}

/* Where the Stress Picture goes, stood above the steps from the moment the
   popover is built so a word whose table lands late paints into a place
   already made for it. Layout-neutral: the picture stretches as it did when it
   was the popover's own child, and a word with no picture leaves nothing. */
.sfc-pop-stress {
    display: flex;
    flex-direction: column;
}

.sfc-pop-stress:empty {
    display: none;
}

.sfc-pop-steps {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: 16px;
    margin-top: 8px;
    padding: 8px;
    border: 1px solid transparent;
    border-radius: calc(var(--radius) * 1.5);
}

/* Each orb wears a hue and spends it on rim, numeral and caption alike, the way
   a scored page's orb row does (ADR-0009). YOURS takes the Trait's own ink, so
   the orb the learner replays is the colour of the mark they are replaying;
   the other two are what they do rather than which Trait they serve. */
.sfc-pop-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 3px 2px;
    --orb-color: var(--sfc-mark-ink, var(--ink));
    transition: filter 0.3s, opacity 0.3s;
}

.sfc-pop-step[data-step="model"] {
    --orb-color: var(--good);
}

.sfc-pop-step[data-step="retry"] {
    --orb-color: var(--rubric);
}

/* A step whose turn has not come is blurred out of the way, so the eye lands
   on the one that is sounding. It is softened, not withdrawn: every orb is a
   control at every point in the walk (#850), and what a disabled one looks
   like is `.is-disabled` below. */
.sfc-pop-step.is-future {
    opacity: 0.66;
    filter: blur(1.5px);
}

/* The orb vocabulary's geometry, restated for a control rather than a score:
   the same 2px rim mixed toward the surface, at the one size that is already a
   touch target, so the row needs no size step of its own at the phone tier. */
.sfc-pop-step-icon {
    position: relative;
    display: flex;
    box-sizing: border-box;
    width: 54px;
    height: 54px;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 2px solid color-mix(in srgb, var(--orb-color) 45%, var(--surface));
    border-radius: 50%;
    background: var(--surface);
    color: color-mix(in srgb, var(--orb-color) 80%, var(--ink-strongest));
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.sfc-pop-step.is-active .sfc-pop-step-icon {
    border-color: var(--orb-color);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--orb-color) 14%, transparent);
}

/* The running step pulses: the flow is doing something even when the sound is
   quiet. */
.sfc-pop-step.is-active .sfc-pop-step-icon {
    animation: sfc-ring-run 1.15s ease-out infinite;
}

.sfc-pop-step.is-gleaming .sfc-pop-step-icon {
    animation: sfc-gleam 1.8s ease-in-out infinite;
}

@keyframes sfc-gleam {
    50% { box-shadow: 0 0 0 5px color-mix(in srgb, var(--orb-color) 12%, transparent); }
}

.sfc-pop-step.is-winding .sfc-pop-step-icon::after {
    opacity: 1;
    animation: sfc-wind-up 0.5s linear both;
}

.sfc-pop-step:is(.is-playing, .is-recording, .is-checking) .sfc-pop-step-icon::after {
    --orb-progress: 1;
    opacity: 1;
}

@keyframes sfc-wind-up {
    from { --orb-progress: 0; }
    to { --orb-progress: 1; }
}

@keyframes sfc-ring-run {
    0% {
        box-shadow: 0 0 0 0 color-mix(in srgb, var(--orb-color) 32%, transparent);
    }

    70% {
        box-shadow: 0 0 0 9px transparent;
    }

    100% {
        box-shadow: 0 0 0 0 transparent;
    }
}

.sfc-pop-step.is-done .sfc-pop-step-icon {
    border-color: color-mix(in srgb, var(--orb-color) 60%, var(--surface));
    background: var(--surface-sunken);
}

/* The retry step is #732's; until its hook is supplied it renders as the
   promise of a step rather than an offer. */
.sfc-pop-step.is-disabled {
    opacity: 0.45;
}

.sfc-pop-step.is-disabled .sfc-pop-step-icon {
    cursor: not-allowed;
}

/* Glyph-free marks: CSS shapes whose ink box is their box, so centring is
   true centring (DECISIONS §7). */
.sfc-pop-step-reader {
    position: absolute;
    inset: 3px;
    width: calc(100% - 6px);
    height: calc(100% - 6px);
    border-radius: 50%;
    object-fit: cover;
    opacity: 0.82;
    filter: saturate(0.88);
}

.sfc-pop-step[data-step="model"] .sfc-pop-step-shape {
    position: relative;
    z-index: 1;
    color: var(--surface);
    filter: drop-shadow(0 1px 2px color-mix(in srgb, var(--ink) 70%, transparent));
}

/* A Sample nobody's in particular reads — a Task's own prompt, the browser's
   voice, or an issue whose word no reader recorded — shows no face, because
   the alternative is an orb naming a reader the learner is not hearing (#923).
   What is left is the plain Sample orb: the play mark drops the white-on-photo
   treatment above and takes the orb's own ink back, so the disc reads as a
   state rather than as a hole where a face was. */
.sfc-pop-step[data-step="model"][data-reader="none"] .sfc-pop-step-shape {
    color: inherit;
    filter: none;
}

.sfc-pop-step-shape {
    flex: none;
    width: 11px;
    height: 13px;
    background: currentcolor;
    clip-path: polygon(0 0, 100% 50%, 0 100%);
}

.sfc-pop-step-shape[data-shape="circle"] {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    clip-path: none;
}

.sfc-pop-step-shape[data-shape="stop"] {
    width: 12px;
    height: 12px;
    border-radius: var(--radius-sm);
    clip-path: none;
}

.sfc-pop-step-shape[data-shape="checking"] {
    width: 14px;
    height: 14px;
    border: 2px solid color-mix(in srgb, currentcolor 25%, transparent);
    border-top-color: currentcolor;
    border-radius: 50%;
    background: transparent;
    clip-path: none;
    animation: sfc-check-spin 0.7s linear infinite;
}

@keyframes sfc-check-spin {
    to { transform: rotate(360deg); }
}

.sfc-pop-step.is-active .sfc-pop-step-shape {
    width: 13px;
    height: 15px;
}

.sfc-pop-step.is-active .sfc-pop-step-shape[data-shape="circle"] {
    width: 15px;
    height: 15px;
}

.sfc-pop-step.is-active .sfc-pop-step-shape[data-shape="stop"] {
    width: 16px;
    height: 16px;
}

.sfc-pop-step.is-active .sfc-pop-step-shape[data-shape="checking"] {
    width: 16px;
    height: 16px;
}

.sfc-pop-step-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    display: none;
    width: 14px;
    height: 14px;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--ink);
    color: var(--surface);
}

.sfc-pop-step.is-done .sfc-pop-step-badge {
    display: flex;
}

.sfc-pop-step-tick {
    flex: none;
    width: 8px;
    height: 7px;
    background: currentcolor;
    clip-path: polygon(0 52%, 12% 40%, 35% 70%, 88% 4%, 100% 16%, 35% 94%);
}

/* The orb's own label, in the shared vocabulary's type (css/main.css
   .ai-score-orb-label) rather than the mono the counter keeps: the row now
   reads as the card's orbs do, four of which sit directly above it. */
.sfc-pop-step-label {
    display: flex;
    min-height: 16px;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.sfc-pop-step-cap {
    /* The vocabulary's own label size, written out rather than read from
       --orb-label-size: that token is declared on an orb slot, and a sheet
       parented to <body> is nowhere near one to inherit it. */
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    line-height: 1;
    text-transform: uppercase;
    white-space: nowrap;
    color: color-mix(in srgb, var(--orb-color) 65%, var(--ink-tertiary));
}

.sfc-pop-step.is-active .sfc-pop-step-cap {
    color: color-mix(in srgb, var(--orb-color) 90%, var(--ink-strongest));
}

/* Both rows of the row area stand the same way: full width, one gap, one
   inset and one corner. Each row below keeps only what makes it itself. */
.sfc-pop-row {
    display: flex;
    width: 100%;
    gap: clamp(4px, 2.2vw, 12px);
    margin-top: 16px;
    padding: 10px 8px;
    border: 1px solid transparent;
    border-radius: calc(var(--radius) * 1.5);
}

.sfc-pop-reader-strip {
    position: relative;
    align-items: center;
    justify-content: center;
    border-color: color-mix(in srgb, var(--good) 22%, var(--border));
    background: color-mix(in srgb, var(--good) 3%, var(--surface));
}

.sfc-pop-reader-strip[hidden] { display: none; }

/* The other row of the row area: the takes the learner has made, oldest first.
   It scrolls sideways rather than shrinking its orbs, because a take is a face
   to tap and the tenth is worth as much as the first. */
.sfc-pop-takes-strip {
    align-items: flex-start;
    justify-content: flex-start;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: thin;
}

.sfc-pop-takes-strip[hidden] { display: none; }

/* One take: an orb wearing the learner's picture, with room beneath it for the
   Retake Mark so a marked chip and a bare one stand at the same height. */
.sfc-pop-take {
    display: flex;
    width: 44px;
    min-width: 44px;
    flex: 0 0 44px;
    flex-direction: column;
    align-items: center;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    gap: 2px;
    transition: transform 0.18s;
}

.sfc-pop-take-image {
    width: 44px;
    height: 44px;
    box-sizing: border-box;
    padding: 2px;
    border: 2px solid transparent;
    border-radius: 50%;
    object-fit: cover;
}

/* An empty orb for a take whose picture the learner has not set: the ring is
   still a target, and still says which take is picked. */
.sfc-pop-take-image[hidden] {
    display: block;
    visibility: hidden;
}

/* The picked take is raised, the way a picked reader is. */
.sfc-pop-take[aria-checked="true"] {
    transform: translateY(-2px);
}

.sfc-pop-take[aria-checked="true"] .sfc-pop-take-image {
    border-color: var(--sfc-mark-ink, var(--good));
}

.sfc-pop-take:hover,
.sfc-pop-take:focus-visible {
    outline: none;
    transform: translateY(-1px);
}

/* The Retake Mark: what the server said about this retake of this issue, in
   the issue's own Trait colour. */
.sfc-pop-take-mark {
    font-family: var(--font-mono);
    /* The Style Guide's floor for a Task Surface: nothing on a sheet the
       learner reads goes under 12px. */
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    color: var(--sfc-mark-ink);
}

.sfc-pop.is-keyboard-nav .sfc-pop-take.is-keyboard-focus .sfc-pop-take-image {
    outline: 2px solid color-mix(in srgb, var(--brand-purple-mid) 58%, var(--border));
    outline-offset: 2px;
}

.sfc-pop-reader-strip::before,
.sfc-pop-reader-strip::after {
    position: absolute;
    bottom: 100%;
    left: 50%;
    border: 8px solid transparent;
    content: '';
    transform: translateX(-50%);
}

.sfc-pop-reader-strip::before {
    border-bottom-color: color-mix(in srgb, var(--good) 22%, var(--border));
}

.sfc-pop-reader-strip::after {
    margin-bottom: -1px;
    border-width: 7px;
    border-bottom-color: color-mix(in srgb, var(--good) 3%, var(--surface));
}

.sfc-pop-reader {
    display: flex;
    width: 44px;
    min-width: 44px;
    max-width: 44px;
    height: 44px;
    min-height: 44px;
    flex: 0 0 44px;
    aspect-ratio: 1;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border: 2px solid transparent;
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
    transition: border-color 0.18s, transform 0.18s;
}

.sfc-pop-reader:hover,
.sfc-pop-reader:focus-visible {
    outline: none;
    transform: translateY(-1px);
}

.sfc-pop.is-keyboard-nav .is-keyboard-region {
    border-color: color-mix(in srgb, var(--brand-purple-mid) 24%, var(--border));
    background-color: color-mix(in srgb, var(--brand-purple-mid) 2%, var(--surface));
    box-shadow: 0 2px 8px color-mix(in srgb, var(--brand-purple-mid) 5%, transparent);
}

.sfc-pop.is-keyboard-nav .sfc-pop-step.is-keyboard-focus .sfc-pop-step-icon,
.sfc-pop.is-keyboard-nav .sfc-pop-reader.is-keyboard-focus,
.sfc-pop.is-keyboard-nav :is(.sfc-pop-prev, .sfc-pop-next).is-keyboard-focus {
    outline: 2px solid color-mix(in srgb, var(--brand-purple-mid) 58%, var(--border));
    outline-offset: 2px;
}

.sfc-pop-reader[aria-checked="true"] {
    border-color: var(--good);
}

.sfc-pop-reader-image {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* ── The footer: where the learner is, and the way on ─────────────────── */

.sfc-pop-foot {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 12px;
    padding: 12px 8px;
    border: 1px solid transparent;
    border-top-color: var(--score-divider);
    border-radius: var(--radius);
}

.sfc-pop-counter {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-transform: uppercase;
    white-space: nowrap;
    color: var(--ink-faint);
}

/* The pager is circular and sits in the same sheet as the orbs, so it takes the
   same rim rather than staying the one hairline circle in the row. */
.sfc-pop-prev,
.sfc-pop-next {
    display: flex;
    box-sizing: border-box;
    width: 24px;
    height: 24px;
    flex: none;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 2px solid color-mix(in srgb, var(--sfc-mark-ink, var(--ink)) 30%, var(--surface));
    border-radius: 50%;
    background: var(--surface);
    color: color-mix(in srgb, var(--sfc-mark-ink, var(--ink)) 70%, var(--ink-tertiary));
    cursor: pointer;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.sfc-pop-prev:hover:not(:disabled),
.sfc-pop-next:hover:not(:disabled) {
    border-color: var(--border-strong);
    background: var(--surface-sunken);
    color: var(--ink);
}

/* One issue on the passage is nowhere to walk to. */
.sfc-pop-prev:disabled,
.sfc-pop-next:disabled {
    opacity: 0.35;
    cursor: default;
}

/* At the end of the flow the next chevron asks for the click (story 37). */
.sfc-pop-next.is-attracting {
    border: 1.5px solid var(--sfc-mark-ink, var(--ink));
    color: var(--sfc-mark-ink, var(--ink));
    animation: sfc-attract 1.5s ease-in-out infinite;
}

@keyframes sfc-attract {
    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.13);
    }
}

.sfc-pop-chevron {
    flex: none;
    width: 9px;
    height: 10px;
    background: currentcolor;
    clip-path: polygon(67% 4%, 81% 18%, 49% 50%, 81% 82%, 67% 96%, 19% 50%);
}

.sfc-pop-next .sfc-pop-chevron {
    clip-path: polygon(33% 4%, 19% 18%, 51% 50%, 19% 82%, 33% 96%, 81% 50%);
}

/* The wave focuses with the popover: bars outside the open issue's words drop
   back so the player points where the passage does (story 31). */
.sfc-wave.is-focusing .sfc-wave-bar.is-dimmed {
    opacity: 0.28;
}

/* Reduced motion: the popover still arrives and the steps still read, they
   just stop moving. */
@media (prefers-reduced-motion: reduce) {
    .sfc-pop,
    .sfc-pop-next.is-attracting,
    .sfc-pop-step.is-active .sfc-pop-step-icon {
        animation: none;
    }
}

/* Phone: the popover becomes a bottom sheet (#733, story 49) — the same cue,
   three steps and footer, fixed to the bottom of the window instead of
   hanging off a word, because 298px under a mark on a 390px screen has nowhere
   to hang. The card's JS decides what "narrow" is once and says so with the
   class, so the shape and the crossfade can never disagree. */
.sfc-pop--sheet {
    position: fixed;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: auto;
    max-height: 82vh;
    overflow-y: auto;
    padding: 16px 20px calc(16px + env(safe-area-inset-bottom, 0px));
    border-width: 1px 0 0;
    border-radius: calc(var(--radius) * 3) calc(var(--radius) * 3) 0 0;
    transform: none;
    animation: sfc-sheet-in 0.3s cubic-bezier(0.19, 1, 0.22, 1);
}

/* A sheet points at nothing: it is the window's edge, not the word's. */
.sfc-pop--sheet .sfc-pop-caret {
    display: none;
}

/* The sheet's own arrival, restated after it: the reduced-motion block above
   is no more specific than `.sfc-pop--sheet`, so it would lose on order. */
@media (prefers-reduced-motion: reduce) {
    .sfc-pop--sheet {
        animation: none;
    }
}

@keyframes sfc-sheet-in {
    from {
        opacity: 0;
        transform: translateY(24px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Everything on the sheet a finger has to hit is a real touch target
   (docs/STYLE_GUIDE.md — 44px), at the guide's 768px phone/tablet boundary
   rather than the 640px the card re-shapes at: the sheet arrives on its own
   breakpoint, but a finger is a finger a tier earlier. */
@media (max-width: 768px) {
    .sfc-pop-prev,
    .sfc-pop-next {
        width: 44px;
        height: 44px;
    }
}
