/* KeyboardGuitar Component Styles */

.kb-guitar {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #1e1e3a;
    border-radius: 16px;
    padding: 1.2rem;
    position: relative;
    overflow: hidden;
    border: 1px solid #333;
}

.kb-guitar-disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* Header */
.kb-guitar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid #333;
}

.kb-guitar-title {
    font-size: 1.1rem;
    font-weight: bold;
    color: #ffcc00;
}

.kb-guitar-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    font-size: 0.85rem;
    color: #aaa;
}

.kb-guitar-controls strong {
    color: #fff;
}

.kb-guitar-mute-display {
    color: #ff4444;
    font-weight: bold;
    animation: kb-mute-blink 0.5s infinite alternate;
}

@keyframes kb-mute-blink {
    from { opacity: 1; }
    to { opacity: 0.4; }
}

.kb-guitar-tempo-pulse {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #444;
    display: inline-block;
    transition: background 0.1s;
}

.kb-guitar-tempo-pulse.kb-pulse-active {
    background: #ffcc00;
    box-shadow: 0 0 8px #ffcc00;
    animation: kb-pulse-flash 0.15s ease-out;
}

.kb-guitar-tempo-pulse.kb-pulse-downbeat {
    background: #ff4400;
    box-shadow: 0 0 12px #ff4400;
}

/* Help button in header */
.kb-help-toggle {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.06);
    color: #ffcc00;
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
    font-weight: 700;
    margin-left: 8px;
}

/* Help drawer */
.kb-guitar-help-drawer {
    display: none;
    background: #0b0b12;
    border-top: 1px solid #222;
    padding: 12px;
    color: #ddd;
    max-height: 340px;
    overflow-y: auto;
    margin-top: 12px;
    border-radius: 8px;
}
.kb-guitar-help-drawer.open { display: block; }
.kb-guitar-help-drawer h3 { color: #ffcc00; margin: 8px 0 6px; }
.kb-guitar-help-drawer ul { margin: 6px 0 12px 18px; color: #ccc; }
.kb-guitar-help-drawer code { background: rgba(255,255,255,0.03); padding: 2px 6px; border-radius: 4px; }

@keyframes kb-pulse-flash {
    from { transform: scale(1.5); }
    to { transform: scale(1); }
}

/* Chord Row */
.kb-guitar-chord-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: 0.5rem 0;
}

.kb-guitar-chord-slot {
    flex: 1 1 calc(20% - 0.5rem);
    min-width: 110px;
    max-width: 180px;
    background: #2a2a4a;
    border-radius: 10px;
    padding: 0.6rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s ease;
    border: 2px solid transparent;
    position: relative;
}

.kb-guitar-chord-slot:hover {
    background: #333366;
    border-color: #555;
}

.kb-guitar-chord-slot.kb-armed {
    border-color: #ffcc00;
    background: #2a2a5a;
    box-shadow: 0 0 15px rgba(255, 204, 0, 0.3), inset 0 0 20px rgba(255, 204, 0, 0.05);
}

.kb-guitar-chord-slot.kb-armed .kb-chord-label {
    color: #ffcc00;
}

.kb-chord-key-hint {
    position: absolute;
    top: 4px;
    right: 6px;
    font-size: 0.65rem;
    color: #666;
    font-family: monospace;
    background: #1a1a2e;
    border-radius: 3px;
    padding: 1px 4px;
}

.kb-armed .kb-chord-key-hint {
    color: #ffcc00;
    background: #333;
}

.kb-chord-roman {
    font-size: 0.75rem;
    color: #888;
    margin-bottom: 2px;
    font-style: italic;
}

.kb-chord-variation-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    width: fit-content;
    margin: 0.1rem auto 0.45rem;
}

.kb-chord-var-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #d7e5ff;
    border-radius: 999px;
    width: 28px;
    height: 28px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    font-size: 1rem;
}

.kb-chord-var-btn:hover {
    background: rgba(255, 255, 255, 0.16);
}

.kb-chord-variation-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    height: 28px;
    padding: 0 0.35rem;
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
    color: #d9e6ff;
}

.kb-armed .kb-chord-roman {
    color: #ddd;
}

.kb-chord-diagram {
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kb-chord-diagram .playable-chord-wrapper {
    width: 100% !important;
}

.kb-chord-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #ccc;
    margin-top: 4px;
}

.kb-chord-variation-meta {
    font-size: 0.68rem;
    color: #7f89a7;
    margin-top: 0.2rem;
    min-height: 1em;
}

/* Strum Arrow */
.kb-guitar-strum-arrow {
    position: absolute;
    top: 50%;
    right: 20px;
    font-size: 3rem;
    color: transparent;
    transform: translateY(-50%);
    transition: color 0.1s, transform 0.1s;
    pointer-events: none;
    font-weight: bold;
    z-index: 10;
}

.kb-guitar-strum-arrow.kb-arrow-active {
    color: #ffcc00;
    text-shadow: 0 0 20px #ffcc00;
    animation: kb-strum-flash 0.3s ease-out;
}

.kb-guitar-strum-arrow.kb-arrow-muted {
    color: #ff4444;
    text-shadow: 0 0 20px #ff4444;
}

@keyframes kb-strum-flash {
    0% { transform: translateY(-50%) scale(1.8); opacity: 1; }
    100% { transform: translateY(-50%) scale(1); opacity: 0; }
}

/* Key Hints Bar */
.kb-guitar-hints {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    margin-top: 1rem;
    padding-top: 0.8rem;
    border-top: 1px solid #333;
}

.kb-hint-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.kb-hint-label {
    font-size: 0.7rem;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kb-hint-keys {
    font-size: 0.8rem;
    color: #aaa;
    font-family: monospace;
    background: #222;
    border-radius: 4px;
    padding: 2px 6px;
}

/* Rhythm Grid */
.kb-rhythm-editor-head {
    display: flex;
    justify-content: space-between;
    align-items: end;
    flex-wrap: wrap;
    gap: 1rem;
    margin-top: 0.9rem;
}

.kb-rhythm-editor-copy {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.kb-rhythm-editor-title-row {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.kb-rhythm-editor-title {
    font-size: 0.9rem;
    color: #e9eefc;
    font-weight: 700;
}

.kb-rhythm-pattern-copy-btn {
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.04);
    color: #9fb3da;
    border-radius: 999px;
    padding: 0.16rem 0.5rem;
    font-size: 0.66rem;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.kb-rhythm-pattern-copy-btn:hover {
    background: rgba(255,255,255,0.08);
    color: #edf3ff;
    border-color: rgba(255,255,255,0.2);
}

.kb-rhythm-editor-subtitle {
    font-size: 0.72rem;
    color: #7f89a7;
}

.kb-rhythm-editor-display {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.35rem;
}

.kb-rhythm-editor-display-label {
    font-size: 0.68rem;
    color: #8fa4cf;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.kb-rhythm-editor-shell {
    position: relative;
}

.kb-rhythm-preset-bar {
    margin-top: 0.75rem;
    padding: 0.7rem 0.85rem;
    border-radius: 12px;
    background: linear-gradient(180deg, rgba(24, 28, 48, 0.95) 0%, rgba(18, 22, 37, 0.95) 100%);
    border: 1px solid rgba(255,255,255,0.08);
}

.kb-rhythm-preset-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 0.5rem;
}

.kb-rhythm-preset-select-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.72rem;
    color: #93a6cf;
}

.kb-rhythm-preset-select {
    min-width: 200px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    color: #edf3ff;
    padding: 0.5rem 0.7rem;
}

.kb-rhythm-library-btn {
    background: linear-gradient(180deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.04) 100%);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 999px;
    color: #eff5ff;
    padding: 0.5rem 0.8rem;
    min-height: 38px;
    cursor: pointer;
}

.kb-rhythm-library-btn:hover {
    border-color: rgba(255,255,255,0.28);
    transform: translateY(-1px);
}

.kb-rhythm-preset-order-help {
    margin-top: 0.55rem;
    font-size: 0.7rem;
    color: #7f93bc;
}

.kb-rhythm-preset-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 0.55rem;
}

.kb-rhythm-preset-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 34px;
    padding: 0.45rem 0.65rem;
    border-radius: 999px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.05);
    color: #edf3ff;
    cursor: grab;
    transition: border-color 0.12s, background 0.12s, transform 0.12s;
}

.kb-rhythm-preset-chip:hover {
    border-color: rgba(255,255,255,0.24);
    transform: translateY(-1px);
}

.kb-rhythm-preset-chip.active {
    background: linear-gradient(135deg, rgba(247, 213, 96, 0.22) 0%, rgba(216, 140, 22, 0.18) 100%);
    border-color: rgba(247, 213, 96, 0.6);
}

.kb-rhythm-preset-chip.dragging {
    opacity: 0.55;
    cursor: grabbing;
}

.kb-rhythm-preset-chip-drop-before {
    box-shadow: inset 3px 0 0 #f7d560;
}

.kb-rhythm-preset-chip-drop-after {
    box-shadow: inset -3px 0 0 #f7d560;
}

.kb-rhythm-preset-chip-handle {
    color: #7b8eb7;
    font-size: 0.72rem;
    letter-spacing: -0.08em;
}

.kb-rhythm-preset-chip-slot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 999px;
    background: rgba(255,255,255,0.08);
    color: #f7d560;
    font-size: 0.74rem;
    font-weight: 700;
}

.kb-rhythm-preset-chip-label {
    font-size: 0.78rem;
    white-space: nowrap;
}

.kb-rhythm-preset-status {
    margin-top: 0.45rem;
    min-height: 1.1em;
    font-size: 0.72rem;
    color: #8ea4d2;
}

.kb-rhythm-palette {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    width: min(420px, 92vw);
    background: linear-gradient(180deg, #1c2137 0%, #131829 100%);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 16px;
    padding: 0.9rem;
    box-shadow: 0 18px 40px rgba(0,0,0,0.35);
    z-index: 15;
    display: none;
}

.kb-rhythm-palette.open {
    display: block;
}

.kb-rhythm-palette-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.kb-rhythm-palette-header-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.kb-rhythm-palette-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: #f7fbff;
}

.kb-rhythm-palette-close {
    border: 0;
    background: rgba(255,255,255,0.08);
    color: #dce8ff;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    cursor: pointer;
}

.kb-rhythm-palette-expand {
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.04);
    color: #dce8ff;
    border-radius: 999px;
    padding: 0.35rem 0.65rem;
    font-size: 0.72rem;
    cursor: pointer;
}

.kb-rhythm-palette-status {
    margin-top: 0.45rem;
    font-size: 0.72rem;
    color: #8ea4d2;
    min-height: 1.1em;
}

.kb-rhythm-palette-editor {
    margin-top: 0.75rem;
    padding: 0.7rem 0.8rem;
    border-radius: 12px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
}

.kb-rhythm-attribute-switch {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.kb-rhythm-palette-slider-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    font-size: 0.72rem;
    color: #9eb2d9;
}

.kb-rhythm-palette-amplitude {
    width: 100%;
}

.kb-rhythm-palette-attribute-row {
    margin-top: 0.55rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
}

.kb-rhythm-attribute-chip {
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.04);
    color: #dce8ff;
    border-radius: 999px;
    padding: 0.3rem 0.6rem;
    font-size: 0.7rem;
    cursor: pointer;
}

.kb-rhythm-attribute-chip.active {
    background: linear-gradient(135deg, rgba(247, 213, 96, 0.2) 0%, rgba(216, 140, 22, 0.18) 100%);
    border-color: rgba(247, 213, 96, 0.45);
    color: #fff4cc;
}

.kb-rhythm-attribute-panel {
    margin-top: 0.75rem;
}

.kb-rhythm-attribute-panel[hidden] {
    display: none;
}

.kb-rhythm-palette-amplitude-value {
    font-size: 0.78rem;
    font-weight: 700;
    color: #f7fbff;
}

.kb-rhythm-palette-shortcut-hint {
    font-size: 0.68rem;
    color: #8fa4cf;
}

.kb-rhythm-palette-mute-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.45rem;
}

.kb-rhythm-mute-btn {
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(255,255,255,0.05);
    color: #edf3ff;
    border-radius: 999px;
    padding: 0.38rem 0.7rem;
    font-size: 0.76rem;
    cursor: pointer;
    transition: border-color 0.12s, background 0.12s, transform 0.12s;
}

.kb-rhythm-mute-btn:hover {
    border-color: rgba(255,255,255,0.24);
    transform: translateY(-1px);
}

.kb-rhythm-mute-btn.active {
    background: linear-gradient(135deg, #f7d560 0%, #d88c16 100%);
    color: #20160b;
    border-color: transparent;
}

.kb-rhythm-palette-input-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-top: 0.7rem;
    font-size: 0.72rem;
    color: #9eb2d9;
}

.kb-rhythm-palette-input {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 10px;
    color: #edf3ff;
    padding: 0.55rem 0.7rem;
}

.kb-rhythm-palette-groups {
    display: grid;
    gap: 0.7rem;
    margin-top: 0.8rem;
}

.kb-rhythm-palette:not(.expanded) .kb-rhythm-palette-groups {
    display: none;
}

.kb-rhythm-palette-group-label {
    font-size: 0.68rem;
    color: #7f89a7;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.28rem;
}

.kb-rhythm-palette-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.kb-rhythm-preset-btn {
    background: linear-gradient(180deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.04) 100%);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 999px;
    color: #eff5ff;
    padding: 0.42rem 0.7rem;
    min-width: 44px;
    font-size: 0.78rem;
    cursor: pointer;
}

.kb-rhythm-preset-btn:hover {
    border-color: rgba(255,255,255,0.28);
    transform: translateY(-1px);
}

.kb-rhythm-preset-btn.active {
    background: linear-gradient(135deg, #f7d560 0%, #d88c16 100%);
    color: #20160b;
    border-color: transparent;
}

.kb-guitar-rhythm-grid {
    display: flex;
    gap: 3px;
    margin-top: 0.8rem;
    padding: 0.5rem;
    background: #151530;
    border-radius: 8px;
}

.kb-rhythm-cell {
    flex: 1;
    height: 24px;
    background: #1c1f2b;
    border-radius: 3px;
    transition: box-shadow 0.12s, border-color 0.12s;
    cursor: pointer;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.08);
    overflow: hidden;
}

.kb-rhythm-cell.kb-rhythm-selected {
    outline: 2px solid rgba(255,255,255,0.9);
    outline-offset: 3px;
}

.kb-rhythm-cell-label {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: rgba(255,255,255,0.9);
    pointer-events: none;
    text-transform: uppercase;
}

.kb-rhythm-cell.kb-rhythm-pluck .kb-rhythm-cell-label {
    color: #f8fbff;
}

.kb-rhythm-cell:hover {
    border-color: rgba(255, 255, 255, 0.25);
}

/* Every 4th cell gets a subtle left border for beat grouping */
.kb-rhythm-cell:nth-child(4n+1) {
    border-left: 2px solid #444;
}

/* Direction color variables */
.kb-rhythm-cell.kb-rhythm-down {
    --kb-rhythm-fill-color: linear-gradient(180deg, #ffd451 0%, #e8a90a 100%);
    --kb-rhythm-accent: rgba(255, 212, 81, 0.8);
}

.kb-rhythm-cell.kb-rhythm-up {
    --kb-rhythm-fill-color: linear-gradient(180deg, #66c8ff 0%, #2482d8 100%);
    --kb-rhythm-accent: rgba(102, 200, 255, 0.8);
}

.kb-rhythm-cell.kb-rhythm-pluck {
    --kb-rhythm-fill-color: linear-gradient(180deg, #8ff0b5 0%, #1f9f64 100%);
    --kb-rhythm-accent: rgba(143, 240, 181, 0.8);
}

/* Non-direction (non-playing) cells should be very dark to read as inactive */
.kb-rhythm-cell:not(.kb-rhythm-down):not(.kb-rhythm-up) {
    --kb-rhythm-fill-color: linear-gradient(180deg, #050507 0%, #0f1113 100%);
    --kb-rhythm-accent: rgba(40, 42, 48, 0.85);
}

/* Default mode: inherit global mute and show glow ring */

/* Default state: thick, prominent, fancy border always visible */
.kb-rhythm-cell.kb-mute-default {
    /* border: 3px solid;
    border-image: linear-gradient(135deg, #ffe066 0%, #fffbe6 40%, #ffe066 100%) 1; */
    box-shadow:
        0 0 0 2px #fffbe6,
        0 2px 8px 0 rgba(255, 224, 102, 0.18),
        0 0 0 4px rgba(255, 224, 102, 0.10);
    z-index: 2;
}

/* Ensure border always surrounds the full block, even when fill is squished */
.kb-rhythm-cell.kb-mute-default .kb-rhythm-mute-badge,
.kb-rhythm-cell.kb-mute-default .kb-rhythm-visual,
.kb-rhythm-cell.kb-mute-default .kb-rhythm-fill,
.kb-rhythm-cell.kb-mute-default .kb-rhythm-metal {
    border-radius: 0;
}

/* Manual mode removes glow ring */
.kb-rhythm-cell.kb-mute-none,
.kb-rhythm-cell.kb-mute-light,
.kb-rhythm-cell.kb-mute-heavy,
.kb-rhythm-cell.kb-mute-full {
    box-shadow: none;
}

.kb-rhythm-cell.kb-rhythm-playhead {
    /* Visible outer ring that sits outside the element border */
    outline: 3px solid rgba(255,255,255,0.95);
    outline-offset: 6px;
    box-shadow: 0 0 16px var(--kb-rhythm-accent);
    z-index: 6;
}

/* Brighten the fill slightly so the playing cell reads even when borders are present */
.kb-rhythm-cell.kb-rhythm-playhead .kb-rhythm-fill {
    filter: brightness(1.25) saturate(1.2);
    transform: translateY(-1px);
}

/* Badge now fills the cell and renders squashed color at the bottom */
.kb-rhythm-mute-badge {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.kb-rhythm-visual {
    position: relative;
    width: 100%;
    height: 100%;
}

.kb-rhythm-fill {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 0;
    background: var(--kb-rhythm-fill-color);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 -1px 0 rgba(0, 0, 0, 0.2);
    transition: height 0.12s ease-out;
}

.kb-rhythm-metal {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 100%;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, rgba(183, 193, 218, 0.04) 24%, rgba(36, 41, 56, 0.38) 100%),
        repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.03) 0 3px, rgba(0, 0, 0, 0.04) 3px 6px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    transition: height 0.12s ease-out;
}

/* Responsive */
@media (max-width: 900px) {
    .kb-guitar-chord-slot {
        width: 110px;
        min-width: 100px;
    }
}

@media (max-width: 600px) {
    .kb-guitar-chord-row {
        gap: 0.3rem;
    }
    .kb-guitar-chord-slot {
        width: 90px;
        min-width: 80px;
        padding: 0.4rem;
    }
    .kb-guitar-hints {
        gap: 0.8rem;
    }
}
