导航

v2.1.0
媒体

文字稿

以随播放进度同步的字幕片段呈现音视频中的话语。

本页内容

文字稿以字幕片段列表呈现音视频中的话语,每个片段都带有开始时间。它随媒体播放进度同步:正在播放的片段以醒目的文字显示在凸起的面板上,已经听过的片段变淡,尚未播放的片段保持正文墨色。选择某个片段,媒体就会从该处播放。transcript 行为脚本把它与媒体播放器或普通的 <audio>、<video> 关联起来,媒体元素通过其 id 在 aria-controls 中指定。

文字稿

<div class="grid gap-sm max-w(480) mx-auto">  <div class="player" id="talk" role="group" aria-label="A short recording">    <audio class="player-media" src="/demo/recording.m4a" controls preload="metadata"></audio>    <div class="player-controls">      <button type="button" class="player-button player-play" aria-label="Play" aria-pressed="false">        <svg class="icon player-off" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">          <path d="M7.633 4.7883L14.865 8.9606A1.2 1.2 0 0 1 14.865 11.0394L7.633 15.2117A1.2 1.2 0 0 1 5.8333 14.1723L5.8333 5.8277A1.2 1.2 0 0 1 7.633 4.7883Z" />        </svg>        <svg class="icon player-on" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">          <rect x="5" y="3.75" width="3.3333" height="12.5" rx="0.8" /><rect x="11.6667" y="3.75" width="3.3333" height="12.5" rx="0.8" />        </svg>      </button>      <span class="player-elapsed">0:00</span>      <input type="range" class="slider player-seek" min="0" max="0" step="any" value="0" aria-label="Seek">      <span class="player-duration">0:00</span>    </div>  </div>  <section class="transcript" aria-label="Transcript" aria-controls="talk" style="--transcript-height: 12rem">    <ol class="transcript-list scroll-area">      <li class="transcript-cue" data-start="0.3">        <button type="button" class="transcript-time">0:00</button>        <p class="transcript-text">          This is a short recording, made to show the player and its transcript.        </p>      </li>      <li class="transcript-cue" data-start="4.7">        <button type="button" class="transcript-time">0:04</button>        <p class="transcript-text">          Each line of the transcript is a cue, with the time it begins.        </p>      </li>      <li class="transcript-cue" data-start="8.7">        <button type="button" class="transcript-time">0:08</button>        <p class="transcript-text">          The line being spoken is marked, and the transcript keeps it in view.        </p>      </li>      <li class="transcript-cue" data-start="13.06">        <button type="button" class="transcript-time">0:13</button>        <p class="transcript-text">          Lines you have heard turn quiet. The ones still to come wait in plain ink.        </p>      </li>      <li class="transcript-cue" data-start="17.65">        <button type="button" class="transcript-time">0:17</button>        <p class="transcript-text">          Choose any line to jump to it, or scroll away and come back later.        </p>      </li>      <li class="transcript-cue" data-start="21.79">        <button type="button" class="transcript-time">0:21</button>        <p class="transcript-text">That is the whole recording. Thank you for listening.</p>      </li>    </ol>    <button type="button" class="btn btn-sm btn-pill transcript-return" hidden>      Back to current    </button>  </section></div><script type="module">  import { attach } from '@master/ui/behaviors'  attach()</script>
import { useEffect, useRef } from 'react'import { attach } from '@master/ui/behaviors'import PlayIcon from '@master/icons-react/native/20/soft/play'import PauseIcon from '@master/icons-react/native/20/soft/pause'export function Example() {  const root = useRef<HTMLDivElement>(null)  useEffect(() => attach(root.current!), [])  return (    <div ref={root} className="grid gap-sm max-w(480) mx-auto">      <div className="player" id="talk" role="group" aria-label="A short recording">        <audio className="player-media" src="/demo/recording.m4a" controls preload="metadata"></audio>        <div className="player-controls">          <button type="button" className="player-button player-play" aria-label="Play" aria-pressed="false">            <PlayIcon className="icon player-off" />            <PauseIcon className="icon player-on" />          </button>          <span className="player-elapsed">0:00</span>          <input type="range" className="slider player-seek" min="0" max="0" step="any" defaultValue="0" aria-label="Seek" />          <span className="player-duration">0:00</span>        </div>      </div>      <section className="transcript" aria-label="Transcript" aria-controls="talk" style={{ '--transcript-height': '12rem' } as React.CSSProperties}>        <ol className="transcript-list scroll-area">          <li className="transcript-cue" data-start="0.3">            <button type="button" className="transcript-time">0:00</button>            <p className="transcript-text">              This is a short recording, made to show the player and its transcript.            </p>          </li>          <li className="transcript-cue" data-start="4.7">            <button type="button" className="transcript-time">0:04</button>            <p className="transcript-text">              Each line of the transcript is a cue, with the time it begins.            </p>          </li>          <li className="transcript-cue" data-start="8.7">            <button type="button" className="transcript-time">0:08</button>            <p className="transcript-text">              The line being spoken is marked, and the transcript keeps it in view.            </p>          </li>          <li className="transcript-cue" data-start="13.06">            <button type="button" className="transcript-time">0:13</button>            <p className="transcript-text">              Lines you have heard turn quiet. The ones still to come wait in plain ink.            </p>          </li>          <li className="transcript-cue" data-start="17.65">            <button type="button" className="transcript-time">0:17</button>            <p className="transcript-text">              Choose any line to jump to it, or scroll away and come back later.            </p>          </li>          <li className="transcript-cue" data-start="21.79">            <button type="button" className="transcript-time">0:21</button>            <p className="transcript-text">That is the whole recording. Thank you for listening.</p>          </li>        </ol>        <button type="button" className="btn btn-sm btn-pill transcript-return" hidden>          Back to current        </button>      </section>    </div>  )}
<script>  import { attach } from '@master/ui/behaviors'  import PlayIcon from '@master/icons-svelte/native/20/soft/play'  import PauseIcon from '@master/icons-svelte/native/20/soft/pause'</script><div class="grid gap-sm max-w(480) mx-auto" {@attach attach}>  <div class="player" id="talk" role="group" aria-label="A short recording">    <audio class="player-media" src="/demo/recording.m4a" controls preload="metadata"></audio>    <div class="player-controls">      <button type="button" class="player-button player-play" aria-label="Play" aria-pressed="false">        <PlayIcon class="icon player-off" />        <PauseIcon class="icon player-on" />      </button>      <span class="player-elapsed">0:00</span>      <input type="range" class="slider player-seek" min="0" max="0" step="any" value="0" aria-label="Seek">      <span class="player-duration">0:00</span>    </div>  </div>  <section class="transcript" aria-label="Transcript" aria-controls="talk" style="--transcript-height: 12rem">    <ol class="transcript-list scroll-area">      <li class="transcript-cue" data-start="0.3">        <button type="button" class="transcript-time">0:00</button>        <p class="transcript-text">          This is a short recording, made to show the player and its transcript.        </p>      </li>      <li class="transcript-cue" data-start="4.7">        <button type="button" class="transcript-time">0:04</button>        <p class="transcript-text">          Each line of the transcript is a cue, with the time it begins.        </p>      </li>      <li class="transcript-cue" data-start="8.7">        <button type="button" class="transcript-time">0:08</button>        <p class="transcript-text">          The line being spoken is marked, and the transcript keeps it in view.        </p>      </li>      <li class="transcript-cue" data-start="13.06">        <button type="button" class="transcript-time">0:13</button>        <p class="transcript-text">          Lines you have heard turn quiet. The ones still to come wait in plain ink.        </p>      </li>      <li class="transcript-cue" data-start="17.65">        <button type="button" class="transcript-time">0:17</button>        <p class="transcript-text">          Choose any line to jump to it, or scroll away and come back later.        </p>      </li>      <li class="transcript-cue" data-start="21.79">        <button type="button" class="transcript-time">0:21</button>        <p class="transcript-text">That is the whole recording. Thank you for listening.</p>      </li>    </ol>    <button type="button" class="btn btn-sm btn-pill transcript-return" hidden>      Back to current    </button>  </section></div>
<script setup>import { onMounted, onUnmounted, ref } from 'vue'import { attach } from '@master/ui/behaviors'import PlayIcon from '@master/icons-vue/native/20/soft/play'import PauseIcon from '@master/icons-vue/native/20/soft/pause'const root = ref(null)let detachonMounted(() => { detach = attach(root.value) })onUnmounted(() => detach?.())</script><template>  <div ref="root" class="grid gap-sm max-w(480) mx-auto">    <div class="player" id="talk" role="group" aria-label="A short recording">      <audio class="player-media" src="/demo/recording.m4a" controls preload="metadata"></audio>      <div class="player-controls">        <button type="button" class="player-button player-play" aria-label="Play" aria-pressed="false">          <PlayIcon class="icon player-off" />          <PauseIcon class="icon player-on" />        </button>        <span class="player-elapsed">0:00</span>        <input type="range" class="slider player-seek" min="0" max="0" step="any" value="0" aria-label="Seek">        <span class="player-duration">0:00</span>      </div>    </div>    <section class="transcript" aria-label="Transcript" aria-controls="talk" style="--transcript-height: 12rem">      <ol class="transcript-list scroll-area">        <li class="transcript-cue" data-start="0.3">          <button type="button" class="transcript-time">0:00</button>          <p class="transcript-text">            This is a short recording, made to show the player and its transcript.          </p>        </li>        <li class="transcript-cue" data-start="4.7">          <button type="button" class="transcript-time">0:04</button>          <p class="transcript-text">            Each line of the transcript is a cue, with the time it begins.          </p>        </li>        <li class="transcript-cue" data-start="8.7">          <button type="button" class="transcript-time">0:08</button>          <p class="transcript-text">            The line being spoken is marked, and the transcript keeps it in view.          </p>        </li>        <li class="transcript-cue" data-start="13.06">          <button type="button" class="transcript-time">0:13</button>          <p class="transcript-text">            Lines you have heard turn quiet. The ones still to come wait in plain ink.          </p>        </li>        <li class="transcript-cue" data-start="17.65">          <button type="button" class="transcript-time">0:17</button>          <p class="transcript-text">            Choose any line to jump to it, or scroll away and come back later.          </p>        </li>        <li class="transcript-cue" data-start="21.79">          <button type="button" class="transcript-time">0:21</button>          <p class="transcript-text">That is the whole recording. Thank you for listening.</p>        </li>      </ol>      <button type="button" class="btn btn-sm btn-pill transcript-return" hidden>        Back to current      </button>    </section>  </div></template>
播放后选择一行。播放期间把文字稿滚离当前行:它会停止跟进,并提供返回的方式。

#跟进与滚离

媒体播放时,行为脚本用 aria-current="true" 标记当前片段:即 data-start 已经过去的最后一个片段,因此在两个片段之间的停顿期间,位置仍会保留。它之前的每个片段都由样式表单独绘制为已播放状态。

列表让当前片段保持在其中央。它只滚动自身,不滚动周围的任何内容,因此含有文字稿的页面绝不会在读者眼前移动;滚动是平滑的,对要求减少动态效果的读者则直接跳转。当读者用滚轮、手指、按键或滚动条滚动列表,使当前片段离开视野时,列表会停止跟进,位于列表底部边缘的小胶囊形按钮 transcript-return 可以让它回到当前位置。选择某个片段,或把当前片段滚回视野中,都会恢复跟进。

列表在 --transcript-height 的高度内滚动,未设置时为 20rem。给列表加上 scroll-area,可获得细滚动条,以及在内容延续的边缘处的渐隐效果。

#来自 WebVTT 轨道

列表为空时,行为脚本会通过 TextTrack API 读取媒体的第一条 captions 或 subtitles 轨道,并据此写入字幕片段:时间、去掉标签的文字,以及语音标签所指定的说话人(<v Ana>)。轨道只有在未被禁用时才会加载其字幕片段,因此行为脚本会把被禁用的轨道设为 hidden,这样该轨道的字幕就不会叠加在画面上。这里的文字稿跟进的是一个使用浏览器自带控件的普通 <audio>。

来自轨道

<div class="grid gap-sm max-w(480) mx-auto">  <audio id="talk-audio" class="w-full" src="/demo/recording.m4a" controls preload="metadata">    <track kind="captions" src="/demo/recording.vtt" srclang="en" label="English">  </audio>  <section class="transcript" aria-label="Transcript" aria-controls="talk-audio" style="--transcript-height: 15rem">    <ol class="transcript-list scroll-area"></ol>    <button type="button" class="btn btn-sm btn-pill transcript-return" hidden>      Back to current    </button>  </section></div><script type="module">  import { attach } from '@master/ui/behaviors'  attach()</script>
import { useEffect, useRef } from 'react'import { attach } from '@master/ui/behaviors'export function Example() {  const root = useRef<HTMLDivElement>(null)  useEffect(() => attach(root.current!), [])  return (    <div ref={root} className="grid gap-sm max-w(480) mx-auto">      <audio id="talk-audio" className="w-full" src="/demo/recording.m4a" controls preload="metadata">        <track kind="captions" src="/demo/recording.vtt" srcLang="en" label="English" />      </audio>      <section className="transcript" aria-label="Transcript" aria-controls="talk-audio" style={{ '--transcript-height': '15rem' } as React.CSSProperties}>        <ol className="transcript-list scroll-area"></ol>        <button type="button" className="btn btn-sm btn-pill transcript-return" hidden>          Back to current        </button>      </section>    </div>  )}
<script>  import { attach } from '@master/ui/behaviors'</script><div class="grid gap-sm max-w(480) mx-auto" {@attach attach}>  <audio id="talk-audio" class="w-full" src="/demo/recording.m4a" controls preload="metadata">    <track kind="captions" src="/demo/recording.vtt" srclang="en" label="English">  </audio>  <section class="transcript" aria-label="Transcript" aria-controls="talk-audio" style="--transcript-height: 15rem">    <ol class="transcript-list scroll-area"></ol>    <button type="button" class="btn btn-sm btn-pill transcript-return" hidden>      Back to current    </button>  </section></div>
<script setup>import { onMounted, onUnmounted, ref } from 'vue'import { attach } from '@master/ui/behaviors'const root = ref(null)let detachonMounted(() => { detach = attach(root.value) })onUnmounted(() => detach?.())</script><template>  <div ref="root" class="grid gap-sm max-w(480) mx-auto">    <audio id="talk-audio" class="w-full" src="/demo/recording.m4a" controls preload="metadata">      <track kind="captions" src="/demo/recording.vtt" srclang="en" label="English">    </audio>    <section class="transcript" aria-label="Transcript" aria-controls="talk-audio" style="--transcript-height: 15rem">      <ol class="transcript-list scroll-area"></ol>      <button type="button" class="btn btn-sm btn-pill transcript-return" hidden>        Back to current      </button>    </section>  </div></template>
字幕片段读取自 recording.vtt。没有脚本时这个列表保持为空,因此如果必须在没有脚本的情况下阅读,请把字幕片段写在页面中。

#行为脚本

transcript 接收根元素,即带有 transcript 类的元素,并返回用于解除绑定的函数。

app.js
import { transcript } from '@master/ui/behaviors/transcript.js'const detach = transcript(document.querySelector('.transcript'))
  • 媒体由 aria-controls 指定:可以是媒体播放器(行为脚本使用其 player-media),也可以是 <audio> 或 <video>。每次媒体报告状态时,行为脚本都会重新查找,因此在文字稿之后写入的媒体,或之后另行指定的媒体,也都能被跟进。media 选项可改为直接指定一个元素。
  • 字幕片段是带有 data-start(开始的秒数)的 li,其中包含一个 transcript-time 按钮和一个 transcript-text。在片段上任意位置按下都会从其开始处播放,除非读者正在选择其中的文字;在其时间上按 Enter 效果相同。
  • 由其他地方写入的行。 行为脚本每次都重新读取列表,不保存任何内容,因此渲染器可以写入并修改字幕片段。draw: false 会把空列表留给渲染器处理;track 选择用于写入字幕片段的轨道。行为脚本写入的行会在解除绑定时移除。
选项默认值
media取自 aria-controls要跟进的媒体元素
track第一条 captions 或 subtitles 轨道用于写入空列表的轨道
drawtrue是否根据轨道写入空列表

未加载行为脚本时,字幕片段只是一个供读者阅读的列表;不会标记任何片段,不会跟进,选择片段也不会跳转。

#键盘操作

所有时间按钮共用一个 Tab 停靠点,即当前片段的时间按钮,用方向键在它们之间移动,因此很长的文字稿不会让 Tab 键导航变得冗长。

按键操作
Tab进入列表时聚焦当前字幕片段的时间,没有时聚焦第一个,再按 Tab 键离开:整个列表只占一个 Tab 停靠点
ArrowDown, ArrowUp移到下一个或上一个字幕片段的时间
Home, End移到第一个或最后一个字幕片段的时间
Enter, Space从聚焦字幕片段的时间开始播放,行为与原生按钮一致

#无障碍

  • 用 aria-label,或用 aria-labelledby 指向一个标题,为文字稿命名,并在 aria-controls 中指定其媒体。
  • 当前片段带有 aria-current="true";样式表用墨色深浅和层次而不是色相来绘制它,在强制颜色模式下则使用系统轮廓线。
  • 媒体播放时,文字稿不会自行获取焦点。焦点只随读者的操作移动,使用返回按钮时会回到当前片段。
  • 纯音频内容需要提供文字稿,以便读者无需收听就能了解内容。如果页面必须在没有脚本的情况下阅读,请把文字稿写在页面中。

#React、Svelte 和 Vue

transcript 组件根据 cues 写入字幕片段,每个片段包含 start、text 和可选的 speaker,指定通过 media 传入的媒体,并绑定行为脚本,由行为脚本负责标记和跟进。使用 npx master-ui add transcript 将组件复制到项目中。有关这些组件的实现和用法,请参阅 React、Svelte 和 Vue。

ui/transcript.tsx
'use client'import { type ComponentProps } from 'react'import { clock, transcript } from '@master/ui/behaviors/transcript.js'import { useBehavior } from './use-behavior'export interface TranscriptCue {  /** The second the cue begins. */  start: number  /** What is said. */  text: string  /** Who says it, when the recording has several voices. */  speaker?: string}export interface TranscriptProps extends Omit<ComponentProps<'section'>, 'children' | 'ref'> {  /** The id of the player, or of the audio or video element, the transcript follows. */  media: string  /** The cues, in the order they are spoken. */  cues: TranscriptCue[]  /** The words of the button that brings the current cue back into view. */  returnLabel?: string}/** What a recording says, as cues that follow it as it plays. The rows are written from `cues`; the behavior marks and follows them. */export function Transcript({ media, cues, returnLabel = 'Back to current', className, ...root }: TranscriptProps) {  const ref = useBehavior(transcript, { draw: false })  return (    <section className={className ? `transcript ${className}` : 'transcript'} aria-controls={media} ref={ref} {...root}>      <ol className="transcript-list scroll-area">        {cues.map((cue, index) => (          <li className="transcript-cue" data-start={cue.start} key={`${cue.start}-${index}`}>            <button type="button" className="transcript-time">{clock(cue.start)}</button>            <p className="transcript-text">              {cue.speaker !== undefined && <span className="transcript-speaker">{cue.speaker}</span>}              {cue.text}            </p>          </li>        ))}      </ol>      <button type="button" className="btn btn-sm btn-pill transcript-return" hidden>{returnLabel}</button>    </section>  )}
ui/Transcript.svelte
<script lang="ts" module>  import type { HTMLAttributes } from 'svelte/elements'  export interface TranscriptCue {    /** The second the cue begins. */    start: number    /** What is said. */    text: string    /** Who says it, when the recording has several voices. */    speaker?: string  }  export interface TranscriptProps extends Omit<HTMLAttributes<HTMLElement>, 'children'> {    /** The id of the player, or of the audio or video element, the transcript follows. */    media: string    /** The cues, in the order they are spoken. */    cues: TranscriptCue[]    /** The words of the button that brings the current cue back into view. */    returnLabel?: string  }</script><script lang="ts">  import { clock, transcript } from '@master/ui/behaviors/transcript.js'  import { behavior } from './behavior.svelte.js'  let { media, cues, returnLabel = 'Back to current', class: className, ...root }: TranscriptProps = $props()  const attach = behavior(transcript, () => ({ draw: false }))</script><!--  @component  What a recording says, as cues that follow it as it plays. The rows are written from `cues`; the behavior marks and follows them.--><section class={['transcript', className]} aria-controls={media} {@attach attach} {...root}>  <ol class="transcript-list scroll-area">    {#each cues as cue, index (`${cue.start}-${index}`)}      <li class="transcript-cue" data-start={cue.start}>        <button type="button" class="transcript-time">{clock(cue.start)}</button>        <p class="transcript-text">          {#if cue.speaker !== undefined}<span class="transcript-speaker">{cue.speaker}</span>{/if}          {cue.text}        </p>      </li>    {/each}  </ol>  <button type="button" class="btn btn-sm btn-pill transcript-return" hidden>{returnLabel}</button></section>
ui/Transcript.vue
<script setup lang="ts">import { useTemplateRef } from 'vue'import { clock, transcript } from '@master/ui/behaviors/transcript.js'import { useBehavior } from './use-behavior'defineOptions({ inheritAttrs: false })export interface TranscriptCue {  /** The second the cue begins. */  start: number  /** What is said. */  text: string  /** Who says it, when the recording has several voices. */  speaker?: string}const { returnLabel = 'Back to current' } = defineProps<{  /** The id of the player, or of the audio or video element, the transcript follows. */  media: string  /** The cues, in the order they are spoken. */  cues: TranscriptCue[]  /** The words of the button that brings the current cue back into view. */  returnLabel?: string}>()/* What a recording says, as cues that follow it as it plays. The rows are written from `cues`; the behavior marks and follows them. */const root = useTemplateRef<HTMLElement>('root')useBehavior(root, transcript, () => ({ draw: false }))</script><template>  <section class="transcript" :aria-controls="media" ref="root" v-bind="$attrs">    <ol class="transcript-list scroll-area">      <li v-for="(cue, index) in cues" :key="`${cue.start}-${index}`" class="transcript-cue" :data-start="cue.start">        <button type="button" class="transcript-time">{{ clock(cue.start) }}</button>        <p class="transcript-text">          <span v-if="cue.speaker !== undefined" class="transcript-speaker">{{ cue.speaker }}</span>          {{ cue.text }}        </p>      </li>    </ol>    <button type="button" class="btn btn-sm btn-pill transcript-return" hidden>{{ returnLabel }}</button>  </section></template>

#类名

类名说明
transcript文字稿本体,位于其媒体旁。设置 aria-label,并用 aria-controls 指向它所跟随的播放器或媒体元素的 id
transcript-list字幕片段列表,应用于 ol,在 --transcript-height 内滚动。加上 scroll-area 可使边缘渐隐
transcript-cue一个字幕片段,即带 data-start(开始的秒数)的 li:先是时间,然后是文字。播放过后变淡,当前播放时以强调样式显示在凸起面板上。按下其上任意位置即从其时间开始播放
transcript-time字幕片段的开始时间,以小号等宽数字显示在从该处播放的按钮上。即列表的 Tab 停靠点
transcript-text字幕片段的文字
transcript-speaker录制内容有多位说话人时,显示在文字上方的说话人
transcript-return返回当前字幕片段:列表下缘的小号胶囊按钮,读者将当前字幕片段滚出视野前保持隐藏

返回按钮是一个按钮,即 btn btn-sm btn-pill,带有 transcript-return 部件类。

#自定义属性

属性默认值说明
--transcript-height20rem列表开始滚动前的最大高度在 transcript 上设置

#源码

@master/ui/components/transcript.css
/* * Transcript: what a recording says, as a list of cues that follows the media as it plays. * Each cue is a row with the time it begins, a small tabular button that is the row's way in from the keyboard, * and its words. Three inks say where the media is: a cue already played is quiet, the current cue * (aria-current="true") is strong and rests on a raised sheet, one step of depth like every current row, and the * cues still to come are in the body's ink. Played is derived from the current cue alone: every cue before it. * The list scrolls inside a height of its own (--transcript-height, 20rem) and the behavior keeps the current cue * in its middle. When the reader scrolls it away, the list stops following and a pill, transcript-return, stands * at its lower edge to bring it back. * Rows answer the pointer at once, with no fade. Without the behavior the cues are a list a reader reads, and * nothing is marked current. */@layer components.ui {  .transcript {    --transcript-height: 20rem;    --transcript-row-radius: var(--radius-control);    position: relative;    display: flex;    flex-direction: column;    min-width: 0;    min-height: 0;    margin: 0;  }  /* The cues, in a scroller of their own. Add scroll-area to fade the edges where the list goes on. */  .transcript-list {    display: grid;    align-content: start;    gap: 2px;    min-height: 0;    max-height: var(--transcript-height);    margin: 0;    padding: .25rem;    overflow: auto;    overscroll-behavior: contain;    list-style: none;    scroll-padding-block: 1rem;    /* The script listens on the whole list for a press on a cue: a tap must not flash the list grey on iOS. */    -webkit-tap-highlight-color: transparent;    /*     * The times share one column across the list, as wide as the longest: past an hour a time is wider than     * the column's least width, and the words of every cue still start on one line. Without subgrid each cue     * sizes its own column, which is the same until a time outgrows that least width.     */    @supports (grid-template-columns: subgrid) {      grid-template-columns: auto minmax(0, 1fr);    }  }  /* One cue: its time, then its words. The whole row seeks under the pointer. */  .transcript-cue {    display: grid;    grid-template-columns: auto minmax(0, 1fr);    align-items: baseline;    gap: .375rem;    margin: 0;    padding-block: .375rem;    padding-inline: .25rem .625rem;    border-radius: calc(var(--transcript-row-radius) * var(--corner-scale));    corner-shape: var(--corner-shape);    color: var(--color-text-body);    cursor: pointer;    -webkit-tap-highlight-color: transparent;    touch-action: manipulation;    @supports (grid-template-columns: subgrid) {      grid-column: 1 / -1;      grid-template-columns: subgrid;    }    /* A cue a search filters out is hidden: the grid above would otherwise beat the browser's own [hidden]. */    &[hidden] {      display: none;    }    /* A cue is a full-width row of a list: on touch a one-line cue is 44px tall, the target a finger is owed. */    @media (pointer: coarse) {      min-height: 2.75rem;      align-content: center;    }    @media (hover: hover) {      &:hover:not([aria-current="true"]) {        background: var(--color-surface-inset);      }    }    /* Pressed: a step deeper than the pointer's tone, so a tap on a cue is answered where there is no pointer. */    &:active:not([aria-current="true"]) {      background: var(--color-surface-inset-hover);    }    /* Already played: every cue before the current one. */    &:has(~ .transcript-cue[aria-current="true"]) {      color: var(--color-text-muted);    }    /* The cue being spoken: strong ink on a raised sheet. */    &[aria-current="true"] {      @apply --surface-sheet;      color: var(--color-text-strong);      box-shadow: var(--shadow-raised);    }    @media (forced-colors: active) {      &[aria-current="true"] {        outline: 2px solid Highlight;        outline-offset: -2px;      }    }  }  /* When the cue begins, as a button: Enter or a press on it plays from there. */  .transcript-time {    min-width: 2.75rem;    margin: 0;    padding: .1875rem .375rem;    border: 0;    border-radius: calc(var(--radius-chip) * var(--corner-scale));    corner-shape: var(--corner-shape);    background: transparent;    color: var(--color-text-muted);    font: var(--font-weight-control) .75rem/1.2 var(--font-family-sans);    font-variant-numeric: tabular-nums;    text-align: end;    appearance: none;    cursor: pointer;    -webkit-tap-highlight-color: transparent;    .transcript-cue[aria-current="true"] & {      color: var(--color-text-strong);    }    &:focus-visible {      @apply --focus-ring;      outline-offset: 0;    }    @media (forced-colors: active) {      &:focus-visible {        outline-color: Highlight;      }    }  }  /* The words of a cue. */  .transcript-text {    margin: 0;    font-size: .875rem;    line-height: 1.5;    text-wrap: pretty;    overflow-wrap: anywhere;  }  /* Who speaks, before the words, when the recording has several voices. */  .transcript-speaker {    display: block;    margin: 0;    color: var(--color-text-strong);    font-size: .75rem;    font-weight: var(--font-weight-control);    line-height: 1.5;  }  /*   * Back to the current cue: a pill at the list's lower edge, shown only while the reader has scrolled away.   * Write it as a small button (btn btn-sm btn-pill); this part places it and lets it fade in.   */  .transcript-return {    position: absolute;    inset-inline: 0;    bottom: .75rem;    width: fit-content;    margin-inline: auto;    transition-property: opacity, display, box-shadow, translate, color;    transition-behavior: allow-discrete;    &[hidden] {      display: none;      opacity: 0;    }    @starting-style {      opacity: 0;    }  }}