/*
 * Copyright (c) 2026, Salesforce, Inc.,
 * All rights reserved.
 * For full license text, see the LICENSE.txt file
 */

/**
 * Initializes ellie icon
 */
.slds-icon-ellie {
  width: calc(14rem / 16);
  height: calc(14rem / 16);
  display: inline-block;
  overflow: hidden;

  /**
   * Add .slds-is-animated to the SVG to enhance the icon with an animation.
   */
  &.slds-is-animated {
    will-change: transform;
    animation: slds-icon-ellie-pop 0.3s ease-in 2s 1 both;

    svg {
      will-change: transform;
      animation: slds-icon-ellie 1.2s steps(20) 2.3s 2 alternate;
    }
  }

  /**
   * Add .slds-is-paused to the SVG to pause the icon with an animation.
   */
  &.slds-is-paused {
    &,
    svg {
      animation-play-state: paused;
    }
  }

  svg {
    width: 17.5rem;
    vertical-align: top;
    color: var(--slds-g-color-accent-1);
  }

  circle:nth-child(2n + 1) {
    fill: currentColor;
    stroke: currentColor;
    stroke-width: 4px;
  }

  circle:nth-child(2n) {
    fill: var(--slds-g-color-on-accent-1);
    stroke: var(--slds-g-color-on-accent-1);
    stroke-width: 1px;
  }
}

/* Generate styles for each frame, based on steps defined in $_ellie-frameset */
.slds-icon-ellie circle:nth-child(1),
.slds-icon-ellie circle:nth-last-child(2) {
  stroke-width: 4px;
}

.slds-icon-ellie circle:nth-child(2),
.slds-icon-ellie circle:nth-last-child(1) {
  stroke-width: 1px;
}

.slds-icon-ellie circle:nth-child(3),
.slds-icon-ellie circle:nth-last-child(4) {
  stroke-width: 3.95px;
}

.slds-icon-ellie circle:nth-child(4),
.slds-icon-ellie circle:nth-last-child(3) {
  stroke-width: 1.2px;
}

.slds-icon-ellie circle:nth-child(5),
.slds-icon-ellie circle:nth-last-child(6) {
  stroke-width: 3.85px;
}

.slds-icon-ellie circle:nth-child(6),
.slds-icon-ellie circle:nth-last-child(5) {
  stroke-width: 1.4px;
}

.slds-icon-ellie circle:nth-child(7),
.slds-icon-ellie circle:nth-last-child(8) {
  stroke-width: 3.6px;
}

.slds-icon-ellie circle:nth-child(8),
.slds-icon-ellie circle:nth-last-child(7) {
  stroke-width: 1.7px;
}

.slds-icon-ellie circle:nth-child(9),
.slds-icon-ellie circle:nth-last-child(10) {
  stroke-width: 3.3px;
}

.slds-icon-ellie circle:nth-child(10),
.slds-icon-ellie circle:nth-last-child(9) {
  stroke-width: 2px;
}

.slds-icon-ellie circle:nth-child(11),
.slds-icon-ellie circle:nth-last-child(12) {
  stroke-width: 3.2px;
}

.slds-icon-ellie circle:nth-child(12),
.slds-icon-ellie circle:nth-last-child(11) {
  stroke-width: 2.4px;
}

.slds-icon-ellie circle:nth-child(13),
.slds-icon-ellie circle:nth-last-child(14) {
  stroke-width: 3.15px;
}

.slds-icon-ellie circle:nth-child(14),
.slds-icon-ellie circle:nth-last-child(13) {
  stroke-width: 2.8px;
}

.slds-icon-ellie circle:nth-child(15),
.slds-icon-ellie circle:nth-last-child(16) {
  stroke-width: 3.1px;
}

.slds-icon-ellie circle:nth-child(16),
.slds-icon-ellie circle:nth-last-child(15) {
  stroke-width: 3.25px;
}

.slds-icon-ellie circle:nth-child(17),
.slds-icon-ellie circle:nth-last-child(18) {
  stroke-width: 3.05px;
}

.slds-icon-ellie circle:nth-child(18),
.slds-icon-ellie circle:nth-last-child(17) {
  stroke-width: 3.7px;
}

.slds-icon-ellie circle:nth-child(19),
.slds-icon-ellie circle:nth-last-child(20) {
  stroke-width: 3px;
}

.slds-icon-ellie circle:nth-child(20),
.slds-icon-ellie circle:nth-last-child(19) {
  stroke-width: 4px;
}

@keyframes slds-icon-ellie-pop {
  0% {
    transform: scale(0.2);
  }
  70% {
    transform: scale(1.1);
  }
  90% {
    transform: scale(0.7);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes slds-icon-ellie {
  to {
    transform: translateX(-17.5rem);
  }
}

/**
 * Initializes equalizer (eq) icon
 */
.slds-icon-eq {
  position: relative;
  width: calc(14rem / 16);
  height: calc(14rem / 16);

  /**
   * Turn animation on for animated icon
   */
  &.slds-is-animated {
    .slds-icon-eq__bar {
      animation: slds-icon-eq 0.25s ease-in-out infinite alternate;
      will-change: transform;
      /* Reset bar height */
      height: 0.1875rem;

      &:nth-of-type(2) {
        animation-duration: 0.65s;
      }

      &:nth-of-type(3) {
        animation-duration: 0.35s;
      }
    }
  }
}

/**
 * Vertical bar for equalizer icon
 */
.slds-icon-eq__bar {
  position: absolute;
  bottom: 0;
  inset-inline-start: 0;
  width: calc(4rem / 16);
  height: 0.5625rem;
  background: var(--slds-g-color-accent-1);
  transform: scaleY(1);
  transform-origin: bottom;

  &:nth-of-type(2) {
    inset-inline-start: calc(5rem / 16);
    height: 0.875rem;
  }

  &:nth-of-type(3) {
    inset-inline-start: calc(10rem / 16);
    height: 0.75rem;
  }
}

@keyframes slds-icon-eq {
  to {
    /* stylelint-disable number-max-precision */
    transform: scaleY(4.6666666667);
    /* stylelint-enable number-max-precision */
  }
}

/**
 * Initializes score icon
 */
.slds-icon-score {
  display: inline-block;
  width: 0.3125rem;
  height: 0.3125rem;
  position: relative;
}

/* We are variying opacity (instead of stroke & fill)
because it is a more performant way of achieving this effect */
.slds-icon-score__positive,
.slds-icon-score__negative {
  position: absolute;
  opacity: 0;
  transition: opacity 0.4s ease-in-out;
  will-change: opacity;
  stroke-width: 1.125px;
}

/**
 * Positive score icon
 */
.slds-icon-score__positive {
  fill: var(--slds-g-color-success-1);
  stroke: var(--slds-g-color-success-1);
}

/**
 * Negative score icon
 */
.slds-icon-score__negative {
  fill: transparent;
  stroke: var(--slds-g-color-error-1);
}

[data-slds-state='positive'] .slds-icon-score__positive,
[data-slds-state='negative'] .slds-icon-score__negative {
  opacity: 1;
}

/**
 * Base icon size and appearance
 * 1. Each dot is an SVG <circle> element
 * 2. Adds transitions when the strength changes.
 *    Modifying the data-slds-strength attribute in JavaScript should
 *    animate the dots nicely.
 * 3. Let the browser know which properties are going to change,
 *    enabling it to optimize rendering speed as best it can
 */

/**
 * Initializes strength icon
 */
.slds-icon-strength {
  width: 1.6875rem;
  height: 0.4375rem;
  display: inline-block;

  circle {
    /* 1 */
    stroke-width: 0.95px;
    fill: transparent;
    stroke: var(--slds-g-color-border-2);
    /* 2 */
    transition:
      fill 0.4s ease-in-out,
      stroke 0.4s ease-in-out;
    /* 3 */
    will-change: fill, stroke;
  }

  /**
   * Strength States
   *
   * The strength is controlled via the data-slds-strength attribute.
   *
   * These styles adapt the stroke and fill depending on the strength level.
   *
   * <svg data-slds-strength="[Number]">
   * 0. no active dots
   * (-)1. one active dot
   * (-)2. two active dots
   * (-)3. all dots active
   */
  &[data-slds-strength='1'] circle:nth-child(1),
  &[data-slds-strength='2'] circle:nth-child(1),
  &[data-slds-strength='2'] circle:nth-child(2),
  &[data-slds-strength='3'] circle:nth-child(1),
  &[data-slds-strength='3'] circle:nth-child(2),
  &[data-slds-strength='3'] circle:nth-child(3) {
    fill: var(--slds-g-color-success-1);
    stroke: var(--slds-g-color-success-1);
  }

  &[data-slds-strength='-1'] circle:nth-child(1),
  &[data-slds-strength='-2'] circle:nth-child(1),
  &[data-slds-strength='-2'] circle:nth-child(2),
  &[data-slds-strength='-3'] circle:nth-child(1),
  &[data-slds-strength='-3'] circle:nth-child(2),
  &[data-slds-strength='-3'] circle:nth-child(3) {
    fill: var(--slds-g-color-error-container-1);
    stroke: var(--slds-g-color-error-1);
  }

  /**
   * Add .slds-is-animated to the SVG to enhance the icon with an animation.
   */
  &.slds-is-animated {
    circle {
      /* Adjust this value to add a delay to the whole animation */
      animation: slds-icon-strength-positive-load 0.4s 1s ease-in-out alternate both paused;

      &:nth-child(2) {
        animation-delay: 1.4s;
      }

      &:nth-child(3) {
        animation-delay: 1.8s;
      }
    }

    &[data-slds-strength^='-'] circle {
      animation-name: slds-icon-strength-negative-load;
    }

    &[data-slds-strength='-1'] circle:nth-child(1),
    &[data-slds-strength='-2'] circle:nth-child(1),
    &[data-slds-strength='-2'] circle:nth-child(2),
    &[data-slds-strength='-3'] circle:nth-child(1),
    &[data-slds-strength='-3'] circle:nth-child(2),
    &[data-slds-strength='-3'] circle:nth-child(3),
    &[data-slds-strength='1'] circle:nth-child(1),
    &[data-slds-strength='2'] circle:nth-child(1),
    &[data-slds-strength='2'] circle:nth-child(2),
    &[data-slds-strength='3'] circle:nth-child(1),
    &[data-slds-strength='3'] circle:nth-child(2),
    &[data-slds-strength='3'] circle:nth-child(3) {
      animation-play-state: running;
    }
  }

  /**
   * Add .slds-is-paused to the SVG to pause the icon with an animation.
   */
  &.slds-is-paused circle {
    /* stylelint-disable declaration-no-important */
    animation-play-state: paused !important;
    /* stylelint-enable declaration-no-important */
  }
}

@keyframes slds-icon-strength-positive-load {
  0% {
    fill: transparent;
    stroke: var(--slds-g-color-border-2);
  }
  100% {
    fill: var(--slds-g-color-success-1);
    stroke: var(--slds-g-color-success-1);
  }
}

@keyframes slds-icon-strength-negative-load {
  0% {
    fill: transparent;
    stroke: var(--slds-g-color-border-2);
  }
  100% {
    /* TODO: fill: var(--slds-g-color-palette-pink-90, #{$palette-pink-90}); */
    fill: var(--slds-g-color-error-container-1);
    stroke: var(--slds-g-color-error-1);
  }
}

/**
 * Initializes trend icon
 */
.slds-icon-trend {
  width: 1rem;
  height: 1rem;
  display: inline-block;

  /**
   * Add .slds-is-animated to the SVG to enhance the icon with an animation.
   */
  &.slds-is-animated {
    .slds-icon-trend__arrow {
      animation: slds-icon-trend-arrow 0.8s 0.4s ease-in-out both;
    }

    .slds-icon-trend__circle {
      animation: slds-icon-trend-circle 0.8s ease-in-out both;
    }
  }

  /**
   * Add .slds-is-paused to the SVG to pause the icon with an animation.
   */
  &.slds-is-paused {
    .slds-icon-trend__arrow,
    .slds-icon-trend__circle {
      animation-play-state: paused;
    }
  }
}

.slds-icon-trend[data-slds-trend='down'] {
  color: var(--slds-g-color-error-1);
  transform: rotate(45deg);
}

.slds-icon-trend[data-slds-trend='neutral'] {
  color: var(--slds-g-color-on-surface-1);
}

.slds-icon-trend[data-slds-trend='up'] {
  color: var(--slds-g-color-success-1);
  transform: rotate(-45deg);
}

.slds-icon-trend__arrow,
.slds-icon-trend__circle {
  stroke: currentColor;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.125px;
}

/**
 * Arrow element inside of trend icon
 */
.slds-icon-trend__arrow {
  stroke-dashoffset: 0.1px;
  stroke-dasharray: 39.175px;
}

/**
 * Circle element inside of trend icon
 */
.slds-icon-trend__circle {
  stroke-dasharray: 42.3385px, 46.3385px;
}

@keyframes slds-icon-trend-arrow {
  from {
    stroke-dashoffset: 40.3px;
  }
}

@keyframes slds-icon-trend-circle {
  from {
    stroke-dasharray: 0.1px, 46.3385px;
  }
}

/* TODO: Loop is hard coded because no time, may revisit later */
/**
 * Containing actionable element that holds the waffle icon
 */
.slds-icon-waffle_container {
  border: 0;
  outline: 0;
  min-height: unset;

  &:focus-visible {
    box-shadow: var(--slds-g-shadow-outline-focus-1);
    outline: 0;
  }
}

.slds-icon-waffle_container:hover .slds-r1,
.slds-icon-waffle_container:hover .slds-r2,
.slds-icon-waffle_container:hover .slds-r3,
.slds-icon-waffle_container:hover .slds-r4,
.slds-icon-waffle_container:hover .slds-r5,
.slds-icon-waffle_container:hover .slds-r6,
.slds-icon-waffle_container:hover .slds-r7,
.slds-icon-waffle_container:hover .slds-r8,
.slds-icon-waffle_container:hover .slds-r9,
.slds-icon-waffle_container:focus .slds-r1,
.slds-icon-waffle_container:focus .slds-r2,
.slds-icon-waffle_container:focus .slds-r3,
.slds-icon-waffle_container:focus .slds-r4,
.slds-icon-waffle_container:focus .slds-r5,
.slds-icon-waffle_container:focus .slds-r6,
.slds-icon-waffle_container:focus .slds-r7,
.slds-icon-waffle_container:focus .slds-r8,
.slds-icon-waffle_container:focus .slds-r9 {
  animation: slds-icon-waffle-throb 2 200ms alternate;
}

.slds-icon-waffle_container:hover .slds-r1,
.slds-icon-waffle_container:hover .slds-r2,
.slds-icon-waffle_container:hover .slds-r3,
.slds-icon-waffle_container:focus .slds-r1,
.slds-icon-waffle_container:focus .slds-r2,
.slds-icon-waffle_container:focus .slds-r3 {
  background-color: var(--slds-g-color-accent-1);
}

.slds-icon-waffle_container:hover .slds-r4,
.slds-icon-waffle_container:hover .slds-r5,
.slds-icon-waffle_container:hover .slds-r7,
.slds-icon-waffle_container:focus .slds-r4,
.slds-icon-waffle_container:focus .slds-r5,
.slds-icon-waffle_container:focus .slds-r7 {
  background-color: var(--slds-g-color-warning-base-70);
}

.slds-icon-waffle_container:hover .slds-r6,
.slds-icon-waffle_container:hover .slds-r8,
.slds-icon-waffle_container:hover .slds-r9,
.slds-icon-waffle_container:focus .slds-r6,
.slds-icon-waffle_container:focus .slds-r8,
.slds-icon-waffle_container:focus .slds-r9 {
  background-color: var(--slds-g-color-palette-yellow-80);
}

.slds-icon-waffle_container:hover .slds-r2,
.slds-icon-waffle_container:hover .slds-r4,
.slds-icon-waffle_container:focus .slds-r2,
.slds-icon-waffle_container:focus .slds-r4 {
  transition-delay: 50ms;
  animation-delay: 50ms;
}

.slds-icon-waffle_container:hover .slds-r3,
.slds-icon-waffle_container:hover .slds-r5,
.slds-icon-waffle_container:hover .slds-r7,
.slds-icon-waffle_container:focus .slds-r3,
.slds-icon-waffle_container:focus .slds-r5,
.slds-icon-waffle_container:focus .slds-r7 {
  transition-delay: 100ms;
  animation-delay: 100ms;
}

.slds-icon-waffle_container:hover .slds-r6,
.slds-icon-waffle_container:hover .slds-r8,
.slds-icon-waffle_container:focus .slds-r6,
.slds-icon-waffle_container:focus .slds-r8 {
  transition-delay: 150ms;
  animation-delay: 150ms;
}

.slds-icon-waffle_container:hover .slds-r9,
.slds-icon-waffle_container:focus .slds-r9 {
  transition-delay: 200ms;
  animation-delay: 200ms;
}

/**
 * Element container circles for the waffle icon
 */
.slds-icon-waffle {
  width: 1.3125rem;
  height: 1.3125rem;
  position: relative;
  display: block;
  cursor: pointer;
}

.slds-icon-waffle .slds-r1,
.slds-icon-waffle .slds-r2,
.slds-icon-waffle .slds-r3,
.slds-icon-waffle .slds-r4,
.slds-icon-waffle .slds-r5,
.slds-icon-waffle .slds-r6,
.slds-icon-waffle .slds-r7,
.slds-icon-waffle .slds-r8,
.slds-icon-waffle .slds-r9 {
  width: 0.3125rem;
  height: 0.3125rem;
  background-color: var(--slds-g-color-neutral-base-50, #747474);
  display: inline-block;
  position: absolute;
  border-radius: 50%;
  transition: background-color 100ms;
  transform-origin: 50% 50%;
  will-change: scale, background-color;
  border: 2px solid transparent;
}

/* Positioning */
.slds-icon-waffle .slds-r1 {
  top: 0;
  inset-inline-start: 0;
}

.slds-icon-waffle .slds-r2 {
  top: 0;
  inset-inline-start: 0.5rem;
}

.slds-icon-waffle .slds-r3 {
  top: 0;
  inset-inline-end: 0;
}

.slds-icon-waffle .slds-r4 {
  top: 0.5rem;
  inset-inline-start: 0;
}

.slds-icon-waffle .slds-r5 {
  top: 0.5rem;
  inset-inline-start: 0.5rem;
}

.slds-icon-waffle .slds-r6 {
  top: 0.5rem;
  inset-inline-end: 0;
}

.slds-icon-waffle .slds-r7 {
  bottom: 0;
  inset-inline-start: 0;
}

.slds-icon-waffle .slds-r8 {
  bottom: 0;
  inset-inline-start: 0.5rem;
}

.slds-icon-waffle .slds-r9 {
  bottom: 0;
  inset-inline-end: 0;
}

/* Default delays */
/* stylelint-disable no-duplicate-selectors */
.slds-icon-waffle .slds-r1 {
  transition-delay: 200ms;
}
/* stylelint-enable no-duplicate-selectors */

.slds-icon-waffle .slds-r2,
.slds-icon-waffle .slds-r4 {
  transition-delay: 150ms;
}

.slds-icon-waffle .slds-r3,
.slds-icon-waffle .slds-r5,
.slds-icon-waffle .slds-r7 {
  transition-delay: 100ms;
}

.slds-icon-waffle .slds-r6,
.slds-icon-waffle .slds-r8 {
  transition-delay: 50ms;
}

@keyframes slds-icon-waffle-throb {
  to {
    transform: scale(1.5);
  }
}

/**
 * Hover and click animations for help icon
 */
.slds-icon-help {
  width: 1.5rem;
  height: 1.5rem;
  fill: var(--slds-g-color-on-surface-1);

  &:hover .slds-icon-help_hover {
    opacity: 1;
    transform: scale(1);
  }

  &:focus {
    animation: slds-click-global-action 80ms cubic-bezier(1, 1.9, 0.94, 0.98);

    .slds-icon-help_focus {
      opacity: 1;
      transform: scale(1);
    }
  }

  mask {
    mask-type: alpha;
  }
}

/**
 * Modifies hover effect of global help icon
 */
.slds-icon-help_hover {
  opacity: 0;
  transform: scale(0.1, 0.1);
  transform-origin: 45px 47px;
  transition: all 200ms ease-out;
  fill: var(--slds-g-color-accent-3);
}

/**
 * Modifies focus effect of global help icon
 */
.slds-icon-help_focus {
  opacity: 0;
  transform: scale(0.1, 0.1);
  transform-origin: 45px 47px;
  transition: all 200ms ease-out;
  fill: var(--slds-g-color-accent-2);
}

.slds-icon-help svg {
  width: 1.5rem;
  height: 1.5rem;
}

.slds-icon-help g {
  mask: url('#questionMark');
}

@keyframes slds-click-global-action {
  25% {
    transform: scale(0.95, 0.95);
  }

  100% {
    transform: scale(0.98, 0.98);
  }
}

/**
 * Initializes typing icon
 */

.slds-icon-typing {
  display: inline-block;
  padding: var(--slds-g-spacing-1) 0;

  /**
   * Add when you wish to animate the dots
   */
  &.slds-is-animated {
    .slds-icon-typing__dot {
      animation: slds-icon-typing__dot-first 1.2s infinite ease-in-out;
    }

    .slds-icon-typing__dot:nth-child(1) {
      animation-name: slds-icon-typing__dot-first;
    }

    .slds-icon-typing__dot:nth-child(2) {
      animation-name: slds-icon-typing__dot-second;
    }

    .slds-icon-typing__dot:nth-child(3) {
      animation-name: slds-icon-typing__dot-third;
    }
  }

  /**
   * Add when you wish to pause the dots animation
   */
  &.slds-is-paused {
    .slds-icon-typing__dot {
      animation-play-state: paused;
    }
  }
}

/**
 * Dots within the typing icon
 */
.slds-icon-typing__dot {
  background-color: var(--slds-g-color-neutral-base-80);
  border-radius: 50%;
  display: inline-block;
  height: 0.5rem;
  margin: 0 0.125rem;
  width: 0.5rem;
}

@keyframes slds-icon-typing__dot-first {
  0% {
    background-color: var(--slds-g-color-neutral-base-80);
  }

  16% {
    background-color: var(--slds-g-color-neutral-base-60);
  }

  33%,
  100% {
    background-color: var(--slds-g-color-neutral-base-80);
  }
}

@keyframes slds-icon-typing__dot-second {
  0%,
  33% {
    background-color: var(--slds-g-color-neutral-base-80);
  }

  50% {
    background-color: var(--slds-g-color-neutral-base-60);
  }

  67%,
  100% {
    background-color: var(--slds-g-color-neutral-base-80);
  }
}

@keyframes slds-icon-typing__dot-third {
  0%,
  67% {
    background-color: var(--slds-g-color-neutral-base-80);
  }

  83% {
    background-color: var(--slds-g-color-neutral-base-60);
  }

  100% {
    background-color: var(--slds-g-color-neutral-base-80);
  }
}
