/* Game-specific styles for namechordroot. */

/* =========================================================
   this file
   Local styles for the "Name The Chord" games (root position +
   all inversions). Builds on top of shared/global.css.
   ========================================================= */

/* ───────────────────────────────────────────────────────────
   EDITABLE SIZE LIMITS  (maximum image heights - change freely)
   ─────────────────────────────────────────────────────────── */
:root {
  --intro-kb-max-height:        110px;  /* piano image in BOTH intro (welcome) modals */
  --game-kb-max-height:         100px;  /* the main question chord image while playing */
  --help-compare-kb-max-height:  90px;  /* the 3 stacked diagrams in "The Three Positions Compared" (inversions help) */
  --help-anim-max-height:       100px;  /* the animated keyboards in the help modals (build-the-chord and inversion animations) */
  --help-stack-max-height:      420px;  /* the C Major scale-notes diagram at the bottom of the inversions help */
}

:root {
  --chordTone: #0cbc67;
  --scaleTone: #3b82f6;

  --sel-root:        #4086f6;
  --sel-root-shadow: #245cb0;
  --sel-qual:        #7c3aed;
  --sel-qual-shadow: #5b21b6;
  --sel-pos:         #f59e0b;
  --sel-pos-shadow:  #b45309;
}

/* ─── Titles ─── */
.gameMainTitle {
  text-align: center;
  font-size: calc(21px * var(--font-scale));
  font-weight: 900;
  color: var(--text-main);
  margin: 0;
  padding: 0 12px;
  line-height: 1.25;
}
.modalGameTitle {
  text-align: center;
  font-size: calc(19px * var(--font-scale));
  font-weight: 900;
  margin-bottom: 10px;
  letter-spacing: 0.3px;
  line-height: 1.25;
}

/* ─── Panels ─── */
.controlsPanel,
.analysisCard {
  background: var(--bg-surface);
  border: 2px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 10px;
  padding-bottom: 14px;
  box-shadow: var(--shadow-soft);
}
body.light-theme .controlsPanel,
body.light-theme .analysisCard { border-color: rgba(0, 0, 0, 0.06); }

.statusPanel { border-radius: var(--radius-md); box-shadow: var(--shadow-soft); }
.statusRow { display: flex; flex-direction: column; align-items: center; }
.statusText {
  text-align: center;
  width: 100%;
  background: var(--bg-base);
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 2px solid rgba(255, 255, 255, 0.05);
  min-height: calc(64px * var(--font-scale));
}
body.light-theme .statusText { border-color: rgba(0, 0, 0, 0.05); }
.phaseTitle { font-size: calc(18px * var(--font-scale)); font-weight: 900; color: var(--text-main); }
.feedbackLine { font-size: calc(15px * var(--font-scale)); color: var(--text-muted); min-height: 22px; font-weight: 500; line-height: 1.5; }
.feedbackLine strong { color: #fff; font-weight: 800; background: var(--accent); padding: 2px 6px; border-radius: 6px; }

/* ─── Control rows ─── */
.actionsGrid { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; width: 100%; }
.actionsGrid .btn { flex: 1 1 calc(120px * var(--control-scale)); height: auto; min-height: calc(52px * var(--control-scale)); padding: 4px 6px; font-size: calc(17px * var(--font-scale)); line-height: 1.15; text-align: center; }
.mainActionRow { display: flex; flex-wrap: wrap; gap: 6px; }
.mainActionRow .btn { flex: 1 1 calc(96px * var(--control-scale)); height: auto; min-height: calc(56px * var(--control-scale)); padding: 4px 6px; font-size: calc(17px * var(--font-scale)); line-height: 1.15; text-align: center; }
.mainActionRow { flex-wrap: nowrap; }
.mainActionRow #beginBtn { flex-grow: 1.3; }
.mainActionRow .iconBtn { flex: 0 0 calc(60px * var(--control-scale)); min-width: 0; font-size: calc(24px * var(--font-scale)); }

.btn:disabled { opacity: 0.38; cursor: not-allowed; transform: none !important; }
.btn-pink { background: #f472b6; color: #fff; border: 2px solid #db2777; box-shadow: 0 4px 0 #db2777; }
.default-btn { background: var(--bg-elevated); color: var(--text-main); border: 2px solid transparent; box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25); }
body.light-theme .default-btn { box-shadow: 0 4px 0 #cbd5e1; }
.secondary-btn { background: var(--bg-elevated); color: var(--text-main); border: 2px solid var(--bg-elevated); box-shadow: 0 4px 0 var(--bg-elevated); font-size: calc(15px * var(--font-scale)); }
.secondary-btn:active:not(:disabled) { box-shadow: 0 0 0 var(--bg-elevated); transform: translateY(4px); }

/* Submit / Next: grey until ready, then orange + pulsing */
.submit-btn { background: var(--bg-base); color: var(--text-main); border: 2px solid var(--bg-elevated); box-shadow: 0 4px 0 var(--bg-elevated); }
.submit-btn:disabled { opacity: 0.45; }
.submitReady {
  background: var(--next-orange) !important; color: #fff !important;
  border-color: var(--next-shadow) !important; box-shadow: 0 4px 0 var(--next-shadow) !important;
  --ringColor: rgba(255, 127, 42, 0.4);
  animation: ringPulse 1.5s ease-in-out infinite;
}
.submitReady:active:not(:disabled) { box-shadow: 0 0 0 var(--next-shadow) !important; transform: translateY(4px); }
#hearBtn.pulse { --ringColor: rgba(244, 114, 182, 0.4); }

/* ─── Chord display ─── */
.keyboardSection { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.miniLegend { display: flex; gap: 18px; align-items: center; font-size: calc(12px * var(--font-scale)); font-weight: 800; color: var(--text-muted); user-select: none; }
.legendDot { width: 10px; height: 10px; border-radius: 999px; display: inline-block; margin-right: 5px; border: 1px solid rgba(0, 0, 0, 0.15); background: var(--chordTone); }
.mount { overflow: hidden; width: 100%; }
.mount svg { display: block; margin: 0 auto; width: 100%; height: auto; }
.miniMount {
  min-height: calc(var(--game-kb-max-height) + 32px); display: flex; align-items: center; justify-content: center; width: 100%;
  background: var(--bg-base); border-radius: var(--radius-md); border: 2px solid var(--bg-elevated); padding: 14px;
}
.miniMount svg { max-height: var(--game-kb-max-height); }
.kbRow { display: flex; align-items: center; justify-content: center; gap: 12px; width: fit-content; max-width: 100%; margin: 0 auto; }
.kbHost { flex: 0 1 auto; min-width: 0; }
.kbHost svg { width: auto; height: var(--game-kb-max-height); max-width: 100%; margin: 0; }
.playChordBtn { flex: 0 0 auto; text-align: center; white-space: nowrap; height: auto; min-height: calc(40px * var(--control-scale)); padding: 4px 10px; font-size: calc(14px * var(--font-scale)); line-height: 1.15; }
.miniMount.twoUp { flex-direction: column; gap: 12px; }
.resKb { width: 100%; text-align: center; }
.resLabel { margin: 0 0 4px; font-size: calc(13px * var(--font-scale)); font-weight: 800; color: var(--text-main); }
.legendDot.red { background: #ef4444; }
.kbPlaceholder { font-size: calc(13px * var(--font-scale)); color: var(--text-muted); text-align: center; }

/* ─── Selection boxes (look like text boxes, open a drop-down) ─── */
.answerPanel { padding: 0; background: transparent; border: none; box-shadow: none; }
.selGrid { display: grid; grid-template-columns: repeat(var(--sel-cols, 2), minmax(0, 1fr)); gap: 10px; align-items: stretch; }
@media (max-width: 520px) { .selGrid { grid-template-columns: minmax(0, 1fr); } }
.selBtn {
  appearance: none; -webkit-appearance: none;
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; text-align: left; cursor: pointer; user-select: none;
  min-height: calc(50px * var(--control-scale)); height: auto; padding: 6px 14px;
  font-family: var(--font-main); font-size: calc(15px * var(--font-scale)); font-weight: 700;
  background: var(--bg-base); color: var(--text-main); border: 2px solid var(--bg-elevated); border-radius: var(--radius-sm);
  box-shadow: 0 4px 0 var(--bg-elevated);
}
.selBtn:hover:not(:disabled), .selBtn[aria-expanded="true"], .selBtn:focus-visible { border-color: var(--accent); outline: none; }
.selK { font-weight: 800; color: var(--text-muted); }
.selV { font-weight: 800; color: var(--text-main); }
.selV.ph { font-weight: 600; color: var(--text-muted); }
.selAns { font-size: calc(12px * var(--font-scale)); font-weight: 800; opacity: 0.95; }
.selBtn:disabled { opacity: 0.45; cursor: default; }
.selBtn.answer-correct, .selBtn.answer-correct:disabled { background: var(--info-teal); border-color: var(--info-shadow); opacity: 1; cursor: default; }
.selBtn.answer-incorrect, .selBtn.answer-incorrect:disabled { background: var(--danger); border-color: var(--danger-shadow); opacity: 1; cursor: default; }
.selBtn.answer-correct .selK, .selBtn.answer-correct .selV, .selBtn.answer-incorrect .selK, .selBtn.answer-incorrect .selV, .selBtn.answer-correct .selAns, .selBtn.answer-incorrect .selAns { color: #fff; }

/* ─── Drop-down menus + Major / Minor buttons ─── */
.ddWrap { position: relative; display: flex; flex-direction: column; }
.ddWrap > .selBtn { width: 100%; flex: 1 1 auto; padding-right: 34px; position: relative; }
.ddWrap > .selBtn::after { content: "▾"; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: calc(14px * var(--font-scale)); opacity: 0.7; }
.ddWrap > .selBtn:disabled::after, .ddWrap > .selBtn.answer-correct::after, .ddWrap > .selBtn.answer-incorrect::after { content: none; }
.ddMenu {
  position: absolute; top: calc(100% + 8px); left: 0; z-index: 60;
  width: max-content; max-width: calc(100vw - 16px);
  display: grid; grid-template-columns: repeat(var(--dd-cols, 4), auto); gap: 6px; padding: 8px;
  background: var(--bg-surface); border: 2px solid var(--bg-elevated); border-radius: var(--radius-sm);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
}
.ddOpt {
  min-width: calc(46px * var(--control-scale)); min-height: calc(40px * var(--control-scale)); padding: 4px 10px;
  font-family: var(--font-main); font-size: calc(16px * var(--font-scale)); font-weight: 900; white-space: nowrap;
  background: var(--bg-base); color: var(--text-main); border: 2px solid var(--bg-elevated); border-radius: 8px; cursor: pointer;
}
.ddOpt:hover, .ddOpt:focus-visible { border-color: var(--accent); outline: none; }
.ddOpt.chosen { background: var(--accent); color: #fff; border-color: var(--accent); }

.selGroup { display: flex; flex-direction: column; gap: 4px; }
.selGroup > .selK { text-align: center; color: var(--text-muted); }
.tonPair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; flex: 1 1 auto; }
.tonBtn {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: calc(88px * var(--control-scale)); height: auto; padding: 8px 6px;
  font-family: var(--font-main); font-size: calc(21px * var(--font-scale)); font-weight: 900; color: #fff;
  border-radius: var(--radius-sm); cursor: pointer; user-select: none;
  transition: filter 0.18s, opacity 0.18s;
}
.tonMajor { background: #eab308; border: 2px solid #ca8a04; box-shadow: 0 4px 0 #ca8a04; }
.tonMinor { background: #7e22ce; border: 2px solid #581c87; box-shadow: 0 4px 0 #581c87; }
/* desaturated until chosen; choosing one desaturates the other again */
.tonBtn:not(.on):not(.answer-correct):not(.answer-incorrect) { filter: saturate(0.12) brightness(0.8); }
.tonBtn:disabled:not(.answer-correct):not(.answer-incorrect) { opacity: 0.38; cursor: default; }
.tonBtn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 0 0 transparent; }
.tonBtn.answer-correct, .tonBtn.answer-correct:disabled { background: var(--info-teal) !important; border-color: var(--info-shadow) !important; box-shadow: 0 4px 0 var(--info-shadow) !important; opacity: 1 !important; filter: none !important; cursor: default; }
.tonBtn.answer-incorrect, .tonBtn.answer-incorrect:disabled { background: var(--danger) !important; border-color: var(--danger-shadow) !important; box-shadow: 0 4px 0 var(--danger-shadow) !important; opacity: 1 !important; filter: none !important; cursor: default; }

/* Root-position game: root note + Major + Minor are three equal, centred buttons */
.selGrid.rootLayout { display: flex; flex-wrap: wrap; justify-content: center; align-items: stretch; gap: 10px; }
.selGrid.rootLayout > .ddWrap { flex: 1 1 100%; align-items: center; }
.selGrid.rootLayout > .ddWrap > .selBtn { max-width: calc(360px * var(--control-scale)); }
.selGrid.rootLayout .tonBtn { flex: 1 1 calc(100px * var(--control-scale)); max-width: calc(170px * var(--control-scale)); }
.selGrid.rootLayout .selGroup, .selGrid.rootLayout .tonPair { display: contents; }

/* ─── Score card ─── */
.analysis { padding: 0; background: transparent; border: none; box-shadow: none; }
.analysisGrid { display: grid; gap: 10px; }
.scoreCardNarrow { max-width: 100%; }
.inside-modal { background: transparent; border: none; box-shadow: none; padding: 0; }
.analysisLabel { font-size: calc(18px * var(--font-scale)); font-weight: 900; color: var(--text-main); margin-bottom: 4px; text-align: center; }
.scoreMeta { text-align: center; font-size: calc(14px * var(--font-scale)); font-weight: 700; color: var(--text-muted); margin-bottom: 12px; }
.scoreActions { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.scoreGrid { display: grid; gap: 8px; }
.scoreGridVertical { grid-template-columns: 1fr; }
.scoreItem { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: var(--bg-base); border-radius: var(--radius-sm); border: 2px solid var(--bg-elevated); }
.scoreK { font-size: calc(13px * var(--font-scale)); font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.scoreV { font-size: calc(20px * var(--font-scale)); font-weight: 900; }
.text-correct { color: var(--info-teal); }
.text-incorrect { color: var(--danger); }
.text-accent { color: var(--accent); }
input:not([type="checkbox"]):not([type="radio"]) {
  width: 100%; height: calc(50px * var(--control-scale)); background: var(--bg-base); border: 2px solid var(--bg-elevated);
  color: var(--text-main); border-radius: var(--radius-sm); padding: 0 16px; font-family: var(--font-main);
  font-size: calc(15px * var(--font-scale)); font-weight: 700; outline: none; -webkit-appearance: none; box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}
input:focus { border-color: var(--accent); }

/* ─── Intro modal examples ─── */
.introFig { margin: 6px 0 14px; text-align: center; }
.introFig .introKb svg { display: block; margin: 0 auto; width: 100%; height: auto; max-height: var(--intro-kb-max-height); }
.introFig figcaption { margin-top: 6px; font-size: calc(13px * var(--font-scale)); font-weight: 700; color: var(--text-muted); }
#introModal .modalBody { text-align: left; }
#introModal .modalBody p { line-height: 1.55; }
.helpInlineLink, a.helpInlineLink { color: var(--accent, #4f8cff); font-weight: 700; text-decoration: underline; cursor: pointer; }

/* ─── Info / Help modal (shared look with Major Or Minor) ─── */
.modalCard.modalCard-info { max-width: 600px; }
#infoModal .modalBody { text-align: center; }
.helpHeading { font-size: calc(16px * var(--font-scale)); font-weight: 900; color: var(--text-main); margin: 20px 0 8px; line-height: 1.25; scroll-margin-top: 40px; }
.helpHeading:first-child { margin-top: 0; }
.helpFormula { font-weight: 600; color: var(--text-main); line-height: 1.5; }
.helpFormula em { color: var(--text-muted); font-weight: 600; }
.helpEq { font-weight: 900; color: var(--text-main); }
.helpQuote { font-style: italic; text-align: center; color: var(--text-main); font-weight: 700; }
.helpFig { margin: 4px 0 14px; text-align: center; }
.helpFig .helpKb svg { display: block; margin: 0 auto; width: 100%; height: auto; }
.helpFig figcaption { margin-top: 6px; font-size: calc(13px * var(--font-scale)); font-weight: 700; color: var(--text-muted); }
.helpFigRow { display: flex; gap: 12px; flex-wrap: wrap; }
.helpFigRow .helpFig { flex: 1 1 150px; min-width: 0; }
.helpPlayBtn {
  flex: 0 0 auto; height: auto; min-height: calc(36px * var(--control-scale)); padding: 4px 12px; font-size: calc(13px * var(--font-scale)); font-weight: 800;
  background: var(--bg-elevated); color: var(--text-main); border: 2px solid var(--bg-elevated);
  box-shadow: 0 3px 0 rgba(0,0,0,0.2); border-radius: var(--radius-sm); cursor: pointer;
}
.helpPlayBtn:active { transform: translateY(3px); box-shadow: 0 0 0 transparent; }
.helpFig > .helpPlayBtn { display: flex; align-items: center; justify-content: center; margin: 8px auto 0; }
.helpBtnRow { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 4px 0 12px; }
#infoModal .helpAnimKb, #infoModal .helpInvAnim { cursor: pointer; border-radius: 6px; }
#infoModal .helpAnimKb svg, #infoModal .helpInvAnim svg { display: block; margin: 0 auto; width: 100%; height: auto; max-height: var(--help-anim-max-height); }
#infoModal .helpAnimKb:focus-visible, #infoModal .helpInvAnim:focus-visible { outline: 2px solid var(--chordTone); outline-offset: 3px; }
#infoModal .helpFig .helpEq { margin: 0 0 8px; font-size: calc(14px * var(--font-scale)); }
#infoModal .helpAnimEq { margin: 0 0 8px; font-size: calc(14px * var(--font-scale)); font-weight: 500; color: var(--text-muted); line-height: 1.4; }
#infoModal .fSeg { display: inline-block; text-decoration: none; transition: color 0.12s; }
#infoModal .fSeg::before { content: attr(data-t); display: block; height: 0; overflow: hidden; visibility: hidden; font-weight: 900; }
#infoModal .fSeg.fOn { font-weight: 900; color: var(--text-main); text-decoration: underline; text-underline-offset: 3px; }
#infoModal .fSeg.fNote { min-width: 1em; text-align: center; }
#infoModal .fSeg.fBold { font-weight: 700; color: var(--text-main); }
#infoModal .eqInt { font-weight: 500; }
#infoModal .invCaption { margin: 0 0 8px; min-height: 2.9em; font-size: calc(14px * var(--font-scale)); font-weight: 700; color: var(--text-main); line-height: 1.4; }
#infoModal .legendRow { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; font-size: calc(13px * var(--font-scale)); font-weight: 800; color: var(--text-muted); margin: 6px 0 12px; }
#infoModal .legendRow .legendDot.blue { background: var(--scaleTone); }
#infoModal .stackFig svg { display: block; margin: 0 auto; width: 100%; height: auto; max-width: 520px; max-height: var(--help-stack-max-height); }

/* "The Three Positions Compared": one diagram per row, play button to the side */
#infoModal .cmpRow { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 0 0 14px; text-align: center; }
#infoModal .cmpMain { flex: 0 1 300px; min-width: 0; }
#infoModal .cmpLabel { margin: 0 0 4px; font-size: calc(13px * var(--font-scale)); font-weight: 800; color: var(--text-main); }
#infoModal .cmpKb { width: var(--cmp-w, 100%); margin: 0 auto; }
#infoModal .cmpKb svg { max-height: var(--help-compare-kb-max-height); }
#infoModal .cmpRow .playChordBtn { flex: 0 0 auto; }
.helpFig > .playChordBtn { display: flex; align-items: center; justify-content: center; margin: 8px auto 0; }
.helpKbRow { display: flex; align-items: center; justify-content: center; gap: 12px; }
.helpKbRow .helpKb { flex: 0 1 auto; min-width: 0; }

/* circles + note names used by the sliding inversion animation */
.inv-dot circle { fill: var(--chordTone); stroke: #fff; stroke-width: 1.4; }
.inv-dot text { font-family: Inter, Arial, sans-serif; font-size: 10px; font-weight: 900; fill: #fff; pointer-events: none; user-select: none; }
.inv-layer { pointer-events: none; }
.hintBox { text-align: left; background: var(--bg-surface); border: 2px solid var(--bg-elevated); border-radius: var(--radius-sm); padding: 10px 12px; }
.hintBox p { margin-bottom: 0 !important; }

/* ─── Keyboard SVG (used by the game display + all help diagrams) ─── */
.kb-w rect { fill: #fff; stroke: #333; stroke-width: 0.8; }
.kb-b rect { fill: #111; stroke: #000; stroke-width: 0.8; }
.kb-lbl { font-family: Inter, Arial, sans-serif; font-size: 10px; fill: rgba(0,0,0,0.5); font-weight: 800; user-select: none; pointer-events: none; }
.kb-lbl-b { font-size: 8px; fill: rgba(255,255,255,0.0); }
.kb-w rect, .kb-b rect { transition: fill var(--kbfade, 0.15s); }
.kb-on rect { fill: var(--chordTone); }
.kb-on .kb-lbl { fill: rgba(255,255,255,0.95); }
.kb-blue rect { fill: var(--scaleTone); }
.kb-red rect { fill: #ef4444; }
.kb-red .kb-lbl { fill: rgba(255,255,255,0.95); }
.kb-blue .kb-lbl { fill: rgba(255,255,255,0.95); }
.stk-title { font-family: Inter, Arial, sans-serif; font-size: 13px; font-weight: 800; fill: var(--text-main); }
.stk-sub { font-family: Inter, Arial, sans-serif; font-size: 10px; font-weight: 700; fill: var(--text-muted); }
