/* Masonry Grid Layout using official Masonry library */

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

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

.grid-item {
    width: 100%;
    margin-bottom: 24px;
}

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

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

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

/* Media Card Styles */
.media-card {
    position: relative;
    overflow: hidden;
    background-color: #000;
    cursor: pointer;
    transition: transform 0.3s ease;
    border-radius: 0; /* Flat edges - no rounded corners */
    height: 100%;
    min-height: 300px;
    aspect-ratio: 1; /* Make cards square by default */
}

.media-card:hover {
    transform: translateY(-2px);
}

.media-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.media-poster,
.media-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center; /* Crop from center */
    display: block;
    transition: opacity 0.3s ease;
}

.media-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center; /* Crop from center */
    opacity: 0;
    transition: opacity 0.3s ease;
}

.media-card:hover .media-video {
    opacity: 1;
}

.media-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px;
    color: white;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.media-card:hover .media-overlay {
    transform: translateY(0);
}

.media-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 4px;
    line-height: 1.2;
}

.media-description {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 8px;
    line-height: 1.3;
}

.media-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.tag {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(4px);
    color: white;
}

/* Text Block Styles */
.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: white;
}

/* Override for the "grow your business" card 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;
}

/* 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;
    }
    
    .media-overlay {
        padding: 12px;
    }
    
    .media-title {
        font-size: 16px;
    }
    
    .media-description {
        font-size: 13px;
    }
    
    .text-block {
        padding: 24px 16px !important;
        min-height: 300px;
    }
}

/* Hover effects */
@media (hover: hover) {
    .media-card {
        transition: all 0.3s ease;
    }
    
    .media-card:hover {
        box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    }
}

/* Focus states for accessibility */
.media-card:focus {
    outline: 2px solid var(--primary-red);
    outline-offset: 2px;
}

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

.media-card[data-loading="true"] .media-poster,
.media-card[data-loading="true"] .media-image {
    opacity: 0.5;
}

/* Animation for staggered loading */
.grid-item {
    opacity: 0;
    animation: fadeInUp 0.6s ease forwards;
}

.grid-item:nth-child(1) { animation-delay: 0.1s; }
.grid-item:nth-child(2) { animation-delay: 0.2s; }
.grid-item:nth-child(3) { animation-delay: 0.3s; }
.grid-item:nth-child(4) { animation-delay: 0.4s; }
.grid-item:nth-child(5) { animation-delay: 0.5s; }
.grid-item:nth-child(6) { animation-delay: 0.6s; }
.grid-item:nth-child(7) { animation-delay: 0.7s; }
.grid-item:nth-child(8) { animation-delay: 0.8s; }
.grid-item:nth-child(9) { animation-delay: 0.9s; }
.grid-item:nth-child(10) { animation-delay: 1s; }

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

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