/**
 * Albasy Marketplace — Animations & Micro-interactions
 * DA v2 — IntersectionObserver · Stagger · Ripple · Skeleton
 *
 * @package Albasy_Marketplace
 */

/* ═══════════════════════════════════════════════════════════
   1. KEYFRAMES
═══════════════════════════════════════════════════════════ */

@keyframes alb-fadeInUp {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes alb-fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes alb-scaleIn {
    from { opacity: 0; transform: scale(.92); }
    to   { opacity: 1; transform: scale(1); }
}

@keyframes alb-slideInRight {
    from { opacity: 0; transform: translateX(32px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes alb-slideInLeft {
    from { opacity: 0; transform: translateX(-32px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes alb-slideDown {
    from { opacity: 0; transform: translateY(-16px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes alb-pulse {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.08); }
}

@keyframes alb-heartbeat {
    0%   { transform: scale(1); }
    14%  { transform: scale(1.3); }
    28%  { transform: scale(1); }
    42%  { transform: scale(1.2); }
    70%  { transform: scale(1); }
}

@keyframes alb-bounce {
    0%, 100% { transform: translateY(0); }
    40%       { transform: translateY(-10px); }
    60%       { transform: translateY(-5px); }
}

@keyframes alb-shimmer {
    0%   { background-position: -600px 0; }
    100% { background-position:  600px 0; }
}

@keyframes alb-spin {
    to { transform: rotate(360deg); }
}

@keyframes alb-ripple {
    0%   { transform: scale(0); opacity: .5; }
    100% { transform: scale(4); opacity: 0; }
}

@keyframes alb-countup-flash {
    0%   { color: var(--alb-primary, #FFD600); }
    100% { color: inherit; }
}

@keyframes alb-flip-down {
    0%   { transform: rotateX(90deg); opacity: 0; }
    100% { transform: rotateX(0);     opacity: 1; }
}

@keyframes alb-bar-grow {
    from { height: 4px !important; }
    to   { /* height set inline */ }
}

@keyframes alb-xp-fill {
    from { width: 0 !important; }
}

@keyframes alb-confetti-fall {
    0%   { transform: translateY(-10px) rotate(0); opacity: 1; }
    100% { transform: translateY(100vh)  rotate(720deg); opacity: 0; }
}

@keyframes alb-toast-in {
    from { opacity: 0; transform: translateX(50%) translateY(-12px); }
    to   { opacity: 1; transform: translateX(50%) translateY(0); }
}

@keyframes alb-toast-out {
    from { opacity: 1; transform: translateX(50%) translateY(0); }
    to   { opacity: 0; transform: translateX(50%) translateY(-12px); }
}


/* ═══════════════════════════════════════════════════════════
   2. REVEAL — IntersectionObserver (classes ajoutées par JS)
═══════════════════════════════════════════════════════════ */

/* État initial — invisible, prêt à animer */
.alb-reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity .55s var(--alb-ease, ease),
                transform .55s var(--alb-ease, ease);
    will-change: opacity, transform;
}
.alb-reveal.alb-reveal--left  { transform: translateX(-32px); }
.alb-reveal.alb-reveal--right { transform: translateX( 32px); }
.alb-reveal.alb-reveal--scale { transform: scale(.92); }

/* Décalages stagger (appliqués inline en JS ou via classes) */
.alb-reveal[data-delay="1"] { transition-delay: .05s; }
.alb-reveal[data-delay="2"] { transition-delay: .10s; }
.alb-reveal[data-delay="3"] { transition-delay: .15s; }
.alb-reveal[data-delay="4"] { transition-delay: .20s; }
.alb-reveal[data-delay="5"] { transition-delay: .25s; }
.alb-reveal[data-delay="6"] { transition-delay: .30s; }
.alb-reveal[data-delay="7"] { transition-delay: .35s; }
.alb-reveal[data-delay="8"] { transition-delay: .40s; }

/* Déclenché — visible */
.alb-reveal.is-visible {
    opacity: 1;
    transform: none !important;
}

/* Réduction de mouvement */
@media (prefers-reduced-motion: reduce) {
    .alb-reveal {
        opacity: 1;
        transform: none;
        transition: none;
    }
}


/* ═══════════════════════════════════════════════════════════
   3. SKELETON LOADING
═══════════════════════════════════════════════════════════ */

.alb-skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 25%,
        #e8e8e8 50%,
        #f0f0f0 75%
    );
    background-size: 600px 100%;
    animation: alb-shimmer 1.4s infinite linear;
    border-radius: var(--alb-radius-sm, 8px);
    color: transparent !important;
    pointer-events: none;
    user-select: none;
}
.alb-skeleton * { visibility: hidden; }

.alb-skeleton-card {
    height: 280px;
    border-radius: var(--alb-radius-md, 14px);
}
.alb-skeleton-text  { height: 14px; width: 80%; margin-bottom: 8px; }
.alb-skeleton-text--sm { height: 10px; width: 50%; }
.alb-skeleton-img   { height: 180px; border-radius: var(--alb-radius-md, 14px); margin-bottom: 12px; }
.alb-skeleton-circle { border-radius: 50%; width: 40px; height: 40px; }


/* ═══════════════════════════════════════════════════════════
   4. BUTTONS — Ripple + Hover
═══════════════════════════════════════════════════════════ */

/* Conteneur du ripple */
.alb-btn, .alb-btn-primary, .alb-btn-outline,
[class*="alb-btn"] {
    position: relative;
    overflow: hidden;
}

/* Particule ripple injectée par JS */
.alb-ripple-particle {
    position: absolute;
    border-radius: 50%;
    width: 8px; height: 8px;
    background: rgba(255,255,255,.45);
    transform: scale(0);
    animation: alb-ripple .55s linear forwards;
    pointer-events: none;
}

/* Bouton pill DA */
.alb-btn-primary {
    background: var(--alb-primary, #FFD600);
    color: var(--alb-on-primary, #212121);
    border: none;
    border-radius: var(--alb-radius-pill, 9999px);
    padding: .65rem 1.6rem;
    font-family: var(--alb-font-body, 'DM Sans', sans-serif);
    font-weight: 700;
    font-size: .9rem;
    cursor: pointer;
    box-shadow: 0 4px 14px var(--alb-primary-glow, rgba(255,214,0,.35));
    transition: transform .25s var(--alb-ease-spring, ease),
                box-shadow .25s var(--alb-ease, ease),
                background .2s ease;
    display: inline-flex;
    align-items: center;
    gap: .45rem;
}
.alb-btn-primary:hover {
    background: var(--alb-primary-dark, #F9A825);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--alb-primary-glow, rgba(255,214,0,.45));
}
.alb-btn-primary:active {
    transform: translateY(0) scale(.97);
    box-shadow: 0 2px 8px var(--alb-primary-glow, rgba(255,214,0,.25));
}

.alb-btn-outline {
    background: transparent;
    border: 2px solid var(--alb-primary, #FFD600);
    color: var(--alb-gray-900, #212121);
    border-radius: var(--alb-radius-pill, 9999px);
    padding: .6rem 1.5rem;
    font-weight: 700;
    font-size: .9rem;
    cursor: pointer;
    transition: background .2s ease, color .2s ease, transform .2s ease;
    display: inline-flex;
    align-items: center;
    gap: .45rem;
}
.alb-btn-outline:hover {
    background: var(--alb-primary, #FFD600);
    color: var(--alb-on-primary, #212121);
    transform: translateY(-2px);
}


/* ═══════════════════════════════════════════════════════════
   5. CARDS — Hover lift
═══════════════════════════════════════════════════════════ */

.alb-card-hover {
    transition: transform .3s var(--alb-ease, ease),
                box-shadow .3s var(--alb-ease, ease);
    will-change: transform;
}
.alb-card-hover:hover {
    transform: translateY(-4px);
    box-shadow: var(--alb-shadow-lg, 0 8px 32px rgba(0,0,0,.10));
}
.alb-card-hover:hover img {
    transform: scale(1.04);
}

/* Image zoom conteneur */
.alb-img-zoom {
    overflow: hidden;
    border-radius: inherit;
}
.alb-img-zoom img {
    transition: transform .4s var(--alb-ease, ease);
    display: block;
    width: 100%;
}


/* ═══════════════════════════════════════════════════════════
   6. GLASSMORPHISM
═══════════════════════════════════════════════════════════ */

.alb-glass {
    background: var(--alb-glass-bg, rgba(255,255,255,.72));
    backdrop-filter: var(--alb-glass-blur, blur(14px));
    -webkit-backdrop-filter: var(--alb-glass-blur, blur(14px));
    border: 1px solid var(--alb-glass-border, rgba(255,255,255,.55));
    box-shadow: var(--alb-shadow-sm, 0 2px 8px rgba(0,0,0,.06));
}


/* ═══════════════════════════════════════════════════════════
   7. TOAST NOTIFICATIONS
═══════════════════════════════════════════════════════════ */

.alb-toast-container {
    position: fixed;
    top: 1.25rem;
    right: 50%;
    transform: translateX(50%);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: .5rem;
    pointer-events: none;
    width: max-content;
    max-width: min(380px, 90vw);
}

.alb-toast {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .75rem 1.25rem;
    border-radius: var(--alb-radius-pill, 9999px);
    background: #1f2937;
    color: #fff;
    font-size: .875rem;
    font-weight: 600;
    font-family: var(--alb-font-body, sans-serif);
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
    animation: alb-toast-in .35s var(--alb-ease-spring, ease) forwards;
    pointer-events: auto;
}
.alb-toast.is-success { background: var(--alb-green-dark, #007E33); }
.alb-toast.is-error   { background: #b91c1c; }
.alb-toast.is-warning { background: var(--alb-warning, #FF9800); color: #1f2937; }
.alb-toast.is-info    { background: var(--alb-info, #2196F3); }
.alb-toast.is-leaving { animation: alb-toast-out .3s ease forwards; }
.alb-toast i          { font-size: 1rem; flex-shrink: 0; }


/* ═══════════════════════════════════════════════════════════
   8. FAVORITES — Cœur animé
═══════════════════════════════════════════════════════════ */

.alb-fav-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: .35rem;
    color: var(--alb-gray-300, #BDBDBD);
    font-size: 1.2rem;
    transition: color .2s ease, transform .2s var(--alb-ease-spring, ease);
}
.alb-fav-btn:hover         { color: #ef4444; transform: scale(1.15); }
.alb-fav-btn.is-active     { color: #ef4444; }
.alb-fav-btn.is-animating  { animation: alb-heartbeat .6s ease; }


/* ═══════════════════════════════════════════════════════════
   9. XP / PROGRESS BARS
═══════════════════════════════════════════════════════════ */

.alb-xp-bar-fill {
    animation: alb-xp-fill 1.2s var(--alb-ease-out, ease) both;
}

.alb-vdash__bar {
    animation: alb-bar-grow .8s var(--alb-ease-out, ease) both;
}


/* ═══════════════════════════════════════════════════════════
   10. SCROLLBAR CUSTOM
═══════════════════════════════════════════════════════════ */

* {
    scrollbar-width: thin;
    scrollbar-color: var(--alb-primary, #FFD600) var(--alb-gray-100, #EEEEEE);
}
*::-webkit-scrollbar       { width: 5px; height: 5px; }
*::-webkit-scrollbar-track { background: var(--alb-gray-100, #EEEEEE); }
*::-webkit-scrollbar-thumb {
    background: var(--alb-primary, #FFD600);
    border-radius: var(--alb-radius-pill, 9999px);
}
