@import url('https://fonts.googleapis.com/css2?family=Inter:wght@200;300;400;500;600;700&family=Playfair+Display:ital,wght@0,400;0,500;0,600;1,400;1,500&display=swap');

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Hide scrollbar amb millor suport */
::-webkit-scrollbar {
    width: 0px;
    background: transparent;
}

body {
    -ms-overflow-style: none;
    scrollbar-width: none;
    text-rendering: optimizeLegibility;
}

/* Background Grids millorat */
.grid-background {
    background-image: 
        linear-gradient(to right, rgba(0,0,0,0.03) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(0,0,0,0.03) 1px, transparent 1px);
    background-size: 80px 80px;
    background-position: center center;
}

.dark .grid-background {
    background-image: 
        linear-gradient(to right, rgba(255,255,255,0.03) 1px, transparent 1px),
        linear-gradient(to bottom, rgba(255,255,255,0.03) 1px, transparent 1px);
}

/* Gradient radial personalitzat */
.bg-gradient-radial {
    background: radial-gradient(circle at center, var(--tw-gradient-stops));
}

/* Noise texture millorat */
.noise-bg {
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E");
    background-size: 150px;
    opacity: 0.5;
}

/* Animacions principals millorades */
@keyframes fadeInUp {
    0% {
        opacity: 0;
        transform: translateY(40px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

@keyframes slideInRight {
    0% {
        opacity: 0;
        transform: translateX(-40px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-30px);
    }
}

@keyframes glowPulse {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.1);
    }
}

/* Classes d'animació */
.fade-in-up {
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp 1s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.fade-in {
    opacity: 0;
    animation: fadeIn 1.2s ease-out forwards;
}

.slide-in-right {
    opacity: 0;
    transform: translateX(-30px);
    animation: slideInRight 1s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* Delay classes millorats */
.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }
.delay-400 { animation-delay: 0.4s; }
.delay-500 { animation-delay: 0.5s; }
.delay-600 { animation-delay: 0.6s; }
.delay-700 { animation-delay: 0.7s; }
.delay-800 { animation-delay: 0.8s; }

/* Scroll Animation Classes millorat */
.fade-in-section {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 1s cubic-bezier(0.22, 1, 0.36, 1), 
                transform 1s cubic-bezier(0.22, 1, 0.36, 1);
}

.fade-in-section.is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Hover effects millorats */
.hover-lift {
    transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1),
                box-shadow 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.hover-lift:hover {
    transform: translateY(-8px);
}

/* Mobile menu animation */
.mobile-link {
    transition: opacity 0.5s cubic-bezier(0.22, 1, 0.36, 1),
                transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

#mobile-menu.flex .mobile-link {
    opacity: 0.7;
    transform: translateY(0);
}

#mobile-menu.flex .mobile-link:hover {
    opacity: 1;
}

#mobile-menu.flex .mobile-link:nth-child(1) { animation: slideInRight 0.5s 0.1s cubic-bezier(0.22, 1, 0.36, 1) forwards; }
#mobile-menu.flex .mobile-link:nth-child(2) { animation: slideInRight 0.5s 0.2s cubic-bezier(0.22, 1, 0.36, 1) forwards; }
#mobile-menu.flex .mobile-link:nth-child(3) { animation: slideInRight 0.5s 0.3s cubic-bezier(0.22, 1, 0.36, 1) forwards; }
#mobile-menu.flex .mobile-link:nth-child(4) { animation: slideInRight 0.5s 0.4s cubic-bezier(0.22, 1, 0.36, 1) forwards; }

/* Smooth transitions globals */
* {
    transition-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
}

/* Text selection styling */
::selection {
    background-color: rgba(0, 0, 0, 0.2);
    color: inherit;
}

.dark ::selection {
    background-color: rgba(255, 255, 255, 0.2);
    color: inherit;
}

/* Focus states millorats */
a:focus,
button:focus {
    outline: 2px solid currentColor;
    outline-offset: 4px;
    border-radius: 4px;
}

/* Image optimization */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Prevent layout shift */
.aspect-ratio-16-10 {
    aspect-ratio: 16 / 10;
}

/* Custom cursor (opcional) */
@media (pointer: fine) {
    body {
        cursor: default;
    }
    
    a, button {
        cursor: pointer;
    }
}

/* Performance optimizations */
.will-change-transform {
    will-change: transform;
}

.will-change-opacity {
    will-change: opacity;
}

/* Reduced motion support */
@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;
    }
    
    .fade-in-section {
        opacity: 1;
        transform: none;
    }
    
    .fade-in-up {
        opacity: 1;
        transform: none;
    }
}

/* Print styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
}

/* Dark mode improvements */
.dark {
    color-scheme: dark;
}

/* Backdrop blur fallback */
@supports not (backdrop-filter: blur(10px)) {
    .backdrop-blur-md,
    .backdrop-blur-xl {
        background-color: rgba(0, 0, 0, 0.8);
    }
    
    .dark .backdrop-blur-md,
    .dark .backdrop-blur-xl {
        background-color: rgba(255, 255, 255, 0.1);
    }
}