/* <cg-video-stack>: the hero's fanned video cards. API and behaviour: the comment at the top of stack.js.
   Light theme. The host sets --cg-card-w and may set --cg-card-ratio, on the element or on any ancestor; the defaults
   are 160px and 9 / 16, or 240px and 16 / 9 for format="horizontal". */

cg-video-stack {
  --_w: var(--cg-card-w, 160px);
  --_ratio: var(--cg-card-ratio, 9 / 16);
  /* the unit the card's details are sized by: its short side, near enough */
  --_u: var(--_w);
  --cg-radius: calc(var(--_u) * 0.095);
  --cg-glow: oklch(73% 0.16 295 / 0.46);
  --cg-glow-2: oklch(83% 0.1 293 / 0.5);
  --cg-haze: oklch(90% 0.055 293 / 0.62);
  display: block;
  position: relative;
  width: var(--_w);
  aspect-ratio: var(--_ratio);
  isolation: isolate;
  contain: layout style;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
cg-video-stack[format="horizontal"] {
  --_w: var(--cg-card-w, 240px);
  --_ratio: var(--cg-card-ratio, 16 / 9);
  --_u: calc(var(--_w) * 0.6);
}

/* The light behind the fan: lilac at the cards, fading out into the page */
.cg-vs-glow {
  position: absolute;
  z-index: 0;
  left: 50%;
  top: 50%;
  width: 420%;
  height: 240%;
  transform: translate(-56%, -48%);
  pointer-events: none;
  background:
    radial-gradient(26% 26% at 50% 54%, var(--cg-glow), transparent 100%),
    radial-gradient(38% 34% at 52% 50%, var(--cg-glow-2), transparent 100%),
    radial-gradient(50% 50% at 50% 50%, var(--cg-haze), transparent 100%);
}
cg-video-stack[side="right"] .cg-vs-glow { transform: translate(-44%, -48%); }
cg-video-stack[format="horizontal"] .cg-vs-glow { width: 230%; height: 400%; transform: translate(-52%, -50%); }
cg-video-stack[format="horizontal"][side="right"] .cg-vs-glow { transform: translate(-48%, -50%); }

.cg-vs-slot { position: absolute; inset: 0; }

.cg-vs-card {
  position: absolute;
  inset: 0;
  transform-origin: 50% 50%;
  will-change: transform;
}

/* A soft violet shadow that falls below the card; its strength follows the card's place in the fan. The shadow is
   all spread, cast by a box small enough to stay behind the card when the shadow grows and drops under a lifted
   card: a box shadow is not drawn under its own box, and a larger box would show there as a pale plate. */
.cg-vs-shadow {
  position: absolute;
  inset: 13% 24%;
  box-shadow:
    0 calc(var(--_u) * 0.145) calc(var(--_u) * 0.24) calc(var(--_u) * 0.13) oklch(32% 0.13 287 / 0.48),
    0 calc(var(--_u) * 0.05) calc(var(--_u) * 0.07) calc(var(--_u) * 0.165) oklch(30% 0.065 285 / 0.16);
}
cg-video-stack[format="horizontal"] .cg-vs-shadow { inset: 21.7% 16.8%; }

.cg-vs-face {
  position: absolute;
  inset: 0;
  border-radius: var(--cg-radius);
  overflow: hidden;
  clip-path: inset(0 round var(--cg-radius));
  background: oklch(92% 0.03 292);
}
.cg-vs-face > video,
.cg-vs-poster,
.cg-vs-xfade,
.cg-vs-soft {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
}
.cg-vs-poster, .cg-vs-xfade { z-index: 1; }
.cg-vs-xfade { opacity: 0; }
/* Only the front card and the next one carry their video on the page; the rest are their poster */
.cg-vs-card:not([data-live]) video { display: none; }

/* Cards behind look further away: out of focus (a soft copy of the poster) and under a lilac haze */
.cg-vs-wash {
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: 0;
}
.cg-vs-wash::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(172deg, oklch(95.5% 0.034 295 / 0.64), oklch(88.5% 0.075 296 / 0.64));
}

/* A card turning away from the viewer loses the light towards its far edge: the edge opposite the one it is held by */
.cg-vs-shade {
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: 0;
  --_far: oklch(20% 0.07 285 / 0.5);
  background: linear-gradient(to right, transparent 6%, var(--_far));
}
cg-video-stack[side="right"] .cg-vs-shade { background: linear-gradient(to left, transparent 6%, var(--_far)); }
cg-video-stack[format="horizontal"] .cg-vs-shade { background: linear-gradient(to top, transparent 6%, var(--_far)); }

/* The thin light rim */
.cg-vs-face::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 4;
  border-radius: inherit;
  pointer-events: none;
  box-shadow:
    inset 0 0 0 max(1.75px, calc(var(--_u) * 0.014)) oklch(100% 0 0 / 0.88),
    inset 0 0 0 calc(var(--_u) * 0.03) oklch(100% 0 0 / 0.14);
}

/* The player bar on the front card: play mark, progress line, time */
.cg-vs-ui {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: calc(var(--_u) * 0.062);
  padding: calc(var(--_u) * 0.34) calc(var(--_u) * 0.09) calc(var(--_u) * 0.085);
  background: linear-gradient(to top, oklch(16% 0.04 282 / 0.5), oklch(16% 0.04 282 / 0.18) 55%, oklch(16% 0.04 282 / 0));
  color: #fff;
  font: 700 calc(var(--_u) * 0.086) / 1 var(--cg-font, inherit);
  letter-spacing: 0.01em;
  pointer-events: none;
}
.cg-vs-play {
  flex: none;
  width: calc(var(--_u) * 0.084);
  height: auto;
  fill: currentColor;
  filter: drop-shadow(0 1px 1.5px oklch(10% 0.03 280 / 0.3));
}
.cg-vs-bar {
  flex: 1;
  height: max(2px, calc(var(--_u) * 0.019));
  border-radius: 99px;
  overflow: hidden;
  background: oklch(100% 0 0 / 0.36);
}
.cg-vs-bar i {
  display: block;
  height: 100%;
  background: #fff;
  transform: scaleX(0);
  transform-origin: 0 50%;
}
.cg-vs-time {
  flex: none;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 2px oklch(10% 0.03 280 / 0.35);
}
