/* Two names for two things the theme has no word for. Sharps take the cool
   accent and flats the warm one everywhere they appear -- wheel, dials, staff --
   so the pairing is written once here rather than chosen again at each use. */
:root {
  --sharp: var(--accent);
  --flat: var(--warm);
  --sym: "Noto Music", "Segoe UI Symbol", "Apple Symbols", "Segoe UI Historic", var(--font-mono);
}

.tool-main {
  padding-block: 40px 64px;
}

.tool-head {
  margin-bottom: 28px;
}

.tool-head h1 {
  margin: 0;
  color: var(--ink);
  font-size: 32px;
  line-height: 1.25;
}

.tool-description {
  max-width: 60ch;
  margin: 8px 0 0;
  color: var(--muted);
}

/* ---- mode switch ---- */

.modes {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.mode {
  padding: 8px 20px;
  color: var(--muted);
  background: var(--paper);
  border: 1px solid var(--line);
  cursor: pointer;
}

.mode + .mode {
  border-left-width: 0;
}

.mode:hover {
  color: var(--ink);
}

.mode.is-active {
  color: var(--paper);
  background: var(--accent);
  border-color: var(--accent);
}

/* ---- layout ---- */

.layout {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 16px;
}

.panel {
  padding: 16px;
  border: 1px solid var(--line);
}

.wheelcol {
  flex: 0 0 auto;
  width: 232px;
}

.boxcol {
  display: flex;
  min-width: 0;
  flex: 1 1 420px;
  flex-direction: column;
  gap: 16px;
}

/* ---- wheel ---- */

.split {
  display: flex;
  justify-content: space-between;
  margin: 0 0 10px;
  color: var(--faint);
}

.split .f { color: var(--flat); }
.split .s { color: var(--sharp); }

.wheelwrap {
  position: relative;
}

/* the selected row sits in a bracketed band, the same [ ] the theme uses for
   the current nav item and a status badge */
.band {
  position: absolute;
  top: 50%;
  right: -4px;
  left: -4px;
  height: 44px;
  border: 1px solid var(--line);
  transform: translateY(-50%);
}

.axis {
  position: absolute;
  top: 8px;
  bottom: 8px;
  left: 50%;
  width: 1px;
  background: var(--line);
}

.wheel {
  position: relative;
  height: 396px;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.wheel.dragging {
  cursor: grabbing;
}

.wheelinner {
  position: absolute;
  top: 50%;
  right: 0;
  left: 0;
  -webkit-user-drag: none;
}

.wheelinner.animate {
  transition: transform 0.2s cubic-bezier(0.22, 0.75, 0.3, 1);
}

.row {
  display: flex;
  height: 44px;
  align-items: center;
  cursor: pointer;
  opacity: 0.34;
  transition: opacity 0.12s;
}

.row:hover { opacity: 0.62; }
.row.sel { opacity: 1; }

.row .half {
  display: flex;
  width: 50%;
  align-items: center;
  font-family: var(--sym);
  font-size: 20px;
  letter-spacing: 2px;
  line-height: 1;
}

.row .half.flats {
  justify-content: flex-end;
  padding-right: 7px;
  color: var(--flat);
}

.row .half.sharps {
  justify-content: flex-start;
  padding-left: 7px;
  color: var(--sharp);
}

.row.sel .half {
  font-size: 23px;
}

.row .zero {
  width: 100%;
  color: var(--faint);
  text-align: center;
}

.hint {
  margin: 12px 0 0;
  color: var(--faint);
  text-align: center;
}

/* ---- the seven letters ---- */

.boxes {
  display: grid;
  overflow-x: auto;
  grid-template-columns: repeat(7, minmax(72px, 1fr));
  gap: 8px;
}

.box {
  display: grid;
  justify-content: center;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  column-gap: 8px;
  grid-template-columns: auto auto;
  row-gap: 6px;
  user-select: none;             /* dragging a dial must not select its glyphs */
  -webkit-user-select: none;
}

.box .tag {
  color: var(--faint);
  grid-column: 1 / -1;
  justify-self: center;
}

.box.key {
  border-color: var(--accent);
}

.box.key .tag {
  color: var(--accent);
}

.box .letter {
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
  text-align: center;
}

/* Graded: the border and the degree label carry the verdict. A filled cell
   would tint the accidental sitting inside it, which is the one thing on the
   card whose colour means something. */
.box.good { border-color: var(--accent); }
.box.bad { border-color: var(--link); }
.box.good .tag { color: var(--accent); }
.box.bad .tag { color: var(--link); }

/* the per-letter dial: a three-position wheel, all three glyphs reachable */
.dial {
  position: relative;
  width: 34px;
  height: 78px;
  overflow: hidden;
  border: 1px solid var(--line);
  cursor: ns-resize;
  touch-action: none;
}

.dtrack {
  position: absolute;
  inset: 0 0 auto 0;
  transition: transform 0.15s cubic-bezier(0.33, 1.3, 0.5, 1);
}

.dopt {
  display: flex;
  height: 34px;
  align-items: center;
  justify-content: center;
  color: var(--faint);
  font-family: var(--sym);
  font-size: 20px;
  opacity: 0.5;
  transition: opacity 0.15s, color 0.15s, font-size 0.15s;
}

/* the middle slot is deliberately empty, so hover is its only affordance */
.dopt:hover {
  color: var(--ink);
  opacity: 1;
}

.dial[data-v="1"] .dopt[data-v="1"],
.dial[data-v="-1"] .dopt[data-v="-1"] {
  font-size: 25px;
  opacity: 1;
}

.dial[data-v="1"] .dopt[data-v="1"] { color: var(--sharp); }
.dial[data-v="-1"] .dopt[data-v="-1"] { color: var(--flat); }

/* ---- staff ---- */

.panel-staff {
  padding: 10px 0;          /* no side padding: the staff lines run edge to edge */
  overflow-x: auto;
}

.staff svg {
  display: block;
  max-width: 100%;
  height: auto;
}

/* the clef, sharps and flats are drawn as text, so they need the symbol stack
   the same way the wheel and the dials do */
.staff text {
  font-family: var(--sym);
}

/* ---- check ---- */

.bar {
  display: flex;
  min-height: 34px;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
}

.btn {
  padding: 4px 16px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  cursor: pointer;
}

.btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

body.learn .bar {
  display: none;
}

.verdict {
  margin: 0;
  color: var(--muted);
}

.verdict.ok { color: var(--accent); }
.verdict.no { color: var(--link); }

@media (max-width: 760px) {
  .wheelcol {
    width: 100%;
    max-width: 232px;
    margin-inline: auto;
  }

  .boxcol {
    flex-basis: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
  }
}
