ナビゲーション

v2.1.0
メディア

トランスクリプト

録音の内容を、再生に合わせて追従するキューで表示します。

このページの内容

トランスクリプトは、録音で話されている内容を、それぞれ開始時刻を持つキューのリストとして示します。再生に合わせて追従し、現在のキューは浮き上がった面に強調表示し、再生済みのキューは控えめに、これから再生されるキューは通常の本文色で表示します。キューを選ぶと、録音がそこから再生されます。transcript のビヘイビアが、aria-controls で ID を指定したメディアプレーヤー、または通常の <audio> や <video> とトランスクリプトを結び付けます。

トランスクリプト

<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 を過ぎた最後のキューです。そのため、2 つのキューの間に間があっても位置が保たれます。それより前のキューは、スタイルシートだけで再生済みとして描画されます。

リストは現在のキューを中央に保ちます。スクロールするのはリスト自身だけで、周囲の要素はスクロールしないため、トランスクリプトを置いたページが読者の操作中に動くことはありません。スクロールは滑らかに行われ、動きを抑える設定をしている読者には瞬時に移動します。読者がホイール、指、キー、スクロールバーでリストをスクロールし、現在のキューが表示範囲から外れると、リストは追従を止めます。リストの下端に表示される小さなピル形の transcript-return で、元に戻せます。キューを選ぶか、現在のキューが再び表示範囲に入るまでスクロールすると、追従が再開します。

リストは --transcript-height の範囲内でスクロールします。指定しない場合は 20rem です。リストに scroll-area を追加すると、細いスクロールバーと、続きがある端のフェードが付きます。

#WebVTT トラックから生成する

リストが空の場合、ビヘイビアは TextTrack API を通じてメディアの最初の captions または subtitles のトラックを読み取り、キューを書き込みます。書き込むのは、時刻、タグを除いたテキスト、そして話者タグ(<v Ana>)で指定された話者です。トラックは disabled でなくなって初めてキューを読み込むため、ビヘイビアは disabled のトラックを hidden にします。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 は、キューを書き込む元のトラックを選びます。ビヘイビアが書き込んだ行は、解除時に削除されます。
オプション既定値
mediaaria-controls から取得追従するメディア要素
track最初の captions または subtitles のトラック空のリストを書き込む元のトラック
drawtrue空のリストをトラックから書き込むかどうか

ビヘイビアを適用しない場合、キューは読者が読むためのリストになります。何も強調されず、追従もせず、キューを選んでもシークしません。

#キーボード操作

Tab キーでフォーカスできる時刻ボタンは、現在のキューのボタンだけです。ボタン間は矢印キーで移動するため、トランスクリプトが長くても Tab キーの停止位置は増えません。

キー操作
Tab現在のキュー、なければ最初のキューの時刻でリストに入り、次の操作でリストから出ます。リスト全体が 1 つのタブストップです。
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 と、追従するプレーヤーまたはメディア要素の id を指定した aria-controls を付けます。
transcript-listキューのリストで、ol に指定し、--transcript-height の範囲内でスクロールします。scroll-area を追加すると端がフェードします。
transcript-cue1 つのキューで、開始秒を data-start に指定した li です。時刻、続いて内容を置きます。再生済みになると控えめに、現在のキューの間は浮き上がったシート上で強調表示します。どこを押してもその時刻から再生します。
transcript-timeキューの開始時刻で、小さな等幅数字で表示し、その時刻から再生するボタンに置きます。リストのタブストップです。
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;    }  }}