/**
 * CCM Brand Cards Slider — Estilos frontend
 *
 * Diseño de referencia: Figma node 925:5679 (CCM web design 2026)
 * Especificaciones Figma: tarjeta 332×210px | border-radius:12px | padding:24/16/24/16
 *
 * Patrón de scroll: igual que ccmg-nav-slider.
 *   - .ccmg-bcs          → overflow:hidden (clip del peek)
 *   - .ccmg-bcs__track   → flex + overflow-x:scroll (scroll container)
 *   - .ccmg-bcs__track::after → spacer para no chocar el último item con el extremo
 *   - .ccmg-bcs__card    → ancho fraccionado (visible = 4.15) para peek intencional
 */

/* =============================================================
   VARIABLES
   ============================================================= */

.ccmg-bcs {
    --ccmg-bcs-gap:       16px;   /* sobreescrito inline por el widget */
    --ccmg-bcs-end-space: 48px;   /* espacio trailing después del último card */
    --ccmg-bcs-visible:   4.15;   /* cards visibles + peek en desktop */
}

/* =============================================================
   TÍTULO
   ============================================================= */

.ccmg-bcs__title {
    all:         unset;
    display:     block;
    font-family: "Founder grotesk CCM", "Founders Grotesk", "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size:   clamp(20px, 1.45vw, 24px);
    font-weight: 500;
    color:       rgba(0, 0, 0, 0.92);
    line-height: 1.2;
    margin-bottom: 12px;
}

/* =============================================================
   WRAPPER PRINCIPAL — clip del peek
   ============================================================= */

.ccmg-bcs {
    position: relative;
    width: 100%;
    overflow: hidden;              /* clip del card parcial (peek) */
}

/* =============================================================
   TRACK WRAPPER — contexto de posición para los botones nav
   ============================================================= */

.ccmg-bcs__track-wrapper {
    position: relative;
    width: 100%;
}

/* =============================================================
   TRACK — scroll container + flex row
   ============================================================= */

.ccmg-bcs__track {
    display: flex;
    flex-wrap: nowrap;
    gap: var(--ccmg-bcs-gap);
    overflow-x: scroll;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    touch-action: pan-x pinch-zoom;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    /* Scrollbar oculta — navegación via botones o drag */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.ccmg-bcs__track::-webkit-scrollbar {
    display: none;
}

/* Spacer trailing: evita que el último card choque con el borde del contenedor */
.ccmg-bcs__track::after {
    content: '';
    flex: 0 0 var(--ccmg-bcs-end-space);
}

.ccmg-bcs__track.is-dragging {
    cursor: grabbing;
    scroll-snap-type: none; /* Desactivar snap durante drag para fluidez */
}

/* =============================================================
   TARJETA — ancho fraccionado para peek intencional
   ============================================================= */

.ccmg-bcs__card {
    /*
     * Formula: (100% - (N_visible - 1) × gap) / N_visible
     * Con N_visible=4.15 en desktop: el 0.15 fraccionario es el peek.
     * 100% aquí = ancho del track (= ancho del contenedor del widget).
     */
    flex-shrink: 0;
    width: calc(
        (100% - (var(--ccmg-bcs-visible) - 1) * var(--ccmg-bcs-gap))
        / var(--ccmg-bcs-visible)
    );
    max-width: 332px;              /* cap al spec Figma en contenedores muy anchos */
    aspect-ratio: 16 / 9;         /* altura responsive, proporcional al ancho */
    min-height: 90px;
    border-radius: 12px;
    padding: 24px 16px;
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: 10px;
    position: relative;
    overflow: hidden;
    text-decoration: none;
    background-color: #000;
    background-size: cover;
    background-position: center;
    scroll-snap-align: start;
    transition: transform 0.2s ease;
}

.ccmg-bcs__card:hover {
    text-decoration: none;
}

/* Overlay gradiente para legibilidad del texto sobre imagen */
.ccmg-bcs__card-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.65) 0%,
        rgba(0, 0, 0, 0.15) 55%,
        rgba(0, 0, 0, 0.00) 100%
    );
    pointer-events: none;
    border-radius: inherit;
}

/* Contenido sobre el overlay */
.ccmg-bcs__card-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: 10px;
    width: 100%;
}

/* Columna izquierda: nombre + CTA */
.ccmg-bcs__card-text {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    flex: 1;
    min-width: 0;
    padding: 4px 0;
}

.ccmg-bcs__card-name {
    display: block;
    font-family: Inter, sans-serif;
    font-weight: 500;
    font-size: 11.5px;
    line-height: 14.3px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

.ccmg-bcs__card-cta {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    color: #fff;
}

.ccmg-bcs__card-cta-label {
    font-family: 'Founders Grotesk', 'Apercu', sans-serif;
    font-weight: 500;
    font-size: 16px;
    line-height: 16px;
    color: #fff;
    white-space: nowrap;
}

.ccmg-bcs__card-cta-arrow {
    display: flex;
    align-items: center;
    color: #fff;
    flex-shrink: 0;
}

/* Columna derecha: logo YITH */
.ccmg-bcs__card-logo {
    flex-shrink: 0;
    display: flex;
    align-items: flex-end;
    justify-content: flex-end;
    max-width: 90px;
}

.ccmg-bcs__card-logo-img {
    display: block;
    width: 90px;
    height: auto;
    max-height: 90px;
    object-fit: contain;
}

/* =============================================================
   NAVEGACIÓN — idéntico al patrón ccmg-nav-slider
   ============================================================= */

/* Botones absolutamente posicionados sobre el track wrapper,
   centrados verticalmente. Ocultos por defecto, aparecen en hover
   del contenedor solo cuando JS añade .is-visible */
.ccmg-bcs__nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;

    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12), 0 1px 4px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 10px;
    color: #000;
    line-height: 1;

    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.ccmg-bcs__nav-btn--prev { left: 8px; }
.ccmg-bcs__nav-btn--next { right: 8px; }

/* Aparece en hover del contenedor SOLO si JS añade .is-visible */
.ccmg-bcs:hover .ccmg-bcs__nav-btn.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.ccmg-bcs__nav-btn.is-visible:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18), 0 3px 8px rgba(0, 0, 0, 0.10);
    transform: translateY(calc(-50% - 1px));
}

.ccmg-bcs__nav-btn:focus-visible {
    outline: 2px solid #121212;
    outline-offset: 2px;
    opacity: 1;
    pointer-events: auto;
}

.ccmg-bcs__nav-btn svg {
    display: block;
}

@media (prefers-reduced-motion: reduce) {
    .ccmg-bcs__nav-btn {
        transition: none;
    }
}

/* =============================================================
   RESPONSIVE
   ============================================================= */

/* Tablet */
@media (max-width: 1023px) {
    .ccmg-bcs {
        --ccmg-bcs-visible: 3.15;
    }

    .ccmg-bcs__title {
        font-size: 18px;
    }
}

/* Mobile */
@media (max-width: 767px) {
    .ccmg-bcs {
        --ccmg-bcs-visible: 2.1;
        --ccmg-bcs-end-space: 24px;
    }

    .ccmg-bcs__card {
        max-width: none; /* En mobile sin cap — el ancho fraccionado ya es correcto */
        padding: 8px;
    }

    .ccmg-bcs__track {
        gap: 8px !important; /* gap fijo en mobile, ignora el valor del widget */
    }

    /* Layout mobile: columna — logo arriba, CTA abajo */
    .ccmg-bcs__card-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    /* Logo pasa a la primera posición (arriba) */
    .ccmg-bcs__card-logo {
        order: -1;
        align-items: flex-start;
        justify-content: flex-start;
        max-width: 60px;
    }

    .ccmg-bcs__card-logo-img {
        width: 60px;
        max-height: 60px;
    }

    /* El bloque de texto ocupa solo lo que necesita */
    .ccmg-bcs__card-text {
        flex: none;
        width: 100%;
    }

    /* Nombre oculto en mobile cuando hay logo — solo logo + CTA */
    .ccmg-bcs__card-name {
        display: none;
    }

    /* Sin logo: mostrar el nombre como identificador de la marca */
    .ccmg-bcs__card--no-logo .ccmg-bcs__card-name {
        display: block;
    }

    .ccmg-bcs__card-cta-label {
        font-size: 12px;
        line-height: 12px;
    }

    .ccmg-bcs__title {
        font-size: 16px;
    }
}
