/* ==========================================================================
   Resizable player pane: js/features/stage_resize.js
   ========================================================================== */

/* ---- Divider handle (a 12px hit strip centred on the stage's right hairline) ---- */
.stage-resizer {
  position: fixed;
  top: var(--header-h);
  bottom: 0;
  left: calc(var(--stage-w) - 6px);
  z-index: calc(var(--z-sticky) + 2);
  width: 12px;
  cursor: col-resize;
  touch-action: none;
  outline: none;
}

.stage-resizer[hidden] {
  display: none;
}

.stage-resizer__line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 5px;
  width: 2px;
  border-radius: var(--radius-full);
  background: var(--border-strong);
  opacity: 0;
  transition: opacity var(--dur-hover) var(--ease);
}

.stage-resizer__grip {
  position: absolute;
  top: 50%;
  left: 2px;
  width: 8px;
  height: 40px;
  margin-top: -20px;
  border-radius: var(--radius-full);
  background: var(--surface-3);
  box-shadow: 0 0 0 1px var(--border-strong);
  opacity: 0;
  transform: scaleY(0.6);
  transition:
    opacity var(--dur-hover) var(--ease),
    transform var(--dur-base) var(--ease);
}

.stage-resizer__tip {
  position: absolute;
  top: calc(50% + 32px);
  left: 18px;
  padding: 4px var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  box-shadow: var(--shadow-popover);
  color: var(--text-1);
  font-size: var(--fs-12);
  line-height: var(--lh-12);
  font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translateX(-4px);
  transition:
    opacity var(--dur-hover) var(--ease),
    transform var(--dur-hover) var(--ease);
}

/* Hover reveals the line and grip after a short intent delay (no flicker when the
   pointer just passes over the edge). */
.stage-resizer:hover .stage-resizer__line,
.stage-resizer:hover .stage-resizer__grip,
.stage-resizer:hover .stage-resizer__tip {
  transition-delay: 150ms;
}

.stage-resizer:hover .stage-resizer__line,
.stage-resizer:focus-visible .stage-resizer__line,
.stage-resizer.is-dragging .stage-resizer__line {
  opacity: 1;
}

.stage-resizer:hover .stage-resizer__grip,
.stage-resizer:focus-visible .stage-resizer__grip,
.stage-resizer.is-dragging .stage-resizer__grip {
  opacity: 1;
  transform: scaleY(1);
}

.stage-resizer:hover .stage-resizer__tip,
.stage-resizer:focus-visible .stage-resizer__tip,
.stage-resizer.is-dragging .stage-resizer__tip {
  opacity: 1;
  transform: none;
}

.stage-resizer:focus-visible .stage-resizer__grip {
  box-shadow: var(--focus-ring);
}

/* Selected state while snapped to a preset: the one place the accent appears. */
.stage-resizer.is-snapped .stage-resizer__line,
.stage-resizer.is-snapped .stage-resizer__grip {
  background: var(--accent);
}

.stage-resizer.is-dragging .stage-resizer__line,
.stage-resizer.is-dragging .stage-resizer__grip,
.stage-resizer.is-dragging .stage-resizer__tip {
  transition-delay: 0ms;
}

/* ---- While dragging / tweening: no transitions, no text selection, no iframe hit-testing ---- */
body.is-resizing {
  cursor: col-resize;
  -webkit-user-select: none;
  user-select: none;
}

body.is-resizing .shell *,
body.is-resizing .shell *::before,
body.is-resizing .shell *::after {
  transition: none !important;
}

body.is-resizing iframe {
  pointer-events: none;
}

/* ---- Wider player: keep the video from eating the details pane ----
   At Half / Two-thirds on a short window a full-width 16:9 video would leave the details
   only a sliver. Cap the video at 60% of the pane height and centre it; extra width
   becomes quiet margin on both sides. */
body.layout-split .stage__screen-slot .screen {
  max-width: calc((100dvh - var(--header-h)) * 0.6 * 16 / 9);
  margin-inline: auto;
}

/* ---- Details pane: two columns when the pane is wide ---- */
.stage-info__cols {
  display: block;
}

@container stage (min-width: 800px) {
  .stage-info__cols {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
    gap: 0 var(--space-8);
    align-items: start;
  }

  .stage-info__side {
    padding-left: var(--space-8);
    border-left: 1px solid var(--hairline);
  }

  .stage-info__main .stage-synopsis__text {
    max-width: 68ch;
  }
}

@container stage (min-width: 1100px) {
  .stage-info__cols {
    grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
    gap: 0 var(--space-12);
  }

  .stage-info__side {
    padding-left: var(--space-12);
  }
}

/* ---- Preset change: View Transition styling (scoped to this feature) ---- */
html.mh-sr-vt::view-transition-group(*) {
  animation-duration: 340ms;
  animation-timing-function: var(--ease);
}

html.mh-sr-vt::view-transition-old(*),
html.mh-sr-vt::view-transition-new(*) {
  animation-duration: 340ms;
  animation-timing-function: var(--ease);
}

/* The page behind the named pieces is just the background: no cross-fade. */
html.mh-sr-vt::view-transition-old(root),
html.mh-sr-vt::view-transition-new(root) {
  animation: none;
}

/* Text panels change width, so their snapshots must not be stretched: show both at
   natural size, pinned top-left, clipped by the morphing box, and cross-fade. */
html.mh-sr-vt::view-transition-group(mh-sr-info),
html.mh-sr-vt::view-transition-group(mh-sr-fbar),
html.mh-sr-vt::view-transition-group(mh-sr-chips),
html.mh-sr-vt::view-transition-group(mh-sr-context),
html.mh-sr-vt::view-transition-group(mh-sr-feedback),
html.mh-sr-vt::view-transition-group(mh-sr-page),
html.mh-sr-vt::view-transition-group(mh-sr-tbar),
html.mh-sr-vt::view-transition-group(mh-sr-grid),
html.mh-sr-vt::view-transition-group(mh-sr-stage) {
  overflow: clip;
}

html.mh-sr-vt::view-transition-old(mh-sr-info),
html.mh-sr-vt::view-transition-new(mh-sr-info),
html.mh-sr-vt::view-transition-old(mh-sr-fbar),
html.mh-sr-vt::view-transition-new(mh-sr-fbar),
html.mh-sr-vt::view-transition-old(mh-sr-chips),
html.mh-sr-vt::view-transition-new(mh-sr-chips),
html.mh-sr-vt::view-transition-old(mh-sr-context),
html.mh-sr-vt::view-transition-new(mh-sr-context),
html.mh-sr-vt::view-transition-old(mh-sr-feedback),
html.mh-sr-vt::view-transition-new(mh-sr-feedback),
html.mh-sr-vt::view-transition-old(mh-sr-page),
html.mh-sr-vt::view-transition-new(mh-sr-page),
html.mh-sr-vt::view-transition-old(mh-sr-tbar),
html.mh-sr-vt::view-transition-new(mh-sr-tbar),
html.mh-sr-vt::view-transition-old(mh-sr-grid),
html.mh-sr-vt::view-transition-new(mh-sr-grid),
html.mh-sr-vt::view-transition-old(mh-sr-stage),
html.mh-sr-vt::view-transition-new(mh-sr-stage) {
  width: auto;
  height: auto;
  object-fit: none;
  object-position: left top;
}

/* Re-wrapping text never cross-fades (two overlapping copies read as a glitch): the old
   copy leaves quickly, then the new one settles in while the boxes finish moving. */
html.mh-sr-vt::view-transition-old(mh-sr-info),
html.mh-sr-vt::view-transition-old(mh-sr-fbar),
html.mh-sr-vt::view-transition-old(mh-sr-chips),
html.mh-sr-vt::view-transition-old(mh-sr-context),
html.mh-sr-vt::view-transition-old(mh-sr-feedback),
html.mh-sr-vt::view-transition-old(mh-sr-page),
html.mh-sr-vt::view-transition-old(mh-sr-tbar),
html.mh-sr-vt::view-transition-old(mh-sr-grid) {
  animation: mh-sr-out 120ms var(--ease-exit) both;
}

html.mh-sr-vt::view-transition-new(mh-sr-info),
html.mh-sr-vt::view-transition-new(mh-sr-fbar),
html.mh-sr-vt::view-transition-new(mh-sr-chips),
html.mh-sr-vt::view-transition-new(mh-sr-context),
html.mh-sr-vt::view-transition-new(mh-sr-feedback),
html.mh-sr-vt::view-transition-new(mh-sr-page),
html.mh-sr-vt::view-transition-new(mh-sr-tbar),
html.mh-sr-vt::view-transition-new(mh-sr-grid) {
  animation: mh-sr-in 240ms var(--ease) 100ms both;
}

@keyframes mh-sr-out {
  to {
    opacity: 0;
  }
}

@keyframes mh-sr-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

/* The stage background is a soft gradient: stretch it instead of cross-fading. */
html.mh-sr-vt::view-transition-old(mh-sr-stage),
html.mh-sr-vt::view-transition-new(mh-sr-stage) {
  width: 100%;
  height: 100%;
  object-fit: fill;
  animation: none;
}

html.mh-sr-vt::view-transition-old(mh-sr-stage) {
  opacity: 0;
}

/* The header doesn't move; keep it on top and still. */
html.mh-sr-vt::view-transition-old(mh-sr-header),
html.mh-sr-vt::view-transition-new(mh-sr-header) {
  animation: none;
}

html.mh-sr-vt::view-transition-old(mh-sr-header) {
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .stage-resizer__line,
  .stage-resizer__grip,
  .stage-resizer__tip {
    transition: none;
  }
}

/* Filter dropdown row: scroll sideways when the browse pane is narrow (stage_resize.js toggles the
   state classes) and fade whichever edge hides more filters. */
.filterbar__group {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}

.filterbar__group::-webkit-scrollbar {
  display: none;
}

.filterbar__group.is-clipped:not(.is-at-end) {
  -webkit-mask-image: linear-gradient(to right, black calc(100% - 40px), transparent);
  mask-image: linear-gradient(to right, black calc(100% - 40px), transparent);
}

.filterbar__group.is-clipped:not(.is-at-start):not(.is-at-end) {
  -webkit-mask-image: linear-gradient(to right, transparent, black 40px, black calc(100% - 40px), transparent);
  mask-image: linear-gradient(to right, transparent, black 40px, black calc(100% - 40px), transparent);
}

.filterbar__group.is-clipped.is-at-end:not(.is-at-start) {
  -webkit-mask-image: linear-gradient(to right, transparent, black 40px);
  mask-image: linear-gradient(to right, transparent, black 40px);
}
