/**
 * Zenith Gallery - Frontend Styles
 */

/* CSS Variables */
:root {
    --zenith-columns: 4;
    --zenith-tablet-columns: 2;
    --zenith-mobile-columns: 1;
    --zenith-gap: 10px;
    --zenith-border-radius: 0px;
    --zenith-aspect-ratio: 100%;
    --zenith-overlay-bg: rgba(0, 0, 0, 0.7);
    --zenith-caption-bg: rgba(0, 0, 0, 0.8);
    --zenith-caption-color: #fff;
    --zenith-thumbnail-size: 200px;
}

/* Gallery Container */
.zenith-gallery {
    width: 100%;
    margin: 0 auto;
}

.zenith-gallery-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
    align-items: center;
}

/* Filters */
.zenith-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.zenith-filter-btn {
    padding: 8px 16px;
    border: 1px solid #ddd;
    background: #fff;
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.zenith-filter-btn:hover,
.zenith-filter-btn.active {
    background: #333;
    color: #fff;
    border-color: #333;
}

/* Sort */
.zenith-sort {
    display: flex;
    align-items: center;
    gap: 8px;
}

.zenith-sort label {
    font-size: 14px;
    color: #666;
}

.zenith-sort-select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

/* Gallery Items Container - Fill Width (default) */
.zenith-gallery-items {
    display: grid;
    grid-template-columns: repeat(var(--zenith-columns), 1fr);
    gap: var(--zenith-gap);
}

/* Center Alignment - Fixed thumbnail size, centered */
.zenith-align-center .zenith-gallery-items {
    grid-template-columns: repeat(var(--zenith-columns), var(--zenith-thumbnail-size));
    justify-content: center;
}

/* Grid Layout */
.zenith-layout-grid .zenith-gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: var(--zenith-border-radius);
}

.zenith-layout-grid .zenith-image-wrapper {
    position: relative;
    padding-bottom: var(--zenith-aspect-ratio);
    overflow: hidden;
}

/* Original aspect ratio - no forced dimensions */
.zenith-layout-grid.zenith-aspect-original .zenith-image-wrapper {
    padding-bottom: 0;
}

.zenith-layout-grid.zenith-aspect-original .zenith-gallery-image {
    position: relative;
    width: 100%;
    height: auto;
    display: block;
}

/* Contain mode - fit entire image, no cropping, with background fill */
.zenith-layout-grid.zenith-aspect-contain .zenith-image-wrapper {
    background-color: #f5f5f5;
}

.zenith-layout-grid.zenith-aspect-contain .zenith-gallery-image {
    object-fit: contain;
}

.zenith-layout-grid .zenith-gallery-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
}

/* For square aspect ratio - ensure full short edge is visible */
.zenith-layout-grid.zenith-aspect-square .zenith-gallery-image {
    object-fit: cover;
    object-position: center center;
}

/* Masonry Layout */
.zenith-layout-masonry .zenith-gallery-items {
    columns: var(--zenith-columns);
    column-gap: var(--zenith-gap);
}

.zenith-layout-masonry .zenith-gallery-item {
    break-inside: avoid;
    margin-bottom: var(--zenith-gap);
    border-radius: var(--zenith-border-radius);
    overflow: hidden;
}

.zenith-layout-masonry .zenith-image-wrapper {
    display: block;
}

.zenith-layout-masonry .zenith-gallery-image {
    width: 100%;
    height: auto;
    display: block;
}

/* Justified Layout */
.zenith-layout-justified .zenith-gallery-items {
    display: flex;
    flex-wrap: wrap;
    gap: var(--zenith-gap);
}

.zenith-layout-justified .zenith-gallery-item {
    flex-grow: 1;
    height: 200px;
    border-radius: var(--zenith-border-radius);
    overflow: hidden;
}

.zenith-layout-justified .zenith-gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Mosaic Layout */
.zenith-layout-mosaic .zenith-gallery-items {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 150px;
    gap: var(--zenith-gap);
}

.zenith-layout-mosaic .zenith-gallery-item:nth-child(5n+1) {
    grid-column: span 2;
    grid-row: span 2;
}

.zenith-layout-mosaic .zenith-gallery-item {
    border-radius: var(--zenith-border-radius);
    overflow: hidden;
}

.zenith-layout-mosaic .zenith-gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Gallery Item */
.zenith-gallery-item {
    position: relative;
    background: #f0f0f0;
}

.zenith-gallery-item-inner {
    position: relative;
    height: 100%;
}

.zenith-image-wrapper {
    position: relative;
    overflow: hidden;
    height: 100%;
}

.zenith-image-wrapper a {
    display: block;
    height: 100%;
}

.zenith-gallery-image {
    transition: transform 0.3s ease, filter 0.3s ease;
}

/* Hover Effects */
.zenith-hover-fade .zenith-gallery-item:hover .zenith-gallery-image {
    opacity: 0.85;
}

.zenith-hover-zoom .zenith-gallery-item:hover .zenith-gallery-image {
    transform: scale(1.1);
}

.zenith-hover-slide-up .zenith-gallery-item:hover .zenith-gallery-image {
    transform: translateY(-5px);
}

.zenith-hover-grayscale .zenith-gallery-image {
    filter: grayscale(100%);
}

.zenith-hover-grayscale .zenith-gallery-item:hover .zenith-gallery-image {
    filter: grayscale(0%);
}

.zenith-hover-blur .zenith-gallery-item:hover .zenith-gallery-image {
    filter: blur(2px);
}

/* Captions */
.zenith-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 15px;
    background: var(--zenith-caption-bg);
    color: var(--zenith-caption-color);
    font-size: 14px;
    line-height: 1.4;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.zenith-caption-title {
    display: block;
    font-weight: 600;
    margin-bottom: 4px;
}

.zenith-caption-text,
.zenith-caption-desc {
    display: block;
    opacity: 0.9;
    font-size: 13px;
}

/* Caption Display Options */
.zenith-captions-hover .zenith-caption {
    opacity: 0;
    transform: translateY(100%);
}

.zenith-captions-hover .zenith-gallery-item:hover .zenith-caption {
    opacity: 1;
    transform: translateY(0);
}

.zenith-captions-none .zenith-caption {
    display: none;
}

.zenith-captions-below .zenith-caption {
    position: relative;
    background: transparent;
    color: #333;
    padding: 10px 0;
}

/* Social Sharing */
.zenith-social-share {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 10;
}

.zenith-gallery-item:hover .zenith-social-share {
    opacity: 1;
}

.zenith-share-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    text-decoration: none;
    transition: all 0.3s ease;
}

.zenith-share-btn:hover {
    background: #333;
    color: #fff;
}

.zenith-share-btn svg {
    width: 16px;
    height: 16px;
}

/* Lazy Loading */
.zenith-lazy {
    opacity: 0;
    transition: opacity 0.5s ease;
}

.zenith-lazy.loaded {
    opacity: 1;
}

/* Pagination */
.zenith-pagination {
    margin-top: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.zenith-page-link {
    display: inline-block;
    padding: 10px 15px;
    border: 1px solid #ddd;
    background: #fff;
    color: #333;
    text-decoration: none;
    border-radius: 4px;
    transition: all 0.3s ease;
}

.zenith-page-link:hover,
.zenith-page-link.current {
    background: #333;
    color: #fff;
    border-color: #333;
}

.zenith-load-more {
    padding: 12px 30px;
    background: #333;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s ease;
}

.zenith-load-more:hover {
    background: #555;
}

.zenith-load-more:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.zenith-infinite-loader {
    text-align: center;
    padding: 20px;
}

.zenith-spinner {
    display: inline-block;
    width: 30px;
    height: 30px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #333;
    border-radius: 50%;
    animation: zenith-spin 1s linear infinite;
}

@keyframes zenith-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 1024px) {
    .zenith-gallery-items {
        grid-template-columns: repeat(var(--zenith-tablet-columns), 1fr);
    }
    
    .zenith-layout-masonry .zenith-gallery-items {
        columns: var(--zenith-tablet-columns);
    }
    
    .zenith-layout-mosaic .zenith-gallery-items {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .zenith-gallery-items {
        grid-template-columns: repeat(var(--zenith-mobile-columns), 1fr);
    }
    
    .zenith-layout-masonry .zenith-gallery-items {
        columns: var(--zenith-mobile-columns);
    }
    
    .zenith-layout-mosaic .zenith-gallery-items {
        grid-template-columns: 1fr;
    }
    
    .zenith-layout-mosaic .zenith-gallery-item:nth-child(5n+1) {
        grid-column: span 1;
        grid-row: span 1;
    }
    
    .zenith-gallery-controls {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .zenith-social-share {
        opacity: 1;
    }
}

/* Accessibility */
.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Focus States */
.zenith-filter-btn:focus,
.zenith-page-link:focus,
.zenith-load-more:focus,
.zenith-lightbox-trigger:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}
