/* ==========================================================================
   Infobulle flottante (bloc personnalisé .tsb-infobulle)
   Bouton flottant en bas à gauche (en bas à droite en arabe) + infobulle
   ouverte par défaut. Comportement : js/infobulle.js
   ========================================================================== */

.tsb-infobulle {
    --tsb-ib-gutter: 24px;
    --tsb-ib-size: 60px;
    --tsb-ib-gap: 18px;
    --tsb-ib-offset: 0px; /* hauteur visible du bandeau cookies, mise à jour par le JS */
    --tsb-ib-icon-message: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5.5 4h13A2.5 2.5 0 0 1 21 6.5v8a2.5 2.5 0 0 1-2.5 2.5H11l-4.2 3.4c-.33.27-.8.03-.8-.39V17h-.5A2.5 2.5 0 0 1 3 14.5v-8A2.5 2.5 0 0 1 5.5 4z'/%3E%3Cpath d='M7.5 8.75h9M7.5 12.25h6'/%3E%3C/svg%3E");
    --tsb-ib-icon-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9.5l6 6 6-6'/%3E%3C/svg%3E");
    --tsb-ib-icon-close: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E");

    position: fixed;
    left: var(--tsb-ib-gutter);
    bottom: calc(var(--tsb-ib-gutter) + var(--tsb-ib-offset));
    z-index: 1000; /* au-dessus du bloc accès rapide (999), sous les modales et le bandeau cookies */
    width: var(--tsb-ib-size);
    height: var(--tsb-ib-size);
    font-family: inherit;
    line-height: 1.4;
    transition: bottom .25s ease;
}

/* Masqué tant que le JS n'a pas appliqué l'état (évite tout clignotement) */
.tsb-infobulle:not(.is-ready) {
    display: none;
}

.tsb-infobulle,
.tsb-infobulle *,
.tsb-infobulle *::before,
.tsb-infobulle *::after {
    box-sizing: border-box;
}

/* Neutralise le clearfix global « div:after » du thème (clean.css) */
.tsb-infobulle::after,
.tsb-infobulle div::after {
    content: none;
}

/* Si le bloc est saisi avec CKEditor, celui-ci peut entourer les boutons d'un <p> */
.tsb-infobulle p:not(.tsb-infobulle__text) {
    display: contents;
}

/** bouton flottant **/

.tsb-infobulle__toggle {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #435463;
    color: #fff;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, .9), 0 10px 24px rgba(24, 37, 69, .28), 0 2px 6px rgba(24, 37, 69, .16);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.tsb-infobulle.is-ready .tsb-infobulle__toggle {
    animation: tsb-ib-pop .45s cubic-bezier(.2, .9, .3, 1.25) backwards;
}

.tsb-infobulle__toggle:hover {
    background: #303e4a;
    transform: translateY(-2px);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, .9), 0 14px 28px rgba(24, 37, 69, .32), 0 3px 8px rgba(24, 37, 69, .18);
}

.tsb-infobulle__toggle:active {
    transform: scale(.95);
}

/* Icône : bulle de message, remplacée par un chevron quand l'infobulle est ouverte */
.tsb-infobulle__toggle::before {
    content: "";
    width: 26px;
    height: 26px;
    background-color: currentColor;
    -webkit-mask: var(--tsb-ib-icon-message) center / contain no-repeat;
    mask: var(--tsb-ib-icon-message) center / contain no-repeat;
    animation: tsb-ib-icon .3s ease;
}

.tsb-infobulle.is-open .tsb-infobulle__toggle::before {
    width: 24px;
    height: 24px;
    -webkit-mask-image: var(--tsb-ib-icon-chevron);
    mask-image: var(--tsb-ib-icon-chevron);
    animation-name: tsb-ib-icon-alt;
}

/* Pastille rouge « non lu » */
.tsb-infobulle__toggle::after {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: 18px;
    height: 18px;
    border: 3px solid #fff;
    border-radius: 50%;
    background: #d90937;
    transform: scale(0);
    transition: transform .25s ease;
}

.tsb-infobulle.is-unread .tsb-infobulle__toggle::after {
    transform: scale(1);
}

.tsb-infobulle.is-unread:not(.is-open) .tsb-infobulle__toggle::after {
    animation: tsb-ib-pulse 2s ease-out 1s infinite;
}

/** infobulle **/

.tsb-infobulle__panel {
    position: absolute;
    left: 0;
    bottom: calc(100% + var(--tsb-ib-gap));
    display: flex;
    flex-direction: column;
    width: 380px;
    max-width: calc(100vw - 2 * var(--tsb-ib-gutter));
    max-height: calc(100vh - var(--tsb-ib-offset) - var(--tsb-ib-size) - var(--tsb-ib-gap) - 2 * var(--tsb-ib-gutter));
    max-height: calc(100dvh - var(--tsb-ib-offset) - var(--tsb-ib-size) - var(--tsb-ib-gap) - 2 * var(--tsb-ib-gutter));
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: #fff;
    box-shadow: 0 18px 40px rgba(24, 37, 69, .18), 0 3px 10px rgba(24, 37, 69, .10);
    color: #566573;
    text-align: left;
    opacity: 0;
    visibility: hidden;
    transform: translateY(14px) scale(.96);
    transform-origin: calc(var(--tsb-ib-size) / 2) 100%;
    transition: opacity .2s ease, transform .2s ease, visibility 0s linear .2s;
}

.tsb-infobulle.is-open .tsb-infobulle__panel {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: opacity .25s ease, transform .35s cubic-bezier(.2, .9, .3, 1.15), visibility 0s;
}

/* Filet rouge TSB en haut de l'infobulle (comme le bloc accès rapide) */
.tsb-infobulle__panel::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2;
    height: 4px;
    border-radius: 4px 4px 0 0;
    background: #d90937;
}

/* Pointe de la bulle, centrée sur le bouton flottant */
.tsb-infobulle__panel::after {
    content: "";
    position: absolute;
    top: 100%;
    left: calc(var(--tsb-ib-size) / 2 - 9px);
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 9px 9px 0;
    border-color: #fff transparent transparent;
    filter: drop-shadow(0 3px 2px rgba(24, 37, 69, .08));
}

.tsb-infobulle .tsb-infobulle__close {
    position: absolute;
    top: 24px;
    right: 16px;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #435463;
    cursor: pointer;
    transition: background-color .2s ease, color .2s ease;
}

.tsb-infobulle .tsb-infobulle__close::before {
    content: "";
    width: 14px;
    height: 14px;
    background-color: currentColor;
    -webkit-mask: var(--tsb-ib-icon-close) center / contain no-repeat;
    mask: var(--tsb-ib-icon-close) center / contain no-repeat;
}

.tsb-infobulle .tsb-infobulle__close:hover {
    background: #f0f4f5;
    color: #d90937;
}

.tsb-infobulle__body {
    flex: 1 1 auto;
    min-height: 0;
    padding: 28px 28px 28px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: #c2d1de transparent;
}

.tsb-infobulle .tsb-infobulle__title {
    margin: 0 0 12px;
    padding: 0 32px 0 0;
    font-family: inherit;
    font-size: 20px;
    font-weight: 700;
    line-height: 1.35;
    color: #435463;
}

.tsb-infobulle .tsb-infobulle__text {
    margin: 0;
    font-size: 16px;
    font-weight: 400;
    line-height: 1.65;
    color: #566573;
}

.tsb-infobulle__actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 24px;
}

/** boutons (reprennent les boutons du site : rayon 3px, graisse 600) **/

.tsb-infobulle .tsb-infobulle__btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 48px;
    margin: 0;
    padding: 12px 20px;
    border: 1px solid transparent;
    border-radius: 3px;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.25;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    transition: background-color .2s ease, border-color .2s ease, color .2s ease;
}

.tsb-infobulle .tsb-infobulle__btn--secondary {
    border-color: #9ba8b5;
    background: #fff;
    color: #435463;
}

.tsb-infobulle .tsb-infobulle__btn--secondary:hover {
    border-color: #435463;
    background: #435463;
    color: #fff;
}

.tsb-infobulle .tsb-infobulle__btn--primary {
    border-color: #d90937;
    background: #d90937;
    color: #fff;
}

.tsb-infobulle .tsb-infobulle__btn--primary:hover {
    border-color: #d90937;
    background: #fff;
    color: #d90937;
}

/** focus clavier **/

.tsb-infobulle .tsb-infobulle__toggle:focus-visible,
.tsb-infobulle .tsb-infobulle__close:focus-visible,
.tsb-infobulle .tsb-infobulle__btn:focus-visible {
    outline: 2px solid #d90937;
    outline-offset: 3px;
}

.tsb-infobulle .tsb-infobulle__sr {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/** animations **/

@keyframes tsb-ib-pop {
    from { opacity: 0; transform: translateY(16px) scale(.6); }
    to { opacity: 1; transform: none; }
}

@keyframes tsb-ib-icon {
    from { opacity: 0; transform: scale(.4); }
    to { opacity: 1; transform: none; }
}

/* Copie de tsb-ib-icon : changer de nom relance l'animation à chaque bascule */
@keyframes tsb-ib-icon-alt {
    from { opacity: 0; transform: scale(.4); }
    to { opacity: 1; transform: none; }
}

@keyframes tsb-ib-pulse {
    0% { box-shadow: 0 0 0 0 rgba(217, 9, 55, .55); }
    70%, 100% { box-shadow: 0 0 0 10px rgba(217, 9, 55, 0); }
}

/** responsive **/

@media (max-width: 767px) {
    .tsb-infobulle {
        --tsb-ib-gutter: 16px;
        --tsb-ib-size: 52px;
        --tsb-ib-gap: 14px;
    }

    .tsb-infobulle__toggle::before {
        width: 23px;
        height: 23px;
    }

    .tsb-infobulle__panel {
        width: calc(100vw - 2 * var(--tsb-ib-gutter));
    }

    .tsb-infobulle__body {
        padding: 24px 20px 22px;
    }

    .tsb-infobulle .tsb-infobulle__close {
        top: 18px;
        right: 10px;
    }

    .tsb-infobulle .tsb-infobulle__title {
        font-size: 18px;
    }

    .tsb-infobulle .tsb-infobulle__text {
        font-size: 15px;
        line-height: 1.6;
    }

    .tsb-infobulle__actions {
        gap: 10px;
        margin-top: 20px;
    }

    .tsb-infobulle .tsb-infobulle__btn {
        min-height: 46px;
    }
}

/** arabe (RTL) : en bas à droite, le bloc accès rapide passant à gauche **/

[dir="rtl"] .tsb-infobulle {
    left: auto;
    right: var(--tsb-ib-gutter);
}

[dir="rtl"] .tsb-infobulle__toggle::after {
    right: auto;
    left: 0;
}

[dir="rtl"] .tsb-infobulle:not(.is-open) .tsb-infobulle__toggle::before {
    scale: -1 1;
}

[dir="rtl"] .tsb-infobulle__panel {
    left: auto;
    right: 0;
    text-align: right;
    transform-origin: calc(100% - var(--tsb-ib-size) / 2) 100%;
}

[dir="rtl"] .tsb-infobulle__panel::after {
    left: auto;
    right: calc(var(--tsb-ib-size) / 2 - 9px);
}

[dir="rtl"] .tsb-infobulle .tsb-infobulle__close {
    right: auto;
    left: 16px;
}

[dir="rtl"] .tsb-infobulle .tsb-infobulle__title {
    padding: 0 0 0 32px;
}

@media (max-width: 767px) {
    [dir="rtl"] .tsb-infobulle .tsb-infobulle__close {
        left: 10px;
    }
}

/** accessibilité / impression **/

@media (prefers-reduced-motion: reduce) {
    .tsb-infobulle,
    .tsb-infobulle *,
    .tsb-infobulle *::before,
    .tsb-infobulle *::after {
        transition: none !important;
        animation: none !important;
    }
}

@media (forced-colors: active) {
    .tsb-infobulle__toggle {
        border: 2px solid ButtonText;
    }

    .tsb-infobulle__toggle::before,
    .tsb-infobulle .tsb-infobulle__close::before {
        background-color: ButtonText;
        forced-color-adjust: none;
    }

    .tsb-infobulle__panel {
        border: 1px solid CanvasText;
    }
}

@media print {
    .tsb-infobulle {
        display: none !important;
    }
}
