/* Entzun: escuchar la página con el TTS de Elhuyar (elh_listen.js). Lo usan el blog de las cuatro webs y la portada de TTS.
   Un reproductor en forma de píldora (botón redondo, título, quién pone la voz o el progreso, parar), un mini reproductor
   fijo abajo cuando el principal queda fuera de la pantalla, y lo que suena marcado: la frase subrayada y la palabra
   resaltada. Colores: los de elh_shell.css (y elh_theme.css en oscuro). La portada de TTS (fondo azul): landpage.css. */

.elh-listen { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .35rem .9rem; max-width: 100%; margin: 0 0 2.2rem;
	padding: .4rem 1.1rem .4rem .4rem; border: 1px solid var(--elh-line); border-radius: 999px; background: var(--elh-surface, #fff);
	box-shadow: 0 1px 2px rgba(16, 24, 40, .05); transition: box-shadow .2s, border-color .2s; }
.elh-listen.is-active { border-color: var(--elh-teal); box-shadow: 0 6px 20px -10px rgba(0, 128, 126, .5); }
.elh-listen__play { display: inline-flex; align-items: center; gap: .7rem; padding: 0; border: 0; background: none; color: var(--elh-ink);
	font: inherit; font-weight: 600; cursor: pointer; }
.elh-listen__icon { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; width: 2.6rem; height: 2.6rem;
	border-radius: 50%; background: var(--elh-teal-dark); color: #fff; font-size: .9rem; transition: background .15s, transform .15s; }
.elh-listen__icon .fa-play { margin-left: .15em; }                       /* el triángulo, centrado a la vista */
.elh-listen__play:hover .elh-listen__icon { background: var(--elh-blue); transform: scale(1.05); }
.elh-listen.is-playing .elh-listen__icon { background: var(--elh-blue); }
/* Con el ratón, sin el marco de foco del navegador (Bootstrap 4 lo pone en todo button:focus); con el teclado, el nuestro */
.elh-listen button:focus:not(:focus-visible), .elh-listen-float button:focus:not(:focus-visible) { outline: 0; box-shadow: none; }
.elh-listen__play:focus-visible, .elh-listen__stop:focus-visible { outline: 3px solid var(--elh-blue); outline-offset: 3px; border-radius: 999px; }
.elh-listen__label { white-space: nowrap; }
.elh-listen__body { display: inline-flex; flex-direction: column; justify-content: center; min-width: 0; }
.elh-listen__by { color: var(--elh-muted); font-size: .82rem; }
.elh-listen__by a { color: var(--elh-teal-dark) !important; text-decoration: underline !important; }
.elh-listen__by i { margin-right: .25rem; opacity: .8; }
.elh-listen.is-active .elh-listen__by { display: none; }                 /* al escuchar: el progreso en su lugar */
.elh-listen__progress { display: none; align-items: center; gap: .6rem; min-width: 9rem; }
.elh-listen.is-active .elh-listen__progress { display: inline-flex; }
.elh-listen__track { position: relative; flex: 1 1 auto; height: 4px; min-width: 6rem; overflow: hidden; border-radius: 4px; background: rgba(0, 128, 126, .18); }
.elh-listen__bar { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: inherit; background: var(--elh-teal-dark); transition: width .3s ease; }
.elh-listen__count { color: var(--elh-muted); font-size: .78rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.elh-listen__stop { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; padding: 0; border: 0;
	border-radius: 50%; background: transparent; color: var(--elh-muted); font-size: .8rem; cursor: pointer; }
.elh-listen__stop:hover { background: var(--elh-blue-hover, #f1f4fd); color: var(--elh-ink); }
.elh-listen__stop[hidden] { display: none; }
/* Error (elh_listen.js, .is-error): en la misma línea, en lugar de "Ahotsa: ...", con un icono; el borde, en rojo suave.
   Si no cabe en una línea (móvil), el reproductor pasa de píldora a tarjeta redondeada para que no quede deforme. */
.elh-listen__status { display: none; }
.elh-listen.is-error { border-color: rgba(200, 40, 40, .35); border-radius: 1.6rem; }
.elh-listen.is-error .elh-listen__by { display: none; }
.elh-listen.is-error .elh-listen__status { display: inline-flex; align-items: center; gap: .45rem; min-width: 0; flex: 1 1 14rem;
	color: var(--elh-danger, #b42318); font-size: .82rem; line-height: 1.35; }
.elh-listen.is-error .elh-listen__status::before { content: "\f071"; flex: 0 0 auto; font-family: "Font Awesome 5 Free"; font-weight: 900; font-size: .9em; }

/* Móvil: dos filas ordenadas en una tarjeta redondeada. Arriba el botón, el título y parar; debajo, alineado con el título,
   quién pone la voz, el progreso o el error (si no, se partía en cualquier sitio y chocaba con el borde de la píldora). */
@media (max-width: 575.98px) {
	.elh-listen { display: flex; row-gap: .15rem; border-radius: 1.6rem; padding: .45rem .6rem .55rem .45rem; }
	.elh-listen__stop { order: 1; margin-left: auto; }
	.elh-listen__body, .elh-listen.is-error .elh-listen__status { order: 2; flex: 1 1 100%; padding-left: 3.3rem; }
	.elh-listen.is-active .elh-listen__progress { display: flex; min-width: 0; }
}

/* Mini reproductor (abajo, centrado): cuando el reproductor de la página no se ve mientras se escucha */
.elh-listen-float { position: fixed; left: 50%; bottom: 1.25rem; z-index: 1040; display: flex; align-items: center; gap: .8rem;
	width: min(36rem, calc(100% - 2rem)); padding: .5rem .6rem .5rem .5rem; transform: translateX(-50%);
	border: 1px solid var(--elh-line); border-radius: 999px; background: var(--elh-surface, #fff);
	box-shadow: 0 12px 32px -8px rgba(16, 24, 40, .3); animation: elh-listen-in .2s ease-out; }
.elh-listen-float[hidden] { display: none; }
@keyframes elh-listen-in { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }
.elh-listen-float__play { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; width: 2.6rem; height: 2.6rem;
	border: 0; border-radius: 50%; background: var(--elh-teal-dark); color: #fff; cursor: pointer; }
.elh-listen-float.is-playing .elh-listen-float__play { background: var(--elh-blue); }
.elh-listen-float__play .fa-play { margin-left: .15em; }
.elh-listen-float__text { display: flex; flex: 1 1 auto; flex-direction: column; gap: .35rem; min-width: 0; }
.elh-listen-float__sentence { overflow: hidden; color: var(--elh-ink); font-size: .9rem; white-space: nowrap; text-overflow: ellipsis; }
.elh-listen-float__stop { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; width: 2.2rem; height: 2.2rem;
	border: 0; border-radius: 50%; background: transparent; color: var(--elh-muted); cursor: pointer; }
.elh-listen-float__stop:hover { background: var(--elh-blue-hover, #f1f4fd); color: var(--elh-ink); }
.elh-listen-float button:focus-visible { outline: 3px solid var(--elh-blue); outline-offset: 2px; }

/* Lo que suena: la frase, subrayada; la palabra, resaltada */
.tts-word.is-reading { text-decoration: underline; text-decoration-color: rgba(0, 172, 169, .55); text-decoration-thickness: 2px; text-underline-offset: .22em; }
.tts-word.is-spoken { border-radius: .25em; background: rgba(0, 172, 169, .22); box-shadow: 0 0 0 .14em rgba(0, 172, 169, .22); color: inherit; }
.elh-listen-on .tts-word { cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
	.elh-listen, .elh-listen__icon, .elh-listen__bar { transition: none; }
	.elh-listen-float { animation: none; }
}

html.theme-dark .elh-listen, html.theme-dark .elh-listen-float { background: var(--dk-surface, #1d2233); border-color: var(--elh-line); }
html.theme-dark .elh-listen.is-active { border-color: #006664; }
html.theme-dark .elh-listen__icon, html.theme-dark .elh-listen-float__play { background: #00807e; }
html.theme-dark .elh-listen.is-playing .elh-listen__icon, html.theme-dark .elh-listen-float.is-playing .elh-listen-float__play { background: var(--dk-fill, #3d5fe0); }
html.theme-dark .elh-listen__stop:hover, html.theme-dark .elh-listen-float__stop:hover { background: var(--dk-raised, #262d44); }
html.theme-dark .elh-listen.is-error { border-color: rgba(255, 138, 128, .4); }
html.theme-dark .elh-listen.is-error .elh-listen__status { color: #ff9b91; }
html.theme-dark .elh-listen__track { background: rgba(95, 224, 213, .2); }
html.theme-dark .elh-listen__bar { background: var(--dk-teal, #5fe0d5); }
html.theme-dark .tts-word.is-reading { text-decoration-color: rgba(95, 224, 213, .6); }
html.theme-dark .tts-word.is-spoken { background: rgba(95, 224, 213, .28); box-shadow: 0 0 0 .14em rgba(95, 224, 213, .28); color: #fff; }
