/* Shared case study rhythm, including legacy campaigns with an unclassed text wrapper. */
.project-story > .prose > p + :is(.case-project-title,.case-subtitle,.client-services-heading),
.project-story > div:not([class]) > p + :is(.case-project-title,.case-subtitle,.client-services-heading) {
  margin-block-start: clamp(1.5rem, 2.2vw, 2rem);
}

.project-story.bookatable-story {
  display: grid;
  grid-template-columns: minmax(0,1.52fr) minmax(0,1fr);
  align-items: start;
  width: 100%;
  max-width: none;
  gap: clamp(1.5rem, 5vw, 5rem);
}
.bookatable-campaign-photo { margin: 0; }
.bookatable-campaign-photo img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--rectification-radius);
}
@media (max-width: 800px) {
  .project-story.bookatable-story { grid-template-columns: minmax(0,1fr); }
  .bookatable-campaign-photo { max-width: 32rem; }
}

.homepage-photo-publication {
  width: min(100%, 33rem);
  margin: clamp(1rem, 2vw, 1.5rem) auto 0;
}
.homepage-photo-publication .publication-image {
  display: block;
  position: relative;
  border-radius: var(--rectification-radius);
  overflow: hidden;
  aspect-ratio: 640 / 853;
}
.homepage-photo-publication .food-preview {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.homepage-photo-publication .social-mark {
  position: absolute;
  z-index: 1;
  top: .75rem;
  left: .75rem;
}

/* Match the home video covers; the photography preview has its own card. */
.social-grid li:last-child .video-v2 .publication-image img {
  object-fit: cover;
  background: transparent;
}

/* Centre short media rows while retaining the established card width and gaps. */
@media (width > 760px) {
  :is(.quality-posts,.text-posts):has(> li > .video-v2):has(> li:last-child:not(:nth-child(3n))),
  .rendered-media:not(.visual-photo-grid):has(> figure:last-child:not(:nth-child(3n))) {
    display: grid;
    grid-template-columns: repeat(6,minmax(0,1fr));
  }
  :where(:is(.quality-posts,.text-posts):has(> li > .video-v2):has(> li:last-child:not(:nth-child(3n))),
    .rendered-media:not(.visual-photo-grid):has(> figure:last-child:not(:nth-child(3n)))) > :is(li,figure) { grid-column: span 2; }

  :is(.quality-posts,.text-posts):has(> li > .video-v2) > li:nth-child(3n+1):nth-last-child(2),
  .rendered-media:not(.visual-photo-grid) > figure:nth-child(3n+1):nth-last-child(2) {
    grid-column: 2 / span 2;
  }
  :is(.quality-posts,.text-posts):has(> li > .video-v2) > li:nth-child(3n+1):last-child,
  .rendered-media:not(.visual-photo-grid) > figure:nth-child(3n+1):last-child {
    grid-column: 3 / span 2;
  }
  .rendered-media:not(.visual-photo-grid):has(> figure:last-child:not(:nth-child(3n))) {
    align-items: start;
    columns: auto;
    row-gap: 1.2rem;
  }
  .rendered-media:not(.visual-photo-grid):has(> figure:last-child:not(:nth-child(3n))) > figure {
    margin: 0;
  }
  /* Four images form complete lines in the feed and analytics showcases. */
  .rendered-media:not(.visual-photo-grid):has(> figure:nth-child(4):last-child) {
    grid-template-columns: repeat(2,minmax(0,1fr));
  }
  .rendered-media:not(.visual-photo-grid):has(> figure:nth-child(4):last-child) > figure {
    grid-column: auto;
  }
}
@media (min-width: 1024px) {
  .rendered-media:not(.visual-photo-grid):has(> figure:nth-child(4):last-child) {
    grid-template-columns: repeat(4,minmax(0,1fr));
  }
}
@media (max-width: 760px) {
  :is(.quality-posts,.text-posts):has(> li > .video-v2):has(> li:nth-child(odd):last-child),
  .rendered-media:not(.visual-photo-grid):has(> figure:nth-child(odd):last-child) {
    display: grid;
    grid-template-columns: repeat(4,minmax(0,1fr));
  }
  :where(:is(.quality-posts,.text-posts):has(> li > .video-v2):has(> li:nth-child(odd):last-child),
    .rendered-media:not(.visual-photo-grid):has(> figure:nth-child(odd):last-child)) > :is(li,figure) { grid-column: span 2; }

  :is(.quality-posts,.text-posts):has(> li > .video-v2) > li:nth-child(odd):last-child,
  .rendered-media:not(.visual-photo-grid) > figure:nth-child(odd):last-child {
    grid-column: 2 / span 2;
  }
  .rendered-media:not(.visual-photo-grid):has(> figure:nth-child(odd):last-child) {
    align-items: start;
    columns: auto;
    row-gap: .7rem;
  }
  .rendered-media:not(.visual-photo-grid):has(> figure:nth-child(odd):last-child) > figure { margin: 0; }
}


/* The authorised cards determine the row lengths. */
@media (width > 760px) {
  :is(.quality-posts,.text-posts):has(> li > .video-v2):has(> li:is(:nth-child(4),:nth-child(8)):last-child) {
    grid-template-columns: repeat(6,minmax(0,1fr));
  }
  :is(.quality-posts,.text-posts):has(> li > .video-v2):has(> li:is(:nth-child(4),:nth-child(8)):last-child) > li:nth-child(odd) {
    grid-column: 2 / span 2;
  }
  :is(.quality-posts,.text-posts):has(> li > .video-v2):has(> li:is(:nth-child(4),:nth-child(8)):last-child) > li:nth-child(even) {
    grid-column: 4 / span 2;
  }
  .quality-posts:has(> li > .video-v2):has(> li:nth-child(10):last-child) > li:is(:nth-child(7),:nth-child(9)) {
    grid-column: 2 / span 2;
  }
  .quality-posts:has(> li > .video-v2):has(> li:nth-child(10):last-child) > li:is(:nth-child(8),:nth-child(10)) {
    grid-column: 4 / span 2;
  }
}
@media (width > 700px) {
  .social-grid:has(> li:nth-child(5):last-child) {
    grid-template-columns: repeat(6,minmax(0,1fr));
  }
  .social-grid:has(> li:nth-child(5):last-child) > li { grid-column: span 2; }
  .social-grid:has(> li:nth-child(5):last-child) > li:nth-child(4) { grid-column: 2 / span 2; }
}
@media (max-width: 700px) {
  .social-grid:has(> li:nth-child(odd):last-child) { grid-template-columns: repeat(4,minmax(0,1fr)); }
  .social-grid:has(> li:nth-child(odd):last-child) > li { grid-column: span 2; }
  .social-grid:has(> li:nth-child(odd):last-child) > li:last-child { grid-column: 2 / span 2; }
}
