/**
 * Casita Palmera - Premium Animation Styles
 * Keyframes, transitions, and animation utilities
 */

/* ============================================
   PAGE LOADER
   ============================================ */
.page-loader {
    position: fixed;
    inset: 0;
    background: var(--bg-secondary);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-6);
}

.loader-logo {
    font-family: var(--font-family-display);
    font-size: var(--font-size-4xl);
    color: var(--color-primary);
    opacity: 0;
    transform: translateY(20px);
}

.loader-bar {
    width: 200px;
    height: 3px;
    background: var(--color-gray-200);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.loader-progress {
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
    border-radius: var(--radius-full);
}

/* Body loaded state */
body.loaded {
    overflow: visible;
}

/* ============================================
   HERO ANIMATIONS - Initial States
   ============================================ */
/* Hide hero elements initially - GSAP will animate them in */
.hero-title,
.hero-address,
.video-container,
.quick-info-item {
    opacity: 0;
    transform: translateY(30px);
}

.hero-title {
    perspective: 400px;
}

.hero-title .char {
    display: inline-block;
    transform-origin: bottom center;
}

.hero-title .word {
    display: inline-block;
    margin-right: 0.25em;
}

/* ============================================
   QUICK INFO ANIMATIONS
   ============================================ */
.quick-info-item {
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.4s ease,
                background-color 0.3s ease;
}

.quick-info-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(9, 120, 108, 0.12);
    background-color: var(--color-gray-50);
}

.quick-info-item i {
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
                color 0.3s ease;
}

.quick-info-item:hover i {
    transform: scale(1.2) rotate(5deg);
    color: var(--color-primary);
}

/* ============================================
   GALLERY ANIMATIONS - SHINE EFFECT
   ============================================ */
.bento-item {
    position: relative;
    overflow: hidden;
}

.bento-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.25),
        transparent
    );
    transform: skewX(-15deg);
    transition: left 0.6s ease;
    z-index: 2;
    pointer-events: none;
}

.bento-item:hover::before {
    left: 150%;
}

/* Enhanced gallery item hover */
.bento-item .bento-image {
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.bento-item:hover .bento-image {
    transform: scale(1.08);
}

.bento-item.bento-large:hover .bento-image {
    transform: scale(1.05);
}

/* Vanilla Tilt glare fix */
.bento-item .js-tilt-glare {
    border-radius: inherit;
}

/* ============================================
   SECTION TITLE ANIMATIONS
   ============================================ */
section h2,
.dintorni h2 {
    perspective: 400px;
}

section h2 .word,
.dintorni h2 .word {
    display: inline-block;
    transform-origin: bottom center;
}

/* ============================================
   FEATURES ANIMATIONS
   ============================================ */
.feature-icon {
    transition: color 0.3s ease,
                transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.feature-item:hover .feature-icon {
    color: var(--color-primary);
    transform: scale(1.25) rotate(8deg);
}


.feature-item:hover {
    background-color: var(--color-gray-50);
}

/* ============================================
   LOCATION ANIMATIONS
   ============================================ */
.location-map {
    transition: border-radius 0.6s ease,
                transform 0.6s ease;
}

.location-highlight {
    transition: transform 0.3s ease,
                color 0.3s ease;
}

.location-highlight:hover {
    transform: translateX(4px);
    color: var(--color-primary);
}

/* Map button ripple base */
.map-button {
    position: relative;
    overflow: hidden;
}

.map-button::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.map-button:active::after {
    width: 300px;
    height: 300px;
}

/* ============================================
   SURROUNDINGS ANIMATIONS
   ============================================ */
.dintorni-item:hover {
    transform: translateX(4px);
}

.dintorni-header i {
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.dintorni-group:hover .dintorni-header i {
    transform: scale(1.15) rotate(5deg);
}

/* ============================================
   BUTTON RIPPLE EFFECT
   ============================================ */
.btn-primary,
.btn-base {
    position: relative;
    overflow: hidden;
}

.btn-primary::before,
.btn-base::before {
    content: '';
    position: absolute;
    top: var(--ripple-y, 50%);
    left: var(--ripple-x, 50%);
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease, opacity 0.6s ease;
    pointer-events: none;
}

.btn-primary.ripple-active::before,
.btn-base.ripple-active::before {
    width: 300px;
    height: 300px;
    opacity: 0;
}

/* Enhanced button hover */
.btn-primary {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                background-color 0.3s ease,
                box-shadow 0.3s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(9, 120, 108, 0.25);
}

.btn-primary:active {
    transform: translateY(0);
}

/* ============================================
   LINK UNDERLINE ANIMATIONS
   ============================================ */
.view-map-link {
    position: relative;
}

.view-map-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: currentColor;
    transition: width 0.4s cubic-bezier(0.65, 0, 0.35, 1);
}

.view-map-link:hover::after {
    width: 100%;
}

/* ============================================
   WHATSAPP BUTTON PULSE
   ============================================ */
@keyframes pulse-ring {
    0% {
        transform: scale(1);
        opacity: 0.8;
    }
    100% {
        transform: scale(1.4);
        opacity: 0;
    }
}

.booking-whatsapp-btn {
    position: relative;
}

.booking-whatsapp-btn::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: var(--color-primary);
    animation: pulse-ring 2s ease-out infinite;
    z-index: -1;
    opacity: 0;
}

.booking-whatsapp-btn:hover::after {
    opacity: 1;
}

/* ============================================
   HEADER SCROLL STATE
   ============================================ */
.header {
    transition: background-color 0.3s ease,
                box-shadow 0.3s ease,
                backdrop-filter 0.3s ease;
}

.header-scrolled {
    background-color: rgba(255, 255, 255, 0.98);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.08);
}

/* ============================================
   LIGHTBOX ENHANCED ANIMATIONS
   ============================================ */
.gallery-lightbox {
    transition: opacity 0.3s ease;
}

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

.lightbox-image-container img {
    transition: transform 0.4s ease, opacity 0.4s ease;
}

/* ============================================
   VIDEO OVERLAY ANIMATIONS
   ============================================ */
.play-button {
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
                background-color 0.3s ease;
}

.play-button:hover {
    transform: scale(1.15);
}

.play-button i {
    transition: transform 0.3s ease;
}

.play-button:hover i {
    transform: translateX(2px);
}

/* ============================================
   CALENDAR INTERACTIONS
   ============================================ */
.calendar-day {
    transition: background-color 0.2s ease,
                transform 0.2s ease,
                color 0.2s ease;
}

.calendar-day:not(.unavailable):not(.past):hover {
    transform: scale(1.1);
}

/* ============================================
   MOBILE CTA ANIMATIONS
   ============================================ */
button.mobile-sticky-cta {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.3s ease;
}

button.mobile-sticky-cta:hover {
    box-shadow: 0 8px 24px rgba(9, 120, 108, 0.3);
    /* transform handled in main.css to preserve translateX(-50%) */
}

/* ============================================
   FOOTER ANIMATIONS
   ============================================ */
.footer-brand,
.footer-contact {
    transition: transform 0.3s ease;
}

.whatsapp-button {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                background-color 0.3s ease;
}

.whatsapp-button:hover {
    transform: translateY(-2px) scale(1.02);
}

/* ============================================
   SMOOTH SCROLL STYLES (Lenis)
   ============================================ */
html.lenis,
html.lenis body {
    height: auto;
}

.lenis.lenis-smooth {
    scroll-behavior: auto !important;
}

.lenis.lenis-smooth [data-lenis-prevent] {
    overscroll-behavior: contain;
}

.lenis.lenis-stopped {
    overflow: hidden;
}

.lenis.lenis-scrolling iframe {
    pointer-events: none;
}

/* ============================================
   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;
    }

    .page-loader {
        display: none !important;
    }

    .bento-item::before {
        display: none;
    }
}

/* ============================================
   WILL-CHANGE OPTIMIZATIONS
   ============================================ */
.hero-title,
.bento-item,
.btn-primary,
.quick-info-item {
    will-change: transform;
}

/* Remove will-change after animation completes */
body.loaded .hero-title {
    will-change: auto;
}
