/* ============================
   Exercices de Solfège - Styles
   ============================ */

/* Preload VexFlow music fonts locally */
@font-face {
  font-family: 'Bravura';
  src: url('../fonts/bravura/bravura.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Bravura Text';
  src: url('../fonts/bravura/bravura.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Academico';
  src: url('../fonts/academico/academico.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #2196F3;
  --primary-dark: #1976D2;
  --correct: #4CAF50;
  --incorrect: #F44336;
  --bg: #f5f7fa;
  --card-bg: #ffffff;
  --text: #333;
  --text-light: #666;
  --text-lighter: #999;
  --border: #e0e0e0;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-hover: 0 4px 16px rgba(0,0,0,0.12);
  --radius: 12px;
  --transition: all 0.2s ease;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ---- Layout ---- */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

/* ---- Header ---- */
.header {
  background: var(--card-bg);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  padding-bottom: 12px;
}
.header .logo {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.header .logo:hover { color: var(--primary); }
.header .score-display {
  font-size: 0.9rem;
  color: var(--text-light);
  background: var(--bg);
  padding: 6px 14px;
  border-radius: 20px;
}

/* ---- Hero ---- */
.hero {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 48px 20px;
  text-align: center;
}
.hero h1 {
  font-size: 2.2rem;
  margin-bottom: 10px;
}
.hero p {
  font-size: 1.1rem;
  opacity: 0.9;
  max-width: 600px;
  margin: 0 auto;
}

/* ---- Sections ---- */
.section-title {
  font-size: 1.4rem;
  margin: 32px 0 16px;
  color: var(--text);
  position: relative;
  padding-left: 16px;
}
.section-title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  width: 4px;
  height: 24px;
  border-radius: 2px;
  background: var(--primary);
}

/* ---- Cards Grid ---- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

/* ---- Category Card ---- */
.category-card {
  border-radius: var(--radius);
  color: white;
  padding: 24px;
  cursor: pointer;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.category-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.3), transparent);
  pointer-events: none;
}
.category-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}
.category-card .card-icon {
  font-size: 2rem;
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
}
.category-card h3 {
  font-size: 1.1rem;
  font-weight: 600;
  position: relative;
  z-index: 1;
}
.category-card .card-count {
  font-size: 0.85rem;
  opacity: 0.85;
  position: relative;
  z-index: 1;
}

/* Category gradients */
.cat-notes { background: linear-gradient(135deg, #2196F3, #1976D2); }
.cat-rythmes { background: linear-gradient(135deg, #9C27B0, #7B1FA2); }
.cat-intervalles { background: linear-gradient(135deg, #FF9800, #F57C00); }
.cat-accords { background: linear-gradient(135deg, #4CAF50, #388E3C); }
.cat-gammes { background: linear-gradient(135deg, #F44336, #D32F2F); }
.cat-armures { background: linear-gradient(135deg, #009688, #00796B); }
.cat-instruments { background: linear-gradient(135deg, #3F51B5, #303F9F); }
.cat-genres { background: linear-gradient(135deg, #E91E63, #C2185B); }

/* ---- Sub-category card ---- */
.sub-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sub-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}
.sub-card h4 {
  font-size: 1rem;
  color: var(--text);
}
.sub-card .progress-badge {
  font-size: 0.8rem;
  color: white;
  background: var(--primary);
  padding: 4px 10px;
  border-radius: 12px;
  white-space: nowrap;
}
.sub-card .progress-badge.done {
  background: var(--correct);
}

/* ---- Breadcrumb ---- */
.breadcrumb {
  padding: 16px 0;
  font-size: 0.9rem;
  color: var(--text-light);
}
.breadcrumb a { color: var(--primary); }
.breadcrumb span { margin: 0 6px; }

/* ---- Exercise Page ---- */
.exercise-page { padding: 20px 0 40px; }

/* Intro screen */
.exercise-intro {
  text-align: center;
  padding: 40px 20px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 600px;
  margin: 0 auto;
}
.exercise-intro h2 {
  font-size: 1.6rem;
  margin-bottom: 12px;
}
.exercise-intro p {
  color: var(--text-light);
  margin-bottom: 24px;
}

/* Buttons */
.btn {
  display: inline-block;
  padding: 12px 32px;
  border-radius: 24px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
}
.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--correct); color: white; }
.btn-danger { background: var(--incorrect); color: white; }
.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}
.btn-outline:hover {
  background: var(--primary);
  color: white;
}
.btn-sm {
  padding: 8px 20px;
  font-size: 0.9rem;
}

/* Exercise game area */
.exercise-game {
  max-width: 700px;
  margin: 0 auto;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

/* Circular progress */
.circular-progress {
  position: relative;
  width: 56px;
  height: 56px;
}
.circular-progress svg {
  transform: rotate(-90deg);
  width: 56px;
  height: 56px;
}
.circular-progress .bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 4;
}
.circular-progress .fg {
  fill: none;
  stroke: var(--primary);
  stroke-width: 4;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.3s ease;
}
.circular-progress .label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
}

.game-score {
  font-size: 0.95rem;
  color: var(--text-light);
}

/* Notation area */
.notation-area {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  overflow-x: auto;
}

/* Question text */
.question-text {
  text-align: center;
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 16px;
  font-weight: 500;
}

/* Answer buttons */
.answers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.answer-btn {
  padding: 14px 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}
.answer-btn:hover {
  border-color: var(--primary);
  background: #f0f7ff;
}
.answer-btn.selected {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}
.answer-btn.correct {
  border-color: var(--correct);
  background: var(--correct);
  color: white;
  animation: pulse-correct 0.3s ease;
}
.answer-btn.incorrect {
  border-color: var(--incorrect);
  background: var(--incorrect);
  color: white;
  animation: shake 0.3s ease;
}

@keyframes pulse-correct {
  0%,100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* Feedback */
.feedback {
  text-align: center;
  padding: 12px;
  border-radius: var(--radius);
  font-weight: 600;
  margin-bottom: 16px;
  display: none;
}
.feedback.show { display: block; }
.feedback.correct {
  background: #e8f5e9;
  color: var(--correct);
}
.feedback.incorrect {
  background: #ffebee;
  color: var(--incorrect);
}

/* Next button */
.next-btn-container {
  text-align: center;
}
.next-btn-container .btn {
  min-width: 160px;
}

/* Result screen */
.result-screen {
  text-align: center;
  padding: 40px 20px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  max-width: 500px;
  margin: 0 auto;
}
.result-screen .score-big {
  font-size: 3rem;
  font-weight: 800;
  margin: 16px 0;
}
.result-screen .score-big.good { color: var(--correct); }
.result-screen .score-big.ok { color: var(--primary); }
.result-screen .score-big.bad { color: var(--incorrect); }

/* ---- Piano keyboard ---- */
.piano-container {
  display: flex;
  justify-content: center;
  position: relative;
  height: 140px;
  user-select: none;
}
.piano-container .white-key {
  width: 40px;
  height: 140px;
  background: white;
  border: 1px solid #ccc;
  border-radius: 0 0 6px 6px;
  cursor: pointer;
  position: relative;
  z-index: 1;
  transition: var(--transition);
}
.piano-container .white-key:hover { background: #f0f0f0; }
.piano-container .white-key.highlight {
  background: #fff3e0;
  border-color: var(--primary);
}
.piano-container .white-key.correct-key {
  background: #c8e6c9;
  border-color: var(--correct);
}
.piano-container .white-key.incorrect-key {
  background: #ffcdd2;
  border-color: var(--incorrect);
}
.piano-container .black-key {
  width: 26px;
  height: 90px;
  background: #333;
  border: 1px solid #222;
  border-radius: 0 0 4px 4px;
  position: absolute;
  z-index: 2;
  cursor: pointer;
  transition: var(--transition);
}
.piano-container .black-key:hover { background: #555; }
.piano-container .black-key.highlight {
  background: #ff9800;
}
.piano-container .black-key.correct-key {
  background: var(--correct);
}
.piano-container .black-key.incorrect-key {
  background: var(--incorrect);
}
.piano-key-label {
  position: absolute;
  bottom: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.65rem;
  color: var(--text-light);
  pointer-events: none;
}

/* ---- Tap area for rhythm ---- */
.tap-area {
  background: var(--card-bg);
  border: 3px dashed var(--border);
  border-radius: var(--radius);
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 16px;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  user-select: none;
}
.tap-area:hover {
  border-color: var(--primary);
  background: #f0f7ff;
}
.tap-area.active {
  border-color: var(--correct);
  background: #e8f5e9;
  transform: scale(0.98);
}
.tap-area .tap-icon {
  font-size: 2rem;
  margin-bottom: 8px;
}

/* Rhythm display */
.rhythm-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.rhythm-beat {
  width: 40px;
  height: 40px;
  border: 2px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--text-light);
  transition: var(--transition);
}
.rhythm-beat.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}
.rhythm-beat.hit {
  background: var(--correct);
  border-color: var(--correct);
  color: white;
}
.rhythm-beat.miss {
  background: var(--incorrect);
  border-color: var(--incorrect);
  color: white;
}

/* Playback controls */
.playback-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 20px;
}

/* ---- Info card (instruments/genres) ---- */
.info-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 16px;
}
.info-card h3 {
  margin-bottom: 8px;
}
.info-card p {
  color: var(--text-light);
  margin-bottom: 12px;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .hero h1 { font-size: 1.6rem; }
  .cards-grid { grid-template-columns: 1fr; }
  .answers-grid { grid-template-columns: repeat(3, 1fr); }
  .piano-container .white-key { width: 32px; height: 110px; }
  .piano-container .black-key { width: 22px; height: 70px; }
  .notation-area { padding: 16px; }
}
@media (max-width: 480px) {
  .answers-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Utility */
.hidden { display: none !important; }
.text-center { text-align: center; }
.mb-16 { margin-bottom: 16px; }
.mt-16 { margin-top: 16px; }
