/* Tanke Masonry - Final Production CSS (v3.5) */

/* 1. Reset and Breakout Logic 
   Forces the gallery to be full-width even inside a constrained Divi row */
.tm-masonry-container,
.tm-masonry-container * {
    box-sizing: border-box;
}

.tm-masonry-container {
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    overflow: hidden;
    background: #fff;
}

.tm-grid-items {
    width: 100% !important;
    margin: 0 !important;
    display: block;
}

/* 2. Grid Element Base */
.tm-grid-items .tm-element {
    width: 20%;
    float: left;
    position: relative;
    display: block;
    padding: 0;
}

/* 3. Image Styling Logic (Natural vs Square) */
.tm-grid-items .tm-element .tm-img-container {
    width: 100%;
    overflow: hidden;
    position: relative;
    background: #eee;
}

/* NATURAL STYLE: Image dictates height (Pinterest style) */
.tm-element.tm-style-natural .tm-img-container img {
    width: 100%;
    height: auto;
    display: block;
}

/* SQUARE STYLE: Forces 1:1 Aspect Ratio with Center Crop */
.tm-element.tm-style-square .tm-img-container {
    aspect-ratio: 1 / 1;
}

.tm-element.tm-style-square .tm-img-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Crops the image to fill the square */
    display: block;
}



/* 4. Hover Effects & Overlays */
.tm-grid-items .tm-element img {
    transition: transform 0.6s cubic-bezier(0.2, 0, 0.2, 1);
}

.tm-grid-items .tm-element:hover img {
    transform: scale(1.08);
}

.tm-overlay-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 5;
}

.tm-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    opacity: 0;
    text-align: center;
    padding: 20px;
    z-index: 10;
    transition: opacity 0.4s ease;
}

.tm-element:hover .tm-overlay-bg,
.tm-element:hover .tm-content {
    opacity: 1;
}

/* 5. Typography */
.tm-content h3 {
    color: #fff !important;
    font-size: 1.2vw;
    margin: 0 0 5px 0;
    text-transform: uppercase;
    letter-spacing: 2px;
    font-weight: 700;
}

.tm-content p {
    color: #fff !important;
    font-size: 0.8vw;
    opacity: 0.6;
    margin: 0;
}

/* 6. Admin Preview UI Overrides 
   Ensures the preview works inside the WordPress dashboard tray */
#tm-preview-tray .tm-masonry-container {
    width: 100%;
    margin: 0;
    left: auto;
    right: auto;
    position: relative;
}

#tm-preview-tray .tm-element {
    width: 20%;
    opacity: 1 !important;
}

#tm-preview-tray .tm-content h3 {
    font-size: 11px;
}

#tm-preview-tray .tm-content p {
    font-size: 9px;
}

/* 7. Responsive Breakpoints */
@media (max-width: 1400px) {
    .tm-grid-items .tm-element {
        width: 25%;
    }

    .tm-content h3 {
        font-size: 18px;
    }
}

@media (max-width: 980px) {
    .tm-grid-items .tm-element {
        width: 50%;
    }
}

@media (max-width: 600px) {
    .tm-grid-items .tm-element {
        width: 100% !important;
        position: relative !important;
        left: auto !important;
        top: auto !important;
    }

    .tm-content h3 {
        font-size: 20px;
    }
}