/* Deep Dive 5 - "read it to me" buttons.
 * A block that has a recording gets a small Listen button. Asked for by Lilah, a student
 * reviewer, 2026-10-10. Nothing plays until the reader presses it: no autoplay, ever,
 * because a page that starts talking by itself is worse than one that stays quiet.
 * Scoped to .dd5-audio* so it cannot touch anything that does not opt in.
 */

.dd5-audio-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: "Work Sans", system-ui, sans-serif;
  font-weight: 600;
  font-size: 14.5px;
  line-height: 1;
  color: var(--accent-dark, #1B3A5C);
  background: #fff;
  border: 2px solid var(--accent-dark, #1B3A5C);
  border-radius: 999px;
  padding: 6px 13px 6px 10px;
  margin: 0 0 8px;
  cursor: pointer;
}
.dd5-audio-btn:hover { background: #F4FBF8; }
.dd5-audio-btn:focus-visible { outline: 3px solid #F4A261; outline-offset: 2px; }
.dd5-audio-btn svg { width: 16px; height: 16px; flex: none; }

/* while this one is playing */
.dd5-audio-btn.is-playing {
  background: var(--accent-dark, #1B3A5C);
  color: #fff;
}

/* the file did not load: say so rather than looking like a dead button */
.dd5-audio-btn[disabled] {
  opacity: .55;
  cursor: default;
  border-style: dashed;
}

/* Inside one of Finn's bubbles the button sits under the name, flush left. */
.dd5-say .dd5-audio-btn { margin: 2px 0 7px; }

/* On a dark "say" band the bubble keeps light text, so the button has to invert too. */
.lesson-card.say .dd5-say .dd5-audio-btn { background: #fff; color: var(--navy, #1B3A5C); border-color: var(--navy, #1B3A5C); }
.lesson-card.say .dd5-say .dd5-audio-btn.is-playing { background: var(--navy, #1B3A5C); color: #fff; }

@media print {
  .dd5-audio-btn { display: none !important; }
}

/* On a word card the button is the icon alone. Five "Listen" pills in a row would shout
 * louder than the five words they belong to. The accessible name still carries the full
 * sentence, so nothing is lost to a screen reader.
 * The word itself is a block, so an inline button would drop onto the definition line and
 * sit on top of the text. Pin it to the corner instead and keep the word clear of it. */
.word.dd5-has-audio { position: relative; }
.word.dd5-has-audio b { padding-right: 32px; }
.word .dd5-audio-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  margin: 0;
  padding: 4px;
  width: 26px;
  height: 26px;
  border-width: 1.5px;
}
.word .dd5-audio-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.word .dd5-audio-btn svg { width: 14px; height: 14px; }

/* On a plain teaching paragraph the button sits inline at the start of the text, icon
 * only. A full pill on its own line would read as a heading for the paragraph rather
 * than a control attached to it. */
p.dd5-has-audio > .dd5-audio-btn {
  margin: 0 9px 0 0;
  padding: 4px;
  width: 26px;
  height: 26px;
  border-width: 1.5px;
  vertical-align: -5px;
}
p.dd5-has-audio > .dd5-audio-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
p.dd5-has-audio > .dd5-audio-btn svg { width: 14px; height: 14px; }

/* A character who has a recording is clickable. The pointer is the only hint needed;
 * the Listen button beside her is the real control and the one a keyboard reaches. */
[data-dd5-audio] .dd5-finn, [data-dd5-audio] .dd5-fig { cursor: pointer; }
[data-dd5-audio] .dd5-finn:hover, [data-dd5-audio] .dd5-fig:hover { opacity: .78; }

/* A "say" block whose character speaks only in audio: no bubble, just the figure and
 * the button sitting next to her. */
.dd5-say-audio { align-items: center; }
.dd5-say-audio .dd5-audio-btn { margin: 0; }

/* A section opener: the character and one Listen line, no speech bubble. Janet, 2026-10-10,
 * after three bubbles on one page started to read as furniture. */
.dd5-say-audio { align-items: center; margin: 0 0 14px; }
.dd5-say-audio > .dd5-audio-btn { margin: 0; justify-self: start; align-self: center; }
