/* =============================================
   CC's Music Game — Shared Styles
   ============================================= */

/* CSS Variables */
:root {
  --pink:    #FFB7C5;
  --yellow:  #FFF3B0;
  --mint:    #C7F2E3;
  --lavender:#E0D4F7;
  --coral:   #FFD4A3;
  --sky:     #D4EEFF;
  --purple:  #F0D4FF;
  --white:   #FFFFFF;
  --offwhite:#F9F9F9;
  --text:    #333333;
  --text-light: #666666;
  --shadow:  rgba(0,0,0,0.12);
  --radius:  16px;
  --radius-sm: 8px;
  --font:    'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
}

/* Reset & Base */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 18px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: linear-gradient(135deg, #FFF8FB 0%, #F0F8FF 50%, #F5FFF9 100%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ============ Page Header ============ */
.page-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--white);
  box-shadow: 0 2px 12px var(--shadow);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.page-header h1 {
  font-size: 1.5rem;
  font-weight: 800;
  flex: 1;
}

.page-header .subtitle {
  font-size: 0.9rem;
  color: var(--text-light);
}

/* ============ Back Button ============ */
.back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--white);
  border: 2px solid #ddd;
  font-size: 1.3rem;
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  transition: background 0.2s, transform 0.1s;
  flex-shrink: 0;
}
.back-btn:hover { background: #f0f0f0; transform: scale(1.08); }
.back-btn:active { transform: scale(0.95); }

/* ============ Main Content ============ */
.main-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

/* ============ Buttons ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
  text-decoration: none;
  min-height: 52px;
  font-family: var(--font);
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 6px 18px var(--shadow); }
.btn:active { transform: translateY(0); box-shadow: none; }
.btn:focus-visible { outline: 3px solid #4a90e2; outline-offset: 3px; }

.btn-primary {
  background: linear-gradient(135deg, #FF8FAB, #FF6B9D);
  color: white;
}
.btn-secondary {
  background: var(--white);
  color: var(--text);
  border: 2px solid #ddd;
}
.btn-mint   { background: var(--mint); color: #1a6b4a; }
.btn-lavender { background: var(--lavender); color: #5a3e8a; }
.btn-yellow { background: var(--yellow); color: #7a6200; }
.btn-coral  { background: var(--coral); color: #8a4200; }
.btn-sky    { background: var(--sky); color: #1a4a8a; }
.btn-purple { background: var(--purple); color: #6a2a8a; }

.btn-note {
  min-width: 72px;
  min-height: 72px;
  border-radius: 50%;
  font-size: 1.3rem;
  font-weight: 900;
  background: var(--white);
  border: 3px solid #ddd;
  color: var(--text);
}
.btn-note:hover { background: var(--lavender); border-color: #b0a0e0; }

.btn-tap {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  font-size: 2rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--coral), #FFAA70);
  color: white;
  border: none;
  box-shadow: 0 8px 24px rgba(255,170,100,0.4);
}
.btn-tap:active { transform: scale(0.93); }

/* ============ Progress Bar ============ */
.progress-section {
  margin: 16px 0;
}
.progress-bar {
  background: #e8e8e8;
  border-radius: 20px;
  height: 18px;
  overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #FF8FAB, #FFB74D);
  border-radius: 20px;
  transition: width 0.4s ease;
  min-width: 4px;
}
.progress-label {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-light);
  margin-top: 4px;
}

/* ============ Score Display ============ */
.score-display {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  margin: 12px 0;
}
.score-item {
  background: var(--white);
  border-radius: var(--radius);
  padding: 10px 20px;
  font-size: 1rem;
  font-weight: 700;
  box-shadow: 0 2px 8px var(--shadow);
  text-align: center;
}
.score-item span { display: block; font-size: 1.4rem; }

/* ============ Staff / ABC Notation ============ */
.staff-container {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px var(--shadow);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 140px;
  margin: 20px 0;
  overflow: hidden;
}

/* ============ Answer Grid ============ */
.answer-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin: 20px 0;
}
.answer-btn {
  padding: 14px 24px;
  border-radius: var(--radius);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  border: 3px solid transparent;
  background: var(--white);
  box-shadow: 0 2px 10px var(--shadow);
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s, border-color 0.15s;
  font-family: var(--font);
  min-width: 140px;
}
.answer-btn:hover { transform: translateY(-2px); box-shadow: 0 6px 18px var(--shadow); background: #f8f8f8; }
.answer-btn:active { transform: translateY(0); }
.answer-btn.correct-ans { background: #b8f0c8; border-color: #4caf50; }
.answer-btn.wrong-ans   { background: #fdd; border-color: #f44336; }
.answer-btn:focus-visible { outline: 3px solid #4a90e2; outline-offset: 3px; }

/* ============ Feedback Messages ============ */
.feedback {
  text-align: center;
  font-size: 1.15rem;
  font-weight: 700;
  min-height: 2em;
  padding: 10px;
  border-radius: var(--radius-sm);
  transition: opacity 0.3s;
}
.feedback.correct { color: #2e7d32; background: #e8f5e9; }
.feedback.wrong   { color: #c62828; background: #ffebee; }
.feedback.empty   { background: transparent; }

/* ============ Index Cards Grid ============ */
.hero {
  text-align: center;
  padding: 32px 0 24px;
}
.hero h1 { font-size: 2.4rem; font-weight: 900; margin-bottom: 8px; }
.hero .tagline { font-size: 1.15rem; color: var(--text-light); }

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 20px;
  margin: 24px 0;
}

.module-card {
  border-radius: var(--radius);
  padding: 24px 20px;
  text-align: center;
  text-decoration: none;
  color: var(--text);
  box-shadow: 0 4px 16px var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  display: block;
  position: relative;
  overflow: hidden;
}
.module-card:hover { transform: translateY(-6px); box-shadow: 0 12px 32px rgba(0,0,0,0.18); }
.module-card::before {
  content: '';
  position: absolute;
  top: -30px; right: -30px;
  width: 100px; height: 100px;
  border-radius: 50%;
  background: rgba(255,255,255,0.3);
}
.module-card .card-icon   { font-size: 2.8rem; display: block; margin-bottom: 10px; }
.module-card .card-title  { font-size: 1.15rem; font-weight: 800; margin-bottom: 6px; }
.module-card .card-desc   { font-size: 0.85rem; color: #555; margin-bottom: 10px; }
.module-card .card-score  { font-size: 0.9rem; font-weight: 700; color: #555; }

.total-stars {
  text-align: center;
  padding: 20px;
  font-size: 1.2rem;
  font-weight: 700;
}

/* ============ Piano Keyboard ============ */
.keyboard-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 0 16px;
  margin: 16px 0;
}
.piano-inner {
  position: relative;
  display: inline-block;
}

.piano-key {
  position: absolute;
  border-radius: 0 0 6px 6px;
  cursor: pointer;
  transition: background 0.1s, transform 0.1s;
  user-select: none;
}
.piano-key.white {
  background: #fff;
  border: 1.5px solid #bbb;
  z-index: 1;
}
.piano-key.white:hover { background: #f0f8ff; }
.piano-key.black {
  background: #222;
  border: 1px solid #000;
  z-index: 2;
}
.piano-key.black:hover { background: #444; }

.piano-key.active    { background: var(--mint) !important; }
.piano-key.correct   { background: #4caf50 !important; }
.piano-key.wrong-key { background: #f44336 !important; }
.piano-key.scale-hint { background: #90e0c0 !important; }

/* ============ Flashcard ============ */
.flashcard-area {
  perspective: 1000px;
  width: 100%;
  max-width: 480px;
  margin: 20px auto;
  height: 280px;
  cursor: pointer;
}
.flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s cubic-bezier(0.4,0,0.2,1);
  transform-style: preserve-3d;
}
.flashcard-area.flipped .flashcard-inner { transform: rotateY(180deg); }

.flashcard-face {
  position: absolute;
  inset: 0;
  border-radius: var(--radius);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 24px;
  box-shadow: 0 6px 24px var(--shadow);
  text-align: center;
}
.flashcard-front {
  background: linear-gradient(135deg, #b3d9ff, var(--sky));
}
.flashcard-back {
  background: linear-gradient(135deg, #a8f0d0, var(--mint));
  transform: rotateY(180deg);
}

.flashcard-term { font-size: 1.8rem; font-weight: 900; margin-bottom: 8px; }
.flashcard-meaning { font-size: 1.2rem; font-weight: 600; }
.flashcard-grade { font-size: 0.8rem; font-weight: 700; padding: 4px 12px; border-radius: 20px; background: rgba(0,0,0,0.12); margin-top: 10px; }
.flashcard-hint { font-size: 0.85rem; color: #555; margin-top: 12px; }

/* ============ Starburst Animation ============ */
.starburst {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  animation: burst 0.8s forwards;
}

@keyframes burst {
  0%   { transform: scale(0) rotate(0deg);   opacity: 1; }
  60%  { transform: scale(2) rotate(180deg); opacity: 1; }
  100% { transform: scale(0) rotate(360deg); opacity: 0; }
}

/* ============ Shake Animation ============ */
@keyframes shake {
  0%   { transform: translateX(0); }
  15%  { transform: translateX(-8px); }
  30%  { transform: translateX(8px); }
  45%  { transform: translateX(-6px); }
  60%  { transform: translateX(6px); }
  75%  { transform: translateX(-3px); }
  90%  { transform: translateX(3px); }
  100% { transform: translateX(0); }
}
.shake { animation: shake 0.45s ease; }

/* ============ Loading Overlay ============ */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.92);
  z-index: 9990;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-size: 1.1rem;
  font-weight: 700;
  color: #555;
}
#loading-overlay .spinner {
  width: 52px;
  height: 52px;
  border: 5px solid #e0e0e0;
  border-top-color: #FF8FAB;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Misc Utilities ============ */
.section-title {
  font-size: 1.2rem;
  font-weight: 800;
  margin: 20px 0 10px;
  text-align: center;
}
.badge {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  background: rgba(0,0,0,0.1);
}
.badge-pink   { background: var(--pink); }
.badge-mint   { background: var(--mint); }
.badge-yellow { background: var(--yellow); }
.badge-sky    { background: var(--sky); }
.badge-purple { background: var(--purple); }

.text-center { text-align: center; }
.mt-12 { margin-top: 12px; }
.mt-20 { margin-top: 20px; }
.mb-12 { margin-bottom: 12px; }
.mb-20 { margin-bottom: 20px; }
.gap-8  { gap: 8px; }
.flex   { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }

.question-label {
  font-size: 1.3rem;
  font-weight: 800;
  text-align: center;
  margin: 16px 0 8px;
}

.mode-toggle {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 12px 0;
}
.mode-btn {
  padding: 10px 22px;
  border-radius: 30px;
  border: 2px solid #ddd;
  background: var(--white);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
}
.mode-btn.active { background: #FF8FAB; color: white; border-color: #FF8FAB; }
.mode-btn:hover:not(.active) { background: #f0f0f0; }

.stars-display { font-size: 1.8rem; text-align: center; margin: 12px 0; }
.result-box {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  box-shadow: 0 4px 16px var(--shadow);
  margin: 16px 0;
}

/* Rhythm tapper specifics */
.beat-dots {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin: 20px 0;
}
.beat-dot {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #ddd;
  transition: background 0.1s, transform 0.1s;
}
.beat-dot.active { background: #FF8FAB; transform: scale(1.3); }

/* Terms flashcards specifics */
.terms-meta {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 12px 0;
  font-size: 0.95rem;
}
.terms-count { font-weight: 700; }

/* Form detective tabs */
.tab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid #ddd;
  margin-bottom: 20px;
  overflow-x: auto;
}
.tab-btn {
  padding: 10px 18px;
  border: none;
  background: transparent;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  color: #888;
  font-family: var(--font);
  transition: color 0.2s;
}
.tab-btn.active { border-bottom-color: #9b59b6; color: #9b59b6; }
.tab-btn:hover:not(.active) { color: #555; }

/* ============ Responsive ============ */
@media (max-width: 600px) {
  html { font-size: 16px; }
  .hero h1 { font-size: 1.8rem; }
  .cards-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .page-header h1 { font-size: 1.1rem; }
  .staff-container { padding: 12px; min-height: 120px; }
  .btn { padding: 12px 18px; }
  .answer-btn { min-width: 110px; padding: 12px 16px; }
  .btn-tap { width: 150px; height: 150px; font-size: 1.6rem; }
  .flashcard-area { height: 240px; }
  .flashcard-term { font-size: 1.4rem; }
}

@media (max-width: 380px) {
  .cards-grid { grid-template-columns: 1fr; }
}
