/* rs-photo.css v1.1 (3 Dec 2026): rows without a photo run full width; the caption sits under the text and the photo takes the height of text + caption (16:9 to 4:3); data-fit="whole" keeps a photo whole.
   v1.0 (20 Nov 2026): credited photos on revision pages (round 2-4 photos), patch_core.py.
   .rs-photo-row = the section's opening text and a photo side by side, half and half (as the Group 7 halogens
   photo); one column on phones. .rs-photo--block = a half-width photo under the text, centred. The frame is 4:3
   with the whole photo shown, so the layout is fixed before the photo loads (no layout shift). */

.rs-photo-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px 24px;
  align-items: start;
  margin: 0 0 18px;
}

.rs-photo-row > .rs-photo-text {
  min-width: 0;
}

.rs-photo-row > .rs-photo-text > :first-child {
  margin-top: 0;
}

.rs-photo-row > .rs-photo-text > :last-child {
  margin-bottom: 0;
}

figure.rs-photo {
  margin: 0;
  min-width: 0;
}

figure.rs-photo > img {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  border-radius: 10px;
  background: #f3f4f8;
}

figure.rs-photo > figcaption {
  margin-top: 6px;
  color: var(--rs-muted, #5f6475);
  font-size: 0.86rem;
  line-height: 1.45;
  text-align: left;
}

figure.rs-photo > figcaption > p {
  margin: 0 !important;
  padding: 0;
  font-size: inherit !important;
  line-height: inherit;
  color: inherit;
}

figure.rs-photo > figcaption > p.rs-photo-credit {
  margin-top: 3px !important;
  font-size: 0.9em !important;
}

figure.rs-photo > figcaption a {
  color: inherit;
  text-decoration: underline;
}

figure.rs-photo.rs-photo--block {
  width: 50%;
  margin: 4px auto 20px;
}

@media (max-width: 767.98px) {
  .rs-photo-row {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 767.98px) {
  figure.rs-photo.rs-photo--block {
    width: 100%;
  }
}

/* v1.1 (3 Dec 2026): a photo row whose photo has been taken out runs full width, not squeezed into the left half */

@media (min-width: 768px) {
  .rs-photo-row:not(:has( > figure.rs-photo)) {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Option B (3 Dec 2026): the caption and credit move under the text, in the text column, and the photo beside them
   takes the height of text + caption. The frame is never shorter than 16:9 or taller than 4:3, and the photo
   fills it (object-fit: cover: up to a quarter of a 4:3 photo's height can be trimmed, top and bottom equally).
   The size comes from the CSS alone, so nothing moves when the photo loads. Phones keep the one-column layout
   (photo, then caption, under the text). */

@media (min-width: 768px) {
  .rs-photo-row:has( > figure.rs-photo) {
    grid-template-rows: auto 1fr;
    row-gap: 0;
    container-type: inline-size;
  }
}

@media (min-width: 768px) {
  .rs-photo-row:has( > figure.rs-photo) > .rs-photo-text {
    grid-column: 1;
    grid-row: 1;
  }
}

@media (min-width: 768px) {
  .rs-photo-row > figure.rs-photo {
    display: contents;
  }
}

@media (min-width: 768px) {
  .rs-photo-row > figure.rs-photo > img {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: stretch;
    width: 100%;
    height: auto;
    contain: size;
    min-height: calc((50cqw - 12px) * 0.5625);
    max-height: calc((50cqw - 12px) * 0.75);
    aspect-ratio: auto;
    object-fit: cover;
    object-position: 50% 50%;
  }
}

@media (min-width: 768px) {
  .rs-photo-row > figure.rs-photo[data-fit="whole"] > img {
    min-height: calc((50cqw - 12px) * 0.75);
    object-fit: contain;
  }
}

@media (min-width: 768px) {
  .rs-photo-row > figure.rs-photo > figcaption {
    grid-column: 1;
    grid-row: 2;
    align-self: start;
    margin-top: 12px;
    padding-top: 7px;
    border-top: 1px solid #e3e6ee;
  }
}

/* Oak National Academy credit line (OGL v3.0) under an existing figure */

.rs-oak-credit {
  display: block;
  margin-top: 2px;
  font-size: 0.85em;
  color: var(--rs-muted, #5f6475);
}

.rs-oak-credit a {
  color: inherit;
  text-decoration: underline;
}

