/* Work Gallery Masonry Layout */

.grid {
    margin: 0;
    padding: 0;
}

/* Grid Sizer for responsive columns */
.grid-sizer,
.grid-item {
    width: 100%;
}

/* Large items (videos and text block) */
.grid-item--width2 {
    width: 100%;
}

.grid-item--height2 {
    min-height: 400px;
}

/* Regular items (images) */
.grid-item {
    margin-bottom: 24px;
    break-inside: avoid;
}

/* Gallery Item Base */
.gallery-item {
    overflow: hidden;
    position: relative;
    box-sizing: border-box;
    /* Ensure items have proper dimensions for masonry */
    min-height: 200px;
    height: auto;
}

.gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
    position: absolute;
    top: 0;
    left: 0;
}

.gallery-item:hover .gallery-image {
    transform: scale(1.02);
}

/* Specific Gallery Item Layouts */

/* Large hero image - full width and height */
.gallery-hero {
    width: 100% !important;
    height: 400px;
}

/* Left brand tile */
.gallery-brand-left {
    width: 100%;
    height: 300px;
}

/* Product flatlay */
.gallery-product {
    width: 100%;
    height: 350px;
}

/* Books/records still */
.gallery-books {
    width: 100%;
    height: 280px;
}

/* Text Block Styles - matching homepage */
.text-block {
    border: 1px solid #e5e7eb;
    border-radius: 0; /* Flat edges - no rounded corners */
    height: 100%;
    min-height: 300px; /* Match the height of regular cards */
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: black;
    padding: 0;
}

/* Override for the text block to match regular card height */
.grid-item:has(.text-block) {
    min-height: 300px;
    height: auto;
}

.grid-item:has(.text-block) .text-block {
    min-height: 300px;
    height: 100%;
}

.text-block h3 {
    font-family: var(--font-ogilvy-serif);
    font-weight: 700;
    line-height: 0.9;
    margin-bottom: 20px;
}

.text-block p {
    color: #666;
    line-height: 1.5;
}

/* USPS blue texture-ish stand-in */
.gallery-usps {
    width: 100%;
    height: 320px;
}

/* Posters / wayfinding */
.gallery-posters {
    width: 100%;
    height: 380px;
}

/* Three-up row */
.gallery-three-1,
.gallery-three-2,
.gallery-three-3 {
    width: 100%;
    height: 260px;
}

/* Wide portrait banner */
.gallery-wide {
    width: 100%;
    height: 450px;
}

/* Responsive adjustments */
@media (min-width: 640px) {
    .grid-sizer,
    .grid-item {
        width: calc(50% - 12px);
    }
    
    .grid-item--width2 {
        width: calc(50% - 12px);
    }
    
    .grid-item {
        margin-bottom: 24px;
    }
}

@media (min-width: 1024px) {
    .grid-sizer,
    .grid-item {
        width: calc(33.333% - 16px);
    }
    
    .grid-item--width2 {
        width: calc(66.666% - 16px);
    }
    
    .grid-item {
        margin-bottom: 32px;
    }
}

@media (min-width: 1400px) {
    .grid-sizer,
    .grid-item {
        width: calc(25% - 18px);
    }
    
    .grid-item--width2 {
        width: calc(50% - 18px);
    }
    
    .grid-item {
        margin-bottom: 32px;
    }
}

@media (max-width: 768px) {
    .grid-item {
        margin-bottom: 20px;
    }
    
    .gallery-hero {
        height: 300px;
    }
    
    .text-block {
        padding: 0;
        min-height: 300px;
    }
    
    .gallery-brand-left,
    .gallery-product,
    .gallery-books,
    .gallery-usps,
    .gallery-posters {
        height: 200px;
    }
    
    .gallery-three-1,
    .gallery-three-2,
    .gallery-three-3 {
        height: 180px;
    }
    
    .gallery-wide {
        height: 350px;
    }
}

@media (max-width: 640px) {
    .grid-item {
        width: 100% !important;
        margin-bottom: 16px;
    }
    
    .gallery-hero {
        height: 250px;
    }
    
    .gallery-brand-left,
    .gallery-product,
    .gallery-books,
    .gallery-usps,
    .gallery-posters,
    .gallery-three-1,
    .gallery-three-2,
    .gallery-three-3 {
        height: 180px;
    }
    
    .gallery-wide {
        height: 300px;
    }
}

/* Hover effects */
@media (hover: hover) {
    .gallery-item {
        transition: all 0.3s ease;
        cursor: pointer;
    }
    
    .gallery-item:hover {
        transform: translateY(-2px);
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    }
    
    .text-block:hover {
        transform: none;
        box-shadow: none;
        cursor: default;
    }
}

/* Focus states for accessibility */
.gallery-item:focus {
    outline: 2px solid #F1002C;
    outline-offset: 2px;
}

/* Loading states */
.gallery-item[data-loading="true"] {
    opacity: 0.7;
}

.gallery-item[data-loading="true"] .gallery-image {
    opacity: 0.5;
}

/* Animation for staggered loading */
.gallery-item {
    opacity: 1; /* Temporarily disable animations for masonry testing */
    /* animation: fadeInUp 0.6s ease forwards; */
}

.gallery-hero { animation-delay: 0.1s; }
.gallery-brand-left { animation-delay: 0.2s; }
.gallery-product { animation-delay: 0.3s; }
.gallery-books { animation-delay: 0.4s; }
.text-block { animation-delay: 0.5s; }
.gallery-usps { animation-delay: 0.6s; }
.gallery-posters { animation-delay: 0.7s; }
.gallery-three-1 { animation-delay: 0.8s; }
.gallery-three-2 { animation-delay: 0.9s; }
.gallery-three-3 { animation-delay: 1.0s; }
.gallery-wide { animation-delay: 1.1s; }

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

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .gallery-item {
        animation: none;
        opacity: 1;
    }
    
    .gallery-item,
    .gallery-image {
        transition: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .gallery-item {
        border: 2px solid #fff;
    }
}

/* Print styles */
@media print {
    .grid {
        display: block;
    }
    
    .grid-item {
        break-inside: avoid;
        margin-bottom: 1rem;
    }
    
    .gallery-image {
        max-height: 400px;
        object-fit: contain;
    }
}