/* After a Braun T523 study drawn in Figma (the light version). Geometry is
   in the drawing's own units: the set is 1549 wide there, so one unit (--u)
   is a 1549th of the stage. Knob, button, shadow and grain artwork in
   assets/ is the Figma artwork itself. */

:root {
  --black: #090909;
  --body: #e0e0e0;
  --glass: #f1f1f1;
  --red: #f00;
  --pointer: #006310;
  --page: #d5d5d5;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--page);
  color: var(--black);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.scene {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
}

.stage {
  container-type: inline-size;
  width: min(100%, 1240px);
  --u: calc(100cqw / 1549);
}

/* ── The set ─────────────────────────────────────────────── */

.radio {
  position: relative;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  padding-top: calc(41 * var(--u));
  border-radius: calc(24 * var(--u));
  background: var(--body);
  font-weight: 700;
}

/* The dial window. */
.window {
  position: relative;
  display: flex;
  align-items: stretch;
  height: calc(160 * var(--u));
  /* a shaded recess along the top edge, then the glass */
  background: linear-gradient(#9a9a9a 0 calc(9 * var(--u)), var(--glass) calc(9 * var(--u)));
  border: max(1px, calc(.925 * var(--u))) solid var(--black);
  border-left: 0;
  border-right: 0;
}

.window::before, .window::after { /* the recess at each end */
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: calc(22 * var(--u));
  background: #aaa;
}
.window::before { left: 0; }
.window::after { right: 0; }

.scales {
  position: relative;
  flex: 0 1 calc(910 * var(--u));
  margin-left: calc(63 * var(--u));
  cursor: ew-resize;
  touch-action: none;
}

.scale { position: absolute; inset: 0; }

.row {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--y) * var(--u));
  height: 0;
  border-top: max(1px, calc(1 * var(--u))) solid currentColor;
}

.row i { /* a tick */
  position: absolute;
  top: 0;
  left: calc(var(--p) * 100%);
  width: max(1px, calc(1 * var(--u)));
  margin-left: calc(max(1px, calc(1 * var(--u))) / -2);
  height: calc(5 * var(--u));
  background: currentColor;
}

.row.years i.major { height: calc(9 * var(--u)); }

.row.years span {
  position: absolute;
  bottom: calc(6 * var(--u));
  left: calc(var(--p) * 100%);
  transform: translateX(-50%);
  font-size: max(7px, calc(13 * var(--u)));
  line-height: 1;
  letter-spacing: .02em;
}

/* A station's row: a mark for every year it has a broadcast. */
.row.station { color: #8a8a8a; }
.row.station i {
  top: calc(-4 * var(--u));
  height: calc(8 * var(--u));
  width: calc(4 * var(--u));
  margin-left: calc(-2 * var(--u));
  background: currentColor;
}

.row.station.tuned {
  color: var(--red);
  box-shadow: 0 calc(-3 * var(--u)) 0 -0.5px currentColor, 0 calc(3 * var(--u)) 0 -0.5px currentColor;
  border-top-width: max(1px, calc(1 * var(--u)));
}
.radio:not(.on) .row.station.tuned { color: var(--black); box-shadow: none; }

.needle {
  --pos: .5;
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--pos) * 100%);
  width: calc(7 * var(--u));
  min-width: 2px;
  margin-left: calc(-3.5 * var(--u));
  background: linear-gradient(90deg, transparent 0 43%, rgba(255, 255, 255, .3) 43% 100%), var(--pointer);
  box-shadow: calc(-5.55 * var(--u)) calc(7.86 * var(--u)) calc(1.85 * var(--u)) rgba(0, 0, 0, .25);
  transition: left .35s cubic-bezier(.3, .7, .3, 1);
  pointer-events: none;
}

.legend {
  position: relative;
  flex: 0 0 calc(150 * var(--u));
  margin-left: calc(17 * var(--u));
  font-size: max(7px, calc(13 * var(--u)));
  line-height: 1;
}

.legend span {
  position: absolute;
  left: 0;
  top: calc(var(--y) * var(--u));
  transform: translateY(-55%);
  white-space: nowrap;
}

.legend span.tuned { color: var(--red); }
.radio:not(.on) .legend span.tuned { color: var(--black); }

/* The small metal push button: power. */
.power {
  position: relative;
  flex: none;
  align-self: flex-start;
  width: calc(59.2 * var(--u));
  height: calc(59.2 * var(--u));
  margin: calc(56 * var(--u)) calc(100 * var(--u)) 0 auto;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
}

.power img, .knob img, .btn img {
  position: absolute;
  display: block;
  max-width: none;
  /* artwork only: the browser must not pick it up and drag it */
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
}

.power .name {
  position: absolute;
  left: calc(100% + 8 * var(--u));
  top: 50%;
  transform: translateY(-50%);
  font-size: max(7px, calc(13 * var(--u)));
  font-weight: 700;
  line-height: 1;
  color: var(--black);
}

/* Our mark, where the maker's badge sits on the drawing. */
.logo {
  flex: none;
  align-self: center;
  margin-left: calc(64 * var(--u));
  font: 800 calc(21 * var(--u))/.92 "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-stretch: condensed;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--black);
}

.power .shadow { left: calc(-14 * var(--u)); top: calc(-2 * var(--u)); width: calc(74.9 * var(--u)); height: calc(90.7 * var(--u)); }
.power .base { inset: 0; width: 100%; height: 100%; }
.power .ring { left: calc(1.7 * var(--u)); top: calc(1.7 * var(--u)); width: calc(55.8 * var(--u)); height: calc(55.8 * var(--u)); }
.power .cap { left: calc(7.4 * var(--u)); top: calc(7.4 * var(--u)); width: calc(44.4 * var(--u)); height: calc(44.4 * var(--u)); transition: transform .08s; }
.power[aria-pressed="true"] .cap { transform: scale(.93); filter: brightness(.94); }

/* ── The control panel ───────────────────────────────────── */

.panel {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  min-height: calc(204 * var(--u));
  padding: calc(35 * var(--u)) calc(81 * var(--u)) 0 calc(100 * var(--u));
}

.control {
  position: relative;
  display: flex;
  align-items: center;
  gap: calc(16 * var(--u));
  width: calc(340 * var(--u));
  height: calc(169 * var(--u));
  align-items: flex-start;
}

.control .name, .control .zero {
  font-size: max(9px, calc(16 * var(--u)));
  line-height: 1;
  margin-top: calc(57 * var(--u));
  position: relative;
  z-index: 1;
}

.control .zero {
  position: absolute;
  left: calc(-32 * var(--u));
  top: 0;
}

.knob {
  --turn: 0deg;
  position: relative;
  flex: none;
  width: calc(132.3 * var(--u));
  height: calc(132.8 * var(--u));
  border-radius: 50%;
  cursor: grab;
  touch-action: none;
}
.knob:active { cursor: grabbing; }

.knob .shadow { left: calc(-92.4 * var(--u)); top: calc(.7 * var(--u)); width: calc(224.1 * var(--u)); height: calc(309.9 * var(--u)); pointer-events: none; }
.knob .base { inset: 0; width: 100%; height: 100%; }
.knob .ring { left: calc(2.6 * var(--u)); top: calc(2.3 * var(--u)); width: calc(128.1 * var(--u)); height: calc(128.1 * var(--u)); }
.knob .ribs {
  left: calc(4.6 * var(--u));
  top: calc(5 * var(--u));
  width: calc(123.4 * var(--u));
  height: calc(123.4 * var(--u));
  border-radius: 50%;
  transform: rotate(var(--turn));
  transition: transform .18s ease-out;
}
.knob .cap { left: calc(19.6 * var(--u)); top: calc(20 * var(--u)); width: calc(92.7 * var(--u)); height: calc(92.7 * var(--u)); }

.knob .mark { /* the volume knob's index line */
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(39 * var(--u));
  height: max(1.5px, calc(2.6 * var(--u)));
  margin-top: calc(-1.3 * var(--u));
  border-radius: 2px;
  background: var(--black);
  transform-origin: 0 50%;
  transform: rotate(calc(var(--turn) + 333deg));
  transition: transform .18s ease-out;
}

:focus-visible { outline: 2px solid #ff4d00; outline-offset: 3px; }

/* The round station buttons. */
.presets {
  display: flex;
  margin-left: auto;
  margin-top: calc(-3 * var(--u));
  height: calc(172 * var(--u));
}

.preset {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(15 * var(--u));
  width: calc(116 * var(--u));
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.preset .label {
  position: relative;
  z-index: 1;
  font-size: max(8px, calc(16 * var(--u)));
  line-height: 1;
  white-space: nowrap;
}

.btn {
  position: relative;
  width: calc(77.7 * var(--u));
  height: calc(77.7 * var(--u));
}

.btn .shadow { left: calc(-69.4 * var(--u)); top: calc(-1.9 * var(--u)); width: calc(149 * var(--u)); height: calc(217.8 * var(--u)); pointer-events: none; }
.btn .base { inset: 0; width: 100%; height: 100%; }
.btn .ring { left: calc(2.8 * var(--u)); top: calc(2.8 * var(--u)); width: calc(72.2 * var(--u)); height: calc(72.2 * var(--u)); }
.btn .cap { left: calc(6.5 * var(--u)); top: calc(6.5 * var(--u)); width: calc(64.8 * var(--u)); height: calc(64.8 * var(--u)); }

.btn .lit { opacity: 0; transition: opacity .25s; }
.radio.on .preset[aria-pressed="true"] .lit { opacity: 1; }
.preset:active .cap { transform: scale(.96); }

/* The darker underside, and the grain over everything. */
.lip {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  /* an inset band, so it follows the rounded corners like the drawing's rim */
  box-shadow:
    0 calc(-17 * var(--u)) 0 rgba(0, 0, 0, .36) inset,
    calc(5 * var(--u)) 0 0 rgba(0, 0, 0, .1) inset;
  pointer-events: none;
}

.noise {
  position: absolute;
  inset: 0;
  background: url(assets/noise.png) 0 0 / calc(231.3 * var(--u)) calc(231.3 * var(--u));
  mix-blend-mode: overlay;
  opacity: .3;
  pointer-events: none;
}

/* ── What's on ───────────────────────────────────────────── */

.card {
  margin: 34px 0 0 calc(63 * var(--u));
  max-width: 520px;
  min-height: 138px;
}

.card p { margin: 0; font-size: 15px; line-height: 1.5; }

.card h1 {
  margin: 2px 0 4px;
  font-size: 34px;
  line-height: 1.1;
  font-weight: 700;
  letter-spacing: -.01em;
}

.card .card-kicker {
  font-size: 13px;
  font-weight: 700;
  text-transform: lowercase;
  color: var(--red);
}

.card .card-note { color: #5c5c5c; margin-top: 4px; }

.credit {
  margin: 22px 0 0 calc(63 * var(--u));
  font-size: 12px;
  color: #777;
}

/* Narrow screens: the same parts, restacked at a larger scale. */
@media (max-width: 720px) {
  .stage { --u: calc(100cqw / 760); }
  .radio { padding-top: calc(30 * var(--u)); }
  .scales { flex: 1 1 0; margin-left: calc(40 * var(--u)); }
  .legend { flex-basis: calc(96 * var(--u)); margin-left: calc(12 * var(--u)); }
  .power { margin: calc(50 * var(--u)) calc(78 * var(--u)) 0 calc(4 * var(--u)); }
  .logo { display: none; } /* no room beside the scale at this size */
  .panel { padding: calc(35 * var(--u)) calc(40 * var(--u)) calc(17 * var(--u)) calc(70 * var(--u)); }
  .control { width: calc(320 * var(--u)); }
  .presets { margin-left: calc(-12 * var(--u)); width: 100%; justify-content: space-between; }
  .preset { width: calc(116 * var(--u)); }
  .card, .credit { margin-left: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  .needle, .knob .ribs, .knob .mark, .btn .lit { transition: none; }
}
