/* Drum machine - 16-step, 4-voice sequencer grid with a moving playhead. */

.drum-machine {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* --- Transport row --- */

.dm-transport {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1rem;
    box-shadow: var(--shadow);
}

.dm-bpm {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.dm-bpm-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.dm-bpm-input {
    width: 5rem;
    text-align: center;
}

/* --- Grid --- */

/* Horizontal scroll keeps the 16 columns usable on narrow screens. */
.dm-grid-scroll {
    overflow-x: auto;
    padding: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 1rem;
    box-shadow: var(--shadow);
}

.dm-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: max-content;
}

.dm-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dm-row-label {
    flex: 0 0 auto;
    width: 3.5rem;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Square step cells. */
.dm-cell {
    flex: 0 0 auto;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 0.4rem;
    background: var(--bg);
    cursor: pointer;
    transition: background 0.08s ease, border-color 0.08s ease, transform 0.08s ease;
}

.dm-cell:hover {
    border-color: var(--accent);
}

.dm-cell:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Downbeats (every 4th column) get a subtle tint to read the bar. */
.dm-cell--downbeat {
    background: var(--accent-weak);
}

/* An active (programmed) hit. */
.dm-cell--active {
    background: var(--accent);
    border-color: var(--accent);
}

/* The current playhead column. */
.dm-cell--playing {
    box-shadow: inset 0 0 0 2px var(--good);
    transform: scale(1.04);
}

.dm-cell--active.dm-cell--playing {
    box-shadow: inset 0 0 0 2px var(--good);
}

@media (max-width: 480px) {
    .dm-cell {
        width: 1.9rem;
        height: 1.9rem;
    }

    .dm-bpm {
        margin-left: 0;
    }
}
