/*
 * EnjoyVideo 1.1.7: consistent video grids and cover thumbnails.
 * Loaded after the base, dark and responsive stylesheets.
 * Scope changes to listing cards; single-post content remains untouched.
 */

.content-loop,
.content-block-1 .posts-loop {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-items: stretch;
  column-gap: 18px;
  row-gap: 25px;
}

/* Home widgets can request a three-column layout. */
.content-block-1 .posts-loop.enjoyvideo-cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.content-loop > .hentry,
.content-block-1 .posts-loop > .hentry {
  float: none !important;
  clear: none !important;
  margin: 0 !important;
  width: auto !important;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Existing CSS floats break masonry-style when adjacent titles differ. */
.content-loop > .hentry > .thumbnail-link,
.content-block-1 .posts-loop > .hentry > .thumbnail-link {
  display: block;
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  aspect-ratio: 16 / 9;
  line-height: 0;
  margin: 0 0 12px;
  overflow: hidden;
  background: #242424;
  border-radius: 3px;
}

.content-loop > .hentry > .thumbnail-link > .thumbnail-wrap,
.content-block-1 .posts-loop > .hentry > .thumbnail-link > .thumbnail-wrap {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.content-loop > .hentry > .thumbnail-link img,
.content-block-1 .posts-loop > .hentry > .thumbnail-link img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: center;
}

.content-loop > .hentry > .entry-header,
.content-block-1 .posts-loop > .hentry > .entry-header {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
}

.content-loop > .hentry .entry-title,
.content-block-1 .posts-loop > .hentry .entry-title {
  line-height: 1.35;
  min-height: 2.7em;
  overflow-wrap: anywhere;
  -webkit-line-clamp: 2;
  line-clamp: 2;
}

.content-loop > .hentry .entry-meta,
.content-block-1 .posts-loop > .hentry .entry-meta {
  margin-top: auto;
  padding-top: 6px;
}

.content-loop > .widget_media_image,
.content-loop > .widget_custom_html {
  grid-column: 1 / -1;
}

/* Featured articles: the large tile matches the height of the two right rows. */
#featured-content {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: stretch;
}

#featured-content .featured-large,
#featured-content .featured-right {
  float: none;
  width: auto;
  min-width: 0;
  margin: 0;
}

#featured-content .featured-large:only-child,
#featured-content .featured-right:only-child {
  grid-column: 1 / -1;
}

#featured-content .featured-right {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

#featured-content .featured-small {
  float: none;
  clear: none;
  width: auto;
  min-width: 0;
  margin: 0;
  aspect-ratio: 16 / 9;
}

#featured-content .featured-small:nth-of-type(2n),
#featured-content .featured-small:nth-of-type(2n + 1) {
  float: none;
  clear: none;
  margin: 0;
}

#featured-content .featured-large .thumbnail-wrap,
#featured-content .featured-large .thumbnail-link,
#featured-content .featured-small .thumbnail-wrap,
#featured-content .featured-small .thumbnail-link {
  display: block;
  position: relative;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

#featured-content .featured-large img,
#featured-content .featured-small img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

@media (max-width: 959px) {
  .content-loop,
  .content-block-1 .posts-loop,
  .content-block-1 .posts-loop.enjoyvideo-cols-3 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 15px;
    row-gap: 22px;
  }
}

@media (max-width: 767px) {
  #featured-content {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }
  #featured-content .featured-large .thumbnail-link {
    aspect-ratio: 16 / 9;
    height: auto;
  }
  #featured-content .featured-large {
    aspect-ratio: 16 / 9;
  }
  #featured-content .featured-right {
    gap: 10px;
  }
}

@media (max-width: 520px) {
  .content-loop,
  .content-block-1 .posts-loop,
  .content-block-1 .posts-loop.enjoyvideo-cols-3 {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 22px;
  }
}

/* Preserve a readable card-size two-column layout on small tablets. */
@supports not (aspect-ratio: 16 / 9) {
  .content-loop > .hentry > .thumbnail-link,
  .content-block-1 .posts-loop > .hentry > .thumbnail-link {
    height: 0;
    padding-bottom: 56.25%;
  }
  .content-loop > .hentry > .thumbnail-link > .thumbnail-wrap,
  .content-block-1 .posts-loop > .hentry > .thumbnail-link > .thumbnail-wrap {
    position: absolute;
    inset: 0;
  }
}

/* Clearfix pseudo-elements must not become phantom grid cells. */
.content-loop::before,
.content-loop::after,
.content-block-1 .posts-loop::before,
.content-block-1 .posts-loop::after,
#featured-content::before,
#featured-content::after {
  content: none;
  display: none;
}
