@use "sass:math";
@use "../termeh" as T;

.landscape {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    box-sizing: border-box;
    overflow: hidden;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    @include T.overflow-touch();
    @include T.scrollable(T.color("primary"));

    > * {
        scroll-snap-align: start;
        flex-shrink: 0;
    }

    &.is-center-snapped > * {
        scroll-snap-align: center;
    }

    &.is-end-snapped > * {
        scroll-snap-align: end;
    }

    &.is-mandatory {
        scroll-snap-type: x mandatory;
    }

    &.is-stacked {
        flex-direction: column;
        overflow-x: hidden;
        overflow-y: auto;
        scroll-snap-type: y proximity;

        &.is-mandatory {
            scroll-snap-type: y mandatory;
        }
    }

    &:not(.is-gapless) {
        margin: T.negate(T.gap("micro"));

        > * {
            margin: T.gap("micro");
        }

        @each $name, $gap in T.gaps(T.var("landscape", "gaps", ())) {
            &.is-#{$name}-gaped {
                margin: T.negate(math.div($gap, 2));

                > * {
                    margin: math.div($gap, 2);
                }
            }
        }
    }

    $-aligns: stretch, flex-start, flex-end, center, baseline;
    @each $align in $-aligns {
        &.is-#{$align}-aligned {
            align-items: $align;
        }
    }

    $-justifies: flex-start, flex-end, center, space-between, space-around,
        space-evenly;
    @each $justify in $-justifies {
        &.is-#{$justify}-justified {
            justify-content: $justify;
        }
    }

    @each $device, $query in T.media-queries() {
        @media #{$query} {
            &.is-#{$device}-stacked {
                flex-direction: column;
                overflow: hidden;
                overflow-y: auto;
                scroll-snap-type: y proximity;
                align-items: stretch;

                &.is-mandatory {
                    scroll-snap-type: y mandatory;
                }
            }

            @each $align in $-aligns {
                &.is-#{$device}-#{$align}-aligned {
                    align-items: $align;
                }
            }

            @each $justify in $-justifies {
                &.is-#{$device}-#{$justify}-justified {
                    justify-content: $justify;
                }
            }
        }
    }
}
