/**
 * Waterfall Grid Tile Styles
 * Handles responsive grid layouts and tile sizing
 */

/* Grid Container */
.waterfall-grid {
    display: block;
    position: relative;
    width: 100%;
    margin: 0 auto;
    overflow: hidden;
    /* Clearfix for floats */
}

/* Base Grid Sizer (for Masonry) */
.waterfall-grid-sizer {
    width: 20% !important;
    /* Default 5 columns */
}

/* Tile Base Styles */
.waterfall-item {
    display: block;
    float: left;
    width: 20% !important;
    /* Default 5 columns */
    padding: 10px;
    box-sizing: border-box;
    /* Ensure tile wrapper fills the item for bottom alignment */
    display: flex;
    flex-direction: column;
}

.waterfall-tile {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    flex: 1;
    /* Fill parent */
}

.waterfall-tile:hover {
    transform: translateY(-2px);
}

/* Box Shadow Variations */
.waterfall-grid.shadow-none .waterfall-tile {
    box-shadow: none;
}

.waterfall-grid.shadow-light .waterfall-tile {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.waterfall-grid.shadow-medium .waterfall-tile {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.waterfall-grid.shadow-heavy .waterfall-tile {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.waterfall-grid.shadow-light .waterfall-tile:hover,
.waterfall-grid.shadow-medium .waterfall-tile:hover,
.waterfall-grid.shadow-heavy .waterfall-tile:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

/* Tile Sizes - Widths & Aspect Ratios for Masonry */
/* Base width is 20% (5 columns) defined in .waterfall-item */

.waterfall-item.tile-1x1 {
    width: 20%;
    aspect-ratio: 1 / 1;
}

.waterfall-item.tile-2x1 {
    width: 40% !important;
    aspect-ratio: 2 / 1;
}

.waterfall-item.tile-1x2 {
    width: 20%;
    aspect-ratio: 1 / 2;
}

.waterfall-item.tile-2x2 {
    width: 40% !important;
    aspect-ratio: 1 / 1;
}

.waterfall-item.tile-3x1 {
    width: 60% !important;
    aspect-ratio: 3 / 1;
}

.waterfall-item.tile-3x2 {
    width: 60% !important;
    aspect-ratio: 3 / 2;
}

.waterfall-item.tile-3x3 {
    width: 60% !important;
    aspect-ratio: 1 / 1;
}

/* Tile Image */
.tile-image {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    /* 16:9 aspect ratio */
    overflow: hidden;
    background: #f5f5f5;
}

.tile-image a {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.tile-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.waterfall-tile:hover .tile-image img {
    transform: scale(1.05);
}

/* Feature #1: Rounded image corners when enabled */
.tile-image img.rounded-corners {
    border-radius: inherit;
}

/* YouTube Play Button Overlay */
.tile-play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    pointer-events: none;
    opacity: 0.85;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.waterfall-tile:hover .tile-play-overlay {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.1);
}

.tile-play-overlay svg {
    display: block;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* Feature #4: 1x1 Image Fill - Image fills entire tile */
.waterfall-item.tile-1x1.tile-image-only .tile-image {
    padding-bottom: 100%;
    /* 1:1 aspect ratio */
    height: 100%;
}

.waterfall-item.tile-1x1.tile-image-only .tile-content {
    display: none;
}

/* Tile Content */
.tile-content {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    min-height: 0;
}

/* Feature #3: Header container for badge and inline price */
.tile-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

/* Source Badge */
.tile-source-badge {
    display: inline-block;
    padding: 4px 10px;
    background: #0073aa;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    border-radius: 3px;
}

.tile-source-youtube .tile-source-badge {
    background: #ff0000;
}

.tile-source-facebook .tile-source-badge {
    background: #1877f2;
}

.tile-source-amazon .tile-source-badge {
    background: #ff9900;
}

.tile-source-wordpress .tile-source-badge {
    background: #21759b;
}

/* Feature #3: Inline price display */
.tile-price-inline {
    display: inline-block;
    padding: 4px 10px;
    background: #f0f0f1;
    color: #0073aa;
    font-size: 14px;
    font-weight: 700;
    border-radius: 3px;
}

/* Title */
.tile-title {
    margin: 0 0 12px;
    font-size: 18px;
    line-height: 1.4;
    font-weight: 600;
}

.tile-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

.tile-title a:hover {
    color: #0073aa;
}

/* Excerpt */
.tile-excerpt {
    margin: 0 0 12px;
    color: #666;
    font-size: 14px;
    line-height: 1.6;
    flex: 1;
}

/* Feature #2: Meta Info - pushed to bottom with margin-top: auto */
.tile-meta {
    margin-top: auto;
    margin-bottom: 0;
    padding-top: 12px;
    font-size: 13px;
    color: #999;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.tile-date:before {
    content: "📅 ";
}

.tile-author:before {
    content: "✍️ ";
}

/* Feature #2: Button - already has margin-top: auto for bottom alignment */
.tile-button {
    display: inline-block;
    padding: 10px 20px;
    background: #0073aa;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 500;
    text-align: center;
    transition: background 0.2s ease;
    margin-top: auto;
}

.tile-button:hover {
    background: #005a87;
    color: #fff;
}

/* Responsive Design */
@media (max-width: 1200px) {

    .waterfall-item,
    .waterfall-grid-sizer {
        width: 25% !important;
        /* 4 columns */
    }

    .waterfall-item.tile-1x1,
    .waterfall-item.tile-1x2 {
        width: 25%;
    }

    .waterfall-item.tile-2x1,
    .waterfall-item.tile-2x2 {
        width: 50% !important;
    }

    .waterfall-item.tile-3x1,
    .waterfall-item.tile-3x2,
    .waterfall-item.tile-3x3 {
        width: 75% !important;
    }
}

@media (max-width: 992px) {

    .waterfall-item,
    .waterfall-grid-sizer {
        width: 33.333% !important;
        /* 3 columns */
    }

    .waterfall-item.tile-1x1,
    .waterfall-item.tile-1x2 {
        width: 33.333%;
    }

    .waterfall-item.tile-2x1,
    .waterfall-item.tile-2x2 {
        width: 66.666% !important;
    }

    .waterfall-item.tile-3x1,
    .waterfall-item.tile-3x2,
    .waterfall-item.tile-3x3 {
        width: 100% !important;
    }
}

@media (max-width: 768px) {

    .waterfall-item,
    .waterfall-grid-sizer {
        width: 50% !important;
        /* 2 columns */
    }

    .waterfall-item.tile-1x1,
    .waterfall-item.tile-1x2,
    .waterfall-item.tile-2x1,
    .waterfall-item.tile-2x2,
    .waterfall-item.tile-3x1,
    .waterfall-item.tile-3x2,
    .waterfall-item.tile-3x3 {
        width: 50% !important;
        aspect-ratio: auto;
        /* Reset aspect ratio on mobile */
        min-height: 350px;
        /* Ensure minimum height */
    }

    .tile-content {
        padding: 15px;
    }
}

@media (max-width: 480px) {

    .waterfall-item,
    .waterfall-grid-sizer {
        width: 100% !important;
        /* 1 column */
    }

    .waterfall-item.tile-1x1,
    .waterfall-item.tile-1x2,
    .waterfall-item.tile-2x1,
    .waterfall-item.tile-2x2,
    .waterfall-item.tile-3x1,
    .waterfall-item.tile-3x2,
    .waterfall-item.tile-3x3 {
        width: 100% !important;
    }
}