/*
 * animations.css — Premium motion & visual design layer
 *
 * Drop this into any template alongside style.css to add:
 *   - Scroll-triggered entrance animations (fade, slide, scale)
 *   - Glassmorphism nav + cards
 *   - Layered shadow system
 *   - Gradient accents
 *   - Button micro-interactions (ripple, press, glow)
 *   - Hover card tilt
 *   - Fluid typography
 *   - Dark mode
 *   - Custom scrollbar
 *   - Smooth page transitions
 *   - Loading skeleton
 *   - Staggered list animations
 *
 * Respects prefers-reduced-motion. Progressive enhancement only —
 * everything works without JS, animations are just gravy.
 */

/* ── Fluid typography ───────────────────────────────────────────── */
h1 { font-size: clamp(1.75rem, 4vw, 3.25rem); }
h2 { font-size: clamp(1.35rem, 3vw, 2.25rem); }
h3 { font-size: clamp(1.1rem, 2.5vw, 1.5rem); }

/* ── Layered shadow system ──────────────────────────────────────── */
:root {
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.04);
    --shadow-lg: 0 12px 32px rgba(0,0,0,0.08), 0 4px 8px rgba(0,0,0,0.04);
    --shadow-xl: 0 20px 48px rgba(0,0,0,0.1), 0 8px 16px rgba(0,0,0,0.06);
    --shadow-glow: 0 0 30px rgba(var(--primary-rgb, 37,99,235), 0.15);
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Glassmorphism nav ──────────────────────────────────────────── */
.navbar {
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    background: rgba(15, 23, 42, 0.85) !important;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    transition: background var(--transition-smooth), box-shadow var(--transition-smooth);
}
.navbar.scrolled {
    box-shadow: var(--shadow-lg);
    background: rgba(15, 23, 42, 0.95) !important;
}

/* ── Scroll-triggered entrance animations ───────────────────────── */
.animate-in {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
                transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.animate-in.visible {
    opacity: 1;
    transform: translateY(0);
}
.animate-in.from-left {
    transform: translateX(-40px);
}
.animate-in.from-left.visible {
    transform: translateX(0);
}
.animate-in.from-right {
    transform: translateX(40px);
}
.animate-in.from-right.visible {
    transform: translateX(0);
}
.animate-in.scale-in {
    transform: scale(0.92);
}
.animate-in.scale-in.visible {
    transform: scale(1);
}

/* Stagger children */
.stagger-children > .animate-in:nth-child(1) { transition-delay: 0ms; }
.stagger-children > .animate-in:nth-child(2) { transition-delay: 80ms; }
.stagger-children > .animate-in:nth-child(3) { transition-delay: 160ms; }
.stagger-children > .animate-in:nth-child(4) { transition-delay: 240ms; }
.stagger-children > .animate-in:nth-child(5) { transition-delay: 320ms; }
.stagger-children > .animate-in:nth-child(6) { transition-delay: 400ms; }
.stagger-children > .animate-in:nth-child(7) { transition-delay: 480ms; }
.stagger-children > .animate-in:nth-child(8) { transition-delay: 560ms; }

/* ── Card hover effects ─────────────────────────────────────────── */
.product-card,
.blog-card,
.review-card,
.form-card,
.testimonial-card,
.menu-card {
    transition: transform var(--transition-spring),
                box-shadow var(--transition-smooth) !important;
}
.product-card:hover,
.blog-card:hover,
.menu-card:hover {
    transform: translateY(-6px) !important;
    box-shadow: var(--shadow-xl) !important;
}

/* Subtle tilt on hover (3D depth feel) */
.product-card:hover,
.menu-card:hover {
    transform: translateY(-6px) perspective(800px) rotateX(2deg) !important;
}

/* ── Button micro-interactions ──────────────────────────────────── */
.btn {
    position: relative;
    overflow: hidden;
    transition: all var(--transition-fast) !important;
    transform: translateZ(0);  /* GPU acceleration */
}
.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.btn:active {
    transform: translateY(0) scale(0.97);
    box-shadow: var(--shadow-xs);
}

/* Ripple effect on click */
.btn::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.25);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.5s, height 0.5s, opacity 0.5s;
    opacity: 0;
    pointer-events: none;
}
.btn:active::after {
    width: 300px;
    height: 300px;
    opacity: 0;
    transition: 0s;
}

/* Primary button glow */
.btn-primary:hover {
    box-shadow: 0 4px 15px rgba(var(--primary-rgb, 37,99,235), 0.35),
                var(--shadow-md);
}

/* ── Hero section enhancements ──────────────────────────────────── */
.hero, .hero-section, [class*="hero"] {
    position: relative;
    overflow: hidden;
}

/* Animated gradient background */
@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Floating shapes (decorative) */
@keyframes float {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    33% { transform: translateY(-15px) rotate(2deg); }
    66% { transform: translateY(8px) rotate(-1deg); }
}

@keyframes floatSlow {
    0%, 100% { transform: translateY(0) scale(1); }
    50% { transform: translateY(-20px) scale(1.02); }
}

.hero h1, .hero-section h1, .find-us-hero h1 {
    animation: floatSlow 6s ease-in-out infinite;
}

/* ── Smooth image loading ───────────────────────────────────────── */
img {
    transition: opacity 0.4s ease, transform 0.4s ease;
}
img[loading="lazy"] {
    opacity: 0;
}
img[loading="lazy"].loaded, img:not([loading="lazy"]) {
    opacity: 1;
}
.product-card img:hover,
.menu-card img:hover,
.gallery-item img:hover {
    transform: scale(1.05);
}

/* ── Loading skeleton ───────────────────────────────────────────── */
@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}
.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius);
}

/* ── Smooth number counter animation ────────────────────────────── */
@keyframes countUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.stat-card h3, .a-card .value, .stat .value {
    animation: countUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* ── Gradient text accent ───────────────────────────────────────── */
.gradient-text {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent, #f59e0b) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ── Custom scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #c1c7ce;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* ── Focus states for accessibility ─────────────────────────────── */
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ── Form input micro-interactions ──────────────────────────────── */
input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
textarea,
select {
    transition: border-color var(--transition-fast),
                box-shadow var(--transition-fast),
                transform var(--transition-fast) !important;
}
input:focus:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]),
textarea:focus,
select:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb, 37,99,235), 0.1) !important;
    transform: translateY(-1px);
}

/* ── Badge pulse for notifications ──────────────────────────────── */
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}
.cart-badge, .badge-green, .badge-red {
    animation: pulse 2s ease-in-out infinite;
}

/* ── Page section dividers ──────────────────────────────────────── */
.section + .section {
    position: relative;
}
.section + .section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--accent, #f59e0b));
    border-radius: 2px;
}

/* ── Footer gradient accent ─────────────────────────────────────── */
.footer {
    position: relative;
}
.footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--accent, #f59e0b), var(--primary));
}

/* ── Cookie banner slide up ─────────────────────────────────────── */
.cookie-banner {
    animation: slideUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) both !important;
}
@keyframes slideUp {
    from { transform: translateY(100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ── Smooth page transitions ────────────────────────────────────── */
@keyframes fadeInPage {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
main {
    animation: fadeInPage 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* ── Category filter pills ──────────────────────────────────────── */
.filter-btn, .pos-cat-btn {
    transition: all var(--transition-spring) !important;
}
.filter-btn:hover, .pos-cat-btn:hover {
    transform: translateY(-2px) scale(1.04);
}
.filter-btn.active, .pos-cat-btn.active {
    box-shadow: 0 4px 12px rgba(var(--primary-rgb, 37,99,235), 0.3);
}

/* ── Respect reduced motion ─────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .animate-in {
        opacity: 1 !important;
        transform: none !important;
    }
}

/* ── Dark mode (tenant restaurant sites only, NOT platform pages) ─ */
@media (prefers-color-scheme: dark) {
    body:not(.platform-page) {
        color-scheme: dark;
        --bg: #0f172a;
        --bg-alt: #1e293b;
        --bg-dark: #020617;
        --text: #f1f5f9;
        --text-light: #94a3b8;
        --border: #334155;
        --shadow: 0 1px 3px rgba(0,0,0,0.3);
        --shadow-lg: 0 10px 30px rgba(0,0,0,0.4);
    }
    body:not(.platform-page) .navbar {
        background: rgba(15, 23, 42, 0.92) !important;
    }
    body:not(.platform-page) .product-card,
    body:not(.platform-page) .blog-card,
    body:not(.platform-page) .menu-card,
    body:not(.platform-page) .review-card,
    body:not(.platform-page) .testimonial-card {
        background: var(--bg-alt) !important;
        border-color: var(--border) !important;
    }
    body:not(.platform-page) input,
    body:not(.platform-page) textarea,
    body:not(.platform-page) select {
        background: var(--bg-alt) !important;
        color: var(--text) !important;
        border-color: var(--border) !important;
    }
    body:not(.platform-page) .footer { background: #020617 !important; }
}
