/* The Listen to this article button with captions that follow the voice. Warm paper in a soft light from the top
   left, with a fine grain; in the middle one ivory pill (.la__pill, moved and stretched only by GSAP). Inside, in one
   rounded box: the ivory fill, the light under the pointer, the hairline of the reading progress and the edges.
   Then the ink disc (play and pause drawn as two halves that morph), the rest face (Listen to this article) and the
   player (waveform, time, speed roller, close). Under the pill the caption: the sentence being read, with a marker. */
:root {
  --paper: #f2ede3;           /* the paper of the page */
  --paper-light: #fffaf0;     /* the soft light on the paper */
  --paper-shade: #ddd4c4;     /* the paper in shadow, at the edges */
  --pill: #fffcf6;            /* the ivory of the pill */
  --ink: #1d1a16;             /* the ink: disc, words, bars */
  --accent: #df5a2e;          /* the vermilion: the live bars, the marker, the progress */
  --mark: #f7d9c9;            /* the marker behind the word being read */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

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

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

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

/* the paper: a soft light from the top left, the shade at the edges and a fine grain */
.stage {
  position: relative;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
  background:
    radial-gradient(min(90vw, 720px) min(70vh, 520px) at 34% 22%, var(--paper-light), transparent 70%),
    radial-gradient(min(140vw, 1100px) min(110vh, 820px) at 50% 50%, transparent 52%, color-mix(in srgb, var(--paper-shade) 70%, transparent)),
    var(--paper);
}

.stage::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.55;
  mix-blend-mode: multiply;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.45 0 0 0 0 0.38 0 0 0 0 0.3 0 0 0 0.16 0'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
}

.la {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(88vw, 360px);
}

/* ---- the pill ---- */
.la__pill {
  --mx: 30%;
  --my: 40%;
  position: relative;
  height: 60px;
  border-radius: 999px;
  isolation: isolate;
  box-shadow:
    0 1px 1px rgba(60, 44, 28, 0.08),
    0 3px 6px -2px rgba(60, 44, 28, 0.1),
    0 14px 26px -12px rgba(60, 44, 28, 0.26),
    0 34px 54px -30px rgba(60, 44, 28, 0.34);
  transition: box-shadow 0.3s ease;
}

.la__skin,
.la__fill,
.la__light,
.la__edge {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}

.la__skin {
  overflow: hidden;
}

/* ivory, lighter at the top, a warm shade low down */
.la__fill {
  background:
    linear-gradient(180deg, #ffffff 0%, var(--pill) 46%, color-mix(in srgb, var(--pill) 88%, var(--paper-shade)) 100%);
}

.la__light {
  opacity: 0;
  background: radial-gradient(140px 80px at var(--mx) var(--my), rgba(255, 255, 255, 0.95), transparent 70%);
  transition: opacity 0.35s ease;
}

/* the edge that takes the light: brighter on top, a warm line underneath */
.la__edge {
  box-shadow:
    inset 0 0 0 1px rgba(60, 44, 28, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 1),
    inset 0 -1px 0 rgba(120, 92, 60, 0.08);
}

/* the hairline of the reading, along the bottom of the open player */
.la__track {
  position: absolute;
  left: 64px;
  right: 26px;
  bottom: 7px;
  height: 2px;
  border-radius: 2px;
  background: rgba(29, 26, 22, 0.07);
  opacity: 0;
}

.la__done {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 60%, transparent), var(--accent));
  transform-origin: 0 50%;
  transform: scaleX(0.44);
}

@media (hover: hover) {
  .la__pill:hover .la__light {
    opacity: 1;
  }

  .la__pill.is-rest:hover {
    box-shadow:
      0 1px 1px rgba(60, 44, 28, 0.08),
      0 4px 8px -2px rgba(60, 44, 28, 0.12),
      0 18px 30px -12px rgba(60, 44, 28, 0.3),
      0 40px 60px -30px rgba(60, 44, 28, 0.38);
  }

  .la__pill.is-rest:hover .la__disc-face {
    transform: scale(1.05);
  }

  .la__pill.is-rest:hover .la__icon {
    transform: translateX(1px);
  }
}

/* the button over the whole pill while it rests */
.la__open {
  position: absolute;
  inset: 0;
  z-index: 3;
  appearance: none;
  border: 0;
  margin: 0;
  padding: 0;
  border-radius: inherit;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.la__open:focus-visible,
.la__disc:focus-visible,
.la__speed:focus-visible,
.la__close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

/* ---- the ink disc ---- */
.la__disc {
  position: absolute;
  z-index: 2;
  left: 8px;
  top: 8px;
  width: 44px;
  height: 44px;
  appearance: none;
  border: 0;
  margin: 0;
  padding: 0;
  border-radius: 50%;
  background: none;
  color: var(--pill);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.la__disc-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(28px 20px at 38% 26%, rgba(255, 255, 255, 0.2), transparent 70%),
    linear-gradient(180deg, #3a342d 0%, var(--ink) 62%, #0f0d0b 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -2px 3px rgba(0, 0, 0, 0.35),
    0 1px 1px rgba(29, 26, 22, 0.3),
    0 6px 12px -6px rgba(29, 26, 22, 0.6);
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.la__icon {
  width: 22px;
  height: 22px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 1.3;
  stroke-linejoin: round;
  overflow: visible;
  transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---- the rest face ---- */
.la__rest {
  position: absolute;
  left: 64px;
  top: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  white-space: nowrap;
  pointer-events: none;
}

.la__title {
  font-size: 15px;
  font-weight: 620;
  font-stretch: 104%;
  letter-spacing: -0.01em;
  line-height: 1.1;
}

.la__sub {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 480;
  font-stretch: 96%;
  color: rgba(29, 26, 22, 0.52);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.la__phones {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.4;
  stroke-linecap: round;
}

.la__phones rect {
  fill: currentColor;
  stroke: none;
}

/* ---- the player ---- */
.la__ctrl {
  position: absolute;
  z-index: 2;
  left: 62px;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 8px;
  visibility: hidden;
}

.la__wave {
  position: relative;
  flex: 1 1 auto;
  min-width: 40px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 22%, #000 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 22%, #000 100%);
}

.la__bar {
  flex: 0 0 auto;
  width: 2px;
  height: 3px;
  border-radius: 2px;
  background: var(--ink);
}

.la__bar.is-live {
  background: var(--accent);
}

.la__bar {
  transition: opacity 0.4s ease;
}

.la__wave.is-quiet .la__bar {
  opacity: 0.32;
}

.la__time {
  flex: 0 0 auto;
  display: flex;
  align-items: baseline;
  gap: 3px;
  font-size: 13px;
  font-weight: 600;
  font-stretch: 100%;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  transition: color 0.3s ease;
}

.la__time.is-quiet .la__now {
  color: rgba(29, 26, 22, 0.5);
}

.la__now {
  display: inline-flex;
  transition: color 0.3s ease;
}

.la__digit {
  position: relative;
  display: inline-block;
  overflow: hidden;
  height: 1.2em;
  line-height: 1.2em;
  vertical-align: bottom;
}

.la__digit > span {
  display: block;
}

.la__digit > span + span {
  position: absolute;
  left: 0;
  top: 0;
}

.la__total {
  font-size: 11px;
  font-weight: 480;
  color: rgba(29, 26, 22, 0.42);
}

/* the speed: a small chip with a roller of values */
.la__speed,
.la__close {
  position: relative;
  flex: 0 0 auto;
  appearance: none;
  border: 0;
  margin: 0;
  padding: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.la__speed {
  height: 30px;
}

.la__speed-face {
  display: grid;
  place-items: center;
  height: 100%;
  padding: 0 8px;
  border-radius: 9px;
  background: linear-gradient(180deg, rgba(29, 26, 22, 0.035), rgba(29, 26, 22, 0.065));
  box-shadow: inset 0 0 0 1px rgba(29, 26, 22, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  transition: background 0.25s ease, box-shadow 0.25s ease;
}

.la__speed-win {
  position: relative;
  display: block;
  height: 16px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 22%, #000 78%, transparent);
  mask-image: linear-gradient(180deg, transparent, #000 22%, #000 78%, transparent);
}

.la__speed-col {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.la__speed-col > span {
  display: block;
  height: 16px;
  line-height: 16px;
  font-size: 12px;
  font-weight: 650;
  font-stretch: 92%;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.la__close {
  width: 26px;
  height: 26px;
}

.la__close-face {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  color: rgba(29, 26, 22, 0.5);
  transition: background 0.25s ease, color 0.25s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.la__close svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

@media (hover: hover) {
  .la__speed:hover .la__speed-face {
    background: linear-gradient(180deg, rgba(223, 90, 46, 0.06), rgba(223, 90, 46, 0.11));
    box-shadow: inset 0 0 0 1px rgba(223, 90, 46, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  }

  .la__close:hover .la__close-face {
    background: rgba(29, 26, 22, 0.06);
    color: var(--ink);
    transform: rotate(90deg);
  }

  .la__disc:hover .la__disc-face {
    transform: scale(1.05);
  }
}

/* ---- the caption under the pill ---- */
.la__cap {
  width: 100%;
  height: 0;
  overflow: hidden;
}

.la__cap-in {
  padding: 22px 6px 4px;
}

.la__kicker {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 560;
  font-stretch: 110%;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(29, 26, 22, 0.42);
}

.la__line {
  position: relative;
  margin: 0;
  font-family: 'Fraunces Variable', Georgia, serif;
  font-size: clamp(16px, min(4.6vw, 3.6vh), 19px);
  font-variation-settings: 'opsz' 24, 'SOFT' 50;
  font-weight: 420;
  line-height: 1.42;
  letter-spacing: -0.005em;
  min-height: calc(3 * 1.42em);
}

.la__w {
  position: relative;
  z-index: 1;
  display: inline-block;
  color: rgba(29, 26, 22, 0.3);
  transition: color 0.28s ease;
}

.la__w.is-past {
  color: rgba(29, 26, 22, 0.86);
}

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

.la__mark {
  position: absolute;
  z-index: 0;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  border-radius: 6px;
  background: var(--mark);
  box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--accent) 55%, transparent);
  opacity: 0;
}

/* the drawn pointer of the loop */
.la__pointer {
  position: absolute;
  z-index: 5;
  left: 0;
  top: 0;
  width: 26px;
  height: 26px;
  opacity: 0;
  pointer-events: none;
  fill: var(--ink);
  stroke: #fffcf6;
  stroke-width: 1.4;
  stroke-linejoin: round;
  filter: drop-shadow(0 3px 4px rgba(29, 26, 22, 0.28));
}
