/**
 * LeBonResto Animations & Micro-interactions
 * Requires tokens.css for variables.
 */

/* ═══ KEYFRAMES ═══ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

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

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

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 8px rgba(var(--primary-rgb), 0.2); }
    50% { box-shadow: 0 0 20px rgba(var(--primary-rgb), 0.35); }
}

@keyframes heartBeat {
    0% { transform: scale(1); }
    15% { transform: scale(1.25); }
    30% { transform: scale(1); }
    45% { transform: scale(1.15); }
    60% { transform: scale(1); }
}

@keyframes countUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ═══ UTILITY CLASSES ═══ */

/* Fade in on load */
.fade-in {
    animation: fadeIn 0.5s ease both;
}

.fade-in-up {
    animation: fadeInUp 0.5s ease both;
}

.fade-in-down {
    animation: fadeInDown 0.4s ease both;
}

.scale-in {
    animation: scaleIn 0.4s ease both;
}

.slide-in-right {
    animation: slideInRight 0.4s ease both;
}

.slide-in-left {
    animation: slideInLeft 0.4s ease both;
}

/* Stagger children — apply to parent, children get delayed fade */
.stagger > * {
    opacity: 0;
    animation: fadeInUp 0.4s ease forwards;
}
.stagger > *:nth-child(1) { animation-delay: 0.05s; }
.stagger > *:nth-child(2) { animation-delay: 0.1s; }
.stagger > *:nth-child(3) { animation-delay: 0.15s; }
.stagger > *:nth-child(4) { animation-delay: 0.2s; }
.stagger > *:nth-child(5) { animation-delay: 0.25s; }
.stagger > *:nth-child(6) { animation-delay: 0.3s; }
.stagger > *:nth-child(7) { animation-delay: 0.35s; }
.stagger > *:nth-child(8) { animation-delay: 0.4s; }
.stagger > *:nth-child(9) { animation-delay: 0.45s; }
.stagger > *:nth-child(10) { animation-delay: 0.5s; }
.stagger > *:nth-child(11) { animation-delay: 0.55s; }
.stagger > *:nth-child(12) { animation-delay: 0.6s; }

/* ═══ HOVER EFFECTS ═══ */

/* Lift on hover */
.hover-lift {
    transition: transform var(--transition), box-shadow var(--transition);
}
.hover-lift:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

/* Subtle glow on hover */
.hover-glow {
    transition: box-shadow var(--transition);
}
.hover-glow:hover {
    box-shadow: var(--shadow-glow);
}

/* Scale on hover (for icons, avatars) */
.hover-scale {
    transition: transform var(--transition-fast);
}
.hover-scale:hover {
    transform: scale(1.08);
}

/* Image zoom on hover (wrap image in overflow:hidden container) */
.hover-zoom img {
    transition: transform 0.4s ease;
}
.hover-zoom:hover img {
    transform: scale(1.06);
}

/* ═══ SCROLL-TRIGGERED (via IntersectionObserver) ═══ */

/* Apply .reveal to elements; JS adds .revealed when in viewport */
.reveal {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* Variants */
.reveal-left {
    opacity: 0;
    transform: translateX(-30px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal-left.revealed {
    opacity: 1;
    transform: translateX(0);
}

.reveal-scale {
    opacity: 0;
    transform: scale(0.92);
    transition: opacity 0.6s ease, transform 0.6s ease;
}
.reveal-scale.revealed {
    opacity: 1;
    transform: scale(1);
}

/* ═══ SKELETON LOADING ═══ */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--gray-100) 25%,
        var(--gray-200) 50%,
        var(--gray-100) 75%
    );
    background-size: 400% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: var(--radius-sm);
    will-change: background-position;
    transform: translateZ(0);
}

.skeleton-text {
    height: 14px;
    margin-bottom: 8px;
    border-radius: 4px;
}

.skeleton-text:last-child {
    width: 60%;
}

.skeleton-circle {
    border-radius: 50%;
}

.skeleton-card {
    height: 200px;
    border-radius: var(--radius-md);
}

/* ═══ SPECIAL EFFECTS ═══ */

/* Pulsing glow (for CTA buttons, notifications) */
.glow-pulse {
    animation: glow 2s ease-in-out infinite;
}

/* Heart animation (for wishlist) */
.heart-beat {
    animation: heartBeat 0.6s ease;
}

/* Number count-up */
.count-up {
    animation: countUp 0.5s ease both;
}

/* ═══ SMOOTH SCROLL ═══ */
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
}

/* ═══ FOCUS VISIBLE ═══ */
:focus-visible {
    outline: 2px solid var(--primary, #00635a);
    outline-offset: 2px;
}
button:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
    outline: none;
}

/* ═══ BUTTON LOADING STATE ═══ */
.btn.loading {
    pointer-events: none;
    opacity: 0.7;
    position: relative;
}
.btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    right: 12px;
    top: 50%;
    margin-top: -8px;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ═══ EXPLORER TAB FADE ═══ */
.explorer-panel {
    display: none;
}
.explorer-panel.active {
    display: block;
    animation: fadeInUp 0.3s cubic-bezier(0.4, 0, 0.2, 1) both;
}

/* ═══ CARD HOVER (desktop only) ═══ */
@media (hover: hover) {
    .resto-card {
        transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1),
                    box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }
    .resto-card:hover {
        transform: translateY(-3px);
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
    }
}

/* ═══ HEART BOUNCE ═══ */
@keyframes heartBounce {
    0% { transform: scale(1); }
    30% { transform: scale(1.3); }
    60% { transform: scale(0.9); }
    100% { transform: scale(1); }
}
.fav-btn.animate,
.resto-card-wishlist.animate,
.nav-btn.animate {
    animation: heartBounce 0.4s ease;
}

/* ═══ REVIEW SNIPPET CLAMP ═══ */
.review-excerpt {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ═══ RATING BAR ANIMATION ═══ */
.stats-bar-fill {
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.stats-bar-fill.animate-in {
    width: var(--bar-width) !important;
}

/* ═══ TOUCH TARGETS MOBILE ═══ */
@media (max-width: 768px) {
    .reaction-btn,
    .vote-btn {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
}

/* ═══ 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-scale {
        opacity: 1;
        transform: none;
    }
    .skeleton {
        animation: none;
        background: var(--gray-100);
    }
}
