/* music/styles.css — matches attieretief.com aesthetic */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --color-bg: #0a0a0f;
    --color-surface: #12121a;
    --color-surface-2: #1a1a24;
    --color-border: rgba(255, 255, 255, 0.08);
    --color-border-strong: rgba(255, 255, 255, 0.15);
    --color-text: #e8e8ed;
    --color-text-muted: #8a8a9a;
    --color-text-faint: rgba(255, 255, 255, 0.45);
    --color-accent: #6366f1;
    --color-accent-bright: #818cf8;
    --color-accent-glow: rgba(99, 102, 241, 0.15);
    --color-success: #10b981;
    --color-danger: #ef4444;
    --radius: 12px;
    --radius-sm: 8px;
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "SF Mono", Menlo, Monaco, "Cascadia Mono", Consolas, monospace;
}

html, body { height: 100%; }

body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Page-level dark gradient background (subtle) */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    background:
        radial-gradient(circle at 20% 0%, rgba(99, 102, 241, 0.10), transparent 50%),
        radial-gradient(circle at 80% 100%, rgba(99, 102, 241, 0.06), transparent 50%);
    z-index: -1;
    pointer-events: none;
}

/* === Top bar === */
.topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
    background: rgba(10, 10, 15, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--color-text);
    text-decoration: none;
}

.topbar-brand .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-accent);
    box-shadow: 0 0 12px var(--color-accent-glow);
}

.topbar-section {
    color: var(--color-text-muted);
    font-size: 0.95rem;
    font-weight: 500;
}

.topbar-spacer { flex: 1; }

.editing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.3rem 0.7rem;
    margin-left: 0.5rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: var(--radius-sm);
    max-width: 24rem;
    overflow: hidden;
}

.editing-indicator-label {
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    font-size: 0.7rem;
    color: var(--color-accent-bright);
}

.editing-indicator-title {
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-link {
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    transition: color 0.2s, background 0.2s;
}

.topbar-link:hover {
    color: var(--color-text);
    background: rgba(255, 255, 255, 0.04);
}

.topbar-back {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-left: 0.75rem;
    padding: 0.4rem 0.75rem 0.4rem 0.55rem;
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    transition: color 0.2s, background 0.2s, border-color 0.2s;
}

.topbar-back:hover {
    color: var(--color-text);
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--color-border-strong);
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 0.95rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border-strong);
    background: rgba(255, 255, 255, 0.03);
    color: var(--color-text);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.btn:hover { border-color: var(--color-accent); background: rgba(99, 102, 241, 0.08); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn:disabled:hover { border-color: var(--color-border-strong); background: rgba(255, 255, 255, 0.03); }

.btn-primary {
    border-color: var(--color-accent);
    background: var(--color-accent);
    color: white;
}
.btn-primary:hover { background: var(--color-accent-bright); border-color: var(--color-accent-bright); }

.btn-icon { padding: 0.55rem; }
.btn-icon svg { width: 16px; height: 16px; }

.btn svg {
    width: 14px;
    height: 14px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* === Layout === */
.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.workspace {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--color-border);
    overflow: hidden;
}

.pane {
    background: var(--color-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.pane-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.7rem 1rem;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
    flex-shrink: 0;
}

.pane-header-label { display: flex; align-items: center; gap: 0.4rem; }
.pane-header-meta { font-size: 0.7rem; color: var(--color-text-faint); text-transform: none; letter-spacing: 0; }

.editor-textarea {
    flex: 1;
    width: 100%;
    border: none;
    outline: none;
    resize: none;
    padding: 1rem 1.25rem;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.7;
    background: transparent;
    color: var(--color-text);
    tab-size: 2;
}

.editor-textarea::placeholder { color: var(--color-text-faint); }

.score-render {
    flex: 1;
    overflow: auto;
    padding: 1.25rem;
    background: #fafafa;
    color: #1a1a1a;
}

.score-render svg text { fill: #1a1a1a; }
.score-render svg path { fill: #1a1a1a; stroke: #1a1a1a; }

.score-render svg {
    max-width: 100%;
    height: auto;
}

/* === Transport bar === */
.transport {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 1.5rem;
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
    flex-wrap: wrap;
    flex-shrink: 0;
}

.transport-group {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.transport-divider {
    width: 1px;
    height: 24px;
    background: var(--color-border);
    margin: 0 0.25rem;
}

.transport label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.transport input[type=range] {
    -webkit-appearance: none;
    appearance: none;
    width: 110px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.transport input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--color-accent);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--color-bg);
    box-shadow: 0 0 0 1px var(--color-accent);
}

.transport input[type=range]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    background: var(--color-accent);
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid var(--color-bg);
    box-shadow: 0 0 0 1px var(--color-accent);
}

.transport-value {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    font-weight: 500;
    min-width: 28px;
    text-align: right;
    color: var(--color-text);
}

.transport-status {
    margin-left: auto;
    font-size: 0.78rem;
    color: var(--color-text-faint);
}

/* === Modal / dialog === */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 2rem;
    max-width: 420px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.modal p {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
    line-height: 1.6;
}

.modal label {
    display: block;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.modal input[type=password],
.modal input[type=text] {
    width: 100%;
    padding: 0.7rem 0.9rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-family: inherit;
    font-size: 0.95rem;
    margin-bottom: 1rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.modal input:focus { border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-glow); }

.modal-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 0.5rem;
}

.modal-error {
    color: var(--color-danger);
    font-size: 0.8rem;
    margin-top: -0.5rem;
    margin-bottom: 1rem;
    min-height: 1.2em;
}

.modal-help {
    font-size: 0.78rem;
    color: var(--color-text-faint);
    margin-top: -0.5rem;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.modal-help a { color: var(--color-accent-bright); text-decoration: none; }
.modal-help a:hover { text-decoration: underline; }

/* === Toast === */
.toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1.25rem;
    font-size: 0.875rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    z-index: 200;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    max-width: 90vw;
    animation: toastIn 0.3s ease;
}

@keyframes toastIn {
    from { opacity: 0; transform: translate(-50%, 12px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

.toast.success { border-color: var(--color-success); }
.toast.error { border-color: var(--color-danger); }

/* === Library page === */
.library-container {
    max-width: 880px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

.library-header {
    margin-bottom: 2rem;
}

.library-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.4rem;
}

.library-header p {
    color: var(--color-text-muted);
    font-size: 0.95rem;
}

.score-toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

#score-search {
    flex: 1;
    padding: 0.6rem 0.9rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text);
    font-family: inherit;
    font-size: 0.9rem;
    transition: border-color 0.2s, background 0.2s;
}

#score-search:focus {
    outline: none;
    border-color: var(--color-accent);
    background: rgba(99, 102, 241, 0.04);
}

#score-search::placeholder { color: var(--color-text-faint); }

.score-count {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.score-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--color-surface);
}

.score-list li + li { border-top: 1px solid var(--color-border); }

.score-row-main {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 0.7rem;
    padding: 0.6rem 1rem;
    text-decoration: none;
    color: inherit;
    transition: background 0.15s, color 0.15s;
}

.score-row-main:hover { background: rgba(99, 102, 241, 0.06); }
.score-row-main:hover .score-row-title { color: var(--color-accent-bright); }
.score-row-main:hover .score-row-icon { color: var(--color-accent-bright); }

.score-row-icon {
    display: inline-flex;
    align-items: center;
    color: var(--color-text-muted);
    transition: color 0.15s;
}

.score-row-title {
    font-size: 0.95rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.score-row-meta {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.score-empty {
    padding: 1.5rem 1rem;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 0.9rem;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius);
}

.empty-state {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--color-text-muted);
}

.empty-state h3 { color: var(--color-text); font-size: 1.1rem; margin-bottom: 0.5rem; }
.empty-state p { font-size: 0.9rem; margin-bottom: 1.5rem; }

/* === Viewer page === */
.viewer-container {
    margin: 0 auto;
    padding: 2rem 2rem 4rem;
}

.viewer-disclaimer {
    margin-top: 2rem;
    font-size: 0.78rem;
    line-height: 1.55;
    color: var(--color-text-muted);
    opacity: 0.7;
    max-width: 60ch;
}
.viewer-disclaimer a { color: var(--color-text-muted); text-decoration: underline; }
.viewer-disclaimer a:hover { color: var(--color-accent-bright); }

.viewer-header {
    margin-bottom: 1.5rem;
}

.viewer-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 0.3rem;
}

.viewer-header .subtitle {
    color: var(--color-text-muted);
    font-size: 0.95rem;
}

.viewer-score {
    background: white;
    color: #1a1a1a;
    border-radius: var(--radius);
    padding: 2.5rem 3rem;
    overflow: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    margin-top: 1.25rem;
}

.viewer-score svg { width: 100% !important; height: auto; max-width: none !important; }
.viewer-score svg text { fill: #1a1a1a; }
.viewer-score svg path { fill: #1a1a1a; stroke: #1a1a1a; }

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

.btn-yt {
    color: #ff5c5c;
    border-color: rgba(255, 0, 0, 0.25);
    background: rgba(255, 0, 0, 0.08);
}
.btn-yt:hover {
    color: white;
    background: #cc0000;
    border-color: #cc0000;
}

/* === Spinner === */
.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* === abcjs cursor styling override === */
.abcjs-cursor {
    stroke: var(--color-accent);
    stroke-width: 2;
}

.score-render svg .abcjs-highlight,
.score-render svg .abcjs-highlight *,
.score-render svg path.abcjs-highlight,
.score-render svg text.abcjs-highlight,
.viewer-score svg .abcjs-highlight,
.viewer-score svg .abcjs-highlight *,
.viewer-score svg path.abcjs-highlight,
.viewer-score svg text.abcjs-highlight,
.abcjs-note_selected {
    fill: var(--color-accent) !important;
    stroke: var(--color-accent) !important;
}

/* === Mobile === */
@media (max-width: 768px) {
    .topbar {
        padding: 0.75rem 1rem;
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .topbar-section { display: none; }
    .editing-indicator { display: none; }

    .workspace {
        grid-template-columns: 1fr;
        grid-template-rows: minmax(220px, 1fr) minmax(280px, 1fr);
    }

    .editor-textarea {
        font-size: 14px;
        padding: 0.85rem 1rem;
    }

    .transport {
        padding: 0.75rem 1rem;
        gap: 0.4rem;
    }

    .transport label { font-size: 0.75rem; gap: 0.35rem; }
    .transport input[type=range] { width: 80px; }
    .transport-divider { display: none; }
    .transport-status { width: 100%; margin-left: 0; margin-top: 0.4rem; text-align: center; }
    .transport-group { flex: 1 1 auto; justify-content: center; }

    .modal { padding: 1.5rem; }
    .modal h2 { font-size: 1.1rem; }

    .library-container { padding: 1.25rem 1rem 3rem; }
    .library-header h1 { font-size: 1.4rem; }
    .viewer-container { padding: 1.25rem 0.75rem 3rem; }
    .viewer-header h1 { font-size: 1.4rem; }
    .viewer-score { padding: 1.5rem 1rem; }
}

/* === Reduced motion === */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
