/* The film and its words are one listening place: the film holds still, the words move. */
.voice-listen {
    position: relative;
}

.voice-stage {
    position: sticky;
    z-index: 2;
    top: 0;
    padding: 12px 0 16px;
    margin: -12px 0 0;
    background: var(--background-color);
}

.voice-player-status {
    margin: 12px 0 0;
    color: var(--muted-color);
    font-size: 13px;
    line-height: 1.7;
}

.voice-player-status:empty { display: none; }
.voice-player-status a { color: var(--primary-color); }

.voice-transcript {
    --fold-height: 300px;
    margin-top: 32px;
}

.voice-transcript-lines {
    position: relative;
}

.voice-cue {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    column-gap: 16px;
    margin: 0;
    padding: 2px 0;
    scroll-margin-top: 45vh;
}

.voice-cue-time {
    min-height: 32px;
    color: var(--muted-color);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.02em;
    line-height: 32px;
    text-decoration: none;
    opacity: 0.72;
    transition: color 160ms ease-out, opacity 160ms ease-out;
}

.voice-cue-text {
    font-size: 16px;
    line-height: 32px;
    overflow-wrap: anywhere;
    transition: color 200ms ease-out;
}

.voice-cue:hover .voice-cue-time,
.voice-cue-time:focus-visible,
.voice-cue-time[aria-current] {
    color: var(--primary-color);
    opacity: 1;
}

.voice-cue-time:focus-visible { outline: 1px solid var(--primary-color); outline-offset: 2px; }

/* While she speaks, the other lines step back and the spoken one stays inked. */
.voice-transcript.is-following .voice-cue-text { color: var(--muted-color); }
.voice-transcript .voice-cue.is-playing .voice-cue-text { color: var(--text-color); }
.voice-cue.is-playing .voice-cue-time { color: var(--primary-color); opacity: 1; }

.voice-transcript.is-folded .voice-transcript-lines {
    max-height: var(--fold-height);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 72px), transparent);
    mask-image: linear-gradient(to bottom, #000 calc(100% - 72px), transparent);
}

.voice-transcript.is-folded .voice-transcript-lines::-webkit-scrollbar { display: none; }

.voice-transcript-toggle {
    position: sticky;
    bottom: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 44px;
    padding: 8px 0 8px 64px;
    border: 0;
    background: linear-gradient(to bottom, transparent, var(--background-color) 12px);
    color: var(--muted-color);
    font: inherit;
    font-size: 13px;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: color 160ms ease-out;
}

.voice-transcript.is-folded .voice-transcript-toggle { position: static; background: none; }
.voice-transcript-toggle:hover { color: var(--primary-color); }
.voice-transcript-toggle:focus-visible { outline: 1px solid var(--primary-color); outline-offset: 2px; }

.voice-transcript-toggle svg {
    width: 10px;
    height: 8px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1;
    transition: transform 180ms ease-out;
}

.voice-transcript-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }

/* Wide screens: the words stand beside the film, a narrow column for short spoken lines. */
@media (min-width: 1024px) {
    .voice-listen.has-transcript {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 320px;
        column-gap: 48px;
        align-items: start;
    }

    .voice-listen.has-transcript .voice-stage {
        top: 32px;
        margin: 0;
        padding: 0;
        background: none;
    }

    .voice-listen.has-transcript .voice-transcript { margin-top: -4px; }
}

@media (max-width: 600px) {
    .voice-stage {
        margin: -8px -16px 0;
        padding: 8px 16px 12px;
    }

    .voice-transcript { margin-top: 20px; }
    .voice-cue { grid-template-columns: 44px minmax(0, 1fr); column-gap: 12px; }
    .voice-cue-time { min-height: 34px; line-height: 34px; }
    .voice-cue-text { line-height: 34px; }
    .voice-transcript-toggle { padding-left: 56px; }
    .voice-transcript.is-folded { --fold-height: 300px; }
}

@media (prefers-reduced-motion: reduce) {
    .voice-cue-time,
    .voice-cue-text,
    .voice-transcript-toggle,
    .voice-transcript-toggle svg { transition: none; }
}
