/* Grain Texture Background */
        body::before {
            content: '';
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            opacity: 0.03;
            z-index: 1;
            pointer-events: none;
            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");
        }
        
        /* Smooth Scroll */
        html {
            scroll-behavior: smooth;
            cursor: none;
        }
        
        body {
            cursor: none;
            position: relative;
            overflow-x: hidden; /* Evita scroll horizontal por las piezas del caos */
            height: auto !important;
        }
        
        /* Custom Cursor - Hollow Circle */
        #custom-cursor {
            position: fixed;
            width: 40px;
            height: 40px;
            border: 2px solid #C26532;
            border-radius: 50%;
            background: transparent;
            pointer-events: none;
            z-index: 1000000;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            justify-content: center;
            font-family: 'Courier New', monospace;
            font-size: 10px;
            font-weight: bold;
            color: #C26532;
            transition: width 0.3s ease, height 0.3s ease, background-color 0.3s ease;
            margin: 0; 
            padding: 0;
            transform-origin: center; 
        }

        
        #custom-cursor.hover-image {
            width: 80px;
            height: 80px;
            background: #C26532;
            color: white;
        }
        
        #custom-cursor.hover-link {
            width: 60px;
            height: 60px;
            border-width: 3px;
        }
        
        /* CAD Grid Background */
        .cad-grid {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-image: 
                linear-gradient(rgba(87, 87, 86, 0.03) 1px, transparent 1px),
                linear-gradient(90deg, rgba(87, 87, 86, 0.03) 1px, transparent 1px);
            background-size: 50px 50px;
            pointer-events: none;
            z-index: 2;
            opacity: 0.5;
        }
        
        /* Horizontal Scroll Portfolio */
        .horizontal-scroll-wrapper {
            height: 100vh;
            overflow: hidden;
            position: relative;
        }
        
        .horizontal-scroll-container {
            display: flex;
            height: 100%;
            will-change: transform;
            transition: transform 0.1s ease-out;
        }
        
        .horizontal-scroll-item {
            min-width: 80vw;
            height: 100%;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 0 10vw;
        }
        
        /* Draggable Service Objects */
        .draggable-service {
            position: absolute;
            cursor: grab;
            transition: transform 0.3s ease, box-shadow 0.3s ease;
            user-select: none;
        }
        
        .draggable-service:active {
            cursor: grabbing;
            transform: scale(1.1);
            z-index: 1000;
        }
        
        .draggable-service.revealed {
            transform: scale(1.5);
        }
        
        /* Measurement Labels */
        .measurement-label {
            position: absolute;
            font-family: 'Courier New', monospace;
            font-size: 10px;
            color: rgba(87, 87, 86, 0.4);
            display: flex;
            align-items: center;
            gap: 5px;
        }
        
        .measurement-line {
            width: 1px;
            height: 20px;
            background: rgba(87, 87, 86, 0.3);
        }
        
        /* Conversational Form */
        .conversational-question {
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            opacity: 0;
            transform: translateY(50px);
            transition: opacity 0.8s ease, transform 0.8s ease;
        }
        
        .conversational-question.active {
            opacity: 1;
            transform: translateY(0);
        }
        
        .giant-question {
            font-size: clamp(2rem, 8vw, 6rem);
            line-height: 1.2;
            max-width: 90%;
        }
        
        /* Section Transition Effect */
        .section-transition {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: #C26532;
            z-index: 10000;
            pointer-events: none;
            opacity: 0;
            transition: opacity 0.5s ease;
        }
        
        .section-transition.active {
            opacity: 1;
        }

        
        /* Text Outline Effect */
        .text-outline {
            -webkit-text-stroke: 2px white;
            color: transparent;
            paint-order: stroke fill;
        }
        
        /* Giant Typography */
        .hero-giant {
            font-size: clamp(4rem, 15vw, 20rem);
            line-height: 0.8;
        }
        
        /* Background Text Effect */
        .bg-text {
            position: absolute;
            font-size: clamp(8rem, 20vw, 30rem);
            font-weight: 900;
            color: rgba(87, 87, 86, 0.070);
            white-space: nowrap;
            pointer-events: none;
            user-select: none;
        }
        
        /* Before/After Slider */
        .comparison-slider {
            position: relative;
            overflow: hidden;
        }
        
        .comparison-slider img {
            display: block;
            width: 100%;
            height: 100%;
            object-fit: cover;
        }
        
        .comparison-slider .after-image {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            clip-path: inset(0 50% 0 0);
        }
        
        .comparison-slider .slider-line {
            position: absolute;
            top: 0;
            left: 50%;
            width: 3px;
            height: 100%;
            background: #C26532;
            transform: translateX(-50%);
            z-index: 10;
            cursor: ew-resize;
        }
        
        .comparison-slider .slider-handle {
            position: absolute;
            top: 50%;
            left: 50%;
            width: 60px;
            height: 60px;
            background: #C26532;
            border: 4px solid white;
            border-radius: 50%;
            transform: translate(-50%, -50%);
            cursor: ew-resize;
            display: flex;
            align-items: center;
            justify-content: center;
            box-shadow: 0 4px 20px rgba(0,0,0,0.3);
        }
        
        .comparison-slider input[type="range"] {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            opacity: 0;
            cursor: ew-resize;
            z-index: 20;
        }
        
        /* Technical Lines */
        .tech-line {
            position: absolute;
            width: 100%;
            height: 1px;
            background: rgba(87, 87, 86, 0.1);
            left: 0;
        }
        
        /* Bento Grid */
        .bento-grid {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 2rem;
        }
        
        .bento-item-large {
            grid-column: span 2;
        }
        
        @media (max-width: 768px) {
            .bento-grid {
                grid-template-columns: 1fr;
            }
            .bento-item-large {
                grid-column: span 1;
            }
            html, body {
                cursor: auto;
            }
            #custom-cursor {
                display: none;
            }
        }

/* Este modo hace que lo que es oscuro en la imagen sea reemplazado por el video,
   y lo que es blanco o transparente se mantenga blanco */
.mix-blend-screen {
    mix-blend-mode: screen;
    background-color: white; /* Obligatorio */
}

/* Si quieres que el logo crezca un poco al cargar para dar impacto */
.mix-blend-screen img {
    animation: logoReveal 1.5s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes logoReveal {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Textura de ruido editorial */
body::before {
    content: "";
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: url('https://grainy-gradients.vercel.app/noise.svg');
    opacity: 0.05;
    pointer-events: none;
    z-index: 9999;
}

/* Tipografía de fondo gigante que se mueve lento */
.bg-text-giant {
    position: absolute;
    font-size: 30vw;
    font-weight: 900;
    color: rgba(0,0,0,0.03);
    white-space: nowrap;
    z-index: -1;
    pointer-events: none;
    user-select: none;
}

.hidden-step {
    display: none;
}
.active-step {
    display: block;
    position: relative;
}

/* Efecto de glitch al pasar el mouse por los inputs */
input:focus {
    box-shadow: -5px 0px 0px #C26532;
    padding-left: 25px;
}

/* Asegura que los pasos ocultos no ocupen espacio ni bloqueen clics */
.hidden-step {
    display: none !important;
}

/* Limpieza de flujo para el Brief */
.brief-step {
    display: none; /* Por defecto todos ocultos */
    opacity: 0;
    width: 100%;
    position: relative; /* Cambiamos a relative para que el contenedor respire */
    z-index: 1;
}

.brief-step.active-step {
    display: block !important;
    opacity: 1;
    z-index: 10;
}

/* Visualización de los botones seleccionados */
input[type="radio"]:checked + div {
    border-color: #C26532 !important; /* Terracota */
    background-color: rgba(194, 101, 50, 0.1) !important;
}

/* Asegurar que el botón continuar siempre esté arriba de todo */
#brief-next, #step-num-container {
    z-index: 50;
    position: relative;
}

/* Animación de pulso técnico para el botón */
@keyframes glitch-button {
    0% { clip-path: inset(0 0 0 0); }
    20% { clip-path: inset(10% -6px 80% 0); }
    40% { clip-path: inset(50% 0 30% 0); }
    60% { clip-path: inset(80% 0 10% 0); }
    100% { clip-path: inset(0 0 0 0); }
}

.group:hover .relative {
    animation: glitch-button 0.3s infinite;
}

/* Navbar Glassmorphism Caótico */
#navbar.scrolled {
    background: rgba(87, 87, 86, 0.05); /* Casi transparente */
    backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid rgba(194, 101, 50, 0.2);
}

/* Elimina el cursor de mano en todo el sitio */
a, button, input, select, textarea, .cursor-pointer {
    cursor: none !important;
}

/* Forzamos que incluso el cuerpo del documento no tenga puntero */
body {
    cursor: none;
}

/* Estilo para cuando el cursor está sobre un link (Caos Controlado) */
#custom-cursor.hover-active {
    width: 70px;
    height: 70px;
    background: rgba(194, 101, 50, 0.9); /* Terracota sólido */
    border-color: white;
    color: white !important; /* Forzamos color de texto blanco */
}



@keyframes glitch-load {
    0% { transform: translate(0); }
    20% { transform: translate(-5px, 5px); }
    40% { transform: translate(-5px, -5px); }
    60% { transform: translate(5px, 5px); }
    80% { transform: translate(5px, -5px); }
    100% { transform: translate(0); }
}

.glitch-active {
    animation: glitch-load 0.2s infinite;
}

#preloader {
    transition: clip-path 1s cubic-bezier(0.87, 0, 0.13, 1);
    clip-path: inset(0 0 0 0);
}

#preloader.loaded {
    clip-path: inset(0 0 100% 0); /* El loader se "encoge" hacia arriba de forma técnica */
}

#service-overlay {
    transition: all 0.5s cubic-bezier(0.19, 1, 0.22, 1);
    height: calc(var(--vh, 1vh) * 100);
}

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

#service-overlay.hidden {
    display: none !important;
}

.service-card:active {
    transform: scale(0.98);
}

#frag-data {
    /* Hacemos que la caja de datos parezca una pieza de hardware */
    clip-path: polygon(0 0, 100% 0, 100% 90%, 90% 100%, 0 100%);
}

#frag-title {
    /* Inclinación leve para romper la ortogonalidad */
    transform: skewX(-5deg);
    z-index: 500;
}

#overlay-img {
    filter: brightness(1.1) contrast(1.1); /* Mejora la nitidez visual */
    image-rendering: -webkit-optimize-contrast; /* Para Mac/Safari */
    pointer-events: auto;
    z-index: 50;
    max-width: 90%;
    max-height: 85%;
}

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

/* Capa para el efecto Flash */
#flash-effect {
    position: fixed;
    inset: 0;
    background: white;
    z-index: 20000;
    pointer-events: none;
    opacity: 0;
}

/* Forzar que las piezas no se desborden */
#frag-data {
    max-height: 80vh;
    overflow-y: auto;
    /* Evita que GSAP acumule desplazamientos extraños */
    transform: none !important; 
}

#frag-visual {
    background: radial-gradient(circle, rgba(10,14,18,0.8) 0%, rgba(10,14,18,1) 100%);
}

/* Glitch de la Galería - No afecta al Loader */
@keyframes gallery-glitch {
    0% { transform: translate(0); filter: hue-rotate(0deg); }
    10% { transform: translate(-5px, 2px) skewX(5deg); filter: saturate(2) contrast(1.5); }
    30% { transform: translate(5px, -2px); clip-path: inset(10% 0 15% 0); }
    50% { transform: translate(-8px, 0) scaleY(1.05); filter: invert(0.5); }
    70% { transform: translate(2px, 5px); clip-path: inset(40% 0 10% 0); }
    100% { transform: translate(0); filter: hue-rotate(0deg); clip-path: inset(0 0 0 0); }
}

.img-glitch-effect {
    animation: gallery-glitch 0.2s steps(2) both;
}

/* El Flash de cierre (se crea dinámicamente) */
.system-flash {
    position: fixed;
    inset: 0;
    background: white;
    z-index: 20000;
    pointer-events: none;
    opacity: 0;
}

/* AJUSTES PARA CELULAR (MÓVIL) */
@media (max-width: 768px) {
    /* 1. El título se vuelve más pequeño y se mueve arriba */
    #frag-title {
        top: 20px !important;
        left: 20px !important;
        right: 20px !important;
        padding: 15px !important;
        transform: skewX(-3deg);
    }
    #frag-title h2 {
        font-size: 2rem !important; /* Reducimos el tamaño para que no tape todo */
    }

    /* 2. El visual (Galería) toma el centro con más altura */
    #frag-visual {
        width: 100vw !important;
        height: 50vh !important;
        margin-top: 40px;
    }

    /* 3. La caja de datos se mueve al fondo y se vuelve compacta */
    #frag-data {
        position: relative !important;
        bottom: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-width: none !important;
        margin-top: -20px; /* Traslape intencional para el estilo industrial */
        padding: 20px !important;
        box-shadow: none !important;
        border-right: none !important;
        border-left: none !important;
        z-index: 100 !important;
        pointer-events: auto !important; /* Permite clics */
    }

    #frag-data p {
        font-size: 0.9rem !important;
        line-height: 1.2 !important;
    }



    /* 4. Los botones de la galería deben ser fáciles de tocar (UX) */
    .gallery-controls {
        width: 100%;
        justify-content: center;
        bottom: 10px !important;
    }

    /* Permitir scroll interno en el overlay si el contenido es largo */
    #service-overlay {
        flex-direction: column !important;
        justify-content: flex-start !important;
        overflow-y: auto !important;
        padding-top: 20px;
    }

    /* Los botones específicos dentro de la data */
    #frag-data button, 
    #frag-data a {
        position: relative;
        z-index: 110 !important;
        pointer-events: auto !important;
        cursor: pointer !important; /* Forzamos el cursor por si el custom-cursor falla aquí */
    }

    /* Evita que el visual "tape" los controles si se escala */
    #frag-visual {
        z-index: 10 !important;
        pointer-events: none !important; /* La caja visual NO debe recibir clics... */
    }

    /* ...PERO las imágenes y botones internos de la galería SÍ deben recibirlos */
    #gallery-container, 
    .gallery-controls {
        pointer-events: auto !important;
    }

    /* Fuerza al overlay a estar arriba de todo */
    #video-intro-overlay {
        z-index: 99999 !important;
        background-color: #000000 !important; /* Fondo negro puro */
    }

    /* Contenedor del video */
    .video-container-wrapper {
        position: relative;
        width: 90vw;
        max-width: 800px;
        aspect-ratio: 16 / 9;
        background: #000;
        overflow: visible !important; /* Permite ver el botón de omitir */
        display: block !important;
    }

    /* El div donde se inyecta el iframe */
    #vimeo-player {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 10;
    }

    #video-intro-overlay.flex {
        display: flex !important;
        opacity: 1 !important;
    }

    #vimeo-player iframe {
        width: 100% !important;
        height: 100% !important;
        border: none;
    }

    /* Asegurar que el botón siempre esté sobre el video */
    .btn-skip {
        pointer-events: auto !important;
        position: absolute;
        opacity: 1 !important;
        visibility: visible !important;
        top: 200px!important;
        right: 100px!important;
        z-index: 99998!important;
    }

    @media (max-width: 768px) {
        .video-container-wrapper {
            width: 100vw; /* Ocupa todo el ancho en cel */
            height: auto;
            aspect-ratio: 16 / 9;
            max-height: 50vh; /* Para que no tape toda la pantalla verticalmente */
        }
        
        .btn-skip {
        pointer-events: auto !important;
        position: absolute;
        opacity: 1 !important;
        visibility: visible !important;
        top: 16px!important;
        right: 100px!important;
        z-index: 99998!important;
        }
    }
}