@use '@/scss/dimensions' as dim;

@function unit($factor: 1) {
  @return #{$factor * 4}px;
}

@mixin main-content-width {
  max-width: 1168px;
  min-width: 604px;
  margin: 0 auto;
}

@mixin flex-column {
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100%;
}

@mixin text-ellipsis {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@mixin form-text-field {
  width: 100%;
}

@mixin vertical-bar {
  border-left: 1px solid var(--color-border);
  width: 0;
}

@mixin subhead-cap {
  color: var(--color-text-secondary);
  font: var(--font-subhead-cap);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

@mixin subhead-cap-small {
  @include subhead-cap;
  font: var(--font-subhead-cap-small);
}

@mixin rotating-animation {
  animation: rotating 1s ease-in-out infinite;
}

@mixin shimmering-animation($baseColor: var(--color-layer-2)) {
  background-color: $baseColor;
  position: relative;
  overflow: hidden;
  border-radius: 8px;

  &::after {
    content: '';
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background-image:
      linear-gradient(
        90deg,
        rgba(var(--color-skeleton-shimmer-rgb), 0) 0,
        rgba(var(--color-skeleton-shimmer-rgb), 0.2) 20%,
        rgba(var(--color-skeleton-shimmer-rgb), 0.5) 60%,
        $baseColor
      );
    animation: shimmer 2s infinite;
  }
}

@keyframes rotating {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

@mixin multi-line-ellipsis($line) {
  // https://css-tricks.com/almanac/properties/l/line-clamp/
  /* stylelint-disable-next-line value-no-vendor-prefix */
  display: -webkit-box;
  -webkit-line-clamp: $line;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}
