@use "sass:map";
@use "@theholocron/config/src" as config;
@use "@theholocron/scss-mixins/src/at-rules/breakpoints" as *;
@use "@theholocron/scss-mixins/src/backgrounds-borders/" as *;

/// The border-color property
/// @since 0.1.0
/// @link https://developer.mozilla.org/en-US/docs/Web/CSS/border-color
/// @param {String} $className ["border-color"] - a CSS class name that will prefix all helpers
/// @param {Map} $breakpoints [config.$breakpoints] - a map of grid breakpoints
/// @param {Map} $colors [config.$border-colors] - a map of colors for borders
/// @example scss
///   @include border-color($className: bs, $breakpoints: ("sm": 480px));
@mixin border-colors($className: "border-color", $breakpoints: config.$breakpoints, $colors: config.$border-colors) {
	.#{$className} {
		@each $key, $value in $colors {
			@each $abbrev, $direction in config.$box-directions {
				@if $abbrev == "all" {
					&-#{$key} {
						@include border-color($color: $value, $direction: $abbrev);
					}

					@each $breakpoint in map.keys($breakpoints) {
						@include media-breakpoint-up($name: $breakpoint, $breakpoints: $breakpoints) {
							&-#{$key}-#{$breakpoint},
							&-#{$key}-#{$breakpoint}-up {
								@include border-color($color: $value, $direction: $abbrev);
							}
						}

						@include media-breakpoint-down($name: $breakpoint, $breakpoints: $breakpoints) {
							&-#{$key}-#{$breakpoint}-down {
								@include border-color($color: $value, $direction: $abbrev);
							}
						}

						@include media-breakpoint-only($name: $breakpoint, $breakpoints: $breakpoints) {
							&-#{$key}-#{$breakpoint}-only {
								@include border-color($color: $value, $direction: $abbrev);
							}
						}
					}
				} @else {
					&-#{$abbrev}-#{$key} {
						@include border-color($color: $value, $direction: $abbrev);
					}

					@each $breakpoint in map.keys($breakpoints) {
						@include media-breakpoint-up($name: $breakpoint, $breakpoints: $breakpoints) {
							&-#{$abbrev}-#{$key}-#{$breakpoint},
							&-#{$abbrev}-#{$key}-#{$breakpoint}-up {
								@include border-color($color: $value, $direction: $abbrev);
							}
						}

						@include media-breakpoint-down($name: $breakpoint, $breakpoints: $breakpoints) {
							&-#{$abbrev}-#{$key}-#{$breakpoint}-down {
								@include border-color($color: $value, $direction: $abbrev);
							}
						}

						@include media-breakpoint-only($name: $breakpoint, $breakpoints: $breakpoints) {
							&-#{$abbrev}-#{$key}-#{$breakpoint}-only {
								@include border-color($color: $value, $direction: $abbrev);
							}
						}
					}
				}
			}
		}
	}
}
