@function columns($columns) {
    @return calc(
        (#{$columns} * var(--layout-column-width)) +
            ((#{$columns} - 1) * var(--layout-column-gap))
    );
}

@mixin child-grid($columns) {
    grid-template-columns: repeat($columns, minmax(0, 1fr));
    column-gap: var(--layout-columns-gap);
    display: grid;
}

@mixin reduced-motion {
    @media (prefers-reduced-motion: reduce) {
        @content;
    }
}

@mixin fade-on-ready($class: 'ready', $duration: 400ms) {
    opacity: 0;
    transition: opacity $duration ease;

    &.#{$class} {
        opacity: 1;
    }
}

// Clamp text block to number of lines
@mixin line-clamp($lines: 3) {
    display: -webkit-box;
    overflow: hidden;
    text-overflow: ellipsis;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: $lines;
}

@mixin stagger-animate($stagger: 100, $num-children: 10, $base-delay: 0) {
    @for $i from 0 through $num-children {
        &:nth-child(#{$i + 1}) {
            transition-delay: #{$stagger * $i + $base-delay}ms;
        }
    }
}

@mixin hover {
    &:hover {
        @content;
    }
}

@mixin drop-cap() {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 400 !important;

    &:first-child::first-letter {
        font-family: var(--font-display);
        font-size: 42px;
    }
}
