@use "sass:color";

code {
  border-radius: var(--rounded-xs);
  background-color: var(--color-background-second);
  padding: 0.125rem 0.25rem;
  color: var(--color-accent);
  font-weight: 500;
  font-size: 0.83rem;
  font-family: var(--main-mono);
}

kbd {
  display: inline-block;
  transition-duration: var(--transition);
  transition-property: transform, box-shadow, background-color;
  cursor: pointer;
  box-shadow:
    inset 0 -2px 0 var(--color-border),
    0 -1px 0 var(--color-border);
  border-radius: var(--rounded-xs);
  background-color: var(--color-background-second);
  padding: 0.125rem 0.375rem;
  font-size: 0.8rem;
  line-height: normal;
  font-family: var(--main-mono);

  &:active {
    transform: translateY(2px);
    box-shadow: inset 0 1px 0 var(--color-border);
    background-color: var(--color-background-mute);
  }
}

time {
  cursor: pointer;
  border: 0.0625rem solid var(--color-border);
  border-bottom: 0.125rem solid var(--color-border);
  border-radius: calc(var(--rounded-xs) - 0.0125rem);
  background-color: var(--color-background-second);
  padding: 0.1875rem;
  color: var(--color-accent);
  font-weight: 700;
  font-size: 0.875rem;
  transition:
    border 0.1s ease,
    font-weight 0.1s ease;

  strong {
    display: inline-block;
    animation: blink 0.7s infinite alternate;
    font-weight: 700;
  }

  @keyframes blink {
    from {
      opacity: 1;
    }

    to {
      opacity: 0.5;
    }
  }

  &:active {
    border-top: 0.125rem solid var(--color-border);
    border-bottom: 0.0625rem solid var(--color-border);
    padding-top: 0.25rem;
    font-weight: 800;

    strong {
      animation: blink 1.5s infinite alternate;
    }
  }
}

.spoiler {
  font-weight: 600;

  span {
    filter: blur(0.25rem);
    animation: glow 1.5s infinite linear alternate-reverse;
    transition: filter 0.3s ease;
    font-weight: normal;

    &:hover {
      filter: none;
      animation: none;
    }

    &:active {
      font-style: italic;
    }
  }

  @keyframes glow {
    0% {
      text-shadow: 0 0 0 var(--color-accent);
    }

    20% {
      text-shadow: 0 0 0.25rem var(--color-accent);
    }

    40% {
      text-shadow: 0 0 0.375rem var(--color-accent);
    }

    60% {
      text-shadow: 0 0 0.5rem var(--color-accent);
    }

    80% {
      text-shadow: 0 0 0.625rem var(--color-accent);
    }

    100% {
      text-shadow: 0 0 0.9375rem var(--color-accent);
    }
  }
}

aside {
  float: right;
  margin-inline-start: 1rem;
  border-radius: var(--rounded-sm);
  background-color: var(--color-background-second);
  padding: 1rem;
  width: 30%;
}

progress {
  -webkit-appearance: none;
  appearance: none;
  appearance: none;
  margin: 0.625rem 0;
  border: none;
  border-radius: calc(var(--rounded-xs) - 0.0125rem);
  background-color: var(--color-background-second);
  height: 0.625rem;
  width: 100%;
  color: var(--color-accent);

  &::-webkit-progress-value {
    border-radius: calc(var(--rounded-xs) - 0.0125rem);
    background-color: var(--color-accent);
  }

  &:indeterminate {
    background-color: var(--color-background-second);
  }

  &:indeterminate::-moz-progress-bar {
    background-color: transparent;
  }

  &::-webkit-progress-bar {
    background-color: transparent;
  }

  &::-moz-progress-bar {
    border-radius: calc(var(--rounded-xs) - 0.0125rem);
    background-color: var(--color-accent);
  }

  &::-ms-fill {
    border-radius: calc(var(--rounded-xs) - 0.0125rem);
    background-color: var(--color-accent);
  }
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 0.625rem;
  background-color: var(--color-background-second);
  border-radius: calc(var(--rounded-xs) - 0.0125rem);
  cursor: pointer;

  &::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 1rem;
    height: 1rem;
    background-color: var(--color-accent);
    border-radius: 50%;
    cursor: pointer;
  }

  &::-moz-range-thumb {
    width: 1rem;
    height: 1rem;
    background-color: var(--color-accent);
    border-radius: 50%;
    cursor: pointer;
  }

  &::-ms-thumb {
    width: 1rem;
    height: 1rem;
    background-color: var(--color-accent);
    border-radius: 50%;
    cursor: pointer;
  }

  &::-ms-track {
    background-color: var(--color-background-second);
    border-radius: calc(var(--rounded-xs) - 0.0125rem);
  }
}

samp {
  border-radius: var(--rounded-sm);
  background-color: var(--color-background-second);
  padding: 0.125rem 0.375rem;
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  font-family: var(--main-mono);
}

legend {
  display: inline-block;
  border-radius: var(--rounded-xs);
  background-color: var(--color-background-second);
  padding: 0.125rem 0.375rem;
  color: var(--color-text);
}

q {
  display: inline-block;
  border-radius: var(--rounded-xs);
  background-color: var(--color-background-second);
  padding: 0.125rem 0.375rem;
  color: var(--color-text-secondary);
  font-style: italic;
}

u {
  text-decoration: underline wavy #ff0000;

  @media (prefers-color-scheme: dark) {
    text-decoration-color: #febebe;
  }
}

@mixin diff($color, $background-color, $decoration) {
  border-radius: var(--rounded-xs);
  background-color: $background-color;
  padding: 0.125rem 0.375rem;
  color: $color;
  font-weight: 500;
  font-size: 0.83rem;
  text-decoration: $decoration solid $color 0.08rem;

  @media (prefers-color-scheme: dark) {
    background-color: color.scale($color, $lightness: -40%);
    color: $background-color;
    text-decoration: $decoration solid $background-color 0.08rem;
  }
}

del {
  @include diff(#ff0000, #febebe, line-through);
}

ins {
  @include diff(#007400, #c6ffc6, underline);
}

cite {
  font-style: italic;
}

var {
  font-style: italic;
  font-family: var(--font-old-style);
}
