/* === Animation Keyframes & Utility Classes ===
 * Micro-animation system for the portal.
 * Uses CSS custom properties from variables.css.
 * Version: 2.0.0
 */

/* ── Fade + slide ─────────────────────────────────── */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-20px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes fadeInRight {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes fadeOut {
    from { opacity: 1; }
    to   { opacity: 0; }
}

/* ── Scale ────────────────────────────────────────── */
@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}
@keyframes scaleOut {
    from { opacity: 1; transform: scale(1); }
    to   { opacity: 0; transform: scale(0.95); }
}
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50%      { transform: scale(1.05); }
}

/* ── Ripple (buttons) ─────────────────────────────── */
@keyframes ripple {
    to { transform: scale(4); opacity: 0; }
}
.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    transform: scale(0);
    animation: ripple 0.6s linear;
    pointer-events: none;
}

/* ── Skeleton shimmer ─────────────────────────────── */
@keyframes shimmer {
    0%   { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* ── Glass glow ───────────────────────────────────── */
@keyframes glassGlow {
    0%, 100% { opacity: 0.4; }
    50%      { opacity: 0.8; }
}

/* ── Confetti fall ─────────────────────────────────── */
@keyframes confettiFall {
    0%   { transform: translateY(-10vh) rotate(0deg); opacity: 1; }
    100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* ── Rotate (FAQ icon, dropdown arrows) ────────────── */
@keyframes rotateIcon {
    from { transform: rotate(0deg); }
    to   { transform: rotate(180deg); }
}

/* ── Fade + scale (cards, modals) ──────────────────── */
@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.9); }
    to   { opacity: 1; transform: scale(1); }
}

/* ── Glow pulse (hero decorative circles) ──────────── */
@keyframes glowPulse {
    0%, 100% { transform: scale(1); opacity: 0.3; }
    50%      { transform: scale(1.2); opacity: 0.5; }
}

/* ── Confetti trajectory (custom properties per particle) ─ */
@keyframes confettiTrajectory {
    0%   { opacity: 1; transform: translate(0, 0) rotate(var(--start-rot, 0deg)); }
    100% { opacity: 0; transform: translate(var(--drift-x, 80px), var(--drift-y, 500px)) rotate(var(--end-rot, 720deg)); }
}

/* ── Confetti drop (CSS-only, static elements) ─────── */
@keyframes confettiDrop {
    0%   { transform: translateY(-10vh) rotate(0deg) scale(1); opacity: 1; }
    100% { transform: translateY(110vh) rotate(720deg) scale(0.5); opacity: 0; }
}

/* ── Icon wiggle (theme toggle, interactive icons) ─── */
@keyframes iconWiggle {
    0%, 100% { transform: rotate(0deg); }
    25%      { transform: rotate(-10deg); }
    75%      { transform: rotate(10deg); }
}

/* ── Notification slide-in ────────────────────────── */
@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}
@keyframes slideOutRight {
    from { transform: translateX(0); opacity: 1; }
    to   { transform: translateX(100%); opacity: 0; }
}

/* ════════════════════════════════════════════════════
   Utility Classes
   ════════════════════════════════════════════════════ */
.anim-fade-in-up    { animation: fadeInUp 0.5s var(--ease-out) both; }
.anim-fade-in-down  { animation: fadeInDown 0.4s var(--ease-out) both; }
.anim-fade-in-left  { animation: fadeInLeft 0.4s var(--ease-out) both; }
.anim-fade-in-right { animation: fadeInRight 0.4s var(--ease-out) both; }
.anim-fade-in       { animation: fadeIn 0.3s var(--ease-out) both; }
.anim-scale-in      { animation: scaleIn 0.3s var(--ease-out) both; }
.anim-pulse         { animation: pulse 2s var(--ease-in-out) infinite; }
.anim-fade-in-scale { animation: fadeInScale 0.5s var(--ease-out) both; }

/* Stagger delays */
.anim-delay-100 { animation-delay: 0.1s; }
.anim-delay-200 { animation-delay: 0.2s; }
.anim-delay-300 { animation-delay: 0.3s; }
.anim-delay-400 { animation-delay: 0.4s; }
.anim-delay-500 { animation-delay: 0.5s; }

/* Stagger children — apply .anim-stagger to parent */
.anim-stagger > * { opacity: 0; animation: fadeInUp 0.5s var(--ease-out) both; }
.anim-stagger > *:nth-child(1) { animation-delay: 0.1s; }
.anim-stagger > *:nth-child(2) { animation-delay: 0.2s; }
.anim-stagger > *:nth-child(3) { animation-delay: 0.3s; }
.anim-stagger > *:nth-child(4) { animation-delay: 0.4s; }
.anim-stagger > *:nth-child(5) { animation-delay: 0.5s; }

/* ── Scroll-reveal (driven by scroll-animation.js) ─── */
.anim-on-scroll {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.6s var(--ease-out),
                transform 0.6s var(--ease-out);
    will-change: transform, opacity;
}
.anim-on-scroll.anim-visible {
    opacity: 1;
    transform: translateY(0);
}

/* ── Scroll-reveal target (initial state) ─────────── */
[data-reveal],
.reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.5s var(--ease-out),
                transform 0.5s var(--ease-out);
}
[data-reveal].revealed,
.reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* ════════════════════════════════════════════════════
   Reduced Motion — respect user preference
   ════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    [data-reveal] {
        opacity: 1;
        transform: none;
        transition: none;
    }
}
