/* ============================================
   GALARY EDGE - Premium 3D Effects & Animations
   Enhanced CSS for Interactive Experience
   ============================================ */

/* ============================================
   RESPECT MOTION PREFERENCES
   ============================================ */
@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-container,
    .about-card-3d,
    .fade-in-up,
    .parallax-layer {
        transform: none !important;
        animation: none !important;
    }
}

/* ============================================
   3D HERO BACKGROUND PARALLAX EFFECT
   ============================================ */

/* Hero container with 3D perspective */
.hero-3d-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    perspective: 1000px;
    transform-style: preserve-3d;
}

/* Background layer with parallax */
.hero-background-layer {
    position: absolute;
    top: -10%;
    left: -10%;
    width: 120%;
    height: 120%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    will-change: transform;
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform-origin: center center;
    backface-visibility: hidden;
}

/* Ambient shadow overlay that follows cursor */
.hero-ambient-shadow {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
    background: radial-gradient(
        circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
        rgba(201, 169, 97, 0.15) 0%,
        rgba(0, 0, 0, 0.3) 40%,
        rgba(0, 0, 0, 0.6) 100%
    );
    mix-blend-mode: multiply;
    z-index: 2;
}

.hero:hover .hero-ambient-shadow {
    opacity: 1;
}

/* Light shift effect */
.hero-light-shift {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.5s ease;
    background: radial-gradient(
        circle at var(--mouse-x, 50%) var(--mouse-y, 50%),
        rgba(255, 255, 255, 0.08) 0%,
        rgba(255, 255, 255, 0.03) 30%,
        transparent 60%
    );
    z-index: 3;
}

.hero:hover .hero-light-shift {
    opacity: 1;
}

/* Enhanced hero content with proper z-index */
.hero .hero-content {
    position: relative;
    z-index: 10;
    will-change: transform;
    transition: transform 0.3s ease-out;
}

/* Depth particles for enhanced 3D feel */
.hero-particles {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
    opacity: 0.3;
}

.particle {
    position: absolute;
    width: 2px;
    height: 2px;
    background: rgba(201, 169, 97, 0.6);
    border-radius: 50%;
    animation: float-particle 20s infinite ease-in-out;
}

@keyframes float-particle {
    0%, 100% {
        transform: translate(0, 0) scale(1);
        opacity: 0;
    }
    10% {
        opacity: 0.6;
    }
    50% {
        transform: translate(var(--drift-x, 50px), var(--drift-y, -100px)) scale(1.5);
        opacity: 0.3;
    }
    90% {
        opacity: 0.6;
    }
}

/* ============================================
   ABOUT SECTION 3D ANIMATIONS
   ============================================ */

/* Base state for fade-in elements */
.fade-in-up {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Active state when in viewport */
.fade-in-up.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Stagger delays for child elements */
.fade-in-up:nth-child(1) { transition-delay: 0.1s; }
.fade-in-up:nth-child(2) { transition-delay: 0.2s; }
.fade-in-up:nth-child(3) { transition-delay: 0.3s; }
.fade-in-up:nth-child(4) { transition-delay: 0.4s; }
.fade-in-up:nth-child(5) { transition-delay: 0.5s; }
.fade-in-up:nth-child(6) { transition-delay: 0.6s; }

/* 3D Card Container */
.about-card-3d {
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
}

/* 3D Card Hover Effects */
.about-card-3d:hover {
    transform: translateY(-10px) rotateX(5deg) rotateY(2deg);
}

.about-card-3d::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(
        135deg,
        rgba(201, 169, 97, 0.1) 0%,
        rgba(201, 169, 97, 0.05) 50%,
        transparent 100%
    );
    opacity: 0;
    transition: opacity 0.5s ease;
    pointer-events: none;
    z-index: 1;
}

.about-card-3d:hover::before {
    opacity: 1;
}

/* Card shadow enhancement */
.about-card-3d::after {
    content: '';
    position: absolute;
    bottom: -20px;
    left: 50%;
    transform: translateX(-50%);
    width: 80%;
    height: 20px;
    background: radial-gradient(
        ellipse at center,
        rgba(0, 0, 0, 0.3) 0%,
        transparent 70%
    );
    opacity: 0;
    transition: opacity 0.5s ease, transform 0.5s ease;
    z-index: -1;
}

.about-card-3d:hover::after {
    opacity: 1;
    transform: translateX(-50%) translateY(5px);
}

/* 3D Tilt effect for images */
.about-image-3d {
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.about-image-3d:hover {
    transform: scale(1.05) rotateY(5deg) rotateX(-5deg);
}

/* Shine effect on hover */
.about-card-3d .shine-effect {
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.2) 50%,
        transparent 100%
    );
    transition: left 0.7s ease;
    pointer-events: none;
    z-index: 2;
}

.about-card-3d:hover .shine-effect {
    left: 100%;
}

/* ============================================
   SECTION REVEAL ANIMATIONS
   ============================================ */

/* Slide from left */
.slide-in-left {
    opacity: 0;
    transform: translateX(-60px);
    transition: opacity 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.slide-in-left.is-visible {
    opacity: 1;
    transform: translateX(0);
}

/* Slide from right */
.slide-in-right {
    opacity: 0;
    transform: translateX(60px);
    transition: opacity 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                transform 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.slide-in-right.is-visible {
    opacity: 1;
    transform: translateX(0);
}

/* Scale animation */
.scale-in {
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.8s cubic-bezier(0.34, 1.56, 0.64, 1),
                transform 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.scale-in.is-visible {
    opacity: 1;
    transform: scale(1);
}

/* ============================================
   STATS COUNTER ANIMATION
   ============================================ */

.stat-number {
    display: inline-block;
    transition: transform 0.3s ease;
}

.stat-box.is-visible .stat-number {
    animation: countPulse 0.6s ease;
}

@keyframes countPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* ============================================
   SERVICES CARD ENHANCEMENTS
   ============================================ */

.service-card {
    position: relative;
    transform-style: preserve-3d;
    transition: all 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.service-card::before {
    content: '';
    position: absolute;
    inset: -2px;
    background: linear-gradient(
        135deg,
        var(--primary-gold),
        transparent,
        var(--primary-gold)
    );
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.5s ease;
    z-index: -1;
}

.service-card:hover::before {
    opacity: 0.3;
}

.service-icon {
    transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.service-card:hover .service-icon {
    transform: scale(1.15) rotateY(360deg);
}

/* ============================================
   PORTFOLIO CARD 3D EFFECTS
   ============================================ */

.portfolio-item {
    transform-style: preserve-3d;
    transition: all 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.portfolio-item:hover {
    transform: translateZ(20px) rotateX(2deg) rotateY(-2deg);
}

.portfolio-item .card-image {
    transition: transform 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform-origin: center;
}

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

/* ============================================
   BUTTON ENHANCEMENTS
   ============================================ */

.btn {
    position: relative;
    overflow: hidden;
    transform-style: preserve-3d;
}

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

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn:active {
    transform: translateY(2px) scale(0.98);
}

/* ============================================
   CURSOR INTERACTIVE GLOW
   ============================================ */

.interactive-glow {
    position: relative;
    overflow: hidden;
}

.interactive-glow::after {
    content: '';
    position: absolute;
    top: var(--mouse-y, 50%);
    left: var(--mouse-x, 50%);
    width: 200px;
    height: 200px;
    background: radial-gradient(
        circle,
        rgba(201, 169, 97, 0.2) 0%,
        transparent 70%
    );
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}

.interactive-glow:hover::after {
    opacity: 1;
}

/* ============================================
   MOBILE OPTIMIZATIONS
   ============================================ */

@media (max-width: 1024px) {
    /* Disable complex 3D effects on tablets and mobile */
    .hero-3d-container {
        perspective: none;
    }
    
    .hero-background-layer {
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        transform: none !important;
    }
    
    .hero-ambient-shadow,
    .hero-light-shift,
    .hero-particles {
        display: none;
    }
    
    .about-card-3d:hover {
        transform: translateY(-5px);
    }
    
    .about-image-3d:hover {
        transform: scale(1.03);
    }
}

@media (max-width: 768px) {
    /* Simplify animations for mobile */
    .fade-in-up,
    .slide-in-left,
    .slide-in-right,
    .scale-in {
        opacity: 1;
        transform: none;
    }
    
    .about-card-3d,
    .about-image-3d,
    .portfolio-item {
        transform: none !important;
    }
}

/* ============================================
   LOADING STATE OPTIMIZATIONS
   ============================================ */

.will-animate {
    will-change: transform, opacity;
}

.animation-complete {
    will-change: auto;
}

/* ============================================
   SMOOTH SCROLLING ENHANCEMENTS
   ============================================ */

html {
    scroll-behavior: smooth;
}

@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

/* ============================================
   ACCESSIBILITY FOCUS STATES
   ============================================ */

.btn:focus-visible,
.card:focus-visible,
.service-card:focus-visible {
    outline: 3px solid var(--primary-gold);
    outline-offset: 4px;
}

/* Ensure focus is visible but not intrusive */
*:focus {
    outline-color: var(--primary-gold);
}

*:focus:not(:focus-visible) {
    outline: none;
}