/**
 * Bek Portfolio Gallery Styles - Masonry Layout with Landscape Handling
 * 
 * CSS for the admin interface and front-end display of the portfolio gallery
 */
/* Admin Styles */
.bek-portfolio-gallery-images {
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 15px;
}
.bek-gallery-image-item {
    position: relative;
    width: 150px;
    height: 150px;
    margin: 0 10px 10px 0;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 3px;
    cursor: move;
    overflow: hidden;
}
.bek-gallery-image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.bek-remove-image {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 20px;
    height: 20px;
    background-color: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 16px;
    line-height: 18px;
    text-align: center;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}
.bek-gallery-image-item:hover .bek-remove-image {
    opacity: 1;
}
.bek-gallery-tools {
    margin: 15px 0;
    display: flex;
    gap: 10px;
}
.bek-portfolio-gallery-container {
    margin-bottom: 20px;
}

/**
 * Bek Portfolio Gallery Styles - Masonry Layout (FIXED)
 * 
 * Fixed version that addresses:
 * 1. The spinner issue
 * 2. The hover movement problem
 */

/* Container styles */
.bek-portfolio-gallery-container {
    margin-bottom: 20px;
    width: 100%;
}

/* Main gallery styling */
.bek-portfolio-gallery {
    opacity: 0;
    transition: opacity 0.3s ease-in;
    width: 100%!important;
    position: relative;
    min-height: 500px; /* Prevents container collapse during loading */
}

.bek-portfolio-gallery.images-loaded {
    opacity: 1;
}

/* Gallery item styling */
.bek-portfolio-gallery .bek-gallery-item {
    position: absolute; /* Essential for masonry positioning */
    overflow: hidden;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: transform 0.3s ease; /* JS handles the transform changes */
    will-change: transform; /* Optimizes for animation performance */
}

/* Image styling */
.bek-portfolio-gallery .bek-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

/* Link styling */
.bek-portfolio-gallery .bek-gallery-link {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
    z-index: 1;
}

/* Hover effects for images only (position handled by JS) */
.bek-portfolio-gallery .bek-gallery-item:hover img {
    transform: scale(1.03);
}

/* Add a subtle overlay on hover */
.bek-portfolio-gallery .bek-gallery-item::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0);
    transition: background-color 0.3s ease;
    pointer-events: none;
}

.bek-portfolio-gallery .bek-gallery-item:hover::after {
    background-color: rgba(0, 0, 0, 0.1);
}

/* Loading spinner */
.bek-portfolio-gallery::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid rgba(0,0,0,0.1);
    border-top-color: rgba(0,0,0,0.3);
    border-radius: 50%;
    animation: spinner 0.6s linear infinite;
    opacity: 1;
    transition: opacity 0.3s ease-out;
    z-index: 1;
}

/* Hide spinner when images are loaded */
.bek-portfolio-gallery.images-loaded::before {
    opacity: 0;
    pointer-events: none;
    animation: none;
}

@keyframes spinner {
    to {transform: rotate(360deg);}
}

/* === Responsive settings === */

/* Desktop (default): 5 columns - handled by JavaScript */

/* Tablet: 3 columns - handled by JavaScript */
@media (max-width: 992px) {
    /* Additional tablet-specific styles can go here */
}

/* Mobile: 2 columns - handled by JavaScript */
@media (max-width: 576px) {
    /* Additional mobile-specific styles can go here */
}

/* For very small screens */
@media (max-width: 400px) {
    .bek-portfolio-gallery .bek-gallery-item {
        border-radius: 3px;
    }
}

/* Disable transitions during resize operations for smoother experience */
.bek-gallery-resizing .bek-gallery-item {
    transition: none !important;
}

/* Increase z-index during hover to ensure item stays above others */
.bek-portfolio-gallery .bek-gallery-item:hover {
    z-index: 10;
}

/* Disable any pointer events during resize to prevent glitches */
.bek-gallery-resizing .bek-gallery-item {
    pointer-events: none;
}

/* Re-enable pointer events after resize is complete */
body:not(.bek-gallery-resizing) .bek-gallery-item {
    pointer-events: auto;
}