/* ═══════════════════════════════════════════════════════════════════════════════
   FindHandsFree.com — Animations & Micro-Interactions
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ─── Scroll Reveal ─────────────────────────────────────────────────────────── */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
}
.reveal.visible {
    opacity: 1;
    transform: translateY(0);
}

.reveal-left {
    opacity: 0;
    transform: translateX(-40px);
    transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
}
.reveal-left.visible {
    opacity: 1;
    transform: translateX(0);
}

.reveal-right {
    opacity: 0;
    transform: translateX(40px);
    transition: opacity 0.7s var(--ease-out), transform 0.7s var(--ease-out);
}
.reveal-right.visible {
    opacity: 1;
    transform: translateX(0);
}

.reveal-scale {
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.6s var(--ease-out), transform 0.6s var(--ease-spring);
}
.reveal-scale.visible {
    opacity: 1;
    transform: scale(1);
}

/* ─── Safety net ──────────────────────────────────────────────────────────────
   Guarantees content is never left permanently hidden if the reveal JS fails to
   fire for an element (e.g. very tall articles). Anything still hidden fades in
   automatically after ~1.2s. The JS still reveals sooner on scroll when it runs. */
.reveal, .reveal-left, .reveal-right, .reveal-scale {
    animation: revealSafetyNet 0.6s ease-out 1.2s forwards;
}
.reveal.visible, .reveal-left.visible, .reveal-right.visible, .reveal-scale.visible {
    animation: none;
}
@keyframes revealSafetyNet {
    to { opacity: 1; transform: none; }
}

/* Stagger children (grid cards, etc.) */
.stagger-children > *:nth-child(1) { transition-delay: 0.05s; }
.stagger-children > *:nth-child(2) { transition-delay: 0.10s; }
.stagger-children > *:nth-child(3) { transition-delay: 0.15s; }
.stagger-children > *:nth-child(4) { transition-delay: 0.20s; }
.stagger-children > *:nth-child(5) { transition-delay: 0.25s; }
.stagger-children > *:nth-child(6) { transition-delay: 0.30s; }
.stagger-children > *:nth-child(7) { transition-delay: 0.35s; }
.stagger-children > *:nth-child(8) { transition-delay: 0.40s; }
.stagger-children > *:nth-child(9) { transition-delay: 0.45s; }

/* ─── Keyframe Animations ───────────────────────────────────────────────────── */

/* Floating effect for hero decorations */
@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-12px); }
}

/* Pulse glow for accent elements */
@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 20px var(--accent-glow); }
    50% { box-shadow: 0 0 40px var(--accent-glow), 0 0 60px rgba(0, 201, 167, 0.1); }
}

/* Bell swing for newsletter */
@keyframes bellSwing {
    0%, 100% { transform: rotate(0deg); }
    10% { transform: rotate(12deg); }
    20% { transform: rotate(-10deg); }
    30% { transform: rotate(8deg); }
    40% { transform: rotate(-6deg); }
    50% { transform: rotate(0deg); }
}

/* Slide down for flash messages */
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-16px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Slide up for modals */
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Fade in */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Shimmer loading placeholder */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
.skeleton {
    background: linear-gradient(90deg,
        var(--bg-card) 25%,
        var(--bg-elevated) 50%,
        var(--bg-card) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
}

/* Spin for loading indicators */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Typing animation for hero text */
@keyframes typewriter {
    from { width: 0; }
    to { width: 100%; }
}
@keyframes blink {
    0%, 50% { border-color: var(--accent); }
    51%, 100% { border-color: transparent; }
}

/* ─── Card Hover Glow Effect ────────────────────────────────────────────────── */
.post-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    opacity: 0;
    transition: opacity var(--duration-base);
    pointer-events: none;
    background: radial-gradient(
        600px circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
        rgba(0, 201, 167, 0.06),
        transparent 40%
    );
}
.post-card { position: relative; }
.post-card:hover::after { opacity: 1; }

/* ─── Price Tag Bounce ──────────────────────────────────────────────────────── */
@keyframes priceBounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}
.product-price {
    animation: priceBounce 2s ease-in-out infinite;
    animation-play-state: paused;
}
.product-box:hover .product-price {
    animation-play-state: running;
}

/* ─── Rating Stars Reveal ───────────────────────────────────────────────────── */
@keyframes starPop {
    0% { transform: scale(0); opacity: 0; }
    60% { transform: scale(1.3); }
    100% { transform: scale(1); opacity: 1; }
}
.product-rating .star {
    display: inline-block;
    animation: starPop 0.4s var(--ease-spring) both;
}
.product-rating .star:nth-child(1) { animation-delay: 0.1s; }
.product-rating .star:nth-child(2) { animation-delay: 0.2s; }
.product-rating .star:nth-child(3) { animation-delay: 0.3s; }
.product-rating .star:nth-child(4) { animation-delay: 0.4s; }
.product-rating .star:nth-child(5) { animation-delay: 0.5s; }

/* ─── Button Ripple ─────────────────────────────────────────────────────────── */
.btn {
    position: relative;
    overflow: hidden;
}
.btn .ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0);
    animation: rippleEffect 0.6s linear;
    pointer-events: none;
}
@keyframes rippleEffect {
    to { transform: scale(4); opacity: 0; }
}

/* ─── Gradient Border Glow ──────────────────────────────────────────────────── */
.glow-border {
    position: relative;
}
.glow-border::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    background: linear-gradient(135deg, var(--accent), var(--highlight), var(--accent));
    z-index: -1;
    opacity: 0;
    transition: opacity var(--duration-base);
}
.glow-border:hover::before { opacity: 1; }

/* ─── Smooth Image Load ─────────────────────────────────────────────────────── */
.lazy-img {
    opacity: 0;
    transition: opacity 0.5s ease;
}
.lazy-img.loaded {
    opacity: 1;
}

/* ─── Hero Particles (CSS only) ─────────────────────────────────────────────── */
.hero-particles {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}
.hero-particles span {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent);
    opacity: 0.2;
    animation: floatParticle linear infinite;
}
.hero-particles span:nth-child(1) { left: 10%; top: 20%; animation-duration: 8s; animation-delay: 0s; }
.hero-particles span:nth-child(2) { left: 30%; top: 60%; animation-duration: 12s; animation-delay: 2s; width: 6px; height: 6px; }
.hero-particles span:nth-child(3) { left: 50%; top: 30%; animation-duration: 10s; animation-delay: 4s; }
.hero-particles span:nth-child(4) { left: 70%; top: 70%; animation-duration: 9s; animation-delay: 1s; width: 3px; height: 3px; }
.hero-particles span:nth-child(5) { left: 85%; top: 40%; animation-duration: 11s; animation-delay: 3s; width: 5px; height: 5px; }
.hero-particles span:nth-child(6) { left: 20%; top: 80%; animation-duration: 7s; animation-delay: 5s; }

@keyframes floatParticle {
    0%   { transform: translate(0, 0) scale(1); opacity: 0; }
    10%  { opacity: 0.3; }
    50%  { transform: translate(40px, -60px) scale(1.5); opacity: 0.2; }
    90%  { opacity: 0.1; }
    100% { transform: translate(-20px, -120px) scale(0.5); opacity: 0; }
}

/* ─── Reduced Motion ────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .reveal, .reveal-left, .reveal-right, .reveal-scale {
        opacity: 1;
        transform: none;
    }
}
