/**
 * apb-ai-search.css — Modal animé pendant la résolution de la recherche IA.
 *
 * v2.29.0 — Migré sur les design tokens canoniques (apb-tokens.css).
 * Avant : palette legacy #185FA5 / #0C447C → rompait visuellement avec
 * la home navy `#0B2A4A` quand le modal s'ouvrait.
 * Après : tout via var(--apb-*) → continuité brand parfaite.
 *
 * Specs : docs/superpowers/specs/2026-04-27-ai-search-loading-modal-design.md
 */

/* ════════════════════════════════════════════════════════════
   MODAL structure
   ════════════════════════════════════════════════════════════ */
.apb-ai-search-modal {
    position: fixed;
    inset: 0;
    z-index: var(--apb-z-modal, 100000);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    font-family: var(--apb-sans, 'Inter', system-ui, sans-serif);
}
.apb-ai-search-modal.is-active {
    display: flex;
}

.apb-ai-search-modal__backdrop {
    position: fixed;
    inset: 0;
    background: rgba(11, 42, 74, 0);
    backdrop-filter: blur(0);
    -webkit-backdrop-filter: blur(0);
    transition: background 350ms var(--apb-ease-out, ease-out),
                backdrop-filter 350ms var(--apb-ease-out, ease-out);
}
.apb-ai-search-modal.is-active .apb-ai-search-modal__backdrop {
    background: rgba(11, 42, 74, 0.60);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.apb-ai-search-modal__card {
    position: relative;
    width: 100%;
    max-width: 480px;
    padding: 48px 32px;
    background: var(--apb-surface, #FFFFFF);
    border: 1px solid var(--apb-line, #E7E3D9);
    border-radius: var(--apb-radius-xl, 24px);
    box-shadow: var(--apb-shadow-3, 0 24px 80px rgba(11, 42, 74, 0.25));
    text-align: center;
    transform: scale(0.92) translateY(20px);
    opacity: 0;
    transition:
        transform 450ms var(--apb-ease-bounce, cubic-bezier(0.34, 1.56, 0.64, 1)),
        opacity 350ms var(--apb-ease-out, ease-out);
    outline: none;
    /* Decorative tri-color tape (drapeau belge — brand signature) */
    background-image: var(--apb-tape, linear-gradient(to right, #0B2A4A 0%, #0B2A4A 33%, #F59E0B 33%, #F59E0B 66%, #EF3340 66%));
    background-repeat: no-repeat;
    background-size: 100% 4px;
    background-position: top left;
}
.apb-ai-search-modal.is-active .apb-ai-search-modal__card {
    transform: scale(1) translateY(0);
    opacity: 1;
}

/* ════════════════════════════════════════════════════════════
   ICON (animated SVG container)
   ════════════════════════════════════════════════════════════ */
.apb-ai-search-modal__icon {
    width: 120px;
    height: 120px;
    margin: 0 auto 24px;
}
.apb-ai-icon {
    width: 100%;
    height: 100%;
    animation: apb-breathing 2.8s ease-in-out infinite;
}

/* ════════════════════════════════════════════════════════════
   TITLE + SUBTITLE
   ════════════════════════════════════════════════════════════ */
.apb-ai-search-modal__title {
    margin: 0 0 8px;
    font-family: var(--apb-display, var(--apb-sans));
    font-size: 24px;
    font-weight: 700;
    color: var(--apb-brand, #0B2A4A);
    line-height: 1.2;
    letter-spacing: var(--apb-tracking-tight, -0.025em);
}
.apb-ai-search-modal__subtitle {
    margin: 0 0 28px;
    font-size: 14px;
    color: var(--apb-ink-3, #64748B);
    line-height: 1.5;
}

/* ════════════════════════════════════════════════════════════
   PROGRESS BAR
   ════════════════════════════════════════════════════════════ */
.apb-ai-search-modal__progress {
    width: 100%;
    height: 4px;
    margin: 0 0 20px;
    border-radius: 4px;
    background: rgba(11, 42, 74, 0.08);
    overflow: hidden;
    position: relative;
}
.apb-ai-search-modal__progress-bar {
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        var(--apb-brand, #0B2A4A) 25%,
        var(--apb-accent, #F59E0B) 50%,
        var(--apb-brand, #0B2A4A) 75%,
        transparent 100%
    );
    background-size: 300% 100%;
    animation: apb-progress-flow 2.4s linear infinite;
}

/* ════════════════════════════════════════════════════════════
   STEP TEXT (cycled by JS)
   ════════════════════════════════════════════════════════════ */
.apb-ai-search-modal__step {
    margin: 0;
    font-size: 14px;
    font-weight: 500;
    color: var(--apb-brand, #0B2A4A);
    min-height: 1.4em;
    transition: opacity 200ms ease-out, transform 200ms ease-out;
}
.apb-ai-search-modal__step.is-fading {
    opacity: 0;
    transform: translateY(6px);
}
.apb-ai-search-modal__step--error {
    color: var(--apb-danger-2, #B91C1C);
}

/* ════════════════════════════════════════════════════════════
   CLOSE BUTTON (only shown on error)
   ════════════════════════════════════════════════════════════ */
.apb-ai-search-modal__close {
    margin-top: 16px;
    padding: 11px 22px;
    background: var(--apb-brand, #0B2A4A);
    color: var(--apb-ink-on-brand, #FFFFFF);
    border: 0;
    border-radius: var(--apb-radius-sm, 10px);
    font-family: inherit;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background var(--apb-dur-fast, 150ms) ease-out,
                transform var(--apb-dur-fast, 150ms) ease-out;
    min-height: 44px;
}
.apb-ai-search-modal__close:hover {
    background: var(--apb-brand-2, #143D69);
    transform: translateY(-1px);
}
.apb-ai-search-modal__close:focus-visible {
    outline: 2px solid var(--apb-accent, #F59E0B);
    outline-offset: 2px;
}

/* ════════════════════════════════════════════════════════════
   Animations keyframes
   ════════════════════════════════════════════════════════════ */

/* Card breathing scale + drop-shadow pulse */
@keyframes apb-breathing {
    0%, 100% {
        transform: scale(1);
        filter: drop-shadow(0 4px 12px rgba(11, 42, 74, 0.25));
    }
    50% {
        transform: scale(1.04);
        filter: drop-shadow(0 6px 20px rgba(11, 42, 74, 0.45));
    }
}

/* Halo pulse derrière l'icône */
.apb-ai-icon__halo {
    transform-origin: 80px 80px;
    animation: apb-halo-pulse 2.8s ease-in-out infinite;
}
@keyframes apb-halo-pulse {
    0%, 100% { transform: scale(1);   opacity: 0.08; }
    50%      { transform: scale(1.3); opacity: 0.18; }
}

/* Orbital dots — rotations contraires */
.apb-ai-icon__orbit { transform-origin: 80px 80px; }
.apb-ai-icon__orbit--outer { animation: apb-rotate-cw  4s linear infinite; }
.apb-ai-icon__orbit--inner { animation: apb-rotate-ccw 3s linear infinite; }

@keyframes apb-rotate-cw  { from { transform: rotate(0); }    to { transform: rotate(360deg); } }
@keyframes apb-rotate-ccw { from { transform: rotate(0); }    to { transform: rotate(-360deg); } }

/* Dots pulse staggered */
.apb-ai-icon__orbit circle {
    transform-origin: center;
    transform-box: fill-box;
    animation: apb-dot-pulse 1.6s ease-in-out infinite;
}
.apb-ai-icon__orbit--outer circle:nth-child(2) { animation-delay: 0.4s; }
.apb-ai-icon__orbit--inner circle:nth-child(1) { animation-delay: 0.2s; }
.apb-ai-icon__orbit--inner circle:nth-child(2) { animation-delay: 0.6s; }

@keyframes apb-dot-pulse {
    0%, 100% { transform: scale(0.8); opacity: 0.65; }
    50%      { transform: scale(1.2); opacity: 1; }
}

/* Progress gradient flow */
@keyframes apb-progress-flow {
    from { background-position: 100% 0%; }
    to   { background-position: -100% 0%; }
}

/* ════════════════════════════════════════════════════════════
   Responsive (mobile)
   ════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
    .apb-ai-search-modal__card {
        padding: 32px 24px;
        border-radius: var(--apb-radius-lg, 18px);
    }
    .apb-ai-search-modal__icon {
        width: 96px;
        height: 96px;
        margin-bottom: 18px;
    }
    .apb-ai-search-modal__title {
        font-size: 20px;
    }
}

/* ════════════════════════════════════════════════════════════
   Reduced motion (accessibility)
   ════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    .apb-ai-icon,
    .apb-ai-icon__halo,
    .apb-ai-icon__orbit--outer,
    .apb-ai-icon__orbit--inner,
    .apb-ai-icon__orbit circle,
    .apb-ai-search-modal__progress-bar { animation: none; }

    .apb-ai-search-modal__card,
    .apb-ai-search-modal__backdrop { transition-duration: 150ms; }
}
