@font-face {
  font-family: 'Badeen Display';
  src: url('./assets/badeen-display-400.woff2') format('woff2');
  font-display: swap;
}

@font-face {
  font-family: 'IBM Plex Mono';
  src: url('./assets/ibm-plex-mono-500.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}

@font-face {
  font-family: 'IBM Plex Mono';
  src: url('./assets/ibm-plex-mono-600.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: #000; color-scheme: dark; }

html, body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  margin: 0;
  background: #000;
  color: #9ba2a6;
  font: 500 1rem 'IBM Plex Mono', monospace;
}

.tuner {
  container-type: inline-size;
  width: min(100%, 402px, 81dvh);
  height: 100dvh;
  margin: auto;
  display: grid;
  grid-template-rows: minmax(0, 55fr) minmax(0, 45fr);
  background: #5b6266 url('./assets/grain.png');
  overflow: hidden;
}

.dial {
  position: relative;
  display: grid;
  place-items: center;
  isolation: isolate;
}

.dial::before {
  content: '';
  position: absolute;
  inset: 0;
  border-bottom: 2px solid #6b7174;
  border-radius: 0 0 calc(60 * 100cqw / 402) calc(60 * 100cqw / 402);
  background: #000;
  box-shadow: 0 3px 6px #0004;
  z-index: -1;
}

.dial-face {
  position: relative;
  container-type: inline-size;
  width: min(100%, calc(55dvh * 402 / 481));
  aspect-ratio: 402 / 481;
}

.dial img,
.ticks span,
.indicators span {
  position: absolute;
  left: calc(var(--x) * 100cqw / 402);
  top: calc(var(--y) * 100cqw / 402);
}

.dial img {
  display: block;
  width: calc(var(--width) * 100cqw / 402);
  height: auto;
  pointer-events: none;
}

.scale { --x: 13; --y: -15; --width: 372; }

.needle {
  --x: 61;
  --y: -15;
  --width: 282;
  transform-origin: 48.93617% 93.93939%;
  transform: rotate(var(--angle, 0deg));
  transition: transform 180ms ease-out;
}

.axle { --x: 179; --y: 340; --width: 40; }
.axle-center { --x: 190; --y: 348; --width: 18; }

.ticks,
.indicators {
  font-size: calc(10 * 100cqw / 402);
  line-height: 1.35;
}

.minus-fifty { --x: 79; --y: 195; transform: translateX(-50%); }
.minus-twenty-five { --x: 124.96; --y: 146; }
.zero { --x: 195.7; --y: 69; color: #b9d9c0; font-size: 1.1em; }
.plus-twenty-five { --x: 254.96; --y: 146; }
.plus-fifty { --x: 319; --y: 195; transform: translateX(-50%); }
.cents { --x: 181.48; --y: 174; color: #83898c; letter-spacing: .125em; }
.indicators { letter-spacing: .1em; color: #929b9f; }
.flat { --x: 88.66; --y: 416; }
.tuned { --x: 175.13; --y: 416; }
.sharp { --x: 275.63; --y: 416; }
.dial[data-tuning='flat'] .flat,
.dial[data-tuning='sharp'] .sharp { color: #ff8881; font-weight: 600; }
.dial[data-tuning='tuned'] .tuned { color: #a6d9ae; font-weight: 600; }

.body {
  display: grid;
  grid-template-rows: minmax(0, 2fr) minmax(0, 1fr) auto;
  justify-items: center;
  align-items: center;
  padding: 0 8px max(env(safe-area-inset-bottom), 3.3dvh, 6px);
}

.display {
  position: relative;
  width: calc(278 * 100cqw / 402);
  height: calc(101 * 100cqw / 402);
  border-radius: calc(16 * 100cqw / 402);
  background: linear-gradient(#101e16, #142820 38%, #101a14);
  box-shadow: inset 0 4px 10px #000e, inset 0 0 0 2px #101511;
  overflow: hidden;
}

.digit,
.decimal,
.unit {
  position: absolute;
  left: calc(var(--x) * 100cqw / 402);
  top: calc(var(--y) * 100cqw / 402);
}

.digit {
  display: block;
  width: calc(var(--width) * 100cqw / 402);
  height: auto;
}

.segment { fill: #2a4435; }
.segment.on { fill: #9effb0; filter: drop-shadow(0 0 2px #7aff9e62); }

.decimal { --x: 208; --y: 67; width: calc(16.5 * 100cqw / 402); height: auto; }
.unit {
  --x: 250;
  --y: 64;
  font-size: calc(12 * 100cqw / 402);
  font-weight: 600;
  color: #9cf7ad;
}

.status-area {
  inline-size: min(100%, 34ch);
  text-align: center;
  color: #f3f6f6;
  font-size: clamp(.6875rem, 2.8dvh, .8125rem);
  line-height: 1.35;
}

#status { margin: 0; }

#open-tuner {
  display: inline-block;
  margin-top: .25em;
  color: #d5ffdd;
}

#brand {
  margin: 0;
  text-align: center;
  color: #83898c;
  font: 400 min(calc(36 * 100cqw / 402), 7dvh) / 1.39 'Badeen Display', sans-serif;
  letter-spacing: .01em;
  text-shadow: 0 1px #0003;
}

@media (max-height: 420px) {
  .body {
    grid-template-rows: minmax(0, 1fr) auto auto;
    row-gap: 3px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .needle { transition: none; }
}
