/* Copyright 2024 Google LLC
SPDX-License-Identifier: Apache-2.0 */

/* ANIMATIONS */

@keyframes opacity {
  to {
    opacity: 1;
  }
}

@keyframes rotate {
  to {
    rotate: 1turn;
  }
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.8;
  }
  50% {
    opacity: 0.1;
  }
}

/* MODEL LOADING STATUS */

#modelStatusWrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  box-sizing: border-box;
  padding: 0.2rem 0.6rem;
  font-family: monospace;
  text-align: center;
  background-color: rgb(from var(--color) r g b / 25%);
  transition: var(--background-color-transition-default);
  &.not-started,
  &.preparing {
    --color: var(--neutral-color);
  }
  &.ready {
    --color: var(--primary-color);
  }
  &.generating-response {
    --color: var(--ai-color);
  }
  &.error {
    --color: var(--error-color);
  }
}

#modelStatus {
  color: var(--color);
  padding-right: 0.4rem;
  &.not-started::before {
    content: '⚫️ Model not ready';
  }
  &.preparing::before {
    content: '⚫️ Preparing model... (~10 seconds)';
  }
  &.ready::before {
    content: '🔵 Model is ready';
  }
  &.generating-response::before {
    content: '🖊️ Generating response...';
  }
  &.error::before {
    content: '❌ Error while preparing the model';
  }
}

/* AI WRAPPER */

#aiWrapper {
  display: flex;
  flex: 1;
  align-items: center;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.6s ease;
  &.visible {
    visibility: visible;
    opacity: 1;
  }
}

/* REVIEW HELPER OUTPUT */

#toxicityAssessmentEl {
  font-size: smaller;
  color: var(--toxic-color);
  margin-left: 0.2rem;
}

/* AI EFFECT */

.ai-effect-wrapper {
  background: white;
  opacity: inherit;
  --size: 26px;
  width: var(--size);
  height: var(--size);
  display: flex;
  border-radius: 10rem;
  transition: var(--background-color-transition-default);
  cursor: pointer;
  &:hover {
    background-color: var(--primary-color-x-light);
    box-shadow: var(--box-shadow-default);
  }
}

#aiEffect {
  --size: 26px;
  --mask-size: calc(var(--size) / 2);

  inline-size: var(--size);
  mask: radial-gradient(
      closest-side,
      #0000 calc(100% - 0.5px),
      red calc(100% + 0.5px)
    )
    calc(-0.5 * var(--size)) calc(-0.5 * var(--size));

  &.not-started,
  &.preparing,
  &.error {
    background: transparent;
  }

  &.ready {
    animation: rotate 1s ease;
    background: linear-gradient(
      to top right in oklch,
      oklch(0.54 0.22 32.77),
      oklch(0.94 0.05 62.95)
    );
  }

  &.generating-response {
    animation: 0.8s infinite pulse cubic-bezier(0.4, 0, 1, 1);
    background: linear-gradient(
      to top right in oklch,
      oklch(0.54 0.22 32.77),
      oklch(0.94 0.05 62.95)
    );
  }
}
