/**
 * RM Instagram Feed Public CSS
 */

.rm-instagram-feed-wrap {
    width: 100%;
    margin: 20px 0;
}

/* --- GRID LAYOUT (Default) --- */
.rm-ig-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.rm-ig-item {
    position: relative;
    overflow: hidden;
    border-radius: 0;
    /* Square look as per request image */
    background: #f0f0f0;
}

/* Force square for standard grid */
.rm-layout-grid .rm-ig-item {
    aspect-ratio: 1 / 1;
}

.rm-ig-item img,
.rm-ig-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.rm-ig-item:hover img {
    transform: scale(1.05);
}

.rm-ig-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    font-size: 32px;
    pointer-events: none;
    /* Let click pass to link */
}

.rm-ig-item:hover .rm-ig-overlay {
    opacity: 1;
}

/* --- MASONRY LAYOUT --- */
.rm-layout-masonry {
    column-count: 4;
    column-gap: 20px;
    display: block;
}

.rm-layout-masonry .rm-ig-item {
    break-inside: avoid;
    margin-bottom: 20px;
    aspect-ratio: auto;
}

.rm-layout-masonry .rm-ig-item img {
    height: auto;
}

/* --- MOSAIC LAYOUT --- */
.rm-layout-mosaic {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 250px;
    gap: 10px;
}

.rm-layout-mosaic .rm-ig-item {
    aspect-ratio: unset;
    height: 100%;
}

.rm-layout-mosaic .rm-ig-item:nth-child(5n+1) {
    grid-column: span 2;
    grid-row: span 2;
}

/* --- CUSTOM MOSAIC LAYOUT (User Requested) --- */
.rm-layout-custom-mosaic {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    grid-template-rows: repeat(2, 250px);
    gap: 10px;
    grid-template-areas:
        "pos1 pos2 large large card"
        "pos4 pos5 large large pos6";
}

.rm-layout-custom-mosaic .rm-item-0 {
    grid-area: pos1;
}

.rm-layout-custom-mosaic .rm-item-1 {
    grid-area: pos2;
}

.rm-layout-custom-mosaic .rm-item-2 {
    grid-area: large;
}

.rm-layout-custom-mosaic .rm-item-3 {
    grid-area: pos4;
}

.rm-layout-custom-mosaic .rm-item-4 {
    grid-area: pos5;
}

.rm-layout-custom-mosaic .rm-item-5 {
    grid-area: pos6;
}

.rm-layout-custom-mosaic .rm-item-card {
    grid-area: card;
}

.rm-layout-custom-mosaic .rm-ig-item {
    aspect-ratio: unset;
    height: 100%;
    width: 100%;
}

/* Ensure images always cover the tile */
.rm-layout-custom-mosaic .rm-ig-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Custom Tile Styling */
.rm-ig-custom-tile {
    background-color: #C1A57B;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #fff;
    text-decoration: none;
    font-family: sans-serif;
    text-align: center;
    height: 100%;
    width: 100%;
}

.rm-ig-custom-tile i,
.rm-ig-custom-tile svg {
    font-size: 32px;
    margin-bottom: 10px;
}

.rm-ig-custom-tile span {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.rm-ig-custom-tile:hover {
    opacity: 0.9;
}

/* Responsive */
@media (max-width: 1024px) {
    .rm-layout-custom-mosaic {
        /* Keep 5 columns but reduce row height to fit smaller screens */
        grid-template-rows: repeat(2, 200px);
    }
}

@media (max-width: 768px) {
    .rm-ig-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .rm-layout-masonry {
        column-count: 2;
    }

    .rm-layout-mosaic {
        grid-template-columns: repeat(2, 1fr);
        grid-auto-rows: 200px;
    }

    .rm-layout-mosaic .rm-ig-item:nth-child(5n+1) {
        grid-column: span 2;
        grid-row: span 2;
    }

    /* Custom Mosaic Mobile: 2 columns, 4 rows */
    .rm-layout-custom-mosaic {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(4, 200px);
        grid-template-areas:
            "pos1 pos2"
            "large large"
            "pos4 pos5"
            "pos6 card";
    }
}

@media (max-width: 480px) {
    .rm-ig-grid {
        grid-template-columns: 1fr;
    }

    .rm-layout-masonry {
        column-count: 1;
    }
}

/* --- LIGHTBOX --- */
.rm-ig-lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
}

.rm-ig-lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
}

.rm-ig-lightbox-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    background: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.rm-ig-media-container {
    width: 100%;
    height: auto;
    display: flex;
    justify-content: center;
    align-items: center;
}

.rm-ig-media-container img,
.rm-ig-media-container video {
    max-width: 100%;
    max-height: 80vh;
    border-radius: 4px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.rm-ig-caption {
    color: #fff;
    margin-top: 15px;
    text-align: center;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    max-width: 600px;
}

.rm-ig-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: #fff;
    font-size: 36px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: transform 0.2s;
}

.rm-ig-close:hover {
    transform: scale(1.1);
}