/*
 * Benefits Grid
 * Layout: template-parts/flex/benefits_grid.php
 * Auto-enqueued by functions.php after css/theme.css.
 */

.benefits-grid {
    --section-pad: var(--space-3xl);
    --motif-size: 35rem;
    padding-block: calc(var(--section-pad) + var(--section-offset, 0px)) var(--space-4xl);
    position: relative;
    overflow: clip;
}

/* Colour motif, bleeding off the top-right corner behind the subheading copy. */
.benefits-grid::before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    width: var(--motif-size);
    height: var(--motif-size);
    translate: 25% -35%;
    background: url('../../assets/graphics/motif-lg-colour.svg') center / contain no-repeat;
    pointer-events: none;
}

.benefits-grid > .container {
    position: relative;
}

/* Header: heading takes the first third, the subheading copy flows in two columns beside it. */
.benefits-grid__header {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
    gap: var(--space-xl) var(--space-3xl);
    align-items: start;
    margin-bottom: var(--space-3xl);
}

/* Optional image above the heading, balancing the copy on the right. */
.benefits-grid__intro {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.benefits-grid__heading {
    margin: 0;
    color: var(--color-primary);
}

/* Any image is framed to a wide 5:2 shape and centre-cropped by the browser, so editors never have to crop uploads. */
.benefits-grid__image {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: .875rem;
}

.benefits-grid__subheading {
    columns: 2;
    column-gap: var(--space-xl);
    font-weight: var(--font-light);
}

.benefits-grid__subheading > * {
    break-inside: avoid;
    margin-block: 0 var(--space-sm);
}

.benefits-grid__subheading > :first-child {
    font-weight: var(--font-regular);
}

.benefits-grid__subheading > :last-child {
    margin-block-end: 0;
}

/* Benefits: wraps at four per row, fewer items keep the same column width. */
.benefits-grid__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr));
    gap: var(--space-2xl) var(--space-lg);
}

.benefit {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    padding-top: var(--space-md);
    border-top: 2px solid var(--color-secondary);
}

/* Icon, sized and fitted the same as .tile__icon in tile-grid.css. */
.benefit__icon {
    width: 3.75rem;
    height: 3.75rem;
    object-fit: contain;
    margin-bottom: var(--space-sm);
}

.benefit__title {
    margin: 0;
    font-size: var(--text-2);
    color: var(--color-primary);
}

.benefit__description {
    margin: 0;
    font-weight: var(--font-light);
}

@media screen and (max-width: 1024px) {

    .benefits-grid__header {
        grid-template-columns: 1fr;
        gap: var(--space-lg);
        margin-bottom: var(--space-2xl);
    }

    .benefits-grid__heading {
        font-size: var(--text-4);
    }

}

@media screen and (max-width: 768px) {

    .benefits-grid {
        --motif-size: 20rem;
    }

    .benefits-grid__subheading {
        columns: 1;
    }

}
