/* B# Music tools: loaded only on pages that carry a tool (see Tools.kt). Uses the tokens from site.css. */

.tool {
  margin: 1.4rem 0 2rem; padding: 1.2rem 1.2rem 1.1rem; border: 1px solid var(--line-strong); border-radius: 18px;
  background: linear-gradient(180deg, rgba(48, 36, 25, 0.75), rgba(16, 12, 9, 0.75));
  display: grid; gap: 0.9rem;
}
.tool-title { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 1.35rem; color: var(--ink); }
.tool-row { display: flex; flex-wrap: wrap; gap: 0.6rem 0.8rem; align-items: flex-end; }
.tool-field { display: grid; gap: 0.3rem; font-size: 0.85rem; color: var(--ink-muted); min-width: 0; }
.tool-field select, .tool-field input[type="number"] {
  font: inherit; font-size: 1rem; color: var(--ink); background: rgba(10, 8, 6, 0.8); border: 1px solid var(--line-strong);
  border-radius: 10px; padding: 0.5rem 0.7rem; min-height: 44px; max-width: 100%;
}
.tool-field input[type="number"] { width: 7.5rem; }
.tool-hint, .tool-small { margin: 0; color: var(--ink-muted); }
.tool-small { font-size: 0.85rem; }
.tool input[type="range"] { accent-color: var(--amber); min-height: 44px; }
.tool :focus-visible { outline: 2px solid var(--amber-strong); outline-offset: 2px; }

/* Note buttons: tuner strings and the tunings table */
.tuner-strings { display: grid; grid-template-columns: repeat(auto-fit, minmax(42px, 1fr)); gap: 0.4rem; }
.string-btn, .play-btn {
  font: inherit; color: var(--ink); cursor: pointer; border: 1px solid var(--line-strong); background: rgba(20, 15, 11, 0.7);
  border-radius: 12px; min-width: 48px; min-height: 48px; padding: 0.35rem 0.7rem; transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}
.string-btn { display: inline-flex; align-items: baseline; justify-content: center; gap: 1px; }
.sb-note { font-family: var(--serif); font-weight: 600; font-size: 1.35rem; }
.sb-oct { font-size: 0.7rem; color: var(--ink-muted); }
.string-btn:hover, .play-btn:hover { border-color: var(--amber); }
.string-btn.is-playing, .play-btn.is-playing, .chord.is-playing { background: rgba(224, 165, 74, 0.28); transform: scale(0.97); }
.string-btn.is-target { border-color: var(--amber-strong); box-shadow: 0 0 0 2px rgba(242, 185, 80, 0.35); }
.play-btn { min-height: 40px; font-size: 0.9rem; }
.tunings td:nth-child(2) { white-space: nowrap; font-weight: 600; letter-spacing: 0.04em; }

/* Tuner meter */
.tuner-meter { display: grid; justify-items: center; gap: 0.2rem; padding: 0.4rem 0; }
.tuner-dial {
  position: relative; width: min(260px, 100%); aspect-ratio: 2 / 1; overflow: hidden;
  border-radius: 260px 260px 0 0; border: 1px solid var(--line-strong); border-bottom: 0;
  background: radial-gradient(circle at 50% 100%, rgba(224, 165, 74, 0.12), transparent 70%),
    repeating-conic-gradient(from -90deg at 50% 100%, rgba(243, 234, 216, 0.28) 0 0.6deg, transparent 0.6deg 9deg);
}
.tuner-zero { position: absolute; left: 50%; top: 6px; width: 2px; height: 22%; margin-left: -1px; background: var(--amber-strong); }
.tuner-needle {
  position: absolute; left: 50%; bottom: 0; width: 3px; height: 88%; margin-left: -1.5px; border-radius: 2px;
  background: var(--ink); transform-origin: 50% 100%; transform: rotate(0deg); transition: transform 0.12s linear, background 0.2s ease;
}
.tuner-meter.in-tune .tuner-needle { background: #7fd18b; }
.tuner-note { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 2.3rem; line-height: 1.1; }
.tuner-cents { font-family: var(--sans); font-weight: 400; font-size: 0.95rem; color: var(--ink-muted); }
.tuner-meter.in-tune .tuner-cents { color: #7fd18b; }
.tuner-freq { margin: 0; color: var(--ink-muted); font-size: 0.9rem; text-align: center; min-height: 1.3em; }

/* Chord charts */
.chord-grid { list-style: none; margin: 1.2rem 0 2rem; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 0.7rem; }
.chord {
  width: 100%; height: 100%; font: inherit; color: var(--ink); cursor: pointer; display: grid; justify-items: center; gap: 0.25rem;
  padding: 0.8rem 0.5rem 0.7rem; border-radius: 14px; border: 1px solid var(--line); background: rgba(20, 15, 11, 0.6);
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease;
}
.chord:hover { border-color: var(--amber); }
.chord-svg { width: 100%; max-width: 130px; height: auto; }
.cs-nut { fill: var(--ink); }
.cs-fret { stroke: var(--line-strong); stroke-width: 1.2; }
.cs-string { stroke: var(--ink-muted); stroke-width: 1.2; }
.cs-dot { fill: var(--amber-strong); }
.cs-open { fill: none; stroke: var(--ink); stroke-width: 1.4; }
.cs-mark { fill: var(--ink-muted); font: 600 12px var(--sans); text-anchor: middle; }
.chord-name { font-family: var(--serif); font-weight: 600; font-size: 1.5rem; line-height: 1; }
.chord-notes { font-size: 0.78rem; color: var(--ink-muted); text-align: center; }

/* Metronome */
.metro-display { display: flex; align-items: baseline; justify-content: center; gap: 0.6rem; }
.metro-bpm { font-family: var(--serif); font-weight: 600; font-size: clamp(3rem, 12vw, 4.6rem); line-height: 1; font-variant-numeric: tabular-nums; }
.metro-unit { color: var(--ink-muted); font-size: 0.9rem; }
.metro-beats { display: flex; justify-content: center; gap: 0.6rem; min-height: 22px; }
.metro-dot { width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--line-strong); background: rgba(243, 234, 216, 0.08); transition: background 0.06s linear; }
.metro-dot.is-accent { width: 20px; height: 20px; margin-top: -2px; }
.metro-dot.is-on { background: var(--ink); }
.metro-dot.is-accent.is-on { background: var(--amber-strong); }
.metro-tempo { justify-content: center; align-items: center; }
.metro-tempo .metro-step { min-width: 56px; justify-content: center; }
.metro-range { order: -1; flex: 1 1 100%; min-width: 0; }

/* Synth */
.synth-panel { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 0.8rem; align-items: start; }
.synth-group { margin: 0; padding: 0.7rem 0.8rem 0.8rem; border: 1px solid var(--line); border-radius: 12px; display: grid; gap: 0.5rem; align-content: start; min-width: 0; }
.synth-group legend { padding: 0 0.3rem; font-size: 0.8rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--amber); }
.synth-knob input { width: 100%; }
.synth-val { color: var(--ink); font-variant-numeric: tabular-nums; }
.synth-env { width: 100%; height: 56px; }
.synth-env path { fill: rgba(224, 165, 74, 0.15); stroke: var(--amber-strong); stroke-width: 1.6; stroke-linejoin: round; }
.synth-keys { position: relative; display: flex; height: 150px; max-width: 100%; user-select: none; -webkit-user-select: none; touch-action: none; }
.synth-key {
  flex: 1 1 0; min-width: 0; position: relative; border: 1px solid #2a2017; border-radius: 0 0 8px 8px; cursor: pointer;
  background: linear-gradient(180deg, #f3ead8, #d9ccb2); color: #5b4a36; display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 0.4rem; font: 600 0.72rem var(--sans);
}
.synth-key.is-black {
  flex: 0 0 auto; width: 9%; margin: 0 -4.5%; z-index: 2; height: 62%; border-radius: 0 0 6px 6px;
  background: linear-gradient(180deg, #2a2119, #0f0b08); color: #cfc2a9; border-color: #000;
}
.synth-key.is-down { background: linear-gradient(180deg, #f2b950, #e0a54a); color: #17110b; }
.synth-key.is-black.is-down { background: linear-gradient(180deg, #8a6430, #5a3f1c); }

/* Size finder and lesson finder */
.size-result { margin: 0; font-size: 1.05rem; color: var(--ink); min-height: 1.5em; }
.finder-q { margin: 0; padding: 0; border: 0; display: grid; gap: 0.5rem; min-width: 0; }
.finder-q legend { padding: 0; margin-bottom: 0.4rem; font-weight: 600; color: var(--ink); }
.finder-opts { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.finder-opt { position: relative; }
.finder-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.finder-opt span {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0.4rem 0.9rem; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line-strong); background: rgba(20, 15, 11, 0.6); color: var(--ink); font-size: 0.92rem;
}
.finder-opt input:checked + span { background: var(--cream); color: var(--on-cream); border-color: var(--cream); }
.finder-opt input:focus-visible + span { outline: 2px solid var(--amber-strong); outline-offset: 2px; }
.finder-result:empty { display: none; }
.finder-result { display: grid; gap: 0.5rem; justify-items: start; padding-top: 0.4rem; border-top: 1px solid var(--line); }
.finder-result p { margin: 0; }
.finder-result ul { margin: 0; padding-left: 1.1rem; }
.finder-head { color: var(--ink-muted); font-size: 0.9rem; }

@media (prefers-reduced-motion: reduce) {
  .tuner-needle, .string-btn, .play-btn, .chord { transition: none; }
}
