/* ============================================================
 * Bloc « Quentin texto » : bulles façon iMessage.
 * Repris de l'ancienne bulle de l'accueil v25 (.imessage).
 * Chargé sur le site et dans l'éditeur (handle qr-texto),
 * seulement sur les pages qui contiennent le bloc.
 *
 * Blindage : les gabarits d'article remettent à zéro les <p>
 * (.qr-watch .content-text p { padding: 0 }). Les bulles sont donc
 * des <div>, et toutes les règles partent de .qr-texto.qr-texto
 * pour passer devant les styles du thème.
 *
 * La queue est une forme SVG en masque, pas un cache blanc :
 * elle reste propre sur n'importe quel fond (grille, image, noir).
 * ============================================================ */

.qr-texto {
    /* style « iMessage » (par défaut) */
    --qr-texto-moi:      #248bf5;
    --qr-texto-moi-ink:  #fff;
    --qr-texto-eux:      #e5e5ea;
    --qr-texto-eux-ink:  #000;
    --qr-texto-meta:     #8e8e93;
}

.qr-texto.is-style-sms {
    --qr-texto-moi:      #34c759;
}

.qr-texto.is-style-sombre {
    --qr-texto-moi:      #0a84ff;
    --qr-texto-eux:      #3a3a3c;
    --qr-texto-eux-ink:  #fff;
    --qr-texto-meta:     #aeaeb2;
}

/* ----- la conversation ----- */

.qr-texto.qr-texto {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    width: 100%;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    padding: 1rem 1.25rem;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 1.05rem;
    line-height: 1.25;
    text-align: left;
}

.qr-texto.qr-texto .qr-texto__contact {
    align-self: center;
    margin: 0 0 0.75rem;
    padding: 0;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--qr-texto-meta);
}

/* ----- les bulles ----- */

.qr-texto.qr-texto .qr-texto__msg {
    --bulle:     var(--qr-texto-moi);
    --bulle-ink: var(--qr-texto-moi-ink);

    position: relative;
    z-index: 0;
    box-sizing: border-box;
    width: fit-content;
    max-width: 75%;
    margin: 0.25rem 0 0;
    padding: 0.5rem 0.875rem;
    border: 0;
    border-radius: 1.15rem;
    background: var(--bulle);
    color: var(--bulle-ink);
    font-size: inherit;
    line-height: 1.25;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.qr-texto.qr-texto .qr-texto__msg--moi {
    align-self: flex-end;
}

.qr-texto.qr-texto .qr-texto__msg--eux {
    --bulle:     var(--qr-texto-eux);
    --bulle-ink: var(--qr-texto-eux-ink);
    align-self: flex-start;
}

/* Changement d'interlocuteur : un peu plus d'air. */
.qr-texto.qr-texto .qr-texto__msg--moi + .qr-texto__msg--eux,
.qr-texto.qr-texto .qr-texto__msg--eux + .qr-texto__msg--moi {
    margin-top: 0.6rem;
}

.qr-texto.qr-texto .qr-texto__msg a {
    color: inherit;
    text-decoration: underline;
}

.qr-texto.qr-texto .qr-texto__msg strong,
.qr-texto.qr-texto .qr-texto__msg em {
    color: inherit;
}

/* ----- la queue, sur la dernière bulle d'une série ----- */

.qr-texto.qr-texto .qr-texto__msg--queue::after {
    content: "";
    position: absolute;
    z-index: -1;            /* sous le texte, sur le fond de la bulle */
    bottom: 0;
    right: -8px;
    width: 26px;
    height: 18px;
    background: var(--bulle);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 26 18'%3E%3Cpath d='M0 0H18C18 8 20.5 14.5 26 18H0Z'/%3E%3C/svg%3E") no-repeat 0 0 / 100% 100%;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 26 18'%3E%3Cpath d='M0 0H18C18 8 20.5 14.5 26 18H0Z'/%3E%3C/svg%3E") no-repeat 0 0 / 100% 100%;
}

.qr-texto.qr-texto .qr-texto__msg--eux.qr-texto__msg--queue::after {
    right: auto;
    left: -8px;
    transform: scaleX(-1);
}

/* ----- « Lu », « Distribué »… ----- */

.qr-texto.qr-texto .qr-texto__statut {
    align-self: flex-end;
    margin: 0.2rem 0.25rem 0 0;
    padding: 0;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--qr-texto-meta);
}

/* ----- « en train d'écrire… » ----- */

.qr-texto.qr-texto .qr-texto__typing {
    position: relative;
    align-self: flex-start;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    box-sizing: border-box;
    margin: 0.6rem 0 0.75rem;
    padding: 0.9rem 0.875rem;
    border-radius: 1.15rem;
    background: var(--qr-texto-eux);
}

/* les deux petites bulles de pensée sous l'indicateur */
.qr-texto.qr-texto .qr-texto__typing::before,
.qr-texto.qr-texto .qr-texto__typing::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    background: var(--qr-texto-eux);
}
.qr-texto.qr-texto .qr-texto__typing::before {
    width: 14px;
    height: 14px;
    left: 1px;
    bottom: -4px;
}
.qr-texto.qr-texto .qr-texto__typing::after {
    width: 8px;
    height: 8px;
    left: -4px;
    bottom: -10px;
}

.qr-texto.qr-texto .qr-texto__typing span[aria-hidden] {
    display: block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--qr-texto-eux-ink);
    opacity: 0.2;
    animation: qr-texto-blink 1.5s infinite ease-in-out;
}
.qr-texto.qr-texto .qr-texto__typing span[aria-hidden]:nth-of-type(3) { animation-delay: 0.2s; }
.qr-texto.qr-texto .qr-texto__typing span[aria-hidden]:nth-of-type(4) { animation-delay: 0.4s; }

@keyframes qr-texto-blink {
    0%, 80%, 100% { opacity: 0.2; }
    40%           { opacity: 0.65; }
}

@media (prefers-reduced-motion: reduce) {
    .qr-texto.qr-texto .qr-texto__typing span[aria-hidden] { animation: none; opacity: 0.45; }
}

/* Lu par les lecteurs d'écran, invisible à l'écran. */
.qr-texto.qr-texto .screen-reader-text {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}
