/*
 * The /new live editor. Layered on top of styles.css's tokens (--accent, --surface,
 * --border, --text, …) — no new palette. Loaded only by the private, noindex pages that
 * use it, per server/src/seo.js.
 */

/* DejaVu Sans is not on Google Fonts. This is the closest metric-compatible fallback
   family available there — widths are close but not pixel-identical to the server's
   DejaVu Sans Bold, which is why web/editor.js documents that dragged X positions are an
   approximation, not exact. */
@import url('https://fonts.googleapis.com/css2?family=Verdana&display=swap');

.ed-page { max-width: 1400px; margin: 0 auto; padding: 0 var(--space-3) var(--space-6); position: relative; z-index: 1; }
.ed-header { margin-bottom: var(--space-3); gap: var(--space-2); }

.editor {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr) 340px;
  gap: var(--space-3);
  align-items: start;
}

/* --- steps rail --- */
.ed-steps { display: flex; flex-direction: column; gap: 6px; position: sticky; top: var(--space-3); }
.ed-step-btn {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text-2); font: inherit; font-weight: 600; font-size: 0.86rem;
  padding: 10px 12px; cursor: pointer; text-align: left;
}
.ed-step-btn:hover { border-color: var(--accent); color: var(--text); }
.ed-step-btn.active { border-color: var(--accent); background: rgba(124, 108, 255, 0.1); color: var(--text); }
.ed-step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%; background: var(--surface-2);
  font-size: 0.72rem; flex: none;
}
.ed-step-btn.active .ed-step-num { background: var(--accent); color: var(--accent-text); }

/* --- centre: preview + timeline --- */
.ed-center { display: flex; flex-direction: column; gap: var(--space-3); min-width: 0; }
.ed-stage-wrap { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); }

.ed-stage {
  position: relative;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  touch-action: none;
  max-width: 100%;
}
.ed-stage video { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; }
.ed-stage canvas { display: block; width: 100%; height: 100%; }

.ed-drag-handle {
  position: absolute;
  width: 26px; height: 26px;
  margin-left: -13px; margin-top: -13px;
  border-radius: 50%;
  background: rgba(124, 108, 255, 0.85);
  border: 2px solid #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  cursor: grab;
  display: none;
}
.ed-drag-handle:active { cursor: grabbing; }
.ed-drag-handle:focus-visible { outline: 3px solid var(--accent-strong); outline-offset: 2px; }

.ed-transport { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 420px; }
.ed-transport #ed-seek { flex: 1; accent-color: var(--accent); }

.ed-timeline-wrap { display: flex; flex-direction: column; gap: 8px; }
.ed-timeline {
  display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px;
  scrollbar-width: thin;
}
.ed-clip {
  flex: none; display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: 74px; padding: 10px 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text-2); cursor: pointer; font: inherit;
}
.ed-clip:hover { border-color: var(--accent); }
.ed-clip.selected { border-color: var(--accent); background: rgba(124, 108, 255, 0.12); color: var(--text); }
.ed-clip-index { font-weight: 800; font-size: 1rem; color: var(--text); }

/* --- right: settings --- */
.ed-settings { display: flex; flex-direction: column; gap: var(--space-3); min-width: 0; }
.ed-panel[hidden] { display: none; }
.ed-step-nav { display: flex; justify-content: space-between; gap: 10px; }

/* --- sticky bottom bar --- */
.ed-bottombar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  margin-top: var(--space-4);
  padding: var(--space-2) var(--space-3);
  background: rgba(20, 19, 29, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.ed-bottombar-info { display: flex; flex-direction: column; gap: 2px; }
.ed-bottombar-info strong { font-size: 1rem; }

/* --- mobile: stepper, preview pinned at top, one panel visible at a time --- */
@media (max-width: 999px) {
  .editor { grid-template-columns: 1fr; }
  .ed-steps {
    position: static;
    flex-direction: row;
    overflow-x: auto;
    gap: 8px;
  }
  .ed-step-btn { flex: none; padding: 8px 12px; }
  .ed-step-btn span:last-child { display: none; }
  .ed-step-btn.active span:last-child { display: inline; }
  .ed-center { order: -1; }
  .ed-stage { width: 100% !important; height: auto !important; aspect-ratio: var(--ed-ratio, 9 / 16); }
  .ed-stage canvas { width: 100% !important; height: 100% !important; }
  .ed-bottombar { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  .ed-bottombar, .ed-clip, .ed-step-btn { transition: none !important; }
}
