.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
    padding: 2rem;
}

.gallery-item {
    position: relative;
    background: var(--content-bg);  /* White background for cards */
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
    transition: transform 0.3s ease;
    cursor: pointer;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-radius: 8px;
}

.gallery-item::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    background: radial-gradient(
        circle at center,
        transparent 80%,
        rgba(0,0,0,0.08) 100%
    );
}

.gallery-item:hover {
    transform: translateY(-5px);
}

.gallery-item img {
    width: 100%;
    height: 300px;
    object-fit: cover;
    border-radius: 8px 8px 0 0;
}

.item-details {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.item-details h3 {
    color: var(--text-color);
    margin-bottom: 0.8rem;
    font-size: 1.4rem;
}

.item-details > p:not(.tech):not(.dimensions):not(.price) {
    margin-bottom: 1rem;
}

.item-meta {
    margin-top: auto;
    border-top: 1px solid var(--background-color);
    padding-top: 1rem;
}

.tech {
    color: var(--text-color);
    opacity: 0.8; /* Slightly more subtle */
    font-size: 0.9rem;
    font-style: italic;
}

.dimensions {
    color: var(--text-color);
    opacity: 0.8;
    font-size: 0.9rem;
    border-left: 3px solid #ffd700;
    padding-left: 0.8rem;
    margin: 0.5rem 0;
}

.price {
    color: var(--text-color);
    font-weight: 600;
    font-size: 1.1rem;
    text-align: right;
    margin-top: 0.5rem;
}

/* Series indicator styling */
.series-indicator {
    margin-top: 0.5rem;
    margin-bottom: 1rem;
    font-style: italic;
    font-size: 0.9rem;
    color: var(--text-color);
}

.series-indicator span {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    background-color: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.3);
}

.date {
    color: var(--text-color);
    opacity: 0.8;
    font-size: 0.9rem;
    font-style: italic;
    margin-bottom: 0.3rem;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 1000;
}

.modal.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90vh;
    display: flex;
    gap: 2rem;
    color: white;
}

.modal-content::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 60%;
    height: 100%;
    pointer-events: none;
    background: radial-gradient(
        circle at center,
        transparent 75%,
        rgba(0,0,0,0.2) 100%
    );
}

.modal-content img {
    max-height: 90vh;
    max-width: 60%;
    object-fit: contain;
    filter: drop-shadow(0 0 20px rgba(0,0,0,0.3));
}

.modal-details {
    max-width: 400px;
    overflow-y: auto;
    padding: 1rem;
}

.modal-details .tech {
    color: #999;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding-bottom: 0.8rem;
}

.modal-details .dimensions {
    border-left-color: rgba(255, 215, 0, 0.4);
}

.modal-details .price {
    color: #ffd700;
    font-size: 1.2rem;
}

.modal-details .item-meta {
    border-top-color: rgba(255,255,255,0.1);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0,0,0,0.5);  /* Add dark background for visibility */
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    width: 40px;    /* Fixed size */
    height: 40px;   /* Fixed size */
    border-radius: 50%;
    display: flex;  /* Center the X */
    align-items: center;
    justify-content: center;
    z-index: 1200;  /* Higher than other elements */
    opacity: 0.9;
    transition: all 0.2s;
    padding: 0;     /* Remove padding that might push content */
    line-height: 1; /* Adjust line height to center X */
}

.modal-close:hover,
.modal-close:active {
    opacity: 1;
    background: rgba(0,0,0,0.7);
    transform: scale(1.1);
}

.modal-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0,0,0,0.3);  /* Add semi-transparent background for better visibility */
    border: none;
    color: var(--accent-color);
    font-size: 1.8rem;  /* Slightly smaller for better mobile display */
    padding: 1rem;
    cursor: pointer;
    opacity: 0.9;  /* More visible by default */
    transition: all 0.2s ease;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    z-index: 1100;  /* Ensure buttons are above all content */
    touch-action: manipulation;  /* Improve touch behavior */
}

.modal-nav:hover,
.modal-nav:active {
    opacity: 1;
    background: rgba(0,0,0,0.5);  /* Darker background on interaction */
    transform: translateY(-50%) scale(1.1);
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

.modal-nav.prev { left: 1rem; }
.modal-nav.next { right: 1rem; }

/* Series gallery in modal */
.modal-series-gallery {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 1.5rem 0;
    justify-content: center;
}

.modal-series-gallery img {
    width: 100px;
    height: 100px;
    object-fit: cover;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    border: 2px solid transparent;
}

.modal-series-gallery img.active {
    border-color: var(--accent-color);
    transform: scale(1.05);
    box-shadow: 0 3px 8px rgba(0,0,0,0.2);
}

.modal-series-gallery img:hover {
    transform: scale(1.05);
    box-shadow: 0 3px 8px rgba(0,0,0,0.2);
}

@media (max-width: 768px) {
    .gallery {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }

    .modal-content {
        flex-direction: column;
        align-items: center;
    }
    
    .modal-content img {
        max-width: 100%;
    }
    
    .modal-details {
        max-width: 100%;
    }
    
    .modal-content::after {
        width: 100%;
    }
    
    /* Enhanced mobile navigation */
    .modal-nav {
        width: 44px;
        height: 44px;
        font-size: 1.5rem;
        background: rgba(0,0,0,0.5);  /* Darker background on mobile for visibility */
    }
    
    .modal-nav.prev { left: 10px; }
    .modal-nav.next { right: 10px; }
    
    .modal-close {
        top: 0.5rem;
        right: 0.5rem;
        font-size: 1.8rem;
        background: rgba(0,0,0,0.3);
        width: 40px;
        height: 40px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}
