@font-face {
  font-family: Roboto;
  src: url("./fonts/roboto-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --background: #151515;
  --sheet: #202426;
  --accent: #56dfef;
  --accent-background: #17373c;
  --circle: #2a2a2a;
  --secondary: #aaa;
  --focus: #95f2fb;
  font-family: Roboto, system-ui, sans-serif;
  background: var(--background);
  color: #fff;
}

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

body {
  margin: 0;
  overscroll-behavior: none;
}

button {
  color: inherit;
  font: inherit;
  border: 0;
  background: none;
  cursor: pointer;
}

button:disabled { cursor: default; }

button:focus-visible,
.wheel:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.metronome {
  display: flex;
  flex-direction: column;
  align-items: center;
  container-type: inline-size;
  height: 100vh;
  height: 100dvh;
  padding: calc(env(safe-area-inset-top, 0px) + 18px)
    env(safe-area-inset-right, 0px)
    calc(env(safe-area-inset-bottom, 0px) + 18px)
    env(safe-area-inset-left, 0px);
}

.wheel {
  position: relative;
  flex-shrink: 0;
  scrollbar-width: none;
  overscroll-behavior: contain;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.wheel::-webkit-scrollbar { display: none; }

.wheel.dragging {
  scroll-snap-type: none;
  cursor: grabbing;
}

.wheel-track { display: flex; }

.wheel-item {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  scroll-snap-align: center;
}

.digit {
  display: block;
  transform: scaleX(.45);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.accent-wheel {
  width: min(260px, 100%);
  height: 48px;
  overflow: auto hidden;
  scroll-snap-type: x mandatory;
  touch-action: pan-x;
  mask-image: linear-gradient(90deg, transparent, #000 40%, #000 60%, transparent);
}

.accent-wheel:focus-visible {
  outline: 0;
}

.accent-wheel:focus-visible .wheel-item.is-centered .accent-circle {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

.accent-wheel .wheel-track {
  width: max-content;
  min-width: 100%;
  padding-inline: max(0px, calc((min(260px, 100cqw) - 52px) / 2));
}

.accent-wheel .wheel-item {
  width: min(52px, 100cqw);
  height: 48px;
}

.accent-circle {
  display: grid;
  place-items: center;
  width: min(48px, 100cqw);
  height: 48px;
  border-radius: 50%;
  background: var(--circle);
  color: var(--secondary);
  font-size: 32px;
}

.accent-wheel .is-centered .accent-circle { color: #fff; }

.accent-wheel[data-enabled="true"] .is-centered .accent-circle {
  color: var(--accent);
  background: var(--accent-background);
}

.accent-wheel[data-enabled="false"] .is-centered { cursor: pointer; }

.bpm-display {
  position: relative;
  display: grid;
  flex: 1;
  place-items: center;
  width: 100%;
  min-height: 0;
  container-type: size;
}

.bpm-display::before,
.bpm-display::after {
  position: absolute;
  top: 50%;
  width: 21.7%;
  height: 2px;
  transform: translateY(-50%);
  border-radius: 2px;
  background: var(--accent);
  content: "";
}

.bpm-display::before { left: 0; }
.bpm-display::after { right: 0; }

.bpm-label {
  position: absolute;
  top: calc(50% - 25px);
  left: 3.9%;
  color: var(--secondary);
  font-size: 13px;
}

.bpm-wheel {
  --step: 29cqh;
  width: 56%;
  height: 87%;
  overflow: hidden auto;
  scroll-snap-type: y mandatory;
  touch-action: pan-y;
  mask-image: linear-gradient(transparent, #000 31%, #000 69%, transparent);
}

.bpm-wheel:focus-visible {
  outline: 0;
}

.bpm-wheel:focus-visible .wheel-item.is-centered {
  outline: 1px solid var(--focus);
  outline-offset: -2px;
  border-radius: 10px;
}

.bpm-wheel .wheel-track {
  flex-direction: column;
  padding-block: var(--step);
}

.bpm-wheel .wheel-item {
  grid-template-columns: minmax(0, 1fr);
  height: var(--step);
  font-size: min(29.58cqh, 48cqw);
}

.bpm-wheel .digit {
  transform: translateY(-.082em) scaleX(.45);
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1.42fr 1fr;
  align-items: center;
  width: min(500px, 100%);
  padding: 0 12px;
}

.sound-button {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  min-height: 52px;
  padding: 3px 2px;
  border-radius: 8px;
  color: var(--secondary);
  font-size: 12px;
  text-align: center;
}

.sound-button[data-active="true"] { color: var(--accent); }

.sound-icon {
  display: block;
  width: 22px;
  height: 22px;
}

.note-icon {
  font-family: system-ui, sans-serif;
  font-size: 22px;
  line-height: 1;
}

.pulse-icon {
  background: currentColor;
  clip-path: polygon(5% 51%, 27% 51%, 42% 22%, 61% 70%, 75% 51%, 95% 51%, 95% 59%, 78% 59%, 59% 84%, 41% 37%, 32% 59%, 5% 59%);
}

.playback-button {
  min-height: 50px;
  padding: 10px 8px;
  border-radius: 9px;
  background: var(--accent-background);
  color: var(--accent);
  font-size: 22px;
  font-weight: 500;
}

.playback-button:disabled { opacity: .72; }

.error-message {
  margin: 4px 16px;
  color: #ffb4ab;
  font-size: 12px;
  text-align: center;
}

.sound-sheet {
  position: fixed;
  inset: auto 0 0;
  width: min(640px, 100%);
  max-width: none;
  max-height: min(85vh, 85dvh);
  margin: 0 auto;
  padding: 20px 20px calc(16px + env(safe-area-inset-bottom, 0px));
  border: 0;
  border-radius: 28px 28px 0 0;
  background: var(--sheet);
  color: #fff;
}

.sound-sheet::backdrop { background: rgb(0 0 0 / 55%); }

.sheet-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.sheet-heading h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 500;
}

.sheet-close {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: var(--secondary);
  font-size: 26px;
}

.accent-switch,
.timbre-option,
.timbre-choice {
  display: flex;
  align-items: center;
  min-height: 48px;
}

.accent-switch {
  position: relative;
  justify-content: space-between;
  min-height: 52px;
  gap: 10px;
  cursor: pointer;
}

.accent-switch input {
  position: absolute;
  inset-inline-end: 0;
  width: 48px;
  height: 28px;
  opacity: 0;
}

.switch-track {
  position: relative;
  flex-shrink: 0;
  width: 48px;
  height: 28px;
  border: 2px solid var(--secondary);
  border-radius: 14px;
  background: var(--circle);
}

.switch-track::before {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--secondary);
  content: "";
}

.accent-switch input:checked + .switch-track {
  border-color: var(--accent);
  background: var(--accent);
}

.accent-switch input:checked + .switch-track::before {
  transform: translateX(20px);
  background: var(--background);
}

.accent-switch input:focus-visible + .switch-track {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.timbre-choice {
  flex: 1;
  gap: 12px;
  cursor: pointer;
}

.timbre-choice input {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--accent);
}

.preview-button {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  color: var(--accent);
}

.preview-button:disabled { color: #808688; }

.preview-button::before {
  width: 0;
  height: 0;
  border: 7px solid transparent;
  border-right: 0;
  border-left: 11px solid currentColor;
  content: "";
}

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