/* The spoken letter. One quiet line under the title, a thin thread in the left margin while it
   plays, and a small floating row once that line has scrolled away. Nothing here exists on a
   letter without audio: the script only builds it when the letter carries a recording.

   One fixed 48px slot holds the invitation and the open controls, so starting, pausing and
   closing never move the prose or the scroll position. */

#voice{position:relative;display:block;width:250px;max-width:100%;height:48px;margin:-13px 0 26px;padding:0;
  font:500 15px/1.5 Figtree,system-ui,sans-serif;color:var(--ink);
  opacity:0;transition:opacity 600ms ease}
#voice[hidden]{display:none}
#voice.is-open{z-index:2}
html.se-reading #voice{opacity:1}
#letterBody.has-voice{position:relative}

#voice button{font:inherit;font-size:13px;border:0;border-radius:0;background:none;color:#625c54;min-height:44px;padding:0;
  cursor:pointer;touch-action:manipulation}
#voice button:active{color:var(--amber-deep)}
#voice button:hover{text-decoration:underline;text-underline-offset:5px}
#voice button:focus-visible{outline:1px solid #956932;outline-offset:2px}

/* The invitation: an outlined play mark with two sound arcs, and the words. */
#voice .voice-invite{position:absolute;top:0;left:0;isolation:isolate;display:inline-flex;align-items:center;gap:10px;
  height:48px;min-height:48px;margin:0;padding:0 4px 0 0;min-width:0;font-size:14px;white-space:nowrap;
  color:#645f57;text-decoration:none;transition:color 650ms ease}
#voice .voice-invite:hover,#voice .voice-invite:focus-visible{color:#34312c;text-decoration:none}
#voice .voice-invite svg{width:27px;height:27px;overflow:visible}
#voice.is-open .voice-invite{left:190px;min-width:44px;font-size:12px}
#voice.is-open .voice-invite svg{display:none}
.voice-entry{fill:none;stroke:#996b32;stroke-width:1.25;stroke-linecap:round;stroke-linejoin:round}
.voice-entry .entry-play{fill:transparent;transition:fill 250ms ease}
.voice-entry .sound-near,.voice-entry .sound-far{stroke-width:1;transition:transform 300ms ease,opacity 250ms ease}
.voice-entry .sound-far{opacity:.35}
.voice-invite:hover .entry-play,.voice-invite:focus-visible .entry-play{fill:#ead2af}
.voice-invite:hover .sound-far,.voice-invite:focus-visible .sound-far{opacity:.85}
.voice-invite:focus-visible .sound-far{transform:translateX(1px)}
@media (hover:hover) and (pointer:fine){ .voice-invite:hover .sound-far{transform:translateX(1px)} }

/* The open controls share the slot: Pause/Resume, time left. Close is the invitation itself. */
#voice .voice-panel{position:absolute;left:0;top:0;width:180px;opacity:0;visibility:hidden;pointer-events:none;
  transition:opacity 220ms ease,visibility 220ms}
#voice.is-open .voice-panel{opacity:1;visibility:visible;pointer-events:auto}
#voice .voice-row{display:flex;flex-wrap:nowrap;align-items:center;gap:18px;min-height:48px}
#voice .voice-toggle{display:inline-flex;align-items:center;justify-content:flex-start;gap:7px;min-width:76px;min-height:48px;font-weight:600}
.voice-mark{display:block;flex:none;width:10px;height:12px}
.voice-mark .pause-mark{display:none}
#voice[data-state="playing"] .play-mark,#voice[data-state="loading"] .play-mark{display:none}
#voice[data-state="playing"] .pause-mark,#voice[data-state="loading"] .pause-mark{display:block}
.voice-clock{font-size:12px;color:#6d665e;font-variant-numeric:tabular-nums;white-space:nowrap}
#voice .voice-message{position:absolute;top:43px;left:0;margin:0;padding:0;white-space:nowrap;font-size:12px;line-height:18px;color:var(--meta)}
#voice .voice-message:empty{display:none}

/* The margin: a fine thread beside the sentence being spoken, and a small sun that travels
   down it as the sentence is read. */
.voice-overlay{position:absolute;inset:0;pointer-events:none;z-index:1}
.voice-thread{position:absolute;left:-22px;top:0;width:14px;
  transition:transform 1100ms cubic-bezier(.4,0,.2,1),height 1100ms cubic-bezier(.4,0,.2,1)}
.voice-thread i{position:absolute;left:6px;top:5px;bottom:5px;width:1px;background:#d8cbb9}
.voice-sun{position:absolute;top:0;left:-18.5px;width:6px;height:6px;border-radius:50%;background:#b08042;will-change:transform}

/* The drift: one sun travels between the logo and the margin. While it flies, the logo's sun and
   the margin sun are both hidden, so only one is ever seen. */
html.se-sun-away #symbolSlot circle{opacity:0}
.voice-overlay.is-travelling .voice-sun{visibility:hidden}
.voice-traveller{--sun-deep:#b08042;position:fixed;left:0;top:0;z-index:30;width:8px;height:8px;border-radius:50%;
  background:var(--amber);pointer-events:none;visibility:hidden;transform-origin:center;will-change:transform}
.voice-traveller.is-flying{visibility:visible}

/* The small floating row, once the main controls have scrolled out of view. */
.voice-dock{position:fixed;z-index:45;left:50%;right:auto;bottom:max(16px,env(safe-area-inset-bottom));transform:translateX(-50%);
  width:max-content;max-width:calc(100vw - 40px);padding:2px 12px;border:0;border-radius:16px;
  background:#f8f8f7;box-shadow:0 2px 12px rgb(40 37 31 / 4.5%);color:#625e58;font:13px/1.4 Figtree,system-ui,sans-serif}
.voice-dock[hidden]{display:none}
.voice-dock-inner{display:flex;align-items:center;gap:12px;min-height:44px;margin:0}
.voice-dock button{font:inherit;font-size:13px;min-height:44px;min-width:48px;padding:0 4px;background:none;border:0;color:inherit;cursor:pointer}
.voice-dock button:hover{color:#443f37}
.voice-dock button:focus-visible{outline:1px solid #956932;outline-offset:0;border-radius:5px}
.voice-dock .dock-close{font-size:12px;color:#69645d}
.voice-dock .dock-clock{font-size:12px;font-variant-numeric:tabular-nums}

@media (max-width:600px){
  .voice-thread{left:-20px}
  .voice-sun{left:-16.5px}
}
@media (prefers-reduced-motion:reduce){
  #voice,#voice .voice-panel,.voice-thread,.voice-entry *{transition:none !important}
  .voice-invite:hover .voice-entry *,.voice-invite:focus-visible .voice-entry *{transform:none !important}
}
@media (forced-colors:active){
  .voice-thread i,.voice-sun,.voice-traveller{background:CanvasText !important}
  .voice-dock{background:Canvas;color:CanvasText;border:1px solid CanvasText;box-shadow:none}
}
