.galeria_projects{
    position: relative;
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    width: 100%;
    height: 100vh;
}

/* 1. ENTRADA desde arriba - cuando aparece por primera vez */
.galeria_projects.sticky-inactive {
    opacity: 0;
    transform: translateY(30px);
    pointer-events: none;
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 2. ESTADO ACTIVO - cuando está sticky */
.galeria_projects.sticky-active {
    position: fixed;
    top: var(--header-height, 80px);
    left: 0;
    z-index: 10;
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 3. SALIDA hacia arriba - cuando se va al final (hacia fotos_piezas) */
.galeria_projects.sticky-bottom {
    position: fixed;
    top: var(--header-height, 80px);
    left: 0;
    z-index: 10;
    opacity: 0;
    transform: translateY(-60px);
    pointer-events: none;
    transition: opacity 1s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 1s cubic-bezier(0.4, 0, 0.2, 1);
}
    .galeria_projects.sticky-bottom {
        position: relative;
        opacity: 0;
        transform: translateY(-60px);
        pointer-events: none;
        z-index: 0;
        transition: opacity 1s cubic-bezier(0.4, 0, 0.2, 1), 
                    transform 1s cubic-bezier(0.4, 0, 0.2, 1);
    }

/* 4. ENTRADA desde abajo - cuando vuelve desde fotos_piezas (scroll inverso) */
.galeria_projects.sticky-bottom-reverse {
    position: fixed;
    top: var(--header-height, 80px);
    left: 0;
    z-index: 10;
    opacity: 0;
    transform: translateY(40px);
    pointer-events: none;
    transition: opacity 0.7s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 0.7s cubic-bezier(0.4, 0, 0.2, 1);
}
    .galeria_projects.sticky-inactive {
        position: relative;
        opacity: 0;
        transform: translateY(30px);
        pointer-events: none;
        z-index: 0;
        transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1), 
                    transform 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    }

.machines-scroll-sections {
    height: 500vh;
    width: 100%;
    position: relative;
    margin: 0;
    padding: 0;
}

.scroll-section {
    height: 100vh;
    width: 100%;
    margin: 0;
    padding: 0;
}

.maquinas_info{
    width: 100%;
    height: 50dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 5%;
}

.title_galeria_projects{
    display: flex;
    align-items: center;
    justify-content: center;
}

.title_galeria_projects h2{
    width: auto;
    min-width: -webkit-fill-available;
    font-weight: 300;
    font-size: clamp(1.5rem, 3vw, 7rem);
    margin-bottom: 0.5rem;
    color: var(--white);
    background-image: linear-gradient(45deg, var(--white) 15%, var(--grey) 82%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.title_galeria_projects model-viewer{
    display: flex;
    align-items: center;
    justify-content: center;
    width: 70px;
    height: 70px;
    border-radius: 10px;
    border: 1px solid var(--grey);
    background-color: var(--dark-grey);
    transition: all 0.4s ease;
    flex-shrink: 0;
}

#title_galeria{
    display: flex;
    align-items: end;
    justify-content: end;
    border-right: 1px solid var(--grey);
    border-bottom: 1px solid var(--grey);
}

#btn_galeria{
    display: flex;
    align-items: end;
    justify-content: start;
    border-left: 1px solid var(--grey);
    border-bottom: 1px solid var(--grey);
}

#btn_galeria .btn{
    width: 30%;
}

#desc_galeria{
    display: flex;
    align-items: start;
    justify-content: start;
    border-left: 1px solid var(--grey);
    border-top: 1px solid var(--grey);
}

#desc_galeria p{
    font-size: 1.5rem;
    font-weight: 300;
    transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    line-height: 1.6;
}

/* Estilos para spans resaltados en las descripciones */
#desc_galeria p span {
    color: var(--primary-color);
    font-weight: 500;
    position: relative;
    transition: all 0.3s ease;
}

#desc_galeria p span:hover {
    color: var(--secondary-color);
    text-shadow: 0 0 8px rgba(125, 14, 223, 0.4);
}

/* Efecto sutil de subrayado animado para los spans */
#desc_galeria p span::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 1px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    transition: width 0.3s ease;
}

#desc_galeria p span:hover::after {
    width: 100%;
}

/* Mejorar la transición del texto completo */
#machine-description {
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

#machine-description.changing {
    opacity: 0;
    transform: translateY(15px);
}

#machine-title,
#machine-description {
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

#machine-title.changing,
#machine-description.changing {
    opacity: 0;
    transform: translateY(20px);
}

#machine-title {
    white-space: nowrap;
    line-height: 1.2;
    margin: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Ajustar el contenedor para que se adapte al contenido */
.title_galeria_projects {
    white-space: nowrap;
    display: flex;
    align-items: end;
    justify-content: end;
    flex-wrap: nowrap;
}

/* Asegurar que el contenido después de las máquinas aparezca correctamente */
.machines-scroll-sections + * {
    position: relative;
    z-index: 1;
}

.galeria_projects {
    position: relative;
    overflow: hidden;
}

/* Canvas para el fondo animado wave */
.galeria_projects::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -2;
    pointer-events: none;
    background: var(--black);
}

#waveCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    pointer-events: none;
    background: transparent;
}

/* ==========================================
   RESPONSIVE DESIGN
   ========================================== */

/* TABLET (768px - 1200px) */
@media screen and (max-width: 1200px) {
    .galeria_projects {
        grid-template-columns: 1fr;
        grid-template-rows: 20vh 40vh 20vh; /* Título, descripción, botón */
        height: 100vh;
    }

    .maquinas_info {
        padding: 1%;
    }

    /* Título más grande y espacio */
    #title_galeria {
        height: 20vh;
        align-items: center;
        justify-content: center;
        border: none;
        text-align: center;
    }

    .title_galeria_projects {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 1rem;
        text-align: center;
    }

    .title_galeria_projects h2 {
        font-size: clamp(2.5rem, 5vw, 4rem); /* Más grande */
        white-space: normal;
        line-height: 1.1;
        margin-bottom: 0;
        text-align: center;
    }

    .title_galeria_projects model-viewer {
        width: 60px;
        height: 60px;
    }

    /* Descripción con más espacio */
    #desc_galeria {
        height: 40vh;
        align-items: center;
        justify-content: center;
        border: none;
        text-align: center;
        order: 2; /* Descripción en segundo lugar */
    }

    #desc_galeria p {
        font-size: 1.4rem;
        line-height: 1.4;
        text-align: center;
        padding: 0 1rem;
    }

    /* Botón con menos espacio */
    #btn_galeria {
        height: 20vh;
        align-items: center;
        justify-content: center;
        border: none;
        order: 3; /* Botón al final */
    }

    #btn_galeria .btn {
        width: 25%;
        padding: 0.6rem 1rem;
    }

    #empty_galeria {
        display: none;
    }
}

/* MÓVIL GRANDE (481px - 767px) */
@media screen and (max-width: 767px) {
    .galeria_projects {
        grid-template-columns: 1fr;
        grid-template-rows: 20vh 50vh 10vh; /* Título más grande, descripción, botón pequeño */
        height: 100vh;
    }

    .maquinas_info {
        padding: 0.5%;
    }

    /* Título con más espacio */
    #title_galeria {
        height: 20vh;
    }

    .title_galeria_projects {
        gap: 0.5rem;
    }

    .title_galeria_projects h2 {
        font-size: clamp(2.2rem, 6vw, 3.5rem); /* Más grande */
        line-height: 1.1;
    }

    .title_galeria_projects model-viewer {
        width: 55px;
        height: 55px;
    }

    /* Descripción con espacio moderado */
    #desc_galeria {
        height: 40vh;
        order: 2;
    }

    #desc_galeria p {
        font-size: 1.3rem; /* Más grande */
        line-height: 1.3;
        padding: 0;
        width: 75%;
        margin: 0 auto;
    }

    /* Botón compacto */
    #btn_galeria {
        height: 15vh;
        order: 3;
    }

    #btn_galeria .btn {
        width: 35%;
        padding: 0.5rem 0.8rem;
    }

    #empty_galeria {
        display: none;
    }

    .galeria_projects.sticky-active {
        top: var(--header-height, 70px);
    }

    .galeria_projects.sticky-bottom {
        top: var(--header-height, 70px);
    }

    .galeria_projects.sticky-bottom-reverse {
        top: var(--header-height, 70px);
    }
}

/* MÓVIL PEQUEÑO (hasta 480px) */
@media screen and (max-width: 480px) {
    .galeria_projects {
        grid-template-columns: 1fr;
        grid-template-rows: 20vh 50vh 10vh; /* Título muy grande, descripción, botón pequeño */
        height: 100vh;
    }

    .maquinas_info {
        padding: 0.3%;
    }

    /* Título con mucho espacio */
    #title_galeria {
        height: 20vh;
    }

    .title_galeria_projects {
        gap: 0.4rem;
    }

    .title_galeria_projects h2 {
        font-size: clamp(2rem, 7vw, 3rem); /* Más grande */
        line-height: 1;
        margin: 0;
    }

    .title_galeria_projects model-viewer {
        width: 50px;
        height: 50px;
        border-radius: 8px;
    }

    /* Descripción compacta pero legible */
    #desc_galeria {
        height: 40vh;
        order: 2;
    }

    #desc_galeria p {
        font-size: 1.2rem; /* Más grande */
        line-height: 1.2;
        padding: 0;
        width: 70%;
        margin: 0 auto;
    }

    /* Botón muy compacto */
    #btn_galeria {
        height: 15vh;
        order: 3;
    }

    #btn_galeria .btn {
        width: 40%;
        padding: 0.5rem 0.7rem;
    }

    #empty_galeria {
        display: none;
    }

    .galeria_projects.sticky-active {
        top: var(--header-height, 60px);
    }

    .galeria_projects.sticky-bottom {
        top: var(--header-height, 60px);
    }

    .galeria_projects.sticky-bottom-reverse {
        top: var(--header-height, 60px);
    }

    #desc_galeria p span:hover {
        color: var(--primary-color);
        text-shadow: none;
    }

    #desc_galeria p span:hover::after {
        width: 0;
    }
}

/* MÓVIL MUY PEQUEÑO (hasta 360px) */
@media screen and (max-width: 360px) {
    .galeria_projects {
        grid-template-rows: 25vh 50vh 10vh; /* Título dominante, descripción mínima, botón pequeño */
    }

    .maquinas_info {
        padding: 0.2%;
    }

    /* Título dominante */
    #title_galeria {
        height: 25vh;
    }

    .title_galeria_projects {
        gap: 0.3rem;
    }

    .title_galeria_projects h2 {
        font-size: clamp(1.8rem, 8vw, 2.5rem); /* Más grande */
    }

    .title_galeria_projects model-viewer {
        width: 45px;
        height: 45px;
    }

    /* Descripción mínima */
    #desc_galeria {
        height: 30vh;
    }

    #desc_galeria p {
        font-size: 1.1rem;
        line-height: 1.1;
        padding: 0;
        width: 70%;
        margin: 0 auto;
    }

    /* Botón pequeño */
    #btn_galeria {
        height: 15vh;
    }

    #btn_galeria .btn {
        width: 45%;
        padding: 0.4rem 0.6rem;
    }

    .machines-scroll-sections {
        height: 400vh;
    }
}