網站導覽

v2.1.0
媒體

逐字稿

以字幕片段呈現錄音的內容,並在播放時跟著進度移動。

本頁內容

逐字稿以字幕片段(cue)清單呈現錄音的內容,每個片段都標有開始時間。播放錄音時,逐字稿會跟著進度移動:目前播放的片段以醒目的文字和有層次感的底色突顯,已播放的片段會淡化,尚未播放的片段則維持一般內文色。選擇某個片段,錄音就會從該處開始播放。transcript 行為會將它連接到媒體播放器或一般的 <audio>、<video>,連接對象由 aria-controls 中的 id 指定。

逐字稿

<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 停駐點
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回到目前片段:位於清單下緣的小型膠囊按鈕,在讀者將目前片段捲出可見範圍之前都會隱藏

返回按鈕是帶有 transcript-return 部件的按鈕,即 btn btn-sm btn-pill。

#自訂屬性

屬性預設值說明
--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;    }  }}