// This is copied from https://stackoverflow.com/a/19721069.
$tooltip-size: 5em;
$line-height: 1.45;

@import "asciidoctor";

:root {
  --body-family: "Source Serif Pro", "IBM Plex Serif", "Noto Serif", serif;
  --header-family: "Source Sans Pro", "IBM Plex Sans", "Noto Sans", sans-serif;
  --mono-family: "Source Code Pro", "IBM Plex Mono", "Noto Mono", monospace;
}

// Base styles.
table tr td > p { margin-top: 1em; }

ul, ol {
  margin: 1em 0 0;
}

pre {
  margin-bottom: 0;
}

a:hover {
  color: var(--base0B);
}

button {
  border: var(--border-style);
}

hr {
  border-color: var(--foreground);
}

kbd {
  font-size: 0.9em;
}

main > article {
  line-height: $line-height;
}

// Layouts
.site__title {
  --size: 2rem;
  margin-bottom: unset;
  font-size: var(--size);
  line-height: unset;
}

.site__socials {
  list-style: none;
  padding-left: 0;
}

.site__links--content,
.site__socials--content {
  margin: 1em 0 0;
  padding: 0;
  gap: 1em;
  display: flex;
  width: 100%;
  justify-content: space-around;
  flex-flow: row wrap;
}

.site__links--content > * { flex-basis: 20; }
.site__socials--content > * { flex-basis: 15%; }

article.post {
  padding: 0.5em;
  background: var(--base01);
}

// Asciidoctor roles (e.g., [.text-center]) on a block.
.text-center {
  text-align: center;
}

.line-through {
  text-decoration: line-through;
}

// Custom layouts
#logo {
  display: flex;
  align-items: center;
  justify-content: center;
  height: $tooltip-size;
  width: $tooltip-size;

  svg {
    --size: 4em;
    height: var(--size);
    width: var(--size);
    fill: var(--base0C);
    position: relative;
    animation: rainbow 3s infinite, pulse 2s alternate infinite,
      bounce 0.6s ease-in-out alternate infinite;
  }
}

@keyframes bounce {
  $baseSize: 3em;
  $baseRotation: 20deg;
  from {
    transform: rotate($baseRotation) translateX($baseSize)
      translateY(-#{$baseSize / 5});
  }
  to {
    transform: rotate(-$baseRotation) translateX(-$baseSize)
      translateY(-#{$baseSize / 5});
  }
}

@keyframes pulse {
  from {
    width: #{$tooltip-size / 2};
  }
  to {
    width: #{$tooltip-size};
  }
}

@keyframes rainbow {
  $colorOrder: "07" "08" "09" "0A" "0B" "0C" "0D" "0E" "0F";
  $divide: floor(100 / length($colorOrder));
  @for $i from 1 to length($colorOrder) {
    #{$i * $divide}% {
      fill: var(--base#{nth($colorOrder, $i)});
    }
  }
}

[data-tooltip] {
  &::before {
    --scale: 0;

    background: var(--base01);
    content: attr(data-tooltip);
    font-size: 0.8em;
    padding: 0.5em;
    position: absolute;
    transform: translateY(var(--translate-y, -#{round($tooltip-size / 2)}))
      scale(var(--scale));
    transform-origin: bottom center;
    width: max-content;
    max-width: 100%;
  }

  &:hover::before {
    --scale: 1;
  }
}

// This setup will use asciidoctor-rouge.
.rouge.highlight,
code[data-lang] {
  &::selection,
  ::selection {
    background: var(--selection-color);
    color: unset;
  }
}
