/* ======================================
   CAPACIDADES - ROMPECABEZAS (RESTAURADO)
====================================== */

#capacidades {
    font-family: 'Poppins', sans-serif;
    background-color: #ffffff;
    padding: 80px 0;
    scroll-margin-top: 90px;
}

.cap-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Subtítulo con la línea decorativa restaurada */
.section-subtitle {
    text-align: left;
    margin-bottom: 60px;
}

.section-subtitle h2 {
    font-size: clamp(150%, 4vw, 250%);
    font-weight: 800;
    color: #173E68;
    position: relative;
    display: inline-block;
}

/* La línea azul que se extiende */
.section-subtitle h2::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -10px;
    height: 4px;
    width: 50vw; /* Línea larga original */
    background-color: #2E5C88;
    border-radius: 2px;
}

.cap-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 60px;
    align-items: center;
}

.cap-text h3 {
    font-size: 28px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 20px;
}

.cap-text p {
    font-size: 17px;
    line-height: 1.8;
    color: #4b5563;
    margin-bottom: 35px;
}

.cap-btn {
    display: inline-block;
    background: #2E5C88;
    color: #ffffff;
    padding: 14px 36px;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    transition: 0.3s;
}

/* --- ESTRUCTURA PUZZLE --- */
.cap-puzzle {
    position: relative;
    width: 80%;
    max-width: 500px;
    aspect-ratio: 1/1;
    margin: 0 auto;
    transition: 0.35s ease;
}

.cap-piece {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    cursor: pointer;
    border-radius: 16px;
    padding: 15px;
    /* Transición suave para el efecto de expansión */
    transition: all 0.5s cubic-bezier(0.2, 1, 0.3, 1);
}

/* Posiciones y Colores Desktop */
.cap-piece.ai { top: 0; left: 0; width: 48%; height: 48%; background: #173E68; color: white; }
.cap-piece.analytics { top: 0; right: 0; width: 48%; height: 48%; background: #9FC0D9; color: white; }
.cap-piece.bigdata { bottom: 0; left: 0; width: 48%; height: 48%; background: #C9DEEC; color: #173E68; }
.cap-piece.automation { bottom: 0; right: 0; width: 48%; height: 48%; background: #2E5C88; color: white; }

.cap-piece span { 
    font-weight: 700; 
    text-transform: uppercase; 
    font-size: 14px; 
}

/* Descripción (Desktop Hover) */
.cap-description {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    font-size: 13px;
    margin-top: 10px;
    transition: 0.35s ease;
}

@media (min-width: 992px) {
    .cap-puzzle:hover { transform: scale(1.02); }
    .cap-piece:hover { z-index: 5; }
    .cap-piece:hover .cap-description {
        opacity: 1;
        max-height: 200px;
    }
}

/* --- MOBILE: CENTRADO Y EXPANSIÓN RESTAURADOS --- */
@media (max-width: 991px) {
    .cap-grid { 
        grid-template-columns: 1fr; 
        gap: 40px; 
    }
    
    .section-subtitle { text-align: center; }
    .section-subtitle h2::after { 
        left: 25%; 
        width: 50%; 
    }

    .cap-puzzle {
        width: 90vw;
        max-width: 380px;
        height: 380px;
        margin: 20px auto !important; /* Forzar centrado */
        left: 0;
        transform: none;
    }

    .cap-description {
        display: none;
        max-height: none;
    }

    /* ESTADO ACTIVO (Expansión Full-Width en el contenedor) */
    .cap-piece.active {
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100% !important;
        height: 100% !important;
        z-index: 100 !important;
        border-radius: 20px;
        padding: 40px 25px;
        box-shadow: 0 20px 50px rgba(0,0,0,0.3);
        display: flex !important;
        justify-content: center;
        align-items: center;
    }

    .cap-piece.active span {
        font-size: 20px;
        margin-bottom: 15px;
        border-bottom: 2px solid rgba(0,0,0,0.1);
        padding-bottom: 10px;
        width: 100%;
    }

    .cap-piece.active.ai span, 
    .cap-piece.active.automation span { 
        border-color: rgba(255,255,255,0.2); 
    }

    .cap-piece.active .cap-description {
        display: block !important;
        opacity: 1;
        font-size: 15px;
        line-height: 1.6;
        animation: slideUpCap 0.4s ease forwards;
    }

    .cap-piece.active::after {
        content: '✕';
        position: absolute;
        top: 15px;
        right: 15px;
        font-size: 20px;
        font-weight: bold;
    }

    @keyframes slideUpCap {
        from { opacity: 0; transform: translateY(15px); }
        to { opacity: 1; transform: translateY(0); }
    }
}