/* 540 frame, filled by one photograph (1536 px source, so 1 source px = 0.3516 CSS px).
   Measured on it: the label's centre is at (200.25, 195.86) and its paper is 65.1 by 67.4 in radius;
   the slot runs from x = 100.9 to 327.3 on y = 428; the knob, as photographed, stands at (213.35, 428). */
.tt {
  --ink: #f6f3ea;
  position: absolute;
  inset: 0;
  overflow: hidden;
  isolation: isolate;
  background: #fbcb02;
  font-family: "Jost Variable", sans-serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

.tt-deck {
  position: absolute;
  inset: 0;
  display: block;
  width: 540px;
  height: 540px;
}

/* The grooves, a second time: the ring of vinyl between the label and the headshell, laid exactly over itself,
   so it can rock a fraction of a degree as the record turns. */
.tt-sheen {
  position: absolute;
  top: 71.86px;
  left: 76.25px;
  width: 248px;
  height: 248px;
  background: url("./deck.jpg") -76.25px -71.86px / 540px 540px;
  mask: radial-gradient(circle, #0000 69px, #000 73px, #000 104px, #0000 122px);
}

/* The label. Its ink is multiplied onto the blank paper in the photograph, so the paper's light, its edge and
   the spindle with its shadow stay where the sun put them while the print goes round. The disc of ink is a
   little larger than the paper; past the paper it falls on black vinyl and doesn't show. */
.tt-label {
  position: absolute;
  top: 125.86px;
  left: 130.25px;
  width: 140px;
  height: 140px;
  /* the paper as it lies in the photograph, a shade taller than wide */
  clip-path: ellipse(65.4px 67.7px at 50% 50%);
  mix-blend-mode: multiply;
}

.tt-label svg {
  position: absolute;
  top: 1.8px;
  left: 1.8px;
  width: 136.4px;
  height: 136.4px;
}

.tt-red {
  fill: #e8302c;
}

.tt-paper {
  fill: #fff;
}

.tt-hour {
  stroke: #fff;
  stroke-width: 1.5;
}

.tt-dial {
  fill: none;
  stroke: #fff;
  stroke-width: 1.5;
}

.tt-label text {
  fill: #17120f;
  font-family: "Jost Variable", sans-serif;
}

.tt-label .tt-mark {
  fill: #fff;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.2em;
}

.tt-title {
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.tt-small {
  font-size: 7.4px;
  font-weight: 600;
  letter-spacing: 0.14em;
}

.tt-rim {
  font-size: 6.6px;
  font-weight: 600;
  letter-spacing: 0.16em;
}

/* The speed selector: three legends screened on the plinth over the three stops of the slide. */
.tt-speeds {
  position: absolute;
  top: 372px;
  left: 64.85px;
  display: flex;
  width: 297px;
  height: 92px;
}

.tt-speed {
  all: unset;
  box-sizing: border-box;
  position: relative;
  flex: 1;
  /* a button centres its text in a set height, so the height is made of padding instead */
  padding: 2px 0 58px;
  color: var(--ink);
  font-size: 29px;
  font-weight: 500;
  line-height: 32px;
  text-align: center;
  letter-spacing: 0.01em;
  font-variant-numeric: lining-nums tabular-nums;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* One third, set as a case fraction beside the 33. */
.tt-third {
  position: relative;
  display: inline-block;
  width: 17px;
  height: 21px;
  margin-left: 2px;
  vertical-align: -1px;
}

.tt-third b {
  position: absolute;
  font-size: 13px;
  font-weight: 600;
  line-height: 13px;
}

.tt-third b:first-child {
  top: 0;
  left: 0;
}

.tt-third b:last-child {
  right: 0;
  bottom: 0;
}

.tt-third i {
  position: absolute;
  top: 1px;
  left: 8px;
  width: 1.6px;
  height: 20px;
  background: currentColor;
  rotate: 30deg;
}

.tt-rpm {
  position: absolute;
  top: 422px;
  left: 36px;
  width: 44px;
  color: var(--ink);
  font-size: 9.5px;
  font-weight: 600;
  line-height: 12px;
  letter-spacing: 0.2em;
  text-align: right;
}

/* The slide: the knob cut out of the photograph, and under it the shadow it cast there. It rides on the slot's
   centre line and snaps into each stop. */
.tt-slide {
  position: absolute;
  top: 56px;
  left: calc(var(--segmented-control-indicator-left) + var(--segmented-control-indicator-width) / 2);
  pointer-events: none;
  transition: left 300ms cubic-bezier(0.3, 1.35, 0.45, 1);
}

.tt-shade,
.tt-cap {
  position: absolute;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

.tt-shade {
  top: -24.75px;
  left: -24.56px;
  width: 70.31px;
  height: 70.31px;
  background-image: url("./shadow.png");
  transition: translate 90ms ease-out;
}

.tt-cap {
  top: -19.125px;
  left: -18.935px;
  width: 37.97px;
  height: 37.97px;
  background-image: url("./knob.png");
  transition: scale 90ms ease-out;
}

/* A thumb on the knob presses it into the slot: it sits lower, so its shadow draws in under it. */
.tt-speeds:has(.tt-speed:active) .tt-shade {
  translate: -2.5px -2.5px;
}

.tt-speeds:has(.tt-speed:active) .tt-cap {
  scale: 0.975;
}

/* Keyboard focus: a ring screened round the knob's stop, in the legends' ink. */
.tt-slide::after {
  content: "";
  position: absolute;
  top: -23px;
  left: -23px;
  width: 46px;
  height: 46px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  opacity: 0;
  scale: 1.18;
  transition:
    opacity 140ms,
    scale 200ms cubic-bezier(0.3, 1.3, 0.5, 1);
}

.tt-speeds:has(.tt-speed:focus-visible) .tt-slide::after {
  opacity: 1;
  scale: 1;
}

@media (prefers-reduced-motion: reduce) {
  .tt-slide,
  .tt-shade,
  .tt-cap,
  .tt-slide::after {
    transition: none;
  }
}
