/* ==========================================================================
   FJM Media Gallery - Frontend Styles
   Clean, modern, responsive grid & interactive lightbox.
   ========================================================================== */

/* Auto-hide default theme page title when FJM Gallery is rendered */
body:has(.fjm-gallery-wrapper) #containwrap .contain > h1,
body:has(.fjm-gallery-wrapper) .contain > h1,
body:has(.fjm-gallery-wrapper) h1:has(+ .wrap-post) {
    display: none !important;
}

.fjm-gallery-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px 10px 50px 10px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    box-sizing: border-box;
}

/* Category Filter Tabs */
.fjm-gallery-filter-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 30px;
}

.fjm-filter-btn {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
    padding: 8px 18px;
    border-radius: 9999px;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    user-select: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.fjm-filter-btn:hover {
    background: #e2e8f0;
    color: #1e293b;
    border-color: #cbd5e1;
}

.fjm-filter-btn.active {
    background: #0284c7;
    color: #ffffff;
    border-color: #0284c7;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25);
}

.fjm-filter-btn .fjm-count-badge {
    background: rgba(0, 0, 0, 0.08);
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 9999px;
    font-weight: 700;
}

.fjm-filter-btn.active .fjm-count-badge {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

/* Gallery Grid */
.fjm-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.fjm-gallery-grid.cols-2 {
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
}

.fjm-gallery-grid.cols-4 {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

/* Item Card */
.fjm-gallery-item {
    position: relative;
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    cursor: pointer;
    transition: transform 0.28s ease, box-shadow 0.28s ease, border-color 0.28s ease;
    display: flex;
    flex-direction: column;
}

.fjm-gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.1);
    border-color: #cbd5e1;
}

/* Thumbnail Container */
.fjm-item-thumb-wrap {
    position: relative;
    width: 100%;
    padding-top: 66.66%; /* 3:2 Aspect Ratio */
    background: #0f172a;
    overflow: hidden;
}

.fjm-item-thumb {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}

.fjm-gallery-item:hover .fjm-item-thumb {
    transform: scale(1.06);
}

/* Badges on Thumbnail */
.fjm-type-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    z-index: 2;
    backdrop-filter: blur(4px);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.fjm-type-badge.type-video {
    background: rgba(225, 29, 72, 0.9);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(225, 29, 72, 0.4);
}

.fjm-type-badge.type-image {
    background: rgba(15, 23, 42, 0.75);
    color: #f8fafc;
}

/* Video Play Overlay Icon */
.fjm-video-play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    width: 52px;
    height: 52px;
    background: rgba(2, 132, 199, 0.9);
    border: 3px solid rgba(255, 255, 255, 0.85);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    transition: all 0.25s ease;
    z-index: 2;
}

.fjm-video-play-overlay svg {
    margin-left: 3px;
}

.fjm-gallery-item:hover .fjm-video-play-overlay {
    background: #0284c7;
    transform: translate(-50%, -50%) scale(1.12);
    box-shadow: 0 6px 25px rgba(2, 132, 199, 0.6);
}

/* Hover Dark Overlay */
.fjm-hover-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(15, 23, 42, 0.85) 0%, rgba(15, 23, 42, 0.1) 60%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
    display: flex;
    align-items: flex-end;
    padding: 16px;
}

.fjm-gallery-item:hover .fjm-hover-overlay {
    opacity: 1;
}

.fjm-overlay-zoom-btn {
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 12px;
    border-radius: 6px;
    backdrop-filter: blur(4px);
}

/* Item Card Body / Meta */
.fjm-item-body {
    padding: 14px 16px 16px 16px;
    background: #ffffff;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.fjm-item-category {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #0284c7;
    margin-bottom: 4px;
}

.fjm-item-title {
    font-size: 15px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.4;
    margin: 0 0 6px 0;
}

.fjm-item-caption {
    font-size: 12.5px;
    color: #64748b;
    line-height: 1.45;
    margin: 0;
}

/* Empty State */
.fjm-gallery-empty {
    text-align: center;
    padding: 60px 20px;
    background: #f8fafc;
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    color: #64748b;
    grid-column: 1 / -1;
}
.fjm-gallery-empty-icon {
    font-size: 40px;
    margin-bottom: 10px;
}

/* ==========================================================================
   FJM Interactive Lightbox (Zero Library, Pure Fast Vanilla)
   ========================================================================== */

.fjm-lightbox-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(10, 15, 29, 0.96);
    backdrop-filter: blur(8px);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    user-select: none;
}

.fjm-lightbox-backdrop.fjm-lb-active {
    opacity: 1;
    pointer-events: auto;
}

/* Top Bar: Counter & Close */
.fjm-lb-topbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10;
}

.fjm-lb-counter {
    font-size: 13.5px;
    color: #94a3b8;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.fjm-lb-close-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.2s ease;
    outline: none;
}

.fjm-lb-close-btn:hover {
    background: rgba(239, 68, 68, 0.9);
    transform: scale(1.08);
}

/* Main Display Container */
.fjm-lb-main-container {
    position: relative;
    max-width: 90vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.fjm-lb-media-wrap {
    max-width: 100%;
    max-height: 72vh;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.fjm-lb-img {
    max-width: 100%;
    max-height: 72vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    display: block;
    animation: fjmFadeIn 0.22s ease-out;
}

.fjm-lb-video-frame {
    width: 76vw;
    max-width: 900px;
    aspect-ratio: 16 / 9;
    border: none;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    animation: fjmFadeIn 0.22s ease-out;
}

.fjm-lb-video-html5 {
    max-width: 100%;
    max-height: 72vh;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
    animation: fjmFadeIn 0.22s ease-out;
}

/* Navigation Arrows */
.fjm-lb-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.15);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    outline: none;
    z-index: 10;
}

.fjm-lb-nav-btn:hover {
    background: #0284c7;
    border-color: #0284c7;
    transform: translateY(-50%) scale(1.1);
}

.fjm-lb-prev {
    left: 20px;
}

.fjm-lb-next {
    right: 20px;
}

/* Bottom Caption Bar */
.fjm-lb-caption-bar {
    margin-top: 14px;
    text-align: center;
    max-width: 760px;
    padding: 0 16px;
}

.fjm-lb-title {
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    margin: 0 0 4px 0;
}

.fjm-lb-meta {
    font-size: 13px;
    color: #94a3b8;
    line-height: 1.4;
    margin: 0;
}

.fjm-lb-category-tag {
    display: inline-block;
    background: rgba(2, 132, 199, 0.25);
    color: #38bdf8;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    margin-right: 8px;
    text-transform: uppercase;
}

/* Animation */
@keyframes fjmFadeIn {
    from {
        opacity: 0;
        transform: scale(0.96);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .fjm-gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
    .fjm-filter-btn {
        font-size: 12px;
        padding: 6px 14px;
    }
    .fjm-item-body {
        padding: 10px 12px;
    }
    .fjm-item-title {
        font-size: 13.5px;
    }
    .fjm-lb-nav-btn {
        width: 38px;
        height: 38px;
    }
    .fjm-lb-prev {
        left: 8px;
    }
    .fjm-lb-next {
        right: 8px;
    }
    .fjm-lb-video-frame {
        width: 92vw;
    }
}

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