/* ==========================================================================
   CHORD BUILDER PAGE
   ========================================================================== */

:root { --tool-rgb: var(--chordbuilder-rgb); --tool-light-rgb: var(--chordbuilder-light-rgb); }

/* ── Overall card polish — same elevated treatment used by the Guitar
   page's Scale/CAGED cards, so this page's card doesn't look flatter
   than the rest of the site. ── */
.tool-controls-card {
    border-color: rgba(var(--tool-light-rgb), .28);
    box-shadow:
        0 22px 54px rgba(0, 0, 0, .45),
        0 2px 8px rgba(0, 0, 0, .25),
        inset 0 1px 0 rgba(255, 255, 255, .10),
        0 0 34px rgba(var(--tool-rgb), .10);
}

/* ── Pill highlights — chord builder only. Uses the same layered glass
   treatment as the shared .root-pill.active / .type-pill-btn.active
   design in tool.css (soft top gradient + radial tool-color glow +
   backdrop blur/saturate + bright bottom edge), keyed to this page's
   own --tool-rgb / --tool-light-rgb instead of the hardcoded purple. ── */
#key-root-pills .root-pill.active:not(.sf-acc-pill),
#key-mode-pills .type-pill-btn.active,
#global-sound-pills .type-pill-btn.active,
#cpb-root-pills .root-pill.active:not(.sf-acc-pill),
#cpb-quality-pills .type-pill-btn.active {
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.10) 0%, rgba(255, 255, 255, 0.01) 55%, transparent 100%),
        radial-gradient(130% 160% at 50% 105%, rgba(var(--tool-rgb), 0.75) 0%, rgba(var(--tool-rgb), 0.38) 55%, rgba(var(--tool-rgb), 0.18) 100%);
    backdrop-filter: blur(14px) saturate(200%);
    -webkit-backdrop-filter: blur(14px) saturate(200%);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-bottom: 2px solid rgba(var(--tool-light-rgb), 1);
    color: #fff;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.3),
        inset 0 -4px 8px -3px rgba(var(--tool-rgb), 0.4),
        0 2px 8px rgba(var(--tool-rgb), 0.2);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
/* Sharp/flat toggle button + accidental pill colors (for both
   #key-root-pills and #cpb-root-pills) now live centrally in tool.css,
   shared by every tool page — no page-specific override needed here. */

.diatonic-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 34px;
}
.diatonic-card {
    flex: 0 1 130px;
    background: var(--glass);
    border: 1.5px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 14px 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s var(--ease);
}
.diatonic-card:hover {
    background: var(--glass-md);
    transform: translateY(-2px);
}
.diatonic-numeral {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 12px;
    color: var(--text3);
    margin-bottom: 4px;
    letter-spacing: .3px;
}
.diatonic-name { font-weight: 800; font-size: 20px; margin-bottom: 2px; line-height: 1.1; }
.diatonic-quality { font-size: 11px; color: var(--text3); margin-bottom: 6px; }
.diatonic-notes { font-size: 11px; color: var(--text3); }

/* ── Quality color-coding — gold for major, lavender for minor, red for
   diminished, matching the Circle of Fifths diatonic card treatment. ── */
.diatonic-card.is-major {
    border-color: rgba(255, 209, 102, 0.45);
    box-shadow: 0 0 16px rgba(255, 209, 102, 0.10);
}
.diatonic-card.is-major:hover {
    border-color: rgba(255, 209, 102, 0.7);
    box-shadow: 0 6px 20px rgba(255, 209, 102, 0.18);
}
.diatonic-card.is-major .diatonic-name { color: var(--gold); }
.diatonic-card.is-minor {
    border-color: rgba(194, 182, 255, 0.45);
    box-shadow: 0 0 16px rgba(194, 182, 255, 0.12);
}
.diatonic-card.is-minor:hover {
    border-color: rgba(194, 182, 255, 0.7);
    box-shadow: 0 6px 20px rgba(194, 182, 255, 0.2);
}
.diatonic-card.is-minor .diatonic-name { color: var(--purple-l); }
.diatonic-card.is-dim {
    border-color: rgba(240, 112, 112, 0.45);
    box-shadow: 0 0 16px rgba(240, 112, 112, 0.10);
}
.diatonic-card.is-dim:hover {
    border-color: rgba(240, 112, 112, 0.7);
    box-shadow: 0 6px 20px rgba(240, 112, 112, 0.18);
}
.diatonic-card.is-dim .diatonic-name { color: #f07070; }
.diatonic-card.tonic-card { border-width: 2px; }

.progression-list { display: flex; flex-direction: column; gap: 10px; }

/* ── Progression dropdown selector + description banner + selected-chord
   cards, replacing the old full-list-of-rows layout. ── */
.progression-select-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}
.progression-select {
    flex: 1;
    min-width: 220px;
    background: var(--bg);
    border: 1px solid var(--glass-border);
    border-radius: 999px;
    color: var(--text);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 13.5px;
    padding: 10px 16px;
    cursor: pointer;
    transition: all 0.15s var(--ease);
}
.progression-select:hover,
.progression-select:focus {
    outline: none;
    border-color: rgba(var(--tool-rgb), 0.5);
    background: var(--bg);
}
.progression-select option {
    background: var(--bg);
    color: var(--text);
}
.progression-select optgroup {
    background: var(--bg);
    color: rgb(var(--tool-light-rgb));
    font-family: var(--font-display);
    font-weight: 800;
    font-style: normal;
}
.progression-desc {
    font-style: italic;
    font-size: 13.5px;
    color: var(--text2);
    background: rgba(var(--tool-rgb), 0.10);
    border: 1px solid rgba(var(--tool-rgb), 0.25);
    border-radius: var(--radius-md);
    padding: 10px 16px;
    margin: 0 0 16px;
}
.progression-tag {
    display: inline-block;
    font-style: normal;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.02em;
    color: rgb(var(--tool-light-rgb));
    background: rgba(var(--tool-rgb), 0.20);
    border: 1px solid rgba(var(--tool-rgb), 0.35);
    border-radius: 999px;
    padding: 3px 10px;
    margin: 0 8px 4px 0;
    vertical-align: middle;
}
.progression-cards { margin-bottom: 34px; }
.progression-play-btn {
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 700;
    padding: 10px 16px;
    border-radius: 999px;
    background: var(--glass-md);
    border: 1px solid var(--glass-border);
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.15s var(--ease);
}
.progression-play-btn:hover { background: rgba(var(--tool-rgb), 0.24); border-color: rgba(var(--tool-rgb), 0.5); }

.section-heading {
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 14px;
    color: var(--text2);
}

/* ==========================================================================
   CHORD PROGRESSION BUILDER — sequencer sub-section
   ========================================================================== */
.cpb-card { margin-bottom: 34px; }

.cpb-add-btn {
    margin: 14px 0 20px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 700;
    padding: 8px 16px;
    border-radius: 999px;
    background: linear-gradient(160deg, rgba(var(--tool-light-rgb), .35) 0%, rgba(var(--tool-rgb), .78) 45%, rgba(var(--tool-rgb), .92) 100%);
    border: 1px solid rgba(var(--tool-light-rgb), .55);
    color: #fff;
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .40), 0 4px 14px rgba(var(--tool-rgb), .25);
    transition: all 0.15s var(--ease);
}
.cpb-add-btn:hover {
    transform: translateY(-1px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), 0 6px 18px rgba(var(--tool-rgb), .35);
}
.cpb-add-btn:active { transform: translateY(0) scale(0.97); transition-duration: 0.08s; }
.cpb-add-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.cpb-seq-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 8px;
}
.cpb-seq-count { font-size: 12px; color: var(--text3); font-weight: 700; }

.cpb-sequence {
    min-height: 90px;
    background: var(--bg2);
    border: 1px solid var(--border2);
    border-radius: var(--radius-md);
    padding: 14px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
}
.cpb-seq-empty {
    width: 100%;
    text-align: center;
    color: var(--text3);
    font-size: 13.5px;
    padding: 20px 0;
}
.cpb-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(var(--tool-rgb), 0.16);
    border: 1px solid rgba(var(--tool-rgb), 0.4);
    border-radius: 10px;
    padding: 8px 10px 8px 14px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 13.5px;
    cursor: pointer;
    transition: all 0.15s var(--ease);
}
.cpb-chip:hover {
    background: rgba(var(--tool-rgb), 0.28);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(var(--tool-rgb), 0.2);
}
.cpb-chip-index {
    font-size: 10.5px;
    color: var(--text3);
    font-weight: 700;
}
.cpb-chip-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.25);
    color: var(--text3);
    font-size: 11px;
    line-height: 1;
    border: none;
    cursor: pointer;
    transition: all 0.15s var(--ease);
}
.cpb-chip-remove:hover { background: rgba(255, 90, 90, 0.5); color: #fff; }
.cpb-chip--playing {
    background: rgba(var(--tool-rgb), 0.42);
    border-color: rgba(var(--tool-light-rgb), 0.75);
    box-shadow: 0 0 0 2px rgba(var(--tool-light-rgb), 0.35), 0 6px 18px rgba(var(--tool-rgb), 0.3);
}

.cpb-transport {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
}
.cpb-transport-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.cpb-tbtn {
    font-family: var(--font-display);
    font-size: 12.5px;
    font-weight: 700;
    padding: 9px 16px;
    border-radius: 999px;
    background: var(--glass-md);
    border: 1px solid var(--glass-border);
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s var(--ease);
}
.cpb-tbtn:hover { background: rgba(var(--tool-rgb), 0.24); border-color: rgba(var(--tool-rgb), 0.5); }
.cpb-tbtn:disabled { opacity: 0.45; cursor: not-allowed; }
.cpb-tbtn--play {
    background: rgba(120, 220, 170, 0.18);
    border-color: rgba(120, 220, 170, 0.4);
    color: #a9f0c8;
}
.cpb-tbtn--play:hover { background: rgba(120, 220, 170, 0.3); }

.cpb-transport-settings {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.cpb-bpm-input {
    width: 60px;
    background: var(--bg2);
    border: 1px solid var(--border2);
    color: var(--text);
    border-radius: var(--radius-sm);
    padding: 7px 8px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 13px;
    text-align: center;
}
.cpb-bpm-input:focus { outline: none; border-color: rgba(var(--tool-rgb), 0.6); }



/* ── Match card width to the circle-of-fifths section above ──
   .circle-section is max-width:1200px with no outer-padding subtraction,
   but .tool-panel (which wraps these cards) has padding:0 24px, making
   cards 48px narrower than the circle. Break these two cards out of that
   padding so their outer edges line up with the circle exactly. */
.cpb-card,
.cbk-card,
.global-sound-card {
    width: calc(100% + 48px);
    max-width: 1200px;
    margin-left: -24px;
    margin-right: -24px;
    box-sizing: border-box;
}


/* ── Show/Hide collapse toggle — Progression Builder & Chords by Key ── */
.tool-controls-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}
.card-toggle-btn {
    background: transparent;
    border: none;
    color: var(--text2);
    padding: 4px 6px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    font-family: inherit;
    transition: color .18s var(--ease), background .18s var(--ease), transform .38s cubic-bezier(0.22, 1, 0.36, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    width: 30px;
    height: 30px;
    flex-shrink: 0;
}
.card-toggle-btn:hover { color: rgba(var(--tool-light-rgb), 1); background: rgba(var(--tool-rgb), 0.16); }
.card-toggle-btn.is-collapsed { transform: rotate(-90deg); }

.card-body-outer {
    display: grid;
    grid-template-rows: 1fr;
    transition: grid-template-rows .42s cubic-bezier(0.22, 1, 0.36, 1), opacity .3s cubic-bezier(0.22, 1, 0.36, 1);
    opacity: 1;
    overflow: hidden;
}
.card-body-outer.collapsed { grid-template-rows: 0fr; opacity: 0; pointer-events: none; }
.card-body { min-height: 0; }

.tool-controls-card.is-collapsed .tool-controls-desc { opacity: 0; max-height: 0; margin: 0; overflow: hidden; }

/* ── Beats segmented control — single grouped pill, matching the
   Keyboard page's octave selector (.pill-group / .pill-btn). Not
   loaded from keyboard.css since it's page-scoped there, so it's
   reproduced here keyed to this page's --tool-rgb. ── */
#cpb-beats-pills.pill-group {
    display: inline-flex;
    background: rgba(255, 255, 255, .03);
    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 8px;
    overflow: hidden;
    backdrop-filter: blur(14px) saturate(150%);
    -webkit-backdrop-filter: blur(14px) saturate(150%);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08), 0 2px 10px rgba(0, 0, 0, .25);
}
#cpb-beats-pills .pill-btn {
    background: transparent;
    border: none;
    color: var(--text2);
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    padding: 6px 14px;
    cursor: pointer;
    transition: background .15s var(--ease), color .15s var(--ease);
}
#cpb-beats-pills .pill-btn:hover { color: rgb(var(--tool-light-rgb)); background: rgba(var(--tool-rgb), .18); }
#cpb-beats-pills .pill-btn.active {
    background: linear-gradient(160deg, rgba(var(--tool-light-rgb), .40) 0%, rgba(var(--tool-rgb), .80) 45%, rgba(var(--tool-rgb), .92) 100%);
    color: #111;
}
#cpb-beats-pills .pill-btn.active:hover {
    background: linear-gradient(160deg, rgba(var(--tool-light-rgb), .40) 0%, rgba(var(--tool-rgb), .80) 45%, rgba(var(--tool-rgb), .92) 100%);
}

@media (max-width: 768px) {
    /* Mobile-only 5% font-size reduction (auto-generated). Desktop keeps
       the original sizes; this block only fires under 768px. */
    .diatonic-numeral { font-size: 11.5px; }
    .diatonic-name { font-size: 19px; }
    .diatonic-quality { font-size: 10.5px; }
    .diatonic-notes { font-size: 10.5px; }
    .progression-select { font-size: 13px; }
    .progression-desc { font-size: 13px; }
    .progression-tag { font-size: 10.5px; }
    .progression-play-btn { font-size: 11.5px; }
    .section-heading { font-size: 14px; }
    .cpb-add-btn { font-size: 11.5px; }
    .cpb-seq-count { font-size: 11.5px; }
    .cpb-seq-empty { font-size: 13px; }
    .cpb-chip { font-size: 13px; }
    .cpb-chip-index { font-size: 10px; }
    .cpb-chip-remove { font-size: 10.5px; }
    .cpb-tbtn { font-size: 12px; }
    .cpb-bpm-input { font-size: 12.5px; }
    .card-toggle-btn { font-size: 17px; }
    #cpb-beats-pills .pill-btn { font-size: 12.5px; }
}
