/* ============================================
   TTFC Modaot Gallery - Full-Width Grid Masonry
   ============================================ */

/* Override content containers only (NOT the header) */
.ttfc-modaot-page main,
.ttfc-modaot-page main .wp-block-group,
.ttfc-modaot-page .wp-block-post-content,
.ttfc-modaot-page .entry-content {
    max-width: none !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* Remove constrained layout only inside main content */
.ttfc-modaot-page main .is-layout-constrained > :where(:not(.alignleft):not(.alignright):not(.alignfull)) {
    max-width: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

.ttfc-modaot-page main.wp-block-group {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

.ttfc-modaot-page .wp-block-spacer {
    display: none !important;
}

.ttfc-modaot-page main .is-layout-flow > * + * {
    margin-block-start: 0 !important;
}

/* Hide page title */
.ttfc-modaot-page .wp-block-post-title,
.ttfc-modaot-page .entry-title,
.ttfc-modaot-page main h1 {
    display: none !important;
}

/* Hide footer for clean gallery experience */
.ttfc-modaot-page footer {
    display: none;
}

/* ============================================
   Grid Masonry Gallery
   Row-based ordering with masonry visual layout.
   Uses CSS Grid with 1px auto-rows; JS explicitly
   places each item in a round-robin column with a
   span matching its image height, eliminating
   vertical gaps within columns.
   ============================================ */

.modaot-gallery {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 1px;
    column-gap: 4px;
    padding: 4px;
    background-color: #ffffff;
    min-height: 100vh;
    direction: ltr;
    opacity: 0;
}

.modaot-gallery.masonry-ready {
    opacity: 1;
    transition: opacity 0.15s ease;
}

.modaot-gallery .modaot-item {
    margin: 0;
    padding: 0;
    overflow: hidden;
    border-radius: 2px;
    line-height: 0;
}

.modaot-gallery .modaot-item a {
    display: block;
    line-height: 0;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.modaot-gallery .modaot-item a:hover {
    opacity: 0.85;
}

.modaot-gallery .modaot-item img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.modaot-gallery .modaot-item a:hover img {
    transform: scale(1.02);
}

/* ============================================
   Infinite Scroll Loader
   ============================================ */

.modaot-loader {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 40px 0;
    background-color: #ffffff;
}

.modaot-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: rgba(255, 255, 255, 0.7);
    border-radius: 50%;
    animation: modaot-spin 0.8s linear infinite;
}

@keyframes modaot-spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   Responsive Column Counts
   ============================================ */

@media (max-width: 480px) {
    .modaot-gallery {
        grid-template-columns: 1fr;
    }
}

@media (min-width: 481px) and (max-width: 768px) {
    .modaot-gallery {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .modaot-gallery {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Default: 4 columns (1025px - 1599px) */

@media (min-width: 1600px) {
    .modaot-gallery {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (min-width: 1920px) {
    .modaot-gallery {
        grid-template-columns: repeat(6, 1fr);
    }
}

@media (min-width: 2560px) {
    .modaot-gallery {
        grid-template-columns: repeat(7, 1fr);
    }
}

@media (min-width: 3440px) {
    .modaot-gallery {
        grid-template-columns: repeat(8, 1fr);
    }
}
