/**
 * styles.css - Estilos completos para el bloque de cursos en tarjetas
 * Totalmente responsivo para computadores y dispositivos móviles
 *
 * @package    block_cursos_tarjetas
 * @copyright  2025 Tu Nombre <tu.email@example.com>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */

/* ===== VARIABLES GLOBALES ===== */
:root {
    --primary-color: #008ed0;
    --primary-color-light: #60bae6;
    --primary-color-dark: #0070a8;
    --primary-color-alpha: rgba(0, 142, 208, 0.2);
    --text-color: #333;
    --text-color-secondary: #666;
    --text-color-light: #777;
    --background-color: #f9f9f9;
    --border-color: #e0e0e0;
    --shadow-color: rgba(0, 0, 0, 0.08);
    --shadow-hover: rgba(0, 142, 208, 0.2);
    --card-radius: 12px;
    --btn-radius: 50%;
    --section-padding: 1.5rem;
    --card-spacing: 1.25rem;
    --transition-speed: 0.3s;
}

h4#instance-37-header {
    display: none;
}

/* ===== RESET Y BASE ===== */
.cursos-tarjetas-container * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.cursos-tarjetas-container img {
    max-width: 100%;
}

/* ===== CONTENEDOR PRINCIPAL ===== */
.cursos-tarjetas-container {
    position: relative;
    margin: 2rem auto;
    padding: var(--section-padding) 0;
    max-width: 95%;
    background: linear-gradient(to bottom, var(--background-color), white);
    border-radius: var(--card-radius);
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

/* ===== ENCABEZADO ===== */
.cursos-header {
    text-align: center;
    margin-bottom: 1.5rem;
    position: relative;
    padding: 0 1rem;
}

.cursos-header::after {
    content: '';
    display: block;
    width: 80px;
    height: 4px;
    background: var(--primary-color);
    margin: 0.75rem auto 0;
    border-radius: 2px;
}

.cursos-titulo {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-color);
    margin: 0;
    padding: 0 0.5rem;
    line-height: 1.3;
}

/* ===== CARRUSEL ===== */
.cursos-slider-wrapper {
    position: relative;
    overflow: visible; /* Para que los controles no se recorten */
    padding: 1rem 3rem;
    margin: 0 auto;
    max-width: 1200px;
    touch-action: pan-y; /* Permitir scroll vertical */
}

.cursos-slider {
    display: flex;
    flex-wrap: nowrap;
    gap: var(--card-spacing);
    transition: transform 0.4s ease;
    padding: 0.5rem 0 1rem;
    user-select: none;
    will-change: transform;
    transform: translateX(0);
    min-height: 280px; /* Altura mínima para evitar saltos de contenido */
}

/* Sin carrusel (pocos cursos) */
.cursos-slider.sin-carousel {
    justify-content: center;
    flex-wrap: wrap;
}

/* ===== TARJETA CURSO ===== */
.curso-tarjeta {
    flex: 0 0 calc(25% - (var(--card-spacing) * 0.75));
    min-width: 250px;
    background-color: white;
    border-radius: var(--card-radius);
    box-shadow: 0 3px 15px var(--shadow-color);
    overflow: hidden;
    transition: all var(--transition-speed) ease, opacity 0.2s ease;
    border: 1px solid rgba(0, 0, 0, 0.05);
    position: relative;
    transform-origin: center bottom;
}

.curso-tarjeta:hover,
.curso-tarjeta:focus-within {
    transform: translateY(-8px);
    box-shadow: 0 12px 30px var(--shadow-hover), 0 4px 8px rgba(0, 142, 208, 0.1);
    border-color: rgba(0, 142, 208, 0.3);
}

/* Enlace de curso */
.curso-enlace {
    color: inherit;
    text-decoration: none;
    display: block;
    height: 100%;
    outline: none;
}

.curso-enlace:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: -2px;
}

/* ===== IMAGEN CURSO ===== */
.curso-imagen {
    height: 160px;
    overflow: hidden;
    position: relative;
}

.curso-imagen::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--primary-color-light));
    z-index: 2;
    opacity: 0;
    transition: opacity var(--transition-speed) ease;
}

.curso-tarjeta:hover .curso-imagen::before {
    opacity: 1;
}

.curso-imagen img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.curso-tarjeta:hover .curso-imagen img {
    transform: scale(1.08);
}

.curso-tarjeta:hover .curso-imagen::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to bottom, var(--primary-color-alpha), transparent);
    z-index: 1;
}

/* ===== INSIGNIAS O ETIQUETAS ===== */
.curso-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 142, 208, 0.85);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    z-index: 3;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* ===== INFORMACIÓN CURSO ===== */
.curso-info {
    padding: 1rem 1.25rem;
    position: relative;
    background: linear-gradient(to bottom, white, #fafafa);
    border-top: 1px solid rgba(0, 0, 0, 0.03);
}

.curso-titulo {
    font-size: 1.25rem;
    font-weight: bold;
    margin: 0 0 0.75rem;
    color: var(--text-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transition: color var(--transition-speed) ease;
    position: relative;
    padding-bottom: 0.5rem;
    line-height: 1.3;
}

.curso-titulo::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 30px;
    height: 2px;
    background-color: #ddd;
    transition: all var(--transition-speed) ease;
}

.curso-tarjeta:hover .curso-titulo {
    color: var(--primary-color);
}

.curso-tarjeta:hover .curso-titulo::after {
    width: 50px;
    background-color: var(--primary-color);
}

.curso-profesores {
    color: var(--text-color-secondary);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    margin-bottom: 0.625rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.4;
}

.curso-profesores::before {
    content: '';
    display: inline-block;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin-right: 8px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='%23008ed0' viewBox='0 0 16 16'%3E%3Cpath d='M8 8a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm2-3a2 2 0 1 1-4 0 2 2 0 0 1 4 0zm4 8c0 1-1 1-1 1H3s-1 0-1-1 1-4 6-4 6 3 6 4zm-1-.004c-.001-.246-.154-.986-.832-1.664C11.516 10.68 10.289 10 8 10c-2.29 0-3.516.68-4.168 1.332-.678.678-.83 1.418-.832 1.664h10z'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
}

.curso-descripcion {
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--text-color-light);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    height: 2.4em;
}

/* ===== CONTROLES SLIDER ===== */
.slider-controls {
    display: flex;
    justify-content: center;
    margin-top: 1.5rem;
    gap: 1rem;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    left: 0;
    right: 0;
    pointer-events: none;
    z-index: 100;
}

.slider-control {
    position: relative;
    z-index: 100;
    background-color: white;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    border-radius: var(--btn-radius);
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    font-size: 1.25rem;
    box-shadow: 0 3px 10px rgba(0, 142, 208, 0.1);
    -webkit-tap-highlight-color: transparent; /* eliminar highlight táctil */
    -webkit-user-select: none;
    user-select: none;
    pointer-events: auto;
    margin: 0 1rem;
}

.prev-btn {
    margin-right: auto;
    margin-left: 0;
    left: 0;
    position: absolute;
}

.next-btn {
    margin-left: auto;
    margin-right: 0;
    right: 0;
    position: absolute;
}

.slider-control:hover {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 5px 15px rgba(0, 142, 208, 0.3);
    transform: translateY(-2px);
}

.slider-control:active {
    transform: scale(0.95);
    box-shadow: 0 2px 5px rgba(0, 142, 208, 0.2);
}

.slider-control.disabled,
.slider-control:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    background-color: #f5f5f5;
    border-color: #ddd;
    color: #aaa;
    box-shadow: none;
    transform: none;
}

/* ===== PAGINACIÓN ===== */
.slider-pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 1rem;
}

.slider-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ddd;
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    position: relative;
}

.slider-dot:hover {
    background: #aaa;
}

.slider-dot.active {
    background: var(--primary-color);
    transform: scale(1.2);
}

.slider-dot.active::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid var(--primary-color);
    opacity: 0.5;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0.6;
    }
    70% {
        transform: translate(-50%, -50%) scale(1.3);
        opacity: 0;
    }
    100% {
        transform: translate(-50%, -50%) scale(0.8);
        opacity: 0;
    }
}

/* ===== FOOTER ===== */
.cursos-footer {
    text-align: center;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.cursos-footer a {
    display: inline-block;
    padding: 0.5rem 1.25rem;
    background-color: #f5f5f5;
    color: var(--text-color-secondary);
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all var(--transition-speed) ease;
    border: 1px solid var(--border-color);
}

.cursos-footer a:hover {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 2px 10px rgba(0, 142, 208, 0.3);
}

/* ===== MEJORAS DE ACCESIBILIDAD ===== */
.slider-control:focus {
    outline: 2px solid rgba(0, 142, 208, 0.5);
    outline-offset: 2px;
}

.slider-dot:focus {
    outline: 2px solid rgba(0, 142, 208, 0.5);
    outline-offset: 2px;
}

/* ===== OPTIMIZACIONES MÓVILES ===== */
/* Para móviles, efecto visual distintivo para la tarjeta activa */
.curso-tarjeta {
    backface-visibility: hidden; /* Optimización de rendimiento */
    -webkit-font-smoothing: antialiased; /* Mejora texto */
}

/* Indicador de deslizamiento para móviles */
.cursos-slider-wrapper::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 50px;
    height: 4px;
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.cursos-slider.has-overflow .cursos-slider-wrapper::after {
    opacity: 1;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (min-width: 1400px) {
    .cursos-slider-wrapper {
        max-width: 1300px;
    }

    .curso-tarjeta {
        flex: 0 0 calc(25% - (var(--card-spacing) * 0.75));
    }
}

@media (max-width: 1200px) {
    .cursos-slider-wrapper {
        max-width: 95%;
        padding-left: 3rem;
        padding-right: 3rem;
    }

    .curso-tarjeta {
        flex: 0 0 calc(33.333% - (var(--card-spacing) * 0.67));
    }

    .cursos-titulo {
        font-size: 1.4rem;
    }

    .slider-control {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
}

@media (max-width: 992px) {
    .curso-tarjeta {
        flex: 0 0 calc(33.333% - (var(--card-spacing) * 0.67));
    }

    .curso-imagen {
        height: 140px;
    }
}

@media (max-width: 768px) {
    :root {
        --card-spacing: 1rem;
        --section-padding: 1rem;
    }

    .cursos-tarjetas-container {
        padding: 1rem 0 1.5rem;
        margin: 1rem auto;
    }

    .cursos-header {
        margin-bottom: 1rem;
    }

    .cursos-titulo {
        font-size: 1.3rem;
    }

    .cursos-header::after {
        width: 60px;
        height: 3px;
    }

    .cursos-slider-wrapper {
        padding: 0.75rem 2.5rem;
    }

    .curso-tarjeta {
        flex: 0 0 calc(50% - (var(--card-spacing) * 0.5));
        min-width: 200px;
    }

    .curso-imagen {
        height: 130px;
    }

    .curso-titulo {
        font-size: 1.1rem;
    }

    .slider-control {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }

    .cursos-footer a {
        padding: 0.4rem 1rem;
        font-size: 0.85rem;
    }

    /* Mejor posicionamiento de los controles */
    .slider-controls {
        top: 40%;
    }

    .prev-btn {
        left: -5px;
    }

    .next-btn {
        right: -5px;
    }
}

@media (max-width: 576px) {
    .cursos-titulo {
        font-size: 1.2rem;
    }

    .cursos-header::after {
        width: 50px;
        margin-top: 0.5rem;
    }

    .cursos-slider-wrapper {
        padding: 0.5rem 2rem;
    }

    .slider-control {
        width: 32px;
        height: 32px;
        font-size: 0.8rem;
    }

    .curso-tarjeta {
        flex: 0 0 calc(100% - 2rem);
        margin: 0 1rem;
        min-width: 0;
        opacity: 0.85;
        transform: scale(0.95);
    }

    .curso-tarjeta.active {
        opacity: 1;
        transform: scale(1);
    }

    .curso-imagen {
        height: 140px;
    }

    .slider-controls {
        margin-top: 0;
    }

    .slider-dot {
        width: 8px;
        height: 8px;
    }

    /* Mejor posicionamiento de los controles */
    .slider-controls {
        top: 35%;
    }

    .prev-btn {
        left: -10px;
    }

    .next-btn {
        right: -10px;
    }
}

@media (max-width: 420px) {
    .cursos-tarjetas-container {
        padding: 0.75rem 0 1.25rem;
        margin: 0.75rem auto;
        max-width: 100%;
    }

    .cursos-slider-wrapper {
        padding: 0.5rem 1.75rem;
    }

    .curso-tarjeta {
        width: calc(100% - 1.5rem);
        margin: 0 0.75rem;
    }

    .curso-imagen {
        height: 150px;
    }

    .curso-info {
        padding: 0.875rem 1rem;
    }

    .curso-titulo {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }

    .curso-descripcion {
        font-size: 0.8rem;
        -webkit-line-clamp: 3;
        height: 3.6em;
    }

    /* Extremos del viewport para controles */
    .prev-btn {
        left: -12px;
        width: 30px;
        height: 30px;
    }

    .next-btn {
        right: -12px;
        width: 30px;
        height: 30px;
    }
}

/* ===== MEJORAS PARA NAVEGADORES ANTIGUOS ===== */
/* Fallbacks para navegadores que no soportan grid o flex */
@supports not (display: flex) {
    .cursos-slider {
        display: block;
        white-space: nowrap;
        font-size: 0;
    }

    .curso-tarjeta {
        display: inline-block;
        vertical-align: top;
        width: 23%;
        margin-right: 2%;
        font-size: 16px;
    }
}

/* Soporte para impresión */
@media print {
    .cursos-tarjetas-container {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .cursos-slider {
        display: block;
        transform: none !important;
    }

    .curso-tarjeta {
        display: block;
        width: 100%;
        margin-bottom: 20px;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .slider-controls, .slider-pagination {
        display: none;
    }
}
