/* ═══════════════════════════════════════════════════════════════
   abc-player.css — Styles for ABC Live Player (Minimal Build)
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Reset & Base ─────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg-primary: #f4f1ea;
    /* warm parchment background */
    --bg-secondary: #fdfbf7;
    /* slightly lighter for surfaces */
    --bg-tertiary: #eae4d8;
    /* slightly darker for audio bar */
    --bg-elevated: #ffffff;
    --surface: #fdfbf7;
    --border: #e3dccf;
    --border-focus: #8c2e2e;
    /* elegant burgundy accent */
    --text-primary: #2c2825;
    /* very dark warm gray / ink */
    --text-secondary: #635d58;
    /* faded ink */
    --text-muted: #948d85;
    --accent: #8c2e2e;
    --accent-hover: #a33838;
    --accent-glow: rgba(140, 46, 46, 0.15);
    --success: #3b82f6;
    --warning: #d97706;
    --error: #dc2626;
    --notation-bg: transparent;
    --notation-highlight: #3b82f6;
    /* calm blue highlight for notes */
    --radius-sm: 4px;
    --radius-md: 6px;
    --radius-lg: 8px;
    --shadow-sm: 0 1px 2px rgba(44, 40, 37, 0.05);
    --shadow-md: 0 4px 12px rgba(44, 40, 37, 0.08);
    --shadow-lg: 0 8px 24px rgba(44, 40, 37, 0.12);
    --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

body {
    font-family: 'Inter', Georgia, serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Layout ───────────────────────────────────────────────── */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.app-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.app-title .icon {
    font-size: 22px;
}

.zoom-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-right: 12px;
}

.zoom-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 18px;
    line-height: 1;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.zoom-btn:hover {
    background: var(--bg-elevated);
    color: var(--accent);
    border-color: var(--accent);
}

.zoom-label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    min-width: 36px;
    text-align: center;
}

.mode-toggle {
    display: flex;
    gap: 2px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 3px;
}

.mode-btn {
    padding: 6px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.mode-btn:hover:not(:disabled) {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

.mode-btn:disabled {
    opacity: 0.4;
    cursor: default;
    text-decoration: line-through;
}

.mode-btn.active {
    color: #fff;
    background: var(--accent);
    box-shadow: 0 2px 8px var(--accent-glow);
}

/* ── Main Content ─────────────────────────────────────────── */
.app-main {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* ── Editor Panel ─────────────────────────────────────────── */
#editor-panel {
    width: 40%;
    min-width: 300px;
    min-height: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border);
    background: var(--bg-secondary);
    transition: all var(--transition);
}

#editor-panel.hidden {
    display: none;
}

.editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

#abc-editor {
    flex: 1;
    width: 100%;
    padding: 16px;
    border: none;
    outline: none;
    resize: none;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 14px;
    line-height: 1.6;
    tab-size: 2;
}

#abc-editor::placeholder {
    color: var(--text-muted);
}

#abc-editor:focus {
    background: var(--surface);
}

/* ── Panel Divider ────────────────────────────────────────── */
#panel-divider {
    width: 5px;
    flex-shrink: 0;
    cursor: col-resize;
    background: var(--border);
    transition: background var(--transition);
    position: relative;
}

#panel-divider::after {
    content: '';
    position: absolute;
    inset: 0 -4px;  /* wider hit target without affecting layout */
}

#panel-divider:hover,
#panel-divider.dragging {
    background: var(--accent);
}

#panel-divider.hidden {
    display: none;
}

/* ── Notation Panel ───────────────────────────────────────── */
#notation-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: var(--bg-primary);
    transition: all var(--transition);
}

#notation-panel.hidden {
    display: none;
}

#errors-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    background: var(--bg-primary);
    transition: all var(--transition);
}

#errors-panel.hidden {
    display: none;
}

#errors-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
    background: #fffbfa;
    border-radius: var(--radius-lg);
    border-left: 4px solid var(--warning);
    margin: 12px;
    box-shadow: var(--shadow-md);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    line-height: 1.6;
}

#errors-list strong {
    color: var(--warning);
    margin-bottom: 8px;
    display: block;
    font-size: 14px;
}

#notation {
    background: #ffffff;
    cursor: pointer;
}

/* responsive:'resize' sets width:100% and handles height via viewBox/padding-bottom */
#notation svg {
    display: block;
}

/* Force dark ink color for all notation elements */
#notation svg path,
#notation svg text {
    fill: var(--text-primary);
}

#notation svg line {
    stroke: var(--text-primary);
}

/* Seek hover — nearest note preview */
#notation svg .seek-hover path,
#notation svg .seek-hover text {
    fill: var(--accent) !important;
    opacity: 0.6;
    transition: fill 80ms ease, opacity 80ms ease;
}

/* Highlight for currently playing notes */
#notation svg .highlight,
#notation svg .highlight path,
#notation svg .highlight text {
    fill: var(--notation-highlight) !important;
    transition: fill 100ms ease;
}

/* Cursor line during playback */
#notation svg .abcjs-cursor {
    stroke: var(--notation-highlight);
    stroke-width: 2;
    opacity: 0.8;
}

.placeholder-text {
    color: var(--text-muted);
    font-size: 15px;
    text-align: center;
    padding: 48px 24px;
    font-style: italic;
}

.error-text {
    color: var(--error);
    font-size: 14px;
    padding: 24px;
    font-family: 'JetBrains Mono', monospace;
}

/* ── Audio Bar ────────────────────────────────────────────── */
#audio-bar {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border);
    padding: 10px 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
    flex-shrink: 0;
    transition: all var(--transition);
}

#audio-bar.hidden {
    display: none;
}

#audio-controls {
    width: 100%;
    max-width: 900px;
}

/* Override abcjs-audio.css dark theme to match our design */
#audio-controls .abcjs-inline-audio {
    background-color: var(--bg-tertiary);
    border-radius: var(--radius-md);
    height: 36px;
    padding: 0 10px;
}

#audio-controls .abcjs-midi-progress-background {
    background-color: var(--bg-elevated);
    border-color: var(--border);
}

#audio-controls .abcjs-midi-progress-indicator {
    background-color: var(--accent);
    border-radius: 8px;
}

#audio-controls .abcjs-btn g {
    fill: var(--text-secondary);
    stroke: var(--text-secondary);
}

#audio-controls .abcjs-btn:hover g {
    fill: var(--accent-hover);
    stroke: var(--accent-hover);
}

#audio-controls .abcjs-midi-clock {
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
}

#audio-controls .abcjs-tempo-wrapper {
    color: var(--text-muted);
    font-size: 11px;
}

/* ── Loading State ────────────────────────────────────────── */
.audio-loading {
    color: var(--text-muted);
    font-size: 13px;
    text-align: center;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
    .app-main {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 53px - 50px);
    }

    #editor-panel {
        width: 100%;
        min-width: unset;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    #notation-panel {
        min-height: 50vh;
    }

    #notation {
        margin: 0;
        padding: 0;
    }
}

/* ── Help button ──────────────────────────────────────────── */
.help-btn {
    width: 22px;
    height: 22px;
    margin-left: 8px;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition);
}

.help-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ── Modal overlay ────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(44, 40, 37, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-tertiary);
}

.modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.modal-body > p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.modal-note {
    font-size: 13px;
    color: var(--text-muted);
}

.modal-body a {
    color: var(--accent);
    text-decoration: none;
}

.modal-body a:hover {
    text-decoration: underline;
}

.modal-note code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    background: var(--bg-tertiary);
    padding: 1px 5px;
    border-radius: 3px;
}

.code-block-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: -6px;
}

.code-block {
    position: relative;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.code-block pre {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 12px;
    line-height: 1.5;
    color: var(--text-primary);
    padding: 14px 48px 14px 14px;
    white-space: pre-wrap;
    word-break: break-all;
    margin: 0;
}

.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 11px;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.copy-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ── Scrollbar styling ────────────────────────────────────── */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-elevated);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border);
}