/* ---- Circle of Fifths ---- */
/* Override tool-page max-width for full-width layout */
.tool-page:has(#cof-layout) { max-width: 100%; }

#container { position: relative; }
#wheel { display: block; cursor: pointer; touch-action: none; }

/* ---- Layout: 50/50 split like library ---- */
#cof-layout {
  display: flex;
  width: 100%;
  max-width: 960px;
  min-height: 540px;
  margin: 0 auto;
  background: #13151f;
  border: 1.5px solid #2a2d3a;
  border-radius: 10px;
  overflow: hidden;
}
#cof-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 50%;
  flex-shrink: 0;
  padding: 24px;
}

/* ---- Chord Cards (inside panel) ---- */
#chords-grid {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.chord-card {
  flex: 1 1 0;
  min-width: 0;
  padding: 6px 2px;
  border-radius: 10px;
  text-align: center;
  transition: transform 0.15s;
  cursor: pointer;
  overflow: hidden;
}
.chord-card:hover { transform: translateY(-2px); }
.chord-degree { font-size: 0.62rem; font-weight: 600; opacity: 0.7; margin-bottom: 1px; letter-spacing: 0.03em; }
.chord-name { font-size: 0.92rem; font-weight: 700; }
.chord-quality { font-size: 0.52rem; opacity: 0.6; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chord-major { background: #3a1818; border: 1px solid #c04040; color: #f0a0a0; }
.chord-minor { background: #142838; border: 1px solid #4088c0; color: #a0c8f0; }
.chord-dim   { background: #183818; border: 1px solid #408840; color: #a0e0a0; }

/* ---- Audio Buttons (inside panel) ---- */
#cof-buttons {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.btn {
  padding: 7px 14px;
  border: 1.5px solid #2a2d3a;
  border-radius: 10px;
  background: #1a1d27;
  color: #ccc;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: background 0.15s, border-color 0.15s;
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1 1 0;
  justify-content: center;
  white-space: nowrap;
}
.btn:hover { background: #252836; border-color: #555; color: #fff; }
.btn svg { width: 14px; height: 14px; fill: currentColor; }
#btn-open-bt { flex: 1 1 100%; }

/* ---- CoF Controls ---- */
.cof-controls { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-bottom: 0.8rem; align-items: center; }
.cof-toggles { display: flex; gap: 8px; justify-content: center; margin-bottom: 0.8rem; }
.cof-pill-group { display: flex; gap: 0; border-radius: 10px; overflow: hidden; border: 1.5px solid #2a2d3a; align-items: stretch; }
/* Dice button uses shared .lib-dice-btn from base.css */
/* Tonic title above circle */
.cof-tonic-title {
  font-size: 1.3rem; font-weight: 700; color: #fff;
  text-align: center; margin-bottom: 2px; line-height: 1.4;
}
.cof-tonic-subtitle {
  font-size: 0.85rem; color: #888;
  text-align: center; margin-bottom: 6px;
}
.cof-tonic-notes {
  font-size: 0.85rem; color: #7cb8ff;
  text-align: center; margin-bottom: 10px;
}

/* Key slider under circle */
.cof-slider-wrap {
  display: flex; align-items: center; gap: 8px;
  justify-content: center; margin-top: 12px; margin-bottom: 4px;
}
.cof-root-label {
  font-size: 1.1rem; font-weight: 700; color: #7cb8ff;
  min-width: 56px; text-align: center;
}
.cof-root-slider {
  -webkit-appearance: none; appearance: none;
  width: 300px; height: 6px; border-radius: 10px;
  background: #2a2d3a; outline: none; cursor: pointer;
}
.cof-root-slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px;
  border-radius: 50%; background: #2a6cb0;
  cursor: pointer; border: 2px solid #7cb8ff;
}
.cof-root-slider::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: #2a6cb0; cursor: pointer; border: 2px solid #7cb8ff;
}
.cof-pill { padding: 6px 14px; font-size: 0.78rem; background: #13151f; color: #888; border: none; cursor: pointer; transition: all 0.15s; }
.cof-pill.active { background: #2a2d3a; color: #ccc; }
.cof-preview-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%; border: 1px solid #3a4060;
  background: #1a1d2e; color: #7cb8ff; cursor: pointer; margin-top: 3px;
  font-size: 0.6rem; transition: all 0.15s;
}
.cof-preview-btn:hover { background: #2a3a5a; border-color: #5a7ab0; }
.cof-preview-btn svg { width: 10px; height: 10px; fill: currentColor; }

/* ---- Explainer Panel (right side, always visible) ---- */
#cof-explainer {
  width: 50%;
  min-width: 0;
  border-left: 2px solid #2a2d3a;
  padding: 20px 22px;
  font-size: 0.85rem;
  line-height: 1.55;
  color: #c0c4d0;
  overflow-y: auto;
}
#explainer-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  padding-bottom: 12px;
  border-bottom: 2px solid #2a2d3a;
  margin-bottom: 12px;
}

/* ---- Accordion sections ---- */
.cof-detail { border-top: 1.5px solid #2a2d3a; }
.cof-detail:first-of-type { border-top: none; }
.cof-detail summary {
  padding: 10px 0;
  font-size: 0.76rem;
  font-weight: 600;
  color: #888;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  transition: color 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.cof-detail summary::-webkit-details-marker { display: none; }
.cof-detail summary::after {
  content: '+';
  font-size: 0.85rem;
  color: #555;
}
.cof-detail[open] summary::after { content: '\2212'; }
.cof-detail summary:hover { color: #ccc; }
.cof-detail[open] summary { color: #bbb; }
.cof-detail-body { padding: 0 0 12px; }

#explainer-notes { margin-bottom: 12px; }
#explainer-notes .note-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
}
#explainer-notes .note-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #1a1d2e;
  border: 1px solid #2a3050;
  color: #b0b8d0;
}
#explainer-notes .note-tag-click {
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
#explainer-notes .note-tag-click:hover {
  background: #2a3a5a;
  border-color: #5a7ab0;
  color: #fff;
}
#explainer-formula { font-size: 0.78rem; color: #999; }
#explainer-formula span { font-weight: 600; color: #c0c4d0; }

#explainer-desc {
  font-size: 0.78rem;
  color: #a0a4b0;
  line-height: 1.6;
  margin-top: 10px;
}
#explainer-howto-text {
  font-size: 0.78rem;
  color: #a0a4b0;
  line-height: 1.6;
}
#explainer-howto-text p { margin: 0 0 8px; }
#explainer-howto-text p:last-child { margin-bottom: 0; }
#explainer-tips {
  font-size: 0.75rem;
  color: #808490;
  margin-top: 8px;
}
#explainer-tips:empty { display: none; }
#explainer-tips strong { color: #a0a8b8; }

.cof-howto p {
  font-size: 0.75rem;
  color: #a0a4b0;
  line-height: 1.55;
  margin: 0 0 8px;
}
.cof-howto p:last-child { margin-bottom: 0; }
.cof-howto strong { color: #c0c4d0; }

.explainer-links { display: flex; flex-wrap: wrap; gap: 6px; }
.explainer-links a {
  display: inline-block; padding: 4px 10px; border-radius: 10px;
  font-size: 0.7rem; font-weight: 600; text-decoration: none;
  background: #1a1d2e; border: 1px solid #2a3050; color: #7cb8ff;
  transition: all 0.15s;
}
.explainer-links a:hover { background: #2a3a5a; border-color: #5a7ab0; color: #a0d0ff; }

/* ---- Click-to-play hint text ---- */
.cof-click-hint {
  font-size: 0.62rem;
  color: #555;
  margin-top: 2px;
  margin-bottom: 6px;
  letter-spacing: 0.02em;
}

/* ---- Audio toolbar buttons ---- */
/* Audio button wave animations — active state from .lib-dice-btn.active */
.cof-audio-btn .cof-audio-wave1,
.cof-audio-btn .cof-audio-wave2 { opacity: 0.3; }
.cof-audio-btn.active .cof-audio-wave1,
.cof-audio-btn.active .cof-audio-wave2 { opacity: 1; }

/* ---- Responsive: stack vertically on narrow screens ---- */
@media (max-width: 1100px) {
  #cof-layout {
    flex-direction: column;
    min-height: 0;
  }
  #cof-left {
    width: 100%;
    padding: 16px;
  }
  #cof-explainer {
    width: 100%;
    border-left: none;
    border-top: 2px solid #2a2d3a;
  }
}
@media (max-width: 600px) {
  .cof-controls { gap: 5px; margin-bottom: 0.6rem; }
  .cof-toggles { gap: 5px; margin-bottom: 0.6rem; }
  .cof-controls .lib-dice-btn svg, .cof-lock-btn svg { width: 14px; height: 14px; }
  .cof-pill { padding: 5px 10px; font-size: 0.7rem; }
  #cof-explainer { padding: 14px 16px; }
  #cof-explainer .btn { font-size: 0.7rem; padding: 6px 10px; }
  #explainer-title { font-size: 1rem; }
  .chord-name { font-size: 0.82rem; }
  .chord-degree { font-size: 0.58rem; }
  .chord-quality { font-size: 0.48rem; }
}
@media (max-width: 400px) {
  .cof-controls { gap: 4px; margin-bottom: 0.4rem; }
  .cof-toggles { gap: 4px; margin-bottom: 0.4rem; }
  .cof-controls .lib-dice-btn svg, .cof-lock-btn svg { width: 12px; height: 12px; }
  .cof-pill { padding: 4px 8px; font-size: 0.65rem; }
}
