/*
 * Firefighter Pfister — media
 *
 * Video-led, then a uniform photo grid. The contrast with the story pages is
 * deliberate: video gets a poster frame and a play button, audio gets a
 * waveform, so a visitor knows which they are getting before they click.
 */

.media {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.media__section {
  width: 100%;
  max-width: calc(var(--layout-container-wide) + 2 * var(--layout-gutter));
  margin-inline: auto;
  padding-inline: var(--layout-gutter);
}

.media__title {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  padding-block: var(--space-xl) 40px;
  text-align: center;
}

@media (min-width: 1000px) {
  .media__title {
    padding-block: 72px 56px;
  }
}

.media__rule {
  width: 64px;
  height: 2px;
  margin: 0;
  border: 0;
  background: var(--accent-solid);
}

/* ---------------------------------------------------------------- *
 * Featured video
 * ---------------------------------------------------------------- */

.media__featured {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  padding-bottom: var(--space-xl);
}

@media (min-width: 1000px) {
  .media__featured {
    padding-bottom: 88px;
  }
}

/*
 * A button, not a div: it swaps the poster for the YouTube iframe on click.
 * Nothing from YouTube loads until then, so the page costs nothing extra to
 * visitors who never press play.
 */
.video {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--ash-900);
  cursor: pointer;
}

.video__poster {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Veil keeps the ember button readable over a busy frame. */
.video__veil {
  position: absolute;
  inset: 0;
  background: rgb(20 17 16 / 0.42);
}

.video__play {
  position: absolute;
  top: 50%;
  left: 50%;
  translate: -50% -50%;
  display: grid;
  place-items: center;
  width: clamp(56px, 6.7vw, 96px);
  aspect-ratio: 1;
  border-radius: 999px;
  background: var(--accent-solid);
  color: var(--ash-900);
  transition: background-color 160ms ease, scale 160ms ease;
}

.video:hover .video__play {
  background: var(--accent-hover);
  scale: 1.05;
}

@media (prefers-reduced-motion: reduce) {
  .video__play {
    transition: none;
  }

  .video:hover .video__play {
    scale: 1;
  }
}

.video__play svg {
  width: 34%;
  height: 34%;
}

.video iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.media__meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: center;
}

.media__video-title {
  font-family: var(--font-display);
  font-size: var(--type-h3);
  font-weight: 700;
  line-height: var(--lh-h3);
  letter-spacing: var(--tr-h3);
  color: var(--text-primary);
  text-decoration: none;
}

.media__video-title:hover {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.media__divider {
  height: 1px;
  margin: 0;
  border: 0;
  background: var(--border-subtle);
}

/* ---------------------------------------------------------------- *
 * Photo grid
 * ---------------------------------------------------------------- */

/*
 * Flex rather than grid, so a trailing row that does not fill stays centred —
 * `justify-content: center` on a grid would still leave columns aligned left.
 * 3 columns -> 2 -> 1 falls out of the fixed basis and wrapping.
 */
.media__grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 36px 32px;
  padding-block: var(--space-xl) var(--space-2xl);
  list-style: none;
  margin: 0;
}

@media (min-width: 1000px) {
  .media__grid {
    padding-top: 72px;
  }
}

/*
 * 3 columns -> 2 -> 1.
 *
 * The basis has to step per breakpoint rather than stay at 405px: flex wraps on
 * the basis before it shrinks anything, and the tablet container is 704px, so a
 * fixed 405 basis would drop straight from 3 columns to 1. Tiles stay uniform
 * at every step — they are just uniformly smaller on tablet.
 */
.media__tile {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  flex: 0 1 100%;
  max-width: 405px;
}

@media (min-width: 768px) {
  .media__tile {
    flex-basis: calc((100% - 32px) / 2);
  }
}

@media (min-width: 1000px) {
  .media__tile {
    flex-basis: 405px;
  }
}

.media__tile img {
  width: 100%;
  aspect-ratio: 405 / 324;
  object-fit: cover;
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
}

.media__caption {
  font-family: var(--font-body);
  font-size: var(--type-small);
  font-weight: 400;
  line-height: var(--lh-small);
  color: var(--text-secondary);
  margin: 0;
}
