/* Wave 4: the video library as a gallery, the editing queue's drop tile and
   preview, the pipeline as a funnel strip, and the brand guidelines as the
   creator's shelf. Loads after hub.css and the wave 2 and 3 files, so a rule
   here wins at equal specificity. Tokens come from hub.css :root. */

/* ---------------------------------------------------------------------
   Small shared bits.
   --------------------------------------------------------------------- */
.mt-sm { margin-top: 10px; }

/* ---------------------------------------------------------------------
   Videos: the gallery of first frames.
   --------------------------------------------------------------------- */
.gallery-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.video-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 18px 14px;
}

.video-tile {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

/* The tile is a button that fills its cell; the dialog span around it has
   no box of its own. */
.video-tile > span[data-controller="dialog"] {
  display: block;
}

.video-tile-open {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
  border-radius: var(--r);
  transition: transform var(--dur-fast) var(--ease-out);
}

.video-tile-open:active {
  transform: scale(.98);
}

.video-tile-open:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.video-tile-frame {
  position: relative;
  display: block;
  aspect-ratio: 9 / 16;
  width: 100%;
  border-radius: var(--r);
  overflow: hidden;
  background: var(--surface-soft);
  box-shadow: var(--ring);
  transition: box-shadow var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}

.video-tile-open:hover .video-tile-frame {
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
}

.video-tile-poster {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  animation: fade-rise var(--dur-enter) var(--ease-out);
}

/* No frame yet: the creator's initial on the soft surface. */
.video-tile-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Quicksand", sans-serif;
  font-weight: 700;
  font-size: 40px;
  color: var(--ink-mute);
}

.video-tile-duration {
  position: absolute;
  right: 8px;
  bottom: 12px;
  padding: 2px 7px;
  border-radius: var(--r-pill);
  background: rgba(0, 0, 0, .68);
  color: #fff;
  font-size: var(--fs-label);
  font-weight: 700;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}

.video-tile-dot {
  position: absolute;
  top: 10px;
  left: 10px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .35);
}

/* Rights as a thin bar along the bottom edge. */
.video-tile-rights {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: var(--line);
}

.video-tile-rights.is-ok { background: var(--ok); }
.video-tile-rights.is-warn { background: var(--warn); }
.video-tile-rights.is-faint { background: var(--line-strong); opacity: .5; }

.video-tile-caption {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 0 2px;
}

.video-tile-title {
  font-size: 13px;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.video-tile-caption .page-sub {
  font-size: var(--fs-sm);
}

/* The sheet: the player on top, the facts in a list, the one switch and
   the download side by side under it. */
.video-sheet-player {
  max-width: none;
  max-height: 52vh;
  margin: 0 auto 6px;
}

.video-sheet-file {
  text-align: center;
  margin: 0 0 12px;
}

.video-sheet-facts {
  margin: 0 0 14px;
}

.video-sheet-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

.video-sheet-children,
.video-sheet-fanout {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
}

.video-sheet-children h3 {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--ink-soft);
  margin: 0 0 4px;
}

.video-sheet-fanout .btn {
  margin-top: 8px;
}

/* The list keeps the poster slot on a phone card, now with the real frame. */
.poster-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

/* ---------------------------------------------------------------------
   The drop tile: a target you can see before you drag. Used on the editing
   queue (the cut) and the shelf (a PDF).
   --------------------------------------------------------------------- */
.drop-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 96px;
  padding: 14px 18px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r);
  background: var(--surface-soft);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  transition: border-color 160ms var(--ease-out), background 160ms var(--ease-out),
              transform 160ms var(--ease-out), box-shadow 160ms var(--ease-out);
}

.drop-tile-compact {
  min-height: 72px;
}

.drop-tile:hover {
  border-color: var(--ink);
  background: var(--surface-solid);
}

.drop-tile:active {
  transform: scale(.98);
}

.drop-tile-icon {
  flex: none;
  color: var(--ink-soft);
}

.drop-tile-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.drop-tile-text strong {
  font-size: var(--fs-body);
}

.drop-tile-text .page-sub {
  font-size: var(--fs-sm);
}

/* Keyboard: the hidden input's focus shows on its label. */
.visually-hidden:focus-visible + .drop-tile {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

/* A file is dragged anywhere over the window: every tile lifts. */
html.is-file-drag .drop-tile {
  border-style: solid;
  border-color: var(--ink);
  background: var(--surface-solid);
  transform: scale(1.01);
  box-shadow: var(--shadow-hover);
}

/* The card the pointer is over: a lime inner glow on its tile. The old
   outline around the whole card is gone. */
.dropzone.is-dragover {
  outline: 0;
  background: inherit;
}

.dropzone.is-dragover .drop-tile {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 3px var(--lime-glow), var(--shadow-hover);
  background: #fff;
}

/* A file is picked: the tile steps back, the preview is the thing. */
.drop-tile.has-file {
  min-height: 0;
  padding: 10px 14px;
  gap: 10px;
}

.drop-tile.has-file .drop-tile-icon {
  width: 18px;
  height: 18px;
}

.drop-tile.has-file .drop-tile-text strong {
  font-size: var(--fs-sm);
}

/* ---------------------------------------------------------------------
   Editing queue: the picked cut, the progress and the delivered state.
   --------------------------------------------------------------------- */
.cut-preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: fade-rise var(--dur-enter) var(--ease-out);
}

.cut-preview-player {
  display: block;
  width: 100%;
  max-width: 320px;
  max-height: 360px;
  border-radius: var(--r-sm);
  background: #000;
}

.cut-preview-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.cut-preview-name {
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  min-width: 0;
  overflow-wrap: anywhere;
}

/* Progress on the house curve, the digits tabular so they do not wobble. */
.cut-progress {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cut-progress-track {
  flex: 1 1 auto;
  height: 8px;
  border-radius: var(--r-pill);
  background: rgba(12, 65, 41, .12);
  overflow: hidden;
}

.cut-progress-bar {
  display: block;
  height: 100%;
  width: 0;
  background: var(--ink);
  border-radius: inherit;
  transition: width 300ms var(--ease-out);
}

.cut-progress-percent {
  flex: none;
  min-width: 3.2em;
  text-align: right;
  font-size: var(--fs-sm);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

.deliver-form .portal-upload-status {
  font-variant-numeric: tabular-nums;
}

.deliver-form .btn[aria-disabled="true"] {
  opacity: .55;
  cursor: not-allowed;
}

/* The card folds as the stream replaces it; the receipt rises in. */
.collab-card.is-collapsing {
  opacity: 0;
  transform: scale(.98);
  transition: opacity 220ms var(--ease-in), transform 220ms var(--ease-in);
}

.collab-card.is-delivered {
  animation: fade-rise var(--dur-enter) var(--ease-out);
}

/* Her script in three blocks. */
.script-fold summary .fold-chevron {
  display: inline-block;
  transition: transform var(--dur-base) var(--ease-out);
}

.script-fold[open] summary .fold-chevron {
  transform: rotate(90deg);
}

.script-blocks {
  display: grid;
  gap: 12px;
  margin-top: 10px;
}

.script-block {
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--surface-soft);
  font-size: 13.5px;
  line-height: 1.7;
}

.script-block p {
  margin: 0;
}

.script-block p + p {
  margin-top: 6px;
}

.script-block-label {
  display: block;
  font-size: var(--fs-label);
  font-weight: 700;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 4px;
}

@media (max-width: 760px) {
  /* Two tiles across on a phone; one 9:16 tile the width of the screen is
     a poster, not a library. */
  .video-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px 10px;
  }

  /* The preview slot is reserved so Deliver does not jump when a file is
     picked, and Deliver is the width of the thumb. */
  .cut-preview {
    min-height: 120px;
  }

  .cut-preview-player {
    max-width: 112px;
    max-height: 200px;
    aspect-ratio: 9 / 16;
  }

  .deliver-actions .btn {
    width: 100%;
  }
}

/* ---------------------------------------------------------------------
   Pipeline: the funnel strip.
   --------------------------------------------------------------------- */
.funnel-strip {
  display: flex;
  gap: 6px;
  width: 100%;
}

.funnel-seg {
  flex: var(--share, 1) 1 56px;
  min-width: 56px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
  min-height: var(--tap);
  min-inline-size: 0;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
}

.funnel-seg:hover {
  border-color: var(--line-strong);
  background: var(--surface-solid);
}

.funnel-seg:active {
  transform: scale(.98);
}

.funnel-seg:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.funnel-seg.is-open {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
  box-shadow: var(--shadow-hover);
}

.funnel-seg.is-empty {
  color: var(--ink-faint);
}

.funnel-name {
  font-size: var(--fs-label);
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.funnel-count {
  font-family: "Indarung", "Quicksand", sans-serif;
  font-size: 22px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.funnel-wait {
  font-size: var(--fs-label);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  min-height: 1.2em;
}

.funnel-seg.is-open .funnel-wait {
  color: rgba(255, 255, 255, .8);
}

.funnel-seg.is-late .funnel-wait {
  color: var(--bad);
}

.funnel-seg.is-late.is-open .funnel-wait {
  color: var(--lime);
}

/* The people in a stage fold open under the strip on the same reveal the
   folds use; a class rather than details[open] because the strip is one row
   of buttons over one panel area. */
.funnel-panel.is-open {
  grid-template-rows: 1fr;
  opacity: 1;
}

.funnel-people {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
}

.funnel-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) 2fr auto;
  align-items: center;
  gap: 8px 16px;
  padding: 10px 4px;
  border-top: 1px solid var(--line-soft);
}

.funnel-row-who {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.funnel-row-name {
  font-weight: 700;
  text-decoration: none;
  color: var(--ink);
}

.funnel-row-name:hover {
  text-decoration: underline;
}

.funnel-row-days {
  font-size: var(--fs-label);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

.funnel-row.is-late .funnel-row-days {
  color: var(--bad);
}

.funnel-row-sentence {
  font-size: var(--fs-sm);
}

.funnel-row-action {
  justify-content: flex-end;
}

.funnel-nobody {
  margin: 14px 0 0;
}

@media (max-width: 760px) {
  .funnel-strip {
    gap: 4px;
  }

  /* Six equal segments on a phone: the share sizing has no room to show,
     and a clipped name says less than a small one. */
  .funnel-seg {
    flex: 1 1 0;
    min-width: 0;
    padding: 7px 5px;
    border-radius: 12px;
  }

  .funnel-name {
    font-size: 9px;
    overflow: visible;
    text-overflow: clip;
  }

  .funnel-count {
    font-size: 18px;
  }

  .funnel-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .funnel-row-action {
    justify-content: flex-start;
  }
}

/* ---------------------------------------------------------------------
   Brand guidelines: her shelf.
   --------------------------------------------------------------------- */
.shelf-add {
  margin-bottom: 14px;
}

.shelf-new-row {
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: var(--r);
  border: 1px solid var(--line);
  background: var(--surface-solid);
  display: grid;
  gap: 12px;
  animation: fade-rise var(--dur-enter) var(--ease-out);
}

.shelf-new-row .form-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.shelf-new-switch {
  margin-top: 22px;
}

.shelf {
  list-style: none;
  margin: 0;
  padding: 0;
}

.shelf-row {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-top: 1px solid var(--line-soft);
  background: var(--surface-solid);
  transition: opacity var(--dur-base) var(--ease-out);
}

.shelf-row:first-child {
  border-top: 0;
}

.shelf-row.is-hidden {
  opacity: .55;
}

.shelf-row.is-dragging {
  position: relative;
  z-index: var(--z-sticky);
  opacity: 1;
  box-shadow: var(--shadow-menu);
  border-radius: var(--r-sm);
  border-top-color: transparent;
}

.shelf.is-reordering .shelf-row:not(.is-dragging) {
  transition: transform 220ms var(--ease-out);
}

.shelf-handle {
  width: 28px;
  height: var(--tap);
  border: 0;
  background: none;
  color: var(--ink-mute);
  font-size: 16px;
  cursor: grab;
  touch-action: none;
  border-radius: var(--r-xs);
  padding: 0;
}

.shelf-handle:hover,
.shelf-handle:focus-visible {
  color: var(--ink);
  background: var(--surface-soft);
  outline: 0;
}

.shelf-row.is-dragging .shelf-handle {
  cursor: grabbing;
}

.shelf-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 48px;
  border-radius: var(--r-xs);
  border: 1px solid var(--line);
  background: var(--surface-soft);
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-soft);
}

.shelf-icon-pdf { color: var(--bad-ink); }
.shelf-icon-deck { color: var(--warn-ink); }

.shelf-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.shelf-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.shelf-title {
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-decoration: none;
  text-align: left;
}

.shelf-title:hover {
  text-decoration: underline;
}

.shelf-line,
.shelf-meta {
  font-size: var(--fs-sm);
}

.shelf-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.shelf-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 4px 6px;
  font-size: var(--fs-label);
  font-weight: 700;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.shelf-divider::before,
.shelf-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.shelf-preview {
  width: 100%;
  height: 70vh;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-soft);
}

.shelf-preview-image {
  display: block;
  max-width: 100%;
  max-height: 70vh;
  margin: 0 auto;
  border-radius: var(--r-sm);
}

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

  .shelf-controls {
    grid-column: 2 / -1;
    justify-content: flex-start;
  }
}

@media (prefers-reduced-motion: reduce) {
  .video-tile-poster,
  .cut-preview,
  .collab-card.is-delivered,
  .shelf-new-row {
    animation: none;
  }

  .collab-card.is-collapsing,
  .cut-progress-bar,
  .funnel-panel {
    transition: none;
  }
}
