// FLEX

:where(.row, .col) {
    --flex-spacing: 0;

    display: flex;
    gap: var(--flex-spacing);
    flex-wrap: wrap;
}

.row {
    flex-direction: row;
}

.col {
    flex-direction: column;
}

.flex-cluster, .flex-cluster-grow {
    display: flex;
    gap: var(--spacing);
    flex-wrap: wrap;
}

.flex-cluster-grow > * {
    flex: 1;
}

// GRID

:where(.grid-dynamic, .grid-fixed) {

    --grid-cols: auto-fill;
    --grid-rows: min-content;
    --grid-item-width: 12rem;
    --grid-justify-items: center;

    --grid-min-cols: 1;
}

.grid-dynamic {
    display: grid;
    grid-template-columns: repeat(
        auto-fit, 
        minmax(min(var(--grid-item-width), 100%), 1fr)
    );
    grid-auto-rows: var(--grid-rows);
    justify-content: space-between;
    justify-items: var(--grid-justify-items);
    place-content: var(--grid-justify-items);
    gap: var(--spacing);
    height: auto;
    width: 100%;

    & > * {
        /* --bg: var(--foreground-secondary);

        background-color: var(--bg); */
        align-self: stretch;
        width: 100%;
    }
}

.grid-fixed {

    --grid-cols: 2;
    --grid-rows: auto;

    display: grid;
    grid-template-columns: repeat(
        var(--grid-cols),
        minmax(
            min(
                var(--grid-item-width), 100%),
            1fr)
    );
    grid-template-rows: var(--grid-rows);
    justify-content: center;
    gap: var(--spacing);
}

.reel {
    --grid-auto-cols: 30%;

    display: grid;
    gap: var(--spacing);
    grid-auto-flow: column;
    grid-auto-columns: calc(var(--grid-auto-cols) - (var(--spacing) / 2));
    overflow-x: scroll;
    scroll-snap-type: x mandatory;
    scroll-padding: var(--spacing);

    & > * {
        scroll-snap-align: start;
    }
}

// Bento Grid -------------------------------------------------

:is(.big-bento, .small-bento, .bento) {

    display: grid;
    gap: var(--xs);
    grid-auto-rows: 1fr;
    aspect-ratio: 16 / 9;

    & > * {
        margin: 0;
        align-self: stretch;
        //aspect-ratio: 1;
        background-color: var(--primary);
    }

    & > img {

        object-position: center;
        object-fit: cover;
    }
}

.small-bento {

    grid-template-columns: repeat(3, 1fr);

    & :nth-child(1) {

        grid-row: span 3;
    }

    & :is(:nth-child(2), :nth-child(3)) {

        grid-row: span 2;
        grid-column: span 2;
    }

    & :nth-child(4) {

        grid-column: span -1;
    }
}

.bento {

    grid-template-columns: repeat(4, 1fr);

    & :nth-child(1) {

        grid-row: span 2;
        grid-column: span 2;
    }

    & :is(:nth-child(2), :nth-child(3)) {

        grid-row: span 2;
    }

    & :is(:nth-child(5)) {

        grid-column: span 2;
    }
}

// A Bento with 10 items

.big-bento {

    grid-template-columns: repeat(7, 1fr);

    & :is(:nth-child(1), :nth-child(3)) {

        grid-column: span 2;
    }

    & :nth-child(2) {

        grid-column: span 3;
    }

    & :is(:nth-child(4), :nth-child(5), :nth-child(7), :nth-child(8)) {
        grid-row: span 2;
    }

    & :nth-child(6) {

        grid-row: span 3;
        grid-column: span 3;
    }

    & :is(:nth-child(9), :nth-child(10)) {

        grid-column: span 2;
    }
}

// Wrapper

:where(.wrapper) {
    width: auto;
    height: auto;
    margin: 0;
    padding: 0;
}

// Background Images

.dotted-grid {

    height: 100%;
    width: 100%;

    background-image: 
        linear-gradient(
            to right, #80808012 1px, transparent 1px 
        ),

        linear-gradient(
            to bottom, #80808012 1px, transparent 1px
        )
    ;

    background-size: 24px 2px;
    background-repeat: repeat;
}