/* The YouTube Party page's shape (`pages/party.rs`): the player first. A
   middle column (notices, the host's search bar and results, the stage, the
   bar under it) and the side column (party-side.css). From 1024 px wide the
   page is the window's height and only the results, the stage, and the
   queue have their own scrolling; narrower, the side column goes under the
   player and the page scrolls. The search bar and results are in party.css. */

.party {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-3);
  padding: var(--space-3);
}

/* `.enter` keeps its last frame (a transform), which would make the page
   the containing block of every fixed descendant, so the OBS panel's
   backdrop would cover only the page. Once the entrance has run the page
   goes back to no transform; it looks the same. */
.party.enter {
  animation-fill-mode: backwards;
}

.party__main {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
}

.party__notices {
  display: grid;
  gap: var(--space-2);
}

.party__notices:empty {
  display: none;
}

/* The hero, "not found", and "ended" keep the reading page's spacing on
   the full-width party page. */
.party-message {
  margin: var(--space-5) var(--space-3) var(--space-6);
}

.party-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
}

/* Player: a dark stage, and on it the largest 16:9 box that fits. The box
   is sized by the stage's container units, never by script. */

.party-player {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
}

.party-player__stage {
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--color-video);
  box-shadow: var(--shadow-card);
  container-type: inline-size;
}

.party-player__video {
  position: relative;
  width: min(100cqw, var(--size-party-stage-max) * 16 / 9);
  aspect-ratio: 16 / 9;
}

/* YouTube puts its iframe inside the frame; it fills the box. */
.party-player__frame,
.party-player__frame > * {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.party-player__shield {
  position: absolute;
  inset: 0;
}

/* Full screen (`player_tools.rs`): the video box fills the screen and the
   player letterboxes inside it. */
.party-player__video:fullscreen {
  background: var(--color-video);
}

/* A video YouTube cannot play: why, and a link to its page. */
.party-player__error {
  display: grid;
  place-content: center;
  justify-items: center;
  gap: var(--space-3);
  height: 100%;
  padding: var(--space-4);
  background: var(--color-video);
  color: var(--color-on-video);
  text-align: center;
}

.party-player__error > .icon {
  width: var(--size-control);
  height: var(--size-control);
}

.party-player__error p {
  max-width: var(--width-reading);
}

/* The bar under the video: the transport, then the song line, in one row. */
.party-player__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  min-height: var(--size-control);
}

.party-player__song {
  flex: 1 1 var(--size-heading-min);
  min-width: 0;
  overflow: hidden;
  font-weight: var(--weight-semibold);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.party-autoplay {
  align-items: center;
  flex-wrap: wrap;
}

.party-autoplay .button {
  margin-left: auto;
}

/* Countdown: 3, 2, 1 over a dimmed video */

.countdown {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: var(--color-video-scrim);
  color: var(--color-on-video);
}

.countdown__number {
  font-size: var(--text-display);
  font-weight: var(--weight-bold);
  line-height: 1;
  font-variant-numeric: tabular-nums;
  animation: countdown-pop var(--duration-enter) var(--ease-out) both;
}

@keyframes countdown-pop {
  from {
    transform: scale(1.3);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Transport */

.transport {
  display: flex;
  flex: 3 1 var(--size-card-min);
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.transport--readonly {
  flex: none;
}

.transport__seek {
  flex: 1 1 auto;
  min-width: 0;
  /* The accent, not the light fill, so the control keeps 3:1. */
  accent-color: var(--color-primary);
  cursor: pointer;
}

.transport__seek:disabled {
  cursor: default;
}

.transport__time {
  color: var(--color-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* This browser's sound and full screen, at the end of the bar. */
.player-tools {
  display: flex;
  flex: none;
  align-items: center;
  gap: var(--space-1);
  margin-left: auto;
}

.player-tools__volume {
  width: var(--size-volume);
  accent-color: var(--color-primary);
  cursor: pointer;
}

/* Connecting: the same shape, pulsing */

.party-skeleton__bar,
.party-skeleton__stage,
.party-skeleton__block {
  border-radius: var(--radius);
  background: var(--color-skeleton);
  animation: skeleton-pulse 1.4s ease-in-out infinite;
}

.party-skeleton__bar {
  height: var(--size-control);
}

.party-skeleton__stage {
  aspect-ratio: 16 / 9;
}

.party-skeleton__block {
  height: var(--size-party-skeleton-block);
}

.party-skeleton__block--tall {
  flex: 1 1 auto;
}

/* Wide: the page is the window's height. The stage takes what the search
   bar, results, and bar leave, and the box inside it is the largest 16:9
   that fits both ways. */

@media (width >= 1024px) {
  .party {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0;
    height: 100vh;
    height: 100dvh;
    min-height: var(--size-party-min-height);
    padding: 0;
  }

  .party__main {
    min-height: 0;
    padding: var(--space-3);
  }

  .party-player {
    flex: 1 1 0;
    min-height: 0;
  }

  .party-player__stage {
    flex: 1 1 0;
    min-height: 0;
    container-type: size;
  }

  .party-player__video {
    width: min(100cqw, 100cqh * 16 / 9);
  }

  .party-skeleton__stage {
    flex: 1 1 0;
    aspect-ratio: auto;
  }
}

@media (max-width: 640px) {
  .party {
    padding: var(--space-2);
  }

  .party-player__song {
    flex-basis: 100%;
  }

  /* Narrow: the mute button only; the device has its own volume. */
  .player-tools__volume {
    display: none;
  }
}
