/**
 * Modern Gallery Styles
 *
 * Elegant, responsive CSS for the FreyaDay gallery
 * featuring a masonry grid layout, lightbox modal,
 * and gothic-inspired design elements
 */

/* ====== Gallery Layout ====== */
.gallery-main {
    background-color: rgba(0, 0, 0, 0.3); /* Changed to 0.3 opacity as requested */
    color: #e0e0e0;
    font-family: 'Cinzel Decorative', serif;
    padding: 0 1rem 2rem;
    max-width: 1600px;
    margin: 0 auto;
}

.gallery-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-top: 0;
    position: relative;
    background: rgba(7, 7, 12, 0.6);
    border-radius: 12px;
    padding: 1rem 1rem 1rem;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(107, 99, 255, 0.15);
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
}

.gallery-title-container {
    position: relative;
    display: inline-block;
    perspective: 800px;
    min-height: 4.5rem; /* Ensures container height remains consistent */
}

.gallery-title, .elder-futhark {
    font-size: 3.5rem;
    margin: 0.2rem 0;
    transition: opacity 0.5s ease-in-out;
    background: linear-gradient(45deg, #6B63FF, #b667d9, #a866d2, #9966ff, #6B63FF);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-family: 'Cinzel Decorative', serif;
    text-shadow: 0 0 12px rgba(155, 102, 255, 0.7);
    line-height: 1.2;
    letter-spacing: 1px;
    font-weight: 700;
    width: 100%;
    text-align: center;
}

.gallery-title {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
}

.gallery-title.revealed {
    font-family: 'Cinzel Decorative', serif;
    /* Default state - will be changed by JS */
    opacity: 0;
}

.elder-futhark {
    opacity: 1;
    transition: opacity 0.5s ease-in-out;
    position: relative;
}

/* When title is revealed, ensure proper visibility */
body.title-revealed .elder-futhark {
    opacity: 0;
}

body.title-revealed .gallery-title.revealed {
    opacity: 1;
}

.gallery-description {
    font-size: 0.95rem;
    margin-top: 1rem;
    font-weight: 300;
    color: #e0e0e0;
    letter-spacing: 1.5px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
    text-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
    position: relative;
}

.gallery-description::after {
    content: '';
    display: block;
    width: 100px;
    height: 2px;
    background: linear-gradient(45deg, transparent, rgba(107, 99, 255, 0.7), transparent);
    margin: 1rem auto 0;
    border-radius: 2px;
}

/* ====== Timeline Navigation ====== */
.timeline-navigation {
    display: flex;
    justify-content: center;
    margin-bottom: 3rem;
    position: sticky;
    top: 0;
    padding: 1rem;
    z-index: 10;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(107, 99, 255, 0.3);
}

.timeline-navigation ul {
    display: flex;
    list-style: none;
    padding: 0;
    margin: 0;
    flex-wrap: wrap;
    justify-content: center;
}

.timeline-navigation li {
    margin: 0.5rem 1rem;
}

.timeline-link {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #b8b8b8;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    padding: 0.5rem;
    border-radius: 8px;
}

.timeline-link:hover, .timeline-link:focus {
    color: #ffffff;
    transform: translateY(-3px);
}

.timeline-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
    height: 40px;
    width: 40px;
    border-radius: 50%;
    background: linear-gradient(45deg, rgba(107, 99, 255, 0.2), rgba(155, 102, 255, 0.3));
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    border: 1px solid rgba(107, 99, 255, 0.3);
}

.timeline-link:hover .timeline-icon {
    background: linear-gradient(45deg, rgba(107, 99, 255, 0.8), rgba(155, 102, 255, 0.9));
    transform: rotate(10deg) scale(1.1);
    box-shadow: 0 0 15px rgba(107, 99, 255, 0.5);
}

.timeline-label {
    font-size: 0.9rem;
    font-weight: 500;
    font-family: 'Cinzel Decorative', serif;
}

/* ====== Gallery Sections ====== */
.gallery-section {
    margin-bottom: 4rem;
    padding-top: 1rem;
    scroll-margin-top: 120px; /* For smooth scrolling with sticky header */
}

.stage-title {
    font-size: 2.2rem;
    margin-bottom: 2rem;
    text-align: center;
    position: relative;
    font-family: 'Cinzel Decorative', serif;
    background: linear-gradient(135deg, #6B63FF, #b667d9, #a866d2, #9966ff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: 1px;
    padding: 1rem 0;
}

.stage-title::after {
    content: '';
    display: block;
    width: 60px;
    height: 3px;
    background: linear-gradient(45deg, #6B63FF, #b667d9);
    margin: 0.8rem auto 0;
    border-radius: 2px;
}

/* ====== Gallery Grid ====== */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* Exactly 3 thumbnails per row */
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding: 1rem;
    transition: all 0.3s ease;
    border-radius: 6px;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    cursor: pointer;
    background: #0f0f0f;
    transform: translateZ(0); /* For smoother transitions */
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
    /* Make gallery items 30% smaller */
    width: 70%;
    margin: 0 auto;
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 1px solid rgba(107, 99, 255, 0.15);
    height: 100%;
    animation: fadeInUp 0.8s cubic-bezier(0.25, 0.8, 0.25, 1) both;
    animation-delay: calc(0.05s * var(--animation-order, 0));
}

.gallery-item-inner {
    position: relative;
    overflow: hidden;
    border-radius: 11px;
    height: 100%;
    aspect-ratio: 1/1; /* Consistent aspect ratio */
}

.gallery-item:hover {
    transform: translateY(-5px) scale(1.03);
    box-shadow: 0 12px 25px rgba(0, 0, 0, 0.7), 0 0 15px rgba(107, 99, 255, 0.3);
    border-color: rgba(107, 99, 255, 0.4);
    z-index: 2;
}

.gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: all 0.3s ease;
    border-radius: 10px;
    cursor: pointer;
    aspect-ratio: 1/1;
    display: block;
    filter: brightness(0.95);
}

.gallery-item:hover .gallery-image {
    transform: scale(1.08);
    filter: brightness(1.05);
}

/* ====== Gallery Overlay ====== */
.gallery-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1.5rem 1rem;
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.9) 0%,
        rgba(0, 0, 0, 0.7) 50%,
        rgba(0, 0, 0, 0.3) 80%,
        rgba(0, 0, 0, 0) 100%
    );
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    backdrop-filter: blur(4px);
    border-bottom-left-radius: 11px;
    border-bottom-right-radius: 11px;
}

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

.gallery-item-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-family: 'Cinzel Decorative', serif;
    background: linear-gradient(45deg, #ffffff, #e0e0e0);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gallery-item-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    color: #b8b8b8;
}

.gallery-item-description {
    font-size: 0.9rem;
    line-height: 1.4;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    color: #cccccc;
    font-family: serif;
}

/* ====== Empty Gallery State ====== */
.empty-gallery-main {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background-color: rgba(15, 15, 20, 0.3); /* Changed opacity from 0.9 to 0.3 for slight transparency */
    border-radius: 8px;
    box-shadow: 0 0 25px rgba(0, 0, 0, 0.5);
}

.empty-gallery-icon {
    font-size: 4rem;
    margin-bottom: 1.5rem;
    color: rgba(107, 99, 255, 0.6);
}

.empty-gallery h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
    font-family: 'Cinzel Decorative', serif;
}

.empty-gallery p {
    font-size: 1.1rem;
    color: #b8b8b8;
    max-width: 400px;
    margin: 0 auto;
}

/* ====== Filter Styles ====== */
.filter-container {
    background: rgba(0, 0, 0, 0.7);
    border-radius: 8px;
    padding: 1.5rem;
    margin-top: 70px; /* Added margin-top to prevent header overlap */
    margin-bottom: 2rem;
    border: 1px solid rgba(107, 99, 255, 0.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.filter-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.filter-inputs {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
}

.filter-group {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 180px;
}

.filter-group label {
    margin-bottom: 0.5rem;
    color: #9370DB;
    font-size: 0.85rem;
    font-weight: 500;
}

.filter-select,
.filter-input {
    padding: 0.75rem 1rem;
    background-color: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(147, 112, 219, 0.4);
    border-radius: 4px;
    color: #e0e0e0;
    font-family: 'Cinzel', serif;
    transition: all 0.3s ease;
}

.filter-select:focus,
.filter-input:focus {
    border-color: rgba(147, 112, 219, 0.8);
    box-shadow: 0 0 8px rgba(147, 112, 219, 0.5);
    outline: none;
}

.filter-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 0.5rem;
}

.filter-button {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-family: 'Cinzel Decorative', serif;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.filter-apply {
    background: linear-gradient(135deg, #6a0dad, #4B0082, #800080);
    color: white;
}

.filter-reset {
    background-color: rgba(0, 0, 0, 0.6);
    color: #9370DB;
    border: 1px solid rgba(147, 112, 219, 0.4);
}

.filter-apply:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(107, 99, 255, 0.4);
}

.filter-reset:hover {
    background-color: rgba(147, 112, 219, 0.1);
    border-color: rgba(147, 112, 219, 0.6);
}

@media (max-width: 768px) {
    .filter-inputs {
        flex-direction: column;
    }
    
    .filter-group {
        width: 100%;
    }
    
    .filter-buttons {
        justify-content: center;
    }
}

/* ====== Lightbox Modal ====== */
.lightbox-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: flex-start; /* Changed from center to flex-start */
    justify-content: center;
    z-index: 1050; /* Higher than the header z-index (10) */
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease-in-out, visibility 0.4s ease-in-out;
    padding-top: 5vh; /* Add top padding to push content down */
}

.lightbox-modal.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-content {
    background: #0a0a0a;
    max-width: 800px;
    width: 80%;
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(107, 99, 255, 0.25);
    animation: fadeInScale 0.4s ease forwards;
    margin-top: 60px;
}

.lightbox-close {
    position: absolute;
    top: 15px;
    right: 15px;
    font-size: 2rem;
    background: transparent;
    border: none;
    color: #ffffff;
    cursor: pointer;
    z-index: 1002;
    line-height: 1;
    padding: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    transition: all 0.3s ease;
}

.lightbox-close:hover {
    background: rgba(107, 99, 255, 0.3);
    transform: rotate(90deg);
}

.lightbox-image-container {
    flex: 1;
    max-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: #000000;
}

.lightbox-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.lightbox-details {
    padding: 1.5rem;
    background-color: #0f0f0f;
    border-top: 1px solid rgba(107, 99, 255, 0.2);
}

.lightbox-title {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
    font-family: 'Cinzel Decorative', serif;
    color: #ffffff;
}

.lightbox-meta {
    margin-bottom: 1rem;
    font-size: 0.95rem;
    color: #b8b8b8;
}

.lightbox-description {
    color: #d0d0d0;
    line-height: 1.5;
    font-family: serif;
}

.lightbox-navigation {
    position: absolute;
    top: 50%;
    width: 100%;
    display: flex;
    justify-content: space-between;
    transform: translateY(-50%);
    padding: 0 1rem;
}

.lightbox-prev, .lightbox-next {
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.lightbox-prev:hover, .lightbox-next:hover {
    background: rgba(107, 99, 255, 0.5);
    border-color: rgba(107, 99, 255, 0.8);
    transform: scale(1.1);
}

.no-scroll {
    overflow: hidden;
}

/* ====== Responsive Adjustments ====== */
@media (max-width: 1200px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 1.25rem;
    }
    
    .gallery-title, .elder-futhark {
        font-size: 3rem;
    }
}

@media (max-width: 992px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 1rem;
    }
    
    .timeline-navigation li {
        margin: 0.5rem;
    }
    
    .gallery-title, .elder-futhark {
        font-size: 2.5rem;
    }
}

@media (max-width: 768px) {
    .gallery-main {
        padding: 1.5rem 0.75rem;
    }
    
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
        gap: 0.75rem;
    }
    
    .timeline-icon {
        height: 35px;
        width: 35px;
        font-size: 1.2rem;
    }
    
    .timeline-label {
        font-size: 0.8rem;
    }
    
    .gallery-title, .elder-futhark {
        font-size: 2.2rem;
    }
    
    .stage-title {
        font-size: 1.8rem;
    }
    
    .lightbox-content {
        width: 95%;
        margin: 1rem;
    }
    
    .lightbox-details {
        padding: 1rem;
    }
}

@media (max-width: 576px) {
    .gallery-main {
        padding: 1rem 0.5rem;
    }
    
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 0.75rem;
    }
    
    .gallery-title, .elder-futhark {
        font-size: 1.8rem;
    }
    
    .timeline-link {
        padding: 0.3rem;
    }
    
    .timeline-icon {
        height: 30px;
        width: 30px;
        font-size: 1rem;
        margin-bottom: 0.3rem;
    }
    
    .timeline-label {
        font-size: 0.7rem;
    }
    
    .gallery-item-title {
        font-size: 1rem;
    }
    
    .gallery-item-description {
        font-size: 0.8rem;
        -webkit-line-clamp: 2;
        line-clamp: 2;
    }
    
    .stage-title {
        font-size: 1.5rem;
    }
    
    .lightbox-title {
        font-size: 1.2rem;
    }
}

/* Ultrasound images often need contrast enhancement */
#ultrasound .gallery-image {
    filter: brightness(1.1) contrast(1.2);
}

/* Animation for gallery items */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Add a subtle glow effect to highlight the current life stage section */
.gallery-section:target {
    animation: sectionHighlight 1.5s ease-out;
}

@keyframes sectionHighlight {
    0% {
        box-shadow: 0 0 0 rgba(107, 99, 255, 0);
    }
    50% {
        box-shadow: 0 0 35px rgba(107, 99, 255, 0.3);
    }
    100% {
        box-shadow: 0 0 0 rgba(107, 99, 255, 0);
    }
}

/* ====== Pagination Styles ====== */
.pagination-container {
    display: flex;
    justify-content: center;
    margin: 2rem 0;
    padding: 1rem 0;
    border-top: 1px solid rgba(107, 99, 255, 0.3);
}

.pagination {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    height: 2.5rem;
    padding: 0 0.75rem;
    color: #9370DB;
    background-color: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(147, 112, 219, 0.3);
    border-radius: 4px;
    text-decoration: none;
    transition: all 0.3s ease;
    font-family: 'Cinzel', serif;
}

.pagination-link:hover {
    background-color: rgba(147, 112, 219, 0.15);
    border-color: rgba(147, 112, 219, 0.7);
    transform: translateY(-2px);
    box-shadow: 0 0 10px rgba(147, 112, 219, 0.5);
}

.pagination-link.active {
    background: linear-gradient(135deg, #6a0dad, #4B0082, #800080, #9370DB);
    color: white;
    font-weight: bold;
    border-color: #9370DB;
}

.pagination-prev,
.pagination-next {
    padding: 0 1rem;
    font-family: 'Cinzel Decorative', serif;
}

.pagination-ellipsis {
    color: #9370DB;
    padding: 0 0.5rem;
}
