.hero-header {
    position: relative;
    overflow: hidden;
    max-height: 1000px;
}

.hero-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
}

.hero-content {
    position: relative;
    z-index: 1;
    height: 100%;
    color: #fff;
    top: 23%;
    align-items: flex-start;

    width: 100%;
}



.imagenes {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}



.imagen-item {
    text-align: center;
    transition: transform 0.3s ease, filter 0.3s ease;
    cursor: pointer;
}

.imagen-contenedor {
    position: relative;
    overflow: hidden;
    border-radius: 15px;
    transition: all 0.4s ease;
}

.imagen-contenedor::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg,
            rgba(255, 255, 255, 0.15) 0%,
            rgba(255, 255, 255, 0.05) 50%,
            rgba(0, 0, 0, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
    pointer-events: none;
}

.imagen-contenedor:hover::before {
    opacity: 1;
}

.imagen-contenedor:hover {
    transform: scale(1.05);
    box-shadow:
        0 16px 48px rgba(0, 0, 0, 0.4),
        0 8px 24px rgba(0, 0, 0, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.3);
}


.imagen-contenedor:hover img {
    transform: scale(1.1);
    filter: brightness(1.1) contrast(1.1) saturate(1.2);
}

.imagen-texto {
    margin-top: 15px;

}


.imagen-item:hover .imagen-texto::after {
    width: 100%;
}

.imagen-item:hover .imagen-texto {
    transform: translateY(-2px);
    color: #f0f0f0;
    text-shadow: 0 4px 12px rgba(0, 0, 0, 0.7);
}

.imagen-contenedor::after {
    content: '';
    position: absolute;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg,
            transparent 30%,
            rgba(255, 255, 255, 0.1) 50%,
            transparent 70%);
    transform: rotate(45deg) translate(-100%, -100%);
    transition: transform 0.6s ease;
    pointer-events: none;
    z-index: 2;
}

.imagen-contenedor:hover::after {
    transform: rotate(45deg) translate(100%, 100%);
}

/* Animation for transitions */
.imagenes-carrusel.animating .imagen-item {
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

.imagenes-carrusel .imagen-item {
    opacity: 1;
    transition: opacity 0.5s ease-in-out;
}

#first-specialty-link {
    text-decoration: none;
    color: inherit;
    transition: all 0.3s ease;
}

#first-specialty-link:hover {
    transform: translateX(5px);
}

.linea-texto-flecha {
    display: flex;
    align-items: center;
    flex-grow: 1;
    /* Permite que ocupe el espacio restante en la fila */
    min-width: calc(40% * 2 / 6);
    /* Garantiza un ancho mínimo para visibilidad */
}

.linea-horizontal {
    flex-grow: 1;
    /* Se expande dentro de .linea-texto-flecha */
    height: 2px;
    background: linear-gradient(90deg, #fff, rgba(255, 255, 255, 0.3));
    margin-right: 20px;
}

.texto-flecha-contenedor {
    gap: 15px;
}

.texto-flecha {
    font-weight: 500;
    letter-spacing: 1px;
    color: #fff;
}

.texto-flecha::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 0;
    height: 2px;
    background: #fff;
    transition: width 0.3s ease;
}

#first-specialty-link:hover .texto-flecha::after {
    width: 100%;
}

.flecha-imagen {
    width: 24px;
    height: 24px;
    transition: transform 0.3s ease;
    filter: brightness(0) invert(1);
}

#first-specialty-link:hover .flecha-imagen {
    transform: translateX(5px);
}

.hero-background {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.5s ease;
    z-index: 0;
}

.btn-volver {
    transition: all 0.3s ease;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 3;
}

.btn-volver::before {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-top: 12px solid transparent;
    border-bottom: 12px solid transparent;
    border-right: 18px solid #fff;
}

.btn-volver:hover::before {
    border-right-color: #ccc;
    transform: translateX(-3px);
}

.btn-volver:hover {
    transform: scale(1.1);
}

/* Animaciones para las tarjetas de especialidades */
.grid-especialidades .card {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(0);
}

.grid-especialidades .card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.grid-especialidades .card .card-img-top::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(243, 176, 64, 0.1);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.grid-especialidades .card:hover .card-img-top::after {
    opacity: 1;
}

@media (max-width: 1440.98px) {
    .hero-header {
        position: relative;
        overflow: hidden;

        max-height: 1200px;
    }

    .hero-content {
        top: 10%;
    }

    .encabezado {
        margin-top: 50px;
    }
}

@media (max-width: 767.98px) {
    .hero-header {
        height: auto;
    }

    .hero-content {
        top: 0;
        left: 0;
        padding-top: 20px;
        padding-left: 15px;
        padding-right: 15px;
    }

    .encabezado {
        margin-top: 0;
    }

    .imagen-item {
        margin-bottom: 20px;
    }

    .imagen-contenedor img {
        max-height: 200px;
        width: 100%;
        object-fit: cover;
    }

}