/* Make a shop reel (js/tools/reel.js): the preview with its clip settings, the sections beside it (one column on a phone),
   the progress while the reel is made, and the finished reel. Loaded when the tool opens, and the first screen waits for it.
   Colours and sizes come from the tokens in app.css, so the text-size button works here too. */

.rl { display: grid; gap: 20px; }
@media (min-width: 880px) {
  .rl { grid-template-columns: minmax(17rem, 23rem) minmax(0, 1fr); align-items: start; gap: 28px; }
  .rl-left { position: sticky; top: 12px; }
}
.rl-left, .rl-right { display: grid; gap: 16px; min-width: 0; }

/* ---------- the preview: tall like a reel ---------- */
.rl-stage { position: relative; width: min(100%, calc(62svh * 9 / 16)); min-width: min(100%, 15rem); aspect-ratio: 9 / 16; margin: 0 auto; overflow: hidden; border-radius: 18px; background: #0f172a; box-shadow: 0 0 0 1px var(--line-2); }
.rl-video, .rl-layer, .rl-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; }
.rl-video { object-fit: cover; background: transparent; }
.rl-video.whole { object-fit: contain; }
.rl-backdrop { object-fit: cover; filter: blur(14px) brightness(.72); transform: scale(1.08); }
.rl-backdrop[hidden] { display: none; }
.rl-layer { pointer-events: none; }
.rl-play { position: absolute; left: 12px; bottom: 12px; display: grid; place-items: center; width: 56px; height: 56px; border: 0; border-radius: 50%; background: rgba(15, 23, 42, .72); color: #fff; font-size: 1.15rem; cursor: pointer; }
.rl-play:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.rl-play[hidden], .rl-stage-time[hidden] { display: none; }
.rl-stage-time { position: absolute; right: 12px; bottom: 26px; padding: 2px 8px; border-radius: 8px; background: rgba(15, 23, 42, .72); color: #fff; font-size: .85rem; font-variant-numeric: tabular-nums; }
.rl-empty { position: absolute; inset: 0; display: grid; align-content: center; justify-items: center; gap: 14px; padding: 18px; background: linear-gradient(180deg, #1e293b, #0f172a); color: #e2e8f0; text-align: center; }
.rl-empty[hidden] { display: none; }
.rl-empty-title { font-size: 1.2rem; font-weight: 800; color: #fff; }
.rl-empty-hint { font-size: .92rem; color: #cbd5e1; }
.rl-empty .rl-add { width: 100%; }

/* the buttons that add clips */
.rl-add { display: grid; gap: 10px; }
.rl-add-btn { width: 100%; }
.rl-add-btn.busy { opacity: .45; pointer-events: none; }
.rl-ic { display: inline-flex; flex: none; }
.rl-clips-add .rl-add { grid-template-columns: repeat(auto-fit, minmax(min(100%, 12rem), 1fr)); }

/* ---------- the clip on the preview: trim, speed, picture ---------- */
.rl-cliptools { display: grid; gap: 12px; padding: 14px; border: 2px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.rl-cliptools[hidden] { display: none; }
.rl-trim { display: grid; gap: 8px; }
.rl-label { font-weight: 700; font-size: .95rem; }
.rl-trimbar { position: relative; height: 64px; margin: 0 14px; touch-action: none; user-select: none; -webkit-user-select: none; }
.rl-strip { position: absolute; inset: 6px 0; display: flex; overflow: hidden; border-radius: 8px; background: #1e293b; }
.rl-strip-pic { flex: 1 1 0; min-width: 0; height: 100%; object-fit: cover; }
canvas.rl-strip-pic { width: 0; }
.rl-sel { position: absolute; top: 0; bottom: 0; border: 3px solid var(--brand-2); border-radius: 10px; pointer-events: none; }
/* the parts of the clip that are cut off, greyed out */
.rl-dim { position: absolute; top: 6px; bottom: 6px; background: rgba(255, 255, 255, .62); pointer-events: none; }
.rl-dim.a { left: 0; border-radius: 8px 0 0 8px; }
.rl-dim.b { right: 0; border-radius: 0 8px 8px 0; }
.rl-playhead { position: absolute; top: 2px; bottom: 2px; width: 3px; margin-left: -1.5px; border-radius: 2px; background: #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .4); pointer-events: none; }
.rl-playhead[hidden] { display: none; }
.rl-handle { position: absolute; top: -4px; bottom: -4px; width: 28px; margin-left: -14px; padding: 0; border: 0; border-radius: 9px; background: var(--brand-2); cursor: ew-resize; touch-action: none; }
.rl-handle::after { content: ""; position: absolute; top: 50%; left: 50%; width: 4px; height: 24px; margin: -12px 0 0 -2px; border-radius: 2px; background: #fff; }
.rl-handle.focus { outline: 3px solid var(--ink); outline-offset: 2px; }
/* the two sliders under the handles: unseen and untouchable, but reachable with the keyboard and screen readers */
.rl-range { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; padding: 0; opacity: 0; pointer-events: none; }
.rl-handle.drag { background: var(--brand); }
.rl-trim-text { font-size: .95rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.rl-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.rl-row > .rl-label { min-width: 4.2rem; }
.rl-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.rl-chip { min-height: 44px; padding: 0 14px; border: 2px solid var(--line-2); border-radius: 999px; background: #fff; color: var(--ink); font-weight: 700; font-size: 1rem; cursor: pointer; }
.rl-chip[aria-checked="true"] { border-color: var(--brand-2); background: var(--brand-soft); color: var(--brand); }
.rl-chip:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.rl-clip-note[hidden] { display: none; }

/* ---------- the sections ---------- */
.rl-sec { display: grid; gap: 12px; padding: 18px 16px; border: 2px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.rl-sec h3 { font-size: 1.2rem; }
.rl-opt { color: var(--muted); font-weight: 400; font-size: .95rem; }
.rl-status { min-height: 1.4em; font-weight: 700; }
.rl-status:empty { display: none; }
.rl-sec input[type="text"] { width: 100%; min-height: 52px; padding: 0 14px; border: 2px solid var(--line-2); border-radius: 12px; background: #fff; color: var(--ink); font: inherit; font-size: 1.05rem; }
.rl-sec input[type="text"]:focus-visible { outline: 3px solid var(--brand); outline-offset: 1px; border-color: var(--brand-2); }

/* the clips, as a row of small tiles in their order (it scrolls sideways when they do not fit) */
.rl-clips { display: flex; gap: 10px; margin: 0; padding: 4px 2px 8px; overflow-x: auto; list-style: none; scroll-snap-type: x proximity; overscroll-behavior-x: contain; }
.rl-tile { flex: 0 0 4.9rem; scroll-snap-align: start; }
.rl-clips[hidden] { display: none; }
.rl-tile { display: grid; gap: 6px; min-width: 0; }
.rl-tile-main { position: relative; display: block; width: 100%; aspect-ratio: 9 / 16; padding: 0; overflow: hidden; border: 3px solid var(--line-2); border-radius: 12px; background: #1e293b; cursor: pointer; }
.rl-tile.on .rl-tile-main { border-color: var(--brand-2); box-shadow: 0 0 0 3px var(--brand-soft); }
.rl-tile-main:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.rl-tile-pic { display: block; width: 100%; height: 100%; object-fit: cover; }
.rl-tile-n { position: absolute; top: 6px; left: 6px; display: grid; place-items: center; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 13px; background: var(--brand-2); color: #fff; font-weight: 800; font-size: .9rem; }
.rl-tile-len { position: absolute; right: 4px; bottom: 4px; left: 4px; padding: 2px 2px; border-radius: 8px; background: rgba(15, 23, 42, .78); color: #fff; font-size: .78rem; font-weight: 700; text-align: center; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rl-mini { display: grid; place-items: center; min-width: 0; height: 40px; padding: 0; border: 2px solid var(--line-2); border-radius: 10px; background: #fff; color: var(--ink); font-size: 1rem; font-weight: 700; cursor: pointer; }
.rl-mini:disabled { opacity: .35; cursor: default; }
.rl-mini:focus-visible { outline: 3px solid var(--brand); outline-offset: 1px; }
.rl-tile.busy { display: grid; place-items: center; height: calc(4.9rem * 16 / 9); border: 3px dashed var(--line-2); border-radius: 12px; }
/* the clip on the preview: which one it is, and Earlier, Later, Remove */
.rl-which-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; }
.rl-which-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.rl-spin { display: inline-block; flex: none; width: 26px; height: 26px; border: 4px solid var(--brand-soft); border-top-color: var(--brand-2); border-radius: 50%; animation: spin .9s linear infinite; }
@media (prefers-reduced-motion: reduce) { .rl-spin { animation-duration: 3s; } }

/* the brand */
.rl-brand { display: grid; gap: 12px; }
.rl-sum { display: flex; align-items: center; gap: 12px; }
.rl-sum-pic { flex: none; max-width: 56px; max-height: 56px; border-radius: 10px; background: var(--checker); }
.rl-sum-text { display: grid; flex: 1 1 auto; min-width: 0; }
.rl-sum-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rl-form { display: grid; gap: 16px; }
.rl-field { display: grid; gap: 8px; }
.rl-logo-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.rl-logo-pic, .rl-frame-pic { flex: none; max-width: 64px; max-height: 72px; border-radius: 8px; background: var(--checker); box-shadow: 0 0 0 1px var(--line-2); }
.rl-colours { display: flex; flex-wrap: wrap; gap: 8px; }
.rl-swatch { width: 44px; height: 44px; padding: 0; border: 3px solid #fff; border-radius: 50%; background: var(--sw); box-shadow: 0 0 0 2px var(--line-2); color: #fff; font-size: .7rem; font-weight: 800; cursor: pointer; }
.rl-swatch.logo { width: auto; min-width: 58px; padding: 0 10px; border-radius: 22px; }
.rl-swatch[aria-checked="true"] { box-shadow: 0 0 0 3px var(--brand-2); }
.rl-swatch:focus-visible { outline: 3px solid var(--ink); outline-offset: 3px; }
.rl-frame { display: grid; gap: 10px; }
.rl-frame-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px; }
.rl-frame-row > div { display: grid; gap: 2px; }
.rl-ok { color: var(--ok); font-weight: 700; font-size: .95rem; }
.rl-warn { color: var(--bad); font-weight: 700; }
.rl-warn[hidden] { display: none; }
.rl-photo-frames { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.rl-photo-frame { padding: 3px; border: 2px solid var(--line-2); border-radius: 10px; background: var(--checker); cursor: pointer; }
.rl-photo-frame canvas { display: block; max-height: 64px; width: auto; }
.rl-form-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; }
.rl-kept { font-size: .92rem; color: var(--ok); font-weight: 700; }
.rl-kept:empty { display: none; }

/* sliders: label, slider, value */
.rl-slider { display: grid; grid-template-columns: minmax(7rem, auto) minmax(0, 1fr) 3.4rem; align-items: center; gap: 10px; }
.rl-slider input[type="range"] { width: 100%; min-height: 44px; accent-color: var(--brand-2); }
.rl-vol { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
@media (max-width: 420px) {
  .rl-slider { grid-template-columns: minmax(0, 1fr) 3.4rem; }
  .rl-slider label { grid-column: 1 / -1; }
}
.rl-music { display: grid; gap: 12px; }
.rl-music-add { justify-self: start; }
.rl-song { display: grid; grid-template-columns: auto minmax(0, 1fr) 48px; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); }
.rl-song-text { display: grid; min-width: 0; }
.rl-song-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rl-song-btns { display: flex; flex-wrap: wrap; gap: 8px; }

/* the fade switch */
.rl-sec-row { grid-template-columns: auto minmax(0, 1fr); align-items: center; }
.rl-sec-row label { display: grid; gap: 2px; cursor: pointer; }
.rl-switch { width: 28px; height: 28px; margin: 0; accent-color: var(--brand-2); cursor: pointer; }

/* a page opened inside an app's own browser */
.rl-inapp { grid-column: 1 / -1; }
.rl-linkbtn { padding: 0; border: 0; background: none; color: var(--brand); font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }

/* Make */
.rl-make { display: grid; gap: 10px; padding: 4px 0 8px; }
.rl-total { font-size: 1.1rem; }
.rl-total:empty { display: none; }

/* ---------- while the reel is made ---------- */
.rl-progress { display: grid; justify-items: center; gap: 16px; max-width: 34rem; margin: 6vh auto; padding: 28px 20px; border: 2px solid var(--line); border-radius: var(--radius); background: var(--surface); text-align: center; }
.rl-progress-head { display: flex; align-items: center; gap: 12px; }
.rl-progress-head h2 { font-size: 1.4rem; }
.rl-bar { width: 100%; height: 16px; overflow: hidden; border-radius: 8px; background: var(--brand-soft); }
.rl-bar > span { display: block; width: 0; height: 100%; border-radius: 8px; background: var(--brand-2); transition: width .2s; }
.rl-progress-words { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- the finished reel ---------- */
.rl-result-body { display: grid; gap: 20px; }
@media (min-width: 760px) { .rl-result-body { grid-template-columns: minmax(15rem, 21rem) minmax(0, 1fr); align-items: start; } }
.rl-result-stage { width: min(100%, calc(64svh * 9 / 16)); min-width: min(100%, 14rem); aspect-ratio: 9 / 16; margin: 0 auto; overflow: hidden; border-radius: 18px; background: #000; }
.rl-result-video { display: block; width: 100%; height: 100%; object-fit: contain; background: #000; }
.rl-result .result-foot { display: flex; flex-wrap: wrap; gap: 10px; }
