/* styles.css — Master Web, Phase 2 Step 4.
 *
 * Palette is lifted from reference/MasterApp.py's colour constants so the
 * web app reads as the desktop app's sibling. Gold (#D6B87A) is reserved for
 * three things and three things only: the Render CTA (Phase 4), the wet
 * spectrum curve, and "value at suggested" slider readouts. Everything else
 * uses off-white-button-on-dark or muted neutrals so the gold actually means
 * something when you see it.
 */

:root {
    --bg:       #1A1A1A;
    --card:     #242424;
    --btn:      #3D3D3D;
    --btn-hov:  #4D4D4D;
    --select:   #5A4F33;
    --txt:      #F0ECE4;
    --txt-hi:   #FFFFFF;
    --dim:      #B0AFA5;
    --dim2:     #7A7873;
    --acc:      #D6B87A;
    --acc-hov:  #E6CB94;
    --log-fg:   #A0C8A0;
    --warn:     #E89A4A;
    --alert:    #E85A5A;

    --grid:     #262626;
    --thumb:    var(--txt);
    --trough:   var(--bg);

    --font-body:  -apple-system, BlinkMacSystemFont, "SF Pro Text",
                  "Segoe UI", system-ui, sans-serif;
    --font-mono:  Menlo, "JetBrains Mono", "Cascadia Mono", monospace;
}

/* ─── base ──────────────────────────────────────────────────────────────── */

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--txt);
    font: 13px/1.45 var(--font-body);
}

main {
    max-width: 940px;
    margin: 0 auto;
    padding: 18px 20px 32px;
}

h1.title {
    color: var(--acc);
    font-weight: 700;
    font-size: 22px;
    letter-spacing: 0.04em;
    margin: 0 0 0 0;
    display: inline-block;
}
.sub {
    color: var(--dim);
    font-style: italic;
    font-size: 12px;
    margin-left: 10px;
}
header.brand {
    padding: 8px 0 8px;
    border-bottom: 1px solid var(--acc);
    margin-bottom: 14px;
}

/* ─── landing (pitch + pricing, collapses after first file load) ────────── */

.landing {
    padding: 12px 16px 14px;
    transition: opacity 200ms, max-height 240ms, padding 240ms, margin 240ms;
    max-height: 200px;
    overflow: hidden;
}
.landing.collapsed {
    opacity: 0;
    max-height: 0;
    padding: 0 16px;
    margin: 0 0 -6px;
    pointer-events: none;
}
.landing-pitch {
    margin: 0 0 10px;
    color: var(--txt);
    font-size: 13px;
    line-height: 1.55;
}
.landing-prices {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}
.landing-tile {
    background: var(--bg);
    padding: 8px 10px 6px;
    border-radius: 4px;
    text-align: left;
}
.landing-tile.primary {
    background: #2A2418;
    border-left: 2px solid var(--acc);
}
.landing-tile-price {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 700;
    color: var(--txt-hi);
    margin-bottom: 1px;
}
.landing-tile.primary .landing-tile-price {
    color: var(--acc);
}
.landing-tile-detail {
    color: var(--dim);
    font-size: 11px;
    line-height: 1.3;
}

/* ─── cards ─────────────────────────────────────────────────────────────── */

section.card {
    background: var(--card);
    padding: 10px 14px;
    margin: 0 0 6px;
    border-radius: 4px;
}
section.card > .card-hdr {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-bottom: 6px;
}
.card-hdr .label {
    color: var(--txt);
    font-weight: 600;
    font-size: 13px;
}
.card-hdr .hint {
    color: var(--dim);
    font-style: italic;
    font-size: 12px;
}

/* ─── form-style rows ──────────────────────────────────────────────────── */

.row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 3px 0;
}
.row .row-label {
    width: 78px;
    flex-shrink: 0;
    color: var(--dim);
    font-weight: 600;
    font-size: 12px;
}

/* ─── buttons (light surface, dark text — the desktop's secondary style) ── */

button,
.btn {
    appearance: none;
    -webkit-appearance: none;
    background: var(--txt);
    color: var(--bg);
    border: 0;
    padding: 5px 12px;
    border-radius: 3px;
    font: 600 12px/1.2 var(--font-body);
    cursor: pointer;
    transition: background 110ms;
}
button:hover:not(:disabled),
.btn:hover:not(.disabled) {
    background: var(--txt-hi);
}
button:disabled,
.btn.disabled {
    background: var(--btn);
    color: var(--dim2);
    cursor: not-allowed;
}
button:focus-visible,
.btn:focus-visible {
    outline: 2px solid var(--acc);
    outline-offset: 1px;
}

/* The Render CTA and the loop's ▶ Play are accent-filled — those are the
   two "what to do next" moments in the whole app. Step 4 wires Play. */
button.hero {
    background: var(--acc);
    color: var(--bg);
    padding: 8px 18px;
    font-size: 14px;
}
button.hero:hover:not(:disabled) {
    background: var(--acc-hov);
}

/* ─── radio-as-button group (target LUFS, solo) ─────────────────────────── */

.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.radio-group label {
    cursor: pointer;
    background: var(--txt);
    color: var(--bg);
    padding: 4px 10px;
    border-radius: 3px;
    font: 600 12px/1.2 var(--font-body);
    user-select: none;
    transition: background 110ms;
}
.radio-group label:hover { background: var(--txt-hi); }
.radio-group input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.radio-group input[type="radio"]:checked + .radio-face,
.radio-group label:has(input[type="radio"]:checked) {
    background: var(--acc);
    color: var(--bg);
}
.radio-group label:has(input[type="radio"]:checked):hover {
    background: var(--acc-hov);
}
.radio-group label:has(input[type="radio"]:focus-visible) {
    outline: 2px solid var(--acc);
    outline-offset: 1px;
}

/* ─── B-bypass checkbox (a tiny square pill) ────────────────────────────── */

.bypass {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    width: 22px;
    height: 22px;
    background: var(--txt);
    color: var(--bg);
    font: 700 11px/1 var(--font-body);
    border-radius: 3px;
    justify-content: center;
    user-select: none;
    flex-shrink: 0;
}
.bypass input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.bypass:has(input[type="checkbox"]:checked) {
    background: var(--acc);
    color: var(--bg);
}
.bypass:hover { background: var(--txt-hi); }
.bypass:has(input[type="checkbox"]:checked):hover { background: var(--acc-hov); }
.bypass.placeholder {
    background: transparent;
    cursor: default;
    pointer-events: none;
}

/* Plain checkboxes (limiter bypass, match level) — small accent box. */
.check {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    color: var(--txt);
    font: 12px var(--font-body);
    user-select: none;
}
.check input[type="checkbox"] {
    accent-color: var(--acc);
    width: 14px;
    height: 14px;
}

/* ─── sliders ───────────────────────────────────────────────────────────── */

.slider-row {
    display: grid;
    grid-template-columns: 28px 110px 1fr 88px;
    align-items: center;
    gap: 10px;
    padding: 3px 0;
}
.slider-row .slider-label {
    color: var(--txt);
    font-size: 12px;
    font-weight: 500;
}
.slider-row .slider-value {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--txt);
    text-align: right;
}
.slider-row .slider-value.at-suggested {
    color: var(--acc);
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    width: 100%;
    height: 22px;
    margin: 0;
    cursor: pointer;
}
/* Chrome/Safari */
input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    background: var(--trough);
    border-radius: 2px;
}
input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--thumb);
    margin-top: -5px;
    border: 0;
    box-shadow: 0 0 0 1px #0008;
    transition: background 80ms, transform 80ms;
}
input[type="range"]:hover::-webkit-slider-thumb {
    background: var(--acc);
}
input[type="range"]:active::-webkit-slider-thumb {
    background: var(--acc-hov);
    transform: scale(1.05);
}
/* Firefox */
input[type="range"]::-moz-range-track {
    height: 4px;
    background: var(--trough);
    border-radius: 2px;
    border: 0;
}
input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--thumb);
    border: 0;
}
input[type="range"]:focus-visible::-webkit-slider-thumb { background: var(--acc); }
input[type="range"]:focus-visible::-moz-range-thumb     { background: var(--acc); }

/* ─── select (genre dropdown) ──────────────────────────────────────────── */

select.genre {
    background: var(--txt);
    color: var(--bg);
    border: 0;
    padding: 4px 28px 4px 10px;
    border-radius: 3px;
    font: 600 12px/1.2 var(--font-body);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--bg) 50%),
                      linear-gradient(135deg, var(--bg) 50%, transparent 50%);
    background-position: calc(100% - 12px) 50%, calc(100% - 7px) 50%;
    background-size: 5px 5px;
    background-repeat: no-repeat;
}
select.genre:hover { background-color: var(--txt-hi); }

/* ─── dropzone (carries over from Step 3, restyled smaller) ─────────────── */

#dropzone {
    background: var(--card);
    border: 1.5px dashed var(--btn-hov);
    border-radius: 6px;
    padding: 16px 16px;
    text-align: center;
    color: var(--dim);
    cursor: pointer;
    transition: border-color 120ms, color 120ms, background 120ms;
    user-select: none;
    margin-bottom: 6px;
}
#dropzone:hover,
#dropzone.hover {
    border-color: var(--acc);
    color: var(--txt);
    background: #2A2A2A;
}
#dropzone[aria-disabled="true"] {
    opacity: 0.6;
    cursor: progress;
}
#dropzone strong { color: var(--txt-hi); font-weight: 600; }
#file-picker, #ref-picker { display: none; }

/* Step 5 polish: the dropzone announces its own state. Pulsing gold border
   during analyze, calm gold border once a file is loaded, alert red on
   decode failure. The <pre id="log"> still has the full trace; this row is
   the at-a-glance indicator the user sees first. */
#dropzone.loading {
    border-color: var(--acc);
    color: var(--txt);
    animation: dropzone-pulse 1.2s ease-in-out infinite;
}
#dropzone.loaded {
    border-color: var(--acc);
    color: var(--txt);
    animation: none;
}
#dropzone.error {
    border-color: var(--alert);
    color: var(--alert);
    animation: none;
}
@keyframes dropzone-pulse {
    0%, 100% { background: #2A2A2A; box-shadow: 0 0 0 0 #D6B87A30; }
    50%      { background: #2F2A22; box-shadow: 0 0 0 4px #D6B87A18; }
}

/* ─── spectrum + meter canvases ────────────────────────────────────────── */

.viz {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-top: 6px;
}
canvas#spectrum {
    background: var(--bg);
    border-radius: 3px;
    width: 100%;
    height: 130px;
    display: block;
    flex: 1;
}
canvas#meters {
    background: var(--bg);
    border-radius: 3px;
    width: 72px;
    height: 130px;
    flex-shrink: 0;
}

/* ─── status line + log ─────────────────────────────────────────────────── */

.status {
    color: var(--txt-hi);
    font: 600 12px/1.4 var(--font-body);
    margin-top: 6px;
    min-height: 1.4em;
}
.status.alert { color: var(--alert); }
.status.warn  { color: var(--warn); }

#log {
    background: #101010;
    color: var(--log-fg);
    border-radius: 4px;
    padding: 10px 12px;
    margin-top: 6px;
    font: 11px/1.5 var(--font-mono);
    height: 160px;
    overflow-y: auto;
    white-space: pre-wrap;
}
#log .ok   { color: #A0C8A0; }
#log .warn { color: var(--warn); }
#log .err  { color: var(--alert); }

/* ─── small utilities ───────────────────────────────────────────────────── */

.spacer  { flex: 1; }
.mono    { font-family: var(--font-mono); }
.hidden  { display: none !important; }
.muted   { color: var(--dim); }

/* ─── tier indicator ──────────────────────────────────────────────────────
 * Sits in the render-card row next to the Render button. Green when the user
 * still has free exports or an active Album Pass, amber on last free export,
 * red on exhausted.
 */
#tier-indicator              { color: var(--dim); }
#tier-indicator.free-some    { color: #A0C8A0; }
#tier-indicator.free-last    { color: var(--warn); }
#tier-indicator.free-empty   { color: var(--alert); }
#tier-indicator.album-pass   { color: var(--acc); }

/* ─── price modal ─────────────────────────────────────────────────────────
 * Modal backdrop covers the whole viewport; card sits centred. Two price
 * tiles side-by-side, Album Pass tinted gold as the "primary" choice.
 */
.modal {
    position: fixed;
    inset: 0;
    background: #00000099;
    backdrop-filter: blur(2px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.modal-card {
    background: var(--card);
    border: 1px solid var(--btn);
    border-radius: 8px;
    padding: 22px 24px 18px;
    max-width: 480px;
    width: 100%;
    margin: 0 16px;
}
.modal-card-wide {
    max-width: 580px;
    max-height: 90vh;
    overflow-y: auto;
}
.modal-card h2 {
    margin: 0 0 10px;
    color: var(--txt-hi);
    font-size: 16px;
    font-weight: 600;
}
.modal-card code {
    font-family: var(--font-mono);
    background: var(--bg);
    padding: 1px 4px;
    border-radius: 2px;
    font-size: 12px;
}
.price-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.price-tile {
    background: var(--btn);
    color: var(--txt);
    text-align: left;
    padding: 14px 14px 12px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 110ms;
    border: 0;
}
.price-tile:hover:not(:disabled) {
    background: var(--btn-hov);
}
.price-tile.primary {
    background: var(--acc);
    color: var(--bg);
}
.price-tile.primary:hover:not(:disabled) {
    background: var(--acc-hov);
}
.price-tile:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}
.price-tile-label {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 6px;
}
.price-tile-price {
    font-family: var(--font-mono);
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
}
.price-tile-hint {
    font-size: 11px;
    opacity: 0.8;
    font-style: italic;
}

/* ─── Legal footer ─────────────────────────────────────────────────── */
.site-footer {
    text-align: center;
    color: var(--muted);
    font-size: 11px;
    padding: 24px 16px 32px;
    line-height: 1.6;
}
.site-footer a {
    color: var(--muted);
    text-decoration: underline;
}
.site-footer a:hover {
    color: var(--text);
}
