:root {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 2rem;
  font-family: system-ui, sans-serif;
  line-height: 1.6;
  color: #eee;
  background: #14110f;
  display: flex;
  flex-direction: column;
}

header a {
  color: #d9c9a3;
}

main {
  flex: 1;
  max-width: 48rem;
  width: 100%;
  margin: 2rem auto 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

h1 {
  margin: 0;
  font-size: 1.5rem;
  color: #d9c9a3;
}

@property --idle-glow {
  syntax: "<number>";
  inherits: false;
  initial-value: 0.15;
}

@property --glow {
  syntax: "<number>";
  inherits: false;
  initial-value: 0;
}

.fretboard {
  --string-height: min(60vh, 28rem);
  width: 100%;
  height: var(--string-height);
  display: flex;
  justify-content: space-evenly;
  align-items: stretch;
  padding: 1.5rem 2rem;
  background: linear-gradient(180deg, #2a1e14, #1a130d);
  border-radius: 1rem;
  border: 1px solid #4a3524;
  touch-action: none;
}

.string-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  flex: 1;
}

.string-col:nth-child(1) .string {
  --hue: 10;
  animation-delay: 0s;
}
.string-col:nth-child(2) .string {
  --hue: 50;
  animation-delay: -0.5s;
}
.string-col:nth-child(3) .string {
  --hue: 95;
  animation-delay: -1s;
}
.string-col:nth-child(4) .string {
  --hue: 140;
  animation-delay: -1.5s;
}
.string-col:nth-child(5) .string {
  --hue: 185;
  animation-delay: -2s;
}
.string-col:nth-child(6) .string {
  --hue: 230;
  animation-delay: -2.5s;
}

.string {
  --bend: 0px;
  --glow: 0;
  --hue: 40;
  appearance: none;
  border: none;
  padding: 0;
  flex: 1;
  min-height: 0;
  width: 6px;
  border-radius: 999px;
  background: linear-gradient(180deg, #f2e6c9, #cbb37a);
  box-shadow:
    0 0 calc(4px + var(--glow) * 22px) calc(1px + var(--glow) * 6px)
      hsl(var(--hue) 90% 65% / var(--glow)),
    0 0 calc(6px + var(--idle-glow) * 14px) calc(2px + var(--idle-glow) * 4px)
      hsl(var(--hue) 85% 65% / var(--idle-glow));
  cursor: grab;
  transform: translateX(var(--bend));
  transition: transform 60ms ease-out, box-shadow 120ms ease-out;
  animation: idle-shimmer 4s ease-in-out infinite;
}

.string:active {
  cursor: grabbing;
}

.string:focus-visible {
  outline: 3px solid #6fb7ff;
  outline-offset: 6px;
}

.string.plucked {
  animation: idle-shimmer 4s ease-in-out infinite, pluck-spring 550ms cubic-bezier(0.36, 1.6, 0.4, 1);
}

@keyframes pluck-spring {
  0% {
    transform: translateX(var(--bend));
  }
  100% {
    transform: translateX(0);
  }
}

@keyframes idle-shimmer {
  0%,
  100% {
    --idle-glow: 0.12;
  }
  50% {
    --idle-glow: 0.5;
  }
}

.key-label {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: #8a7a63;
  text-transform: uppercase;
  user-select: none;
}
