/* Scenes — pill tabs in header, create menu, transitions panel.
   Matches the existing app vocabulary: monospace eyebrows, teal accent
   on selection, var(--bg-*) surfaces, var(--border-*) hairlines. */

/* ---------- Scene tabs ---------- */
.scene-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 14px;
  padding-left: 14px;
  border-left: 1px solid var(--border-1);
  min-width: 0;
  /* Fill remaining header width so chips have room to lay out. When
     they overflow, wrap to a new row below — header grows with content. */
  flex: 1 1 0;
  flex-wrap: wrap;
  row-gap: 6px;
}

.scene-tab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 12px;
  height: 22px;
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--fg-2);
  transition: background var(--dur-fast), border-color var(--dur-fast),
              color var(--dur-fast), transform var(--dur-fast);
  white-space: nowrap;
  user-select: none;
  max-width: 200px;
  flex: none;
}
.scene-tab.dragging {
  opacity: 0.45;
  cursor: grabbing;
}
.scene-tab.drop-target {
  border-color: var(--teal-400);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--teal-400) 35%, transparent);
}
.scene-tab:hover { background: var(--bg-3); color: var(--fg-1); }
.scene-tab.active {
  background: color-mix(in oklab, var(--teal-400) 14%, var(--bg-2));
  border-color: var(--teal-400);
  color: var(--fg-0);
}
/* Only tighten the right padding when there's actually a close button
   inside the active tab — otherwise the chip stays symmetric. */
.scene-tab.active:has(.scene-tab-close) { padding-right: 6px; }
.scene-tab-name {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}
.scene-tab.auto .scene-tab-name { letter-spacing: 0.005em; }

.scene-tab-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--fg-3);
  flex: none;
}
.scene-tab-dot.analyzing {
  background: var(--teal-400);
  animation: scenePulse 1.2s ease-in-out infinite;
}
.scene-tab-dot.ready { background: var(--teal-400); }
.scene-tab-dot.error { background: var(--color-danger, #e25555); }
@keyframes scenePulse {
  0%, 100% { opacity: 0.4; transform: scale(0.85); }
  50% { opacity: 1; transform: scale(1.15); }
}

.scene-tab-input {
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--fg-0);
  font: inherit;
  width: 130px;
  padding: 0;
}

.scene-tab-close {
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--fg-2);
  width: 18px;
  height: 18px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  margin-left: 2px;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.scene-tab-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--fg-0);
}

.scene-tab-plus {
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  flex: none;
  background: transparent;
  border: 1px dashed var(--border-2);
  color: var(--fg-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast),
              color var(--dur-fast);
}
.scene-tab-plus:hover,
.scene-tab-plus.open {
  border-color: var(--teal-400);
  color: var(--teal-400);
  background: color-mix(in oklab, var(--teal-400) 8%, transparent);
}

/* ---------- Create-scene popdown ---------- */
.scene-create-menu {
  z-index: 60;
  background: var(--bg-1);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  padding: 12px;
  width: 380px;
  box-shadow: var(--shadow-2);
  backdrop-filter: blur(12px);
}

.scene-create-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.scene-create-card {
  appearance: none;
  background: var(--bg-2);
  border: 1px solid var(--border-1);
  border-radius: var(--r-md);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  text-align: left;
  cursor: pointer;
  color: var(--fg-1);
  transition: background var(--dur-fast), border-color var(--dur-fast),
              transform var(--dur-fast);
}
.scene-create-card:hover {
  background: var(--bg-3);
  border-color: var(--teal-400);
  transform: translateY(-1px);
}

.scene-create-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--bg-0);
  border: 1px solid var(--border-1);
  color: var(--teal-400);
  margin-bottom: 2px;
}

.scene-create-title {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-0);
}
.scene-create-sub {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--fg-3);
  line-height: 1.45;
}

.scene-create-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.scene-create-form-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-3);
  margin-bottom: 2px;
}
.scene-create-form-title::before { content: '// '; color: var(--fg-4); }

.scene-create-input {
  width: 100%;
  background: var(--bg-0);
  border: 1px solid var(--border-2);
  border-radius: var(--r-sm);
  color: var(--fg-1);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 8px 10px;
  outline: 0;
}
.scene-create-input:focus { border-color: var(--teal-400); }
.scene-create-input::placeholder { color: var(--fg-4); }

.scene-create-form-hint {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--fg-3);
  line-height: 1.5;
  padding: 2px 2px 4px;
}
.scene-create-form-hint::before { content: '// '; color: var(--fg-4); }

.scene-create-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 4px;
}
.scene-create-btn,
.scene-create-btn-ghost {
  appearance: none;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-radius: var(--r-sm);
  padding: 8px 14px;
  cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast),
              color var(--dur-fast);
}
.scene-create-btn {
  background: var(--teal-400);
  border: 1px solid var(--teal-400);
  color: var(--bg-0);
  font-weight: 600;
}
.scene-create-btn:hover:not(:disabled) {
  background: var(--teal-500, var(--teal-400));
}
.scene-create-btn:disabled {
  background: var(--bg-3);
  border-color: var(--border-2);
  color: var(--fg-4);
  cursor: not-allowed;
}
.scene-create-btn-ghost {
  background: transparent;
  border: 1px solid var(--border-2);
  color: var(--fg-2);
}
.scene-create-btn-ghost:hover {
  border-color: var(--fg-2);
  color: var(--fg-0);
}

/* ---------- Scene transitions panel (below right rail) ---------- */
/* The panel publishes its actual rendered height to --bb-anim-panel-h
   on <html> via ResizeObserver. The rail's bottom edge tracks the
   panel's top minus a constant 12px gap — so the visual gap between
   the two panels stays identical whether the panel is collapsed or
   expanded, regardless of how tall the open panel actually is. */
.right-rail.with-transitions {
  bottom: calc(20px + var(--bb-anim-panel-h, 45px) + 12px);
  height: auto;
  transition: bottom var(--dur-med) var(--ease-out);
}

.scene-transitions {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 320px;
  z-index: 25;
  background: rgba(17, 22, 29, 0.92);
  border: 1px solid var(--border-2);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  backdrop-filter: blur(12px);
  overflow: hidden;
  /* Cap so a tall list doesn't push the rail off-screen. */
  max-height: 60vh;
  display: flex;
  flex-direction: column;
}

.scene-transitions-header {
  appearance: none;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid transparent;
  cursor: pointer;
  text-align: left;
  transition: background var(--dur-fast), border-color var(--dur-fast);
}
.scene-transitions.open .scene-transitions-header {
  border-bottom-color: var(--border-1);
}
.scene-transitions-header:hover { background: rgba(45, 212, 160, 0.04); }

.scene-transitions-title {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-1);
  flex: 1;
}
.scene-transitions-title::before { content: '// '; color: var(--fg-3); }

.scene-transitions-meta {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--fg-3);
}

.scene-transitions-caret {
  display: inline-flex;
  color: var(--fg-3);
  transition: transform var(--dur-med) var(--ease-out);
}
.scene-transitions:not(.open) .scene-transitions-caret { transform: rotate(-90deg); }

.scene-transitions-body {
  padding: 12px 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.scene-transitions-from {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--fg-3);
  margin-bottom: 2px;
}
.scene-transitions-from strong { color: var(--fg-0); font-weight: 600; }

.scene-transitions-empty {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--fg-3);
  padding: 8px 4px;
  border: 1px dashed var(--border-1);
  border-radius: var(--r-sm);
  text-align: center;
}

.scene-transition-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 0;
  border-top: 1px solid var(--border-1);
}
.scene-transition-row:first-of-type { border-top: 0; padding-top: 4px; }

.scene-transition-target {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--fg-1);
  font-weight: 500;
}

.scene-transition-controls {
  display: grid;
  grid-template-columns: 1.2fr 1.2fr 56px auto;
  gap: 6px;
  align-items: center;
}

.scene-transition-select,
.scene-transition-num {
  appearance: none;
  background: var(--bg-0);
  border: 1px solid var(--border-1);
  border-radius: var(--r-sm);
  color: var(--fg-1);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 5px 7px;
  outline: 0;
}
.scene-transition-select:focus,
.scene-transition-num:focus { border-color: var(--teal-400); }

.scene-transition-num {
  width: 100%;
  text-align: right;
  -moz-appearance: textfield;
}
.scene-transition-num::-webkit-outer-spin-button,
.scene-transition-num::-webkit-inner-spin-button { display: none; }

.scene-transition-unit {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--fg-3);
  letter-spacing: 0.06em;
}

.scene-transitions-export {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
  padding: 8px 12px;
  background: color-mix(in oklab, var(--teal-400) 12%, var(--bg-2));
  border: 1px solid var(--teal-400);
  border-radius: var(--r-sm);
  color: var(--fg-0);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background var(--dur-fast);
}
.scene-transitions-export:hover {
  background: color-mix(in oklab, var(--teal-400) 22%, var(--bg-2));
}
.scene-transitions-export svg { color: var(--teal-400); }

/* ---------- Scene preview animations ---------- */
/* Per-block orchestrated transition. App.jsx drives a RAF tick that:
   - lerps canvas.W/D/H so the wireframe frame morphs smoothly;
   - tags each block with a `_previewRole` (exit/persist/enter) and
     applies inline transform+opacity on a wrapper <g>.
   The CSS here is mostly for the wrapper performance hint and the
   preview-mode "frame" affordance. */

.stage-anim {
  position: relative;
  transform-origin: 50% 50%;
}

.bb-block-anim {
  will-change: transform, opacity;
}
.bb-block-exit,
.bb-block-enter {
  /* Inline style on each <g> sets transform/opacity per-frame; this
     class just hints to the GPU. */
  pointer-events: none;
}

/* Preview button — primary accent, like Export was. */
.scene-transitions-export svg polygon { fill: var(--teal-400); }
