/* 音准读数组件（ears.css）
 * ----------------------------------------------------------------------------
 * 音准页与首页练习共用的同一份外观：大唱名 / 指针条 / 刻度 / 轨迹 / 小结。
 * 色板严格走 UI-SPEC.md，不引入第二套配色。
 * 页面壳（模式切换、麦克风按钮、页脚、琴头图）留在各自页面的 CSS 里。 */

/* ---------- 表头：大唱名 + 音名 ---------- */
.tn-stage {
  --trace-h: 150px;          /* 轨迹画布高度；左侧刻度 = 这个值 − 16px 电平带 */
  padding: 18px 4px 6px;
  text-align: center;
}

.tn-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-height: 56px;
}

.tn-step {
  font: 700 11px/1 var(--mono);
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* 大唱名：拉琴时先看这个，颜色跟着音准状态走 */
.tn-solfege {
  font: 700 clamp(44px, 7vw, 64px)/1 Georgia, serif;
  color: var(--ink);
  letter-spacing: -.02em;
  transition: color .15s ease;
}

.tn-solfege.is-good { color: var(--good); }
.tn-solfege.is-warm { color: var(--warm); }
.tn-solfege.is-bad { color: var(--danger, #b91c1c); }
.tn-solfege.is-idle { color: #c9c3b6; }

.tn-note {
  font: 500 13px/1.2 var(--mono);
  color: var(--muted);
  letter-spacing: .02em;
}

/* ---------- 指针条 ---------- */
.tn-gauge {
  margin: 16px auto 0;
  max-width: 620px;
}

/* 指针两端的相邻半音音名 */
.tn-edges {
  display: flex;
  justify-content: space-between;
  font: 500 11px/1 var(--mono);
  color: #9a9384;
  padding: 0 2px 4px;
}

/* 刻度尺：每 10 音分一根，0 那根加长加深 */
.tn-ruler {
  position: relative;
  height: 9px;
}

.tn-ruler i {
  position: absolute;
  bottom: 0;
  width: 1px;
  height: 5px;
  margin-left: -0.5px;
  background: rgba(30, 36, 51, .22);
}

.tn-ruler i.is-mid {
  height: 9px;
  background: rgba(30, 36, 51, .5);
}

.tn-track {
  position: relative;
  height: 16px;
  border-radius: 999px;
  background: #f1eee6;
  border: 1px solid var(--line);
}

.tn-zone {
  position: absolute;
  /* 默认 ±10（练习）；调音器模式下 JS 把这两个变量改成 ±5 的宽度 */
  left: var(--zone-left, 40%);
  width: var(--zone-w, 20%);
  top: 0;
  bottom: 0;
  background: rgba(15, 118, 110, .22);
  border-radius: 3px;
}

.tn-zero {
  position: absolute;
  left: 50%;
  top: -3px;
  bottom: -3px;
  width: 1px;
  background: rgba(30, 36, 51, .3);
}

.tn-needle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 5px;
  height: 30px;
  margin-left: -2.5px;
  transform: translateY(-50%);
  border-radius: 3px;
  background: var(--accent);
  box-shadow: 0 2px 8px rgba(79, 70, 229, .35);
  transition: left .07s linear, background .15s ease;
}

.tn-needle.is-off {
  background: #c9c3b6;
  box-shadow: none;
  opacity: .55;
}

.tn-track[data-state="good"] .tn-needle { background: var(--good); box-shadow: 0 2px 8px rgba(15, 118, 110, .35); }
.tn-track[data-state="warm"] .tn-needle { background: var(--warm); box-shadow: 0 2px 8px rgba(180, 83, 9, .3); }
.tn-track[data-state="bad"] .tn-needle { background: var(--danger, #b91c1c); box-shadow: 0 2px 8px rgba(185, 28, 28, .3); }

/* 刻度数字：按百分比定位，和刻度线严格对齐 */
.tn-scale {
  position: relative;
  height: 14px;
  margin-top: 5px;
  font: 500 10px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  color: #9a9384;
}

.tn-scale span {
  position: absolute;
  transform: translateX(-50%);
}

.tn-scale span.is-mid {
  color: var(--ink);
  font-weight: 700;
}

.tn-sides {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  padding: 6px 2px 0;
}

/* ---------- 读数 ---------- */
.tn-readout {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 12px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.tn-cents {
  font: 700 30px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  min-width: 120px;
  text-align: right;
}

.tn-verdict {
  font-size: 14px;
  font-weight: 700;
}

.tn-verdict.is-good { color: var(--good); }
.tn-verdict.is-warm { color: var(--warm); }
.tn-verdict.is-bad { color: var(--danger, #b91c1c); }
.tn-verdict.is-idle { color: var(--muted); font-weight: 600; }

.tn-hint {
  margin: 10px auto 0;
  max-width: 520px;
  padding: 8px 12px;
  border-radius: 10px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: var(--warm);
  font-size: 13px;
}

/* ---------- 轨迹 ---------- */
.tn-tracewrap {
  margin: 16px 0 0;
  position: relative;
}

.tn-chart {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

/* 高度 = 画布高度 − 底部电平带 16px，刻度标签才和网格对齐 */
.tn-axis {
  position: relative;
  flex: 0 0 26px;
  height: calc(var(--trace-h) - 16px);
  font: 500 9px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  color: #9a9384;
}

.tn-axis span {
  position: absolute;
  right: 0;
  transform: translateY(-50%);
}

.tn-axis span.is-mid {
  color: var(--ink);
  font-weight: 700;
}

.tn-trace {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  height: var(--trace-h);
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffdf8;
}

.tn-tracewrap figcaption {
  margin-top: 5px;
  font-size: 11px;
  color: #9a9384;
  text-align: center;
}

/* ---------- 小结 ---------- */
.tn-summary {
  margin: 18px auto 0;
  max-width: 520px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  padding: 14px 16px;
}

.tn-summary h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

.tn-badge {
  display: inline-block;
  margin: 0 0 8px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #ecfdf5;
  color: var(--good);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .04em;
}

.tn-stat {
  margin: 3px 0;
  font-size: 13px;
  color: var(--ink);
}

.tn-tend {
  margin: 6px 0 0;
  font-size: 13px;
  font-weight: 650;
  color: var(--accent);
}

.tn-sub {
  margin: 12px 0 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
}

.tn-worst {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.tn-worst li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 13px;
}

.tn-worst li b {
  font-family: var(--mono);
  color: var(--warm);
}

.tn-summary-acts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.tn-again {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  border-radius: 9px;
  padding: 8px 14px;
  font: 700 12px/1 inherit;
  cursor: pointer;
}

.tn-again:hover {
  background: var(--accent-soft);
  border-color: #c7d2fe;
  color: var(--accent);
}

/* ---------- 紧凑档（首页卡片内嵌时用，少占高度） ---------- */
.tn-stage.is-compact {
  --trace-h: 120px;
  padding: 12px 2px 2px;
}

.tn-stage.is-compact .tn-head { min-height: 44px; }
.tn-stage.is-compact .tn-solfege { font-size: clamp(34px, 5vw, 46px); }
.tn-stage.is-compact .tn-gauge { margin-top: 12px; }
.tn-stage.is-compact .tn-readout { margin-top: 12px; }
.tn-stage.is-compact .tn-cents { font-size: 24px; min-width: 96px; }

@media (max-width: 640px) {
  .tn-stage { --trace-h: 120px; }
  .tn-stage.is-compact { --trace-h: 104px; }
  .tn-cents { font-size: 26px; min-width: 96px; }
  .tn-scale { font-size: 9px; }
}

@media print {
  .tn-stage { display: none !important; }
}

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