.media-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 12px;
}

.media-count {
  color: #65676b;
  font-size: 13px;
  font-weight: 700;
}

.media-toggle {
  min-height: 34px;
  border: 1px solid #d0d7de;
  border-radius: 8px;
  background: #f6f8fa;
  color: #1877f2;
  padding: 7px 12px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
}

.media-toggle:hover {
  background: #e7f3ff;
  border-color: #b6d6fb;
}

.grid.media-collapsed figure:nth-child(n+5) {
  display: none;
}

.grid figure img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  background: #f0f2f5;
}

.grid.facebook-grid-4-square {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 2px;
  width: min(100%, 900px);
  aspect-ratio: 1 / 1;
  margin-inline: auto;
  overflow: hidden;
}

.grid.facebook-grid-4-square figure {
  min-width: 0;
  min-height: 0;
  margin: 0;
  aspect-ratio: 1 / 1;
}

.grid.facebook-grid-4-square figure img {
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
}

.grid.facebook-post-layout {
  grid-template-columns: minmax(0, 1.993fr) minmax(0, 1fr);
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
  max-width: 900px;
  aspect-ratio: 898 / 900;
  margin-inline: auto;
  overflow: hidden;
  border-radius: 12px;
  background: #d9efff;
}

.grid.facebook-post-layout figure {
  min-width: 0;
  min-height: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
}

.grid.facebook-post-layout figure:first-child {
  grid-column: 1;
  grid-row: 1 / 4;
}

.grid.facebook-post-layout figure:nth-child(2) {
  grid-column: 2;
  grid-row: 1;
}

.grid.facebook-post-layout figure:nth-child(3) {
  grid-column: 2;
  grid-row: 2;
}

.grid.facebook-post-layout figure:nth-child(4) {
  grid-column: 2;
  grid-row: 3;
}

.grid.facebook-post-layout figure img {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  object-fit: cover;
}

/* Facebook Feed previews used by the three latest campaign posts. */
.grid.facebook-feed-gallery {
  display: grid;
  gap: 2px;
  width: min(100%, 680px);
  margin-inline: auto;
  overflow: hidden;
  border-radius: 0;
  background: #fff;
}

.grid.facebook-feed-gallery figure {
  min-width: 0;
  min-height: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  overflow: hidden;
}

.grid.facebook-feed-gallery figure img {
  width: 100%;
  height: 100%;
  aspect-ratio: auto;
  object-fit: cover;
  display: block;
}

/* One square photo: a single full-width Facebook tile. */
.grid.facebook-feed-square-1 {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  aspect-ratio: 1 / 1;
}

/* Two square photos: two equal Facebook tiles. */
.grid.facebook-feed-square-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: minmax(0, 1fr);
  aspect-ratio: 2 / 1;
}

/* Three square photos: one hero tile left, two stacked tiles right. */
.grid.facebook-feed-square-3 {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  grid-template-rows: repeat(2, minmax(0, 1fr));
  aspect-ratio: 1 / 1;
}

.grid.facebook-feed-square-3 figure:first-child {
  grid-column: 1;
  grid-row: 1 / 3;
}

.grid.facebook-feed-square-3 figure:nth-child(2) {
  grid-column: 2;
  grid-row: 1;
}

.grid.facebook-feed-square-3 figure:nth-child(3) {
  grid-column: 2;
  grid-row: 2;
}

/* One portrait photo: Facebook Feed keeps the 4:5 frame. */
.grid.facebook-feed-single-portrait {
  display: block;
  aspect-ratio: 4 / 5;
}

.grid.facebook-feed-single-portrait figure {
  width: 100%;
  height: 100%;
  aspect-ratio: 4 / 5;
}

/* Four photos led by a portrait: one hero left, three squares right. */
.grid.facebook-feed-portrait-4 {
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  grid-template-rows: repeat(3, minmax(0, 1fr));
  aspect-ratio: 1 / 1;
}

.grid.facebook-feed-portrait-4 figure:first-child {
  grid-column: 1;
  grid-row: 1 / 4;
}

.grid.facebook-feed-portrait-4 figure:nth-child(2) {
  grid-column: 2;
  grid-row: 1;
}

.grid.facebook-feed-portrait-4 figure:nth-child(3) {
  grid-column: 2;
  grid-row: 2;
}

.grid.facebook-feed-portrait-4 figure:nth-child(4) {
  grid-column: 2;
  grid-row: 3;
}

/* Five photos led by a 598:900 portrait: portrait hero left, four square SKU tiles right. */
.grid.facebook-feed-portrait-5 {
  grid-template-columns: minmax(0, 1.3289fr) repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
  aspect-ratio: 1498 / 900;
}

.grid.facebook-feed-portrait-5 figure:first-child {
  grid-column: 1;
  grid-row: 1 / 3;
}

.grid.facebook-feed-portrait-5 figure:nth-child(2) {
  grid-column: 2;
  grid-row: 1;
}

.grid.facebook-feed-portrait-5 figure:nth-child(3) {
  grid-column: 3;
  grid-row: 1;
}

.grid.facebook-feed-portrait-5 figure:nth-child(4) {
  grid-column: 2;
  grid-row: 2;
}

.grid.facebook-feed-portrait-5 figure:nth-child(5) {
  display: block;
  grid-column: 3;
  grid-row: 2;
}

/* Five square photos: two large tiles above three smaller tiles. */
.grid.facebook-feed-square-5 {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-rows: minmax(0, 3fr) minmax(0, 2fr);
  aspect-ratio: 6 / 5;
}

.grid.facebook-feed-square-5 figure:first-child {
  grid-column: 1 / 4;
  grid-row: 1;
}

.grid.facebook-feed-square-5 figure:nth-child(2) {
  grid-column: 4 / 7;
  grid-row: 1;
}

.grid.facebook-feed-square-5 figure:nth-child(3) {
  grid-column: 1 / 3;
  grid-row: 2;
}

.grid.facebook-feed-square-5 figure:nth-child(4) {
  grid-column: 3 / 5;
  grid-row: 2;
}

.grid.facebook-feed-square-5 figure:nth-child(5) {
  display: block;
  grid-column: 5 / 7;
  grid-row: 2;
}

/* Facebook shows five tiles for posts with more than five square photos. */
.grid.facebook-feed-square-5 figure:nth-child(n+6) {
  display: none;
}

.grid.facebook-feed-with-more figure:nth-child(5) {
  position: relative;
}

.grid.facebook-feed-with-more figure:nth-child(5)::after {
  content: attr(data-more-label);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.48);
  color: #fff;
  font: 700 clamp(28px, 7vw, 52px)/1 Arial, sans-serif;
  pointer-events: none;
}

section:has(> .grid.facebook-feed-gallery) > .media-head {
  display: none;
}

.grid figure:has(video) {
  background: #000;
}

.grid figure video {
  width: 100%;
  height: auto;
  max-height: none;
  aspect-ratio: auto;
  object-fit: contain;
  display: block;
  background: #000;
}

@media (max-width: 760px) {
  .media-head {
    align-items: stretch;
    flex-direction: column;
  }

  .media-toggle {
    width: 100%;
  }
}
