/* Video Layout Studio — two-step flow: a layout card (frame + gallery), then
   the build view: a bar, the stage card beside the clips inspector, and the
   result card; output settings live in the Options sheet (layout from
   styles/components/form.css). Each slot on the stage is an uploader drop
   surface (styles/components/uploader.css paints its scrim). Only the layout
   diagrams, the stage and its tiles, the transport and the clip rows' insides
   are the page's own. */

/* Selectors below that style a form field are written input.<class>: the
   shared form rule input[type="…"] in common.css is (0,1,1) and silently
   beats a bare class, so these declarations never used to apply. */

.vgr-title-icon {
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #06b6d4, #0284c7);
}

/* ── Step 1 · layout gallery ───────────────────────────────────────────── */
.vgr-frame-row { flex-wrap: wrap; }

.vgr-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: var(--space-3);
}

.vgr-card {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-2);
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  color: var(--text-dim);
  cursor: pointer;
  text-align: center;
  box-shadow: var(--shadow-1);
  transition: border-color 0.14s ease, color 0.14s ease, transform 0.08s ease, box-shadow 0.14s ease;
}

.vgr-card:hover {
  border-color: var(--border-strong);
  color: var(--text);
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
}

.vgr-card:active { transform: translateY(0) scale(0.99); }

.vgr-card.is-active {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow-2);
}

.vgr-card-mini {
  position: relative;
  width: 100%;
  border-radius: var(--radius-sm);
  background: var(--bg-recessed);
  overflow: hidden;
}

/* Schematic tiles — neutral so they read on both themes, accent when picked. */
.vgr-card-cell {
  position: absolute;
  background: var(--text-dim);
  border-radius: 2.5px;
  box-shadow: inset 0 0 0 1.5px var(--bg-recessed);
}

.vgr-card.is-active .vgr-card-cell { background: var(--accent); }

.vgr-card-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: inherit;
}

.vgr-card-sub {
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Step 2 · build bar ────────────────────────────────────────────────── */
.vgr-build-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-dim);
}

input.vgr-input {
  width: 96px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  letter-spacing: -0.01em;
  border-radius: var(--radius-md);
}

/* ── Stage ─────────────────────────────────────────────────────────────── */
.vgr-stage {
  position: relative;
  width: 100%;
  /* Preserve the frame aspect AND keep the box inside the viewport height:
     cap width to (maxH × aspect) so portrait/square frames stay correctly
     shaped instead of being squished into a full-width landscape box.
     --ar-num (numeric aspect) + aspect-ratio are set inline per frame. */
  --stage-maxh: 58vh;
  max-width: calc(var(--stage-maxh) * var(--ar-num, 1.7778));
  max-height: var(--stage-maxh);
  aspect-ratio: 16 / 9; /* overridden inline by the chosen frame */
  margin-inline: auto;
  background: #000;
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}

.vgr-tile {
  position: absolute;
  overflow: hidden;
  background: #050505;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.10);
}

.vgr-tile video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  display: block;
}

.vgr-tile--add {
  display: grid;
  place-items: center;
  border: none;
  background: #0c0c0d;
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: color 0.12s ease, background 0.12s ease, box-shadow 0.12s ease;
}

.vgr-tile--add:hover,
.vgr-tile--add:focus-visible {
  color: #fff;
  background: #15171a;
  box-shadow: inset 0 0 0 1.5px var(--accent);
  outline: none;
}

.vgr-add-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  font-size: 12px;
  font-weight: 600;
}

.vgr-tile.is-dragover {
  box-shadow: inset 0 0 0 2px var(--accent);
}
/* The drop scrim is translucent: hide the empty slot's own label under it. */
.vgr-tile.is-dragover .vgr-add-inner { visibility: hidden; }

.vgr-tile-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  max-width: calc(100% - 44px);
  padding: 3px 8px 3px 4px;
  border-radius: var(--radius-pill);
  background: var(--scrim);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: -0.01em;
  pointer-events: none;
}

.vgr-tile-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  flex: none;
}

.vgr-tile-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vgr-tile-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--scrim);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fff;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.12s ease, background 0.12s ease;
}

.vgr-tile:hover .vgr-tile-remove,
.vgr-tile-remove:focus-visible { opacity: 1; }
.vgr-tile-remove:hover { background: var(--danger); }

/* ── Transport ─────────────────────────────────────────────────────────── */
.vgr-play {
  flex: none;
  width: 44px;
  height: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.vgr-time {
  flex: none;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 92px;
  text-align: right;
}

.vgr-seek,
.vgr-clip-range {
  flex: 1 1 auto;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: var(--radius-pill);
  background: var(--bg-recessed);
  cursor: pointer;
  margin: 0;
}

.vgr-seek::-webkit-slider-thumb,
.vgr-clip-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-elev);
  box-shadow: var(--shadow-thumb);
  cursor: grab;
}

.vgr-seek::-moz-range-thumb,
.vgr-clip-range::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-elev);
  box-shadow: var(--shadow-thumb);
  cursor: grab;
}

/* ── Clip list ─────────────────────────────────────────────────────────── */
.vgr-count {
  color: var(--text-muted);
  font-weight: 500;
}

/* Each clip is a row of the Clips card (the card draws the inset and the
   hairlines); inside it: number · name + meta · tools, then the start slider. */
.vgr-clip {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

.vgr-clip-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  flex: none;
}

.vgr-clip-num--empty {
  background: var(--bg-recessed);
  color: var(--text-muted);
}

.vgr-clip-main { min-width: 0; }

.vgr-clip-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vgr-clip-name--empty {
  color: var(--text-muted);
  font-weight: 500;
}

.vgr-clip-meta {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  }

.vgr-clip-tools {
  display: inline-flex;
  align-items: center;
  gap: 0;
}

.vgr-iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease;
}

.vgr-iconbtn:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text);
}

.vgr-iconbtn:disabled { opacity: 0.3; cursor: default; }

.vgr-iconbtn--danger:hover:not(:disabled) {
  background: var(--danger-soft);
  color: var(--danger);
}

.vgr-clip-start {
  grid-column: 2 / -1;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.vgr-clip-start__label {
  font-size: 12px;
  color: var(--text-muted);
  flex: none;
}

.vgr-clip-start input[type="number"] {
  width: 74px;
  padding: 5px 8px;
  font-size: 13px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Progress / result ─────────────────────────────────────────────────── */
.vgr-result-meta {
  font: 12px/1.35 var(--mono);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ── Mobile ────────────────────────────────────────────────────────────────
   Below ~520px the frame label + 4-button segment can't sit on one line, so
   the segment takes a line of its own, stretches and wraps (mirrors
   .segment--full). */
@media (max-width: 520px) {
  .vgr-frame-control { flex: 1 1 100%; }

  #vgr-frame {
    display: flex;
    width: 100%;
    flex-wrap: wrap;
  }

  #vgr-frame .segment__btn {
    flex: 1 1 auto;
    min-width: 0;
    padding: 7px 10px;
  }
}
