/* ==========================================================================
   The Reel — Ken Burns video maker.

   Reuses the shared dk-* instrument components from darkroom.css; this sheet
   adds the reel-specific layout (preview + photo strip), the 3×3 focus
   picker, the render progress bar, and re-declares the photo-tray primitives
   (shared visually with the collage tray, but that sheet isn't loaded here).
   Flat design only — solid colours, no gradients. Scoped under .pt-scope so
   it inherits the instrument tokens.
   ========================================================================== */

.reel-layout {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-start;
}

.reel-preview {
    flex: 1 1 320px;
    min-width: 0;
}

.reel-preview__wrap {
    display: flex;
    align-items: center;
    justify-content: center;
}

.reel-preview__hint {
    margin: 0.5rem 0 0;
    font-family: var(--pt-font-ui);
    font-size: 0.75rem;
    color: var(--pt-text-muted);
}

/* ---- Photo strip (vertical on wide screens, reuses tray primitives) ---- */

.reel-strip {
    flex: 0 0 auto;
    max-width: 100%;
    margin-top: 0;
}

.dk-tray {
    padding: 0.75rem;
    background: var(--pt-surface);
    border: 1px solid var(--pt-border);
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.625rem;
    overflow-x: auto;
}

.dk-tray__list {
    display: flex;
    gap: 0.625rem;
    list-style: none;
    margin: 0;
    padding: 0;
}

.dk-tray__item {
    position: relative;
    width: 64px;
    height: 64px;
    flex: 0 0 auto;
    border: 2px solid var(--pt-border-strong);
    border-radius: 0.375rem;
    overflow: hidden;
    cursor: grab;
    background: var(--pt-chrome-bg);
    touch-action: none;
    transition: border-color var(--pt-dur) var(--pt-ease);
}

.dk-tray__item:hover { border-color: var(--pt-text-muted); }
.dk-tray__item.is-selected { border-color: var(--pt-accent); }
.dk-tray__item.is-dragging { opacity: 0.5; cursor: grabbing; }

.dk-tray__thumb {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    pointer-events: none;
}

.dk-tray__num {
    position: absolute;
    left: 3px;
    bottom: 3px;
    padding: 1px 4px;
    font-family: var(--pt-font-mono);
    font-size: 0.625rem;
    font-weight: 700;
    line-height: 1.3;
    color: #ffffff;
    background: rgba(28, 28, 28, 0.75);
    border-radius: 3px;
    pointer-events: none;
}

.dk-tray__remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    line-height: 1;
    color: #ffffff;
    background: rgba(28, 28, 28, 0.7);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0;
    transition: opacity var(--pt-dur) var(--pt-ease), background-color var(--pt-dur) var(--pt-ease);
}

.dk-tray__item:hover .dk-tray__remove,
.dk-tray__item:focus-within .dk-tray__remove { opacity: 1; }

.dk-tray__remove:hover { background: var(--pt-bad, #c0453b); }

.dk-tray__add {
    flex: 0 0 auto;
    padding: 0.5rem 0.875rem;
    font-family: var(--pt-font-ui);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    color: var(--pt-text-secondary);
    background: var(--pt-chrome-bg);
    border: 1px dashed var(--pt-border-strong);
    border-radius: 0.375rem;
    cursor: pointer;
    white-space: nowrap;
    transition: color var(--pt-dur) var(--pt-ease), border-color var(--pt-dur) var(--pt-ease);
}

.dk-tray__add:hover { color: var(--pt-text); border-color: var(--pt-accent); }

/* On wide screens stack the strip vertically beside the preview. */
@media (min-width: 720px) {
    .reel-strip { flex-direction: column; align-items: stretch; max-height: 520px; }
    .reel-strip .dk-tray__list { flex-direction: column; }
}

/* ---- Panels ---- */

.reel-panel { margin-top: 1rem; }

.reel-panel.is-disabled { opacity: 0.5; pointer-events: none; }

.reel-panel__for {
    font-style: normal;
    color: var(--pt-accent);
    font-family: var(--pt-font-mono);
    font-size: 0.6875rem;
    margin-left: 0.25rem;
}

.reel-chips { flex-wrap: wrap; }

/* ---- 3×3 focus picker ---- */

/* Machined keypad: equal cells share 1px hairlines (the border-strong grid
   background bleeds through the gaps), the whole pad framed and clipped so
   the corner cells round cleanly. Flat — the active cell is a solid fill. */
.reel-focus {
    display: grid;
    grid-template-columns: repeat(3, 30px);
    grid-template-rows: repeat(3, 30px);
    gap: 1px;
    padding: 1px;
    background: var(--pt-border-strong);
    border: 1px solid var(--pt-border-strong);
    border-radius: 6px;
    overflow: hidden;
}

.reel-focus__cell {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: var(--pt-chrome-bg);
    border: none;
    border-radius: 0;
    cursor: pointer;
    transition: background-color var(--pt-dur) var(--pt-ease);
}

.reel-focus__cell:hover { background: var(--pt-surface-raised); }

.reel-focus__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--pt-text-faint);
    transition: background-color var(--pt-dur) var(--pt-ease);
}

.reel-focus__cell.is-active { background: var(--pt-accent); }

.reel-focus__cell.is-active .reel-focus__dot { background: var(--pt-chrome-bg); }

/* ---- Render section ---- */

.reel-render__head {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

/* FORMAT readout — a dk-readout-chip whose value colour reports, honestly,
   which encoder you'll actually get. data-mode is set by reel.js. */
.reel-render__format { flex: 0 0 auto; }

.reel-render__format .dk-readout-chip__value { color: var(--pt-text-muted); }
.reel-render__format[data-mode="mp4"] .dk-readout-chip__value { color: var(--pt-ok); }
.reel-render__format[data-mode="webm"] .dk-readout-chip__value { color: var(--pt-accent); }
.reel-render__format[data-mode="none"] .dk-readout-chip__value { color: var(--pt-bad); }

.reel-render__caption {
    display: flex;
    flex-direction: column;
    gap: 0.1875rem;
    min-width: 0;
}

.reel-render__cap {
    margin: 0;
    font-family: var(--pt-font-ui);
    font-size: 0.8125rem;
    line-height: 1.4;
    color: var(--pt-text-secondary);
}

.reel-render__meta {
    margin: 0;
    font-family: var(--pt-font-mono);
    font-size: 0.75rem;
    color: var(--pt-text-muted);
}

.reel-render__meta.is-over { color: var(--pt-bad, #c0453b); }

.reel-caps-error { margin-top: 0.5rem; }

/* Progress = honest frame count + a solid bar built from nested divs. */
.reel-progress {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0.5rem 0;
}

.reel-progress__track {
    flex: 1 1 auto;
    height: 8px;
    background: var(--pt-border-strong);
    border-radius: 4px;
    overflow: hidden;
}

.reel-progress__fill {
    height: 100%;
    width: 0;
    background: var(--pt-accent);
    transition: width 0.12s linear;
}

.reel-progress__label {
    flex: 0 0 auto;
    margin: 0;
    font-family: var(--pt-font-mono);
    font-size: 0.75rem;
    color: var(--pt-text-secondary);
    white-space: nowrap;
}

.dk-stage.is-rendering .reel-layout,
.dk-stage.is-rendering .reel-panel {
    opacity: 0.55;
}

/* ---- Mobile (≤640px) ---- */
@media (max-width: 640px) {
    /* Stack the FORMAT pill above its caption so neither is squeezed. */
    .reel-render__head {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    /* The photo strip is a horizontal filmstrip on narrow screens (the
       ≥720px vertical column rule above simply doesn't apply here). */
    .reel-strip { width: 100%; }

    .reel-preview { flex-basis: 100%; }
}
