:root {
  --bg: #0d0f12;
  --bga: oklch(from var(--bg) l c h / 0.65);
  --gradient: linear-gradient(
    160deg,
    var(--bga) 0%,
    transparent 50%,
    oklch(from var(--bg) l c h / 0.4) 100%
  );
  --fg: #f1f7ff;
  --color: #ff076d;
  --color-alt: #076dff;
  --hl: color-mix(in oklab, var(--color) 66.6%, transparent);
  --light: color-mix(in oklab, var(--fg) 66.6%, transparent);
  --muted: color-mix(in oklab, var(--fg) 55%, transparent);
  --border: color-mix(in oklab, var(--fg) 20%, transparent);
  --placeholder: color-mix(in oklab, var(--fg) 10%, transparent);
  --radius: 0.5rem;
  --font: "Public Sans", sans-serif;
  --font-title: "Fraunces", serif;
  --space: 4rem;

  --color-awful: #e85d6a;
  --color-bad: #ed9852;
  --color-meh: #dfc65b;
  --color-good: #68bd86;
  --color-great: #7040b8;
}

/**
* Reset
**/

*,
*::before,
*::after {
  box-sizing: border-box;
}

:not(dialog) {
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: none;
  text-size-adjust: none;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0;
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg);
  color: var(--fg);
}

h1,
h2,
h3,
h4 {
  line-height: 1.2;
  text-wrap: balance;
  overflow-wrap: break-word;
}

audio,
iframe,
img,
svg,
video {
  max-block-size: 100%;
  max-inline-size: 100%;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
}

ul,
ol {
  list-style: none;
}

/* Scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) var(--color-bg);
}

/* Chrome, Edge and Safari */
*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
*::-webkit-scrollbar-track {
  border-radius: 0px;
  background-color: #1b1c29;
}

*::-webkit-scrollbar-thumb {
  border-radius: 8px;
  background-color: #8d99ae;
}

*::-webkit-scrollbar-thumb:active {
  background-color: var(--color);
}

#nprogress .bar {
  background: var(--color) !important;
}

/**
 * Layout
 **/

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

main.container {
  flex: 1;
  padding: 6rem 1rem var(--space);

  @media (max-width: 640px) {
    padding-top: 5rem;
  }

  &:has(#not-found) {
    max-width: 100vw;
    padding: 0;
  }
}

.columns {
  display: flex;
  flex-wrap: wrap;
  gap: 2rem;

  > * {
    flex: 1 1 0;
  }

  @media (max-width: 640px) {
    flex-direction: column;
  }
}

[id] {
  scroll-margin-top: 5rem;

  @media (max-width: 640px) {
    scroll-margin-top: 8rem;
  }
}

/**
 * Forms
 **/
form {
  &.inline {
    font-size: 1rem;
    border: 1px solid var(--border);
    background: var(--bg);
    transition: box-shadow 150ms;
    border-radius: var(--radius);
    display: flex;
    height: 2.25rem;
    overflow: hidden;

    &:focus-within {
      box-shadow: 0 0 0 3px color-mix(in oklab, var(--fg) 20%, transparent);
    }

    input {
      flex: 1;
      min-width: 0;
      padding: 0 0.75rem;
      border: 0;
      outline: 0;
      border-radius: inherit;
      background: transparent;
      color: var(--fg);

      &::placeholder {
        color: var(--muted);
      }
    }

    label {
      font-weight: 700;
      display: grid;
      place-items: center;
      padding: 0 0.75rem;
      background: var(--placeholder);
    }

    button {
      display: grid;
      place-items: center;
      padding: 0 0.75rem;
      flex-shrink: 0;
      border: 0;
      background: transparent;
      color: var(--light);
      cursor: pointer;
      border-left: 1px var(--border) solid;
      border-radius: 0;
      white-space: nowrap;

      svg {
        aspect-ratio: 1;
        width: 1.25rem;
        height: 1.25rem;
      }

      &:hover {
        color: var(--color);
      }
    }
  }
}

/**
 * Expandable content
 **/

.expandable {
  --expandable-lines: 3;
  line-height: 1.5;
  position: relative;

  &.is-collapsed {
    max-height: calc(var(--expandable-lines) * 1lh);
    overflow: hidden;

    &::after {
      content: "";
      position: absolute;
      bottom: 0;
      left: 0;
      width: 100%;
      height: 1lh;
      mask: linear-gradient(to top, black, transparent);
      backdrop-filter: blur(4px);
      z-index: 1;
    }
  }
}

.expandable-toggle {
  position: absolute !important;
  bottom: 0;
  right: 0;
  height: 1lh !important;
  line-height: 1lh;
  z-index: 2;

  &[hidden],
  &[aria-expanded="true"] {
    display: none;
  }
}

/**
 * Buttons
 **/

.btn {
  --background: var(--gradient);
  --contrast: var(--fg);
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1rem;
  height: 2.5rem;
  background: var(--background);
  color: var(--contrast);
  box-shadow: 0 0 0 1px var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  vertical-align: middle;
  border: none;
  outline: none;

  figure,
  svg {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
  }

  small {
    font-size: 1em;
    color: var(--muted);
  }

  &:hover {
    opacity: 0.8;
  }

  &.small {
    height: 2rem;
    font-size: 0.8rem;
    padding: 0 0.75rem;

    svg {
      width: 1rem;
      height: 1rem;
    }
  }

  &.round {
    border-radius: 50%;
    aspect-ratio: 1;
    flex-grow: 0 !important;
    padding: 0;
    justify-content: center;
  }

  &.secondary {
    --background: transparent;
  }

  &.dark {
    --background: var(--bga);
  }

  &.ghost {
    --background: transparent;
    --contrast: var(--fg);
    box-shadow: none;

    &:hover {
      --background: var(--placeholder);
    }
  }

  &.disabled,
  &:disabled {
    pointer-events: none;
    --background: transparent;
    --contrast: var(--border);

    .currentScore {
      color: var(--fg);
    }
  }

  &.loading {
    pointer-events: none;

    &::after {
      content: "";
      aspect-ratio: 1;
      width: 1em;
      flex-shrink: 0;
      border: 3px solid color-mix(in oklab, currentColor 25%, transparent);
      border-top-color: currentColor;
      border-radius: 50%;

      animation: spin 0.8s linear infinite;
    }

    &:has(> .icon) {
      &::after {
        position: absolute;
        left: 1rem;
        top: 50%;
        translate: 0 -50%;
      }

      &:is(.round) {
        &::after {
          position: absolute;
          left: 50%;
          top: 50%;
          translate: -50% -50%;
        }
      }

      .icon {
        opacity: 0;
      }
    }
  }

  &.active {
    --background: var(--fg);
    --contrast: var(--bg);
    box-shadow: none;

    .currentScore {
      color: var(--contrast);
    }
  }
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

.btnActions {
  display: flex;

  &:has(> :nth-child(2 of .btn:not([hidden]))) {
    > .btn:not([hidden]) {
      border-radius: 0;

      &:nth-child(1 of .btn:not([hidden])) {
        border-radius: var(--radius) 0 0 var(--radius);
      }

      &:nth-last-child(1 of .btn:not([hidden])) {
        border-radius: 0 var(--radius) var(--radius) 0;
      }
    }
  }
}

.buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;

  &.horizontal {
    flex-wrap: nowrap;
    scroll-snap-type: x proximity;
    overflow-x: auto;
    padding: 1px;

    > * {
      white-space: nowrap;
    }

    &:not(:hover) {
      scrollbar-color: transparent transparent;

      &::-webkit-scrollbar-thumb {
        background: transparent;
      }
    }

    @media (max-width: 640px) {
      margin-right: -1rem;
      padding-right: 1rem;
    }
  }
}

/**
 * Generic
 **/

a {
  color: var(--fg);
  text-decoration-color: var(--muted);

  &:hover {
    text-decoration-color: var(--fg);
  }
}

.icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  flex-shrink: 0;
  vertical-align: -0.125em;

  &:is(svg) {
    rect,
    line,
    polyline,
    path.straight-edges {
      shape-rendering: crispEdges;
    }

    circle,
    ellipse,
    path.curves {
      shape-rendering: geometricPrecision;
    }
  }

  &.filled {
    fill: currentColor;
    stroke: none;
  }
}

h1 {
  font-size: 2rem;
  margin: 0 0 0.5rem;
}
h2 {
  font-size: 1.25rem;
  margin: 1.5rem 0 0.75rem;
}

figure {
  position: relative;
  background: var(--placeholder);
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border);

  &.avatar {
    border-radius: 100%;
  }

  img,
  canvas,
  > .icon {
    width: 100%;
    height: 100%;
    object-fit: cover;

    &.empty {
      scale: 0.666;
      object-fit: contain;
      opacity: 0.25;
    }
  }

  canvas {
    position: absolute;
    inset: 0;
    z-index: 1;
  }

  img {
    color: transparent;
    position: relative;
    z-index: 2;
  }
}

.blur {
  background: var(--gradient);
  backdrop-filter: blur(12px);
}

.tag {
  font-size: 0.9rem;
  font-weight: 400;
  line-height: 1;
  color: var(--light);
  font-style: normal;
}
