/* aperture.css — the signature of this product surface.
   ----------------------------------------------------------------------------
   Two devices carry the whole visual argument, and everything else stays quiet:

   1. THE APERTURE. A 9:16 window cut out of a 16:9 leader, with the discarded
      margins hatched the way leader tape is hatched. This is literally what the
      pipeline does: find the moment, keep the middle, throw the sides away. The
      aperture is the card frame, the thumbnail, and the empty state at once, so
      the page never needs a decorative image.

   2. THE RULER. Every number that means time or position sits in mono on a
      measured track, because a digit that shifts under you is a digit you
      misread. The ruler is the only place the page is allowed to be loud about
      a number.

   Both are sized from tokens so density, radius and theme keep working.
*/

.aperture {
  --ap-w: 9;    /* 9:16 */
  --ap-h: 16;
  --ap-pad: 8%;
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: var(--ap-w) / var(--ap-h);
  background: var(--grease);
  border-radius: var(--radius-md);
  overflow: hidden;
  isolation: isolate;
}

/* The 16:9 leader the aperture is cut from. Kept as a sibling box so the
   discarded area stays visible — that contrast is the whole point. */
.aperture--leader {
  aspect-ratio: 16 / 9;
  --ap-pad: 11.5%;
}

.aperture__frame {
  position: absolute;
  inset: 0;
}

.aperture--leader .aperture__frame {
  /* the kept window, centred */
  inset: 0 var(--ap-pad);
  border-radius: var(--radius-sm);
}

/* discarded leader: hatched, low contrast, never competing with the clip */
.aperture--leader .aperture__frame::before,
.aperture--leader .aperture__frame::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: var(--ap-pad);
  background-image: repeating-linear-gradient(
    -45deg,
    color-mix(in srgb, var(--text) 9%, transparent) 0 2px,
    transparent 2px 7px
  );
}

.aperture--leader .aperture__frame::before { left: calc(-1 * var(--ap-pad)); }
.aperture--leader .aperture__frame::after  { right: calc(-1 * var(--ap-pad)); }

.aperture__media {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Кадр видео закрывает этот фон; токен, а не литерал, чтобы не заводить
     цвет вне палитры. */
  background: var(--grease);
}

.aperture__media[hidden] { display: none; }

/* No clip yet: say what is missing, don't apologise. */
.aperture__void {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: var(--sp-2);
  padding: var(--sp-3);
  text-align: center;
  color: var(--muted);
  font-size: var(--type-xs);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.aperture__void::before {
  content: "";
  justify-self: center;
  width: 22px;
  height: 22px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background:
    linear-gradient(var(--tally), var(--tally)) center / 100% 2px no-repeat;
}

/* Tally dot: the record light. Only on clips the pipeline considers finished. */
.aperture__tally {
  position: absolute;
  top: var(--sp-3);
  right: var(--sp-3);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--tally);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--bg) 70%, transparent);
}

.aperture__tally[data-status="queued"]  { background: var(--status-queued); }
.aperture__tally[data-status="running"] { background: var(--sodium); }
.aperture__tally[data-status="failed"]  { background: var(--tally); }
.aperture__tally[data-status="done"]    { background: var(--phosphor); }

/* While the pipeline works, the record light breathes. One animated element on
   the page, and only where something is genuinely in flight. */
@media (prefers-reduced-motion: no-preference) {
  .aperture__tally[data-status="running"] { animation: aperture-breathe 1.8s ease-in-out infinite; }
}

@keyframes aperture-breathe {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.35; }
}

/* ── The ruler ─────────────────────────────────────────────────────────────
   A measured track with real ticks. Ticks step 10 px in the data font, so the
   scale is the same everywhere and two numbers can be compared by eye. */

.ruler {
  position: relative;
  height: 18px;
  font-family: var(--font-data);
  font-size: 10px;
  letter-spacing: 0.02em;
  color: var(--muted);
  border-top: 1px solid var(--line);
  user-select: none;
}

.ruler__tick {
  position: absolute;
  top: 0;
  width: 1px;
  height: 5px;
  background: var(--line-strong);
}

.ruler__tick[data-major] { height: 9px; background: color-mix(in srgb, var(--text) 28%, transparent); }

.ruler__mark {
  position: absolute;
  top: 9px;
  transform: translateX(-50%);
  white-space: nowrap;
}

.ruler__head {
  position: absolute;
  top: -1px;
  bottom: 0;
  width: 2px;
  background: var(--phosphor);
  transform: translateX(-1px);
}

.ruler__head::after {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 7px;
  height: 7px;
  transform: translate(-50%, -1px) rotate(45deg);
  background: var(--phosphor);
}

/* The clip's own in/out span on the source timeline. This is the only thing the
   ruler is allowed to mark up: where in the hour the cut was taken from. */
.ruler__band {
  position: absolute;
  top: 0;
  height: 100%;
  background: color-mix(in srgb, var(--phosphor) 22%, transparent);
  border-left: 1px solid color-mix(in srgb, var(--phosphor) 55%, transparent);
  border-right: 1px solid color-mix(in srgb, var(--phosphor) 55%, transparent);
}

/* Score strip: the pipeline's verdict on a clip, as a measured length. */
.score-strip {
  position: relative;
  height: 4px;
  background: var(--grease);
  border-radius: 2px;
  overflow: hidden;
}

.score-strip__fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: var(--phosphor);
  width: calc(var(--score, 0) * 10%);
}

.score-strip[data-below-threshold="yes"] .score-strip__fill {
  background: var(--muted);
}
