/* ============================================================
   Media Gallery Pro – gallery.css  v1.1 (image-fix)
   ============================================================ */

.mgp-gallery-wrap {
    --mgp-primary:    #0ea5e9;
    --mgp-primary-dk: #0284c7;
    --mgp-bg:         #0f172a;
    --mgp-surface:    #1e293b;
    --mgp-border:     rgba(255,255,255,.10);
    --mgp-text:       #f1f5f9;
    --mgp-muted:      #94a3b8;
    --mgp-radius:     12px;
    --mgp-gap:        16px;
    --mgp-transition: .28s cubic-bezier(.4,0,.2,1);

    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: var(--mgp-text);
    box-sizing: border-box;
    width: 100%;
}
.mgp-gallery-wrap *,
.mgp-gallery-wrap *::before,
.mgp-gallery-wrap *::after { box-sizing: inherit; }

/* ── FILTER TABS ── */
.mgp-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 28px;
}
.mgp-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border: 1.5px solid var(--mgp-border);
    border-radius: 100px;
    background: transparent;
    color: var(--mgp-muted);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: .02em;
    cursor: pointer;
    transition: all var(--mgp-transition);
    white-space: nowrap;
    line-height: 1.4;
}
.mgp-filter-btn:hover {
    border-color: var(--mgp-primary);
    color: var(--mgp-primary);
    background: rgba(14,165,233,.08);
}
.mgp-filter-btn.active {
    background: var(--mgp-primary);
    border-color: var(--mgp-primary);
    color: #fff;
    box-shadow: 0 0 0 3px rgba(14,165,233,.22);
}
.mgp-count {
    display: inline-block;
    background: rgba(255,255,255,.15);
    border-radius: 100px;
    padding: 1px 7px;
    font-size: 11px;
    line-height: 1.6;
}
.mgp-filter-btn.active .mgp-count { background: rgba(255,255,255,.25); }

/* ── GRID ── */
.mgp-grid {
    display: grid;
    gap: var(--mgp-gap);
}
.mgp-cols-2 { grid-template-columns: repeat(2, 1fr); }
.mgp-cols-3 { grid-template-columns: repeat(3, 1fr); }
.mgp-cols-4 { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) {
    .mgp-cols-4 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 680px) {
    .mgp-cols-3, .mgp-cols-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 420px) {
    .mgp-cols-2, .mgp-cols-3, .mgp-cols-4 { grid-template-columns: 1fr; }
}

/* ── GRID ITEM ──
   FIX: default to visible (opacity:1). JS adds mgp-anim class
   to enable the entrance animation only after script loads.     */
.mgp-item {
    border-radius: var(--mgp-radius);
    overflow: hidden;
    cursor: pointer;
    position: relative;
    background: var(--mgp-surface);
    /* NO opacity:0 here — images must show even if JS is slow  */
    transition: box-shadow var(--mgp-transition), transform var(--mgp-transition);
}
/* Animation class added by JS after DOM ready */
.mgp-item.mgp-anim {
    opacity: 0;
    transform: translateY(16px);
    transition: opacity var(--mgp-transition), transform var(--mgp-transition);
}
.mgp-item.mgp-visible {
    opacity: 1 !important;
    transform: translateY(0) !important;
}
.mgp-item.mgp-hidden {
    display: none !important;
}
.mgp-item:hover {
    box-shadow: 0 8px 32px rgba(0,0,0,.35);
}
.mgp-item:focus {
    outline: 2px solid var(--mgp-primary);
    outline-offset: 3px;
}

/* ── THUMBNAIL WRAPPER ──
   Use padding-top hack for max theme compatibility instead of
   aspect-ratio (some older WP themes override it).             */
.mgp-item-inner {
    position: relative;
    width: 100%;
    padding-top: 75%;   /* 4:3 ratio */
    overflow: hidden;
    background: var(--mgp-surface);
    display: block;
}

/* FIX: absolute-fill the image so theme max-width resets don't break it */
.mgp-item-inner img {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;   /* override theme resets */
    object-fit: cover !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    transition: transform .45s cubic-bezier(.4,0,.2,1);
}
.mgp-item:hover .mgp-item-inner img {
    transform: scale(1.06);
}

/* ── VIDEO BADGE ── */
.mgp-video-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0,0,0,.65);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: 3px 8px;
    border-radius: 4px;
    z-index: 2;
    pointer-events: none;
}

/* ── OVERLAY ── */
.mgp-overlay {
    position: absolute;
    inset: 0;
    top: 0; left: 0; right: 0; bottom: 0;   /* IE fallback */
    background: linear-gradient(
        to top,
        rgba(15,23,42,.92) 0%,
        rgba(15,23,42,.30) 55%,
        transparent 100%
    );
    display: flex;
    align-items: flex-end;
    padding: 14px;
    opacity: 0;
    transition: opacity var(--mgp-transition);
    z-index: 3;
}
.mgp-item:hover .mgp-overlay,
.mgp-item:focus .mgp-overlay { opacity: 1; }

.mgp-overlay-content {
    width: 100%;
    transform: translateY(6px);
    transition: transform var(--mgp-transition);
}
.mgp-item:hover .mgp-overlay-content,
.mgp-item:focus .mgp-overlay-content { transform: translateY(0); }

.mgp-play-btn, .mgp-zoom-btn {
    display: block;
    width: 44px;
    height: 44px;
    margin: 0 auto 8px;
    filter: drop-shadow(0 2px 6px rgba(0,0,0,.5));
}
.mgp-item-title {
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    text-align: center;
    margin: 0 0 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}
.mgp-item-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: center;
}
.mgp-tag {
    font-size: 10px;
    background: rgba(14,165,233,.3);
    border: 1px solid rgba(14,165,233,.5);
    color: #7dd3fc;
    border-radius: 4px;
    padding: 1px 6px;
    line-height: 1.6;
}

/* ── EMPTY STATE ── */
.mgp-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--mgp-muted);
}
.mgp-empty svg { margin: 0 auto 16px; display: block; opacity: .35; }
.mgp-empty p   { font-size: 15px; margin: 0; }
.mgp-no-items  { grid-column: 1 / -1; text-align: center; color: var(--mgp-muted); padding: 40px 20px; }

/* ================================================================
   LIGHTBOX
================================================================ */
.mgp-lightbox {
    position: fixed;
    inset: 0;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    visibility: hidden;
    opacity: 0;
    transition: opacity .3s ease, visibility .3s ease;
}
.mgp-lightbox.mgp-lb-open {
    visibility: visible;
    opacity: 1;
}

.mgp-lb-backdrop {
    position: absolute;
    inset: 0;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.93);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    cursor: pointer;
}

.mgp-lb-container {
    position: relative;
    z-index: 1;
    width: min(90vw, 1100px);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

/* Buttons */
.mgp-lb-close,
.mgp-lb-prev,
.mgp-lb-next {
    position: absolute;
    background: rgba(255,255,255,.13);
    border: 1.5px solid rgba(255,255,255,.30);
    border-radius: 50%;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    line-height: 1;
    transition: background var(--mgp-transition), transform var(--mgp-transition);
    z-index: 10;
}
/* Explicit SVG styling — don't rely on color/currentColor inheritance */
.mgp-lb-close svg,
.mgp-lb-prev svg,
.mgp-lb-next svg {
    display: block;
    overflow: visible;
    stroke: #ffffff !important;
    fill: none !important;
}
.mgp-lb-close svg line,
.mgp-lb-prev svg polyline,
.mgp-lb-next svg polyline {
    stroke: #ffffff !important;
    stroke-width: 2.5px !important;
    fill: none !important;
}

/* Close button — top right corner of container */
.mgp-lb-close {
    top: -52px;
    right: 0;
    width: 42px;
    height: 42px;
}
.mgp-lb-close svg { width: 20px; height: 20px; }
.mgp-lb-close:hover {
    background: rgba(239,68,68,.65);
    border-color: rgba(239,68,68,.8);
    transform: rotate(90deg);
}

/* Prev / Next — sides of the media box, inside viewport */
.mgp-lb-prev,
.mgp-lb-next {
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
}
.mgp-lb-prev svg,
.mgp-lb-next svg { width: 22px; height: 22px; }

.mgp-lb-prev { left: -58px; }
.mgp-lb-next { right: -58px; }

.mgp-lb-prev:hover {
    background: rgba(255,255,255,.25);
    transform: translateY(-50%) translateX(-2px);
}
.mgp-lb-next:hover {
    background: rgba(255,255,255,.25);
    transform: translateY(-50%) translateX(2px);
}

/* Media area */
.mgp-lb-media {
    width: 100%;
    max-height: 72vh;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    overflow: hidden;
    background: #000;
    transform: scale(.93);
    transition: transform .35s cubic-bezier(.4,0,.2,1);
}
.mgp-lightbox.mgp-lb-open .mgp-lb-media { transform: scale(1); }

.mgp-lb-media img {
    max-width: 100% !important;
    max-height: 72vh !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain;
    display: block;
}
.mgp-lb-media iframe,
.mgp-lb-media video {
    width: 100%;
    max-height: 72vh;
    aspect-ratio: 16/9;
    display: block;
    border: none;
}

/* Info */
.mgp-lb-info { text-align: center; padding: 0 8px; width: 100%; }
.mgp-lb-title   { font-size: 16px; font-weight: 600; margin: 0 0 4px; color: #f1f5f9; }
.mgp-lb-desc    { font-size: 13px; color: #94a3b8; margin: 0 0 5px; }
.mgp-lb-counter { font-size: 12px; color: #475569; letter-spacing: .04em; }

/* Spinner */
.mgp-lb-loader {
    width: 40px; height: 40px;
    border: 3px solid rgba(255,255,255,.1);
    border-top-color: var(--mgp-primary);
    border-radius: 50%;
    animation: mgp-spin .7s linear infinite;
}
@keyframes mgp-spin { to { transform: rotate(360deg); } }

/* Mobile — keep buttons visible */
@media (max-width: 860px) {
    .mgp-lb-prev { left: -44px; width: 38px; height: 38px; }
    .mgp-lb-next { right: -44px; width: 38px; height: 38px; }
}
@media (max-width: 680px) {
    .mgp-lb-container { width: 92vw; }
    .mgp-lb-prev { left: 8px; width: 36px; height: 36px; }
    .mgp-lb-next { right: 8px; width: 36px; height: 36px; }
    .mgp-lb-close { top: -46px; right: 0; }
}
