/* ==============================================================================
   VIDEOS BLOCK
   ============================================================================== */

/* A grid of compact video cards (templates/blocks/videos.html, ADR-068):
   one per row on a phone, two on a tablet and as many as fit, up to
   four, on a desktop. Each card is the facade of video.css at card size,
   so the rules here only give .video, .video__poster and .video__player
   their box; the play button, the [hidden] handling and what a page
   without JavaScript shows are video.css's and apply here unchanged. */
.block-videos {
  /* main.css keeps the block hidden until this sheet has arrived. */
  visibility: visible;
  animation: none;
}

.videos__grid {
  display: grid;
  gap: var(--spacing-lg) var(--spacing-md);
  grid-template-columns: minmax(0, 1fr);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* A grid of portrait clips alone starts at two per row: one 9:16 card as
   wide as a phone is taller than its screen, the very thing this block
   is there to avoid. */
.videos--portrait .videos__grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 600px) {
  .videos__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .videos--portrait .videos__grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* From here the columns are counted by the cards themselves: 13rem is
   the narrowest a card stays comfortable at, and a quarter of the row
   (less its three gaps) is the narrowest it may get, which is what keeps
   the row at four cards: the page's column is wide enough for five of
   13rem, and Fotos y vídeos showed five and one when it got its sixth
   video. auto-fit drops the tracks nothing fills, so two videos share
   the row as two wide cards instead of leaving half of it empty. */
@media (min-width: 960px) {
  .videos__grid,
  .videos--portrait .videos__grid {
    grid-template-columns: repeat(auto-fit, minmax(max(13rem, calc((100% - 3 * var(--spacing-md)) / 4)), 1fr));
  }

  /* Five or six videos go in threes: two level rows, or three and two,
     instead of a full row of four with one or two cards left under it.
     The selector reads «has a fifth card and has no seventh». */
  .videos__grid:has(> :nth-child(5)):not(:has(> :nth-child(7))) {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

/* min-width: 0 lets a long title wrap instead of widening its column.
   The cap is for a grid of one or two videos on a wide screen, where
   auto-fit would stretch a single card across the whole page. */
.video-card {
  min-width: 0;
  max-width: 34rem;
}

/* The box every card of a grid shares, so a row stays level whatever is
   in it. It belongs to the wrapper and not to the picture: an <img> with
   an aspect-ratio of its own loses the size its width and height
   attributes give it and measures nothing until its file arrives (see
   gallery.css), while the wrapper has its full height from the first
   paint.

   The dark ink behind is what shows where a video does not fill the box.
   It is --accent-warm-ink and not video.css's --text-primary because
   that one turns light in the dark theme, and a pale band beside a
   playing video reads as part of the page, not of the player. */
.video-card .video {
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--accent-warm-ink);
}

.videos--portrait .video-card .video {
  aspect-ratio: 9 / 16;
}

/* Landscape and portrait clips in one grid meet in a square: the box
   that wastes least of both. A 16:9 video leaves a band above and below
   and a 9:16 one a band at each side, each a little over a fifth of the
   card, where a 16:9 box would leave a portrait clip two bands of a third
   each. */
.videos--mixed .video-card .video {
  aspect-ratio: 1;
}

/* Both fill the box, which outweighs the 70vh video.css gives a video
   that stands alone. The poster is cropped to it, like the photos of a
   gallery are to theirs: it is only there to say what the video is. The
   video itself is never cropped (object-fit: contain, from video.css). */
.video-card .video__poster,
.video-card .video__player {
  width: 100%;
  height: 100%;
  border-radius: 0;
  background: none;
}

/* The crop keeps more of the top of a poster than of its bottom: a
   portrait clip of people has their heads in its upper third, and a
   centred square cut the one of «Un consejo estético de la Asamblea» at
   the forehead. A quarter of the way down is where all five portrait
   posters of the site keep their subject (compared one by one, 17
   November 2026). A landscape poster in a square is only cropped at its
   sides, so this does not move it. */
.video-card .video__poster {
  object-fit: cover;
  object-position: center 25%;
}

/* A video's title wears the serious serif wherever it stands (Juan, 14
   October 2026: «los títulos de los vídeos, con fuente seria»), here at
   the size of the text around it: four of them share a row. balance
   evens out the two lines a narrow card gives it, so «del 11-N» does not
   leave its N alone on the second. */
.video-card__title {
  margin: var(--spacing-sm) 0 0;
  font-family: var(--font-title-serious);
  font-size: var(--font-size-base);
  font-weight: 600;
  line-height: 1.25;
  overflow-wrap: anywhere;
  text-wrap: balance;
}
