/* =====================================================
   Media Gallery v3 — Frontend Styles
   ===================================================== */

/* ---- Outer wrapper ---- */
.mg-gallery-wrap {
    margin: 1.5em 0;
}

/* ============================================================
   TABS
   ============================================================ */
.mg-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 2px solid #e5e5e5;
    padding-bottom: 0;
}

.mg-tab {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;          /* sit on top of the border-bottom */
    padding: 8px 18px;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    cursor: pointer;
    border-radius: 4px 4px 0 0;
    transition: color .18s, border-color .18s, background .18s;
    line-height: 1.4;
    font-family: inherit;
}
.mg-tab:hover {
    color: #222;
    background: #f5f5f5;
}
.mg-tab.mg-tab-active {
    color: #2271b1;
    border-bottom-color: #2271b1;
    background: none;
}

/* Hidden items when tab filtering */
.mg-item.mg-tab-hidden {
    display: none !important;
}

/* ============================================================
   GALLERY GRID
   ============================================================ */
.mg-gallery {
    --mg-gap: 12px;
    display: grid;
    gap: var(--mg-gap);
    width: 100%;
}

.mg-cols-2 { grid-template-columns: repeat(2, 1fr); }
.mg-cols-3 { grid-template-columns: repeat(3, 1fr); }
.mg-cols-4 { grid-template-columns: repeat(4, 1fr); }
.mg-cols-5 { grid-template-columns: repeat(5, 1fr); }

/* ---- Masonry ---- */
.mg-layout-masonry {
    grid-template-columns: unset;
    columns: 3;
    column-gap: var(--mg-gap);
    display: block;
}
.mg-cols-2.mg-layout-masonry { columns: 2; }
.mg-cols-4.mg-layout-masonry { columns: 4; }
.mg-cols-5.mg-layout-masonry { columns: 5; }
.mg-layout-masonry .mg-item {
    break-inside: avoid;
    margin-bottom: var(--mg-gap);
}

/* ---- Item ---- */
.mg-item {
    position: relative;
    overflow: hidden;
    border-radius: 6px;
    cursor: pointer;
    background: #111;
}

/* ---- Thumb Wrap  (16:9 aspect ratio) ---- */
.mg-thumb-wrap {
    position: relative;
    width: 100%;
    padding-top: 56.25%;   /* 16:9 — gives a real height */
    overflow: hidden;
    background: #1e2d40;   /* fallback so placeholder is visible */
}
.mg-layout-masonry .mg-thumb-wrap {
    padding-top: 0;
    min-height: 80px;      /* give masonry items some minimum height */
}

.mg-thumb-wrap img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .35s ease;
}
.mg-layout-masonry .mg-thumb-wrap img {
    position: static;
    height: auto;
    width: 100%;
}
.mg-item:hover .mg-thumb-wrap img { transform: scale(1.04); }

/* ---- Video placeholder (shows when no poster image) ---- */
.mg-video-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e2d40, #0f1923);
}
.mg-video-placeholder svg {
    width: 56px;
    height: 56px;
    opacity: .8;
}

/* ---- Image hover overlay ---- */
.mg-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .25s;
}
.mg-item:hover .mg-overlay { background: rgba(0,0,0,.35); }

.mg-zoom {
    color: #fff;
    font-size: 30px;
    opacity: 0;
    transform: scale(.7);
    transition: opacity .2s, transform .2s;
    line-height: 1;
}
.mg-item:hover .mg-zoom { opacity: 1; transform: scale(1); }

/* ---- Play button (local video + embeds) ---- */
.mg-play-btn {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    pointer-events: none;
}
.mg-play-btn svg {
    width: 50px;
    height: 50px;
    fill: #fff;
    background: rgba(0,0,0,.45);
    border-radius: 50%;
    padding: 13px 11px 13px 15px;
    box-sizing: border-box;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,.5));
    transition: background .2s, transform .2s;
}
.mg-item:hover .mg-play-btn svg {
    background: rgba(0,0,0,.72);
    transform: scale(1.1);
}

/* ---- Provider badge ---- */
.mg-embed-badge {
    position: absolute;
    bottom: 8px;
    left: 8px;
    z-index: 3;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: 2px 7px;
    border-radius: 3px;
    pointer-events: none;
    font-family: sans-serif;
}
.mg-badge-youtube { background: #f00;    color: #fff; }
.mg-badge-vimeo   { background: #1ab7ea; color: #fff; }

/* ============================================================
   LIGHTBOX
   ============================================================ */
.mg-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mg-lb-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.92);
    cursor: pointer;
}
.mg-lb-content {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 40px 60px;
    box-sizing: border-box;
}

/* Media area */
.mg-lb-media {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 90vw;
    max-height: 85vh;
    animation: mg-fade-in .2s ease;
}
@keyframes mg-fade-in {
    from { opacity: 0; transform: scale(.96); }
    to   { opacity: 1; transform: scale(1); }
}

.mg-lb-media img,
.mg-lb-media video {
    display: block;
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 40px rgba(0,0,0,.6);
}

/* Embed iframe wrapper */
.mg-lb-embed-wrap {
    position: relative;
    width: min(90vw, 960px);
    aspect-ratio: 16 / 9;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(0,0,0,.6);
    background: #000;
}
.mg-lb-embed-wrap iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Controls */
.mg-lb-close,
.mg-lb-prev,
.mg-lb-next {
    position: absolute;
    background: rgba(255,255,255,.12);
    border: none;
    color: #fff;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s, transform .2s;
    z-index: 2;
}
.mg-lb-close { top:16px; right:16px; width:42px; height:42px; font-size:26px; line-height:1; }
.mg-lb-prev, .mg-lb-next { top:50%; transform:translateY(-50%); width:48px; height:48px; font-size:30px; }
.mg-lb-prev { left:12px; }
.mg-lb-next { right:12px; }
.mg-lb-close:hover, .mg-lb-prev:hover, .mg-lb-next:hover { background:rgba(255,255,255,.25); }
.mg-lb-prev:hover { transform:translateY(-50%) scale(1.08); }
.mg-lb-next:hover { transform:translateY(-50%) scale(1.08); }

/* Counter */
.mg-lb-counter {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255,255,255,.7);
    font-size: 13px;
    font-family: sans-serif;
    letter-spacing: .05em;
    pointer-events: none;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
    .mg-cols-4, .mg-cols-5 { grid-template-columns: repeat(2, 1fr); }
    .mg-cols-4.mg-layout-masonry, .mg-cols-5.mg-layout-masonry { columns: 2; }
    .mg-lb-embed-wrap { width: 96vw; }
}
@media (max-width: 480px) {
    .mg-cols-3, .mg-cols-4, .mg-cols-5 { grid-template-columns: repeat(2, 1fr); }
    .mg-cols-3.mg-layout-masonry { columns: 2; }
    .mg-lb-content { padding: 40px 16px; }
    .mg-lb-prev { left: 4px; }
    .mg-lb-next { right: 4px; }
    .mg-tab { padding: 6px 12px; font-size: 13px; }
}
