/* The lossless audio switch: a dark card on a black page, a glass track with a brushed metal knob, the wave of the
   song drawn on a canvas under it and three values that roll. The knob is moved by GSAP on .knob, its look lives on
   the child .knob__body (squash, press) so the two transforms never cancel each other. */
:root {
  --page: #000000;          /* the page */
  --card: #0d0e11;          /* the body of the card */
  --card-top: #15171b;      /* the top of the card, a little lighter */
  --edge: rgba(255, 255, 255, 0.07); /* the edge at rest */
  --ink: #eef0f3;           /* the words */
  --muted: #858a94;         /* the small words */
  --faint: #4c5058;         /* the wave while compressed */
  --accent: #6ff2cf;        /* the lossless light, mint */
  --accent-2: #9db4ff;      /* the second colour of the light, periwinkle */
  --metal: #d9dce1;         /* the knob */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
  overflow-x: clip;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Mona Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: hidden;
}

/* ---- the card ---- */
.card {
  --p: 0;                   /* where the knob is, 0 off, 1 on (from the script) */
  --mx: 70%;                /* the pointer over the card */
  --my: 20%;
  position: relative;
  width: min(88vw, 340px);
  padding: clamp(14px, 3.4vh, 20px) 18px clamp(14px, 3vh, 18px);
  border-radius: 22px;
  background: linear-gradient(180deg, var(--card-top), var(--card) 46%);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.05) inset,
    0 2px 4px rgba(0, 0, 0, 0.5),
    0 18px 40px -16px rgba(0, 0, 0, 0.9),
    0 40px 90px -40px rgba(111, 242, 207, calc(var(--p) * 0.28));
  isolation: isolate;
  opacity: 0;
}

/* a soft light that follows the pointer under the words */
.card__light {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(260px 180px at var(--mx) var(--my), rgba(255, 255, 255, 0.045), transparent 70%);
  pointer-events: none;
  z-index: -1;
}

/* the 1px edge that takes the light: brighter at the top and where the pointer is */
.card__rim {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  background:
    radial-gradient(200px 120px at var(--mx) var(--my), rgba(255, 255, 255, 0.22), transparent 70%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0.04) 40%, rgba(255, 255, 255, 0.02));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  pointer-events: none;
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  letter-spacing: 0.01em;
  color: var(--muted);
}

.card__brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  font-weight: 600;
  font-stretch: 112%;
}

.card__brand svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.6;
  stroke-linecap: round;
}

/* ---- the row with the switch ---- */
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: clamp(10px, 2.6vh, 16px);
  min-height: 48px;
}

.row__text {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.row__head {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* the Hi-Res badge that arrives once the wave is smooth */
.badge {
  display: inline-block;
  opacity: 0;
}

.badge__in {
  position: relative;
  display: block;
  overflow: hidden;
  padding: 2px 6px 2px;
  border-radius: 6px;
  font-size: 9.5px;
  font-weight: 650;
  font-stretch: 115%;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: linear-gradient(180deg, rgba(111, 242, 207, 0.14), rgba(111, 242, 207, 0.05));
  box-shadow: inset 0 0 0 1px rgba(111, 242, 207, 0.32), 0 0 14px -4px rgba(111, 242, 207, 0.5);
}

.badge__shine {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -50%;
  width: 40%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: skewX(-20deg);
  opacity: 0;
}

.row__title {
  font-size: 19px;
  font-weight: 640;
  font-stretch: 104%;
  letter-spacing: -0.01em;
  cursor: pointer;
  user-select: none;
}

.row__sub {
  font-size: 12.5px;
  color: var(--muted);
  height: 17px;
}

/* the words that roll: each line is a row of letters, the old one leaves up, the new one comes from below */
.roll {
  position: relative;
  display: block;
  overflow: hidden;
  white-space: nowrap;
}

.roll__line {
  display: block;
  white-space: pre;
}

.roll__line > span {
  display: inline-block;
}

.roll__line.is-new {
  position: absolute;
  left: 0;
  top: 0;
}

/* the soft shimmer while the app matches the source */
.roll__line.is-busy {
  background: linear-gradient(90deg, var(--muted) 0 35%, var(--ink) 50%, var(--muted) 65% 100%);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: shimmer 0.9s linear infinite;
}

@keyframes shimmer {
  from { background-position: 100% 0; }
  to { background-position: 0% 0; }
}

/* ---- the switch ---- */
.switch {
  --w: 62px;
  --h: 36px;
  --k: 28px;                /* the knob */
  position: relative;
  flex: none;
  width: var(--w);
  height: var(--h);
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  cursor: grab;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.switch:active {
  cursor: grabbing;
}

.switch:focus-visible {
  box-shadow: 0 0 0 2px var(--page), 0 0 0 4px rgba(111, 242, 207, 0.7);
}

.switch__track {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: #1b1d22;
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.7),
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 1px 0 rgba(255, 255, 255, 0.06),
    0 0 18px -2px rgba(111, 242, 207, calc(var(--p) * 0.45));
  overflow: hidden;
}

.switch__fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(100deg, var(--accent), var(--accent-2));
  opacity: 0;
}

/* the glass over the track: a highlight along the top and a faint bend of light at the bottom */
.switch__glass {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0) 48%),
    linear-gradient(0deg, rgba(255, 255, 255, 0.08), transparent 30%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), inset 0 -2px 6px rgba(0, 0, 0, 0.25);
  mix-blend-mode: screen;
}

.knob {
  position: absolute;
  left: 4px;
  top: 4px;
  width: var(--k);
  height: var(--k);
  pointer-events: none;
}

.knob__body {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  overflow: hidden;
  box-shadow:
    0 1px 1px rgba(0, 0, 0, 0.5),
    0 4px 10px -2px rgba(0, 0, 0, 0.6),
    inset 0 0 0 0.5px rgba(255, 255, 255, 0.6);
  transform-origin: 50% 50%;
}

/* brushed metal: a conic sweep of greys, with fine rings on top */
.knob__metal {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    repeating-radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.05) 0 0.6px, rgba(0, 0, 0, 0.04) 0.6px 1.2px),
    conic-gradient(from 210deg, #f4f5f7, #a9adb5 18%, #eceef1 32%, #9a9ea6 50%, #f0f1f4 66%, #b3b7be 82%, #f4f5f7);
}

/* the highlight of the metal, moved by the pointer */
.knob__spec {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at var(--sx, 35%) var(--sy, 28%), rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0) 46%);
  mix-blend-mode: soft-light;
}

/* the glint that crosses the knob at the snap */
.knob__glint {
  position: absolute;
  top: -20%;
  bottom: -20%;
  left: -60%;
  width: 40%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.85), transparent);
  transform: skewX(-18deg);
  opacity: 0;
  mix-blend-mode: overlay;
}

/* ---- the wave ---- */
.scope {
  position: relative;
  margin-top: clamp(10px, 2.4vh, 16px);
  height: clamp(66px, 17vh, 96px);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0)),
    #08090b;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.8), 0 1px 0 rgba(255, 255, 255, 0.04);
}

.scope__wave {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: inherit;
}

.scope__edge {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  pointer-events: none;
}

.scope__tag,
.scope__track {
  position: absolute;
  top: 8px;
  font-size: 10px;
  letter-spacing: 0.04em;
  line-height: 13px;
  height: 13px;
  color: var(--muted);
}

.scope__tag {
  left: 10px;
  font-weight: 600;
  font-stretch: 112%;
  text-transform: uppercase;
}

.scope__tag.is-on {
  color: var(--accent);
}

.scope__track {
  right: 10px;
  font-stretch: 96%;
  color: #5d626b;
}

/* ---- the values ---- */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: clamp(10px, 2.4vh, 14px) 0 0;
}

.stat {
  min-width: 0;
}

.stat + .stat {
  padding-left: 10px;
  border-left: 1px solid rgba(255, 255, 255, 0.06);
}

.stat dt {
  font-size: 10.5px;
  color: var(--muted);
  white-space: nowrap;
}

.stat dd {
  margin: 3px 0 0;
  height: 19px;
  font-size: 14.5px;
  font-weight: 600;
  font-stretch: 108%;
  line-height: 19px;
}

.stat dd.is-on {
  color: #f6fffb;
}

@media (hover: hover) {
  .switch:hover .switch__track {
    box-shadow:
      inset 0 1px 2px rgba(0, 0, 0, 0.7),
      inset 0 0 0 1px rgba(255, 255, 255, 0.12),
      0 1px 0 rgba(255, 255, 255, 0.06),
      0 0 18px -2px rgba(111, 242, 207, calc(var(--p) * 0.45 + 0.08));
  }
}

@media (max-height: 460px) {
  .card__head {
    font-size: 10.5px;
  }
  .row__head {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* the Hi-Res badge that arrives once the wave is smooth */
.badge {
  display: inline-block;
  opacity: 0;
}

.badge__in {
  position: relative;
  display: block;
  overflow: hidden;
  padding: 2px 6px 2px;
  border-radius: 6px;
  font-size: 9.5px;
  font-weight: 650;
  font-stretch: 115%;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: linear-gradient(180deg, rgba(111, 242, 207, 0.14), rgba(111, 242, 207, 0.05));
  box-shadow: inset 0 0 0 1px rgba(111, 242, 207, 0.32), 0 0 14px -4px rgba(111, 242, 207, 0.5);
}

.badge__shine {
  position: absolute;
  top: 0;
  bottom: 0;
  left: -50%;
  width: 40%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  transform: skewX(-20deg);
  opacity: 0;
}

.row__title {
    font-size: 17px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .roll__line.is-busy {
    animation: none;
    color: var(--ink);
    background: none;
  }
}
