/* Chord Explorer Styles */

.chord-circle-container {
    position: relative;
    width: 100%;
    max-width: 400px;
    margin: 0 auto;
}

.chord-circles {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
}

.root-circle {
    fill: #fff;
    stroke: #6c757d;
    stroke-width: 2;
    cursor: pointer;
    transition: all 0.2s ease;
}

.root-circle:hover {
    fill: #e3f2fd;
    stroke: #1976d2;
    stroke-width: 3;
}

.root-circle.selected {
    fill: #1976d2;
    stroke: #0d47a1;
    stroke-width: 3;
}

.root-text {
    font-size: 26px;
    font-weight: 600;
    fill: #333;
    pointer-events: none;
    user-select: none;
}

.root-circle.selected + .root-text {
    fill: #fff;
}

.type-circle {
    fill: #fff;
    stroke: #0891b2;
    stroke-width: 2;
    cursor: pointer;
    transition: all 0.2s ease;
    animation: popIn 0.2s ease-out;
}

@keyframes popIn {
    from {
        transform: scale(0);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.type-circle:hover {
    fill: #e0f7fa;
    stroke: #0e7490;
    stroke-width: 3;
}

.type-circle.selected {
    fill: #0891b2;
    stroke: #0e7490;
    stroke-width: 3;
}

.type-text {
    font-size: 11px;
    font-weight: 500;
    fill: #333;
    pointer-events: none;
    user-select: none;
}

.type-circle.selected + .type-text {
    fill: #fff;
}

.selected-chord-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
    font-weight: 700;
    color: #333;
    pointer-events: none;
}

/* Full-width keyboard section fixed at bottom */
.keyboard-section {
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(4px);
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
}

/* Fix B and C note overlap - remove negative margin on first key of each octave */
.chord-piano .key.white.c {
    margin-left: 0;
}

.inversion-piano .key.white.c {
    margin-left: 0;
}

/* Piano for chord display - uses VirtualPiano module */
.chord-piano-rows {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .5rem;
    transform-origin: center bottom;
}
.chord-piano-rows .chord-piano[hidden] { display: none; }
/* Each row is a piano of its own: no gap at its start, round at both ends. */
/* The keys float, so a row narrower than its keys would wrap them. */
.chord-piano { width: max-content; }
.chord-piano .key.white:first-child { margin-left: 0; }

.chord-piano .key.white {
    width: 48px;
    height: 160px;
}

.chord-piano .key.black {
    width: 30px;
    height: 100px;
}

.chord-piano .key.white.expected {
    background: linear-gradient(to bottom, #cffafe 0%, #22d3ee 100%);
    border-color: #0891b2;
}

.chord-piano .key.black.expected {
    background: linear-gradient(to bottom, #0891b2 0%, #0e7490 100%);
}

/* Score container */
.chord-score {
    min-height: 100px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.chord-score svg {
    max-width: 100%;
}

/* Chord builder UI */
.chord-option-group {
    text-align: left;
}

.chord-option-label {
    display: block;
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #6b7280;
    margin-bottom: .5rem;
}

.chord-quality-btn,
.chord-variant-btn,
.chord-ext-btn {
    color: #6b7280;
    border-color: #d1d5db;
    transition: all 0.15s ease;
}

.chord-quality-btn:hover,
.chord-variant-btn:hover,
.chord-ext-btn:hover {
    background-color: #e0f7fa;
    border-color: #0891b2;
    color: #0891b2;
}

.chord-quality-btn.active,
.chord-variant-btn.active,
.chord-ext-btn.active {
    background-color: #0891b2;
    border-color: #0891b2;
    color: #fff;
}

.chord-quality-btn.active:hover,
.chord-variant-btn.active:hover,
.chord-ext-btn.active:hover {
    background-color: #0e7490;
    border-color: #0e7490;
}

/* The page column centres its children, which shrank this card to its
   content and squeezed the keys: it takes the full width of the page. */
.chord-inversions { width: 100%; }
.inversion-piano .key { flex-shrink: 0; }
@media (min-width: 768px) {
    .chord-inversions .inversion-piano .key.white { width: 44px; height: 140px; }
    .chord-inversions .inversion-piano .key.black { width: 28px; height: 88px; }
}

/* Inversion pianos grid */
.inversion-pianos-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.inversion-piano-item {
    background: #f8fafc;
    border-radius: .75rem;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 2px solid transparent;
    overflow: hidden;
    width: 100%;
}

.inversion-piano-item:hover {
    background: #e0f7fa;
    border-color: #0891b2;
}

.inversion-piano-item.active {
    background: #cffafe;
    border-color: #0891b2;
    box-shadow: 0 0 0 3px rgba(8, 145, 178, 0.2);
}

.inversion-piano-item.d-none {
    display: none !important;
}

.inversion-label {
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: #6b7280;
    margin-bottom: .5rem;
    text-align: center;
}

.inversion-piano {
    transform-origin: center;
    margin: 0 auto;
    display: flex;
    justify-content: center;
}

.inversion-piano .key.white {
    width: 36px;
    height: 120px;
}

.inversion-piano .key.black {
    width: 24px;
    height: 75px;
}

.inversion-piano .key.white.expected {
    background: linear-gradient(to bottom, #cffafe 0%, #22d3ee 100%);
    border-color: #0891b2;
}

.inversion-piano .key.black.expected {
    background: linear-gradient(to bottom, #0891b2 0%, #0e7490 100%);
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .root-circle {
        fill: #2d2d2d;
        stroke: #888;
    }

    :root:not([data-theme="light"]) .root-circle:hover {
        fill: #1a3a5c;
        stroke: #64b5f6;
    }

    :root:not([data-theme="light"]) .root-circle.selected {
        fill: #1976d2;
    }

    :root:not([data-theme="light"]) .root-text {
        fill: #e0e0e0;
    }

    :root:not([data-theme="light"]) .type-circle {
        fill: #2d2d2d;
        stroke: #22d3ee;
    }

    :root:not([data-theme="light"]) .type-circle:hover {
        fill: #1a3a4d;
    }

    :root:not([data-theme="light"]) .type-text {
        fill: #e0e0e0;
    }

    :root:not([data-theme="light"]) .selected-chord-label {
        color: #e0e0e0;
    }
}

:root[data-theme="dark"] .root-circle {
    fill: #2d2d2d;
    stroke: #888;
}

:root[data-theme="dark"] .root-circle:hover {
    fill: #1a3a5c;
    stroke: #64b5f6;
}

:root[data-theme="dark"] .root-circle.selected {
    fill: #1976d2;
}

:root[data-theme="dark"] .root-text {
    fill: #e0e0e0;
}

:root[data-theme="dark"] .type-circle {
    fill: #2d2d2d;
    stroke: #22d3ee;
}

:root[data-theme="dark"] .type-circle:hover {
    fill: #1a3a4d;
}

:root[data-theme="dark"] .type-text {
    fill: #e0e0e0;
}

:root[data-theme="dark"] .selected-chord-label {
    color: #e0e0e0;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .chord-piano .key.white {
        width: 36px;
        height: 130px;
    }
    .chord-piano .key.black {
        width: 24px;
        height: 82px;
    }
    /* A white key after a black one tucks under half of it; -1em is for wider keys. */
    .chord-piano .key.white.a, .chord-piano .key.white.b, .chord-piano .key.white.d,
    .chord-piano .key.white.e, .chord-piano .key.white.g,
    .chord-piano .key.black { margin-left: -12px; }
}

@media (max-width: 576px) {
    .chord-circle-container {
        max-width: 100%;
    }

    .selected-chord-label {
        font-size: 2rem;
    }

    /* Two rows of ten or so keys; the names small enough to fit a key. */
    .chord-piano .keyText { font-size: .62rem; letter-spacing: -.02em; }
    /* Two rows of eleven or so keys: wider keys, a little shorter. */
    .chord-piano .key.white {
        width: 30px;
        height: 92px;
    }
    .chord-piano .key.black {
        width: 19px;
        height: 58px;
    }
    /* A white key after a black one tucks under half of it; -1em is for wider keys. */
    .chord-piano .key.white.a, .chord-piano .key.white.b, .chord-piano .key.white.d,
    .chord-piano .key.white.e, .chord-piano .key.white.g,
    .chord-piano .key.black { margin-left: -10px; }
}
