/**
 * ForgR Homepage Layout: MOSAIC
 * Style mosaïque avec variations de tailles
 */

body.layout-mosaic .wp-block-latest-posts,
body.layout-mosaic .wp-block-latest-posts__list,
.forgr-mosaic-layout {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    padding: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    list-style: none !important;
}

/* All cards base style */
body.layout-mosaic .wp-block-latest-posts li,
.forgr-mosaic-layout li {
    background: var(--card-bg, #fff);
    border-radius: var(--card-border-radius, 0);
    box-shadow: var(--card-shadow, none);
    border: var(--card-border, 4px solid var(--font-color, #000));
    overflow: hidden;
    transition: var(--card-transition, all 0.3s ease);
    display: flex;
    flex-direction: column;
    padding: 0;
    margin: 0 !important;
    position: relative;
    cursor: pointer;
}

body.layout-mosaic .wp-block-latest-posts li:hover,
.forgr-mosaic-layout li:hover {
    transform: var(--card-hover-transform, translate(-4px, -4px));
    box-shadow: var(--card-hover-shadow, 8px 8px 0 var(--secondary-color, #F97316));
    border-color: var(--secondary-color, #F97316);
}

/* First article - hero: image 50% height, content 50% */
body.layout-mosaic .wp-block-latest-posts li:first-child,
.forgr-mosaic-layout li:first-child {
    grid-column: span 2;
    grid-row: span 2;
    min-height: 600px;
    display: flex;
    flex-direction: column;
}

/* First article image - exactly 50% of card height */
body.layout-mosaic .wp-block-latest-posts li:first-child .wp-block-latest-posts__featured-image,
.forgr-mosaic-layout li:first-child .wp-block-latest-posts__featured-image {
    flex: 0 0 50% !important;
    height: 50% !important;
    max-height: 50% !important;
    width: 100% !important;
    overflow: hidden;
    aspect-ratio: unset !important;
}

body.layout-mosaic .wp-block-latest-posts li:first-child .wp-block-latest-posts__featured-image img,
.forgr-mosaic-layout li:first-child .wp-block-latest-posts__featured-image img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
}

/* First article content - remaining 50% */
body.layout-mosaic .wp-block-latest-posts li:first-child .wp-block-latest-posts__post-title,
body.layout-mosaic .wp-block-latest-posts li:first-child .wp-block-latest-posts__post-date,
body.layout-mosaic .wp-block-latest-posts li:first-child .wp-block-latest-posts__post-excerpt {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
}

body.layout-mosaic .wp-block-latest-posts li:first-child .wp-block-latest-posts__post-title {
    font-size: 1.75rem;
    margin-top: 1.5rem;
}

/* More excerpt text for first article */
body.layout-mosaic .wp-block-latest-posts li:first-child .wp-block-latest-posts__post-excerpt,
.forgr-mosaic-layout li:first-child .wp-block-latest-posts__post-excerpt {
    -webkit-line-clamp: 5;
    max-height: none;
    font-size: 1rem;
}

/* Wide card - 4th position */
body.layout-mosaic .wp-block-latest-posts li:nth-child(4),
.forgr-mosaic-layout li:nth-child(4) {
    grid-column: span 2;
}

/* Regular cards - featured image */
body.layout-mosaic .wp-block-latest-posts__featured-image,
.forgr-mosaic-layout .wp-block-latest-posts__featured-image {
    width: 100%;
    aspect-ratio: 16/10;
    overflow: hidden;
    margin: 0;
}

body.layout-mosaic .wp-block-latest-posts__featured-image img,
.forgr-mosaic-layout .wp-block-latest-posts__featured-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

body.layout-mosaic .wp-block-latest-posts li:hover img,
.forgr-mosaic-layout li:hover img {
    transform: scale(1.05);
}

/* Post title */
body.layout-mosaic .wp-block-latest-posts__post-title,
.forgr-mosaic-layout .wp-block-latest-posts__post-title {
    font-size: 1.1rem;
    line-height: 1.3;
    margin: 1rem 1rem 0.5rem;
    color: var(--card-title-color, #000);
    text-decoration: none;
    font-weight: 700;
    text-transform: uppercase;
}

body.layout-mosaic .wp-block-latest-posts__post-title:hover,
.forgr-mosaic-layout .wp-block-latest-posts__post-title:hover {
    color: var(--secondary-color, #F97316) !important;
}

/* Post excerpt */
body.layout-mosaic .wp-block-latest-posts__post-excerpt,
.forgr-mosaic-layout .wp-block-latest-posts__post-excerpt {
    font-size: 0.9rem;
    color: var(--text-muted, #666);
    margin: 0 1rem 1rem;
    line-height: 1.5;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Hide Read more / Lire la suite */
body.layout-mosaic .read-more,
body.layout-mosaic .wp-block-latest-posts__post-excerpt a,
.forgr-mosaic-layout .read-more,
.forgr-mosaic-layout .wp-block-latest-posts__post-excerpt a {
    display: none !important;
}

/* Post date */
body.layout-mosaic .wp-block-latest-posts__post-date,
.forgr-mosaic-layout .wp-block-latest-posts__post-date {
    font-size: 0.75rem;
    color: var(--card-meta-color, #666);
    margin: 0 1rem 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Make card clickable via title stretch */
body.layout-mosaic .wp-block-latest-posts__post-title::after,
.forgr-mosaic-layout .wp-block-latest-posts__post-title::after {
    content: ;
    position: absolute;
    inset: 0;
    z-index: 1;
}

/* Responsive */
@media (max-width: 1024px) {
    body.layout-mosaic .wp-block-latest-posts,
    .forgr-mosaic-layout {
        grid-template-columns: repeat(2, 1fr);
    }
    
    body.layout-mosaic .wp-block-latest-posts li:first-child,
    .forgr-mosaic-layout li:first-child {
        grid-column: span 2;
        grid-row: span 1;
        min-height: 450px;
    }
    
    body.layout-mosaic .wp-block-latest-posts li:nth-child(4),
    .forgr-mosaic-layout li:nth-child(4) {
        grid-column: span 1;
    }
}

@media (max-width: 767px) {
    body.layout-mosaic .wp-block-latest-posts,
    .forgr-mosaic-layout {
        grid-template-columns: 1fr;
        padding: 1rem;
    }
    
    body.layout-mosaic .wp-block-latest-posts li:first-child,
    body.layout-mosaic .wp-block-latest-posts li:nth-child(4),
    .forgr-mosaic-layout li:first-child,
    .forgr-mosaic-layout li:nth-child(4) {
        grid-column: span 1;
        min-height: 400px;
    }
}
