/**
 * Estilos Frontend para g2galeria
 * Soporte para Mosaico Creativo Modula, Filas Justificadas, Grid Estándar y Masonry Clásico
 */

.g2-gallery-container {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    box-sizing: border-box;
}

.g2-gallery-container *,
.g2-gallery-container *::before,
.g2-gallery-container *::after {
    box-sizing: border-box;
}

/* Soporte nativo para contenedor <picture> y renderizado fotográfico de alta fidelidad */
.g2-picture {
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}

.g2-layout-masonry .g2-picture {
    height: auto !important;
}

.g2-image {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: auto;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
}

/* ----------------------------------------------------
 * 1. DISEÑO: MOSAICO CREATIVO (BORDES FLUSH & MULTI-SPAN)
 * ---------------------------------------------------- */
.g2-layout-mosaic {
    display: grid;
    grid-auto-flow: dense;
    gap: var(--g2-gap, 16px);
    grid-template-columns: repeat(var(--g2-cols-mob, 1), minmax(0, 1fr));
    grid-auto-rows: var(--g2-row-height, 220px);
}

@media (min-width: 640px) {
    .g2-layout-mosaic {
        grid-template-columns: repeat(var(--g2-cols-tab, 2), minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .g2-layout-mosaic {
        grid-template-columns: repeat(var(--g2-cols-desk, 4), minmax(0, 1fr));
    }
}

.g2-layout-mosaic .g2-gallery-item {
    margin: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
}

.g2-layout-mosaic .g2-item-inner {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    background-color: #f1f5f9;
    border-radius: 2px;
}

.g2-layout-mosaic .g2-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Definición de Proporciones (Spans) */
.g2-layout-mosaic .g2-span-1x1 {
    grid-column: span 1;
    grid-row: span 1;
}

.g2-layout-mosaic .g2-span-2x1 {
    grid-column: span 2;
    grid-row: span 1;
}

.g2-layout-mosaic .g2-span-1x2 {
    grid-column: span 1;
    grid-row: span 2;
}

.g2-layout-mosaic .g2-span-2x2 {
    grid-column: span 2;
    grid-row: span 2;
}

/* Adaptación en pantallas móviles si las columnas son 1 */
@media (max-width: 639px) {
    .g2-layout-mosaic[style*="--g2-cols-mob: 1"] .g2-span-2x1,
    .g2-layout-mosaic[style*="--g2-cols-mob: 1"] .g2-span-2x2 {
        grid-column: span 1;
    }
}

/* ----------------------------------------------------
 * 2. DISEÑO: FILAS JUSTIFICADAS (JUSTIFIED ROWS)
 * ---------------------------------------------------- */
.g2-layout-justified {
    display: flex;
    flex-wrap: wrap;
    gap: var(--g2-gap, 16px);
}

.g2-layout-justified .g2-gallery-item {
    flex: 1 1 calc(var(--g2-row-height, 220px) * 1.3);
    height: var(--g2-row-height, 220px);
    margin: 0;
    min-width: 140px;
}

.g2-layout-justified .g2-span-2x1,
.g2-layout-justified .g2-span-2x2 {
    flex: 2 1 calc(var(--g2-row-height, 220px) * 2);
}

.g2-layout-justified .g2-item-inner {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    background-color: #f1f5f9;
    border-radius: 2px;
}

.g2-layout-justified .g2-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ----------------------------------------------------
 * 3. DISEÑO: GRID ESTÁNDAR
 * ---------------------------------------------------- */
.g2-layout-grid {
    display: grid;
    grid-template-columns: repeat(var(--g2-cols-mob, 1), 1fr);
    gap: var(--g2-gap, 16px);
}

@media (min-width: 640px) {
    .g2-layout-grid {
        grid-template-columns: repeat(var(--g2-cols-tab, 2), 1fr);
    }
}

@media (min-width: 1024px) {
    .g2-layout-grid {
        grid-template-columns: repeat(var(--g2-cols-desk, 3), 1fr);
    }
}

.g2-layout-grid .g2-gallery-item {
    margin: 0;
    width: 100%;
}

.g2-layout-grid .g2-item-inner {
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    position: relative;
    background-color: #f1f5f9;
    border-radius: 2px;
}

.g2-layout-grid .g2-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ----------------------------------------------------
 * 4. DISEÑO: MASONRY EN CASCADA (PROPORCIONAL SIN CORTES)
 * ---------------------------------------------------- */
.g2-layout-masonry {
    width: 100%;
    box-sizing: border-box;
    align-items: flex-start;
}

/* Fallback nativo CSS multi-columna mientras carga JS o si JS no está activo */
.g2-layout-masonry:not(.g2-masonry-cols-ready) {
    display: block;
    column-count: var(--g2-cols-desk, 4);
    column-gap: var(--g2-gap, 16px);
}

@media (max-width: 1023px) {
    .g2-layout-masonry:not(.g2-masonry-cols-ready) {
        column-count: var(--g2-cols-tab, 2);
    }
}

@media (max-width: 639px) {
    .g2-layout-masonry:not(.g2-masonry-cols-ready) {
        column-count: var(--g2-cols-mob, 1);
    }
}

.g2-layout-masonry:not(.g2-masonry-cols-ready) .g2-gallery-item {
    break-inside: avoid;
    margin-bottom: var(--g2-gap, 16px);
    width: 100%;
    display: inline-block;
}

/* Cuando JS ya estructuró las columnas .g2-masonry-col con distribución por menor altura */
.g2-layout-masonry.g2-masonry-cols-ready {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: var(--g2-gap, 16px);
    align-items: flex-start !important; /* Siempre alineadas arriba para no forzar estiramientos */
}

.g2-masonry-col {
    display: flex;
    flex-direction: column;
    gap: var(--g2-gap, 16px);
    min-width: 0;
    box-sizing: border-box;
    align-items: stretch;
}

.g2-layout-masonry .g2-gallery-item {
    margin: 0;
    width: 100%;
    height: auto !important;
    display: block;
    box-sizing: border-box;
    flex: none !important;
}

.g2-layout-masonry .g2-item-inner {
    position: relative;
    overflow: hidden;
    background-color: transparent;
    border-radius: 2px;
    width: 100%;
    height: auto !important;
    display: block !important;
}

/* En Masonry las fotos SOLO se redimensionan manteniendo su proporción original:
 * NUNCA se cortan (sin object-fit:cover, sin altura fija forzada, 100% de la foto visible) */
.g2-layout-masonry .g2-image {
    width: 100% !important;
    height: auto !important;
    max-width: 100% !important;
    max-height: none !important;
    display: block !important;
    object-fit: contain !important;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ----------------------------------------------------
 * 5. DISEÑO: CARRUSEL ESTILO BOOTSTRAP 5
 * ---------------------------------------------------- */
.g2-layout-carousel {
    position: relative;
    width: 100%;
    overflow: hidden;
    background-color: #000000;
    border-radius: 6px;
    box-sizing: border-box;
    user-select: none;
}

.g2-carousel-inner {
    position: relative;
    width: 100%;
    overflow: hidden;
}

.g2-carousel-track {
    display: flex;
    transition: transform 0.6s cubic-bezier(0.25, 0.1, 0.25, 1);
    will-change: transform;
}

.g2-layout-carousel .g2-gallery-item {
    flex: 0 0 100%;
    width: 100%;
    margin: 0;
    box-sizing: border-box;
    position: relative;
}

.g2-layout-carousel .g2-item-inner {
    width: 100%;
    height: var(--g2-row-height, 460px);
    position: relative;
    overflow: hidden;
    background-color: #0f172a;
}

.g2-layout-carousel .g2-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Indicadores inferiores estilo Bootstrap 5 (barras rectangulares) */
.g2-carousel-indicators {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 10;
    display: flex;
    justify-content: center;
    padding: 0;
    margin-right: 15%;
    margin-bottom: 1rem;
    margin-left: 15%;
    gap: 6px;
    list-style: none;
}

.g2-carousel-indicators .g2-indicator {
    box-sizing: content-box;
    flex: 0 1 auto;
    width: 32px;
    height: 3px;
    padding: 0;
    margin: 0;
    text-indent: -9999px;
    cursor: pointer;
    background-color: #ffffff;
    background-clip: padding-box;
    border: 0;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    opacity: 0.5;
    transition: opacity 0.5s ease, transform 0.2s ease;
    border-radius: 1px;
}

.g2-carousel-indicators .g2-indicator.is-active {
    opacity: 1;
    transform: scaleY(1.3);
}

.g2-carousel-indicators .g2-indicator:hover:not(.is-active) {
    opacity: 0.8;
}

/* Controles laterales estilo Bootstrap 5 (franjas completas con SVG chevrons) */
.g2-carousel-control-prev,
.g2-carousel-control-next {
    position: absolute;
    top: 0;
    bottom: 0;
    z-index: 12;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 14%;
    padding: 0;
    color: #ffffff;
    text-align: center;
    background: none;
    border: 0;
    opacity: 0.5;
    transition: opacity 0.2s ease, background 0.25s ease;
    cursor: pointer;
}

.g2-carousel-control-prev {
    left: 0;
}

.g2-carousel-control-next {
    right: 0;
}

.g2-carousel-control-prev:hover {
    opacity: 0.95;
    background: linear-gradient(90deg, rgba(0, 0, 0, 0.45) 0%, rgba(0, 0, 0, 0) 100%);
}

.g2-carousel-control-next:hover {
    opacity: 0.95;
    background: linear-gradient(270deg, rgba(0, 0, 0, 0.45) 0%, rgba(0, 0, 0, 0) 100%);
}

/* Iconos SVG oficiales de Bootstrap 5 */
.g2-carousel-control-prev-icon,
.g2-carousel-control-next-icon {
    display: inline-block;
    width: 2.25rem;
    height: 2.25rem;
    background-repeat: no-repeat;
    background-position: 50%;
    background-size: 100% 100%;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.6));
}

.g2-carousel-control-prev-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3e%3cpath d='M11.354 1.646a.5.5 0 0 1 0 .708L5.707 8l5.647 5.646a.5.5 0 0 1-.708.708l-6-6a.5.5 0 0 1 0-.708l6-6a.5.5 0 0 1 .708 0z'/%3e%3c/svg%3e");
}

.g2-carousel-control-next-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3e%3cpath d='M4.646 1.646a.5.5 0 0 1 .708 0l6 6a.5.5 0 0 1 0 .708l-6 6a.5.5 0 0 1-.708-.708L10.293 8 4.646 2.354a.5.5 0 0 1 0-.708z'/%3e%3c/svg%3e");
}

/* Captions estilo Bootstrap 5 */
.g2-carousel-caption {
    position: absolute;
    right: 15%;
    bottom: 2rem;
    left: 15%;
    padding: 12px 20px;
    color: #ffffff;
    text-align: center;
    z-index: 10;
    background: rgba(0, 0, 0, 0.45);
    border-radius: 8px;
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.g2-caption-title {
    margin: 0 0 4px;
    font-size: 1.25rem;
    font-weight: 700;
    line-height: 1.25;
    color: #ffffff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.g2-caption-text {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.4;
    color: #e2e8f0;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.g2-visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* ----------------------------------------------------
 * 5. EFECTOS HOVER EDITORIALES & OVERLAYS
 * ---------------------------------------------------- */
.g2-has-lightbox .g2-gallery-item {
    cursor: zoom-in;
}

.g2-gallery-item:hover .g2-image {
    transform: scale(1.05);
}

.g2-item-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.85) 0%, rgba(0, 0, 0, 0.35) 60%, rgba(0, 0, 0, 0) 100%);
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 18px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    z-index: 2;
}

.g2-gallery-item:hover .g2-item-overlay {
    opacity: 1;
}

.g2-item-details {
    transform: translateY(8px);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    color: #ffffff;
}

.g2-gallery-item:hover .g2-item-details {
    transform: translateY(0);
}

.g2-item-title {
    margin: 0 0 4px;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
}

.g2-item-caption {
    margin: 0;
    font-size: 12px;
    line-height: 1.4;
    color: #e2e8f0;
    text-shadow: 0 1px 6px rgba(0, 0, 0, 0.7);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ----------------------------------------------------
 * AVISOS EN EL EDITOR GUTENBERG
 * ---------------------------------------------------- */
.g2-editor-notice {
    padding: 24px;
    background: #fdf2f2;
    border: 1px solid #f8b4b4;
    border-radius: 4px;
    color: #9b1c1c;
    text-align: center;
    font-size: 13px;
}
