/* =============================================================================
   Article layouts — the magazine tools writers get in the composer.
   One file, loaded by the public article page (article.html), the dashboard
   (composer + final review: admin/index.html) and "Preview as published"
   (writer.js), so what a writer sets up is exactly what readers see.

   Every rule targets both the public body (.article-body, a 720px column)
   and the composer (.compose-body, up to 1140px), via the :is() list below.

   Figure classes (set by the composer's image window):
     size     rt-size-small | -compact | -standard | -wide | -large (full width)
     align    rt-align-left | rt-align-right   (inset; text wraps beside it)
     caption  rt-cap-minimal | rt-cap-side | rt-cap-overlay   (default: classic)
     frame    rt-frame-plain | rt-frame-rounded | rt-frame-mounted
   Blocks: figure.rt-gallery (image grid), aside.rt-callout, div.rt-stats,
   and pull-quote styles rt-pq-large / rt-pq-side.
   ========================================================================== */

/* styles.css gives every <img> content-visibility:auto, which collapses an
   off-screen picture to zero height until it scrolls into view — the page
   then jumps as each one pops in. Article pictures keep their real size. */
:is(.article-body, .compose-body) img { content-visibility: visible; }

/* ── Sizes ─────────────────────────────────────────────────────────────── */
:is(.article-body, .compose-body) figure.rt-figure { margin-top: 44px; margin-bottom: 44px; }
:is(.article-body, .compose-body) figure.rt-figure.rt-size-small { max-width: 320px; margin-left: auto; margin-right: auto; }
:is(.article-body, .compose-body) figure.rt-figure.rt-size-compact { max-width: 520px; margin-left: auto; margin-right: auto; }
:is(.article-body, .compose-body) figure.rt-figure.rt-size-standard { max-width: 720px; margin-left: auto; margin-right: auto; }
:is(.article-body, .compose-body) figure.rt-figure img,
:is(.article-body, .compose-body) figure.rt-gallery img { display: block; width: 100%; height: auto; margin: 0; }

/* Wide: breaks out of the text column. */
.compose-body figure.rt-figure.rt-size-wide,
.compose-body figure.rt-gallery.rt-size-wide { max-width: 980px; margin-left: auto; margin-right: auto; }
@media (min-width: 1080px) {
  .article-body figure.rt-figure.rt-size-wide,
  .article-body figure.rt-gallery.rt-size-wide { width: min(1040px, calc(100vw - 96px)); max-width: none; margin-left: 50%; transform: translateX(-50%); }
}

/* Full width: edge to edge of the screen. */
.compose-body figure.rt-figure.rt-size-large { max-width: none; margin-left: -20px; margin-right: -20px; }
.article-body figure.rt-figure.rt-size-large { width: 100vw; max-width: none; margin-left: 50%; transform: translateX(-50%); border-radius: 0; }
.article-body figure.rt-figure.rt-size-large img { border-radius: 0; max-height: 86vh; object-fit: cover; }
.article-body figure.rt-figure.rt-size-large figcaption { padding-left: 24px; padding-right: 24px; }
body[data-page="article"] .article-body-wrap { overflow-x: clip; }

/* ── Inset left / right: text wraps beside the picture ─────────────────── */
@media (min-width: 760px) {
  :is(.article-body, .compose-body) figure.rt-figure.rt-align-left,
  :is(.article-body, .compose-body) figure.rt-figure.rt-align-right {
    width: 44%; max-width: 340px; margin-top: 8px; margin-bottom: 20px;
  }
  :is(.article-body, .compose-body) figure.rt-figure.rt-size-small.rt-align-left,
  :is(.article-body, .compose-body) figure.rt-figure.rt-size-small.rt-align-right { width: 34%; max-width: 240px; }
  :is(.article-body, .compose-body) figure.rt-figure.rt-align-left { float: left; margin-left: 0; margin-right: 34px; }
  :is(.article-body, .compose-body) figure.rt-figure.rt-align-right { float: right; margin-right: 0; margin-left: 34px; }
  :is(.article-body, .compose-body) figure.rt-figure:is(.rt-align-left, .rt-align-right) figcaption { text-align: left; max-width: none; margin-left: 0; font-size: 13px; }
  /* Full-width things start below a floating picture. */
  :is(.article-body, .compose-body) > :is(figure.rt-figure:not(.rt-align-left):not(.rt-align-right):not(.rt-lead), figure.rt-gallery, .rt-stats, aside.rt-callout, hr) { clear: both; }
}
.compose-body figure.rt-figure.rt-align-left,
.compose-body figure.rt-figure.rt-align-right { outline-offset: 4px; }

/* ── Frames ─────────────────────────────────────────────────────────────── */
:is(.article-body, .compose-body) figure.rt-frame-plain img { border-radius: 0; }
:is(.article-body, .compose-body) figure.rt-frame-rounded img { border-radius: 14px; }
:is(.article-body, .compose-body) figure.rt-frame-mounted > img,
:is(.article-body, .compose-body) figure.rt-frame-mounted > a > img {
  padding: 12px; background: #fbf8f1; border: 1px solid rgba(15, 23, 42, 0.12); border-radius: 2px;
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04), 0 18px 36px -24px rgba(15, 23, 42, 0.5);
  box-sizing: border-box;
}

/* ── Caption styles ─────────────────────────────────────────────────────── */
/* Minimal: small, left-aligned, sans, no rule. */
:is(.article-body, .compose-body) figure.rt-cap-minimal figcaption {
  margin: 10px 0 0; padding: 0; max-width: none; border: 0;
  font-family: var(--sans, "Inter", -apple-system, system-ui, sans-serif); font-style: normal;
  font-size: 13px; line-height: 1.5; text-align: left; color: var(--ink-muted, #5b6474);
}
:is(.article-body, .compose-body) figure.rt-cap-minimal figcaption .fig-caption-text { display: inline; color: var(--ink, #1d1d1f); }
:is(.article-body, .compose-body) figure.rt-cap-minimal figcaption .fig-caption-credit { display: inline; margin: 0 0 0 8px; font-size: 10.5px; }

/* Beside the image (wide screens): a narrow caption column on the right. */
@media (min-width: 900px) {
  :is(.article-body, .compose-body) figure.rt-cap-side:not(.rt-align-left):not(.rt-align-right) {
    display: grid; grid-template-columns: minmax(0, 1fr) 190px; gap: 22px; align-items: end;
  }
  :is(.article-body, .compose-body) figure.rt-cap-side:not(.rt-align-left):not(.rt-align-right) > :is(img, a) { grid-column: 1; }
  :is(.article-body, .compose-body) figure.rt-cap-side:not(.rt-align-left):not(.rt-align-right) figcaption {
    grid-column: 2; margin: 0 0 4px; padding-top: 10px; max-width: none; text-align: left; font-size: 13.5px;
  }
}
@media (min-width: 1240px) {
  .article-body figure.rt-cap-side.rt-size-standard { width: 940px; max-width: none; margin-left: 0; }
}

/* Overlay: the caption sits on the bottom of the picture. */
:is(.article-body, .compose-body) figure.rt-cap-overlay { position: relative; }
:is(.article-body, .compose-body) figure.rt-cap-overlay figcaption {
  position: absolute; left: 0; right: 0; bottom: 0; margin: 0; max-width: none;
  padding: 56px 22px 16px; border: 0; text-align: left;
  background: linear-gradient(to top, rgba(10, 12, 18, 0.72), rgba(10, 12, 18, 0));
  color: #f8f7f3; font-size: 15px; border-radius: 0 0 inherit inherit;
}
:is(.article-body, .compose-body) figure.rt-cap-overlay figcaption .fig-caption-text { color: #f8f7f3; }
:is(.article-body, .compose-body) figure.rt-cap-overlay figcaption .fig-caption-credit { color: rgba(248, 247, 243, 0.78); }
:is(.article-body, .compose-body) figure.rt-cap-overlay.rt-frame-rounded figcaption { border-radius: 0 0 14px 14px; }
:is(.article-body, .compose-body) figure.rt-cap-overlay.rt-frame-mounted figcaption { left: 13px; right: 13px; bottom: 13px; }

/* ── Image grid (2–3 pictures side by side) ─────────────────────────────── */
:is(.article-body, .compose-body) figure.rt-gallery { margin: 48px auto; max-width: 720px; }
:is(.article-body, .compose-body) .rt-gallery-grid { display: grid; gap: 10px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
:is(.article-body, .compose-body) figure.rt-gallery.rt-cols-3 .rt-gallery-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
:is(.article-body, .compose-body) figure.rt-gallery .rt-gallery-grid img { width: 100%; height: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 4px; }
:is(.article-body, .compose-body) figure.rt-gallery.rt-shape-square .rt-gallery-grid img { aspect-ratio: 1; }
:is(.article-body, .compose-body) figure.rt-gallery.rt-shape-portrait .rt-gallery-grid img { aspect-ratio: 4 / 5; }
:is(.article-body, .compose-body) figure.rt-gallery.rt-shape-natural .rt-gallery-grid { align-items: start; }
:is(.article-body, .compose-body) figure.rt-gallery.rt-shape-natural .rt-gallery-grid img { aspect-ratio: auto; height: auto; }
:is(.article-body, .compose-body) figure.rt-gallery.rt-frame-plain .rt-gallery-grid img { border-radius: 0; }
:is(.article-body, .compose-body) figure.rt-gallery.rt-frame-rounded .rt-gallery-grid img { border-radius: 12px; }
@media (max-width: 560px) {
  :is(.article-body, .compose-body) figure.rt-gallery.rt-cols-3 .rt-gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ── Callout box ────────────────────────────────────────────────────────── */
:is(.article-body, .compose-body) aside.rt-callout {
  margin: 40px auto; padding: 22px 26px 6px; max-width: 680px;
  background: #f3eee4; border-left: 3px solid #8a5a3c; border-radius: 0 10px 10px 0;
  font-size: 0.92em; line-height: 1.6; color: var(--ink, #1d1d1f);
}
:is(.article-body, .compose-body) aside.rt-callout p { margin: 0 0 16px; }
:is(.article-body, .compose-body) aside.rt-callout .rt-callout-label {
  margin: 0 0 8px; font-family: var(--sans, "Inter", -apple-system, system-ui, sans-serif);
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: #8a5a3c;
}
:is(.article-body, .compose-body) aside.rt-callout[data-tone="sage"] { background: #e8ede1; border-left-color: #4f6b52; }
:is(.article-body, .compose-body) aside.rt-callout[data-tone="sage"] .rt-callout-label { color: #4f6b52; }
:is(.article-body, .compose-body) aside.rt-callout[data-tone="ink"] { background: #18202e; border-left-color: #e8d9b0; color: #eef0f4; }
:is(.article-body, .compose-body) aside.rt-callout[data-tone="ink"] .rt-callout-label { color: #e8d9b0; }
:is(.article-body, .compose-body) aside.rt-callout[data-tone="ink"] a { color: #f3e6c2; }
:is(.article-body, .compose-body) aside.rt-callout[data-tone="line"] { background: transparent; border: 1px solid rgba(15, 23, 42, 0.16); border-left: 3px solid var(--ink, #1d1d1f); }
:is(.article-body, .compose-body) aside.rt-callout[data-tone="line"] .rt-callout-label { color: var(--ink, #1d1d1f); }

/* ── By the numbers ─────────────────────────────────────────────────────── */
:is(.article-body, .compose-body) .rt-stats {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0;
  margin: 44px auto; max-width: 760px; border-top: 2px solid var(--ink, #1d1d1f); border-bottom: 1px solid rgba(15, 23, 42, 0.16);
}
:is(.article-body, .compose-body) .rt-stats.rt-stats-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
:is(.article-body, .compose-body) .rt-stats.rt-stats-1 { grid-template-columns: 1fr; text-align: center; }
:is(.article-body, .compose-body) .rt-stat { padding: 20px 20px 18px; border-left: 1px solid rgba(15, 23, 42, 0.12); }
:is(.article-body, .compose-body) .rt-stat:first-child { border-left: 0; padding-left: 0; }
:is(.article-body, .compose-body) .rt-stats.rt-stats-1 .rt-stat { padding-left: 20px; }
:is(.article-body, .compose-body) .rt-stat p { margin: 0; }
:is(.article-body, .compose-body) .rt-stat .rt-stat-num {
  font-family: var(--serif, Georgia, serif); font-weight: 700; font-size: 2.6em; line-height: 1;
  letter-spacing: -0.03em; color: var(--ink, #1d1d1f);
}
:is(.article-body, .compose-body) .rt-stat .rt-stat-label {
  margin-top: 10px; font-family: var(--sans, "Inter", -apple-system, system-ui, sans-serif);
  font-size: 13.5px; line-height: 1.45; color: var(--ink-muted, #5b6474);
}
@media (max-width: 640px) {
  :is(.article-body, .compose-body) .rt-stats { grid-template-columns: 1fr !important; }
  :is(.article-body, .compose-body) .rt-stat { border-left: 0; border-top: 1px solid rgba(15, 23, 42, 0.12); padding-left: 0; }
  :is(.article-body, .compose-body) .rt-stat:first-child { border-top: 0; }
}

/* ── Pull-quote styles ──────────────────────────────────────────────────── */
:is(.article-body, .compose-body) figure.rt-pullquote.rt-pq-large {
  max-width: 760px; padding: 18px 8px 8px; border: 0;
  font-size: 2.2rem; font-weight: 500; line-height: 1.22; font-style: italic;
}
:is(.article-body, .compose-body) figure.rt-pullquote.rt-pq-large::before {
  content: "“"; display: block; height: 0.55em; margin-bottom: 6px;
  font-size: 2.6em; line-height: 1; font-style: normal; color: #8a5a3c;
}
@media (min-width: 900px) {
  :is(.article-body, .compose-body) figure.rt-pullquote.rt-pq-side {
    float: right; width: 42%; max-width: 320px; margin: 8px 0 22px 36px; padding: 16px 0 14px;
    border-top: 3px solid var(--ink, #1d1d1f); border-bottom: 0; text-align: left;
    font-size: 1.35rem; line-height: 1.32;
  }
  :is(.article-body, .compose-body) figure.rt-pullquote.rt-pq-side figcaption { text-align: left; }
}

/* ── Composer only: show which blocks are editable controls ────────────── */
.compose-body figure.rt-gallery { cursor: pointer; position: relative; }
.compose-body figure.rt-gallery:hover { outline: 2px solid var(--accent, #0f172a); outline-offset: 6px; border-radius: 6px; }
.compose-body :is(aside.rt-callout, .rt-stats, figure.rt-pullquote).is-active { outline: 2px dashed rgba(15, 23, 42, 0.35); outline-offset: 6px; }

/* Credit lines link to the source when there is one. */
:is(.article-body, .compose-body) .fig-caption-credit a { color: inherit; text-decoration: underline; text-decoration-color: rgba(15, 23, 42, 0.3); text-underline-offset: 2px; }
:is(.article-body, .compose-body) .fig-caption-credit a:hover { text-decoration-color: currentColor; }
:is(.article-body, .compose-body) figure.rt-cap-overlay .fig-caption-credit a { text-decoration-color: rgba(248, 247, 243, 0.5); }
