/* ============================================================
   Drum Notation Vex — Frontend Stylesheet v1.5
   Dark theme, full-width, multi-row sheet music on mobile
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Space+Mono:wght@400;700&display=swap');

.dnv-wrapper {
    --bg:      #0d1117;
    --surface: #161b22;
    --border:  #21262d;
    --accent:  #f0c040;
    --accent2: #e05a5a;
    --text:    #e6edf3;
    --muted:   #6e7681;
    --note-col:#ffffff;

    font-family: 'Space Mono', monospace;
    background: var(--bg);
    color: var(--text);
    width: 100%;
    margin: 0;
    padding: 0;
    position: relative;
    overflow: visible;
}

/* ── Header ── */
.dnv-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 16px 0 22px;
    height: 52px;
    background: linear-gradient(180deg, #f8f9fa 0%, #e8ecf0 100%);
    border-bottom: 1px solid #d0d5dd;
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    gap: 12px;
}

.dnv-title {
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
    font-weight: 700;
    font-size: clamp(0.88rem, 3vw, 1.1rem);
    letter-spacing: 0.01em;
    color: #1a2a3a;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Mobile header action buttons — hidden on desktop */
.dnv-header-mobile-actions {
    display: none;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.dnv-header-mobile-actions .dnv-metro-btn {
    width: 34px; height: 34px; border-radius: 8px;
}
.dnv-header-mobile-actions .dnv-metro-icon { width: 18px; height: 18px; }
.dnv-header-mobile-actions .dnv-pdf-btn {
    height: 34px; padding: 0 10px;
    font-size: 0; /* hide text, show icon only */
    gap: 0;
}
.dnv-header-mobile-actions .dnv-pdf-btn svg { width: 16px; height: 16px; }

/* ── BPM steppers (mobile only, hidden on desktop) ── */
.dnv-bpm-steppers {
    display: none;
    align-items: center;
    gap: 4px;
}
.dnv-bpm-step {
    width: 30px; height: 30px;
    border-radius: 6px;
    border: 1.5px solid #c0ccd8;
    background: linear-gradient(180deg, #f0f4f8 0%, #dce4ec 100%);
    color: #3a5a7a;
    font-size: 0.68rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.1s;
    white-space: nowrap;
    flex-shrink: 0;
    line-height: 1;
    padding: 0;
}
.dnv-bpm-step:hover { background: linear-gradient(180deg, #dce8f4 0%, #c0d4e8 100%); border-color: #8ab0cc; }
.dnv-bpm-step:active { transform: scale(0.93); }
.dnv-bpm-readout-mobile {
    font-size: 0.9rem; font-weight: 700; color: #1a2a3a;
    min-width: 30px; text-align: center;
    font-variant-numeric: tabular-nums;
}

/* ── Sheet music canvas area ── */
.dnv-notation-area {
    background: #ffffff;
    width: 100%;
    overflow: visible;
    padding: 0;
    margin: 0;
    border-bottom: 1px solid #d0d5dd;
}

.dnv-canvas {
    display: block;
    width: 100%;
    position: relative;
    /* Height is set explicitly by JS via style.height — do NOT use height:auto */
}

.dnv-canvas svg {
    display: block;
    /* VexFlow renders at exactly canvas.offsetWidth px — do not rescale via CSS,
       or the playhead overlay's pixel-based positioning will drift out of sync. */
}

.dnv-playhead {
    position: absolute;
    top: 0;
    width: 2px;
    background: rgba(230, 57, 70, 0.6);
    pointer-events: none;
    display: none;
}

/* ── Controls bar — white, clean, professional ── */
.dnv-controls {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0 22px;
    height: 68px;
    background: #f0f4f8;
    background: linear-gradient(180deg, #f8f9fa 0%, #e8ecf0 100%);
    border-top: 1px solid #d0d5dd;
    border-bottom: 1px solid #d0d5dd;
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

/* Transport group */
.dnv-transport {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.dnv-btn {
    display: flex; align-items: center; justify-content: center;
    border: none; cursor: pointer; transition: all 0.12s ease;
    flex-shrink: 0;
    outline: none;
    position: relative;
}

/* ── 3D Glassy button base ── */
.dnv-play-btn,
.dnv-stop-btn {
    width: 48px; height: 48px;
    border-radius: 50%;
    background:
        radial-gradient(circle at 38% 35%, #e8f4ff 0%, #b8d4ec 30%, #7aaacb 60%, #4a7a9b 80%, #2a5a7b 100%);
    box-shadow:
        0 0 0 2.5px #8ab0cc,
        0 0 0 4px #5a8aaa,
        0 4px 12px rgba(0,0,0,0.35),
        0 2px 4px rgba(0,0,0,0.2),
        inset 0 1px 0 rgba(255,255,255,0.5);
    position: relative;
    overflow: visible;
}

/* Glassy shine overlay — sits on top but pointer-events:none, does not block clicks */
.dnv-play-btn::before,
.dnv-stop-btn::before {
    content: '';
    position: absolute;
    top: 3px; left: 6px; right: 6px;
    height: 44%;
    border-radius: 50% 50% 40% 40% / 60% 60% 40% 40%;
    background: linear-gradient(180deg,
        rgba(255,255,255,0.72) 0%,
        rgba(255,255,255,0.08) 100%);
    pointer-events: none;
    /* Don't let shine escape the circle */
    clip-path: circle(50% at 50% 50%);
}

/* Icon inside button — always on top, always white */
.dnv-play-btn svg,
.dnv-stop-btn svg {
    fill: #ffffff;
    color: #ffffff;
    filter: drop-shadow(0 1px 3px rgba(0,0,0,0.5));
    flex-shrink: 0;
}
.dnv-play-btn svg { width: 18px; height: 18px; margin-left: 2px; }
.dnv-stop-btn svg { width: 14px; height: 14px; }

/* Hover: slightly brighter */
.dnv-play-btn:hover,
.dnv-stop-btn:hover {
    background:
        radial-gradient(circle at 38% 35%, #f0faff 0%, #cce4f5 30%, #8ec0dc 60%, #5a90bb 80%, #3a6a8b 100%);
    transform: translateY(-1px) scale(1.04);
    box-shadow:
        0 0 0 2.5px #8ab0cc,
        0 0 0 4px #5a8aaa,
        0 6px 16px rgba(0,0,0,0.4),
        0 3px 6px rgba(0,0,0,0.25),
        inset 0 1px 0 rgba(255,255,255,0.55);
}

/* Active / pressed */
.dnv-play-btn:active,
.dnv-stop-btn:active {
    transform: translateY(1px) scale(0.97);
    box-shadow:
        0 0 0 2.5px #8ab0cc,
        0 0 0 4px #5a8aaa,
        0 1px 4px rgba(0,0,0,0.3),
        inset 0 2px 4px rgba(0,0,0,0.2);
}

/* Playing state — red glassy */
.dnv-play-btn.playing {
    background:
        radial-gradient(circle at 38% 35%, #ffe8e8 0%, #f0a0a0 30%, #d06060 60%, #b03030 80%, #8a1818 100%);
    box-shadow:
        0 0 0 2.5px #d08888,
        0 0 0 4px #a05050,
        0 4px 12px rgba(180,0,0,0.4),
        0 2px 4px rgba(0,0,0,0.2),
        inset 0 1px 0 rgba(255,255,255,0.5);
}

/* Divider */
.dnv-ctrl-sep {
    width: 1px; height: 30px;
    background: linear-gradient(180deg, transparent, #c8cdd4, transparent);
    margin: 0 20px;
    flex-shrink: 0;
}

/* BPM section */
.dnv-bpm-control {
    display: flex; align-items: center; gap: 10px;
    flex-shrink: 0;
}
.dnv-bpm-label {
    font-size: 0.6rem;
    font-weight: 700;
    color: #8a9ab0;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    white-space: nowrap;
}
.dnv-bpm-readout {
    font-size: 0.92rem;
    font-weight: 700;
    color: #1a2a3a;
    min-width: 34px;
    text-align: left;
    font-variant-numeric: tabular-nums;
}
.dnv-bpm-slider {
    width: 110px;
    -webkit-appearance: none; appearance: none;
    height: 4px;
    background: linear-gradient(90deg, #a0b8cc 0%, #d0dce8 100%);
    border-radius: 99px;
    outline: none; cursor: pointer;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.15);
}
.dnv-bpm-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px; height: 16px;
    background: radial-gradient(circle at 40% 35%, #e8f4ff, #7aaacb 60%, #4a7a9b);
    border-radius: 50%;
    cursor: pointer;
    box-shadow:
        0 0 0 1.5px #5a8aaa,
        0 2px 6px rgba(0,0,0,0.3),
        inset 0 1px 0 rgba(255,255,255,0.6);
}
.dnv-bpm-slider::-moz-range-thumb {
    width: 16px; height: 16px;
    background: #7aaacb;
    border: 1.5px solid #5a8aaa;
    border-radius: 50%; cursor: pointer;
}

/* Metronome icon button */
.dnv-metronome { display: flex; align-items: center; }

.dnv-metro-btn {
    width: 38px; height: 38px;
    border-radius: 8px;
    background: transparent;
    border: 1.5px solid #d0d5dd;
    color: #8a9ab0;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
    padding: 0;
}
.dnv-metro-btn:hover {
    border-color: #7aaacb;
    color: #3a5a7a;
    background: #f0f6fc;
}
.dnv-metro-btn.active {
    background: linear-gradient(180deg, #e8f0f8 0%, #ccd8e8 100%);
    border-color: #7aaacb;
    color: #2a5a7a;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.1);
}
.dnv-metro-icon { width: 20px; height: 20px; }
/* Pendulum arm swings when active */
@keyframes dnv-swing {
    0%,100% { transform-origin: 12px 18px; transform: rotate(-18deg); }
    50%      { transform-origin: 12px 18px; transform: rotate(18deg); }
}
.dnv-metro-btn.active .dnv-metro-arm {
    animation: dnv-swing 0.5s ease-in-out infinite;
}

/* Kit selector in controls bar */
.dnv-kit-control {
    display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.dnv-kit-player-sel {
    height: 32px; padding: 0 8px;
    background: linear-gradient(180deg, #f0f4f8 0%, #dce4ec 100%);
    border: 1.5px solid #b0c0d0;
    border-radius: 6px;
    color: #2a4a6a;
    font-family: inherit; font-size: 0.74rem; font-weight: 600;
    cursor: pointer; outline: none;
    transition: border-color 0.12s;
    min-width: 120px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
}
.dnv-kit-player-sel:hover { border-color: #7aaacb; }
.dnv-kit-player-sel:focus { border-color: #5a8aaa; outline: none; }

/* Spacer */
.dnv-ctrl-spacer { flex: 1; }

/* PDF button — glassy pill */
.dnv-pdf-btn {
    display: flex; align-items: center; gap: 6px;
    height: 36px; padding: 0 16px;
    background: linear-gradient(180deg, #e8f0f8 0%, #ccd8e8 100%);
    border: 1.5px solid #9ab0c8;
    border-radius: 99px;
    color: #3a5a7a;
    font-family: inherit;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: all 0.12s;
    white-space: nowrap;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12), inset 0 1px 0 rgba(255,255,255,0.7);
}
.dnv-pdf-btn:hover {
    background: linear-gradient(180deg, #cce0f4 0%, #a8c4dc 100%);
    border-color: #7aaacb; color: #1a3a5a;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.7);
}
.dnv-pdf-btn:active { transform: translateY(0); }
.dnv-pdf-btn svg { width: 13px; height: 13px; flex-shrink: 0; }

/* ── Mobile responsive ── */
@media (max-width: 520px) {
    /* Header: show mobile action buttons */
    .dnv-header-mobile-actions { display: flex; }

    /* Controls: smaller buttons */
    .dnv-controls { padding: 0 10px; height: 52px; }
    .dnv-play-btn { width: 36px; height: 36px; }
    .dnv-stop-btn { width: 28px; height: 28px; }
    .dnv-play-btn svg { width: 13px; height: 13px; }
    .dnv-stop-btn svg { width: 11px; height: 11px; }
    .dnv-ctrl-sep { margin: 0 8px; }
    .dnv-transport { gap: 6px; }
    .dnv-bpm-label { display: none; }

    /* BPM: hide slider, show steppers */
    .dnv-bpm-slider { display: none; }
    .dnv-bpm-readout:not(.dnv-bpm-readout-mobile) { display: none; }
    .dnv-bpm-steppers { display: flex; }

    /* Hide metro + PDF from controls bar (now in header) */
    .dnv-ctrl-desktop { display: none !important; }
    .dnv-ctrl-sep-desktop { display: none !important; }

    /* Spacer not needed on mobile (pdf/metro moved to header) */
    .dnv-ctrl-spacer { display: none; }
}

/* ── Step indicator — hidden ── */
.dnv-step-indicator { display: none; }

/* ── Context menu for snare variants ── */
.dnv-ctx-menu {
    position: fixed;
    background: #1c2128;
    border: 1px solid #30363d;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.6);
    z-index: 99999;
    min-width: 170px;
    overflow: hidden;
    font-family: 'Space Mono', monospace;
    font-size: 0.78rem;
}
.dnv-ctx-title {
    padding: 8px 12px 6px;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: #6e7681;
    border-bottom: 1px solid #21262d;
}
.dnv-ctx-item {
    padding: 9px 14px;
    cursor: pointer;
    color: #e6edf3;
    display: flex; align-items: center; gap: 10px;
    transition: background 0.1s;
}
.dnv-ctx-item:hover { background: #21262d; }
.dnv-ctx-item.active { background: rgba(240,192,64,0.12); color: #f0c040; }
.dnv-ctx-badge {
    font-size: 0.65rem; padding: 1px 6px;
    border-radius: 10px; background: rgba(255,255,255,0.08);
    color: #aaa; flex-shrink: 0;
}
