/* Filterable Gallery Styles - Updated Version with Content Overlay */

/* ==========================================
   MAIN WRAPPER & LAYOUT
   ========================================== */

.fg-gallery-wrapper {
    display: flex;
    width: 100%;
    min-height: 500px;
}

/* Sidebar Positions */
.fg-gallery-wrapper.fg-sidebar-left {
    flex-direction: row;
}

.fg-gallery-wrapper.fg-sidebar-left .fg-gallery-sidebar {
    padding-right: 60px; /* Default - can be overridden by Elementor control */
    min-width: 250px;
}

.fg-gallery-wrapper.fg-sidebar-right {
    flex-direction: row-reverse;
}

.fg-gallery-wrapper.fg-sidebar-right .fg-gallery-sidebar {
    padding-left: 60px; /* Default - can be overridden by Elementor control */
    min-width: 250px;
}

.fg-gallery-wrapper.fg-sidebar-top {
    flex-direction: column;
}

.fg-gallery-wrapper.fg-sidebar-top .fg-gallery-sidebar {
    padding-bottom: 40px; /* Default - can be overridden by Elementor control */
}

.fg-gallery-wrapper.fg-sidebar-top .fg-filter-menu {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
}

/* ==========================================
   SIDEBAR & FILTERS
   ========================================== */

.fg-gallery-sidebar {
    flex-shrink: 0;
}

/* ==========================================
   STICKY SIDEBAR
   ========================================== */

.fg-gallery-wrapper.fg-sticky-enabled .fg-gallery-sidebar {
    position: -webkit-sticky;
    position: sticky;
    top: 30px; /* Default, will be overridden by JS/inline styles */
    align-self: flex-start;
    z-index: 10;
    transition: background-color 0.3s ease, padding 0.3s ease;
}

/* When sticky class is added (via JS for additional control) */
.fg-gallery-sidebar.fg-sticky {
    /* Additional styles when actively sticky */
}

/* Disable sticky for top position - doesn't make sense for horizontal layout */
.fg-gallery-wrapper.fg-sidebar-top.fg-sticky-enabled .fg-gallery-sidebar {
    position: relative;
    top: auto;
}

.fg-gallery-heading {
    font-size: 48px;
    font-weight: 700;
    margin: 0 0 40px 0;
    letter-spacing: 2px;
    line-height: 1.2;
}

.fg-filter-menu {
    display: flex;
    flex-direction: column;
}

.fg-gallery-wrapper.fg-sidebar-top .fg-filter-menu {
    flex-direction: row;
}

.fg-filter-item {
    font-size: 18px;
    font-weight: 400;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    padding-bottom: 5px;
    margin-bottom: 15px;
    display: inline-block;
}

.fg-filter-item:hover {
    opacity: 0.7;
}

.fg-filter-item.active {
    font-weight: 500;
}

.fg-filter-item.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 30px;
    height: 2px;
    background-color: #e91e63;
}

/* ==========================================
   GALLERY MAIN AREA
   ========================================== */

.fg-gallery-main {
    flex: 1;
    min-width: 0;
}

/* ==========================================
   CATEGORY INFO (Heading & Description above gallery)
   ========================================== */

.fg-category-info {
    margin-bottom: 30px;
    transition: opacity 0.3s ease;
}

.fg-category-info-heading {
    font-size: 36px;
    font-weight: 700;
    margin: 0 0 15px 0;
    padding: 0;
    color: #000000;
    line-height: 1.2;
}

.fg-category-info-description {
    font-size: 18px;
    font-weight: 400;
    margin: 0;
    padding: 0;
    color: #333333;
    line-height: 1.6;
    max-width: 800px;
}

/* Hide category info when empty */
.fg-category-info:empty {
    display: none;
    margin: 0;
}

/* Gallery Grid Container */
.fg-gallery-grid {
    width: 100%;
    margin: -15px;
    position: relative;
}

/* Clear floats */
.fg-gallery-grid::after {
    content: '';
    display: table;
    clear: both;
}

/* ==========================================
   GALLERY ITEMS - BASE STYLES
   ========================================== */

.fg-gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 0;
    background-color: #f5f5f5;
    margin: 15px;
    float: left;
}

/* Isotope hidden state for filtering */
.fg-gallery-item.isotope-hidden {
    opacity: 0 !important;
    pointer-events: none;
}

/* Item Links & Images */
.fg-gallery-item a.fg-item-link {
    display: block;
    height: 100%;
    width: 100%;
    position: relative;
    text-decoration: none;
}

/* Image wrapper */
.fg-item-image-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.fg-item-image-wrapper a.fg-item-link {
    display: block;
    width: 100%;
    height: 100%;
}

/* When content is below, image wrapper takes specific height */
.fg-content-style-below .fg-gallery-item {
    height: auto !important;
    display: flex;
    flex-direction: column;
}

.fg-content-style-below .fg-item-image-wrapper {
    height: 280px; /* Will be overridden by Elementor setting */
    flex-shrink: 0;
}

.fg-gallery-item a.glightbox {
    cursor: zoom-in;
}

.fg-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hidden gallery links */
.fg-hidden-gallery-link {
    display: none !important;
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

/* Elementor Popup link */
.fg-gallery-item a.fg-elementor-popup-link {
    cursor: pointer;
}

/* Masonry Layout - Fixed height, variable width based on image aspect ratio */
.fg-gallery-grid.fg-layout-masonry .fg-gallery-item {
    /* Width is calculated by JS based on image aspect ratio */
    flex-shrink: 0;
}

.fg-gallery-grid.fg-layout-masonry .fg-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ==========================================
   COLUMN WIDTHS
   ========================================== */

/* 1 Column */
.fg-gallery-grid.fg-columns-1 .fg-gallery-item {
    width: calc(100% - 30px);
}

/* 2 Columns */
.fg-gallery-grid.fg-columns-2 .fg-gallery-item {
    width: calc(50% - 30px);
}

/* 3 Columns */
.fg-gallery-grid.fg-columns-3 .fg-gallery-item {
    width: calc(33.333% - 30px);
}

/* 4 Columns */
.fg-gallery-grid.fg-columns-4 .fg-gallery-item {
    width: calc(25% - 30px);
}

/* Masonry Layout - Override column widths, use JS-calculated widths */
.fg-gallery-grid.fg-layout-masonry.fg-columns-1 .fg-gallery-item,
.fg-gallery-grid.fg-layout-masonry.fg-columns-2 .fg-gallery-item,
.fg-gallery-grid.fg-layout-masonry.fg-columns-3 .fg-gallery-item,
.fg-gallery-grid.fg-layout-masonry.fg-columns-4 .fg-gallery-item {
    width: auto; /* Let JavaScript control the width */
}

/* ==========================================
   ITEM HEIGHTS & SIZES
   ========================================== */

/* Default Normal Size - All Layouts */
.fg-gallery-item {
    height: 280px;
}

/* Masonry Layout - FIXED HEIGHT, widths calculated by JS based on aspect ratio */
.fg-gallery-grid.fg-layout-masonry .fg-gallery-item {
    height: 280px;
    /* Width is calculated by JavaScript based on image aspect ratio */
}

/* Grid Layout - Custom height support */
.fg-gallery-grid.fg-layout-fitRows .fg-gallery-item {
    height: 280px;
}

/* Packery Layout */
.fg-gallery-grid.fg-layout-packery .fg-gallery-item {
    height: 280px;
}

/* For masonry, ignore manual size settings - JS calculates based on actual image */
.fg-gallery-grid.fg-layout-masonry .fg-gallery-item.fg-size-wide,
.fg-gallery-grid.fg-layout-masonry .fg-gallery-item.fg-size-tall,
.fg-gallery-grid.fg-layout-masonry .fg-gallery-item.fg-size-big {
    /* All items have same height, width auto-calculated */
}

/* Wide Items (Full Width) - For Packery */
.fg-gallery-grid.fg-layout-packery .fg-gallery-item.fg-size-wide {
    width: calc(100% - 30px) !important;
}

/* Tall Items (Double Height) - For Packery */
.fg-gallery-grid.fg-layout-packery .fg-gallery-item.fg-size-tall {
    height: 575px; /* 280px * 2 + 15px gap */
}

/* Big Items (Full Width + Double Height) - For Packery */
.fg-gallery-grid.fg-layout-packery .fg-gallery-item.fg-size-big {
    width: calc(100% - 30px) !important;
    height: 575px;
}

/* Grid Layout - Sizes (optional) */
.fg-gallery-grid.fg-layout-fitRows .fg-gallery-item.fg-size-wide,
.fg-gallery-grid.fg-layout-fitRows .fg-gallery-item.fg-size-tall,
.fg-gallery-grid.fg-layout-fitRows .fg-gallery-item.fg-size-big {
    /* Grid keeps uniform sizes */
}

/* ==========================================
   CONTENT OVERLAY STYLES
   ========================================== */

.fg-item-overlay {
    position: absolute;
    left: 0;
    right: 0;
    display: flex;
    align-items: flex-end;
    pointer-events: none;
    z-index: 5;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Position variants */
.fg-item-overlay.fg-position-bottom {
    bottom: 0;
    top: auto;
    align-items: flex-end;
}

.fg-item-overlay.fg-position-top {
    top: 0;
    bottom: auto;
    align-items: flex-start;
}

.fg-item-overlay.fg-position-center {
    top: 0;
    bottom: 0;
    align-items: center;
    justify-content: center;
}

.fg-item-content {
    width: 100%;
    padding: 15px;
    background: rgba(0, 0, 0, 0.6);
    text-align: left;
}

.fg-item-overlay.fg-position-center .fg-item-content {
    text-align: center;
    background: rgba(0, 0, 0, 0.7);
    width: auto;
    max-width: 90%;
    border-radius: 4px;
}

.fg-item-header {
    margin: 0 0 8px 0;
    padding: 0;
    font-size: 18px;
    font-weight: 600;
    color: #ffffff;
    line-height: 1.3;
}

.fg-item-caption {
    margin: 0;
    padding: 0;
    font-size: 14px;
    font-weight: 400;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.5;
}

/* Content on hover only */
.fg-gallery-grid.fg-content-hover .fg-item-overlay {
    opacity: 0;
    transform: translateY(10px);
}

.fg-gallery-grid.fg-content-hover .fg-gallery-item:hover .fg-item-overlay {
    opacity: 1;
    transform: translateY(0);
}

/* Content always visible */
.fg-gallery-grid.fg-content-always .fg-item-overlay {
    opacity: 1;
}

/* ==========================================
   TEXT BELOW IMAGE STYLE
   ========================================== */

.fg-item-text-below {
    padding: 15px 0 5px 0;
    background-color: transparent;
}

.fg-item-text-below .fg-item-header {
    font-size: 20px;
    font-weight: 600;
    color: #000000;
    margin: 0 0 8px 0;
    line-height: 1.3;
}

.fg-item-text-below .fg-item-caption {
    font-size: 14px;
    font-weight: 400;
    color: #666666;
    margin: 0;
    line-height: 1.5;
}

/* ==========================================
   HOVER EFFECTS
   ========================================== */

.fg-gallery-grid.fg-hover-zoom .fg-gallery-item:hover img {
    transform: scale(1.1);
}

.fg-gallery-grid.fg-hover-opacity .fg-gallery-item:hover {
    opacity: 0.8;
}

.fg-gallery-grid.fg-hover-none .fg-gallery-item:hover img {
    transform: none;
}

/* ==========================================
   RESPONSIVE - TABLET
   ========================================== */

@media (max-width: 1024px) {
    /* Stack sidebar on tablet */
    .fg-gallery-wrapper.fg-sidebar-left,
    .fg-gallery-wrapper.fg-sidebar-right {
        flex-direction: column;
    }
    
    .fg-gallery-wrapper.fg-sidebar-left .fg-gallery-sidebar,
    .fg-gallery-wrapper.fg-sidebar-right .fg-gallery-sidebar {
        padding: 0 0 30px 0;
        min-width: auto;
    }
    
    /* Disable sticky on tablet - layout becomes stacked */
    .fg-gallery-wrapper.fg-sticky-enabled .fg-gallery-sidebar {
        position: relative;
        top: auto;
    }
    
    /* Reduce heading size */
    .fg-gallery-heading {
        font-size: 36px;
        margin-bottom: 30px;
    }
    
    /* Horizontal filter menu */
    .fg-filter-menu {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 15px;
    }
    
    .fg-filter-item {
        margin-bottom: 0;
    }
    
    /* Category info tablet */
    .fg-category-info {
        margin-bottom: 25px;
    }
    
    .fg-category-info-heading {
        font-size: 28px;
    }
    
    .fg-category-info-description {
        font-size: 16px;
    }
    
    /* Smaller item heights */
    .fg-gallery-item {
        height: 220px;
    }
    
    /* Masonry - Fixed height on tablet (JS will recalculate widths) */
    .fg-gallery-grid.fg-layout-masonry .fg-gallery-item {
        /* Height is controlled by Elementor setting via inline styles */
        /* Width is auto-calculated by JavaScript */
    }
    
    /* Packery - Can have different heights */
    .fg-gallery-grid.fg-layout-packery .fg-gallery-item {
        height: 220px;
    }
    
    .fg-gallery-grid.fg-layout-packery .fg-gallery-item.fg-size-tall {
        height: 455px; /* 220px * 2 + 15px */
    }
    
    .fg-gallery-grid.fg-layout-packery .fg-gallery-item.fg-size-big {
        height: 455px;
    }
    
    /* 3-4 columns become 2 columns */
    .fg-gallery-grid.fg-columns-3 .fg-gallery-item,
    .fg-gallery-grid.fg-columns-4 .fg-gallery-item {
        width: calc(50% - 30px);
    }
    
    /* Packery wide items on tablet */
    .fg-gallery-grid.fg-columns-3.fg-layout-packery .fg-gallery-item.fg-size-wide,
    .fg-gallery-grid.fg-columns-4.fg-layout-packery .fg-gallery-item.fg-size-wide {
        width: calc(100% - 30px) !important;
    }

    /* Content overlay adjustments */
    .fg-item-header {
        font-size: 16px;
    }
    
    .fg-item-caption {
        font-size: 13px;
    }
    
    /* Text below adjustments */
    .fg-item-text-below .fg-item-header {
        font-size: 18px;
    }
    
    .fg-item-text-below .fg-item-caption {
        font-size: 13px;
    }
}

/* ==========================================
   RESPONSIVE - MOBILE
   ========================================== */

@media (max-width: 768px) {
    /* Smaller heading */
    .fg-gallery-heading {
        font-size: 28px;
        margin-bottom: 20px;
    }
    
    .fg-filter-item {
        font-size: 16px;
    }
    
    /* Category info mobile */
    .fg-category-info {
        margin-bottom: 20px;
    }
    
    .fg-category-info-heading {
        font-size: 24px;
        margin-bottom: 10px;
    }
    
    .fg-category-info-description {
        font-size: 14px;
    }
    
    /* Tighter margins */
    .fg-gallery-grid {
        margin: -10px;
    }
    
    .fg-gallery-item {
        margin: 10px;
        height: 200px;
    }
    
    /* Masonry on mobile - maintain aspect ratios with fixed height from JS */
    .fg-gallery-grid.fg-layout-masonry .fg-gallery-item {
        /* Height and width controlled by JS based on aspect ratio */
        max-width: calc(100% - 20px); /* Prevent overflow */
    }
    
    /* Grid and Packery - All columns become single or double column */
    .fg-gallery-grid.fg-layout-fitRows .fg-gallery-item,
    .fg-gallery-grid.fg-layout-packery .fg-gallery-item {
        width: calc(100% - 20px);
        height: 200px;
    }
    
    /* Reset all special sizes on mobile for non-masonry */
    .fg-gallery-grid.fg-layout-fitRows .fg-gallery-item.fg-size-wide,
    .fg-gallery-grid.fg-layout-fitRows .fg-gallery-item.fg-size-tall,
    .fg-gallery-grid.fg-layout-fitRows .fg-gallery-item.fg-size-big,
    .fg-gallery-grid.fg-layout-packery .fg-gallery-item.fg-size-wide,
    .fg-gallery-grid.fg-layout-packery .fg-gallery-item.fg-size-tall,
    .fg-gallery-grid.fg-layout-packery .fg-gallery-item.fg-size-big {
        width: calc(100% - 20px) !important;
        height: 200px !important;
    }

    /* Content overlay adjustments */
    .fg-item-content {
        padding: 12px;
    }
    
    .fg-item-header {
        font-size: 15px;
        margin-bottom: 5px;
    }
    
    .fg-item-caption {
        font-size: 12px;
    }
    
    /* Text below mobile adjustments */
    .fg-item-text-below {
        padding: 12px 0 5px 0;
    }
    
    .fg-item-text-below .fg-item-header {
        font-size: 16px;
    }
    
    .fg-item-text-below .fg-item-caption {
        font-size: 12px;
    }
}

/* ==========================================
   RESPONSIVE - SMALL MOBILE
   ========================================== */

@media (max-width: 480px) {
    .fg-gallery-heading {
        font-size: 24px;
        letter-spacing: 1px;
    }
    
    .fg-filter-item {
        font-size: 14px;
    }
    
    .fg-gallery-item {
        height: 180px;
    }
    
    /* Masonry on small mobile */
    .fg-gallery-grid.fg-layout-masonry .fg-gallery-item {
        /* Height and width controlled by JS */
        max-width: calc(100% - 20px);
    }
    
    /* Grid and Packery */
    .fg-gallery-grid.fg-layout-fitRows .fg-gallery-item,
    .fg-gallery-grid.fg-layout-packery .fg-gallery-item {
        height: 180px;
    }
    
    .fg-gallery-grid.fg-layout-fitRows .fg-gallery-item.fg-size-wide,
    .fg-gallery-grid.fg-layout-fitRows .fg-gallery-item.fg-size-tall,
    .fg-gallery-grid.fg-layout-fitRows .fg-gallery-item.fg-size-big,
    .fg-gallery-grid.fg-layout-packery .fg-gallery-item.fg-size-wide,
    .fg-gallery-grid.fg-layout-packery .fg-gallery-item.fg-size-tall,
    .fg-gallery-grid.fg-layout-packery .fg-gallery-item.fg-size-big {
        height: 180px !important;
    }

    /* Content overlay adjustments */
    .fg-item-content {
        padding: 10px;
    }
    
    .fg-item-header {
        font-size: 14px;
        margin-bottom: 4px;
    }
    
    .fg-item-caption {
        font-size: 11px;
        line-height: 1.4;
    }
    
    /* Text below small mobile adjustments */
    .fg-item-text-below {
        padding: 10px 0 5px 0;
    }
    
    .fg-item-text-below .fg-item-header {
        font-size: 14px;
    }
    
    .fg-item-text-below .fg-item-caption {
        font-size: 11px;
    }
}

/* ==========================================
   INITIAL LOAD FADE-IN
   ========================================== */

/* Hide items before Isotope positions them */
.fg-gallery-grid .fg-gallery-item {
    opacity: 0;
}

/* Fade in items after layout is complete */
.fg-gallery-grid.fg-loaded .fg-gallery-item {
    opacity: 1;
    transition: opacity 0.6s ease;
}

/* ==========================================
   LOADING STATE (OPTIONAL)
   ========================================== */

.fg-gallery-grid.loading {
    min-height: 400px;
    position: relative;
}

.fg-gallery-grid.loading::before {
    content: 'Loading...';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 18px;
    color: #999;
}

/* ==========================================
   LOAD MORE BUTTON
   ========================================== */

.fg-load-more-wrapper {
    text-align: center;
    margin-top: 30px;
    padding: 0 15px;
    width: 100%;
    clear: both;
}

.fg-load-more-btn {
    display: inline-block;
    padding: 12px 30px;
    background-color: #e91e63;
    color: #ffffff;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
    text-transform: none;
    letter-spacing: 0.5px;
}

.fg-load-more-btn:hover {
    background-color: #c2185b;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(233, 30, 99, 0.3);
}

.fg-load-more-btn:active {
    transform: translateY(0);
}

.fg-load-more-btn:focus {
    outline: 2px solid rgba(233, 30, 99, 0.5);
    outline-offset: 2px;
}

/* Hidden items - Isotope handles visibility via data-visible attribute */
/* No CSS needed - Isotope's filter handles show/hide */

/* Loading state for button */
.fg-load-more-btn.loading {
    opacity: 0.7;
    pointer-events: none;
    position: relative;
}

.fg-load-more-btn.loading::after {
    content: '';
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-left: 10px;
    border: 2px solid #ffffff;
    border-top-color: transparent;
    border-radius: 50%;
    animation: fg-spin 0.8s linear infinite;
    vertical-align: middle;
}

@keyframes fg-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==========================================
   RESPONSIVE - LOAD MORE BUTTON
   ========================================== */

@media (max-width: 768px) {
    .fg-load-more-wrapper {
        margin-top: 20px;
    }
    
    .fg-load-more-btn {
        padding: 10px 25px;
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .fg-load-more-btn {
        padding: 10px 20px;
        font-size: 13px;
        width: 100%;
        max-width: 200px;
    }
}

/* ==========================================
   CATEGORY LABEL (For "All" View)
   ========================================== */

.fg-category-label {
    display: none;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    color: #ffffff;
    padding: 40px 15px 15px 15px;
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    z-index: 5;
    pointer-events: none;
}

/* Show category labels when in "All" one-per-category mode */
.fg-gallery-wrapper.fg-show-category-labels .fg-category-label {
    display: block;
}

/* Hide regular content when showing category labels */
.fg-gallery-wrapper.fg-show-category-labels .fg-item-overlay,
.fg-gallery-wrapper.fg-show-category-labels .fg-item-text-below {
    display: none !important;
}

/* Responsive category label */
@media (max-width: 768px) {
    .fg-category-label {
        font-size: 14px;
        padding: 30px 10px 10px 10px;
    }
}

@media (max-width: 480px) {
    .fg-category-label {
        font-size: 13px;
        padding: 25px 8px 8px 8px;
    }
}

/* ==========================================
   CATEGORY COVER ITEMS (for "All" View)
   ========================================== */

/* Cover items are hidden by default, shown only in "All" one-per-category mode */
.fg-category-cover-item {
    display: none;
}

/* When Isotope reveals them via filter, allow display */
.fg-gallery-wrapper.fg-covers-active .fg-category-cover-item {
    display: block;
}
