/* ==========================================================================
Popup témoignage vidéo (flottant, bas de page à gauche)
========================================================================== */
.mw-vt-popup {
    /* Couleurs de base, surchargées par les réglages du plugin */
    --mw-vt-primary: #1e3a5f;
    --mw-vt-secondary: #2f6aa3;
    --mw-vt-on-primary: #ffffff;

    /* Couleurs par zone : par défaut, dérivées des couleurs de base.
       Les réglages ne redéfinissent que celles qui ont été renseignées. */
    --mw-vt-toggle-bg: var(--mw-vt-primary);
    --mw-vt-toggle-icon: var(--mw-vt-on-primary);
    --mw-vt-toggle-bg-hover: var(--mw-vt-secondary);

    --mw-vt-header-bg: var(--mw-vt-primary);
    --mw-vt-header-text: var(--mw-vt-on-primary);
    --mw-vt-header-btn-bg: color-mix(in srgb, var(--mw-vt-header-text) 20%, transparent);
    --mw-vt-header-btn-icon: var(--mw-vt-header-text);

    --mw-vt-media-bg-start: var(--mw-vt-primary);
    --mw-vt-media-bg-end: var(--mw-vt-secondary);
    --mw-vt-play-bg: var(--mw-vt-on-primary);
    --mw-vt-play-icon: var(--mw-vt-primary);
    --mw-vt-play-ring: var(--mw-vt-play-bg);

    --mw-vt-panel-bg: #ffffff;
    /* --mw-vt-panel-text : sans valeur par défaut, le texte garde la couleur du thème */

    --mw-vt-cta-bg: var(--mw-vt-primary);
    --mw-vt-cta-text: var(--mw-vt-on-primary);
    --mw-vt-cta-bg-hover: var(--mw-vt-secondary);
    --mw-vt-cta-text-hover: var(--mw-vt-cta-text);

    position: fixed;
    left: 20px;
    bottom: 20px;
    z-index: 1000;
    line-height: 1.4;
}

/* Isolation légère vis-à-vis des styles du thème hôte */
.mw-vt-popup *,
.mw-vt-popup *::before,
.mw-vt-popup *::after {
    box-sizing: border-box;
}

.mw-vt-popup button {
    min-height: 0;
    margin: 0;
    font: inherit;
    line-height: 1;
    text-transform: none;
    letter-spacing: normal;
}

.mw-vt-popup iframe,
.mw-vt-popup video {
    max-width: none;
    margin: 0;
    border-radius: 0;
}

/* Bloc vidéo : bords droits, quels que soient les arrondis que le thème
   applique aux images et aux boutons */
.mw-vt-popup .mw-vt-media,
.mw-vt-popup .mw-vt-media .mw-vt-facade,
.mw-vt-popup .mw-vt-media img,
.mw-vt-popup .mw-vt-media .mw-vt-frame {
    border-radius: 0;
    margin: 0;
    box-shadow: none;
}

.mw-vt-popup .mw-vt-media img {
    max-width: none;
}

/* Masqué jusqu'à ce que le script ait choisi et injecté un témoignage */
.mw-vt-popup[hidden] {
    display: none;
}

/* Les display: block ci-dessous l'emportent sur la règle [hidden] du navigateur :
   il faut donc masquer explicitement les éléments que le script escamote. */
.mw-vt-popup [hidden] {
    display: none;
}

/* Bulle d'ouverture
   ========================================================================== */
.mw-vt-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 56px;
    width: 56px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background-color: var(--mw-vt-toggle-bg);
    color: var(--mw-vt-toggle-icon);
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
    transition: background-color .3s ease, transform .3s ease;
}

.mw-vt-toggle:hover {
    background-color: var(--mw-vt-toggle-bg-hover);
    transform: scale(1.05);
}

.mw-vt-toggle svg {
    height: 26px;
    width: 26px;
}

.mw-vt-toggle .mw-vt-icon-close,
.mw-vt-popup.is-open .mw-vt-toggle .mw-vt-icon-open {
    display: none;
}

.mw-vt-popup.is-open .mw-vt-toggle .mw-vt-icon-close {
    display: block;
}

/* Panneau
   ========================================================================== */
.mw-vt-panel {
    position: absolute;
    left: 0;
    bottom: calc(100% + 12px);
    width: 320px;
    max-width: calc(100vw - 40px);
    overflow: hidden;
    border-radius: 16px;
    background-color: var(--mw-vt-panel-bg);
    color: var(--mw-vt-panel-text);
    box-shadow: 0 8px 30px rgba(0, 0, 0, .25);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    pointer-events: none;
    transition: width .4s ease, opacity .3s ease, transform .3s ease, visibility .3s ease;
}

.mw-vt-popup.is-playing .mw-vt-panel {
    width: 500px;
}

.mw-vt-popup.is-open .mw-vt-panel {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    pointer-events: auto;
}

.mw-vt-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    background-color: var(--mw-vt-header-bg);
    color: var(--mw-vt-header-text);
}

/* flex + min-width : le titre absorbe l'espace et se tronque au lieu de
   repousser les flèches et la croix hors du panneau */
.mw-vt-header-title {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-weight: 600;
}

.mw-vt-nav {
    display: flex;
    align-items: center;
    gap: 4px;
}

.mw-vt-prev,
.mw-vt-next,
.mw-vt-close {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 28px;
    width: 28px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background-color: var(--mw-vt-header-btn-bg);
    color: var(--mw-vt-header-btn-icon);
    cursor: pointer;
    transition: background-color .4s ease;
}

.mw-vt-prev:hover,
.mw-vt-next:hover,
.mw-vt-close:hover {
    /* Le fond se rapproche de la couleur de l'icône, quelle que soit la palette */
    background-color: color-mix(in srgb, var(--mw-vt-header-btn-bg), var(--mw-vt-header-btn-icon) 30%);
}

.mw-vt-prev svg,
.mw-vt-next svg {
    height: 20px;
    width: 20px;
}

.mw-vt-close svg {
    height: 18px;
    width: 18px;
}

/* Façade puis lecteur
   ========================================================================== */
.mw-vt-media {
    position: relative;
    aspect-ratio: 16 / 9;
    background: linear-gradient(135deg, var(--mw-vt-media-bg-start), var(--mw-vt-media-bg-end));
}

.mw-vt-facade {
    display: block;
    height: 100%;
    width: 100%;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
}

.mw-vt-facade img {
    height: 100%;
    width: 100%;
    display: block;
    object-fit: cover;
}

.mw-vt-play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    height: 60px;
    width: 60px;
    border-radius: 50%;
    background-color: var(--mw-vt-play-bg);
    color: var(--mw-vt-play-icon);
    box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
    transition: transform .3s ease;
}

.mw-vt-facade:hover .mw-vt-play {
    transform: translate(-50%, -50%) scale(1.1);
}

.mw-vt-play svg {
    height: 32px;
    width: 32px;
}

/* Anneau qui tourne en continu autour du bouton, pour appeler à la lecture */
.mw-vt-play::before {
    content: "";
    position: absolute;
    top: -9px;
    right: -9px;
    bottom: -9px;
    left: -9px;
    border-radius: 50%;
    border: 3px solid color-mix(in srgb, var(--mw-vt-play-ring) 35%, transparent);
    border-top-color: var(--mw-vt-play-ring);
    animation: mw-vt-spin 1.4s linear infinite;
}

@keyframes mw-vt-spin {
    to {
        transform: rotate(360deg);
    }
}

@media (prefers-reduced-motion: reduce) {
    .mw-vt-play::before {
        animation: none;
    }
}

/* En absolu : le lecteur occupe exactement le cadre 16/9, sans pousser le panneau */
.mw-vt-frame {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    border: none;
    display: block;
}

/* Vidéo de la médiathèque : format quelconque (portrait compris), cadrée sans rognage */
video.mw-vt-frame {
    object-fit: contain;
    background: #000;
}

/* Contenu
   ========================================================================== */
.mw-vt-body {
    padding: 14px;
}

.mw-vt-text {
    margin: 0;
    font-size: .95em;
    line-height: 1.5;
}

.mw-vt-cta {
    display: block;
    margin-top: 14px;
    padding: 10px 16px;
    border-radius: 8px;
    background-color: var(--mw-vt-cta-bg);
    color: var(--mw-vt-cta-text);
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    transition: background-color .3s ease;
}

.mw-vt-cta:hover,
.mw-vt-cta:focus {
    background-color: var(--mw-vt-cta-bg-hover);
    color: var(--mw-vt-cta-text-hover);
}

@media (max-width: 600px) {
    .mw-vt-popup {
        left: 15px;
        bottom: 15px;
    }
    .mw-vt-toggle {
        height: 48px;
        width: 48px;
    }
    .mw-vt-toggle svg {
        height: 22px;
        width: 22px;
    }
    .mw-vt-panel {
        max-width: calc(100vw - 30px);
    }
}
