/* =========================================
   ESTRUCTURA GENERAL
   ========================================= */
.tgp-v3-wrapper {
    width: 100%;
    margin: 20px 0;
}

.tgp-v3-container {
    display: grid;
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
}

.tgp-item {
    position: relative;
    display: block;
    overflow: hidden;
    border-radius: 6px;
    cursor: pointer;
    background: #f0f0f0;
}

.tgp-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}

.tgp-item:hover img {
    transform: scale(1.05);
}

/* OCULTAR EN DESKTOP (Para cuando excede filas x columnas) */
.tgp-hide-desktop {
    display: none !important;
}

/* =========================================
   DISEÑO 1: GRID CLÁSICO
   ========================================= */
.tgp-layout-grid {
    grid-template-columns: repeat(var(--tgp-cols, 3), 1fr);
    grid-auto-rows: var(--tgp-height, 250px);
}

/* =========================================
   DISEÑO 2: MASONRY (Pinterest)
   ========================================= */
.tgp-layout-masonry {
    display: block; /* Masonry usa columnas CSS, no Grid */
    column-count: var(--tgp-cols, 3);
    column-gap: 10px;
}
.tgp-layout-masonry .tgp-item {
    margin-bottom: 10px;
    break-inside: avoid;
    height: auto !important; /* Altura automática según imagen */
}
.tgp-layout-masonry .tgp-item img {
    height: auto !important;
}

/* =========================================
   DISEÑO 3: FEATURED (Destacado)
   ========================================= */
.tgp-layout-featured {
    grid-template-columns: 2fr 1fr;
    grid-template-rows: repeat(2, 200px);
    height: 410px; /* 200*2 + 10 gap */
}
.tgp-layout-featured .tgp-item:nth-child(1) {
    grid-column: 1 / 2;
    grid-row: 1 / 3;
}
.tgp-layout-featured .tgp-item:nth-child(n+4) {
    display: none !important; /* Solo muestra 3 */
}

/* =========================================
   DISEÑO 4: MOSAIC (1 Arriba, 3 Abajo)
   ========================================= */
.tgp-layout-mosaic {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: 300px 150px;
}
.tgp-layout-mosaic .tgp-item:nth-child(1) {
    grid-column: 1 / -1; /* Ocupa todo el ancho */
    grid-row: 1 / 2;
}
.tgp-layout-mosaic .tgp-item:nth-child(n+5) {
    display: none !important; /* Solo muestra 4 */
}

/* =========================================
   DISEÑO 5: METRO (Moderno)
   ========================================= */
.tgp-layout-metro {
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 200px;
}
/* Patrón Metro: 1º grande, 2º normal, 3º ancho... */
.tgp-layout-metro .tgp-item:nth-child(1) { grid-column: span 2; grid-row: span 2; }
.tgp-layout-metro .tgp-item:nth-child(4) { grid-column: span 2; }
.tgp-layout-metro .tgp-item:nth-child(5) { grid-column: span 2; }

/* =========================================
   DISEÑO 6: CHESS (Ajedrez)
   ========================================= */
.tgp-layout-chess {
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: 250px;
}
.tgp-layout-chess .tgp-item:nth-child(4n+1), 
.tgp-layout-chess .tgp-item:nth-child(4n+4) {
    height: 350px; /* Alterna alturas */
    grid-row: span 2; 
}

/* =========================================
   RESPONSIVE Y LÓGICA MÓVIL (CRÍTICO)
   ========================================= */
.tgp-mobile-overlay { display: none; }

@media (max-width: 767px) {
    /* Reseteamos el contenedor para mostrar solo 1 bloque */
    .tgp-v3-container,
    .tgp-layout-grid, .tgp-layout-masonry, .tgp-layout-featured, 
    .tgp-layout-mosaic, .tgp-layout-metro, .tgp-layout-chess {
        display: block !important;
        grid-template-columns: none !important;
        grid-template-rows: none !important;
        height: auto !important;
        column-count: auto !important;
    }

    /* OCULTAR todo lo que tenga la clase mobile-hidden (items 2,3,4...) */
    .tgp-hide-mobile {
        display: none !important;
    }
    
    /* Mostrar lo que estaba oculto en desktop si es el item 1 */
    .tgp-hide-desktop.tgp-mobile-trigger {
        display: block !important;
    }

    /* Estilo del Item Único en Móvil */
    .tgp-item {
        width: 100% !important;
        height: 300px !important; /* Altura fija atractiva en móvil */
        margin-bottom: 0 !important;
    }

    /* OVERLAY ICONO (Cámara) */
    .tgp-mobile-overlay {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        position: absolute;
        top: 0; left: 0; right: 0; bottom: 0;
        background: rgba(0,0,0,0.3);
        color: #fff;
        font-weight: bold;
        transition: background 0.3s;
    }

    .tgp-icon-camera {
        width: 48px; height: 48px;
        background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M12 8.8c-1.8 0-3.2 1.4-3.2 3.2s1.4 3.2 3.2 3.2 3.2-1.4 3.2-3.2-1.4-3.2-3.2-3.2zm0 4.8c-.9 0-1.6-.7-1.6-1.6s.7-1.6 1.6-1.6 1.6.7 1.6 1.6-.7 1.6-1.6 1.6zM19 6h-2.5l-1.7-1.8c-.4-.5-1-.8-1.6-.8H10.8c-.6 0-1.2.3-1.6.8L7.5 6H5c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2z'/%3E%3C/svg%3E");
        background-repeat: no-repeat;
        background-position: center;
    }
    
    .tgp-count {
        margin-top: 5px;
        font-size: 16px;
        background: rgba(0,0,0,0.6);
        padding: 2px 8px;
        border-radius: 10px;
    }
}
/* =========================================
   DISEÑO 7: MARQUESINA (Derecha a Izquierda)
   Tamaño de imagen y velocidad editables desde el panel.
   ========================================= */
.tgp-layout-marquee {
    display: block;            /* Anula el grid del contenedor base */
    overflow: hidden;          /* Oculta lo que se sale de la cinta */
    width: 100%;
    position: relative;
    -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 6%, #000 94%, transparent 100%);
            mask-image: linear-gradient(90deg, transparent 0, #000 6%, #000 94%, transparent 100%);
}

.tgp-layout-marquee .tgp-marquee-track {
    display: flex;
    flex-wrap: nowrap;
    width: max-content;
    gap: 10px;
    /* La animación recorre la mitad (-50%) porque el set está duplicado,
       logrando un bucle perfecto y continuo. */
    animation: tgp-marquee-rtl var(--tgp-mq-speed, 40s) linear infinite;
    will-change: transform;
}

/* Pausa al pasar el cursor */
.tgp-layout-marquee:hover .tgp-marquee-track {
    animation-play-state: paused;
}

.tgp-layout-marquee .tgp-item {
    flex: 0 0 auto;
    width: var(--tgp-mq-w, 320px);
    height: var(--tgp-mq-h, 220px);
    margin: 0;
    border-radius: 6px;
}

.tgp-layout-marquee .tgp-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Movimiento Derecha -> Izquierda */
@keyframes tgp-marquee-rtl {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}

/* Accesibilidad: si el usuario pidió menos movimiento, detenemos la cinta */
@media (prefers-reduced-motion: reduce) {
    .tgp-layout-marquee .tgp-marquee-track {
        animation: none;
        overflow-x: auto;
    }
}

/* RESPONSIVE: la marquesina SIGUE siendo marquesina en móvil.
   Sobrescribimos la regla global que convierte los layouts en bloque. */
@media (max-width: 767px) {
    .tgp-layout-marquee {
        display: block !important;
        height: auto !important;
    }
    .tgp-layout-marquee .tgp-marquee-track {
        display: flex !important;
    }
    /* En móvil reducimos un poco el tamaño para que no domine la pantalla */
    .tgp-layout-marquee .tgp-item {
        width: calc(var(--tgp-mq-w, 320px) * 0.8) !important;
        height: calc(var(--tgp-mq-h, 220px) * 0.8) !important;
        margin-bottom: 0 !important;
    }
    /* No mostramos el overlay de cámara móvil en este layout */
    .tgp-layout-marquee .tgp-mobile-overlay { display: none !important; }
}
