/**
 * Music Recommendation Workshop - Styles
 * Clean, friendly design for educational workshop
 */

/* ============================================================================
   CSS RESET & BASE STYLES
   ============================================================================ */

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

:root {
  --color-primary: #6366f1;
  --color-primary-dark: #4f46e5;
  --color-secondary: #ec4899;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;

  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-border: #e2e8f0;
  --color-text: #1e293b;
  --color-text-muted: #64748b;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);

  --font-sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "SF Mono", Monaco, "Cascadia Code", monospace;
}

body {
  font-family: var(--font-sans);
  background-color: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  padding: 2rem 1rem;
}

/* ============================================================================
   LAYOUT
   ============================================================================ */

.container {
  max-width: 1200px;
  margin: 0 auto;
}

header {
  text-align: center;
  margin-bottom: 3rem;
}

h1 {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 0.5rem;
}

.subtitle {
  font-size: 1.125rem;
  color: var(--color-text-muted);
}

.main-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

@media (min-width: 768px) {
  .main-grid {
    grid-template-columns: 2fr 1fr;
  }
}

/* ============================================================================
   CARDS
   ============================================================================ */

.card {
  background: var(--color-surface);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.card h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--color-text);
}

.card h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--color-text);
}

/* ============================================================================
   PLAYER CARD
   ============================================================================ */

.song-info {
  text-align: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

#song-title {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

#song-artist {
  font-size: 1.125rem;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}

.genre-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

/* .song-actions removed: Play button no longer used */

/* Genre badge colors */
.genre-pop {
  background-color: #fbbf24;
  color: #78350f;
}
.genre-rock {
  background-color: #ef4444;
  color: #ffffff;
}
.genre-hiphop {
  background-color: #8b5cf6;
  color: #ffffff;
}
.genre-edm {
  background-color: #06b6d4;
  color: #ffffff;
}
.genre-rb {
  background-color: #ec4899;
  color: #ffffff;
}
.genre-jazz {
  background-color: #f97316;
  color: #ffffff;
}
.genre-classical {
  background-color: #6366f1;
  color: #ffffff;
}
.genre-country {
  background-color: #84cc16;
  color: #365314;
}
.genre-indie {
  background-color: #14b8a6;
  color: #ffffff;
}
.genre-ambient {
  background-color: #a78bfa;
  color: #ffffff;
}

.features-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.feature-item {
  text-align: center;
}

.feature-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
}

.feature-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--color-primary);
}

/* Star rating */
.star-rating {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.star {
  font-size: 2rem;
  color: #cbd5e1;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.star:hover,
.star.active {
  color: #fbbf24;
  transform: scale(1.1);
}

.star:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Navigation buttons */
.nav-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}

button {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  background-color: var(--color-primary);
  color: white;
}

button:hover {
  background-color: var(--color-primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

button:active {
  transform: translateY(0);
}

button:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

button.secondary {
  background-color: var(--color-border);
  color: var(--color-text);
}

button.secondary:hover {
  background-color: #cbd5e1;
}

button:disabled,
button[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

/* Why This Song */
.why-this {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}

#match-percentage {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--color-success);
  text-align: center;
  margin-bottom: 1rem;
}

.contribution-item {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  font-size: 0.9375rem;
}

.contribution-item span:first-child {
  color: var(--color-text-muted);
}

.contribution-item span:last-child {
  font-weight: 600;
  font-family: var(--font-mono);
}

.genre-contribution {
  background-color: #fef3c7;
  padding: 0.5rem;
  border-radius: 4px;
  margin-top: 0.5rem;
}

.contribution-total {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 0;
  margin-top: 0.5rem;
  border-top: 2px solid var(--color-border);
  font-weight: 700;
  font-size: 1rem;
}

/* Feature comparison bars */
.feature-bars {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--color-border);
}

.bar-row {
  margin-bottom: 1.5rem;
}

.bar-label {
  font-weight: 600;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

.bar-pair {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.bar-container {
  position: relative;
  background-color: var(--color-border);
  height: 24px;
  border-radius: 4px;
  overflow: hidden;
}

.bar {
  height: 100%;
  transition: width 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 0.5rem;
}

.bar-pref {
  background-color: var(--color-primary);
}

.bar-song {
  background-color: var(--color-secondary);
}

.bar-value {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--color-text);
}

.bar-legend {
  display: flex;
  gap: 1rem;
  font-size: 0.75rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.legend-color {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

.legend-pref {
  background-color: var(--color-primary);
}

.legend-song {
  background-color: var(--color-secondary);
}

/* ============================================================================
   RATINGS HISTORY
   ============================================================================ */

.no-ratings {
  text-align: center;
  padding: 2rem;
  color: var(--color-text-muted);
  font-style: italic;
}

#ratings-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
}

.rating-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1rem;
  cursor: pointer;
  transition: all 0.2s;
}

.rating-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.rating-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.rating-stars {
  color: #fbbf24;
  font-size: 0.875rem;
}

.rating-card-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
  font-size: 0.9375rem;
}

.rating-card-artist {
  color: var(--color-text-muted);
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
}

.rating-card-features {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--color-text-muted);
}

/* ============================================================================
   CONTROLS PANEL
   ============================================================================ */

.controls-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.controls-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 0;
}

.controls-section h3 {
  font-size: 1rem;
  margin-bottom: 0.75rem;
}

.similarity-toggle {
  display: flex;
  gap: 0.5rem;
}

.similarity-btn {
  flex: 1;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  background-color: var(--color-border);
  color: var(--color-text);
}

.similarity-btn.active {
  background-color: var(--color-primary);
  color: white;
}

.weight-control {
  margin-bottom: 1rem;
}

.weight-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
}

.weight-name {
  font-weight: 600;
}

.weight-value {
  font-family: var(--font-mono);
  color: var(--color-text-muted);
}

input[type="range"] {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: var(--color-border);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer;
  transition: all 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: var(--shadow-md);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-primary);
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

input[type="range"]::-moz-range-thumb:hover {
  transform: scale(1.2);
  box-shadow: var(--shadow-md);
}

input[type="range"]:focus-visible::-webkit-slider-thumb {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

input[type="range"]:focus-visible::-moz-range-thumb {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.control-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.control-buttons button {
  width: 100%;
  padding: 0.5rem;
  font-size: 0.875rem;
}

/* ============================================================================
   DEBUG PANEL
   ============================================================================ */

#debug-panel {
  display: none;
}

#debug-panel.visible {
  display: block;
}

.debug-section {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background-color: var(--color-bg);
  border-radius: 8px;
}

.debug-section h4 {
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 0.75rem;
}

.debug-row {
  display: flex;
  justify-content: space-between;
  padding: 0.5rem 0;
  font-size: 0.875rem;
  border-bottom: 1px solid var(--color-border);
}

.debug-row:last-child {
  border-bottom: none;
}

.debug-row span:first-child {
  color: var(--color-text-muted);
}

.debug-row span:last-child {
  font-weight: 600;
  font-family: var(--font-mono);
}

/* ============================================================================
   HOW IT WORKS
   ============================================================================ */

.how-it-works {
  line-height: 1.8;
}

.how-it-works h2 {
  margin-bottom: 1rem;
}

.how-it-works p {
  margin-bottom: 1rem;
  color: var(--color-text-muted);
}

.how-it-works ul {
  list-style: none;
  padding-left: 0;
}

.how-it-works li {
  padding-left: 1.5rem;
  margin-bottom: 0.75rem;
  position: relative;
}

.how-it-works li:before {
  content: "→";
  position: absolute;
  left: 0;
  color: var(--color-primary);
  font-weight: 700;
}

.how-it-works code {
  background-color: var(--color-bg);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

/* Math explainer */
.math-explainer {
  line-height: 1.8;
}

.math-explainer h2 {
  margin-bottom: 1rem;
}

.math-explainer p {
  margin-bottom: 1rem;
  color: var(--color-text-muted);
}

.math-explainer ul {
  list-style: none;
  padding-left: 0;
  margin-bottom: 1rem;
}

.math-explainer li {
  padding-left: 1.5rem;
  margin-bottom: 0.75rem;
  position: relative;
}

.math-explainer li:before {
  content: "∑";
  position: absolute;
  left: 0;
  color: var(--color-primary);
  font-weight: 700;
}

.math-explainer code {
  background-color: var(--color-bg);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

/* ==========================================================================
   WORKSHOP GUIDE
   ========================================================================= */

.workshop-guide {
  line-height: 1.8;
}

.workshop-guide h2 {
  margin-bottom: 1rem;
}

.workshop-guide p {
  margin-bottom: 1rem;
  color: var(--color-text-muted);
}

.workshop-guide ol,
.workshop-guide ul {
  margin-bottom: 1rem;
}

/* Keep ordered list numbers, but align indentation with other sections */
.workshop-guide ol {
  list-style: decimal;
  padding-left: 1.5rem;
}

/* Unordered lists mimic other sections (no default bullets; custom marker) */
.workshop-guide ul {
  list-style: none;
  padding-left: 0;
}

.workshop-guide li {
  margin-bottom: 0.75rem;
}

.workshop-guide ul li {
  position: relative;
  padding-left: 1.5rem;
}

.workshop-guide ul li:before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--color-primary);
  font-weight: 700;
}

.workshop-guide .note {
  background-color: var(--color-bg);
  padding: 0.75rem 1rem;
  border-radius: 6px;
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

#sr-live {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* Focus visible styles */
*:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ============================================================================
   RESPONSIVE DESIGN
   ============================================================================ */

@media (max-width: 640px) {
  h1 {
    font-size: 2rem;
  }

  .features-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .nav-buttons {
    flex-direction: column;
  }

  #ratings-list {
    grid-template-columns: 1fr;
  }

  .similarity-toggle {
    flex-direction: column;
  }
}

/* ============================================================================
   KEYBOARD SHORTCUTS HINT
   ============================================================================ */

.keyboard-hint {
  margin-top: 2rem;
  padding: 1rem;
  background-color: var(--color-bg);
  border-radius: 8px;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  text-align: center;
}

.keyboard-hint kbd {
  display: inline-block;
  padding: 0.125rem 0.375rem;
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  margin: 0 0.125rem;
}
