/* Video editor styles. The design system, shell, buttons, modals and theme tokens all come from
 * app.BG15.css, including the shared tab strip; this file only adds the timeline. */

@layer app {
  /* ---------------------------------------------------------------- stage */
  .stage-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 290px;
    gap: 16px;
    align-items: start;
    margin-bottom: 16px;
  }

  @media (max-width: 900px) {
    .stage-row {
      grid-template-columns: minmax(0, 1fr);
    }
  }

  .preview-pane-video {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
  }

  /* A fixed stage rather than an aspect ratio: the clips are a mix of portrait and landscape,
     and letting the frame follow the video makes the page jump between clips. */
  .preview-frame {
    position: relative;
    height: clamp(240px, 42vh, 460px);
    background: #05070d;
    display: grid;
    place-items: center;
    overflow: hidden;
  }

  .preview-frame video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    background: #05070d;
  }

  .preview-empty {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    color: #8b98b0;
    font-size: 14px;
    pointer-events: none;
  }

  .transport {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-top: 1px solid var(--line);
    flex-wrap: wrap;
  }

  .scrub {
    flex: 1 1 160px;
    min-width: 120px;
    accent-color: var(--accent);
  }

  .time-label {
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
    color: var(--text-2);
    font-weight: 650;
    white-space: nowrap;
  }

  /* ---------------------------------------------------------------- inspector */
  .clip-inspector {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 16px;
  }

  .clip-inspector h2 {
    margin: 0 0 14px;
    font-size: 14px;
    font-weight: 700;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .clip-inspector .field {
    margin-bottom: 10px;
  }

  .clip-inspector input[type="number"] {
    width: 100%;
    padding: 8px 10px;
  }

  .trim-rails {
    display: grid;
    gap: 4px;
    margin: 10px 0 12px;
  }

  .trim-rails input[type="range"] {
    width: 100%;
    accent-color: var(--accent);
  }

  .clip-facts {
    font-size: 12px;
    color: var(--text-3);
    line-height: 1.6;
    margin-bottom: 12px;
  }

  .inspector-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
  }

  /* ---------------------------------------------------------------- timeline */
  .timeline-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 14px;
    margin-bottom: 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
  }

  .timeline-summary {
    font-size: 13px;
    color: var(--text-2);
  }

  .timeline-summary strong {
    color: var(--text);
  }

  .clip-track {
    list-style: none;
    margin: 0;
    padding: 12px;
    display: flex;
    gap: 10px;
    overflow-x: auto;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    min-height: 150px;
  }

  .clip-card {
    position: relative;
    flex: 0 0 176px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    cursor: pointer;
    transition:
      border-color 0.15s ease,
      box-shadow 0.15s ease;
  }

  .clip-card:hover {
    border-color: var(--line-strong);
  }

  .clip-card.is-active {
    border-color: var(--accent);
    box-shadow: var(--ring);
  }

  .clip-card.is-dragging {
    opacity: 0.45;
  }

  .clip-card.drop-before {
    border-left: 3px solid var(--accent);
  }

  .clip-card.drop-after {
    border-right: 3px solid var(--accent);
  }

  .clip-thumb {
    position: relative;
    aspect-ratio: 16 / 10;
    background: #05070d;
  }

  .clip-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }

  .clip-index {
    position: absolute;
    top: 6px;
    left: 6px;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 6px;
    background: color-mix(in srgb, var(--text) 78%, transparent);
    color: var(--bg);
    font-size: 11px;
    font-weight: 800;
    display: grid;
    place-items: center;
  }

  .clip-length {
    position: absolute;
    right: 6px;
    bottom: 6px;
    padding: 3px 7px;
    border-radius: 6px;
    background: color-mix(in srgb, var(--text) 78%, transparent);
    color: var(--bg);
    font-size: 11px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
  }

  .clip-trimmed {
    position: absolute;
    left: 6px;
    bottom: 6px;
    padding: 3px 7px;
    border-radius: 6px;
    background: var(--accent);
    color: var(--on-accent);
    font-size: 10.5px;
    font-weight: 800;
  }

  .clip-body {
    padding: 8px 10px;
  }

  .clip-name {
    font-size: 12.5px;
    font-weight: 650;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .clip-meta {
    font-size: 11px;
    color: var(--text-3);
    margin-top: 2px;
  }

  .clip-buttons {
    display: flex;
    gap: 4px;
    padding: 0 8px 8px;
  }

  .clip-btn {
    flex: 1;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--text-2);
    border-radius: 7px;
    padding: 5px 0;
    font-size: 12px;
    font-weight: 650;
    line-height: 1.2;
  }

  .clip-btn:hover:not(:disabled) {
    background: var(--surface-2);
    color: var(--text);
  }

  .clip-btn.danger:hover:not(:disabled) {
    background: var(--danger-soft);
    color: var(--danger);
    border-color: color-mix(in srgb, var(--danger) 40%, var(--line-strong));
  }

  .clip-track-empty {
    margin: auto;
    color: var(--text-3);
    font-size: 13px;
  }

  /* ---------------------------------------------------------------- export */
  .export-progress {
    height: 5px;
    border-radius: 999px;
    background: var(--surface-3);
    overflow: hidden;
    flex: 1 1 140px;
    min-width: 100px;
  }

  .export-progress span {
    display: block;
    height: 100%;
    width: 0;
    background: var(--accent);
    border-radius: 999px;
    transition: width 0.2s ease;
  }

  .export-dialog {
    width: min(720px, calc(100% - 32px));
  }

  .export-dialog video {
    width: 100%;
    max-height: 52vh;
    border-radius: var(--radius);
    background: #05070d;
    display: block;
  }

  .export-facts {
    margin-top: 14px;
    font-size: 13px;
    color: var(--text-2);
    font-variant-numeric: tabular-nums;
  }

  .export-facts strong {
    color: var(--text);
  }

  #exportWarnings {
    margin-top: 12px;
  }

  @media (max-width: 680px) {
    .clip-card {
      flex-basis: 150px;
    }

    .transport {
      gap: 8px;
    }
  }
}

@layer app {
  /* ---- Inspector groups ---- */
  .inspector-group {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
  }

  .inspector-group .section-title {
    margin-bottom: 8px;
  }

  .inspector-group .field + .field,
  .inspector-group .field + .inspector-actions,
  .inspector-group .inline-check + .field {
    margin-top: 9px;
  }

  .ghost-btn[aria-pressed="true"] {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
  }

  /* ---- Crop box over the preview ----
   * The overlay covers the whole frame, including the letterbox bars, because the crop is
   * measured against the source picture rather than whatever the preview happens to show. */
  .vcrop-overlay {
    position: absolute;
    inset: 0;
    z-index: 3;
  }

  .vcrop-box {
    position: absolute;
    border: 2px solid var(--accent);
    box-shadow: 0 0 0 100vmax rgb(0 0 0 / 0.5);
    cursor: move;
    touch-action: none;
  }

  .vcrop-handle {
    position: absolute;
    width: 16px;
    height: 16px;
    background: var(--accent);
    border-radius: 3px;
    touch-action: none;
  }

  .vcrop-handle[data-edge="nw"] {
    left: -8px;
    top: -8px;
    cursor: nwse-resize;
  }
  .vcrop-handle[data-edge="ne"] {
    right: -8px;
    top: -8px;
    cursor: nesw-resize;
  }
  .vcrop-handle[data-edge="sw"] {
    left: -8px;
    bottom: -8px;
    cursor: nesw-resize;
  }
  .vcrop-handle[data-edge="se"] {
    right: -8px;
    bottom: -8px;
    cursor: nwse-resize;
  }

  /* ---- Text overlay list ---- */
  .overlay-list {
    list-style: none;
    margin: 0 0 10px;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .overlay-row {
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--surface-2);
    padding: 9px;
  }

  .overlay-row textarea {
    width: 100%;
    min-height: 44px;
    resize: vertical;
    padding: 6px 8px;
    border-radius: 7px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 13px;
  }

  .overlay-row textarea:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
  }

  .overlay-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(86px, 1fr));
    gap: 7px;
    margin-top: 7px;
  }

  .overlay-grid label {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--text-3);
    min-width: 0;
  }

  .overlay-grid input,
  .overlay-grid select {
    width: 100%;
    padding: 5px 6px;
    border-radius: 6px;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--text);
    font-size: 12.5px;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
  }

  .overlay-grid input[type="color"] {
    padding: 2px;
    height: 28px;
  }

  .overlay-row-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
  }

  .overlay-row-head strong {
    flex: 1;
    font-size: 12px;
    color: var(--text-2);
  }

  .overlay-empty {
    font-size: 12.5px;
    color: var(--text-3);
    padding: 6px 0;
  }
}
