/* ==========================================================================
   Assay figures: three types × three placements, one component.
   Markup (tools/assays/figures.py):
     <figure class="fig fig--{a|b|c} fig--{inline|expanded|margin} [fig--stack]">
       <div class="fig__media"> … </div>
       <figcaption class="fig__cap"><span class="fig__num">Figure n</span><span class="fig__text">…</span><span class="fig__src">…</span></figcaption>
     </figure>
   Images are never framed, recoloured or enlarged past their own pixel width; the page supplies only space,
   scale and a caption. Measurements refer to the reading column set in assay.css.
   ========================================================================== */

.assay { container-type: inline-size; container-name: assay; }
.a-body {
  /* where the reading column starts and how far the page's right margin is, for expanded figures */
  --col-left: calc(var(--m) + (100cqw - 2 * var(--m) + 40px) / 12 * 2);
  --to-right: calc(100cqw - var(--col-left) - var(--m));
}

/* ---- the figure ---- */
.fig { margin: 2.4em 0 2.6em; clear: both; }
.fig__media img { display: block; width: 100%; height: auto; border-radius: 2px; background: rgba(43, 75, 90, .06); }

/* caption: number, interpretation, source; one block under the image, set to the reading measure */
.fig__cap { display: block; max-width: 38em; margin-top: 16px; font-size: 16px; line-height: 1.55; color: rgba(32, 37, 38, .84); }
.fig__num {
  display: block; margin-bottom: 4px;
  font-family: 'Roboto Serif', Georgia, serif; font-weight: 420; font-size: 15px; letter-spacing: 0; color: var(--slate);
}
.fig__text { display: block; }
.fig__src { display: block; margin-top: 6px; font-size: 14px; line-height: 1.5; color: rgba(32, 37, 38, .66); }
.fig__src a { color: inherit; text-decoration: underline 1px rgba(32, 37, 38, .28); text-underline-offset: 3px; }
.fig__src a:hover, .fig__src a:focus-visible { color: var(--slate); text-decoration-color: var(--slate); }

/* ---- placements (desktop) ---- */
@media (min-width: 1001px) {
  /* expanded: from the column's left edge to the page's right margin */
  .fig--expanded { width: var(--to-right); max-width: none; margin-top: 3em; margin-bottom: 3.2em; }
  .fig--expanded .fig__cap { max-width: 36em; }
}
@media (min-width: 1380px) {
  /* marginal: beside the passage, in the right margin (same position as the pull observations) */
  .fig--margin { float: right; clear: right; width: 290px; margin: .3em -350px 1em 0; }
  .fig--margin .fig__cap { font-size: 15px; }
}

/* ---- Type C: comparison panels, equal width, side by side ---- */
.fig__media--panels { display: grid; grid-template-columns: repeat(var(--n, 2), minmax(0, 1fr)); gap: 24px; align-items: start; }
.fig__panel { max-width: var(--native); }               /* never wider than the source's own pixels */
.fig__panel-label {
  display: block; margin-top: 10px;
  font-family: 'Roboto Serif', Georgia, serif; font-weight: 380; font-size: 15px; color: var(--slate);
}
@media (min-width: 1001px) {
  .fig--c.fig--expanded .fig__media--panels { max-width: calc(var(--n, 2) * 824px + 24px); }
}

/* ---- Type B: the whole artifact and one detail; the detail is marked on the whole (Selective Attention) ---- */
.fig__media--detail { display: grid; grid-template-columns: 1.65fr 1fr; gap: 24px; align-items: start; }
.fig__whole { position: relative; }
.fig__mark {
  position: absolute; box-sizing: border-box; pointer-events: none;
  border: 2px solid var(--bone); outline: 1px solid rgba(32, 37, 38, .55); outline-offset: 0;
}
.fig__detail img { aspect-ratio: auto; }

/* ---- tablet and phone: every figure returns to the reading flow ---- */
@media (max-width: 1000px) {
  .fig, .fig--expanded, .fig--margin { float: none; width: auto; margin: 2.2em 0 2.4em; }
}
@media (max-width: 640px) {
  .fig { margin: 2em 0 2.2em; }
  .fig--stack .fig__media--panels, .fig__media--detail { grid-template-columns: 1fr; gap: 20px; }
  .fig__panel { max-width: none; }
  .fig__cap { font-size: 15px; }
  .fig__src { font-size: 14px; }
}

/* the pull observation and figures never collide: a figure always starts below any floated margin element */
.a-pull + .fig, .fig + .a-pull { clear: both; }

/* ---- added for Assays 02 and 03 (2026-12-01) ---- */
/* marginal width can be set per figure (--fig-w); the left edge stays 60px from the column */
@media (min-width: 1380px) {
  .fig--margin { width: var(--fig-w, 290px); margin-right: calc(-1 * var(--fig-w, 290px) - 60px); }
}
/* a portrait frame never fills a tablet or phone column at full height */
@media (max-width: 1379px) { .fig--portrait .fig__media { max-width: 360px; } }
/* Type B detail: never wider than its own pixels */
.fig__detail { max-width: var(--native, none); }
/* a marginal figure attached to its paragraph (handoff A02-F02): level with the paragraph's first line */
@media (min-width: 1380px) {
  .a-attach { position: relative; }
  .a-attach > .fig--margin { position: absolute; top: .35em; right: calc(-1 * var(--fig-w, 290px) - 60px); float: none; margin: 0; }
}
/* Type B: the mark is positioned on the image frame, so a label can sit under the whole view */
.fig__frame { position: relative; }
/* a figure capped narrower than the column (handoff width, e.g. a portrait frame at 280px): centred */
.fig--capped .fig__media { max-width: var(--fig-w); margin-inline: auto; }
/* comparison of narrow (portrait) panels: each capped; side by side from the left on desktop */
.fig--narrow-panels .fig__media--panels { grid-template-columns: repeat(var(--n, 2), minmax(0, var(--panel-max))); }
@media (max-width: 640px) {
  .fig--narrow-panels.fig--stack .fig__media--panels { grid-template-columns: minmax(0, var(--panel-max)); justify-content: center; }
  .fig--narrow-panels .fig__panel { max-width: var(--panel-max); }
}
