/* A lesson's video at the top of its sheet (LessonVideoComponent, design C "On the sheet, where it will play"), at the
   size advisors will see it play: a 16:9 frame inside the text's padding. Empty, a dashed invitation; busy (sending,
   Stream preparing it), a quiet frame; failed, the error's colours; ready, Stream's player with Replace and Remove
   under it. A new video on its way takes the frame, at the player's size. The preview shows the same player. On a
   phone the frame is a little lower. The invitation is full width but only as tall as what it says, on a phone and a
   desktop alike: a 16:9 box of it pushed the text the author came to write below the fold (WI-12401). */
/* The block, and what it shows when no upload is under way: the frame, then its buttons. */
.wi-lesson-video,
.wi-lesson-video__current {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.wi-lesson-video {
  padding: var(--space-5) var(--space-8) 0;
  font-family: var(--font-family-sans);
  color: var(--text-primary);
}

/* What the `video-upload` controller hides stays hidden, whatever its display. */
.wi-lesson-video [hidden] {
  display: none;
}

.wi-lesson-video__frame,
.wi-lesson-video__ready,
.wi-lesson-video__player {
  box-sizing: border-box;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-md);
}

.wi-lesson-video__frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-4);
  text-align: center;
  background: var(--background-page);
  border: var(--border-1) solid var(--border-default);
  color: var(--text-secondary);
}

/* The invitation on one band: its badge, what it asks with the files it takes under it, then Add a video, clear of
   the X in its corner. */
.wi-lesson-video__frame--empty {
  position: relative;
  display: grid;
  aspect-ratio: auto;
  grid-template-columns: auto minmax(0, 1fr) auto;
  column-gap: var(--space-4);
  row-gap: var(--space-0-5);
  align-items: center;
  justify-items: start;
  padding-inline-end: var(--space-12);
  text-align: start;
  border: var(--border-2) dashed var(--border-strong);
}

.wi-lesson-video__frame--empty > .wi-lesson-video__badge {
  grid-row: 1 / span 2;
}

.wi-lesson-video__frame--empty > .wi-lesson-video__title,
.wi-lesson-video__frame--empty > .wi-lesson-video__text {
  grid-column: 2;
}

/* Add a video. */
.wi-lesson-video__add {
  grid-column: 3;
  grid-row: 1 / span 2;
}

/* Puts the invitation away, in its top right corner. */
.wi-lesson-video__dismiss {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
}

.wi-lesson-video__frame--failed {
  background: var(--feedback-error-bg);
  border-color: var(--feedback-error-border);
  color: var(--text-primary);
}

.wi-lesson-video__frame--failed > svg,
.wi-lesson-video__frame--failed .wi-lesson-video__title {
  color: var(--feedback-error-fg);
}

.wi-lesson-video__frame > svg {
  width: var(--size-icon-xl);
  height: var(--size-icon-xl);
}

.wi-lesson-video__badge {
  display: grid;
  place-items: center;
  width: var(--space-12);
  height: var(--space-12);
  border-radius: var(--radius-full);
  background: var(--turquoise-50);
  color: var(--turquoise-700);
}

.wi-lesson-video__badge > svg {
  width: var(--size-icon-lg);
  height: var(--size-icon-lg);
}

.wi-lesson-video__title {
  font-size: var(--font-size-base);
  line-height: var(--font-line-height-base);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

.wi-lesson-video__text {
  font-size: var(--font-size-sm);
  line-height: var(--font-line-height-sm);
}

/* The upload's progress, filled by the `video-upload` controller (`--progress`). */
.wi-lesson-video__bar {
  width: min(20rem, 90%);
  height: var(--space-1);
  border-radius: var(--radius-full);
  background: var(--border-default);
  overflow: hidden;
}

.wi-lesson-video__bar-fill {
  display: block;
  width: var(--progress, 0%);
  height: 100%;
  background: var(--turquoise-700);
  transition: width 0.2s ease-out;
}

/* The button's spinner (.wi-btn__spinner), larger and in turquoise. */
.wi-lesson-video__spinner {
  width: var(--size-icon-xl);
  height: var(--size-icon-xl);
  color: var(--turquoise-700);
}

.wi-lesson-video__ready {
  position: relative;
  overflow: hidden;
  background: var(--blue-gray-900);
}

.wi-lesson-video__length {
  position: absolute;
  right: var(--space-2);
  bottom: var(--space-2);
  padding: 0 var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--background-inverse);
  color: var(--text-primary-inverse);
  font-size: var(--font-size-xs);
  line-height: var(--font-line-height-sm);
  font-weight: var(--font-weight-semibold);
}

.wi-lesson-video__buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
}

.wi-lesson-video__buttons--end {
  justify-content: flex-end;
}

.wi-lesson-video__error {
  margin: 0;
  color: var(--feedback-error-fg);
  font-size: var(--font-size-sm);
  line-height: var(--font-line-height-sm);
}

.wi-lesson-video__player {
  display: block;
  border: 0;
  background: var(--blue-gray-900);
}

@media (prefers-reduced-motion: reduce) {
  .wi-lesson-video__bar-fill { transition: none; }
}

@media (max-width: 767.98px) {
  .wi-lesson-video {
    padding: var(--space-4) var(--space-4) 0;
  }

  .wi-lesson-video__frame {
    aspect-ratio: auto;
    min-height: 12rem;
  }

  /* On a phone the band is too narrow for three columns: its words then the button, centred, without the badge,
     which only decorates. */
  .wi-lesson-video__frame--empty {
    display: flex;
    gap: var(--space-2);
    min-height: 0;
    padding-inline-end: var(--space-4);
    text-align: center;
  }

  .wi-lesson-video__frame--empty > .wi-lesson-video__badge {
    display: none;
  }

  /* Its first line keeps clear of the X, on either side so that it stays centred. */
  .wi-lesson-video__frame--empty > .wi-lesson-video__title {
    padding-inline: var(--space-8);
  }
}
