/* The record crate search: a dark field with a small turntable for a lens, and under it a wooden crate of record
   sleeves on a black page, with the record in front described beside it. */
:root {
  --page: #000000;          /* the page */
  --ink: #f4efe4;           /* the words */
  --muted: #958d80;         /* the quieter words */
  --field: #141210;         /* the field */
  --edge: #2c2824;          /* its edge */
  --accent: #ff6b3d;        /* the focus, the record playing */
  --wood: #6b4a30;          /* the crate, in the light */
  --wood-dark: #2e1f14;     /* the crate, in the shade */
  --paper: #ebe4d4;         /* the back of a sleeve, the divider card */
  --vinyl: #0d0c0b;         /* the records */
}

* {
  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: 'Bricolage Grotesque Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

.stage {
  min-height: 100svh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  justify-items: center;
  align-content: center;
  padding: 32px 16px;
}

.dig {
  --s: 200px;               /* the side of a sleeve: the script writes it from SLEEVE */
  position: relative;
  width: min(540px, 100%);
}

.dig__form {
  position: relative;
  z-index: 1;
  margin: 0;
}

/* ---------------------------------------------------------------- the field */
.dig__field {
  position: relative;
  height: 60px;
  border-radius: 18px;
  background: var(--field);
  box-shadow: inset 0 0 0 1px var(--edge), 0 18px 40px -24px rgba(255, 190, 140, 0.18);
  transition: box-shadow 0.25s ease;
}

.dig__field:focus-within,
.dig.is-pretend .dig__field {
  box-shadow: inset 0 0 0 1px #5a5149, 0 0 0 3px rgba(255, 107, 61, 0.28), 0 18px 40px -24px rgba(255, 190, 140, 0.18);
}

/* the lens: a small turntable seen from above */
.deck {
  position: absolute;
  left: 9px;
  top: 8px;
  width: 44px;
  height: 44px;
  overflow: visible;
  pointer-events: none;
}

.deck__plinth {
  fill: #221f1c;
  stroke: #3a3530;
  stroke-width: 1;
}

.deck__vinyl {
  fill: var(--vinyl);
  stroke: #2a2724;
  stroke-width: 0.6;
}

.deck__groove {
  fill: none;
  stroke: rgba(255, 255, 255, 0.09);
  stroke-width: 0.5;
}

.deck__label {
  fill: #8f877c;
}

.deck__half {
  fill: rgba(0, 0, 0, 0.28);
}

/* the light stays still while the record turns under it */
.deck__shine {
  fill: rgba(255, 255, 255, 0.09);
}

.deck__spindle {
  fill: #d8d2c8;
}

.deck__pivot {
  fill: #4a443e;
  stroke: #6d655c;
  stroke-width: 0.6;
}

.deck__arm {
  fill: none;
  stroke: #cfc8bd;
  stroke-width: 1.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.deck__head {
  fill: #cfc8bd;
}

.dig__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0 54px 0 66px;
  border: 0;
  border-radius: inherit;
  outline: none;
  background: transparent;
  color: var(--ink);
  caret-color: var(--accent);
  font: 500 17px / normal 'Bricolage Grotesque Variable', system-ui, sans-serif;
  -webkit-appearance: none;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.dig__input::placeholder {
  color: var(--muted);
  opacity: 1;
}

/* the caret drawn while the library's preview types without the focus */
.dig__caret {
  position: absolute;
  top: 19px;
  width: 2px;
  height: 22px;
  border-radius: 1px;
  background: var(--accent);
  opacity: 0;
  pointer-events: none;
}

.dig__caret.is-on {
  animation: blink 1s steps(1) infinite;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}

.dig__clear {
  position: absolute;
  right: 11px;
  top: 12px;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: #24211e;
  color: var(--muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.dig__clear svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.dig__clear:focus-visible,
.listen:focus-visible,
.try:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

@media (hover: hover) {
  .dig__clear:hover {
    color: var(--ink);
    background: #2e2a26;
  }
}

/* ---------------------------------------------------------------- the crate and the record described */
.dig__shop {
  position: relative;
  z-index: 3;
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 22px;
  align-items: end;
  margin-top: 14px;
}

.crate {
  position: relative;
  height: 312px;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

/* the room the sleeves stand in, seen from a little above */
.crate__bin {
  position: absolute;
  /* wider than the crate, so a record sliding out at the side is not cut; the sleeves sink out of sight at the
     bottom. Only the sleeves take the pointer: the room at the sides lets it through */
  inset: 0 -150px;
  overflow: hidden;
  perspective: 900px;
  perspective-origin: 50% -40%;
  pointer-events: none;
  touch-action: none;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.crate.is-held,
.crate.is-held .sleeve {
  cursor: grabbing;
}

/* the sides of the crate, going back */
.crate__side {
  position: absolute;
  bottom: 0;
  width: 170px;
  height: 64px;
  border-radius: 0 6px 0 0;
  background: linear-gradient(90deg, #3b2a1c, #22170e 70%, #1a120b);
  pointer-events: none;
}

.crate__side--l {
  left: calc(50% - var(--s) / 2 - 18px);
  transform-origin: 0 50%;
  transform: rotateY(90deg);
}

.crate__side--r {
  left: calc(50% + var(--s) / 2 + 18px);
  transform-origin: 0 50%;
  transform: rotateY(90deg);
}

/* a sleeve: the cover in front, the back with its track list, the record inside */
.sleeve {
  position: absolute;
  left: 50%;
  bottom: 12px;
  width: var(--s);
  height: var(--s);
  margin-left: calc(var(--s) / -2);
  transform-origin: 50% 100%;
  transform-style: preserve-3d;
  will-change: transform;
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
  -webkit-tap-highlight-color: transparent;
}

.sleeve__face {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: 2px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

/* the cover a pixel in front of the record, the back a pixel behind it: in 3D, not in the order of the page */
.sleeve__front {
  transform: translateZ(1px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.sleeve__front svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* the gloss of the card, and the worn ring the record has pressed into it */
.sleeve__front::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 50% 52%, transparent 40%, rgba(255, 255, 255, 0.07) 41.5%, transparent 44%),
    linear-gradient(160deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0) 38%, rgba(0, 0, 0, 0) 70%, rgba(0, 0, 0, 0.22));
  pointer-events: none;
}

.cover__words {
  position: absolute;
  left: 9%;
  right: 9%;
  top: 3.6%;
  line-height: 1;
}

.cover__title {
  display: block;
  overflow: hidden;
  font-size: calc(var(--s) * 0.078);
  font-weight: 760;
  font-stretch: 78%;
  letter-spacing: -0.01em;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.cover__artist {
  display: block;
  margin-top: 0.95em;
  font-size: calc(var(--s) * 0.054);
  font-weight: 480;
  opacity: 0.86;
  white-space: nowrap;
}

/* the darkness of the sleeves further back */
.sleeve__shade {
  position: absolute;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
}

.sleeve__back {
  transform: rotateX(180deg) translateZ(1px);
  background:
    repeating-linear-gradient(180deg, transparent 0 13px, rgba(40, 32, 24, 0.16) 13px 15px) 14% 34% / 58% 44% no-repeat,
    linear-gradient(#e2dac8, #cfc5b0);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.sleeve__back span {
  position: absolute;
  left: 14%;
  top: 16%;
  font-size: calc(var(--s) * 0.058);
  font-weight: 700;
  color: #3a3128;
  white-space: nowrap;
}

.sleeve__disc {
  position: absolute;
  left: 5%;
  top: 4%;
  width: 90%;
  height: 90%;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}

.disc {
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--lab) 0 15.5%, #000 16% 17%, transparent 17.5%),
    repeating-radial-gradient(circle, #121110 0 1.6px, #1d1b19 1.6px 2.4px),
    var(--vinyl);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06), 0 6px 18px rgba(0, 0, 0, 0.5);
}

.disc::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 20deg, transparent 0 8%, rgba(255, 255, 255, 0.13) 12%, transparent 18% 58%, rgba(255, 255, 255, 0.1) 62%, transparent 68%);
}

/* the card standing in an empty crate */
.divider {
  position: absolute;
  left: 50%;
  bottom: 12px;
  width: var(--s);
  height: calc(var(--s) * 0.86);
  margin-left: calc(var(--s) / -2);
  transform-origin: 50% 100%;
  visibility: hidden;
  pointer-events: none;
}

.divider__tab {
  position: absolute;
  left: 10%;
  top: -22px;
  height: 24px;
  padding: 5px 12px 0;
  border-radius: 6px 6px 0 0;
  background: var(--paper);
  color: #6b6052;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.divider__card {
  position: absolute;
  inset: 0;
  display: block;
  padding: 16% 10% 0;
  border-radius: 0 3px 3px 3px;
  background: linear-gradient(var(--paper), #d9d0bd);
  color: #2a231c;
}

.divider__small {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: #6b6052;
}

.divider__word {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  font-size: 30px;
  font-weight: 780;
  font-stretch: 76%;
  line-height: 1;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* the front of the crate, over everything */
.crate__front {
  position: absolute;
  left: 50%;
  bottom: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  width: calc(var(--s) + 40px);
  height: 66px;
  margin-left: calc(var(--s) / -2 - 20px);
  border-radius: 5px 5px 9px 9px;
  background:
    repeating-linear-gradient(178deg, rgba(0, 0, 0, 0) 0 7px, rgba(0, 0, 0, 0.07) 7px 8px, rgba(255, 220, 180, 0.04) 8px 10px),
    linear-gradient(180deg, var(--wood) 0%, #4c3422 38%, var(--wood-dark) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 222, 186, 0.35), inset 0 -14px 22px rgba(0, 0, 0, 0.45), 0 -18px 26px -10px rgba(0, 0, 0, 0.85);
  pointer-events: none;
}

/* the little metal holder with the card that says what is in the crate */
.crate__holder {
  display: grid;
  place-items: center;
  min-width: 108px;
  height: 26px;
  padding: 3px;
  border-radius: 4px;
  background: linear-gradient(#b9b2a6, #6f685e);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.crate__tag {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0 10px;
  border-radius: 2px;
  background: #efe8d8;
  color: #3b3127;
  font-size: 11.5px;
  font-weight: 650;
  line-height: 20px;
  letter-spacing: 0.06em;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
}

/* ---------------------------------------------------------------- the record in front, described */
.info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding-bottom: 6px;
}

:where(.info) p {
  margin: 0;
}

.info__meta {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.info__title {
  margin-top: 8px;
  font-size: 26px;
  font-weight: 760;
  font-stretch: 80%;
  line-height: 1.02;
  letter-spacing: -0.01em;
}

.info__artist {
  margin-top: 6px;
  font-size: 16px;
  color: #d6cfc2;
}

.info__price {
  margin-top: 14px;
  font-size: 15px;
  font-weight: 650;
}

.info__price span {
  margin-left: 6px;
  font-weight: 450;
  color: var(--muted);
}

.info__try {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.info__tries {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.try {
  height: 36px;
  padding: 0 15px;
  border: 1px solid #3a3530;
  border-radius: 18px;
  background: transparent;
  color: var(--ink);
  font: 550 15px / 1 'Bricolage Grotesque Variable', system-ui, sans-serif;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

@media (hover: hover) {
  .try:hover {
    border-color: var(--accent);
    background: rgba(255, 107, 61, 0.12);
  }
}

/* listen: the record in front goes onto the turntable */
.listen {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  align-self: flex-start;
  height: 46px;
  margin-top: 20px;
  padding: 0 20px 0 15px;
  border: 0;
  border-radius: 23px;
  background: var(--ink);
  color: var(--page);
  font: 650 15px / 1 'Bricolage Grotesque Variable', system-ui, sans-serif;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.25s ease, color 0.25s ease, transform 0.25s cubic-bezier(0.3, 1.6, 0.5, 1);
}

.listen:active {
  transform: scale(0.96);
}

.listen.is-on {
  background: var(--accent);
  color: #1a0d07;
}

.listen[disabled] {
  opacity: 0;
  pointer-events: none;
}

.listen__icon {
  position: relative;
  display: block;
  width: 18px;
  height: 18px;
}

.listen__play {
  position: absolute;
  inset: 0;
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* three bars that move while the record plays */
.listen__bars {
  position: absolute;
  inset: 2px 1px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  opacity: 0;
}

.listen__bars i {
  display: block;
  width: 3.5px;
  height: 100%;
  border-radius: 1px;
  background: currentColor;
  transform-origin: 50% 100%;
}

.listen.is-on .listen__play {
  opacity: 0;
}

.listen.is-on .listen__bars {
  opacity: 1;
}

@media (hover: hover) {
  .listen:hover {
    background: #ffffff;
  }

  .listen.is-on:hover {
    background: #ff8a63;
  }
}

/* the record on its way to the turntable: over the field, under the crate, so it leaves its sleeve still
   behind the cover */
.dig__flight {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.dig__flight .disc {
  position: absolute;
  left: 0;
  top: 0;
}

/* ---------------------------------------------------------------- a phone: the crate, and the record under it */
@media (max-width: 560px) {
  .dig__shop {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }

  .crate {
    height: 280px;
  }

  .info {
    flex-direction: row;
    align-items: center;
    gap: 14px;
    min-height: 56px;
    padding: 0 2px;
  }

  .info__record,
  .info__none {
    flex: 1;
    min-width: 0;
  }

  .info__meta,
  .info__price {
    display: none;
  }

  .info__title {
    margin-top: 0;
    overflow: hidden;
    font-size: 20px;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .info__artist {
    margin-top: 3px;
    overflow: hidden;
    font-size: 14px;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .info__none {
    display: flex;
    align-items: center;
    gap: 10px;
  }

  .info__none[hidden] {
    display: none;
  }

  .info__tries {
    flex-wrap: nowrap;
    margin-top: 0;
    gap: 6px;
  }

  .try {
    padding: 0 12px;
  }

  .listen {
    flex: none;
    align-self: center;
    margin-top: 0;
  }
}
