/* ESC STUDIO — Theme system styles (esc-theme.css)
 *
 *  - Oswald headings across the app (h1-h5) + ESC chrome.
 *  - Theme tokens --esc-t-* (defaults = ESC Gold; the engine overwrites them
 *    live from the active theme).
 *  - Playhead follows the theme's playhead colour.
 *  - High-contrast mode: thicker focus outlines.
 *  - Theme Studio panel + header button.
 */

:root {
    --esc-t-accent: #d4af37;
    --esc-t-accent-bright: #ffd24a;
    --esc-t-bg: #0a0a0a;
    --esc-t-panel: #16161a;
    --esc-t-text: #f5f0dd;
    --esc-t-muted: #8a8371;
    --esc-t-playhead: #d4af37;
}

/* ---- Oswald headings across the whole app ---- */
h1, h2, h3, h4, h5 {
    font-family: "Oswald", "Arial Narrow", sans-serif;
    letter-spacing: .04em;
}

/* ---- Playhead follows the theme (the cursor element carries
        data-component="cursor" in TimeAxis.tsx) ---- */
[data-component="cursor"] {
    background-color: var(--esc-t-playhead, var(--color-bright)) !important;
}

/* ---- High-contrast mode: visible focus everywhere ---- */
.esc-high-contrast :focus-visible {
    outline: 2px solid var(--esc-t-accent-bright, #ffd24a) !important;
    outline-offset: 2px;
}

/* ---- Header "Theme" button (injected into header[data-app-header]) ---- */
.esc-theme-header-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: inherit;
    font: 400 12px/1 "Oswald", "Arial Narrow", sans-serif;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding: 6px 10px;
    cursor: pointer;
    white-space: nowrap;
}
.esc-theme-header-btn:hover {
    border-color: var(--esc-t-accent, #d4af37);
    color: var(--esc-t-accent, #d4af37);
}
.esc-theme-header-btn[aria-pressed="true"] {
    border-color: var(--esc-t-accent, #d4af37);
    color: var(--esc-t-accent, #d4af37);
    background: color-mix(in srgb, var(--esc-t-accent, #d4af37) 12%, transparent);
}
.esc-theme-header-btn svg {
    flex: 0 0 auto;
}

/* ---- Theme Studio panel (right drawer) ---- */
.esc-theme-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(380px, 92vw);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    background: var(--esc-t-bg, #0a0a0a);
    color: var(--esc-t-text, #f5f0dd);
    border-left: 1px solid var(--esc-t-accent, #d4af37);
    box-shadow: -12px 0 40px rgba(0, 0, 0, .55);
    font-family: system-ui, sans-serif;
    font-size: 13px;
    line-height: 1.45;
}
.esc-theme-panel[hidden] {
    display: none;
}

.esc-theme-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--esc-t-muted, #8a8371);
    background: var(--esc-t-panel, #16161a);
}
.esc-theme-head-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
    flex: 0 0 auto;
}
.esc-theme-title {
    margin: 0;
    flex: 1 1 auto;
    font-family: "Oswald", "Arial Narrow", sans-serif;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--esc-t-accent, #d4af37);
}
.esc-theme-close {
    background: transparent;
    border: 1px solid var(--esc-t-muted, #8a8371);
    border-radius: 6px;
    color: var(--esc-t-text, #f5f0dd);
    font-size: 18px;
    line-height: 1;
    width: 30px;
    height: 30px;
    cursor: pointer;
}
.esc-theme-close:hover {
    border-color: var(--esc-t-accent, #d4af37);
    color: var(--esc-t-accent, #d4af37);
}

.esc-theme-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px;
}
.esc-theme-section {
    margin-bottom: 22px;
}
.esc-theme-section-title {
    margin: 0 0 10px;
    font-family: "Oswald", "Arial Narrow", sans-serif;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--esc-t-accent, #d4af37);
}
.esc-theme-note {
    margin: 8px 0 0;
    font-size: 12px;
    color: var(--esc-t-muted, #8a8371);
}

/* Preset gallery */
.esc-theme-gallery {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.esc-theme-preset {
    display: block;
    width: 100%;
    padding: 0 0 8px;
    background: var(--esc-t-panel, #16161a);
    border: 1px solid var(--esc-t-muted, #8a8371);
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    text-align: left;
    color: var(--esc-t-text, #f5f0dd);
}
.esc-theme-preset:hover {
    border-color: var(--esc-t-accent, #d4af37);
}
.esc-theme-preset[aria-pressed="true"] {
    border-color: var(--esc-t-accent, #d4af37);
    box-shadow: 0 0 0 1px var(--esc-t-accent, #d4af37);
}
.esc-theme-preset-preview {
    height: 64px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.esc-theme-preset-bar {
    height: 5px;
    border-radius: 3px;
}
.esc-theme-preset-panel {
    flex: 1 1 auto;
    border-radius: 4px;
    padding: 7px 8px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}
.esc-theme-preset-line {
    height: 5px;
    border-radius: 3px;
    width: 82%;
}
.esc-theme-preset-line-short {
    width: 55%;
}
.esc-theme-preset-name {
    margin: 8px 10px 0;
    font-family: "Oswald", "Arial Narrow", sans-serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .05em;
    text-transform: uppercase;
}
.esc-theme-preset-blurb {
    margin: 2px 10px 0;
    font-size: 11px;
    line-height: 1.35;
    color: var(--esc-t-muted, #8a8371);
}

/* Colour rows */
.esc-theme-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
}
.esc-theme-row-label {
    flex: 1 1 auto;
    min-width: 0;
}
.esc-theme-swatch {
    width: 34px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--esc-t-muted, #8a8371);
    border-radius: 5px;
    background: transparent;
    cursor: pointer;
    flex: 0 0 auto;
}
.esc-theme-swatch:disabled {
    opacity: .45;
    cursor: default;
}
.esc-theme-hex {
    width: 76px;
    flex: 0 0 auto;
    background: var(--esc-t-panel, #16161a);
    color: var(--esc-t-text, #f5f0dd);
    border: 1px solid var(--esc-t-muted, #8a8371);
    border-radius: 5px;
    padding: 5px 7px;
    font-family: ui-monospace, monospace;
    font-size: 12px;
    text-transform: uppercase;
}
.esc-theme-hex:disabled {
    opacity: .45;
}
.esc-theme-lock {
    font-size: 11px;
    color: var(--esc-t-muted, #8a8371);
    flex: 0 0 auto;
}
.esc-theme-more {
    margin-top: 6px;
    border-top: 1px solid var(--esc-t-muted, #8a8371);
    padding-top: 6px;
}
.esc-theme-more-title {
    cursor: pointer;
    font-family: "Oswald", "Arial Narrow", sans-serif;
    font-size: 13px;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--esc-t-muted, #8a8371);
}
.esc-theme-derive {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    cursor: pointer;
}
.esc-theme-derive-toggle {
    accent-color: var(--esc-t-accent, #d4af37);
    width: 16px;
    height: 16px;
}

/* Background zones */
.esc-theme-zone {
    border: 1px solid var(--esc-t-muted, #8a8371);
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 10px;
}
.esc-theme-zone-title {
    margin: 0 0 8px;
    font-family: "Oswald", "Arial Narrow", sans-serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
}
.esc-theme-zone-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}
.esc-theme-zone-row:last-child {
    margin-bottom: 0;
}
.esc-theme-zone-label {
    flex: 1 1 auto;
}
.esc-theme-select {
    width: 100%;
    background: var(--esc-t-panel, #16161a);
    color: var(--esc-t-text, #f5f0dd);
    border: 1px solid var(--esc-t-muted, #8a8371);
    border-radius: 5px;
    padding: 6px 8px;
    font-size: 13px;
}
.esc-theme-lib {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}
.esc-theme-lib-thumb {
    flex: 1 1 0;
    height: 44px;
    border: 2px solid transparent;
    border-radius: 6px;
    background-size: cover;
    background-position: center;
    cursor: pointer;
    padding: 0;
}
.esc-theme-lib-thumb.selected {
    border-color: var(--esc-t-accent, #d4af37);
}
.esc-theme-upload {
    display: block;
    text-align: center;
    border: 1px dashed var(--esc-t-muted, #8a8371);
    border-radius: 6px;
    padding: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    color: var(--esc-t-muted, #8a8371);
}
.esc-theme-upload:hover {
    border-color: var(--esc-t-accent, #d4af37);
    color: var(--esc-t-accent, #d4af37);
}
.esc-theme-file {
    display: none;
}
.esc-theme-slider {
    flex: 1 1 auto;
    accent-color: var(--esc-t-accent, #d4af37);
}
.esc-theme-slider-val {
    width: 52px;
    text-align: right;
    font-family: ui-monospace, monospace;
    font-size: 12px;
    flex: 0 0 auto;
}

/* Contrast guard */
.esc-theme-contrast {
    border: 1px solid #c0392b;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 22px;
    font-size: 12px;
    background: color-mix(in srgb, #c0392b 12%, transparent);
}
.esc-theme-contrast[hidden] {
    display: none;
}

/* Save / share */
.esc-theme-save-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}
.esc-theme-name {
    flex: 1 1 auto;
    min-width: 0;
    background: var(--esc-t-panel, #16161a);
    color: var(--esc-t-text, #f5f0dd);
    border: 1px solid var(--esc-t-muted, #8a8371);
    border-radius: 5px;
    padding: 7px 9px;
    font-size: 13px;
}
.esc-theme-btn-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.esc-theme-btn {
    background: var(--esc-t-accent, #d4af37);
    color: #111;
    border: none;
    border-radius: 6px;
    padding: 8px 12px;
    font-family: "Oswald", "Arial Narrow", sans-serif;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    cursor: pointer;
}
.esc-theme-btn:hover {
    background: var(--esc-t-accent-bright, #ffd24a);
}
.esc-theme-import {
    display: inline-flex;
    align-items: center;
    background: transparent;
    color: var(--esc-t-text, #f5f0dd);
    border: 1px solid var(--esc-t-muted, #8a8371);
}
.esc-theme-import:hover {
    border-color: var(--esc-t-accent, #d4af37);
    color: var(--esc-t-accent, #d4af37);
    background: transparent;
}
.esc-theme-danger-btn {
    background: transparent;
    color: var(--esc-t-text, #f5f0dd);
    border: 1px solid #c0392b;
}
.esc-theme-danger-btn:hover {
    background: #c0392b;
    color: #fff;
}
.esc-theme-saved-title {
    margin: 16px 0 8px;
    font-family: "Oswald", "Arial Narrow", sans-serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
}
.esc-theme-saved-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-top: 1px solid var(--esc-t-muted, #8a8371);
}
.esc-theme-saved-swatch {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    flex: 0 0 auto;
}
.esc-theme-saved-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.esc-theme-mini-btn {
    background: transparent;
    color: var(--esc-t-text, #f5f0dd);
    border: 1px solid var(--esc-t-muted, #8a8371);
    border-radius: 5px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    flex: 0 0 auto;
}
.esc-theme-mini-btn:hover {
    border-color: var(--esc-t-accent, #d4af37);
    color: var(--esc-t-accent, #d4af37);
}
.esc-theme-mini-btn.esc-theme-danger:hover {
    border-color: #c0392b;
    color: #ff8a7a;
}
.esc-theme-empty {
    margin: 0;
    color: var(--esc-t-muted, #8a8371);
    font-size: 12px;
}

/* ESC build 4: no backing behind the header keycap in any theme (owner: remove the light square). */

/* ---- MIDI notes section (Theme Studio) ---- */
.esc-theme-midirow {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
}
.esc-theme-midirow input:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.esc-theme-midi-preview {
    position: relative;
    box-sizing: border-box;
    width: 100%;
    height: 84px;
    margin: 4px 0 10px;
    border: 1px solid var(--esc-t-accent, #d4af37);
    border-radius: 4px;
    overflow: hidden;
    background: #16161a;
}
.esc-theme-midi-preview-row {
    height: calc(100% / 7);
}
.esc-theme-midi-preview-grid {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
}
.esc-theme-midi-preview-note {
    position: absolute;
    box-sizing: border-box;
    border-radius: 1px;
}
.esc-theme-midi-preview-playhead {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
}
