////
///
/// Glow Animations Mixin Module
/// ===========================================================================
///
/// Provides glowing effects using animated box-shadows. Includes pulse glow,
/// color shifting, and multi-color rainbow variants. Perfect for buttons,
/// highlights, and emphasis effects.
///
/// @group Animations
/// @author Scape Agency
/// @link https://move.gl
/// @since 0.1.0 initial release
/// @access public
///
////


// ============================================================================
// Use
// ============================================================================

@use "sass:math";
@use "sass:list";
@use "../../dev" as *;
@use "../../variables" as *;
@use "../keyframes" as *;
@use "base" as *;


// ============================================================================
// Mixins
// ============================================================================


///
/// Glow Animation
/// ---------------------------------------------------------------------------
/// Creates a glowing effect by animating the box shadow of the element.
///
/// @name animate_glow
/// @param {Color} $color [$animate_base_color_glow_01] - The color of the glow
/// @param {Length} $start_shadow_size [5px] - Initial shadow size
/// @param {Length} $end_shadow_size [15px] - Maximum shadow size
/// @param {Time} $duration [$animate_base_duration] - Animation duration
/// @param {String} $timing_function [ease-in-out] - Timing function
/// @param {Number|String} $iteration_count - Number of iterations
///
/// @example scss - Basic usage
///   .button {
///     @include animate_glow;
///   }
///
@mixin animate_glow(
    $color: $animate_base_color_glow_01,
    $start_shadow_size: 5px,
    $end_shadow_size: 15px,
    $duration: $animate_base_duration,
    $timing_function: ease-in-out,
    $iteration_count: $animate_base_iteration_count
) {
    @include animate_base(
        animate_glow,
        $duration,
        $timing_function,
        $iteration_count,
    );
    @keyframes animate_glow {
        0%, 100% { box-shadow: 0 0 $start_shadow_size 0 $color; }
        50% { box-shadow: 0 0 $end_shadow_size 5px $color; }
    }
}


///
/// Pulse Glow Animation
/// ---------------------------------------------------------------------------
/// Creates a pulsing glow effect where the glow size changes over time.
///
/// @name animate_glow_pulse
/// @param {Color} $color [$animate_base_color_glow_01] - The color of the glow
/// @param {Time} $duration [$animate_base_duration] - Animation duration
/// @param {String} $timing_function [ease-in-out] - Timing function
/// @param {Number|String} $iteration_count - Number of iterations
///
/// @example scss - Usage
///   .notification {
///     @include animate_glow_pulse;
///   }
///
@mixin animate_glow_pulse(
    $color: $animate_base_color_glow_01,
    $duration: $animate_base_duration,
    $timing_function: ease-in-out,
    $iteration_count: $animate_base_iteration_count
) {
    @include animate_base(
        animate_glow_pulse,
        $duration,
        $timing_function,
        $iteration_count,
    );
    @keyframes animate_glow_pulse {
        0%, 100% { box-shadow: 0 0 10px -5px $color; }
        50% { box-shadow: 0 0 20px 0 $color; }
    }
}


///
/// Soft Glow Animation
/// ---------------------------------------------------------------------------
/// Creates a soft glow effect with a slower and subtler animation.
///
/// @name animate_glow_soft
/// @param {Color} $color [$animate_base_color_glow_01] - The color of the glow
/// @param {Time} $duration [$animate_base_duration_slow] - Animation duration
/// @param {String} $timing_function [ease-in-out] - Timing function
/// @param {Number|String} $iteration_count - Number of iterations
///
/// @example scss - Usage
///   .card {
///     @include animate_glow_soft;
///   }
///
@mixin animate_glow_soft(
    $color: $animate_base_color_glow_01,
    $duration: $animate_base_duration_slow,
    $timing_function: ease-in-out,
    $iteration_count: $animate_base_iteration_count
) {
    @include animate_base(
        animate_glow_soft,
        $duration,
        $timing_function,
        $iteration_count,
    );
    @keyframes animate_glow_soft {
        0%, 100% { box-shadow: 0 0 10px 0 rgba($color, 0.5); }
        50% { box-shadow: 0 0 20px 5px rgba($color, 0.8); }
    }
}

.animate_glow_soft {
    @include animate_glow_soft($animate_base_color_glow_01);
}


///
/// Multi-Color Glow Animation
/// ---------------------------------------------------------------------------
/// Creates a glow animation that cycles through multiple colors.
///
/// @name animate_glow_multicolor
/// @param {List} $colors - A list of colors for the glow animation
/// @param {Time} $duration [$animate_base_duration_slow] - Animation duration
/// @param {String} $timing_function [linear] - Timing function
/// @param {Number|String} $iteration_count - Number of iterations
///
/// @example scss - Usage
///   .rainbow-button {
///     @include animate_glow_multicolor;
///   }
///
@mixin animate_glow_multicolor(
    $colors: (
        $animate_base_color_glow_01,
        $animate_base_color_glow_02,
        $animate_base_color_glow_03,
    ),
    $duration: $animate_base_duration_slow,
    $timing_function: linear,
    $iteration_count: $animate_base_iteration_count
) {
    @include animate_base(
        animate_glow_multicolor,
        $duration,
        $timing_function,
        $iteration_count,
    );
    $total_colors: list.length($colors);
    @keyframes animate_glow_multicolor {
        @for $i from 1 through $total_colors {
            #{math.percentage(math.div(($i - 1), $total_colors))},
            #{math.percentage(math.div($i, $total_colors))} {
                    box-shadow: 0 0 10px 5px list.nth($colors, $i);
            }
        }
    }
}
