/* /style.css
   Intervals game styling aligned to the shared Ear Training Lab template.
   (Matches button sizing, pulse, panels, analysis cards, modal, next button pulse.)
*/

:root{
  --page-bg:#ffffff;
  --text:#111;

  /* Pulse */
  --pulseRGBA: rgba(77,163,255,0.28);

  /* Reference playback */
  --refNoteFadeOut: 0.26s;

  /* Notes */
  --firstNote:#4da3ff;
  --secondNote:#34c759;

  /* Next */
  --nextOrange:#ff8a1f;
  --nextPulseRGBA: rgba(255,138,31,0.35);

  /* Layout */
  --text-max: 1000px;
  --analysis-max: 700px;
  --answers-max:700px; /* adjustable */
  
  --scaleBlue:#4da3ff;
  --scaleBlueRGBA: rgba(77,163,255,0.22);
}

*{box-sizing:border-box}

body{
  margin:0;
  font-family:Arial,Helvetica,sans-serif;
  background:var(--page-bg);
  color:var(--text);
}

.app{
  max-width:1260px;
  margin:8px auto;
  padding:16px;
}

.hero{text-align:center;margin:0px 0 12px}

/* Title images */
.app-titleWrap{
  display:flex;
  justify-content:center;
  align-items:center;
  margin:14px 0 6px;
}
.app-titleImg{
  height:auto;
  max-width: 100%; 
  display:block;
  user-select:none;
  -webkit-user-drag:none;
  padding-bottom: 10px;
}
.app-titleImgWide{ width: 100%; max-width: 700px; }
.app-titleImgWrapped{ width:min(220px, 55vw); }
.titleModeWide .app-titleImgWide{ display:block; }
.titleModeWide .app-titleImgWrapped{ display:none; }
.titleModeWrapped .app-titleImgWide{ display:none; }
.titleModeWrapped .app-titleImgWrapped{ display:block; }

.app-subtitle{
  margin:auto;
  max-width:1020px;
  font-size:15px;
  font-weight:400;
  opacity:.75;
  line-height:1.3;
}

.controlsPanel{
  background:#fff;
  border:1px solid rgba(0,0,0,.0);
  border-radius:16px;
  padding:0px;
}
.controlsPanelActions{margin-top:8px}

.hidden{display:none}

select{
  height:38px;
  width:auto;
  padding:0 10px;
  border-radius:12px;
  border:1px solid rgba(0,0,0,.2);
  background:#fff;
  cursor:pointer;
  font-weight:700;
  text-align: center;
}
.compactSelect{max-width:none; justify-content: center;}
.inlineControlRowAuto{min-width:unset;width:auto;}
.compactSelectAuto{ width:auto; max-width:none; inline-size:auto; justify-content: center;}

button{
  height:38px;
  padding:0 14px;
  border-radius:12px;
  border:1px solid rgba(0,0,0,.2);
  background:#fff;
  cursor:pointer;
  font-weight:800;
  white-space:nowrap;
}
button:active{transform:translateY(1px)}

button:disabled{
  opacity: .90;
  cursor: not-allowed;
  transform: none;
  background: #ebebeb;          
  border-color: #9c9c9c;         
  color:#989898
}

.primary{
  background:rgb(71, 101, 166);
  color:#fff;
  border-color:rgba(0,0,0,.2);
}

@keyframes ringPulse{
  0%   { box-shadow:0 0 0 0 rgba(0,0,0,0); }
  55%  { box-shadow:0 0 0 12px var(--ringColor, var(--pulseRGBA)); }
  100% { box-shadow:0 0 0 0 rgba(0,0,0,0); }
}
.pulse{
  --ringColor: var(--pulseRGBA);
  animation: ringPulse 1.15s ease-in-out infinite;
  animation-delay: var(--pulseSyncDelay, 0s);
}

.actionsRow{
  display:flex;
  align-items:flex-end;
  gap:10px;
  flex-wrap:wrap;
}
.actionsRow > *{ 
  flex: 0 1 auto; 
  max-width: 100%;
}
.actionsCentered{justify-content:center}

.actionsStack{
  display:flex;
  flex-direction:column;
  gap:10px;
  align-items:center;
}

.inlineControl{
  display:flex;
  flex-direction:column;
  gap:6px;
}
.inlineControlRow{min-width:unset; width:auto;}
.inlineLabel{
  font-size:12px;
  font-weight:800;
  opacity:.75;
}

.answerGrid{
  display:flex;
  align-items:stretch;
  justify-content:center;
  gap:8px;
  padding: 2px;
  width: 100%;
  max-width: var(--answers-max);
  margin: 0 auto;
  flex-wrap: wrap;
}
.intervalBtn{
  height:auto;
  min-height:32px;
  padding:7px 8px;
  line-height:1.05;
  text-align:center;
  display:flex;
  flex-direction:column;
  justify-content:center;
  gap:3px;
}
.intervalBtn small{ font-size:11px; font-weight:800; opacity:.75; }

.intervalBtn.correct{ background:#1f9d55; color:#fff; border-color:rgba(0,0,0,.18); }
.intervalBtn.incorrect{ background:#d13b3b; color:#fff; border-color:rgba(0,0,0,.18); }

.nextReady{
  --ringColor: var(--nextPulseRGBA);
  background: var(--nextOrange);
  color:#fff;
  border-color: rgba(0,0,0,.15);
  animation: ringPulse 1.15s ease-in-out infinite;
  animation-delay: var(--pulseSyncDelay, 0s);
}

.analysis{
  align-items: center;
  max-width: var(--analysis-max);
  margin: 10px auto 0;
  background:#fff;
  border:1px solid rgba(0,0,0,.0);
  border-radius:16px;
  padding:0px;
}

.analysisGrid{display:grid;gap:10px;margin:0 auto;justify-items:center}
.feedbackGridPitch{ grid-template-columns: 1.25fr 0.75fr; align-items:stretch; }

/* Ensures whitespace normalization to protect the scorecard layout in modals */
.analysisCard{
  border:1px solid rgba(0,0,0,.2);
  border-radius:14px;
  padding:12px;
  background:#f9f9f9;
  white-space: normal; 
}
.fixedFeedbackCard{ min-height: 240px; }

.analysisLabel{
  align-items: center;
  font-size:16px;
  opacity:.85;
  margin-bottom:8px;
  font-weight:900;
  letter-spacing:.2px;
  text-align:center;
}

.analysisBody{font-size:14px;line-height:1.45;word-break:break-word}
.scoreBody{font-variant-numeric:tabular-nums}

.feedbackStack{
  align-items: center;
  display:flex;
  flex-direction:column;
  gap:8px;
}

/* Constrained horizontal stretching */
.scoreCardNarrow{ 
  padding: 14px 10px; 
  margin: 0 auto; 
  width: 100%;
  max-width: 440px; 
}
.scoreGrid{ display:grid; gap:8px 10px; }
.scoreGridVertical{ grid-template-columns: 1fr; gap:8px; max-width: 420px; margin: 0 auto;}
.scoreItem{
  display:flex;
  justify-content:space-between;
  align-items:baseline;
  gap:10px;
  padding:8px 10px;
  border:1px solid rgba(0,0,0,.2);
  border-radius:12px;
  background:#fff;
}
.scoreK{ font-size:12px; opacity:.75; font-weight:800; letter-spacing:.2px; }
.scoreV{ font-weight:900; font-variant-numeric:tabular-nums; }

/* PER NOTE STYLES */
.perNoteGrid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  margin-top: 4px;
  width: 100%;
}
.perNoteItem {
  background: #fff;
  border: 1px solid rgba(0,0,0,0.18);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 800;
  color: rgba(0,0,0,0.75);
  font-variant-numeric: tabular-nums;
}

/* HTML Scorecard Custom Text Positioning */
.scoreSiteUrl {
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  opacity: 0.6;
  margin-bottom: 14px;
}
.scoreFooter {
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  opacity: 0.55;
  margin-top: 24px;
}


#feedbackOut{ text-align: center; }

.miniLegend{
  display:flex;
  gap:12px;
  align-items:center;
  justify-content:center;
  font-size:12px;
  font-weight:800;
  opacity:.75;
  user-select:none;
}
.miniLegendInCard{ margin: 0; }

.legendDot{
  width:10px;height:10px;border-radius:999px;display:inline-block;margin:0 6px 0 0;
  border:1px solid rgba(0,0,0,.2);
}
.legendFirst{background:var(--firstNote)}
.legendSecond{background:var(--secondNote)}

.mount{ overflow:hidden; }
.mount svg{ display:auto; margin:0 auto; height:128px; }
.miniMountInCard{ height: 128px; min-height: 100px; display:flex; align-items:center; justify-content:center; }

.hero, .controlsPanel, .endnotes{
  max-width: var(--text-max);
  margin-left: auto;
  margin-right: auto;
}

.modal{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.45);
  display:flex;
  align-items:flex-start;
  justify-content:center;
  padding-top: 100px;
  padding-left:10px;
  padding-right: 10px;
  z-index:50;
  overflow:auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.modal.hidden{display:none}
.modalCard{
  width:min(720px,100%);
  background:white;
  border-radius:18px;
  border:1px solid rgba(0,0,0,.1);
  padding:14px;
  box-shadow:0 12px 30px rgba(0,0,0,.25);
  max-height: calc(100dvh - 36px);
  overflow:auto;
  display:flex;
  flex-direction:column;
  align-items:center;
}
.modalTitle{font-size:18px;font-weight:900;margin:0 0 8px;text-align:center}
.modalBody{
  font-size:14px;
  line-height:1.45;
  opacity:.95;
  white-space:pre-wrap;
  text-align:center;
  display:flex;
  flex-direction:column;
  align-items:center;
  width:100%;
}
.modalBody > *{ width:100%; }
.modalBody p{ margin:0 0 10px; }
.modalBody ul{ margin:0; padding:0; list-style-position: inside; text-align:center; }
.modalBody li{ margin:6px 0; }
.modalActions{margin-top:10px;display:flex;justify-content:center;gap:10px;flex-wrap:wrap}

@media (max-width:820px){
  .feedbackGridPitch{ grid-template-columns: 1fr; }
  .fixedFeedbackCard{ min-height: 260px; }
}

@media (max-width:420px){
  button{padding:0 12px;}
}

.settingsGrid{ display:grid; grid-template-columns: 1fr; gap: 10px; justify-items: center; }
.settingsLabel{ font-weight: 900; opacity: .78; font-size: 12px; letter-spacing: .2px; text-align:center; }
.settingsHint{ font-size: 13px; opacity: .8; line-height: 1.35; margin-top: 2px; text-align:center; }

.statusPanel{ max-width: var(--text-max); margin: 8px auto 0; background:#fff; border:1px solid rgba(0,0,0,0); border-radius:16px; padding: 0; }
.statusRow{ display:flex; flex-direction:column; align-items:center; justify-content:center; gap:10px; padding: 10px 10px 6px; }
.scaleMiniWrap{ width: min(780px, 100%); }
.statusText{ width:100%; text-align:center; }
.phaseTitle{ font-weight:900; font-size:16px; }

.scoreInline{ display:flex; gap:8px; justify-content:center; padding: 0 10px 12px; flex-wrap:wrap; }
.scorePill{ display:flex; gap:8px; align-items:baseline; border:1px solid rgba(0,0,0,.16); border-radius:999px; padding:6px 10px; background:#fff; font-variant-numeric: tabular-nums; }
.scoreLabel{ font-size:12px; opacity:.7; font-weight:900; }
.scoreValue{ font-size:14px; font-weight:900; }

.noteBtn{
  height:auto;
  min-height:36px;
  padding:8px 8px;
  width: auto;
  max-width: none;
  flex: 0 1 auto;
  min-width: 55px;
  line-height:1.05;
  text-align:center;
  display:flex;
  flex-direction:column;
  justify-content:center;
  gap:2px;
  user-select:none;
}
.noteBtn.correct{ background:#1f9d55; color:#fff; border-color:rgba(0,0,0,.18); }
.noteBtn.incorrect{ background:#d13b3b; color:#fff; border-color:rgba(0,0,0,.18); }
.noteBtn.correct:disabled, .noteBtn.incorrect:disabled{ opacity: 1; }
.noteBtn.chosen{ box-shadow: 0 0 0 6px var(--scaleBlueRGBA); border-color: rgba(0,0,0,.25); }

.noteBtn .deg{ font-size:12px; font-weight:900; opacity:.78; letter-spacing:.2px; }
.noteBtn .note{ font-size:13px; font-weight:900; line-height:1.05; }

@media (max-width:420px){ .statusRow{ padding-top: 8px; } }

.scaleOptionBtn{ width: 100%; display:flex; justify-content:center; background:#fff; }
.scaleOptionBtn.selected{ background:#1f9d55; color:#fff; border-color: rgba(0,0,0,.18); }

#beginBtn.isRestart{ background:#fff; color: var(--text); }
.confirmPrimary{ background:#1f9d55; color:#fff; border-color: rgba(0,0,0,.18); }

.feedbackLine{ max-width: var(--text-max); margin: 12px auto 0; text-align:center; font-size:14px; line-height:1.4; opacity: .92; }

.scoreMeta{ text-align:center; font-size:12px; font-weight:900; opacity:.75; margin: 2px 0 10px; }
.scoreActions{ display: flex; flex-direction:column; align-items:center; gap:10px; }

.nameLabel{ font-size:12px; font-weight:900; opacity:.75; }
#playerNameInput, #modalPlayerNameInput { height:38px; padding:0 10px; border-radius:12px; border:1px solid rgba(0,0,0,.2); background:#fff; font-weight:800; width:min(240px, 70vw); }
#playerNameInput::placeholder, #modalPlayerNameInput::placeholder { opacity:.6; font-weight:800; }
#downloadScorecardBtn, #modalDownloadScorecardBtn { height:38px; }

/* VIRTUAL KEYBOARD INPUT MODE */
.answerKeyboard {
  margin: 10px auto;
  user-select: none;
  transition: opacity 0.2s;
}
.answerKeyboard.locked {
  pointer-events: none;
}