/* Pinterest-style Gallery Layout */
.day-gallery {
    margin: 3rem 0;
    padding: 0 1rem;
}

/* Base Grid Layout */
.gallery-grid {
    display: grid;
    gap: 1rem;
    margin: 1rem 0;
}

/* Gallery Item Base Styles */
.gallery-item {
    position: relative;
    background: rgba(20, 20, 20, 0.85);
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

/* Glassy border effect */
.gallery-item::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 20px;
    padding: 1px;
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.1),
        rgba(255, 255, 255, 0.05) 50%,
        transparent 50%,
        transparent
    );
    -webkit-mask: 
        linear-gradient(#fff 0 0) content-box, 
        linear-gradient(#fff 0 0);
    mask: 
        linear-gradient(#fff 0 0) content-box, 
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
    z-index: 2;
}

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

/* Caption Overlay */
.gallery-item::after {
    content: attr(data-caption);
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 2rem;
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.9),
        rgba(0, 0, 0, 0.7) 50%,
        transparent
    );
    color: white;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
}

/* Hover Effects */
.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 45px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.2);
}

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

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

/* Single Image Layout */
.gallery-grid:has(.gallery-item:only-child) {
    grid-template-columns: 1fr;
    margin: 1rem 0;
}

.gallery-grid:has(.gallery-item:only-child) .gallery-item {
    aspect-ratio: 16/12;
    width: 100%;
    min-height: 600px;
}

/* Adjust day-gallery container for single images */
.day-gallery:has(.gallery-grid .gallery-item:only-child) {
    margin: 1.2rem 0;
    padding: 0 0.5rem;
}

/* Multiple Images Layout - Base */
.gallery-grid:not(:has(.gallery-item:only-child)) {
    display: grid;
    gap: 0.35rem;
    margin: 0;
}

/* Desktop Layout (769px and up) */
@media (min-width: 769px) {
    .day-gallery {
        margin: 1rem 0 0 0;
        padding: 0 0.5rem;
    }

    .gallery-grid:not(:has(.gallery-item:only-child)) {
        grid-template-columns: repeat(12, 1fr);
        grid-auto-rows: 250px;
        grid-auto-flow: dense;
        gap: 0.35rem;
    }

    .gallery-grid:not(:has(.gallery-item:only-child)) .gallery-item:nth-child(1) {
        grid-column: span 6;
        grid-row: span 2;
    }

    .gallery-grid:not(:has(.gallery-item:only-child)) .gallery-item:nth-child(2) {
        grid-column: span 4;
        grid-row: span 2;
    }

    .gallery-grid:not(:has(.gallery-item:only-child)) .gallery-item:nth-child(3) {
        grid-column: span 2;
        grid-row: span 1;
        height: 100%;
    }

    .gallery-grid:not(:has(.gallery-item:only-child)) .gallery-item:nth-child(4) {
        grid-column: 11 / span 2;
        grid-row: 2 / span 1;
        height: 100%;
    }
}

/* Mobile Layout */
@media (max-width: 768px) {
    .day-gallery {
        margin: 1rem 0;
        padding: 0 0.25rem;
    }

    /* Single Image Mobile */
    .gallery-grid:has(.gallery-item:only-child) .gallery-item {
        aspect-ratio: auto;
        min-height: 450px;
    }

    /* Multiple Images Mobile */
    .gallery-grid:not(:has(.gallery-item:only-child)) {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.25rem;
    }

    .gallery-grid:not(:has(.gallery-item:only-child)) .gallery-item {
        aspect-ratio: 3/4;
        min-height: 300px;
    }

    .gallery-item::after {
        padding: 1rem;
        font-size: 1rem;
        opacity: 1;
        transform: none;
        background: linear-gradient(
            to top,
            rgba(0, 0, 0, 0.8),
            rgba(0, 0, 0, 0.6) 50%,
            transparent
        );
    }

    .gallery-item:hover {
        transform: none;
    }
}

/* Removed unnecessary bottom spacing from day section */
.day-section {
    margin-bottom: 2rem;
}

.day-section:last-child {
    margin-bottom: 0;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .gallery-item {
        background: rgba(0, 0, 0, 0.95);
        border: 2px solid #80be78;
    }
    
    .gallery-item::before {
        display: none;
    }
    
    .gallery-item::after {
        background: rgba(0, 0, 0, 0.9);
        opacity: 1;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .gallery-item,
    .gallery-item img {
        transition: none;
    }
    
    .gallery-item:hover {
        transform: none;
    }
}