/* MK Gallery Frontend Styles */

.mk-gallery-wrap {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 20px;
}

.mk-gallery-container {
    position: relative;
}

/* Gallery Grid */
.mk-gallery-grid {
    margin: 0;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mk-gallery-grid.isotope-initialized {
    opacity: 1;
}

/* Column layouts */
.mk-gallery-item {
    margin: 0 0 20px 0;
    float: left;
    padding: 0 10px;
    box-sizing: border-box;
}

/* 2 columns */
.mk-columns-2 .mk-gallery-item {
    width: 50%;
}

/* 3 columns (default) */
.mk-columns-3 .mk-gallery-item {
    width: 33.333%;
}

/* 4 columns */
.mk-columns-4 .mk-gallery-item {
    width: 25%;
}

/* 5 columns */
.mk-columns-5 .mk-gallery-item {
    width: 20%;
}

/* 6 columns */
.mk-columns-6 .mk-gallery-item {
    width: 16.666%;
}

/* Project Box */
.mk-gallery-project {
    position: relative;
    overflow: hidden;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.mk-gallery-project:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.15);
}

.mk-gallery-project-image {
    position: relative;
    overflow: hidden;
    display: block;
    background: #f0f0f0;
}

/* Modern browsers with aspect-ratio support */
@supports (aspect-ratio: 1) {
    .mk-gallery-project-image {
        aspect-ratio: 4 / 3;
    }
}

/* Fallback for older browsers */
@supports not (aspect-ratio: 1) {
    .mk-gallery-project-image {
        padding-bottom: 75%; /* 4:3 ratio */
    }
    .mk-gallery-project-image img {
        position: absolute;
        top: 0;
        left: 0;
    }
}

.mk-gallery-project-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease;
}

/* Responsive image heights for different column counts */
.mk-columns-2 .mk-gallery-project-image {
    aspect-ratio: 3 / 2;
}

.mk-columns-3 .mk-gallery-project-image {
    aspect-ratio: 4 / 3;
}

.mk-columns-4 .mk-gallery-project-image {
    aspect-ratio: 1 / 1;
}

.mk-columns-5 .mk-gallery-project-image {
    aspect-ratio: 1 / 1;
}

.mk-columns-6 .mk-gallery-project-image {
    aspect-ratio: 1 / 1;
}

.mk-gallery-project:hover .mk-gallery-project-image img {
    transform: scale(1.1);
}

/* Project Link Overlay */
.mk-gallery-project-link {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0);
    transition: background 0.3s ease;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mk-gallery-project-link:before {
    content: '\f00e';
    font-family: 'dashicons';
    font-size: 40px;
    color: #fff;
    opacity: 0;
    transform: scale(0);
    transition: all 0.3s ease;
}

.mk-gallery-project:hover .mk-gallery-project-link {
    background: rgba(0, 0, 0, 0.5);
}

.mk-gallery-project:hover .mk-gallery-project-link:before {
    opacity: 1;
    transform: scale(1);
}

/* Image Caption */
.mk-gallery-image-caption {
    padding: 15px;
    background: #fff;
    font-size: 14px;
    color: #333;
    text-align: center;
    font-weight: 500;
}

/* Pagination */
.mk-gallery-pagination {
    margin-top: 50px;
    text-align: center;
    clear: both;
    list-style: none;
    padding: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.mk-gallery-pagination li {
    display: inline-block;
    margin: 0;
}

.mk-gallery-pagination a {
    display: inline-block;
    min-width: 40px;
    height: 40px;
    line-height: 40px;
    padding: 0 12px;
    text-align: center;
    background: #fff;
    color: #666;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    text-decoration: none;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
}

.mk-gallery-pagination a:hover {
    background: #f8f8f8;
    border-color: #ccc;
    color: #333;
}

.mk-gallery-pagination a.current {
    background: #ff6b6b;
    color: #fff;
    border-color: #ff6b6b;
    pointer-events: none;
}

/* Arrow buttons */
.mk-gallery-pagination .prev-page,
.mk-gallery-pagination .next-page {
    position: relative;
    width: 40px;
    padding: 0;
    font-size: 0;
}

.mk-gallery-pagination .prev-page:before,
.mk-gallery-pagination .next-page:before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    border-top: 2px solid #666;
    border-right: 2px solid #666;
}

.mk-gallery-pagination .prev-page:before {
    transform: translate(-40%, -50%) rotate(-135deg);
}

.mk-gallery-pagination .next-page:before {
    transform: translate(-60%, -50%) rotate(45deg);
}

.mk-gallery-pagination .prev-page:hover:before,
.mk-gallery-pagination .next-page:hover:before {
    border-color: #333;
}

/* Loading state */
.mk-gallery-loading .mk-gallery-pagination {
    pointer-events: none;
    opacity: 0.6;
}

/* Responsive */
@media (max-width: 992px) {
    /* 4+ columns become 3 columns on tablets */
    .mk-columns-4 .mk-gallery-item,
    .mk-columns-5 .mk-gallery-item,
    .mk-columns-6 .mk-gallery-item {
        width: 33.333%;
    }

    /* Adjust aspect ratio for 4+ columns on tablets */
    .mk-columns-4 .mk-gallery-project-image,
    .mk-columns-5 .mk-gallery-project-image,
    .mk-columns-6 .mk-gallery-project-image {
        aspect-ratio: 4 / 3;
    }
}

@media (max-width: 768px) {
    /* All layouts become 2 columns on small tablets */
    .mk-gallery-item {
        width: 50% !important;
    }

    /* Use 1:1 aspect ratio for 2 columns on small tablets */
    .mk-gallery-project-image {
        aspect-ratio: 1 / 1;
    }
}

@media (max-width: 576px) {
    /* All layouts become 1 column on mobile */
    .mk-gallery-item {
        width: 100% !important;
    }

    .mk-gallery-wrap {
        padding: 20px 10px;
    }

    .mk-gallery-project-image {
        aspect-ratio: 3 / 2;
    }
}

/* Loading State */
.mk-gallery-grid:not(.isotope-initialized):after {
    content: 'Loading gallery...';
    display: block;
    text-align: center;
    padding: 40px;
    color: #666;
    font-size: 16px;
}

.mk-gallery-loading {
    position: relative;
}

.mk-gallery-loading:before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mk-gallery-loading:after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin: -20px 0 0 -20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #ff6b6b;
    border-radius: 50%;
    animation: mk-gallery-spin 1s linear infinite;
    z-index: 101;
}

@keyframes mk-gallery-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive pagination */
@media (max-width: 576px) {
    .mk-gallery-pagination {
        gap: 4px;
    }

    .mk-gallery-pagination a {
        min-width: 35px;
        height: 35px;
        line-height: 35px;
        padding: 0 8px;
        font-size: 13px;
    }

    .mk-gallery-pagination .prev-page,
    .mk-gallery-pagination .next-page {
        width: 35px;
    }
}
