/* Spoken — audio player, sits above article content. */

.spoken {
  --spoken-accent: var(--Brand-Colour-1, #1ca695);
  --spoken-ink: var(--Brand-Colour-3, #24213b);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0 0 1.75rem;
  padding: 0.75rem 1rem;
  border: 1px solid rgb(36 33 59 / 12%);
  border-radius: 12px;
  background: #fff;
  color: var(--spoken-ink);
}

.spoken__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--spoken-accent);
  color: var(--spoken-ink);
  cursor: pointer;
  transition: background-color 150ms ease;
}

.spoken__toggle:hover {
  background: color-mix(in srgb, var(--spoken-accent) 82%, #000);
}

.spoken__toggle:focus-visible {
  outline: 3px solid var(--spoken-ink);
  outline-offset: 3px;
}

.spoken__icon {
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0.55rem 0 0.55rem 0.9rem;
  border-color: transparent transparent transparent currentcolor;
  transform: translateX(2px);
}

/*
 * Sticky once playback has been used and the page has been scrolled: the
 * player follows the reader down the article and stays put if they pause.
 * Before anyone presses play it stays in the flow.
 */
.spoken.is-stuck {
	position: -webkit-sticky;
	position: sticky;
	top: var(--spoken-top, 1.25rem);
	z-index: 1;
	box-shadow: 0 6px 20px rgb(36 33 59 / 12%);
}

.spoken.is-playing .spoken__icon {
  width: 0.8rem;
  height: 0.9rem;
  border: 0;
  transform: none;
  background:
    linear-gradient(currentcolor, currentcolor) left center / 0.28rem 100%
      no-repeat,
    linear-gradient(currentcolor, currentcolor) right center / 0.28rem 100%
      no-repeat;
}

.spoken__body {
  flex: 1 1 auto;
  min-width: 0;
}

.spoken__label {
  margin: 0 0 0.35rem;
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1.2;
}

.spoken__scrub {
  padding: 0.4rem 0;
  cursor: pointer;
}

.spoken__scrub:focus-visible {
  outline: 2px solid var(--spoken-ink);
  outline-offset: 2px;
  border-radius: 4px;
}

.spoken__track {
  display: block;
  height: 4px;
  border-radius: 999px;
  background: rgb(36 33 59 / 15%);
}

.spoken__fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: var(--spoken-accent);
}

.spoken__time {
  flex: 0 0 auto;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.spoken__rate select {
  padding: 0.25rem 0.4rem;
  border: 1px solid rgb(36 33 59 / 20%);
  border-radius: 6px;
  background: #fff;
  color: var(--spoken-ink);
  font: inherit;
  font-size: 0.8125rem;
}

.spoken audio {
  display: none;
}

/*
 * Small screens: one compact row. The player is pinned for the rest of the
 * article once it is in use, so it has to stay short enough not to eat the
 * viewport — the label goes and the controls tighten up.
 */
@media (max-width: 600px) {
	.spoken {
		flex-wrap: nowrap;
		gap: 0.5rem;
		padding: 0.5rem 0.75rem;
		border-radius: 10px;
	}

	.spoken__label {
		display: none;
	}

	.spoken__toggle {
		width: 2.5rem;
		height: 2.5rem;
	}

	.spoken__time {
		font-size: 0.75rem;
	}

	.spoken__rate select {
		padding: 0.2rem 0.3rem;
		font-size: 0.75rem;
	}

	.spoken.is-stuck {
		top: var(--spoken-top, 0.5rem);
	}
}

/* Landscape phones and other very short viewports: keep it to a slim bar. */
@media (max-height: 520px) {
	.spoken {
		padding: 0.4rem 0.6rem;
		gap: 0.5rem;
	}

	.spoken__toggle {
		width: 2.25rem;
		height: 2.25rem;
	}

	.spoken__time,
	.spoken__rate select {
		font-size: 0.75rem;
	}

	.spoken__label {
		display: none;
	}

	.spoken.is-stuck {
		top: var(--spoken-top, 0.25rem);
	}
}

@media (prefers-reduced-motion: reduce) {
  .spoken__toggle {
    transition: none;
  }
}
