:root {
  --text-color: white;
  --body-bg: #111;
  --highlight: #f0ece5;
  --max-width: 500px;
  --media-size: 300px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: "IBM Plex Sans", sans-serif;
  background-color: var(--body-bg);
  color: var(--text-color);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-inline: clamp(15px, 3vw, 20px);
  padding-block: clamp(30px, 6vh, 40px);
  overscroll-behavior: none;
  font-size: clamp(18px, 2vw, 20px);
  line-height: 1.3;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
  &:hover {
    text-decoration: underline;
  }
}

.d-flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.visually-hidden {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

@keyframes bgAnim {
  0% {
    transform: scale(1) rotate(0);
  }
  50% {
    transform: scale(1.5) rotate(180deg);
  }
  100% {
    transform: scale(1) rotate(360deg);
  }
}

/* Background */
#background {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: -1;
  img {
    position: absolute;
    top: -20vmax;
    left: -20vmax;
    right: -20vmax;
    bottom: -20vmax;
    width: 150vmax;
    height: 150vmax;
    object-fit: cover;
    opacity: 0.6;
    filter: blur(25px);
    animation: bgAnim forwards 500s infinite linear;
    transform-origin: center;
  }
}

.has-noise::after {
  content: "";
  background: url(./noise.webp) center;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  opacity: 0.8;
}

#container {
  width: 100%;
  max-width: var(--max-width);
  position: relative;
  overflow: hidden;
  gap: 20px;
}

/* Header Styles */
header {
  text-align: center;
  align-items: center;
  h1 {
    font-family: "Climate Crisis", sans-serif;
    font-variation-settings: "YEAR" 1979;
    text-transform: uppercase;
    font-size: clamp(2.5em, 10vw, 4em);
    font-weight: bold;
    line-height: 0.75;
    margin-bottom: 0.15em;
    color: var(--highlight);
    max-width: 9ch;
    span {
      background: -webkit-linear-gradient(
        var(--highlight) 60%,
        transparent 100%
      );
      background-clip: text;
      -webkit-text-fill-color: transparent;
    }
  }
  p {
    font-size: clamp(0.8em, 3vw, 1em);
    text-wrap-style: balance;
    a {
      border-bottom: 1px dotted;
      padding-bottom: 0.1em;
      &:hover {
        text-decoration: none;
        border-bottom-style: solid;
      }
    }
  }
}

#display-area {
  align-items: center;
  width: 100%;
  gap: 15px;
  background-color: #ffffff10;
  padding: clamp(20px, 3vw, 25px);
  border-radius: 15px;
  aspect-ratio: 1/1.39;
  @media (orientation: landscape) {
    aspect-ratio: 1/1.03;
  }
  .has-error & {
    aspect-ratio: auto;
  }
}

/* CONTROLS */
#controls {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: var(--media-size);
  transition: opacity 0.15s ease-in-out;

  &.loading {
    opacity: 0.5;
    pointer-events: none;
  }
}

input {
  flex: 1;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid #ffffff20;
  border-radius: 10em;
  padding: 10px 100px 10px 15px;
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
  color: white;
  &:hover {
    border-color: #ffffff50;
  }
  &:focus {
    border-color: white;
    background: rgba(0, 0, 0, 0.25);
    box-shadow: inset 0 2px 6px #00000040;
  }
  &::placeholder {
    color: rgba(255, 255, 255, 0.5);
  }
  &:placeholder-shown + .btn-small {
    display: none;
  }
}

#controls-ui {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  gap: 2px;
  z-index: 1;
}

.filter-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding-left: 0.5rem;
}

select {
  background-color: #ffffff20;
  color: white;
  border: 1px solid transparent;
  border-radius: 10em;
  padding: 0.25em 2em 0.25em 0.75em;
  height: 30px;
  font-size: 13px;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 6px center;
  background-size: 1em;
  min-width: 8ch;
  transition: all 0.15s;
  &:hover {
    border-color: #ffffff50;
  }
  &:focus {
    border-color: white;
    background-color: rgba(255, 255, 255, 0.1);
  }
}

.btn-primary {
  padding: 0.5em;
  background: var(--highlight);
  border: none;
  border-radius: 10em;
  color: var(--body-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  width: 30px;
  height: 30px;

  &:after {
    display: inline-flex;
    content: attr(aria-label);
    position: absolute;
    min-width: max-content;
    bottom: 120%;
    background-color: #ffffffcc;
    font-size: 11px;
    font-weight: bold;
    line-height: 1;
    padding: 0.2em 0.5em;
    border-radius: 0.25em;
    opacity: 0;
    transition: opacity 0.15s ease;
    pointer-events: none;
    box-shadow: 0 2px 3px #00000060;
  }
  @media (pointer: fine) {
    &:hover:not(:disabled) {
      background: white;
      border-color: white;
      transform: scale(1.05);
      box-shadow: 0 1px 5px #00000050;

      &:after {
        transition: opacity 0.15s ease 1s;
        opacity: 1;
      }
    }
  }

  &:disabled {
    cursor: wait;
    transform: scale(0.9);
    .btn-icon {
      animation: rotate forwards 1s infinite;
    }
  }
}

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

.btn-icon {
  width: 1em;
}

/* RECORD */

#result {
  gap: 10px;
  align-items: center;
}

.art-container {
  position: relative;
}

#album-art-link {
  width: 100%;
  aspect-ratio: 1;
  max-width: var(--media-size);
  display: inline-block;
  margin-inline: auto;
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.15s ease;
  background-color: #ffffff20;
  box-shadow:
    0 10px 20px #00000060,
    0 15px 10px -10px #00000030;
  @media (pointer: fine) {
    &:hover {
      transform: scale(0.98);
      opacity: 0.9;
    }
  }
}

.album-art {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

#result-info {
  text-align: center;
  width: 100%;
  max-width: var(--media-size);
  gap: 3px;
}

.album-link {
  text-decoration: none;
  display: block;
}

.album-title {
  font-size: 1em;
  font-weight: 700;
  line-height: 1.2;
  transition: color 0.2s;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  text-overflow: ellipsis;
}

.album-link:hover {
  .album-title {
    text-decoration: underline;
  }
}

.artist-name {
  font-size: 0.7em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#tag-container {
  margin-top: 10px;
  display: flex;
  justify-content: center;
  gap: 3px;
  flex-wrap: wrap;
}

.tag {
  display: inline-block;
  padding: 0.3em 0.75em;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 5em;
  font-size: 10px;
  line-height: 1;
  text-transform: uppercase;
}

/* Loading */

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.skeleton {
  background: linear-gradient(
    90deg,
    #eeeeee10 25%,
    #eeeeee20 50%,
    #eeeeee10 75%
  );
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  border-radius: 0.5rem;
}

#loading {
  width: 100%;
  max-width: var(--media-size);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.skeleton-art {
  width: 100%;
  max-width: var(--media-size);
  aspect-ratio: 1;
  margin: 0 auto;
}
.skeleton-title {
  height: 1.4em;
  width: 90%;
  margin: 0 auto;
}
.skeleton-artist {
  height: 0.9em;
  width: 50%;
  margin: 0 auto;
}

.skeleton-tags {
  height: 0.8em;
  width: 30%;
  margin: 0 auto;
}

/* FOOTER */

footer {
  text-align: center;
  font-size: 11px;
  opacity: 0.6;
}

/* ERRORS */

#error-box {
  position: fixed;
  bottom: 20px;
  font-size: 15px;
  font-weight: bold;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: rgba(193, 1, 1, 0.65);
  backdrop-filter: blur(10px);
  padding: 1em 1.5em;
  border-radius: 1em;
  color: white;
  z-index: 50;
  transition:
    transform 0.25s ease 0.25s,
    opacity 0.25s ease;
  opacity: 0;

  &.on-screen {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
  }
}
