/* ============================================================
   ANIMATIONS 3D — El Patio Premium Motion System
   Three.js · GSAP ScrollTrigger · CSS Motion
   ============================================================ */

/* --- Design Tokens --- */
:root {
    --anim-speed-fast: 0.4s;
    --anim-speed-base: 0.8s;
    --anim-speed-slow: 1.2s;
    --anim-ease-premium: cubic-bezier(0.16, 1, 0.3, 1);
    --anim-ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --anim-ease-smooth: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --anim-tilt-max: 8deg;
    --anim-glow-color: rgba(233, 193, 118, 0.15);
    --anim-glow-strong: rgba(233, 193, 118, 0.3);
}

/* ============================================================
   1. HERO 3D CANVAS
   ============================================================ */
.hero-home {
    position: relative;
    overflow: hidden;
}

#hero-3d-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    pointer-events: none;
    opacity: 0;
    transition: opacity 1.5s var(--anim-ease-premium);
}

#hero-3d-canvas.is-loaded {
    opacity: 1;
}

.hero-home .hero-media {
    z-index: 0;
}

.hero-home .hero-shade,
.hero-home .hero-fade {
    z-index: 2;
}

.hero-home .hero-content {
    position: relative;
    z-index: 3;
}

/* Hero content enhanced entrance */
.hero-home .hero-content h1 {
    opacity: 0;
    transform: translateY(40px) scale(0.95);
    animation: heroTitleEnter 1.4s var(--anim-ease-premium) 0.3s forwards;
}

.hero-home .hero-content p {
    opacity: 0;
    transform: translateY(30px);
    animation: heroSubEnter 1.2s var(--anim-ease-premium) 0.6s forwards;
}

.hero-home .hero-actions {
    opacity: 0;
    transform: translateY(25px);
    animation: heroActionsEnter 1s var(--anim-ease-premium) 0.9s forwards;
}

@keyframes heroTitleEnter {
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes heroSubEnter {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes heroActionsEnter {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================================
   2. ENHANCED SCROLL REVEAL (GSAP replaces IntersectionObserver)
   ============================================================ */

/* Base state for GSAP-driven reveals */
.gsap-reveal {
    opacity: 0;
    transform: translateY(50px);
    filter: blur(4px);
    will-change: transform, opacity, filter;
}

.gsap-reveal.is-revealed {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
}

/* Reveal from left */
.gsap-reveal-left {
    opacity: 0;
    transform: translateX(-60px);
    filter: blur(3px);
}

/* Reveal from right */
.gsap-reveal-right {
    opacity: 0;
    transform: translateX(60px);
    filter: blur(3px);
}

/* Reveal with scale */
.gsap-reveal-scale {
    opacity: 0;
    transform: scale(0.85);
    filter: blur(6px);
}

/* Section heading parallax */
.section-heading[data-parallax] {
    will-change: transform;
}

/* ============================================================
   3. CARD 3D TILT EFFECT
   ============================================================ */
[data-3d-tilt] {
    perspective: 800px;
    transform-style: preserve-3d;
}

[data-3d-tilt] > * {
    transition: transform var(--anim-speed-fast) var(--anim-ease-smooth);
    transform-style: preserve-3d;
    will-change: transform;
}

/* Glow overlay for tilt cards */
.tilt-glow {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    opacity: 0;
    background: radial-gradient(
        circle at var(--glow-x, 50%) var(--glow-y, 50%),
        var(--anim-glow-color) 0%,
        transparent 60%
    );
    transition: opacity 0.4s ease;
    z-index: 5;
}

[data-3d-tilt]:hover .tilt-glow {
    opacity: 1;
}

/* Dish card 3D enhancements */
.dish-card[data-3d-tilt] {
    position: relative;
    overflow: hidden;
}

.dish-card[data-3d-tilt] .dish-image img {
    transition: transform 0.6s var(--anim-ease-premium);
}

.dish-card[data-3d-tilt]:hover .dish-image img {
    transform: scale(1.08);
}

/* Gallery tile 3D enhancements */
.gallery-tile[data-3d-tilt] {
    position: relative;
    overflow: hidden;
}

.gallery-tile[data-3d-tilt] img {
    transition: transform 0.6s var(--anim-ease-premium);
}

.gallery-tile[data-3d-tilt]:hover img {
    transform: scale(1.05);
}

/* Event card 3D enhancements */
[data-3d-tilt].event-card-3d {
    position: relative;
    overflow: hidden;
}

[data-3d-tilt].event-card-3d:hover {
    border-color: var(--anim-glow-color) !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5),
                0 0 30px var(--anim-glow-color);
}

/* ============================================================
   4. TAG ANIMATIONS
   ============================================================ */
.dish-tag {
    animation: tagPulseIn 0.5s var(--anim-ease-bounce) both;
}

.dish-tag:nth-child(1) { animation-delay: 0.1s; }
.dish-tag:nth-child(2) { animation-delay: 0.2s; }
.dish-tag:nth-child(3) { animation-delay: 0.3s; }

@keyframes tagPulseIn {
    0% {
        opacity: 0;
        transform: scale(0.6);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* ============================================================
   5. FORM MICRO-ANIMATIONS
   ============================================================ */

/* Focus glow ring */
.form-field .form-control:focus {
    border-color: var(--secondary) !important;
    box-shadow: 0 0 0 3px rgba(233, 193, 118, 0.12),
                0 0 20px rgba(233, 193, 118, 0.06);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Floating label effect */
.form-field {
    position: relative;
}

.form-field label {
    transition: color 0.3s ease, transform 0.3s ease;
}

.form-field:focus-within label {
    color: var(--secondary);
}

/* Error shake */
@keyframes fieldShake {
    0%, 100% { transform: translateX(0); }
    10%, 50%, 90% { transform: translateX(-4px); }
    30%, 70% { transform: translateX(4px); }
}

.form-field.has-error {
    animation: fieldShake 0.4s ease;
}

.form-field.has-error .form-control {
    border-color: #ffb4ab !important;
    box-shadow: 0 0 0 2px rgba(255, 180, 171, 0.15);
}

/* Success animation overlay */
.reservation-success-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    background: rgba(10, 10, 9, 0.92);
    backdrop-filter: blur(20px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s var(--anim-ease-premium);
}

.reservation-success-overlay.is-active {
    opacity: 1;
    pointer-events: auto;
}

.success-checkmark {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--secondary), #d4a84b);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: successPop 0.6s var(--anim-ease-bounce) forwards;
    box-shadow: 0 0 40px rgba(233, 193, 118, 0.3);
}

.success-checkmark .material-symbols-outlined {
    font-size: 48px;
    color: var(--on-secondary);
    font-variation-settings: 'FILL' 1;
}

@keyframes successPop {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    60% {
        transform: scale(1.15);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.success-text {
    margin-top: 24px;
    text-align: center;
    animation: successTextIn 0.5s var(--anim-ease-premium) 0.3s forwards;
    opacity: 0;
    transform: translateY(15px);
}

@keyframes successTextIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.success-text h3 {
    font-family: var(--font-display);
    font-size: 1.6rem;
    margin: 0 0 8px;
    color: var(--secondary);
}

.success-text p {
    font-size: 0.9rem;
    color: var(--on-muted);
    margin: 0;
}

/* Confetti particles */
.confetti-particle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 1px;
    opacity: 0;
    animation: confettiFall 2s ease-in forwards;
}

@keyframes confettiFall {
    0% {
        opacity: 1;
        transform: translateY(0) rotate(0deg) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(400px) rotate(720deg) scale(0.3);
    }
}

/* ============================================================
   6. GALLERY DEPTH EFFECTS
   ============================================================ */
.gallery-grid [data-3d-tilt] {
    transition: box-shadow 0.4s ease;
}

.gallery-grid [data-3d-tilt]:hover {
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5),
                0 0 30px rgba(233, 193, 118, 0.08);
}

/* Lightbox modal entrance */
.gallery-lightbox {
    opacity: 0;
    transition: opacity 0.4s var(--anim-ease-premium);
}

.gallery-lightbox.is-active {
    opacity: 1;
}

.gallery-lightbox .lightbox-content {
    transform: scale(0.9) translateY(20px);
    transition: transform 0.5s var(--anim-ease-bounce);
}

.gallery-lightbox.is-active .lightbox-content {
    transform: scale(1) translateY(0);
}

/* ============================================================
   7. FOOTER AMBIENT
   ============================================================ */
.site-footer {
    position: relative;
    overflow: hidden;
}

#footer-ambience {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0.4;
    z-index: 0;
}

.site-footer .footer-grid,
.site-footer .footer-bottom {
    position: relative;
    z-index: 1;
}

/* Social icons hover 3D */
.social-row a {
    transition: transform 0.3s var(--anim-ease-bounce),
                color 0.3s ease;
}

.social-row a:hover {
    transform: translateY(-3px) scale(1.15);
    color: var(--secondary);
}

.social-row a:hover .social-icon-svg {
    fill: var(--secondary);
    filter: drop-shadow(0 0 8px var(--anim-glow-color));
}

/* ============================================================
   8. EXPERIENCE BAND PARALLAX
   ============================================================ */
.experience-band {
    overflow: hidden;
}

.experience-band .experience-bg img {
    transition: transform 0.1s linear;
    will-change: transform;
}

/* ============================================================
   9. NAV LINK HOVER PREMIUM
   ============================================================ */
.nav-links a {
    position: relative;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--secondary);
    transition: width 0.3s var(--anim-ease-premium), left 0.3s var(--anim-ease-premium);
    border-radius: 1px;
}

.nav-links a:hover::after,
.nav-links a:focus-visible::after {
    width: 100%;
    left: 0;
}

/* ============================================================
   10. BUTTON HOVER ENHANCEMENTS
   ============================================================ */
.button-primary {
    position: relative;
    overflow: hidden;
    transition: transform 0.3s var(--anim-ease-bounce),
                box-shadow 0.3s ease;
}

.button-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(233, 193, 118, 0.25);
}

.button-primary::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        105deg,
        transparent 30%,
        rgba(255, 255, 255, 0.15) 50%,
        transparent 70%
    );
    transform: translateX(-100%);
    transition: transform 0.6s ease;
}

.button-primary:hover::before {
    transform: translateX(100%);
}

.button-secondary:hover,
.button-ghost:hover {
    transform: translateY(-2px);
    transition: transform 0.3s var(--anim-ease-bounce);
}

/* ============================================================
   11. SECTION DIVIDER GLOW LINE
   ============================================================ */
.section-label {
    position: relative;
    display: inline-block;
}

.section-label::before {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 0;
    width: 40px;
    height: 2px;
    background: var(--secondary);
    border-radius: 1px;
    animation: glowPulse 3s ease-in-out infinite;
}

@keyframes glowPulse {
    0%, 100% {
        box-shadow: 0 0 4px var(--anim-glow-color);
        opacity: 0.7;
    }
    50% {
        box-shadow: 0 0 12px var(--anim-glow-strong);
        opacity: 1;
    }
}

/* ============================================================
   12. PAGE TRANSITION
   ============================================================ */
main {
    animation: pageIn 0.6s var(--anim-ease-premium) forwards;
}

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

/* ============================================================
   13. LOADING SHIMMER FOR IMAGES
   ============================================================ */
.dish-image,
.gallery-tile,
.media-frame {
    position: relative;
    overflow: hidden;
}

.dish-image::before,
.gallery-tile::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(233, 193, 118, 0.03) 50%,
        transparent 100%
    );
    animation: shimmer 2s infinite;
    z-index: 1;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ============================================================
   RESPONSIVE — MOBILE SIMPLIFICATIONS
   ============================================================ */
@media (max-width: 768px) {
    /* Disable 3D tilt on touch */
    [data-3d-tilt] > * {
        transform: none !important;
    }

    .tilt-glow {
        display: none;
    }

    /* Reduce reveal distances */
    .gsap-reveal {
        transform: translateY(30px);
        filter: blur(2px);
    }

    /* Keep hero 3D canvas active on mobile */

    /* Simpler hero entrance */
    .hero-home .hero-content h1 {
        animation-duration: 0.8s;
        transform: translateY(20px) scale(1);
    }

    .hero-home .hero-content p {
        animation-duration: 0.7s;
    }

    .hero-home .hero-actions {
        animation-duration: 0.6s;
    }

    /* Footer ambient hidden on mobile */
    #footer-ambience {
        display: none;
    }
}

/* ============================================================
   ACCESSIBILITY — REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    #hero-3d-canvas,
    #footer-ambience {
        display: none !important;
    }

    .gsap-reveal,
    .gsap-reveal-left,
    .gsap-reveal-right,
    .gsap-reveal-scale {
        opacity: 1 !important;
        transform: none !important;
        filter: none !important;
    }

    [data-3d-tilt] > * {
        transform: none !important;
    }

    .tilt-glow {
        display: none !important;
    }

    .button-primary::before {
        display: none;
    }
}
