/* The voice message with the transcript that lights up word by word: one bubble of a messaging app on black. The
   bubble is a dark layered surface with a 1px edge that catches light at the top and a faint grain; behind it a warm
   glow wakes up while the message plays. The words of the transcript are spans; one pill behind them slides on a
   spring to the word being said. */
:root {
  --page: #000000;          /* the page */
  --bubble: #141417;        /* the bubble */
  --bubble-low: #0e0e10;    /* the bottom of the bubble */
  --edge: rgba(255, 255, 255, 0.075); /* the edge of the bubble */
  --ink: #f1f0ee;           /* the words */
  --muted: #8b8a90;         /* the small words */
  --accent: #ff9a5a;        /* the accent: the played bars, the play button, the pill */
  --accent-2: #ff5f6d;      /* where the accent ends, at the far end of the wave */
  --accent-ink: #fff1e6;    /* the word being said */
  --button-ink: #1a0d06;    /* the icon on the play button */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
.wave:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
}

/* ---- the bubble ---- */
.voice {
  position: relative;
  width: min(90vw, 356px);
  padding: 14px 16px 14px;
  border-radius: 22px 22px 22px 8px;
  background: linear-gradient(180deg, var(--bubble) 0%, var(--bubble-low) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    inset 0 0 0 1px var(--edge),
    0 1px 2px rgba(0, 0, 0, 0.6),
    0 18px 40px -18px rgba(0, 0, 0, 0.9),
    0 40px 80px -40px rgba(0, 0, 0, 0.9);
  isolation: isolate;
  opacity: 0;
}

/* the warm glow behind the bubble, awake while it plays */
.voice__glow {
  position: absolute;
  inset: 10% 6% -6%;
  z-index: -1;
  border-radius: 40px;
  background: radial-gradient(60% 60% at 30% 40%, color-mix(in oklab, var(--accent) 55%, transparent), transparent 70%),
    radial-gradient(50% 50% at 80% 70%, color-mix(in oklab, var(--accent-2) 45%, transparent), transparent 70%);
  filter: blur(34px);
  opacity: 0;
  pointer-events: none;
}

.voice__grain {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0.06;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}

.voice__head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.voice__avatar {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 10.5px;
  font-weight: 650;
  font-stretch: 110%;
  letter-spacing: 0.02em;
  color: var(--button-ink);
  background: linear-gradient(140deg, var(--accent-ink), var(--accent) 60%, var(--accent-2));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 0 0 1px rgba(0, 0, 0, 0.4);
}

.voice__who {
  margin: 0;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.voice__name {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
}

.voice__kind,
.voice__clock {
  font-size: 11.5px;
  color: var(--muted);
}

.voice__clock {
  font-variant-numeric: tabular-nums;
  align-self: flex-start;
  margin-top: 2px;
}

/* ---- the row: play, wave, speed ---- */
.voice__row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.play {
  flex: none;
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
}

.play__face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(155deg, var(--accent-ink) -30%, var(--accent) 45%, var(--accent-2) 120%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.55),
    inset 0 -2px 4px rgba(120, 30, 0, 0.25),
    0 6px 16px -6px color-mix(in oklab, var(--accent) 70%, transparent),
    0 0 0 1px rgba(0, 0, 0, 0.5);
}

.play svg {
  width: 20px;
  height: 20px;
  fill: var(--button-ink);
}

.wave {
  flex: 1;
  min-width: 0;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  touch-action: none;
  border-radius: 6px;
}

.bar {
  flex: none;
  width: 3px;
  height: var(--h, 40%);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.17);
  transform-origin: 50% 50%;
  transition: background-color 0.18s ease, box-shadow 0.18s ease;
}

.bar.is-on {
  background: color-mix(in oklab, var(--accent-2) calc(var(--k) * 100%), var(--accent));
}

/* the bars of the word being said */
.bar.is-now {
  background: var(--accent-ink);
  box-shadow: 0 0 8px color-mix(in oklab, var(--accent) 70%, transparent);
}

/* the bars of the word under the pointer in the transcript: where a tap would jump */
.bar.is-peek {
  background: color-mix(in oklab, var(--accent) 55%, rgba(255, 255, 255, 0.25));
}

.speed {
  flex: none;
  height: 26px;
  min-width: 40px;
  padding: 0 9px;
  border-radius: 13px;
  font-size: 12px;
  font-weight: 620;
  font-stretch: 112%;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.07);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.09), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transition: background-color 0.25s ease, color 0.25s ease, box-shadow 0.25s ease;
}

.speed.is-fast {
  color: var(--accent-ink);
  background: color-mix(in oklab, var(--accent) 22%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--accent) 50%, transparent), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.speed__win {
  position: relative;
  display: block;
  overflow: hidden;
  height: 16px;
  line-height: 16px;
}

.speed__val {
  display: block;
  white-space: nowrap;
}

/* ---- the meta row: time and the Transcript button ---- */
.voice__meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding-left: 56px;
}

.voice__time {
  margin: 0;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.voice__of {
  color: var(--muted);
}

.tbtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 8px 0 9px;
  margin-right: -4px;
  border-radius: 13px;
  font-size: 12px;
  font-weight: 560;
  color: var(--muted);
  transition: color 0.2s ease, background-color 0.2s ease;
}

.tbtn[aria-expanded="true"] {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
}

.tbtn svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tbtn__win {
  display: block;
  overflow: hidden;
  height: 16px;
  line-height: 16px;
}

.tbtn__words {
  display: block;
}

/* ---- the transcript ---- */
.trans {
  overflow: hidden;
  height: 0;
}

.trans__in {
  position: relative;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.trans__text {
  position: relative;
  margin: 0;
  padding: 0 4px;
  font-size: 15px;
  line-height: 1.62;
  letter-spacing: -0.003em;
  font-weight: 460;
}

.trans__pill {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 0;
  border-radius: 7px;
  background: color-mix(in oklab, var(--accent) 24%, transparent);
  box-shadow: inset 0 0 0 1px color-mix(in oklab, var(--accent) 48%, transparent),
    0 4px 14px -6px color-mix(in oklab, var(--accent) 60%, transparent);
  opacity: 0;
  pointer-events: none;
}

.w {
  position: relative;
  z-index: 1;
  display: inline-block;
  padding: 0 3px;
  margin: 0 -3px;
  border-radius: 6px;
  color: rgba(241, 240, 238, 0.3);
  cursor: pointer;
  transition: color 0.22s ease;
}

.w.is-said {
  color: var(--ink);
}

.w.is-now {
  color: var(--accent-ink);
}

.trans__sweep {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: 40%;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, color-mix(in oklab, var(--accent) 22%, transparent), transparent);
  opacity: 0;
  z-index: 2;
}

@media (hover: hover) {
  .play:hover .play__face {
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.6),
      inset 0 -2px 4px rgba(120, 30, 0, 0.25),
      0 8px 22px -6px color-mix(in oklab, var(--accent) 85%, transparent),
      0 0 0 1px rgba(0, 0, 0, 0.5);
  }
  .speed:hover { background: rgba(255, 255, 255, 0.11); }
  .speed.is-fast:hover { background: color-mix(in oklab, var(--accent) 30%, transparent); }
  .tbtn:hover { color: var(--ink); background: rgba(255, 255, 255, 0.06); }
  .w:hover:not(.is-now) { background: rgba(255, 255, 255, 0.07); }
}

/* ---- the drawn pointer of the autopilot ---- */
.ghost {
  position: fixed;
  left: 0;
  top: 0;
  width: 22px;
  height: 22px;
  fill: #ffffff;
  stroke: #000000;
  stroke-width: 1.3;
  stroke-linejoin: round;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  z-index: 5;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}

@media (prefers-reduced-motion: reduce) {
  .bar,
  .w,
  .speed,
  .tbtn {
    transition-duration: 0.01s;
  }
}
