/* ══════════════════════════════════════════════════════════════════════════
   figures.css — the plates.

   Every study page carries sourced figures now, and they all need the same
   three things: a frame that does not fight the prose column, a caption that
   reads like a caption and not like a paragraph, and a licence line that is
   small but never hidden. The licence line matters legally for CC BY and
   CC BY-SA, so it is text, not a tooltip.

   Loaded after journal.css on purpose: journal.css flattens radii and shadows
   under body.jr, and these rules are scoped to body.jr to win on specificity
   rather than with !important.

   Click-to-zoom is figure-zoom.js, which opts in on img[data-zoom] and reads
   the credit line from .topic-img-src — so the class name below is a contract,
   not a style choice.
   ══════════════════════════════════════════════════════════════════════════ */

body.jr .vt-fig {
  margin: 1.7rem 0 1.5rem;
  padding: 0;
  display: block;
  break-inside: avoid;
}

body.jr .vt-fig img {
  display: block;
  margin: 0 auto;
  width: auto;
  max-width: 100%;
  max-height: 520px;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: #fff;
  cursor: zoom-in;
}

body.jr .vt-fig figcaption {
  margin: .75rem auto 0;
  max-width: 64ch;
  font-size: .9rem;
  line-height: 1.6;
  color: var(--text2);
  text-wrap: pretty;
}

body.jr .vt-fig .topic-img-src {
  margin: .4rem auto 0;
  max-width: 64ch;
  font-size: .72rem;
  line-height: 1.45;
  letter-spacing: .01em;
  color: var(--text3);
}

body.jr .vt-fig .topic-img-src a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

body.jr .vt-fig .topic-img-src a:hover {
  color: var(--text2);
}

/* ── inside the block reader ───────────────────────────────────────────────
   A reader block is meant to be one screenful. 520 px of plate plus a section
   heading plus a two-line caption overflows a laptop viewport, which pushed
   the licence line behind the fixed footer — off the very view the figures
   were added for. So the plate is capped against the viewport, not in absolute
   pixels.

   The 470px reserve is measured, not guessed: top bar 58 + reader padding +
   the section head (two or three lines depending on the title) puts the plate
   at y≈245–320, the footer takes 69 and 96 goes to caption plus licence.
   470 is the worst case of those sums, so the credit line stays on screen at
   every viewport height instead of hiding behind the Next button. */
#chRRead .vt-fig { margin: 1rem 0 .3rem; }
#chRRead .vt-fig img { max-height: max(230px, calc(100vh - 470px)); }
#chRRead .vt-fig figcaption { margin-top: .6rem; font-size: .88rem; line-height: 1.55; }
#chRRead .vt-fig .topic-img-src { margin-top: .3rem; }

/* On a phone a tall diagram would fill three screens; cap it and let the
   zoom viewer do the work. */
@media (max-width: 640px) {
  body.jr .vt-fig img { max-height: 58vh; }
  body.jr .vt-fig figcaption { font-size: .86rem; }
  #chRRead .vt-fig img { max-height: 50vh; }
}

@media print {
  body.jr .vt-fig img { max-height: 90mm; cursor: default; }
  body.jr .vt-fig .topic-img-src a { text-decoration: none; }
}
