/* =============================================================================
   piano-chords.css — chord buttons (.cc) + chord detail panel (.cd)
   ========================================================================== */

:root {
  /* chord controls panel — lighter grey */
  --cc-bg: #3d3d42;
  --cc-btn-bg: #4d4d53;
  --cc-btn-hover: #5c5c63;
  --cc-btn-border: #66666d;
  --cc-btn-fg: #f2f2f2;
  --cc-active-bg: #f2f2f2;
  --cc-active-fg: #1d1d1f;
  --cc-related: #f2f2f2;          /* outline: same root as the active chord, other type */
  --cc-select-bg: #2b2b2e;
  --cc-select-fg: #f2f2f2;
  --cc-focus: #3d7be8;

  /* chord detail panel */
  --cd-bg: #ffffff;
  --cd-fg: #1d1d1f;
  --cd-muted: #6b6b70;
  --cd-border: #e3e3e6;
  --cd-name-bg: #1d1d1f;
  --cd-name-fg: #ffffff;
  --cd-name-hover: #3a3a3e;
  --cd-margin-top: 28px;
  --cd-host-gap: 15px;           /* SYNC: .cp margin-top/bottom in circle-o-5ths.css */
  --cd-relative-bg: #ffffff;
  --cd-relative-border: #00bcd4; /* Material Cyan 500 */
  --cd-circle: 52px;
}

/* --- chord controls: type dropdown + one row of 12 buttons ------------------ */
/* fill the parent container whatever its display type (block, flex row, grid) */
.cc {
  margin-top: 12px;
  margin-bottom: 15px;
  width: 100%;
  min-width: 0;
  flex: 1 1 100%;
  grid-column: 1 / -1;
  box-sizing: border-box;
}

.cc-group {
  padding: 12px;
  border-radius: 10px;
  background: var(--cc-bg);
  box-sizing: border-box;
}

.cc-type {
  display: block;
  min-height: 44px;
  max-width: 100%;
  margin-bottom: 10px;
  padding: 0 40px 0 12px;
  border: 1px solid var(--cc-btn-border);
  border-radius: 8px;
  background-color: var(--cc-select-bg);
  /* chevron: inline SVG data URI (no external request) */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23f2f2f2' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  color: var(--cc-select-fg);
  font: inherit;
  font-size: 15px;
  letter-spacing: 0.02em;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}
.cc-type:hover { border-color: var(--cc-btn-fg); }
.cc-type:focus-visible { outline: 3px solid var(--cc-focus); outline-offset: 2px; }
.cc-type option,
.cc-type optgroup { background: var(--cc-select-bg); color: var(--cc-select-fg); }

.cc-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 8px;
}

/* chord buttons: rounded badges, same shape as .cd-name / .cp-rel-badge */
.cc-btn {
  appearance: none;
  -webkit-appearance: none;
  min-width: 0;
  min-height: 44px;
  padding: 0 6px;
  border: 1px solid var(--cc-btn-border);
  border-radius: 22px;
  background: var(--cc-select-bg);
  color: var(--cc-btn-fg);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 80ms linear, border-color 80ms linear;
}

.cc-btn:hover { border-color: var(--cc-btn-fg); background: var(--cc-btn-hover); }
.cc-btn:focus-visible { outline: 3px solid var(--cc-focus); outline-offset: 2px; }
.cc-btn.is-active { background: var(--cc-active-bg); color: var(--cc-active-fg); border-color: var(--cc-active-bg); }
.cc-btn.is-related { box-shadow: inset 0 0 0 2px var(--cc-related); }

/* --- chord detail panel (#chord-data) ---------------------------------------- */
.cd {
  width: 100%;
  min-width: 0;
  flex: 1 1 100%;
  grid-column: 1 / -1;
  margin-top: var(--cd-margin-top);
  padding: 14px 16px 18px;
  border-radius: 10px;
  border: 3px solid var(--cd-border);
  background: var(--cd-bg);
  color: var(--cd-fg);
  box-sizing: border-box;
  text-align: left;
}

.cd[hidden] { display: none; }

/* #root-chord-data / #minor-chord-data (class added by piano-chords.js):
   the panel fills the full height of its container, no margin */
.cd-host {
  display: flex;
  flex-direction: column;
  min-height: 100%;   /* fills a wrapping column; when the host is the column itself, flex stretch fills it */
  /* SYNC: same 15px top/bottom spacing as the progression panels (.cp margin in circle-o-5ths.css),
     so chord-data and progressions side by side line up top and bottom */
  padding-top: var(--cd-host-gap);
  padding-bottom: var(--cd-host-gap);
  box-sizing: border-box;
}
.cd-host > .cd {
  flex: 1 1 auto;
  margin: 0;
}

/* "Root Chord" title, top-left of the chord detail card */
.cd-title {
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--cd-muted);
}

.cd-name {
  appearance: none;
  -webkit-appearance: none;
  display: inline-block;
  min-height: 44px;
  padding: 0 18px;
  margin-bottom: 14px;
  border: none;
  border-radius: 22px;
  background: var(--cd-name-bg);
  color: var(--cd-name-fg);
  font: inherit;
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 80ms linear;
}
.cd-name:hover { background: var(--cd-name-hover); }
.cd-name:focus-visible { outline: 3px solid var(--cc-focus); outline-offset: 2px; }

.cd-tones {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.cd-tone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.cd-degree {
  color: var(--cd-muted);
  font-size: 13px;
  font-weight: 600;
  min-height: 16px;
}

.cd-circle {
  appearance: none;
  -webkit-appearance: none;
  width: var(--cd-circle);
  height: var(--cd-circle);
  border-radius: 50%;
  border: none;
  background: var(--cd-circle-bg, #555);
  color: var(--cd-circle-fg, #fff);
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.12);
  -webkit-tap-highlight-color: transparent;
  transition: transform 80ms ease-out;
}

/* root: white ring (with dark outline so it reads on the white panel), matching the keyboard root badge */
.cd-circle.is-root { box-shadow: 0 0 0 3px #fff, 0 0 0 5px #1d1d1f; }
.cd-circle.is-active { transform: scale(1.1); box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--cc-focus); }
.cd-circle:focus-visible { outline: 3px solid var(--cc-focus); outline-offset: 4px; }

/* --- octave rows inside #chord-data: [C4 (C)(E)(G)] ----------------------------- */
:root {
  --cd-dot: 30px;                /* visible circle */
  --cd-hit: 44px;                /* touch target around each circle */
}

.cd-octaves {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--cd-border);
}

/* rounded rectangle in the octave's color, wrapping the label and the circles */
.cd-octave-pill {
  display: inline-flex;
  flex-wrap: wrap;               /* in narrow cards the circles wrap instead of overflowing */
  max-width: 100%;
  box-sizing: border-box;
  align-items: center;
  padding: 0 4px 0 2px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: calc(var(--cd-hit) / 2);
  background: var(--cd-octave-bg, #eee);
}
.cd-octave-pill.is-active { box-shadow: 0 0 0 3px var(--cc-focus); }

.cd-octave-label,
.cd-octave-note {
  appearance: none;
  -webkit-appearance: none;
  min-height: var(--cd-hit);
  margin: 0;
  border: none;
  background: transparent;
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* clickable label: plays the full chord in this octave */
.cd-octave-label {
  min-width: var(--cd-hit);
  padding: 0 8px 0 12px;
  border-radius: calc(var(--cd-hit) / 2);
  color: var(--cd-fg);
  font-size: 15px;
  font-weight: 700;
  text-align: left;
}
.cd-octave-label:hover { background: rgba(0, 0, 0, 0.08); }

/* clickable circle: plays that single note in this octave */
.cd-octave-note {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--cd-hit);      /* 44px touch target; the circle inside stays 30px */
  padding: 0;
  border-radius: 50%;
}

.cd-octave-label:focus-visible,
.cd-octave-note:focus-visible { outline: 3px solid var(--cc-focus); outline-offset: -2px; }

.cd-octave-dot {
  box-sizing: border-box;
  min-width: var(--cd-dot);
  height: var(--cd-dot);
  padding: 0 4px;
  border-radius: calc(var(--cd-dot) / 2);
  background: var(--cd-dot-bg, #555);
  color: var(--cd-dot-fg, #fff);
  font-size: 13px;
  font-weight: 700;
  line-height: var(--cd-dot);
  text-align: center;
  transition: transform 80ms ease-out;
}
.cd-octave-dot.is-root { box-shadow: 0 0 0 2px #fff, 0 0 0 3px rgba(0, 0, 0, 0.5); }
.cd-octave-note:hover .cd-octave-dot { transform: scale(1.08); }
.cd-octave-note.is-active .cd-octave-dot { transform: scale(1.12); box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--cc-focus); }

/* relative minor panel (#minor-chord-data): white with a cyan border */
.cd.cd-relative {
  border-color: var(--cd-relative-border);
  background: var(--cd-relative-bg);
}
.cd-relative .cd-octaves { border-top-color: var(--cd-relative-border); }

/* =============================================================================
   BREAKPOINTS — keep at end of file
   ========================================================================== */

@media (max-width: 1280px) {
  .cc-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

@media (max-width: 768px) {
  .cc-group { padding: 10px 8px; border-radius: 8px; }
  .cc-type { width: 100%; }
  .cd { padding: 12px; border-radius: 8px; }
  :root { --cd-margin-top: 20px; }
}

@media (max-width: 430px) {
  .cc-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .cc-btn { font-size: 14px; }
  :root { --cd-circle: 48px; }
  .cd-tones { gap: 12px; }
}
