/* game.css
   Styles for Violin Teaching Game - Phase 3 Game Mode
*/

/* Game container */
#game-section {
  width: 100%;
  max-width: 700px;
  margin: 1.5em auto;
  padding: 1em;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

#game-section h2 {
  text-align: center;
  color: #4b2e83;
  margin-bottom: 0.5em;
}

/* Song selector */
.game-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1em;
  align-items: center;
  justify-content: center;
  margin-bottom: 1em;
}

#song-select {
  font-size: 1em;
  padding: 0.4em 1em;
  border-radius: 6px;
  border: 1px solid #ccc;
  min-width: 180px;
}

/* Sound toggle */
.sound-toggle {
  display: flex;
  align-items: center;
  gap: 0.4em;
}

.sound-toggle label {
  font-size: 0.95em;
  color: #555;
}

/* Sound controls (volume, tone type) */
.sound-control {
  display: flex;
  align-items: center;
  gap: 0.4em;
}

.sound-control label {
  font-size: 0.9em;
  color: #555;
}

.sound-control select {
  font-size: 0.9em;
  padding: 0.3em 0.5em;
  border-radius: 4px;
  border: 1px solid #ccc;
}

.volume-control input[type="range"] {
  width: 80px;
  cursor: pointer;
}

.volume-control #volume-display {
  font-size: 0.85em;
  color: #666;
  min-width: 32px;
}

/* Game buttons */
#game-start-btn, #game-stop-btn {
  padding: 0.5em 1.5em;
  font-size: 1em;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
}

#game-start-btn {
  background: #4caf50;
  color: #fff;
}

#game-start-btn:hover {
  background: #43a047;
  transform: scale(1.02);
}

#game-start-btn:disabled {
  background: #a5d6a7;
  cursor: not-allowed;
}

#game-stop-btn {
  background: #f44336;
  color: #fff;
}

#game-stop-btn:hover {
  background: #e53935;
  transform: scale(1.02);
}

#game-stop-btn:disabled {
  background: #ef9a9a;
  cursor: not-allowed;
}

/* Score display */
.game-score-display {
  text-align: center;
  margin: 1em 0;
  padding: 0.8em;
  background: linear-gradient(135deg, #f5f5f5, #e8e8e8);
  border-radius: 8px;
}

.game-score-display .score-label {
  font-size: 0.9em;
  color: #666;
}

.game-score-display .score-value {
  font-size: 2em;
  font-weight: bold;
  color: #4b2e83;
}

/* Progress bar */
.game-progress {
  width: 100%;
  height: 8px;
  background: #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
  margin: 0.5em 0;
}

.game-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #4caf50, #81c784);
  width: 0%;
  transition: width 0.3s ease;
}

/* Sheet music container for game */
.game-score-container {
  position: relative;
  width: 100%;
  min-height: 200px;
  max-height: 220px;
  margin: 1em 0;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background: #fafafa;
  padding: 0.5em 0;
}

.game-score-container::-webkit-scrollbar {
  height: 8px;
}

.game-score-container::-webkit-scrollbar-track {
  background: #f0f0f0;
  border-radius: 4px;
}

.game-score-container::-webkit-scrollbar-thumb {
  background: #4b2e83;
  border-radius: 4px;
}

.game-score-container::-webkit-scrollbar-thumb:hover {
  background: #3a2366;
}

/* Note highlighting states */
.vf-note.note-active {
  transition: all 0.15s ease;
}

/* Active note - waiting for player */
.vf-note.note-active .vf-notehead path,
.vf-note.note-active .vf-stem path {
  fill: #2196f3 !important;
  stroke: #1976d2 !important;
  filter: drop-shadow(0 0 8px rgba(33, 150, 243, 0.6));
  animation: pulse-active 0.8s ease-in-out infinite;
}

@keyframes pulse-active {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(33, 150, 243, 0.6)); }
  50% { filter: drop-shadow(0 0 14px rgba(33, 150, 243, 0.9)); }
}

/* Correct note - glowing green based on hold quality */
.vf-note.note-correct .vf-notehead path,
.vf-note.note-correct .vf-stem path {
  fill: #4caf50 !important;
  stroke: #388e3c !important;
  transition: filter 0.1s ease;
}

/* Brightness levels based on hold duration */
.vf-note.note-correct.glow-1 .vf-notehead path,
.vf-note.note-correct.glow-1 .vf-stem path {
  filter: drop-shadow(0 0 4px rgba(76, 175, 80, 0.4));
}

.vf-note.note-correct.glow-2 .vf-notehead path,
.vf-note.note-correct.glow-2 .vf-stem path {
  filter: drop-shadow(0 0 8px rgba(76, 175, 80, 0.6));
}

.vf-note.note-correct.glow-3 .vf-notehead path,
.vf-note.note-correct.glow-3 .vf-stem path {
  filter: drop-shadow(0 0 12px rgba(76, 175, 80, 0.8));
}

.vf-note.note-correct.glow-full .vf-notehead path,
.vf-note.note-correct.glow-full .vf-stem path {
  filter: drop-shadow(0 0 18px rgba(76, 175, 80, 1));
  animation: glow-complete 0.5s ease-out;
}

@keyframes glow-complete {
  0% { filter: drop-shadow(0 0 25px rgba(76, 175, 80, 1)); }
  100% { filter: drop-shadow(0 0 18px rgba(76, 175, 80, 1)); }
}

/* Missed note - faded red */
.vf-note.note-missed .vf-notehead path,
.vf-note.note-missed .vf-stem path {
  fill: #f44336 !important;
  stroke: #d32f2f !important;
  opacity: 0.7;
}

/* Partial note - orange (note detected but not held long enough) */
.vf-note.note-partial .vf-notehead path,
.vf-note.note-partial .vf-stem path {
  fill: #ff9800 !important;
  stroke: #f57c00 !important;
  filter: drop-shadow(0 0 6px rgba(255, 152, 0, 0.5));
}

/* Completed note (past) */
.vf-note.note-completed .vf-notehead path,
.vf-note.note-completed .vf-stem path {
  fill: #81c784 !important;
  stroke: #66bb6a !important;
  opacity: 0.85;
}

/* Current note indicator bar */
.note-cursor {
  position: absolute;
  width: 3px;
  background: linear-gradient(180deg, #2196f3, #1976d2);
  top: 30px;
  height: 140px;
  z-index: 10;
  border-radius: 2px;
  transition: left 0.15s ease-out;
  box-shadow: 0 0 8px rgba(33, 150, 243, 0.5);
}

/* Feedback message */
.game-feedback {
  text-align: center;
  min-height: 2em;
  font-size: 1.2em;
  font-weight: 500;
  margin: 0.5em 0;
  transition: color 0.2s;
}

.game-feedback.feedback-good {
  color: #4caf50;
}

.game-feedback.feedback-great {
  color: #2e7d32;
  animation: pop 0.3s ease-out;
}

.game-feedback.feedback-miss {
  color: #f44336;
}

.game-feedback.feedback-waiting {
  color: #2196f3;
}

@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* Game over screen */
.game-over {
  text-align: center;
  padding: 2em;
}

.game-over h3 {
  font-size: 1.8em;
  color: #4b2e83;
  margin-bottom: 0.5em;
}

.game-over .final-score {
  font-size: 3em;
  font-weight: bold;
  color: #4caf50;
}

.game-over .score-breakdown {
  margin-top: 1em;
  font-size: 1em;
  color: #666;
}

.game-over .score-breakdown div {
  margin: 0.3em 0;
}

.game-over .auto-replay-countdown {
  margin-top: 1.5em;
  font-size: 1.2em;
  color: #4b2e83;
  font-weight: bold;
  animation: pulse-countdown 1s ease-in-out infinite;
}

@keyframes pulse-countdown {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Stats display during game */
.game-stats {
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 0.5em;
  margin: 0.5em 0;
  font-size: 0.9em;
  color: #555;
}

.game-stats span {
  background: #f5f5f5;
  padding: 0.3em 0.8em;
  border-radius: 4px;
}

/* Responsive adjustments */
@media (max-width: 600px) {
  #game-section {
    margin: 0.5em;
    padding: 0.8em;
  }
  
  .game-controls {
    flex-direction: column;
  }
  
  .game-score-display .score-value {
    font-size: 1.6em;
  }
}

/* ===== Fingerboard Diagram ===== */
.fingerboard-container {
  width: 100%;
  max-width: 400px;
  margin: 1.5em auto;
  padding: 1em;
  background: #2d2d2d;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.fingerboard-title {
  text-align: center;
  color: #fff;
  font-size: 1.1em;
  margin-bottom: 0.8em;
  font-weight: 500;
}

.fingerboard {
  position: relative;
  display: flex;
  background: linear-gradient(180deg, #8B4513 0%, #654321 100%);
  border-radius: 8px;
  padding: 0.5em;
  overflow: hidden;
}

.fingerboard-nut {
  width: 8px;
  background: #f5f5dc;
  border-radius: 2px;
  margin-right: 4px;
}

.fingerboard-neck {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.position-labels {
  display: flex;
  justify-content: space-around;
  padding: 0 30px 0 0;
  margin-bottom: 4px;
}

.position-labels span {
  color: #ccc;
  font-size: 0.75em;
  width: 36px;
  text-align: center;
}

.string-row {
  position: relative;
  display: flex;
  align-items: center;
  height: 32px;
  transition: background 0.2s;
}

.string-row.active-string {
  background: rgba(255, 235, 59, 0.15);
  border-radius: 4px;
}

.string-name {
  width: 24px;
  color: #fff;
  font-weight: bold;
  font-size: 0.9em;
  text-align: center;
}

.string-line {
  position: absolute;
  left: 28px;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  border-radius: 1px;
}

.string-line.g-string {
  height: 4px;
  background: linear-gradient(180deg, #d4af37 0%, #aa8c2c 100%);
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.string-line.d-string {
  height: 3px;
  background: linear-gradient(180deg, #c0c0c0 0%, #a0a0a0 100%);
}

.string-line.a-string {
  height: 2.5px;
  background: linear-gradient(180deg, #c0c0c0 0%, #909090 100%);
}

.string-line.e-string {
  height: 2px;
  background: linear-gradient(180deg, #e0e0e0 0%, #b0b0b0 100%);
}

.finger-spot {
  position: relative;
  width: 36px;
  height: 28px;
  margin-left: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.finger-spot:first-of-type {
  margin-left: 4px;
}

.finger-spot::after {
  content: attr(data-finger);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(100, 100, 100, 0.3);
  border: 2px solid rgba(150, 150, 150, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75em;
  color: rgba(255, 255, 255, 0.3);
  transition: all 0.15s ease;
}

.finger-spot[data-finger="0"]::after {
  content: "○";
  font-size: 1em;
}

.finger-spot.active::after {
  background: linear-gradient(135deg, #4caf50 0%, #2e7d32 100%);
  border-color: #81c784;
  color: #fff;
  box-shadow: 0 0 12px rgba(76, 175, 80, 0.8), 0 0 24px rgba(76, 175, 80, 0.4);
  transform: scale(1.15);
  animation: finger-pulse 0.8s ease-in-out infinite;
}

.finger-spot.next-active::after {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.4);
  color: #fff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.2);
  transform: scale(0.9);
}

@keyframes finger-pulse {
  0%, 100% { box-shadow: 0 0 12px rgba(76, 175, 80, 0.8), 0 0 24px rgba(76, 175, 80, 0.4); }
  50% { box-shadow: 0 0 16px rgba(76, 175, 80, 1), 0 0 32px rgba(76, 175, 80, 0.6); }
}

.finger-info {
  display: flex;
  justify-content: center;
  gap: 1.5em;
  margin-top: 1em;
  padding-top: 0.8em;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.finger-info span {
  color: #aaa;
  font-size: 0.9em;
}

.finger-info strong {
  color: #fff;
  margin-left: 0.3em;
}

/* Hide fourth finger spots by default, show when needed */
.finger-spot[data-finger="4"] {
  display: none;
}

.fingerboard-container.show-fourth .finger-spot[data-finger="4"] {
  display: flex;
}

/* Pitch Indicator */
.pitch-indicator {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 4px;
  height: 100%;
  background: rgba(255, 80, 80, 0.8);
  transform: translateX(-50%);
  z-index: 10;
  pointer-events: none;
  transition: left 0.1s linear, background 0.2s;
  border-radius: 2px;
  box-shadow: 0 0 4px rgba(0,0,0,0.3);
}

.pitch-indicator::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 6px solid rgba(255, 80, 80, 0.8);
}

.pitch-indicator::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid rgba(255, 80, 80, 0.8);
}

.pitch-indicator.in-tune {
  background: #00e676;
  box-shadow: 0 0 8px #00e676;
}

.pitch-indicator.in-tune::before {
  border-bottom-color: #00e676;
}

.pitch-indicator.in-tune::after {
  border-top-color: #00e676;
}

/* Ensure string row is relative for absolute positioning of indicator */
.string-row {
  position: relative; 
}

/* ===== Dark Mode ===== */
@media (prefers-color-scheme: dark) {
  #game-section {
    background: #252538;
    box-shadow: 0 2px 12px rgba(0,0,0,0.3);
  }
  
  #game-section h2 {
    color: #9d7fd4;
  }
  
  #song-select {
    background: #2a2a3a;
    color: #e0e0e0;
    border-color: #555;
  }
  
  .sound-toggle label {
    color: #bbb;
  }
  
  .sound-control label {
    color: #bbb;
  }
  
  .sound-control select {
    background: #2a2a3a;
    color: #e0e0e0;
    border-color: #555;
  }
  
  .volume-control #volume-display {
    color: #aaa;
  }
  
  .game-score-display {
    background: linear-gradient(135deg, #2a2a3a, #353550);
  }
  
  .game-score-display .score-label {
    color: #999;
  }
  
  .game-score-display .score-value {
    color: #9d7fd4;
  }
  
  .game-progress {
    background: #3a3a4a;
  }
  
  .game-score-container {
    background: #1e1e2a;
    border-color: #444;
  }
  
  .game-score-container::-webkit-scrollbar-track {
    background: #2a2a3a;
  }
  
  .game-score-container::-webkit-scrollbar-thumb {
    background: #7c5cbf;
  }
  
  .game-score-container::-webkit-scrollbar-thumb:hover {
    background: #9d7fd4;
  }
  
  /* VexFlow staff lines in dark mode */
  .game-score-container svg .vf-stave path,
  .game-score-container svg .vf-stave-line {
    stroke: #666 !important;
  }
  
  .game-score-container svg .vf-clef path,
  .game-score-container svg .vf-timesig path {
    fill: #bbb !important;
  }
  
  /* Default note color in dark mode */
  .game-score-container svg .vf-notehead path,
  .game-score-container svg .vf-stem path {
    fill: #ccc !important;
    stroke: #aaa !important;
  }
  
  .game-over h3 {
    color: #9d7fd4;
  }
  
  .game-over .score-breakdown {
    color: #aaa;
  }
  
  .game-over .auto-replay-countdown {
    color: #9d7fd4;
  }
  
  .game-stats {
    color: #bbb;
  }
  
  .game-stats span {
    background: #353550;
  }
  
  .fingerboard-container {
    background: #1a1a28;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  }
  
  .fingerboard {
    background: linear-gradient(180deg, #5a3a20 0%, #402a15 100%);
  }
  
  .fingerboard-nut {
    background: #d0d0c0;
  }
}
