/* ============================================================
   BaBBot — CSA Tir Bonaparte
   Mascotte militaire + interface compacte et fonctionnelle.
   ============================================================ */

:root {
    --bb-green: #111c10;
    --bb-green-2: #263120;
    --bb-green-3: #323a2d;
    --bb-gold: #c79f52;
    --bb-gold-light: #ead6a5;
    --bb-cream: #f4efe3;
    --bb-white: #ffffff;
    --bb-text: #20241f;
    --bb-muted: #6b7169;
    --bb-line: rgba(199, 159, 82, .35);
    --bb-shadow: 0 24px 70px rgba(0, 0, 0, .34);
}

.babbot,
.babbot * {
    box-sizing: border-box;
}

.babbot {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 2147483000;
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

/* ------------------------------------------------------------
   Bouton flottant
   ------------------------------------------------------------ */

.babbot-launcher {
    display: flex;
    align-items: center;
    gap: 11px;
    min-height: 68px;
    padding: 6px 16px 6px 6px;
    border: 1px solid var(--bb-gold);
    border-radius: 999px;
    background:
        linear-gradient(
            135deg,
            var(--bb-green-2),
            var(--bb-green)
        );
    color: var(--bb-white);
    box-shadow: 0 14px 34px rgba(0, 0, 0, .28);
    cursor: pointer;
    transition:
        transform .18s ease,
        box-shadow .18s ease;
}

.babbot-launcher:hover,
.babbot-launcher:focus-visible {
    transform: translateY(-2px);
    box-shadow:
        0 18px 42px rgba(0, 0, 0, .36),
        0 0 0 3px rgba(199, 159, 82, .18);
    outline: none;
}

.babbot-launcher__portrait {
    width: 56px;
    height: 56px;
    flex: 0 0 56px;
    overflow: hidden;
    border: 2px solid var(--bb-gold);
    border-radius: 50%;
    background: var(--bb-cream);
}

.babbot-launcher__portrait img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 50% 42%;
    border-radius: 50%;
    clip-path: circle(50% at 50% 50%);
}

.babbot-launcher__copy {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    line-height: 1.12;
}

.babbot-launcher__copy strong {
    color: var(--bb-gold-light);
    font-size: 16px;
    letter-spacing: .02em;
}

.babbot-launcher__copy small {
    margin-top: 3px;
    color: rgba(255, 255, 255, .82);
    font-size: 11px;
}

/* ------------------------------------------------------------
   Fenêtre
   ------------------------------------------------------------ */

.babbot-panel {
    position: absolute;
    right: 0;
    bottom: 82px;
    width: min(430px, calc(100vw - 24px));
    max-height: min(720px, calc(100vh - 110px));
    overflow: hidden;
    border: 2px solid var(--bb-gold);
    border-radius: 28px;
    background: var(--bb-cream);
    color: var(--bb-text);
    box-shadow: var(--bb-shadow);
    transform-origin: right bottom;
    animation: babbot-in .20s ease-out both;
}

.babbot-panel[hidden] {
    display: none !important;
}

/* ------------------------------------------------------------
   En-tête inspiré du visuel validé
   ------------------------------------------------------------ */

.babbot-head {
    position: relative;
    display: grid;
    grid-template-columns: 108px minmax(0, 1fr);
    gap: 14px;
    align-items: center;
    padding: 18px 52px 18px 16px;
    background:
        radial-gradient(
            circle at 15% 20%,
            rgba(199, 159, 82, .22),
            transparent 36%
        ),
        linear-gradient(
            135deg,
            #2d3826 0%,
            #121d11 70%
        );
    border-bottom: 1px solid var(--bb-gold);
}

.babbot-head__portrait {
    width: 104px;
    height: 104px;
    overflow: hidden;
    border: 3px solid var(--bb-gold);
    border-radius: 50%;
    background: var(--bb-white);
    box-shadow:
        0 7px 20px rgba(0, 0, 0, .28),
        inset 0 0 0 3px rgba(255, 255, 255, .45);
}

.babbot-head__portrait img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 50% 42%;
    border-radius: 50%;
    clip-path: circle(50% at 50% 50%);
}

.babbot-head__bubble {
    position: relative;
    min-width: 0;
    padding: 14px 14px 13px;
    border: 1px solid rgba(199, 159, 82, .85);
    border-radius: 18px;
    background: #fffdf8;
    box-shadow: 0 7px 20px rgba(0, 0, 0, .13);
}

.babbot-head__bubble::before {
    content: "";
    position: absolute;
    left: -8px;
    top: 38px;
    width: 15px;
    height: 15px;
    border-left: 1px solid var(--bb-gold);
    border-bottom: 1px solid var(--bb-gold);
    background: #fffdf8;
    transform: rotate(45deg);
}

.babbot-kicker {
    display: block;
    margin-bottom: 3px;
    color: #81672f;
    font-size: 9px;
    font-weight: 900;
    letter-spacing: .11em;
    text-transform: uppercase;
}

.babbot-head h2 {
    margin: 0;
    color: var(--bb-green);
    font-size: 27px;
    line-height: 1;
}

.babbot-head p {
    margin: 7px 0 0;
    color: #4c534b;
    font-size: 12px;
    line-height: 1.45;
}

.babbot-mode {
    display: inline-flex;
    margin-top: 8px;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(199, 159, 82, .14);
    color: #6f5728;
    font-size: 9px;
    font-weight: 850;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.babbot-close {
    position: absolute;
    top: 12px;
    right: 12px;
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid rgba(234, 214, 165, .58);
    border-radius: 50%;
    background: rgba(0, 0, 0, .22);
    color: var(--bb-white);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.babbot-close:hover,
.babbot-close:focus-visible {
    background: rgba(0, 0, 0, .38);
    outline: 2px solid var(--bb-gold);
    outline-offset: 2px;
}

/* ------------------------------------------------------------
   Corps
   ------------------------------------------------------------ */

.babbot-body {
    max-height: 460px;
    overflow-y: auto;
    padding: 15px 16px 17px;
    background:
        radial-gradient(
            circle at top right,
            rgba(199, 159, 82, .10),
            transparent 34%
        ),
        var(--bb-cream);
    scrollbar-width: thin;
    scrollbar-color:
        rgba(199, 159, 82, .65)
        rgba(17, 28, 16, .08);
}

.babbot-location {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 11px;
    border: 1px solid rgba(17, 28, 16, .08);
    border-radius: 12px;
    background: rgba(255, 255, 255, .66);
    color: var(--bb-muted);
    font-size: 10px;
}

.babbot-location strong {
    color: var(--bb-green);
    font-size: 11px;
}

/* ------------------------------------------------------------
   Boutons comme sur l'affiche d'origine
   ------------------------------------------------------------ */

.babbot-actions {
    display: grid;
    gap: 8px;
    margin-top: 13px;
}

.babbot-action {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) 20px;
    gap: 10px;
    align-items: center;
    min-height: 50px;
    padding: 6px 10px 6px 6px;
    border: 1px solid rgba(199, 159, 82, .62);
    border-radius: 999px;
    background:
        linear-gradient(
            145deg,
            #3a3d34,
            #1c211b
        );
    color: #f8f4e9;
    text-decoration: none;
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, .03);
    transition:
        transform .15s ease,
        border-color .15s ease,
        box-shadow .15s ease;
}

.babbot-action:hover,
.babbot-action:focus-visible {
    transform: translateX(2px);
    border-color: var(--bb-gold-light);
    box-shadow: 0 7px 16px rgba(0, 0, 0, .16);
    outline: none;
}

.babbot-action__icon {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--bb-gold);
    color: var(--bb-green);
    font-size: 17px;
    font-weight: 950;
}

.babbot-action__label {
    min-width: 0;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: .025em;
    text-transform: uppercase;
}

.babbot-action__arrow {
    color: var(--bb-gold-light);
    font-size: 24px;
    line-height: 1;
}

/* ------------------------------------------------------------
   Recherche
   ------------------------------------------------------------ */

.babbot-search {
    margin-top: 15px;
    padding-top: 14px;
    border-top: 1px solid rgba(17, 28, 16, .12);
}

.babbot-search__label {
    display: block;
    margin-bottom: 7px;
    color: var(--bb-green);
    font-size: 11px;
    font-weight: 900;
}

.babbot-search__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 7px;
}

.babbot-search__input {
    width: 100%;
    min-width: 0;
    height: 42px;
    padding: 0 12px;
    border: 1px solid rgba(17, 28, 16, .18);
    border-radius: 12px;
    background: var(--bb-white);
    color: var(--bb-text);
    font: inherit;
    font-size: 12px;
}

.babbot-search__input:focus {
    border-color: var(--bb-gold);
    outline: 3px solid rgba(199, 159, 82, .14);
}

.babbot-search__submit {
    min-height: 42px;
    padding: 0 14px;
    border: 1px solid var(--bb-gold);
    border-radius: 12px;
    background: var(--bb-green);
    color: var(--bb-gold-light);
    font-weight: 900;
    cursor: pointer;
}

.babbot-search__submit:hover,
.babbot-search__submit:focus-visible {
    background: var(--bb-green-2);
    outline: 2px solid var(--bb-gold);
    outline-offset: 2px;
}

/* ------------------------------------------------------------
   Réponse
   ------------------------------------------------------------ */

.babbot-answer {
    margin-top: 10px;
    padding: 12px 13px;
    border: 1px solid var(--bb-line);
    border-left: 4px solid var(--bb-gold);
    border-radius: 10px 14px 14px 10px;
    background: var(--bb-white);
    color: #555d54;
    font-size: 12px;
    line-height: 1.55;
}

.babbot-answer strong {
    color: var(--bb-green);
}

.babbot-answer p {
    margin: 5px 0 0;
}

.babbot-answer a {
    display: inline-flex;
    margin-top: 8px;
    padding: 8px 11px;
    border-radius: 999px;
    background: var(--bb-green);
    color: var(--bb-gold-light);
    font-weight: 850;
    text-decoration: none;
}

/* ------------------------------------------------------------
   Bas
   ------------------------------------------------------------ */

.babbot-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 45px;
    padding: 9px 14px 8px;
    background: var(--bb-green);
    color: var(--bb-gold-light);
    font-size: 9px;
    font-weight: 900;
    letter-spacing: .11em;
    text-transform: uppercase;
}

.babbot-foot i {
    opacity: .55;
    font-style: normal;
}

.babbot-tricolor {
    display: grid;
    grid-template-columns: repeat(3, 34px);
    width: 102px;
    height: 4px;
    overflow: hidden;
    border-radius: 999px;
    flex-basis: 102px;
    margin-left: 100%;
    margin-right: 100%;
}

.babbot-tricolor span:nth-child(1) {
    background: #1f4ba5;
}

.babbot-tricolor span:nth-child(2) {
    background: #ffffff;
}

.babbot-tricolor span:nth-child(3) {
    background: #d72f3b;
}

@keyframes babbot-in {
    from {
        opacity: 0;
        transform: translateY(10px) scale(.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ------------------------------------------------------------
   Mobile
   ------------------------------------------------------------ */

@media (max-width: 640px) {
    .babbot {
        right: 9px;
        bottom: 9px;
    }

    .babbot-launcher {
        min-height: 60px;
        padding: 5px;
    }

    .babbot-launcher__portrait {
        width: 50px;
        height: 50px;
        flex-basis: 50px;
    }

    .babbot-launcher__copy {
        display: none;
    }

    .babbot-panel {
        position: fixed;
        right: 8px;
        left: 8px;
        bottom: 74px;
        width: auto;
        max-height: calc(100vh - 88px);
        border-radius: 23px;
    }

    .babbot-head {
        grid-template-columns: 84px minmax(0, 1fr);
        gap: 10px;
        padding: 14px 46px 14px 12px;
    }

    .babbot-head__portrait {
        width: 82px;
        height: 82px;
    }

    .babbot-head h2 {
        font-size: 22px;
    }

    .babbot-head p {
        font-size: 11px;
    }

    .babbot-body {
        max-height: calc(100vh - 300px);
        padding: 12px;
    }

    .babbot-search__row {
        grid-template-columns: 1fr;
    }

    .babbot-search__submit {
        width: 100%;
    }
}

@media (max-width: 380px) {
    .babbot-head {
        grid-template-columns: 70px minmax(0, 1fr);
    }

    .babbot-head__portrait {
        width: 68px;
        height: 68px;
    }

    .babbot-head p {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .babbot-panel,
    .babbot-launcher,
    .babbot-action {
        animation: none;
        transition: none;
    }
}


/* ============================================================
   Correctif rendu / profondeur
   ============================================================ */

.babbot-panel {
    background:
        linear-gradient(
            180deg,
            #f8f4e9 0%,
            #f1eadc 100%
        );
}

.babbot-head__bubble {
    box-shadow:
        0 10px 24px rgba(0, 0, 0, .16),
        inset 0 1px 0 rgba(255, 255, 255, .86);
}

.babbot-action {
    box-shadow:
        0 6px 14px rgba(0, 0, 0, .13),
        inset 0 1px 0 rgba(255, 255, 255, .06);
}

.babbot-action__icon {
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, .42),
        0 2px 6px rgba(0, 0, 0, .18);
}

.babbot-location {
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, .72),
        0 4px 10px rgba(17, 28, 16, .05);
}

.babbot-search__input {
    box-shadow:
        inset 0 1px 2px rgba(0, 0, 0, .04);
}

.babbot-launcher__portrait {
    overflow: hidden !important;
    border-radius: 50% !important;
    clip-path: circle(50% at 50% 50%);
}

.babbot-launcher__portrait img {
    max-width: none !important;
}
