/*
   style.css
   Dubplate (web)

   The look of everything that sits on top of the picture: the glass control
   panel, its sliders, the ? card and the music-source card. Sizes follow the
   Mac app's panel (ContentView.swift) so the two feel like one app.
*/

:root {
    --ink: rgba(255, 255, 255, 0.92);
    --ink-soft: rgba(255, 255, 255, 0.62);
    --ink-faint: rgba(255, 255, 255, 0.38);
    --wash: rgba(255, 255, 255, 0.08);
    --wash-on: rgba(255, 255, 255, 0.22);
    --hairline: rgba(255, 255, 255, 0.14);
    font-family: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    color: var(--ink);
    color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: #000;
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* The pointer disappears with the panel, so nothing sits on the picture. */
body.idle { cursor: none; }

[hidden] { display: none !important; }

#stage {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    background: #000;
}

#ui { position: fixed; inset: 0; pointer-events: none; }
#ui > * { pointer-events: auto; }

button {
    font: inherit;
    color: inherit;
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
}
button:disabled { cursor: default; }
button:focus-visible, .knob-track:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.7);
    outline-offset: 3px;
}
svg { width: 1em; height: 1em; display: block; }

/* ---------- glass ---------- */

.glass {
    background: rgba(22, 22, 26, 0.46);
    -webkit-backdrop-filter: blur(26px) saturate(1.5);
    backdrop-filter: blur(26px) saturate(1.5);
    border: 1px solid var(--hairline);
    border-radius: 30px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.10);
}

/* ---------- the stack at the bottom: ? card above the panel ---------- */

.controls {
    --fit: 1;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding-bottom: max(28px, env(safe-area-inset-bottom));
    pointer-events: none !important;
    transform: scale(var(--fit));
    transform-origin: 50% 100%;
    transition: opacity 0.25s ease, translate 0.25s ease;
}
.controls > * { pointer-events: auto; }
.controls.hidden {
    opacity: 0;
    translate: 0 40px;
}
.controls.hidden > * { pointer-events: none; }

.panel {
    display: flex;
    flex-direction: column;
    gap: 30px;
    padding: 30px 38px;
    width: max-content;
    max-width: none;
}

.header {
    display: flex;
    align-items: center;
    gap: 14px;
}
.scenes { display: flex; align-items: center; gap: 14px; }

.divider {
    width: 1px;
    height: 14px;
    background: var(--hairline);
    flex: none;
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    transition: background 0.15s ease;
}
.pill:hover { background: var(--wash); }
.pill.on { background: var(--wash-on); }
.pill .icon { font-size: 13px; opacity: 0.9; }
.pill.source { font-weight: 500; color: var(--ink-soft); padding-inline: 10px; }
.pill.source:hover { color: var(--ink); }

.round {
    width: 22px;
    height: 22px;
    flex: none;
    display: inline-grid;
    place-items: center;
    border-radius: 50%;
    background: var(--wash);
    color: var(--ink-soft);
    font-size: 11px;
    font-weight: 700;
    transition: background 0.15s ease, color 0.15s ease;
}
.round:hover { background: rgba(255, 255, 255, 0.16); color: var(--ink); }
.round.on { background: var(--wash-on); color: var(--ink); }

/* The status dot: orange = no source, red = silent, green = hearing music. */
.dot-button {
    width: 18px;
    height: 18px;
    flex: none;
    display: inline-grid;
    place-items: center;
}
.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ff9f0a;
    box-shadow: 0 0 6px currentColor;
    color: #ff9f0a;
}
.dot[data-state="silent"] { background: #ff453a; color: #ff453a; }
.dot[data-state="live"] { background: #30d158; color: #30d158; }

/* ---------- sliders ---------- */

.knob-rows { display: flex; flex-direction: column; gap: 30px; }
.knob-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 48px; }

.knob { display: flex; flex-direction: column; gap: 9px; flex: 1 1 118px; min-width: 118px; }
.knob-head {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 14px;
    font-size: 10px;
    font-weight: 500;
    color: var(--ink-soft);
}

.chip {
    display: inline-grid;
    place-items: center;
    padding: 2px 5px;
    border-radius: 999px;
    font-size: 10px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--ink-faint);
}
.chip.on { background: rgba(255, 255, 255, 0.25); color: var(--ink); }

/* The visible line is a hairline; the track around it (padding, cancelled
   out by the negative margin so nothing moves) makes it easy to grab. */
.knob-track {
    margin: -8px -12px -16px;
    padding: 8px 12px 16px;
    cursor: pointer;
    touch-action: none;
    outline-offset: -2px;
    border-radius: 8px;
}
.knob-line { position: relative; height: 20px; pointer-events: none; }
.knob-line > * { position: absolute; top: 50%; }
.tick {
    width: 1px;
    height: 4px;
    margin-top: -2px;
    background: rgba(255, 255, 255, 0.25);
}
.tick.end { height: 8px; margin-top: -4px; background: rgba(255, 255, 255, 0.4); }
.knob-rail, .knob-fill {
    left: 0;
    height: 3px;
    margin-top: -1.5px;
    border-radius: 2px;
}
.knob-rail { right: 0; background: rgba(255, 255, 255, 0.15); }
.knob-fill { width: 0; background: rgba(255, 255, 255, 0.6); }
.knob-thumb {
    left: 0;
    width: 11px;
    height: 11px;
    margin: -5.5px 0 0 -5.5px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.5);
}
.gliding .knob-thumb { transition: left 0.35s ease-out; }
.gliding .knob-fill { transition: width 0.35s ease-out; }

/* ---------- cards ---------- */

.card { padding: 30px 38px; }

.help {
    display: none;
    flex-direction: column;
    gap: 22px;
    width: max-content;
}
.help.open { display: flex; }
.help-grid {
    display: grid;
    grid-template-columns: 104px 240px;
    gap: 10px 24px;
    font-size: 11px;
    color: var(--ink-soft);
}
.help-head {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-faint);
}
.help-name { font-weight: 600; }
.keys {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 16px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 10px;
    color: var(--ink-soft);
}
.key-hint { display: inline-flex; align-items: center; gap: 5px; }
kbd {
    font: inherit;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.12);
    border: 0.5px solid rgba(255, 255, 255, 0.25);
    color: var(--ink);
}

.layer {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    overflow: auto;
}

.sources, .fatal {
    width: min(440px, 100%);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.fatal .lead { white-space: pre-line; }   /* step-by-step messages keep their lines */
.sources h1, .fatal h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.01em;
}
.lead {
    margin: 0 0 8px;
    font-size: 14px;
    line-height: 1.45;
    color: var(--ink-soft);
    text-wrap: pretty;
}
.selectable { -webkit-user-select: text; user-select: text; }

.option {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 12px 14px;
    border-radius: 16px;
    background: var(--wash);
    text-align: left;
    transition: background 0.15s ease;
}
.option:hover:not(:disabled) { background: rgba(255, 255, 255, 0.16); }
/* The main way in: bigger and brighter than the two under it. */
.option.main {
    padding: 18px 16px;
    background: rgba(255, 255, 255, 0.20);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}
.option.main:hover:not(:disabled) { background: rgba(255, 255, 255, 0.28); }
.option.main .option-icon { font-size: 30px; opacity: 1; }
.option.main .option-text strong { font-size: 16px; }
.or {
    margin: 2px 0;
    text-align: center;
    font-size: 11px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-faint);
}
.option:disabled { opacity: 0.45; }
.option-icon { font-size: 24px; flex: none; opacity: 0.9; }
.option-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.option-text strong { font-size: 14px; font-weight: 600; }
.option-text span { font-size: 12px; line-height: 1.4; color: var(--ink-soft); text-wrap: pretty; }
.busy .option { pointer-events: none; opacity: 0.6; }

.source-error {
    margin: 4px 0 0;
    font-size: 12.5px;
    line-height: 1.45;
    color: #ffb4ab;
    text-wrap: pretty;
}
.source-error:empty { display: none; }
.source-note {
    margin: 4px 0 0;
    font-size: 12px;
    line-height: 1.45;
    color: var(--ink-soft);
    text-wrap: pretty;
}
.source-note:empty { display: none; }
.fine { margin: 6px 0 0; font-size: 11px; line-height: 1.45; color: var(--ink-faint); }
.card-foot { display: flex; justify-content: flex-end; gap: 18px; margin-top: 2px; }
.link { font-size: 13px; font-weight: 600; color: var(--ink-soft); padding: 4px 2px; }
.link:hover { color: var(--ink); }

/* A small message at the top of the picture. */
.notice {
    position: absolute;
    top: max(18px, env(safe-area-inset-top));
    left: 50%;
    translate: -50% 0;
    max-width: calc(100vw - 32px);
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
    text-align: center;
}

.drop-hint {
    position: absolute;
    inset: 16px;
    display: grid;
    place-items: center;
    border: 2px dashed rgba(255, 255, 255, 0.5);
    border-radius: 28px;
    background: rgba(0, 0, 0, 0.45);
    font-size: 18px;
    font-weight: 600;
    pointer-events: none !important;
}

/* ---------- narrow screens: wrap instead of shrinking to a sliver ---------- */

@media (max-width: 760px) {
    .controls { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
    .panel {
        width: calc(100vw - 24px);
        max-height: 52vh;       /* the top half of the screen stays picture */
        overflow-y: auto;
        padding: 20px 22px;
        gap: 22px;
        border-radius: 24px;
    }
    .header { flex-wrap: wrap; gap: 8px 10px; justify-content: center; }
    .scenes { flex-wrap: wrap; justify-content: center; gap: 6px; width: 100%; }
    .divider { display: none; }
    .pill { padding: 8px 14px; font-size: 13px; }
    .round { width: 30px; height: 30px; font-size: 13px; }
    /* All ten sliders in one two-column grid (the rows of five dissolve). */
    .knob-rows { display: grid; grid-template-columns: 1fr 1fr; gap: 22px 28px; }
    .knob-row { display: contents; }
    .knob { min-width: 0; }
    .knob-head { font-size: 12px; height: 16px; }
    .help { width: calc(100vw - 24px); max-height: 30vh; overflow-y: auto; padding: 20px 22px; border-radius: 24px; }
    .help-grid { grid-template-columns: auto 1fr; }
    .card { padding: 24px 22px; }
}

@media (prefers-reduced-motion: reduce) {
    .controls, .pill, .round, .option { transition: none; }
    .gliding .knob-thumb, .gliding .knob-fill { transition: none; }
}
