/* =============================================================
   barrio_npm_prototype — related-videos grid (shared component)

   Content-type-neutral. Any content type with field_related_videos renders
   the grid via templates/content/_video-grid.html.twig (data from
   Video\RelatedVideosBuilder) inside its own <section> + heading, and emits
   the shared #np-video-modal (_video-modal.html.twig + barrioNpmVideoModal
   JS). The section wrapper + heading are owned per-content-type; the grid +
   cards + count behaviour live here so they stay consistent everywhere.

   `data-count` sits on the grid, so the single/double sizing applies
   regardless of the wrapper:
     · 1 video  → 50% width + 16:9 poster (full width + 4:3 at phone)
     · 2 videos → forced 2 columns
     · 3+ videos → auto-fit grid
   ============================================================= */

.np-videos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}
.np-video-card {
  /* Strip UA <button> chrome and lay out as image-then-title column. */
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: #2c2c2b;
}
.np-video-card:focus-visible {
  outline: 3px solid var(--hue);
  outline-offset: 2px;
  border-radius: 8px;
}
.np-video-card-thumb {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 8px;
  overflow: hidden;
  background: #f1ece1;
  display: block;
}
.np-video-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
/* Play button — centered SVG triangle in a circular Pātai-hued background.
   Slightly translucent so the thumbnail is still readable beneath it.
   Stronger contrast + scale on hover/focus. */
.np-video-card-play {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 60px; height: 60px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .92);
  color: var(--hue-dk);
  display: grid;
  place-items: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
  transition: transform .15s, background .15s;
  pointer-events: none;
}
.np-video-card-play svg {
  margin-left: 4px; /* optical centring — triangle tip pulls right */
}
.np-video-card:hover .np-video-card-play,
.np-video-card:focus-visible .np-video-card-play {
  transform: translate(-50%, -50%) scale(1.08);
  background: #fff;
}
/* Title under the thumbnail. Clamps to two lines so cards in the same
   grid row stay roughly the same height. */
.np-video-card-title {
  font-size: 13.5px;
  line-height: 1.35;
  font-weight: 600;
  color: #2c2c2b;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Count-based sizing — on the grid, so every content type inherits it.
   1 video: capped at 50% (was a fixed 480px on the project wrapper) with a
   16:9 poster; 2 videos: forced 2-col; 3+ videos: the auto-fit grid above. */
.np-videos-grid[data-count="1"] {
  grid-template-columns: minmax(0, 50%);
}
.np-videos-grid[data-count="1"] .np-video-card-thumb {
  aspect-ratio: 16 / 9;
}
.np-videos-grid[data-count="2"] {
  grid-template-columns: 1fr 1fr;
}

@media (max-width: 575.98px) {
  /* Smaller play button at phone width so it doesn't dominate the
     thumbnail when the grid drops to a single column. */
  .np-video-card-play {
    width: 48px;
    height: 48px;
  }
  /* A lone video goes full width with a 4:3 poster at phone width. */
  .np-videos-grid[data-count="1"] {
    grid-template-columns: 1fr;
  }
  .np-videos-grid[data-count="1"] .np-video-card-thumb {
    aspect-ratio: 4 / 3;
  }
}
