/* =========================================
   tunerstyle.css
   Builds on shared/global.css
   ========================================= */

/* ── Full-height layout (no scroll) ── */
html, body { height: 100%; overflow: hidden; }

.tuner-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  touch-action: none;
}

/* ── Game title ── */
.gameMainTitle {
  text-align: center;
  font-size: 26px;
  font-weight: 900;
  color: var(--text-main);
  margin: 0;
  padding-top: 4px;
  padding-bottom: 0;
  line-height: 1;
  flex-shrink: 0;
}

/* ── Controls panel ── */
.controlsPanel {
  background: var(--bg-surface);
  border: 2px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-soft);
  flex-shrink: 0;
}
body.light-theme .controlsPanel { border-color: rgba(0,0,0,0.06); }

.actionsGrid {
  display: flex;
  gap: 8px;
  width: 100%;
}
.actionsGrid .icon-btn      { flex: 0 0 52px; height: 52px; padding: 0; font-size: 22px; }
.actionsGrid .flex-text-btn { flex: 1 1 0; padding: 0 4px; font-size: 14px; white-space: nowrap; }


/* ── Stacked layout ── */
.tuner-stack {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 0 0 4px;
}

/* ── Shared tile base ── */
.tuner-tile {
  background: var(--bg-surface);
  border: 2px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  transition: border-color 0.3s;
}
body.light-theme .tuner-tile { border-color: rgba(0,0,0,0.06); }

/* In-tune glow */
.tuner-tile.in-tune {
  border-color: var(--info-teal);
  box-shadow: var(--shadow-soft), 0 0 18px rgba(12, 188, 103, 0.35);
}

/* ── Animation tile ── */
.tuner-anim-tile {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: row;
}

/* Left: Chladni canvas */
.tuner-canvas-area {
  flex: 1 1 0;
  min-width: 0;
  position: relative;
}

#chladni-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
}

/* Right: note info panel */
.tuner-note-panel {
  flex: 0 0 38%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 12px 10px;
  border-left: 2px solid rgba(255,255,255,0.07);
  gap: 6px;
}
body.light-theme .tuner-note-panel { border-left-color: rgba(0,0,0,0.07); }

.tuner-note-name {
  font-size: clamp(2.8rem, 10vw, 4rem);
  font-weight: 900;
  color: var(--text-main);
  line-height: 1;
  text-align: center;
  transition: color 0.25s;
}

.tuner-note-name.in-tune {
  color: var(--info-teal);
}

.tuner-note-enharmonic {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
  min-height: 1.1em;
  line-height: 1.1;
}

/* Flat/sharp indicator dot track */
.tuner-pitch-dot-track {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 3px;
  align-items: stretch;
  margin-top: 2px;
}

.tuner-pitch-dot-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0 2px;
}

.tuner-pitch-dot-bar {
  position: relative;
  height: 8px;
  background: var(--bg-elevated);
  border-radius: 4px;
  overflow: visible;
}

.tuner-pitch-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: left 0.12s ease-out, background 0.25s;
  box-shadow: 0 0 6px rgba(0,0,0,0.4);
}

.tuner-pitch-dot.in-tune {
  background: var(--info-teal);
  box-shadow: 0 0 8px rgba(12,188,103,0.6);
}

/* A=440 reference button */
.tuner-ref-btn {
  background: var(--bg-elevated);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  padding: 6px 10px;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  line-height: 1.2;
  margin-top: 4px;
  width: 100%;
}
.tuner-ref-btn:hover {
  background: var(--bg-base);
  border-color: var(--accent);
  color: var(--text-main);
}
body.light-theme .tuner-ref-btn { border-color: rgba(0,0,0,0.1); }

/* ── Cents meter tile ── */
.tuner-meter-tile {
  flex: 0 0 auto;
  padding: 10px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.tuner-meter-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tuner-meter-label {
  font-size: 10px;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.tuner-meter-label-center {
  font-size: 13px;
  font-weight: 900;
  color: var(--text-main);
  letter-spacing: 1px;
  transition: color 0.25s;
}

.tuner-meter-label-center.in-tune {
  color: var(--info-teal);
}

/* Meter track: canvas background + dot overlay */
.tuner-meter-track {
  position: relative;
  height: 32px;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

#meter-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
}

.tuner-meter-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 8px rgba(255,255,255,0.6);
  transition: left 0.12s ease-out, background 0.25s, box-shadow 0.25s;
  pointer-events: none;
}

.tuner-meter-dot.in-tune {
  background: var(--info-teal);
  box-shadow: 0 0 12px rgba(12,188,103,0.7);
}

/* ── Settings modal ── */
.tuner-settings-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 4px;
}

.tuner-setting-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.tuner-setting-info {
  flex: 1;
  min-width: 0;
}

.tuner-setting-name {
  display: block;
  font-size: 14px;
  font-weight: 800;
  color: var(--text-main);
}

.tuner-setting-desc {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.4;
}

.tuner-ref-input-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.tuner-ref-input {
  width: 64px;
  background: var(--bg-base);
  border: 2px solid var(--bg-elevated);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 15px;
  font-weight: 800;
  text-align: center;
  padding: 6px 4px;
  outline: none;
  -moz-appearance: textfield;
}
.tuner-ref-input::-webkit-outer-spin-button,
.tuner-ref-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.tuner-ref-input:focus {
  border-color: var(--accent);
}

.tuner-ref-unit {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

/* ── Info modal ── */
.tuner-info-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 4px;
}

.tuner-info-body p {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.55;
}

.tuner-info-body strong {
  color: var(--text-main);
  font-weight: 800;
}

/* ── Tone generator ── */
.tone-gen {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
body.light-theme .tone-gen { border-top-color: rgba(0,0,0,0.08); }

.tone-toggle-btn {
  width: 100%;
  background: var(--bg-elevated);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 800;
  padding: 6px 8px;
  cursor: pointer;
  text-align: center;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  letter-spacing: 0.3px;
}
.tone-toggle-btn.tone-on {
  background: var(--info-teal);
  border-color: var(--info-shadow);
  color: #fff;
}

.tone-freq-row {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 3px;
}

.tone-freq-val {
  font-size: 1.15rem;
  font-weight: 900;
  color: var(--text-main);
  cursor: ew-resize;
  border-bottom: 1px dashed rgba(255,255,255,0.25);
  padding-bottom: 1px;
  transition: color 0.15s;
  min-width: 2ch;
  text-align: right;
}
.tone-freq-val:hover { color: var(--accent); border-bottom-color: var(--accent); }
body.light-theme .tone-freq-val { border-bottom-color: rgba(0,0,0,0.2); }

.tone-freq-unit {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-muted);
}

.tone-freq-edit {
  width: 100%;
  background: var(--bg-base);
  border: 2px solid var(--accent);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 1rem;
  font-weight: 800;
  text-align: center;
  padding: 4px 2px;
  outline: none;
  display: none;
  -moz-appearance: textfield;
}
.tone-freq-edit::-webkit-outer-spin-button,
.tone-freq-edit::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Logarithmic range slider */
.tone-slider {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-elevated);
  outline: none;
  cursor: pointer;
}
.tone-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid rgba(255,255,255,0.2);
  transition: background 0.15s;
}
.tone-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid rgba(255,255,255,0.2);
}

/* ── Reference pitch modal ── */
.ref-pitch-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 10px 0 6px;
}

.ref-pitch-display {
  font-size: 1.9rem;
  font-weight: 900;
  color: var(--text-main);
  letter-spacing: 1px;
}

.ref-pitch-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ref-step-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  font-size: 18px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.ref-modal-num {
  width: 80px;
  font-size: 1.3rem !important;
  padding: 8px 4px !important;
}

.ref-pitch-range-hint {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
}
