/*
 * Video Lab — only what's specific to this tool.
 * Window, menus, toolbar, panel, buttons, fields, sliders, readouts,
 * wells, status bar and taskbar come from ../../shared-studio.css.
 */

:root {
    --rec: #ff3355;
    --display: 'VT323', var(--s-mono);
}

[hidden] { display: none !important; }
html, body { height: 100%; overflow: hidden; }

#win-main { min-width: 0; min-height: 0; border: none; box-shadow: none; }

/* ─── Toolbar ───────────────────────────────────────────── */

.topbar { flex-wrap: wrap; row-gap: 3px; }
.field { display: inline-flex; align-items: center; gap: 4px; margin: 0 4px; }
.pan-field .s-slider { width: 80px; }

.rec .dot, .rec-badge .dot {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
    display: inline-block; margin-right: 5px; vertical-align: -1px;
    background: var(--rec); border: 1px solid #000;
}
.rec.recording { color: #fff; background: var(--rec); }
.rec.recording .dot { background: #fff; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* Small square icon button (play, mute, undo). */
.s-btn-icon { width: 26px; padding: 3px 0; text-align: center; }
.s-btn-icon:active:not(:disabled), .s-btn-icon.active { padding: 4px 0 2px 1px; }

.link {
    padding: 0; border: 0; background: none; cursor: pointer;
    color: var(--s-phosphor); text-decoration: underline; text-underline-offset: 2px;
    font: inherit;
}

/* ─── Workspace ─────────────────────────────────────────── */

.workspace {
    flex: 1; min-height: 0;
    display: grid; grid-template-columns: minmax(0, 1fr) 340px;
    gap: 4px; padding: 4px;
}

.stage-col { display: flex; flex-direction: column; gap: 4px; min-width: 0; min-height: 0; }

.stage {
    position: relative; flex: 1; min-height: 0; overflow: hidden;
    display: flex; align-items: center; justify-content: center;
    background-image:
        linear-gradient(45deg, var(--s-ink-2) 25%, transparent 25%, transparent 75%, var(--s-ink-2) 75%),
        linear-gradient(45deg, var(--s-ink-2) 25%, transparent 25%, transparent 75%, var(--s-ink-2) 75%);
    background-size: 22px 22px; background-position: 0 0, 11px 11px;
}

#out-canvas { display: block; max-width: 100%; max-height: 100%; touch-action: none; }
.stage.comparing #out-canvas { cursor: ew-resize; }

.stage-badge {
    position: absolute; top: 8px; padding: 2px 8px;
    font: 18px/1 var(--display); letter-spacing: 1px;
    border: 1px solid #000;
}
.live-badge { left: 8px; background: var(--s-phosphor); color: var(--s-on-phosphor); }
.rec-badge { right: 8px; display: flex; align-items: center; background: var(--s-ink); color: #fff; border-color: var(--rec); }
.rec-badge .dot { animation: blink 1s infinite; }

.drop-overlay {
    position: absolute; inset: 0; pointer-events: none;
    display: none; align-items: center; justify-content: center;
    font: 32px var(--display); color: var(--s-phosphor);
    background: rgba(0, 0, 0, .55);
    outline: 2px dashed var(--s-phosphor); outline-offset: -10px;
}
.drop-overlay::before { content: '> '; }
.stage.dragging .drop-overlay { display: flex; }

.stage-hint {
    position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%);
    display: flex; align-items: center; gap: 10px;
    max-width: calc(100% - 20px); padding: 6px 10px;
    font: 11px var(--s-mono); color: var(--s-ink-text);
    background: var(--s-ink); border: 1px solid var(--s-ink-line);
}
.stage-hint::before { content: '>'; color: var(--s-phosphor); }
.stage-hint .link { text-decoration: none; color: var(--s-ink-dim); }

/* ─── Timeline ──────────────────────────────────────────── */

.timeline {
    display: flex; flex-direction: column; gap: 6px; padding: 6px;
    background: var(--s-face);
    border: 1px solid; border-color: var(--s-sunken);
}
.tl-row { display: flex; align-items: center; gap: 6px; }
.tl-opts { flex-wrap: wrap; }
.tl-time { min-width: 128px; text-align: center; font-variant-numeric: tabular-nums; }
.tl-len { margin-left: auto; font: 10px var(--s-mono); color: var(--s-dark); }

.tl-track {
    position: relative; flex: 1; height: 44px; overflow: hidden;
    cursor: pointer; touch-action: none; user-select: none;
}
.tl-strip { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .75; }
.tl-dim { position: absolute; top: 0; bottom: 0; background: rgba(0, 0, 0, .7); pointer-events: none; }
#tl-dim-l { left: 0; }
#tl-dim-r { right: 0; }
.tl-range {
    position: absolute; top: 0; bottom: 0; pointer-events: none;
    border-top: 2px solid var(--s-phosphor); border-bottom: 2px solid var(--s-phosphor);
}
/* Trim handles are little Windows grips sitting on the terminal track. */
.tl-handle {
    position: absolute; top: 0; bottom: 0; width: 11px; margin-left: -5px;
    cursor: ew-resize;
    background-color: var(--s-face);
    background-image: repeating-linear-gradient(0deg, var(--s-lo) 0 1px, transparent 1px 3px);
    background-clip: content-box; padding: 12px 2px;
    border: 2px solid; border-color: var(--s-raised);
}
.tl-head {
    position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px;
    background: var(--s-phosphor); pointer-events: none;
}

/* Segmented control: a row of Windows buttons, one pressed. */
.seg { display: inline-flex; }
.seg button {
    padding: 2px 8px; cursor: pointer; color: var(--s-text);
    background: var(--s-face);
    border: 2px solid; border-color: var(--s-raised);
    margin-right: -2px;
}
.seg button:last-child { margin-right: 0; }
.seg button:hover { background: var(--s-face-hover); }
.seg button.active {
    border-color: var(--s-sunken);
    background-image: repeating-conic-gradient(var(--s-face) 0 25%, var(--s-hi) 0 50%);
    background-size: 2px 2px;
}

#reverse-btn.active { border-color: var(--s-sunken); }

.stat { min-width: 90px; }

/* ─── Side panel ────────────────────────────────────────── */

.panel { min-height: 0; }

.count {
    display: inline-block; min-width: 18px; margin-left: 4px; padding: 0 4px;
    font: 10px/14px var(--s-mono); color: var(--s-phosphor); background: var(--s-ink);
    text-align: center;
}

.tab-body { display: none; flex: 1; min-height: 0; overflow-y: auto; padding: 6px; flex-direction: column; gap: 6px; }
.tab-body.active { display: flex; }
.tab-body > .s-section { margin: 4px -6px 0; }
.tab-body > .s-section small { font-weight: normal; letter-spacing: 0; text-transform: none; opacity: .7; margin-left: 6px; }

.row { display: flex; align-items: center; gap: 4px; }
.row.gap { gap: 6px; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }

.hint-line { margin: 0; font-size: 10px; color: #404040; }

/* Looks */

.look-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; padding: 4px; }
.look-grid:empty::before { content: '> nothing saved yet'; grid-column: 1 / -1; padding: 6px; font-size: 11px; color: var(--s-ink-dim); }

.look {
    position: relative; padding: 0; overflow: hidden; cursor: pointer; text-align: left;
    background: #000; border: 1px solid var(--s-ink-line);
}
.look:hover { border-color: var(--s-phosphor); }
.look canvas { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: #000; }
.look .name {
    display: block; padding: 3px 6px;
    font: 10px var(--s-mono); color: var(--s-ink-text); background: var(--s-ink-2);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.look:hover .name { color: var(--s-on-phosphor); background: var(--s-phosphor); }
.look .del {
    position: absolute; top: 3px; right: 3px; width: 16px; height: 14px; padding: 0;
    display: none; cursor: pointer;
    font: bold 9px/1 var(--s-ui-font); color: var(--s-text); background: var(--s-face);
    border: 1px solid; border-color: var(--s-raised);
}
.look:hover .del { display: block; }

/* Stack */

.layer-list { list-style: none; margin: 0; padding: 0; min-height: 26px; }
.layer-list:empty { display: none; }
.layer { gap: 4px; padding: 0 2px; font-size: 11px; }
.layer.off .layer-name { opacity: .45; text-decoration: line-through; }
.layer.dragging { opacity: .6; }
.drag-handle { padding: 0 3px; color: var(--s-ink-dim); cursor: grab; touch-action: none; letter-spacing: -2px; }
.layer-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.layer-name small { margin-left: 6px; opacity: .6; }
.layer .mini { width: 20px; height: 18px; padding: 0; border: 0; background: none; color: inherit; cursor: pointer; opacity: .7; font: inherit; }
.layer .mini:hover { opacity: 1; }
.layer.selected .drag-handle { color: inherit; }

.empty { padding: 18px 10px; }

.layer-controls { display: flex; flex-direction: column; gap: 6px; padding-top: 4px; }
.layer-controls:empty { display: none; }
.lc-head { margin: 0 -6px; padding: 6px 8px; background: var(--s-ink); border-top: 1px solid var(--s-lo); border-bottom: 1px solid var(--s-hi); }
.lc-head h4 { margin: 0; font: 22px/1 var(--display); color: var(--s-phosphor); letter-spacing: 1px; }
.lc-head p { margin: 3px 0 0; font: 10px/1.5 var(--s-mono); color: var(--s-ink-dim); }

.ctrl { display: flex; flex-direction: column; gap: 3px; }
.ctrl-top { display: flex; justify-content: space-between; align-items: center; }
.ctrl-top output { font-variant-numeric: tabular-nums; }
.ctrl .s-select { width: 100%; }
.ctrl.inline { flex-direction: row; align-items: center; justify-content: space-between; }
.ctrl.s-check { flex-direction: row; justify-content: flex-start; }
.ctrl input[type="color"] {
    width: 40px; height: 20px; padding: 1px; cursor: pointer;
    background: var(--s-field); border: 2px solid; border-color: var(--s-sunken);
}
.ctrl-sep { height: 0; border-top: 1px solid var(--s-lo); border-bottom: 1px solid var(--s-hi); }

.lc-actions { display: flex; flex-wrap: wrap; gap: 3px; }
.lc-actions .s-btn { flex: 1; }

/* Export */

.out-summary { margin: 0; padding: 6px 8px; font-size: 11px; color: var(--s-ink-dim); }
.out-summary strong { color: var(--s-phosphor); font-weight: normal; }

.field.grow { flex: 1; margin: 0; }
.field.grow .s-select { flex: 1; }

/* Determinate progress: a phosphor fill in the shared progress well. */
.progress { width: 100%; height: 14px; }
.progress div { height: 100%; width: 0; background: var(--s-phosphor); transition: width .1s; }

.studio-image { display: flex; gap: 8px; align-items: center; padding: 2px 0; }
.si-thumb { width: 60px; height: 60px; flex-shrink: 0; background: #000 center / cover no-repeat; }
.si-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.si-text span { font-size: 10px; color: #404040; }

#still-row .studio-send-wrap { flex: 1; display: flex; }
#still-row .studio-send-wrap .s-btn { flex: 1; }

/* ─── Dialogs (effect browser, shortcuts) ───────────────── */

.modal {
    position: fixed; inset: 0; z-index: 20000; padding: 16px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0, 0, 0, .55);
}
.modal-card {
    position: relative; inset: auto;
    width: min(860px, 100%); max-height: min(760px, 100%);
}
.modal-card.small { width: min(440px, 100%); }
.modal-head { display: flex; gap: 6px; padding: 6px; flex-shrink: 0; }
.modal-head .s-input { flex: 1; }

.fx-browser { flex: 1; min-height: 0; overflow-y: auto; margin: 0 6px 6px; padding: 0 10px 12px; }
.fx-cat h3 { margin: 12px 0 6px; font-size: 11px; color: var(--s-phosphor); letter-spacing: 1px; }
.fx-cat h3::before { content: '## '; color: var(--s-ink-dim); }
.fx-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 6px; }
.fx-card {
    display: flex; flex-direction: column; padding: 0; overflow: hidden; cursor: pointer; text-align: left;
    color: var(--s-ink-text); background: var(--s-ink-2);
    border: 1px solid var(--s-ink-line);
    font: inherit;
}
.fx-card:hover { border-color: var(--s-phosphor); }
.fx-card canvas { display: block; width: 100%; aspect-ratio: 16 / 9; background: #000; }
.fx-card strong { padding: 5px 7px 0; font-weight: bold; }
.fx-card span { padding: 2px 7px 7px; font-size: 10px; color: var(--s-ink-dim); }

.shortcuts {
    display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; align-items: center;
    margin: 4px; border: 2px solid; border-color: var(--s-sunken);
}
.shortcuts .s-kbd { justify-self: start; }

/* ─── Small screens ─────────────────────────────────────── */

@media (max-width: 900px) {
    html, body { overflow: auto; height: auto; }
    .s-desktop { position: static; }
    #win-main { position: static; width: auto !important; height: auto !important; }
    #win-main .s-win-controls, .s-menubar { display: none; }
    .workspace { grid-template-columns: 1fr; }
    .stage { flex: none; aspect-ratio: 16 / 10; max-height: 70vh; }
    .tab-body { overflow: visible; }
    .tl-time { min-width: 0; }
}

@media (max-width: 520px) {
    .pan-field .s-slider { width: 60px; }
    .tl-len { width: 100%; margin-left: 0; }
}

/* ─── Phones: stage on top, one panel at a time below ──── */
/* Tab bar, sheet and finger-sized controls come from shared-studio.css.
   Comes after the 900px rules above so it wins on phones. */

@media (max-width: 768px) {
    html, body { overflow: hidden; height: 100%; }
    .s-desktop { position: fixed; }
    #win-main .s-win-controls { display: none; }
    .workspace { display: flex; flex-direction: column; padding: 0; gap: 0; }
    .stage-col { flex: 1; min-height: 0; gap: 0; }
    .stage { flex: 1; aspect-ratio: auto; max-height: none; border: none; }
    .stage-hint { font-size: 12px; }
    .timeline { padding: 6px; border-left: none; border-right: none; }
    .timeline .s-btn, .timeline .seg button { min-height: 36px; }
    .s-btn-icon { width: 40px; }
    .tl-time { min-width: 0; font-size: 12px; }
    .tl-track { height: 48px; }
    .tl-handle { width: 20px; margin-left: -10px; }

    .tab-body, .tab-body.active { display: flex; flex: none; overflow: visible; padding: 8px 10px 10px; gap: 8px; }
    .tab-body > .s-section { margin: 4px -10px 0; }
    .hint-line { font-size: 12px; }

    /* The toolbar, moved into the sheet as the Source tab. */
    .topbar {
        display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
        padding: 8px 10px 10px; border: none; background: none;
    }
    .topbar .s-tool-sep, .topbar .s-tool-spacer { display: none; }
    .topbar .s-tool-btn {
        min-height: 40px; justify-content: center; font-size: 13px;
        background: var(--s-face); border: 2px solid; border-color: var(--s-raised);
    }
    .topbar .s-tool-btn:active { border-color: var(--s-sunken); }
    .topbar .field { grid-column: 1 / -1; margin: 0; display: grid; grid-template-columns: 64px 1fr; font-size: 13px; }
    .topbar .field .s-select { min-height: 40px; font-size: 16px; }
    .pan-field .s-slider { width: auto; }

    .layer { min-height: 40px; font-size: 13px; }
    .layer .mini { width: 36px; height: 36px; font-size: 15px; opacity: .85; }
    .drag-handle { touch-action: none; padding: 0 6px; font-size: 16px; }
}
