/* DNA Gallery Styles */

@import url('https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;500;600;700&display=swap');

.dna-gallery {
    margin: 2rem 0;
    position: relative;
}

.dna-gallery-grid {
    display: grid;
    gap: 1rem;
    margin-bottom: 2rem;
    /* Force grid to fill all columns */
    grid-auto-flow: dense;
}

.dna-gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f8f9fa;
    aspect-ratio: 1;
    /* Ensure items fill their grid cells */
    width: 100%;
    height: 100%;
}

.dna-gallery-item.empty {
    display: none !important;
    visibility: hidden;
    opacity: 0;
}

.dna-gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
}

.dna-gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.dna-gallery-item:hover img {
    transform: scale(1.05);
}

.dna-gallery-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, rgba(0, 0, 0, 0.1), transparent);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.dna-gallery-item:hover::before {
    opacity: 1;
}

.dna-gallery-item::after {
    content: '🔍';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    font-size: 2rem;
    color: white;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s ease;
    z-index: 2;
}

.dna-gallery-item:hover::after {
    transform: translate(-50%, -50%) scale(1);
}

.dna-gallery-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0));
    color: white;
    padding: 1rem 0.75rem 0.5rem;
    font-size: 0.875rem;
    font-family: 'Open Sans', sans-serif;
    text-align: center;
    font-weight: 500;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 3;
}

.dna-gallery-item:hover .dna-gallery-caption {
    opacity: 1;
}

/* Loading Animation */
.dna-gallery-loading {
    text-align: center;
    padding: 2rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* Modal Styles */
.dna-gallery-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    display: none !important;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    overflow: hidden;
}

.dna-gallery-modal.active {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.dna-gallery-modal-content {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.dna-gallery-modal-image {
    max-width: 100vw;
    max-height: 100vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 0;
    box-shadow: none;
    filter: none !important;
    -webkit-filter: none !important;
    background-color: white !important;
}

.dna-gallery-modal-caption {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-size: 1rem;
    font-family: 'Open Sans', sans-serif;
    text-align: center;
    font-weight: 500;
    z-index: 10001;
    max-width: 80vw;
    word-wrap: break-word;
}

.dna-gallery-close {
    position: fixed;
    top: 20px;
    right: 20px;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.7);
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
    z-index: 10000;
}

.dna-gallery-close:hover {
    background: rgba(0, 0, 0, 0.9);
}

.dna-gallery-modal-nav {
    position: fixed;
    top: 50%;
    left: 0;
    width: 100%;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    padding: 0 2rem;
    pointer-events: none;
    z-index: 10000;
    box-sizing: border-box;
}

.dna-gallery-prev,
.dna-gallery-next {
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    padding: 1rem 1.5rem;
    cursor: pointer;
    border-radius: 50%;
    font-size: 1.5rem;
    transition: background 0.3s ease;
    pointer-events: all;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dna-gallery-prev:hover,
.dna-gallery-next:hover {
    background: rgba(0, 0, 0, 0.9);
}

/* Responsive Design */
@media (max-width: 768px) {
    .dna-gallery-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem;
    }
    
    .dna-gallery-modal-content {
        max-width: 95%;
        max-height: 95%;
    }
    
    .dna-gallery-prev,
    .dna-gallery-next {
        padding: 0.5rem;
        font-size: 1rem;
    }
    
    .dna-gallery-prev {
        margin-left: -40px;
    }
    
    .dna-gallery-next {
        margin-right: -40px;
    }
}

@media (max-width: 480px) {
    .dna-gallery-grid {
        grid-template-columns: 1fr !important;
    }
    
    .dna-gallery-item::after {
        font-size: 1.5rem;
    }
}

/* Animation for grid items */
.dna-gallery-item {
    animation: fadeInUp 0.6s ease forwards;
    opacity: 0;
    transform: translateY(20px);
}

.dna-gallery-item:nth-child(1) { animation-delay: 0.1s; }
.dna-gallery-item:nth-child(2) { animation-delay: 0.2s; }
.dna-gallery-item:nth-child(3) { animation-delay: 0.3s; }
.dna-gallery-item:nth-child(4) { animation-delay: 0.4s; }
.dna-gallery-item:nth-child(5) { animation-delay: 0.5s; }
.dna-gallery-item:nth-child(6) { animation-delay: 0.6s; }

@keyframes fadeInUp {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Masonry effect for different image sizes */
.dna-gallery-item:nth-child(odd) {
    grid-row: span 1;
}

.dna-gallery-item:nth-child(3n) {
    grid-row: span 2;
}

/* Focus styles for accessibility */
.dna-gallery-item:focus,
.dna-gallery-close:focus,
.dna-gallery-prev:focus,
.dna-gallery-next:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .dna-gallery-item {
        border: 2px solid #000;
    }
    
    .dna-gallery-modal {
        background: rgba(0, 0, 0, 1);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .dna-gallery-item,
    .dna-gallery-modal,
    .spinner {
        transition: none;
        animation: none;
    }
}
