/**
 * BWA Search IA - Front-office styles
 * Design Grands Bourgognes avec effet typewriter LLM
 */

.bwa-search-ia-result {
    --bwa-ease-out: cubic-bezier(0.23, 1, 0.32, 1);
    background: linear-gradient(135deg,
        hsl(36, 45%, 96%) 0%,
        hsl(36, 45%, 92%) 50%,
        hsl(34, 40%, 90%) 100%);
    border: 1px solid hsl(36, 45%, 80%);
    border-radius: 16px;
    padding: 28px 32px;
    margin: 24px 0 32px 0;
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.06),
        0 1px 3px rgba(0, 0, 0, 0.04);
    color: #111;
    font-family: var(--typo-primary, "Josefin Sans", sans-serif);
    position: relative;
    overflow: hidden;
}

/* Accent doré subtil en haut */
.bwa-search-ia-result::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg,
        hsl(36, 45%, 56%) 0%,
        hsl(34, 100%, 59%) 50%,
        hsl(36, 45%, 56%) 100%);
    border-radius: 16px 16px 0 0;
}

.bwa-search-ia-content {
    display: flex;
    align-items: flex-start;
    gap: 20px;
}

.bwa-search-ia-text {
    flex: 1;
    min-width: 0;
}

.bwa-search-ia-title {
    margin: 0 0 12px 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: hsl(36, 35%, 30%);
    font-family: var(--typo-secondary, "Playfair Display", serif);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Badge icône loupe + étoiles */
.bwa-search-ia-title::after {
    content: '';
    display: inline-block;
    width: 38px;
    height: 22px;
    border-radius: 11px;
    background:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 38 22'%3E%3Ccircle cx='12' cy='11' r='4.5' fill='none' stroke='white' stroke-width='1.8'/%3E%3Cline x1='15.5' y1='14.5' x2='19' y2='18' stroke='white' stroke-width='1.8' stroke-linecap='round'/%3E%3Cpath d='M24 5 l1.2 2.4 2.6 0.4 -1.9 1.8 0.5 2.6 -2.4 -1.2 -2.4 1.2 0.5 -2.6 -1.9 -1.8 2.6 -0.4 z' fill='white'/%3E%3Cpath d='M32 11 l0.7 1.4 1.5 0.2 -1.1 1.1 0.3 1.5 -1.4 -0.7 -1.4 0.7 0.3 -1.5 -1.1 -1.1 1.5 -0.2 z' fill='white'/%3E%3C/svg%3E") no-repeat center / 38px 22px,
        linear-gradient(135deg, hsl(36, 45%, 56%), hsl(34, 80%, 50%));
    vertical-align: middle;
}

.bwa-search-ia-text p {
    margin: 0;
    font-size: 1rem;
    line-height: 1.7;
    color: #516765;
}

/* ========================================
   EFFET TYPEWRITER LLM
   ======================================== */

/* Container du texte avec curseur */
.bwa-search-ia-text p.bwa-ia-typing {
    position: relative;
}

/* Curseur clignotant style LLM */
.bwa-ia-cursor {
    display: inline-block;
    width: 2px;
    height: 1.1em;
    background: hsl(36, 45%, 56%);
    margin-left: 2px;
    vertical-align: text-bottom;
    animation: blink-cursor 0.8s ease-in-out infinite;
}

@keyframes blink-cursor {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Fade-in mot par mot : opacité seule, le texte se lit pendant qu'il s'écrit */
.bwa-ia-word {
    display: inline;
    opacity: 0;
    animation: word-appear 160ms var(--bwa-ease-out) forwards;
}

@keyframes word-appear {
    to {
        opacity: 1;
    }
}

/* ========================================
   SELECTION DU SOMMELIER
   ======================================== */

.bwa-ia-picks {
    margin: 16px 0 0;
    padding: 0;
    list-style: none;
}

.bwa-ia-pick {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 0;
    border-top: 1px solid hsl(36, 45%, 85%);
}

.bwa-ia-pick:first-child {
    border-top: 0;
    padding-top: 0;
}

.bwa-ia-pick__name {
    font-weight: 600;
    color: hsl(36, 35%, 30%);
    text-decoration: underline;
    text-decoration-color: hsl(36, 45%, 70%);
    text-underline-offset: 3px;
}

.bwa-ia-pick__name:hover,
.bwa-ia-pick__name:focus-visible {
    color: #111;
    text-decoration-color: currentColor;
}

.bwa-ia-pick__reason {
    color: #516765;
    line-height: 1.6;
}

/* Apparition des vins après l'introduction, en cascade courte */
.bwa-ia-picks--enter .bwa-ia-pick {
    opacity: 0;
    transform: translateY(6px);
    animation: bwa-pick-enter 240ms var(--bwa-ease-out) forwards;
}

.bwa-ia-picks--enter .bwa-ia-pick:nth-child(2) { animation-delay: 50ms; }
.bwa-ia-picks--enter .bwa-ia-pick:nth-child(3) { animation-delay: 100ms; }

@keyframes bwa-pick-enter {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Échec ou rien de pertinent : le bloc s'efface avant d'être retiré */
.bwa-search-ia-result.bwa-ia-leaving {
    opacity: 0;
    transition: opacity 150ms ease-out;
}

@media (prefers-reduced-motion: reduce) {
    .bwa-ia-picks--enter .bwa-ia-pick {
        transform: none;
        animation-duration: 120ms;
    }

    .bwa-ia-word,
    .bwa-ia-cursor,
    .bwa-ia-loading-dots span {
        animation: none;
        opacity: 1;
    }
}

/* ========================================
   ETAT LOADING
   ======================================== */

.bwa-ia-placeholder {
    color: #888 !important;
    font-style: italic;
}

/* Animation dots de chargement */
.bwa-ia-loading-dots {
    display: inline-flex;
    gap: 4px;
    margin-left: 8px;
}

.bwa-ia-loading-dots span {
    width: 6px;
    height: 6px;
    background: hsl(36, 45%, 56%);
    border-radius: 50%;
    animation: loading-dot 1s ease-in-out infinite;
}

.bwa-ia-loading-dots span:nth-child(1) { animation-delay: 0s; }
.bwa-ia-loading-dots span:nth-child(2) { animation-delay: 0.15s; }
.bwa-ia-loading-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes loading-dot {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    .bwa-search-ia-result {
        padding: 20px;
        margin: 16px 0 24px 0;
        border-radius: 12px;
    }

    .bwa-search-ia-title {
        font-size: 1.1rem;
        margin-bottom: 8px;
    }

    .bwa-search-ia-title::after {
        width: 32px;
        height: 18px;
        border-radius: 9px;
        background-size: 32px 18px;
    }

    .bwa-search-ia-text p {
        font-size: 0.95rem;
        line-height: 1.6;
    }
}

/* ==========================================================================
   Conseil de recherche (sans IA) : domaine épuisé, vins disponibles
   Les cartes produits reprennent la miniature du thème (.products)
   ========================================================================== */

.bwa-search-advice {
    margin: 24px 0 32px;
    padding-bottom: 24px;
    border-bottom: 1px solid hsl(36, 45%, 85%);
}

.bwa-search-advice__title {
    margin: 0 0 8px;
    font-family: var(--typo-secondary, "Playfair Display", serif);
    font-size: 1.5rem;
    font-weight: 600;
    color: hsl(36, 35%, 30%);
}

.bwa-search-advice__text {
    margin: 0 0 12px;
    max-width: 65ch;
    color: #516765;
    line-height: 1.6;
}

.bwa-search-advice__sold-out {
    margin: 0 0 20px;
    padding-left: 1.2em;
    list-style: disc;
}

.bwa-search-advice__sold-out li {
    margin-bottom: 4px;
}

.bwa-search-advice__sold-out a {
    color: hsl(36, 35%, 30%);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.bwa-search-advice__sold-out a:hover,
.bwa-search-advice__sold-out a:focus-visible {
    color: #111;
}

.bwa-search-advice__subtitle {
    margin: 20px 0 12px;
    font-size: 1.1rem;
    font-weight: 600;
    color: #111;
}

.bwa-search-advice__labels {
    font-weight: 400;
    color: #516765;
}

/* Budget reconnu dans la recherche */
.bwa-search-budget {
    margin: 16px 0;
    color: #516765;
}

.bwa-search-budget strong {
    color: #111;
}

.bwa-search-budget a {
    margin-left: 0.5em;
    color: hsl(36, 35%, 30%);
    text-decoration: underline;
    text-underline-offset: 3px;
}
