/**
 * Icon sound
 *  Custom properties and styles with configuration
 */

/**
 * Requires
 */
@use '../../abstract/config' as abstract;
@use '../../mixins/properties' as mixins;

/**
 * Component css class
 * @protected
 * @type {string} css class
 */
$class: 'ui-icon' !default;

/**
 * Component property prefix
 * @protected
 * @type {string} property name
 */
$props: 'ui-icon-' !default;

/**
 * Config defaults
 * @private
 * @type {map}
 */
$-config: (
  sound-height: 0.65,
  sound-width: 0.4,
  sound-offset: 0.05,
  sound-muted-height: 0.3,
  sound-muted-width: 0.08,
  sound-none-border: 0.08,
  sound-none-line: 0.06,
  sound-on-cap: 0.5,
  sound-on-border: 0.1,
  sound-on-offset: 0.15,
);

/**
 * Update component config options
 * @public
 * @param {map} $options - Map of config options
 * @output {void} - Only sets config options
 */
@mixin config($options) {
  $-config: abstract.config($options, $-config, false, true, 'icons-styled-sound.config::') !global;
}

/**
 * Generate required custom properties
 * @public
 * @output Adds components custom properties in current scope
 */
@mixin properties() {
  @include mixins.properties($-config, $props, '_at_', 'icons-styled-sound.properties::');
}

/**
 * Generate icon styles
 * @public
 * @output Outputs configured icon styles in given context
 */
@mixin styles() {
  .#{$class}[data-icon^="sound"] {
    span:first-child {
      &::before {
        left: calc(50% - (var(--#{$props}size) * var(--#{$props}unit) * var(--#{$props}sound-offset)));
        height: calc(var(--#{$props}size) * var(--#{$props}unit) * var(--#{$props}sound-height) / 2);
        width: calc(var(--#{$props}size) * var(--#{$props}unit) * var(--#{$props}sound-width));
        background-color: var(--#{$props}color);
      }
      &::after {
        left: calc(50% - (var(--#{$props}size) * var(--#{$props}unit) * var(--#{$props}sound-offset)));
        width: 0;
        height: 0;
        transform: translate(-50%, -50%);
        border-top: calc(var(--#{$props}size) * var(--#{$props}unit) * var(--#{$props}sound-height) / 2) solid transparent;
        border-bottom: calc(var(--#{$props}size) * var(--#{$props}unit) * var(--#{$props}sound-height) / 2) solid transparent;
        border-right: calc(var(--#{$props}size) * var(--#{$props}unit) * var(--#{$props}sound-width)) solid var(--#{$props}color);
      }
    }
  }
  .#{$class}[data-icon="sound-muted"] {
    &::before,
    &::after {
      top: calc((var(--#{$props}size) * var(--#{$props}unit) - var(--#{$props}size) * var(--#{$props}unit) * var(--#{$props}sound-muted-height)) / 2);
      left: calc(50% + var(--#{$props}size) * var(--#{$props}unit) * var(--#{$props}sound-width) / 2 + var(--#{$props}size) * var(--#{$props}unit) * var(--#{$props}sound-muted-width));
      height: calc(var(--#{$props}size) * var(--#{$props}unit) * var(--#{$props}sound-muted-height));
      width: calc(var(--#{$props}size) * var(--#{$props}unit) * var(--#{$props}sound-muted-width));
      background-color: var(--#{$props}color);
    }
    &::before {
      transform: rotate(45deg);
    }
    &::after {
      transform: rotate(-45deg);
    }
  }
  .#{$class}[data-icon="sound-none"] {
    &::before {
      width: inherit;
      height: inherit;
      border-radius: 50%;
      border: calc(var(--#{$props}size) * var(--#{$props}unit) * var(--#{$props}sound-none-border)) solid var(--#{$props}color);
    }
    &::after {
      height: 100%;
      width: calc(var(--#{$props}size) * var(--#{$props}unit) * var(--#{$props}sound-none-line));
      transform: translate(-50%, -50%) rotate(-45deg);
      background-color: var(--#{$props}color);
    }
  }
  .#{$class}[data-icon="sound-on"] {
    &::before {
      left: auto;
      right: calc(var(--#{$props}size) * var(--#{$props}unit) * var(--#{$props}sound-on-offset));
      border-top: calc(var(--#{$props}size) * var(--#{$props}unit) * var(--#{$props}sound-on-cap) / 2) solid transparent;
      border-bottom: calc(var(--#{$props}size) * var(--#{$props}unit) * var(--#{$props}sound-on-cap) / 2) solid transparent;
      border-left: calc(var(--#{$props}size) * var(--#{$props}unit) * var(--#{$props}sound-on-border)) solid var(--#{$props}color);
    }
  }
}
