/* 1) Wrapper en grille 2 lignes x 4 colonnes */
.speech-tts-wrapper {
  display: grid;
  grid-template-columns: auto auto 1fr auto auto;
  grid-template-rows: auto auto;
  gap: 0 1rem;
  width: 100%;
  max-width: 100%;
  margin: 10px 0;
  position: relative;
  align-items: center;
  padding: 10px 20px 20px 20px;
  height: 70px;  
  border-radius: 5px;  
  box-sizing: border-box;
  border: 1px solid transparent;
}

/* 2) Le titre injecté en colonne 2, ligne 1 */
.speech-tts-wrapper::before {
  content: "Écouter cet article";
  grid-column: 2;
  grid-row: 1;
  font-size: 1rem;
  font-weight: 500;
  color: #2D3748;
}

/* Lecteurs distincts : TTS vs MP3 (classes pour ciblage / surcharge) */
.speech-player-tts { /* lecteur TTS (Web Speech API) */ }
.speech-player-mp3 { /* lecteur MP3 (fichier audio) */ }
.speech-player-auto { /* lecteur unique (mode auto) */ }
.speech-progress-tts,
.speech-progress-mp3 { /* barres de progression dédiées */ }

/* Conteneur dual : 2 lecteurs côte à côte */
.speech-tts-dual-container {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin: 10px 0;
}

.speech-tts-dual-container .speech-tts-wrapper {
  flex: 1;
  min-width: 280px;
}

/* En mode dual, masquer le ::before et afficher le label */
.speech-tts-dual-container .speech-tts-wrapper::before {
  content: none;
}

.speech-player-label {
  grid-column: 2;
  grid-row: 1;
  font-size: 0.875rem;
  font-weight: 600;
  color: #2D3748;
  align-self: center;
}

/* Cacher le titre automatique dès que la lecture a démarré */
.speech-tts-wrapper.has-started::before {
  display: none;
}

/* 3) Bouton Play en colonne 1, ligne 1 */
.speech-tts-button {
  grid-column: 1;
  grid-row: 1;
  color: #FFF;
  border: none;
  width: 46px;
  height: 46px;
  border-radius: 5px;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  position: relative;
  margin-bottom: -20px;
  background-color: #0061a7; /* Couleur par défaut */
}
/* Variantes du bouton : forme */
.speech-tts-button.pxn-btn-round { border-radius: 50%; }
.speech-tts-button.pxn-btn-square { border-radius: 4px; }

/* Variantes du bouton : taille */
.speech-tts-button.pxn-btn-small { width: 54px; height: 54px; margin-bottom: -21px; }
.speech-tts-button.pxn-btn-small .icon-play { border-left-width: 20px; border-top-width: 12px; border-bottom-width: 12px; }
.speech-tts-button.pxn-btn-normal { width: 46px; height: 46px; margin-bottom: -20px; }
.speech-tts-button.pxn-btn-large { width: 56px; height: 56px; margin-bottom: -24px; }
.speech-tts-button.pxn-btn-large .icon-play { border-left-width: 20px; border-top-width: 12px; border-bottom-width: 12px; }

/* Variantes du bouton : ombre */
.speech-tts-button.pxn-btn-shadow { box-shadow: 0 2px 6px rgba(0,0,0,0.15); }
.speech-tts-button.pxn-btn-flat { box-shadow: none; }

/* 4) Chrono en colonne 4, ligne 1, aligné à droite */
.speech-time {
  grid-column: 4;
  grid-row: 1;
  justify-self: end;
  font-size: 0.875rem;
  color: #2D3748;
  min-width: 60px;
  text-align: right;
}

/* 3) Bouton Vitesse en colonne 5, rangée 1, collé au bord droit */
.speech-speed-button {
  grid-column: 5;
  grid-row: 1;
  justify-self: end;   /* bord droit de la grille */
  align-self: center;  /* milieu vertical du wrapper */
  border: none;
  font-size: 0.875rem;
  cursor: pointer;
  /* optionnel : ajustez padding/marge selon votre design */
  padding: 0 0.5rem;
  /* Masquer temporairement (fonctionnalités toujours actives) */
  display: none !important;
}

/* 5) Barre de progression : de la colonne 2 à la dernière, ligne 2 */
.speech-progress {
  grid-column: 2 / -1;
  /* CORRECTION : doit être en ligne 2 */
  grid-row: 2;

  /* valeur initiale du point de rupture du dégradé */
  --val: 0%;
  --progress-color: #4abfff; /* Couleur par défaut de la barre de progression */
  --progress-track-bg-color: #e2e8f0; /* Couleur de la barre de fond (piste non lue) */
  --progress-track-height: 4px; /* Réglage pxn_speech_progress_height (surchargé par le wrapper) */

  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: var(--progress-track-height, 4px);
  box-shadow: inset 0 1px 0 #ccc;
  border-radius: 6px;
  cursor: pointer;
  margin: 0;
  padding: 0;
}

/* Styles du track avec dégradé dynamique (hauteur = réglage pxn_speech_progress_height) */
.speech-progress::-webkit-slider-runnable-track {
  height: var(--progress-track-height, 4px);
  background: linear-gradient(to right, var(--progress-color) 0%, var(--progress-color) var(--val), var(--progress-track-bg-color, #e2e8f0) var(--val), var(--progress-track-bg-color, #e2e8f0) 100%);
  border-radius: 2px;
  border: none;
}

.speech-progress::-moz-range-track {
  height: var(--progress-track-height, 4px);
  background: linear-gradient(to right, var(--progress-color) 0%, var(--progress-color) var(--val), var(--progress-track-bg-color, #e2e8f0) var(--val), var(--progress-track-bg-color, #e2e8f0) 100%);
  border-radius: 2px;
  border: none;
}

/* Thumb avec couleur dynamique (with border) */
.speech-progress::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--progress-color);
  cursor: pointer;
  margin-top: -6px;  /* centrer verticalement (track 4px) */
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.speech-progress::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.speech-progress::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border: none;
  border-radius: 50%;
  background: var(--progress-color);
  cursor: pointer;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.speech-progress::-moz-range-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

/* Focus styles pour l'accessibilité */
.speech-progress:focus {
  outline: none;
}

.speech-progress:focus::-webkit-slider-thumb {
  box-shadow: 0 0 0 3px rgba(74, 191, 255, 0.3);
}

.speech-progress:focus::-moz-range-thumb {
  box-shadow: 0 0 0 3px rgba(74, 191, 255, 0.3);
}

/* Option : curseur de la barre de progression sans bordure (plus petit, sans ombre) */
.speech-tts-wrapper.pxn-progress-no-border .speech-progress::-webkit-slider-thumb {
  border: none;
  box-shadow: none;
  width: 11px;
  height: 11px;
  margin-top: -3.5px;
}
.speech-tts-wrapper.pxn-progress-no-border .speech-progress::-webkit-slider-thumb:hover {
  box-shadow: none;
}
.speech-tts-wrapper.pxn-progress-no-border .speech-progress:focus::-webkit-slider-thumb {
  box-shadow: 0 0 0 2px rgba(74, 191, 255, 0.4);
}
.speech-tts-wrapper.pxn-progress-no-border .speech-progress::-moz-range-thumb {
  border: none;
  box-shadow: none;
  width: 11px;
  height: 11px;
}
.speech-tts-wrapper.pxn-progress-no-border .speech-progress::-moz-range-thumb:hover {
  box-shadow: none;
}
.speech-tts-wrapper.pxn-progress-no-border .speech-progress:focus::-moz-range-thumb {
  box-shadow: 0 0 0 2px rgba(74, 191, 255, 0.4);
}

/* Mot en cours de lecture */
.speech-word.reading {
  font-size: 1.2em;
  border-radius: 5px;
  padding: 5px 8px;
}

.speech-tts-button:hover{
	opacity:0.8;
}

/* Tooltip horodatage barre — supprimé */
.speech-progress-tooltip { display: none !important; visibility: hidden !important; pointer-events: none !important; position: absolute !important; left: -9999px !important; }

.icon-play {
    display: inline-block;
    width: 0;
    height: 0;
    /* Triangle pointing to the right */
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    border-left: 17px solid #fff; /* couleur blanche */
    /* Ajustements optionnels pour le positionnement */
    vertical-align: middle;
    margin-left: 6px;
}

.icon-pause {
    display: inline-block;
    width: 16px;     /* largeur totale du pictogramme (2 barres + espace) */
    height: 20px;    /* même hauteur que le triangle play */
    position: relative;
    vertical-align: middle;
    margin-left: 2px;/* même décalage que .icon-play */
}

.icon-pause::before,
.icon-pause::after {
    content: "";
    position: absolute;
    top: 0;
    width: 5px;      /* épaisseur de chaque barre */
    height: 100%;    /* reprendra les 20px du parent */
    background: #fff;/* couleur blanche */
    border-radius: 1px; /* coins légèrement arrondis */
}

.icon-pause::before {
    left: 0;         /* barre de gauche */
}

.icon-pause::after {
    right: 0;        /* barre de droite */
}

/* Animation 4 barres pendant la lecture (style ChatGPT, centrée verticalement) */
.speech-bars {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    height: 75%;
    min-height: 18px;
    vertical-align: middle;
    margin-left: 0px;
}
/* Chaque barre est centrée et grandit depuis le centre ; hauteur max = 75% du bouton */
/* border-radius: valeur grande = coins au max (largeur 5px => bords gauche/droite arrondis à 2.5px) */
.speech-bars .speech-bar {
    width: 5px;
    height: 100%;
    background: #fff;
    border-radius: 999px;
    transform-origin: center center;
    transform: scaleY(0.4);
}
/* Rythme type voix : attaque rapide, décroissance plus douce, cycles décalés (syllabes/formants) */
.speech-bars .speech-bar:nth-child(1) {
    animation: speech-voice-1 0.36s cubic-bezier(0.25, 0.46, 0.45, 0.94) infinite;
    animation-delay: 0s;
}
.speech-bars .speech-bar:nth-child(2) {
    animation: speech-voice-2 0.44s cubic-bezier(0.33, 0.66, 0.66, 1) infinite;
    animation-delay: 0.07s;
}
.speech-bars .speech-bar:nth-child(3) {
    animation: speech-voice-3 0.4s cubic-bezier(0.39, 0.58, 0.57, 0.9) infinite;
    animation-delay: 0.14s;
}
.speech-bars .speech-bar:nth-child(4) {
    animation: speech-voice-4 0.38s cubic-bezier(0.3, 0.5, 0.5, 0.95) infinite;
    animation-delay: 0.2s;
}
/* Silence (blancs / pauses) : barres minimales, micro-animation réaliste */
.speech-tts-button.speech-bars-silent .speech-bars .speech-bar {
    animation: speech-bar-silent 1.5s ease-in-out infinite;
    animation-delay: 0s;
    transform: scaleY(0.15);
}
.speech-tts-button.speech-bars-silent .speech-bars .speech-bar:nth-child(1) { animation-delay: 0s; }
.speech-tts-button.speech-bars-silent .speech-bars .speech-bar:nth-child(2) { animation-delay: 0.15s; }
.speech-tts-button.speech-bars-silent .speech-bars .speech-bar:nth-child(3) { animation-delay: 0.3s; }
.speech-tts-button.speech-bars-silent .speech-bars .speech-bar:nth-child(4) { animation-delay: 0.45s; }
@keyframes speech-bar-silent {
    0%, 100% { transform: scaleY(0.1); }
    50% { transform: scaleY(0.25); }
}
.speech-tts-button.pxn-btn-small .speech-bars .speech-bar { width: 5px; }
.speech-tts-button.pxn-btn-large .speech-bars .speech-bar { width: 6px; }
/* Enveloppe type parole : montée rapide (attaque), redescente plus étalée */
/* Barre 1 (extrême) : toujours plus basse que 2 et 3, max ~0.62 */
@keyframes speech-voice-1 {
    0%, 100% { transform: scaleY(0.18); }
    8%  { transform: scaleY(0.25); }
    18% { transform: scaleY(0.62); }
    38% { transform: scaleY(0.35); }
    55% { transform: scaleY(0.48); }
    72% { transform: scaleY(0.22); }
    88% { transform: scaleY(0.28); }
}
@keyframes speech-voice-2 {
    0%  { transform: scaleY(0.35); }
    22% { transform: scaleY(0.98); }
    45% { transform: scaleY(0.55); }
    62% { transform: scaleY(0.92); }
    78% { transform: scaleY(0.42); }
    100% { transform: scaleY(0.35); }
}
@keyframes speech-voice-3 {
    0%  { transform: scaleY(0.2); }
    15% { transform: scaleY(0.45); }
    35% { transform: scaleY(0.88); }
    52% { transform: scaleY(1); }
    70% { transform: scaleY(0.5); }
    85% { transform: scaleY(0.3); }
    100% { transform: scaleY(0.2); }
}
/* Barre 4 (extrême) : toujours plus basse que 2 et 3, max ~0.62 */
@keyframes speech-voice-4 {
    0%, 100% { transform: scaleY(0.28); }
    20% { transform: scaleY(0.5); }
    48% { transform: scaleY(0.62); }
    65% { transform: scaleY(0.42); }
    82% { transform: scaleY(0.55); }
}

/* Styles pour le ticker défilant */
.ticker-text {
  /* Utiliser la grille pour un positionnement plus fiable */
  grid-column: 2 / 4;  /* De la colonne 2 à la colonne 4 (avant le chrono) */
  grid-row: 1;
  justify-self: start;
  align-self: center;
  overflow: hidden;

  /* Apparence texte */
  white-space: nowrap;
  font-size: 1rem;
  font-weight: 500;
  color: #2D3748;
  line-height: 1.2;
  max-width: 100%;

  /* Masqué par défaut avant le premier clic */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;

  /* Transition pour les changements d'état */
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

/* État visible du ticker */
.ticker-text.visible {
  opacity: 1;
  visibility: visible;
}







/* Styles pour le lecteur sticky */
.speech-tts-wrapper.sticky-enabled {
  transition: all 0.3s ease;
}

/* Styles pour le lecteur sticky */
/* Sticky top (mode existant) */
.speech-tts-wrapper.sticky-enabled.is-sticky:not(.is-sticky-down) {
  position: sticky;
  top: 0; /* contrôlé dynamiquement via style.top */
  left: 0;
  right: 0;
  z-index: 9999;
  animation: slideDown 0.3s ease;
  margin: 0;
  box-shadow: 0 3px 3px rgb(100 100 100 / 40%);
}

/* Sticky down: plein écran collé en bas */
.speech-tts-wrapper.sticky-enabled.is-sticky.is-sticky-down {
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
  max-width: 100%;
  bottom: 0; /* ajusté en JS via style.bottom */
  z-index: 99999;
  animation: slideUp 0.3s ease;
  border-radius: 0 !important;
  margin: 0;
  box-shadow: 0 0 10px rgba(100 100 100 /  40%);
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

/* Responsive : désactiver le sticky sur mobile */
@media (max-width: 600px) {
  .speech-tts-wrapper.sticky-enabled.is-sticky {
    position: relative !important;
    top: auto !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    z-index: auto !important;
    animation: none !important;
  }
  
}

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to   { transform: translateY(0); }
}

/* Désactivation complète des transitions de couleur */
.speech-tts-wrapper *,
.speech-tts-wrapper *::before,
.speech-tts-wrapper *::after {
  transition-property: none !important;
  transition-duration: 0s !important;
  transition-delay: 0s !important;
}