/* ─────────────────────────────────────────────────────────────
   Circle of Fifths — stylesheet
   Palette and component style consistent with the interval trainer.
   Layout: two-column (circle | panel) on desktop, stacked on mobile.
───────────────────────────────────────────────────────────── */

:root {
  --bg:            #f6f6f3;
  --surface:       #ffffff;
  --border:        #deded8;
  --text:          #1a1a1a;
  --text-muted:    #666660;
  --accent:        #2b4b82;
  --accent-hover:  #1e3660;
  --accent-light:  rgba(43, 75, 130, 0.08);
  --correct:       #2a6640;
  --correct-bg:    #edf7f1;
  --incorrect:     #9b2626;
  --incorrect-bg:  #fdf0f0;
  --radius:        8px;
  --shadow:        0 1px 4px rgba(0,0,0,0.08);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0 0 3rem;
  line-height: 1.5;
}

/* ── Header ──────────────────────────────────────────────────── */

.site-header {
  text-align: center;
  padding: 1.75rem 1rem 1.1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.1rem;
}

.site-header h1 {
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  margin: 0 0 0.2rem;
}

.subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0;
  letter-spacing: 0.02em;
}

/* ── Mode nav ────────────────────────────────────────────────── */

.mode-nav {
  display: flex;
  justify-content: center;
  gap: 0;
  max-width: 220px;
  margin: 0 auto 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
}

.mode-btn {
  flex: 1;
  border: none;
  background: none;
  border-radius: 8px;
  padding: 0.45rem 1rem;
  font-size: 0.88rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.mode-btn.active {
  background: var(--accent);
  color: #fff;
}

.mode-btn:hover:not(.active) {
  background: var(--bg);
  color: var(--text);
}

/* ── App layout ──────────────────────────────────────────────── */

.app-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 1.5rem;
  max-width: 900px;
  margin: 0 auto;
  padding: 0 1.25rem;
  align-items: start;
}

/* ── Circle section ──────────────────────────────────────────── */

.circle-section {
  position: sticky;
  top: 1rem;
}

#circle-wrap {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  overflow: hidden;   /* safe — circle content stays within viewBox */
  position: relative; /* anchor for the concealed overlay */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
}

#circle-svg {
  width: 100%;
  height: auto;
  display: block;
  transition: opacity 0.25s ease;
}

/* Quiz: hide circle until the student answers */
.circle-concealed #circle-svg {
  opacity: 0;
  pointer-events: none;
}

.circle-concealed::after {
  content: 'Answer the question to reveal the circle';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 65%;
  font-size: 0.83rem;
  color: var(--text-muted);
  font-style: italic;
  text-align: center;
  pointer-events: none;
  line-height: 1.5;
}

/* Key info panel below the circle */
.key-info {
  margin-top: 0.75rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.83rem;
  min-height: 3.2rem;
  line-height: 1.6;
}

.key-info-hint {
  color: var(--text-muted);
  font-style: italic;
  margin: 0;
  font-size: 0.82rem;
}

.key-info-grid {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.15rem 0.75rem;
  margin: 0;
}

.key-info-grid dt {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.key-info-grid dd {
  margin: 0;
  color: var(--text);
}

/* ── Content panels (learn + quiz) ───────────────────────────── */

.content-panel {
  min-width: 0; /* prevent grid blowout */
}

/* ── Panel header ────────────────────────────────────────────── */

.panel-header {
  margin-bottom: 1rem;
}

.panel-header h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 0.2rem;
}

.panel-header p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
}

/* ── Step card (learn mode) ──────────────────────────────────── */

.step-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 0.9rem;
  min-height: 140px;
}

.step-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: var(--accent-light);
  padding: 0.18rem 0.55rem;
  border-radius: 4px;
  margin-bottom: 0.75rem;
}

.step-title {
  font-size: 0.97rem;
  font-weight: 600;
  margin: 0 0 0.55rem;
}

.step-body {
  font-size: 0.86rem;
  color: var(--text-muted);
  line-height: 1.65;
  margin: 0;
}

.step-body strong {
  color: var(--text);
  font-weight: 600;
}

/* ── Step navigation ─────────────────────────────────────────── */

.step-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

/* ── Step progress bar ───────────────────────────────────────── */

.step-progress {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  margin-bottom: 1rem;
  overflow: hidden;
}

.step-progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.step-counter {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ── Filters (quiz mode) ─────────────────────────────────────── */

.filters {
  margin-bottom: 1rem;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.filter-group label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
}

.filter-group select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E")
    no-repeat right 0.6rem center / 8px 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.45rem 1.8rem 0.45rem 0.6rem;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
  width: 100%;
}

.filter-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(43,75,130,0.15);
}

/* ── Question card ───────────────────────────────────────────── */

.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 0.9rem;
  min-height: 80px;
}

.question-prompt {
  font-size: 0.92rem;
  color: var(--text-muted);
  margin: 0 0 1rem;
  min-height: 1.4em;
}

.question-prompt strong { color: var(--text); }

/* ── Answer buttons ──────────────────────────────────────────── */

.answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.answer-btn {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  font-size: 0.87rem;
  color: var(--text);
  cursor: pointer;
  text-align: center;
  line-height: 1.3;
  transition: border-color 0.1s, background 0.1s;
}

.answer-btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: #eef2fb;
}

.answer-btn:disabled { cursor: default; }

.answer-btn.correct {
  background: var(--correct-bg);
  border-color: var(--correct);
  color: var(--correct);
  font-weight: 600;
}

.answer-btn.incorrect {
  background: var(--incorrect-bg);
  border-color: var(--incorrect);
  color: var(--incorrect);
}

.answer-btn.reveal {
  background: var(--correct-bg);
  border-color: var(--correct);
  color: var(--correct);
  font-weight: 600;
}

/* ── Feedback ────────────────────────────────────────────────── */

.feedback {
  margin-top: 0.85rem;
  font-size: 0.83rem;
  line-height: 1.55;
  color: var(--text-muted);
  min-height: 1.2em;
}

.feedback.correct   { color: var(--correct);   }
.feedback.incorrect { color: var(--incorrect); }

/* ── Controls ────────────────────────────────────────────────── */

.quiz-controls {
  display: flex;
  gap: 0.6rem;
  margin-bottom: 1.1rem;
}

/* ── Buttons ─────────────────────────────────────────────────── */

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 0.6rem 1.3rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--surface);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.6rem 1.3rem;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-secondary:hover {
  background: var(--accent);
  color: #fff;
}

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.9rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.btn-ghost:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-ghost:disabled,
.btn-secondary:disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

/* ── Score panel ─────────────────────────────────────────────── */

.score-panel {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex-wrap: wrap;
}

.score-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
}

.score-label {
  font-size: 0.67rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.score-value {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

/* ── SVG segment transitions ─────────────────────────────────── */

#circle-svg path {
  transition: fill 0.22s ease;
}

/* ── Responsive ──────────────────────────────────────────────── */

@media (max-width: 680px) {
  .app-layout {
    grid-template-columns: 1fr;
    padding: 0 1rem;
  }

  .circle-section {
    position: static;
  }

  #circle-wrap {
    max-width: 320px;
    margin: 0 auto;
  }

  .answers {
    grid-template-columns: 1fr;
  }

  .score-panel {
    justify-content: center;
  }
}

@media (max-width: 380px) {
  #circle-wrap { max-width: 280px; }
}
