/**
 * @file
 * Featured Videos section.
 *
 * Figma: SML Design Refresh, homepage node 2300:2015. Measurements in the
 * comments below are taken from that node at a 1728px frame width, where the
 * content column is 1395px wide (827px primary + 543px list).
 */

.sml-videos__intro {
  max-width: 52rem;
  margin: -1.5rem 0 2rem;
  font-family: var(--sml-font-jost);
  font-size: 1.125rem;
  line-height: 1.5;
}

.sml-videos__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 3rem);
  align-items: start;
}

/* Thumbnails. */
.sml-videos__thumb {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 5px;
  background: var(--sml-near-black);
}

.sml-videos__thumb--lg {
  aspect-ratio: 16 / 9;
}

/* Scrim keeps the centered play control legible over any frame. */
.sml-videos__thumb--lg::after {
  position: absolute;
  content: "";
  background: rgba(0, 0, 0, 0.55);
  inset: 0;
}

.sml-videos__thumb--sm {
  flex: 0 0 183px;
  width: 183px;
  aspect-ratio: 183 / 120;
}

.sml-videos__thumb--sm::after {
  position: absolute;
  content: "";
  background: rgba(0, 0, 0, 0.6);
  inset: 0;
}

.sml-videos__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sml-videos__feature-link {
  display: block;
  text-decoration: none;
}

/* Centered play control on the primary card. */
.sml-videos__play {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.875rem;
  color: var(--sml-white);
}

.sml-videos__play .sml-play {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
}

.sml-videos__play-text {
  font-family: var(--sml-font-code-pro-bold);
  font-size: 1.25rem;
  font-weight: 700;
}

/* Play badge centered on each secondary thumbnail. */
.sml-videos__thumb-play {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sml-white);
}

.sml-videos__thumb-play .sml-play {
  width: 40px;
  height: 40px;
}

.sml-videos__caption {
  margin: 1.5rem 0 0;
  font-family: var(--sml-font-code-pro-bold);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.1667;
}

/* The caption reads as the heading it sits in until it is hovered. */
.sml-videos__caption a {
  text-decoration: none;
  color: inherit;
}

.sml-videos__caption a:hover {
  text-decoration: underline;
  color: var(--sml-purple);
}

/* Side list. */
.sml-videos__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* flex-start keeps the thumbnail from stretching to the title's height, which
 * would override its aspect-ratio and squash the image on long titles. */
.sml-videos__item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--sml-gray-dark);
  gap: 1.125rem;
}

.sml-videos__item-body {
  flex: 0 1 340px;
}

.sml-videos__item-title {
  margin: 0;
  font-family: var(--sml-font-code-pro);
  font-size: 1.25rem;
  font-weight: 400;
  line-height: 1.6;
}

.sml-videos__item-title a {
  text-decoration: underline;
  color: var(--sml-black);
}

.sml-videos__item-title a:visited {
  color: var(--sml-purple);
}

.sml-videos__item-title a:hover {
  text-decoration: none;
  color: var(--sml-purple);
}

/* The thumbnail link is a second trigger for the same video, so hovering it
 * drives the title state too. Kept in its own rule: browsers without :has()
 * would drop the plain :hover rule above if the two were grouped. */
.sml-videos__item:has(.sml-videos__thumb--sm:hover) .sml-videos__item-title a {
  text-decoration: none;
  color: var(--sml-purple);
}

/* Dashed focus ring, per the design's keyboard state. */
.sml-videos__item-title a:focus-visible,
.sml-videos__feature-link:focus-visible {
  border-radius: 5px;
  outline: 2px dashed var(--sml-black);
  outline-offset: 4px;
}

/* -------------------------------------------------------------------------
 * Lightbox.
 *
 * The player is cloned into .sml-video-dialog__body on open and removed on
 * close. Sizing lives on the body so both the embedded iframe and a local
 * <video> land on the same 16:9 box.
 * ---------------------------------------------------------------------- */
.sml-video-dialog {
  overflow: visible;
  width: min(1100px, 92vw);
  max-width: none;
  padding: 0;
  color: var(--sml-white);
  border: 0;
  background: transparent;
}

.sml-video-dialog::backdrop {
  background: rgba(0, 0, 0, 0.8);
}

.sml-video-dialog__inner {
  position: relative;
}

.sml-video-dialog__close {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  cursor: pointer;
  color: var(--sml-white);
  border: 0;
  border-radius: 5px;
  background: transparent;
  inset-inline-end: 0;
  inset-block-end: calc(100% + 0.5rem);
}

.sml-video-dialog__close:hover {
  color: var(--sml-purple);
}

.sml-video-dialog__close:focus-visible {
  outline: 2px solid var(--sml-white);
  outline-offset: 2px;
}

.sml-video-dialog__close-icon {
  width: 24px;
  height: 24px;
}

.sml-video-dialog__body {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 5px;
  background: var(--sml-black);
}

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

/* video_embed_field wraps its iframe in a padding-ratio box that would
 * fight the aspect-ratio above. */
.sml-video-dialog__body .video-embed-field-responsive-video {
  position: static;
  height: 100%;
  padding: 0;
}

/* Below this the side list column is too narrow to hold a 183px thumbnail next
 * to a readable title, so the list drops under the primary video and each row
 * spans the full width instead. */
@media (max-width: 1199px) {
  .sml-videos__grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 767px) {
  .sml-videos__thumb--sm {
    flex-basis: 120px;
    width: 120px;
  }

  .sml-videos__play-text {
    font-size: 1rem;
  }
}

@media (min-width: 1500px) {
  .sml-videos__intro {
    max-width: 824px;
    margin-bottom: 1.5rem;
  }

  .sml-videos__grid {
    grid-template-columns: minmax(0, 827px) minmax(0, 543px);
    justify-content: space-between;
    gap: 2rem;
  }

  .sml-videos__thumb--lg {
    height: 541px;
    aspect-ratio: auto;
  }

  /* 120px thumbnail + 45px either side of the rule = 210px row pitch. */
  .sml-videos__item {
    min-height: 120px;
    margin-bottom: 45px;
    padding-bottom: 45px;
  }

  .sml-videos__thumb--sm {
    height: 120px;
    aspect-ratio: auto;
  }
}
