/* ==========================================================================
   RIDHU CMS — Typography system for rich content (assets/css/typography.css)

   One stylesheet for every place article HTML is shown:
     public site   .dyn-article-body (stories, live blogs, previews), .page-body (static pages), .prose (live updates)
     admin editor  .rt-content (the Jodit editing area, so what is written looks as it will be published)
   Loaded after site.css on the public site and by the admin pages that have the rich-text editor. Every rule is
   scoped to those containers; site.css keeps the element defaults for the rest of the site.

   The tokens fall back to the site's design tokens (site.css :root, Admin → Appearance), so the admin, which does
   not define them, renders with the same fonts and sizes. Content markup comes from App\Html (sanitised; tables are
   wrapped in .table-wrap, iframes carry their aspect ratio) and from the editor (docs/EDITOR.md, docs/TYPOGRAPHY.md).
   ========================================================================== */

:is(.prose, .dyn-article-body, .page-body, .rt-content) {
  /* families */
  /* (the fallbacks are site.css's defaults, for the admin editor, which does not define the site's tokens) */
  --ty-font-text: var(--font-editorial, "Faustina", "Faustina Fallback", "Noto Serif Devanagari", Georgia, "Times New Roman", serif);
  --ty-font-head: var(--ty-font-text);
  --ty-font-ui: var(--font-ui, "Montserrat", "Montserrat Fallback", "Noto Sans Devanagari", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif);
  --ty-font-mono: var(--font-mono, ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace);
  /* sizes: fluid between a 320 px phone and a 1440 px screen, never larger after that */
  --ty-size: var(--fs-prose, clamp(1.125rem, 1.07rem + 0.25vw, 1.1875rem));
  --ty-h1: clamp(1.625rem, 1.35rem + 1.1vw, 2.125rem);
  --ty-h2: clamp(1.375rem, 1.18rem + 0.75vw, 1.75rem);
  --ty-h3: clamp(1.1875rem, 1.08rem + 0.4vw, 1.375rem);
  --ty-h4: 1.125rem;
  --ty-h5: 1rem;
  --ty-h6: 0.8125rem;
  --ty-small: 0.875em;
  --ty-caption: 0.8125rem;
  --ty-table: 0.9375rem;
  --ty-code: 0.875em;
  --ty-quote: clamp(1.1875rem, 1.1rem + 0.35vw, 1.3125rem);
  /* weights, line heights, letter spacing */
  --ty-w-text: var(--fw-regular, 400);
  --ty-w-strong: var(--fw-bold, 700);
  --ty-w-head: var(--fw-headline, 700);
  --ty-w-ui: var(--fw-semibold, 600);
  --ty-lh: 1.68;
  --ty-lh-head: var(--lh-snug, 1.3);
  --ty-lh-tight: var(--lh-normal, 1.5);
  --ty-ls-head: var(--ls-headline, -0.005em);
  --ty-ls-caps: var(--ls-caps, 0.06em);
  /* rhythm: everything is in em, so the reader's text-size control scales the spacing too */
  --ty-flow: 1.1em;              /* between paragraphs and blocks */
  --ty-head-before: 1.8em;       /* above a heading */
  --ty-head-after: 0.5em;        /* between a heading and what it introduces */
  --ty-list-indent: 1.5em;
  --ty-list-gap: 0.4em;
  --ty-figure-space: 1.6em;      /* above and below images, galleries, media, tables */
  --ty-float-gap: 1.5rem;        /* between a floated image and the text beside it */
  --ty-table-pad: 0.6em 0.75em;
  --ty-code-pad: 1em 1.1em;
  --ty-quote-pad: 1.25rem;
  --ty-gallery-gap: 0.5rem;
  /* colours */
  --ty-ink: var(--ink-2, #2b2b2b);
  --ty-strong-ink: var(--ink, #111);
  --ty-head-ink: var(--heading, var(--ink, #111));
  --ty-muted: var(--faint, #6b6b6b);
  --ty-line: var(--line, #e5e5e5);
  --ty-line-2: var(--line-2, #cfcfcf);
  --ty-fill: var(--fill, #f5f5f5);
  --ty-mark: var(--mark, #fff3b0);
  --ty-link: var(--brand, #1f4b99);

  font-family: var(--ty-font-text);
  font-size: var(--ty-size);
  font-weight: var(--ty-w-text);
  line-height: var(--ty-lh);
  color: var(--ty-ink);
  overflow-wrap: break-word;
  min-width: 0;
}
/* the reader's text-size control (Article Experience) scales the story text */
.dyn-article-body { font-size: calc(var(--ty-size) * var(--ak-fs, 1)); }
/* live-blog updates are set a little smaller than a story */
.lb-up-body.prose { --ty-size: var(--fs-base, 0.9375rem); }

/* ---------- reset and vertical rhythm ---------- */
:is(.prose, .dyn-article-body, .page-body, .rt-content) :where(p, h1, h2, h3, h4, h5, h6, ul, ol, dl, dd, blockquote, figure, pre, address, table, details, hr, section, article, aside, header, footer, nav) { margin: 0; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) > * + *,
:is(.prose, .dyn-article-body, .page-body, .rt-content) :is(section, article, aside, header, footer, nav, details, blockquote, li, dd, td, th, figcaption) > * + * { margin-top: var(--ty-flow); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) > :first-child { margin-top: 0; }
/* the float of the last image never sticks out of the text */
:is(.prose, .dyn-article-body, .page-body, .rt-content)::after { content: ""; display: block; clear: both; }

/* ---------- headings ---------- */
:is(.prose, .dyn-article-body, .page-body, .rt-content) :is(h1:not(.page-h1), h2, h3, h4, h5, h6) {
  margin-top: var(--ty-head-before); color: var(--ty-head-ink); font-family: var(--ty-font-head); font-weight: var(--ty-w-head);
  line-height: var(--ty-lh-head); letter-spacing: var(--ty-ls-head); text-wrap: balance; overflow-wrap: break-word; hyphens: manual;
}
:is(.prose, .dyn-article-body, .page-body, .rt-content) > :is(h1:not(.page-h1), h2, h3, h4, h5, h6):first-child { margin-top: 0; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) :is(h1:not(.page-h1), h2, h3, h4, h5, h6) + * { margin-top: var(--ty-head-after); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) :is(h1:not(.page-h1), h2, h3, h4, h5, h6) + :is(h1:not(.page-h1), h2, h3, h4, h5, h6) { margin-top: 0.8em; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) h1:not(.page-h1) { font-size: var(--ty-h1); line-height: var(--lh-tight, 1.2); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) h2 { font-size: var(--ty-h2); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) h3 { font-size: var(--ty-h3); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) h4 { font-size: var(--ty-h4); }
/* h5 and h6 are labels: the interface font, h6 in capitals */
:is(.prose, .dyn-article-body, .page-body, .rt-content) :is(h5, h6) { font-family: var(--ty-font-ui); font-weight: var(--ty-w-ui); letter-spacing: normal; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) h5 { font-size: var(--ty-h5); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) h6 { font-size: var(--ty-h6); letter-spacing: var(--ty-ls-caps); text-transform: uppercase; }
/* a heading (and a rule, a table, a code block) starts below a floated image, never squeezed beside it */
:is(.prose, .dyn-article-body, .page-body, .rt-content) :is(h2, h3, hr, .table-wrap, pre, figure.media, figure.gallery, .mg, details) { clear: both; }

/* ---------- text ---------- */
:is(.prose, .dyn-article-body, .page-body, .rt-content) a { color: var(--ty-link); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) a:visited { color: var(--link-visited, var(--ty-link)); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) a:hover { text-decoration-thickness: 2px; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) a:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) :is(strong, b) { font-weight: var(--ty-w-strong); color: var(--ty-strong-ink); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) :is(em, i, cite, dfn, var) { font-style: italic; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) dfn { font-weight: var(--ty-w-ui); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) u { text-decoration: underline; text-underline-offset: 0.18em; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) :is(s, strike) { text-decoration: line-through; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) del { text-decoration: line-through; text-decoration-color: var(--red, #c8102e); color: var(--ty-muted); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) ins { text-decoration: underline; text-decoration-color: var(--green, #067647); text-underline-offset: 0.18em; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) mark { padding: 0 0.15em; background: var(--ty-mark); color: var(--ty-strong-ink); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) small { font-size: var(--ty-small); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) big { font-size: 1.2em; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) :is(sub, sup) { position: relative; font-size: 0.75em; line-height: 0; vertical-align: baseline; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) sup { top: -0.5em; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) sub { bottom: -0.25em; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) abbr[title] { text-decoration: underline dotted; text-underline-offset: 0.18em; cursor: help; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) q { quotes: "\201C" "\201D" "\2018" "\2019"; font-style: normal; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) :is(time, data, bdi, bdo, span) { font: inherit; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) address { font-style: normal; padding-left: 0.9em; border-left: 2px solid var(--ty-line-2); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) ruby { ruby-position: over; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) rt { font-family: var(--ty-font-ui); font-size: 0.55em; line-height: 1; color: var(--ty-muted); }
/* paragraphs left empty by an editor take no space */
:is(.prose, .dyn-article-body, .page-body, .rt-content) > p:empty { display: none; }

/* ---------- lists ---------- */
:is(.prose, .dyn-article-body, .page-body, .rt-content) :is(ul, ol):not([class]) { padding-left: var(--ty-list-indent); }
/* lists beside a floated image move clear of it (their markers would otherwise sit on the image) */
:is(.prose, .dyn-article-body, .page-body, .rt-content) :is(ul, ol, dl, blockquote, address) { display: flow-root; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) :is(ul, ol):not([class]) > li { padding-left: 0.2em; }
/* numbers of three digits or more (a list from 98, a value of 120, ten or more items counted down) need more room */
:is(.prose, .dyn-article-body, .page-body, .rt-content) ol:not([class]):is([start], [reversed], :has(> li[value]), :has(> li:nth-child(10))) { padding-left: 2.4em; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) li + li { margin-top: var(--ty-list-gap); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) li > :is(ul, ol) { margin-top: var(--ty-list-gap); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) li::marker { color: var(--ty-muted); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) ol > li::marker { font-variant-numeric: tabular-nums; }
/* nested markers, unless the editor chose one (type="" or a list-style-type style) */
:is(.prose, .dyn-article-body, .page-body, .rt-content) ul ul:not([type], [style*="list-style"]) { list-style-type: circle; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) ul ul ul:not([type], [style*="list-style"]) { list-style-type: square; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) ol ol:not([type], [style*="list-style"]) { list-style-type: lower-alpha; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) ol ol ol:not([type], [style*="list-style"]) { list-style-type: lower-roman; }
/* named marker styles for authors writing HTML */
:is(.prose, .dyn-article-body, .page-body, .rt-content) ol.list-alpha { list-style-type: lower-alpha; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) ol.list-roman { list-style-type: lower-roman; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) ul.list-none { list-style: none; padding-left: 0; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) ul.list-check { list-style: none; padding-left: var(--ty-list-indent); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) ul.list-check > li::before { content: "\2713"; display: inline-block; width: 1.3em; margin-left: -1.3em; color: var(--green, #067647); font-weight: var(--ty-w-strong); }
/* description lists: term and description side by side; one column on phones */
:is(.prose, .dyn-article-body, .page-body, .rt-content) dl { display: grid; grid-template-columns: minmax(0, max-content) minmax(0, 1fr); gap: 0.5em 1.5em; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) dt { grid-column: 1; margin: 0; font-weight: var(--ty-w-strong); color: var(--ty-strong-ink); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) dd { grid-column: 2; margin: 0; }
@media (max-width: 575px) {
  :is(.prose, .dyn-article-body, .page-body, .rt-content) dl { grid-template-columns: minmax(0, 1fr); gap: 0.15em; }
  :is(.prose, .dyn-article-body, .page-body, .rt-content) :is(dt, dd) { grid-column: 1; }
  :is(.prose, .dyn-article-body, .page-body, .rt-content) dd + dt { margin-top: 0.6em; }
}

/* ---------- quotations ---------- */
:is(.prose, .dyn-article-body, .page-body, .rt-content) blockquote:not(.twitter-tweet, .instagram-media, .tiktok-embed) {
  padding-left: var(--ty-quote-pad); border-left: 3px solid var(--ty-strong-ink); font-family: var(--ty-font-text); font-size: var(--ty-quote);
  font-style: italic; line-height: var(--ty-lh-tight); color: var(--ty-strong-ink);
}
:is(.prose, .dyn-article-body, .page-body, .rt-content) blockquote > * + * { margin-top: 0.6em; }
/* attribution: a cite or footer inside the quotation */
:is(.prose, .dyn-article-body, .page-body, .rt-content) blockquote > :is(cite, footer) { display: block; font-family: var(--ty-font-ui); font-size: 0.75em; font-style: normal; line-height: var(--ty-lh-tight); color: var(--ty-muted); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) blockquote > :is(cite, footer)::before { content: "\2014\00a0"; }
/* a quotation inside a quotation: smaller, lighter rule */
:is(.prose, .dyn-article-body, .page-body, .rt-content) blockquote blockquote:not([class]) { font-size: 0.9em; border-left-width: 2px; border-left-color: var(--ty-line-2); }

/* ---------- code ---------- */
:is(.prose, .dyn-article-body, .page-body, .rt-content) :is(code, kbd, samp, pre) { font-family: var(--ty-font-mono); font-size: var(--ty-code); font-style: normal; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) :not(pre) > :is(code, samp) { padding: 0.1em 0.3em; background: var(--ty-fill); overflow-wrap: anywhere; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) kbd { padding: 0.05em 0.4em; border: 1px solid var(--ty-line-2); border-bottom-width: 2px; background: var(--bg, #fff); font-size: 0.8em; white-space: nowrap; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) pre {
  max-width: 100%; overflow-x: auto; padding: var(--ty-code-pad); background: var(--ty-fill); border-left: 3px solid var(--ty-line-2);
  line-height: 1.55; white-space: pre; overflow-wrap: normal; tab-size: 4; -webkit-overflow-scrolling: touch;
}
:is(.prose, .dyn-article-body, .page-body, .rt-content) pre code { padding: 0; background: none; font-size: inherit; white-space: inherit; overflow-wrap: normal; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) pre:focus-visible { outline: 2px solid var(--ty-link); outline-offset: 2px; }

/* ---------- rules and breaks ---------- */
:is(.prose, .dyn-article-body, .page-body, .rt-content) hr { height: 0; margin-block: 2em; border: 0; border-top: 1px solid var(--ty-line-2); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) hr + hr { display: none; }                /* no doubled separators */
:is(.prose, .dyn-article-body, .page-body, .rt-content) hr + * { margin-top: 0; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) hr:last-child { margin-bottom: 0; }

/* ---------- images ---------- */
:is(.prose, .dyn-article-body, .page-body, .rt-content) :is(img, picture, svg, video, canvas) { max-width: 100%; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) img { height: auto; }
/* an image in a line of text stays in the line */
:is(.prose, .dyn-article-body, .page-body, .rt-content) :is(p, li, td, th, dd, a, span, em, strong, figcaption) > img { display: inline-block; vertical-align: middle; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) figure { margin-block: var(--ty-figure-space); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) > figure:first-child { margin-top: 0; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) figcaption { margin-top: 0.5rem; font-family: var(--ty-font-ui); font-size: var(--ty-caption); line-height: 1.45; color: var(--ty-muted); text-align: left; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) figcaption .credit { font-style: italic; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) figcaption .credit::before { content: ""; }
/* a figure of an image: as wide as its image (original size, never upscaled), centred; the caption wraps to it */
:is(.prose, .dyn-article-body, .page-body, .rt-content) figure.image { display: table; max-width: 100%; margin-inline: auto; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) figure.image > :is(img, picture, a) { display: block; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) figure.image img { display: block; width: auto; max-width: 100%; height: auto; margin-inline: auto; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) figure.image > figcaption { display: table-caption; caption-side: bottom; }
/* a chosen width (25–100 %): the figure has it, the image fills it */
:is(.prose, .dyn-article-body, .page-body, .rt-content) figure.image_resized { max-width: 100%; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) figure.image_resized img { width: 100%; }
/* beside the text: left, right (the editor's "side") */
:is(.prose, .dyn-article-body, .page-body, .rt-content) figure:is(.image-style-side, .image-style-align-right) { float: right; clear: both; max-width: 46%; margin: 0.3em 0 1em var(--ty-float-gap); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) figure.image-style-align-left { float: left; clear: both; max-width: 46%; margin: 0.3em var(--ty-float-gap) 1em 0; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) figure:is(.image-style-side, .image-style-align-right, .image-style-align-left):not(.image_resized) img { width: 100%; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) figure:is(.image-style-block, .image-style-align-center) { margin-inline: auto; }
/* phones: images beside text are stacked above it, full width */
@media (max-width: 575px) {
  :is(.prose, .dyn-article-body, .page-body, .rt-content) figure:is(.image-style-side, .image-style-align-right, .image-style-align-left) { float: none; display: table; width: auto !important; max-width: 100%; margin: var(--ty-figure-space) auto; }
}
/* an image that failed to load keeps its box and shows its description (assets/js/article.js marks it) */
:is(.prose, .dyn-article-body, .page-body, .rt-content) img.is-broken { min-width: 8rem; min-height: 4rem; padding: 0.75rem; background: var(--ty-fill); border: 1px dashed var(--ty-line-2); color: var(--ty-muted); font: var(--ty-caption)/1.4 var(--ty-font-ui); object-fit: none; }

/* ---------- galleries ----------
   .gallery: written in the editor (Insert gallery): <figure class="gallery gallery-cols-3">, one figure per photo,
             then an optional caption for the whole gallery. gallery-masonry keeps each photo's own shape.
   .mg:      a Media Library gallery ([gallery id=N], /gallery/{slug}); its layout rules are in site.css. */
:is(.prose, .dyn-article-body, .page-body, .rt-content) figure.gallery { --cols: 3; display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: var(--ty-gallery-gap); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) figure.gallery.gallery-cols-1 { --cols: 1; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) figure.gallery.gallery-cols-2 { --cols: 2; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) figure.gallery.gallery-cols-3 { --cols: 3; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) figure.gallery.gallery-cols-4 { --cols: 4; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) figure.gallery > figure { min-width: 0; margin: 0; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) figure.gallery > figure img { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; background: var(--ty-fill); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) figure.gallery > figure > figcaption { margin-top: 0.3rem; font-size: 0.75rem; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) figure.gallery > figcaption { grid-column: 1 / -1; margin-top: 0.25rem; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) figure.gallery.gallery-cols-1 > figure img { aspect-ratio: auto; object-fit: contain; }
/* masonry: columns, every photo in its own proportions */
:is(.prose, .dyn-article-body, .page-body, .rt-content) figure.gallery.gallery-masonry { display: block; columns: var(--cols); column-gap: var(--ty-gallery-gap); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) figure.gallery.gallery-masonry > figure { break-inside: avoid; margin-bottom: var(--ty-gallery-gap); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) figure.gallery.gallery-masonry > figure img { aspect-ratio: auto; object-fit: contain; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) figure.gallery.gallery-masonry > figcaption { column-span: all; }
@media (max-width: 767px) { :is(.prose, .dyn-article-body, .page-body, .rt-content) figure.gallery.gallery-cols-4 { --cols: 3; } }
@media (max-width: 599px) { :is(.prose, .dyn-article-body, .page-body, .rt-content) figure.gallery:is(.gallery-cols-3, .gallery-cols-4) { --cols: 2; } }
@media (max-width: 359px) { :is(.prose, .dyn-article-body, .page-body, .rt-content) figure.gallery:not(.gallery-cols-1) { --cols: 1; } }
/* the photo opens in the lightbox (assets/js/lightbox.js wraps each image in this button) */
.lbx-open { display: block; width: 100%; padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: zoom-in; }
.lbx-open:focus-visible { outline: 3px solid var(--brand, #1f4b99); outline-offset: 2px; }

/* the lightbox (a modal dialog over the page) */
html:has(dialog.lbx[open]) { overflow: hidden; }
dialog.lbx { position: fixed; inset: 0; width: 100vw; max-width: none; height: 100dvh; max-height: none; margin: 0; padding: 0; border: 0; background: #0b0b0b; color: #f2f2f2; }
dialog.lbx[open] { display: flex; flex-direction: column; }
dialog.lbx::backdrop { background: rgb(0 0 0 / 0.6); }
.lbx-bar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.5rem 0.5rem 0.5rem 1rem; padding-top: max(0.5rem, env(safe-area-inset-top)); }
.lbx-count { margin: 0; font: 600 0.875rem/1.2 var(--font-ui, system-ui, sans-serif); color: #d8d8d8; }
.lbx-stage { position: relative; display: flex; flex: 1 1 auto; align-items: center; justify-content: center; gap: 0.5rem; min-height: 0; padding: 0 0.5rem 0.75rem; touch-action: pan-y pinch-zoom; }
.lbx-fig { display: flex; flex: 1 1 auto; flex-direction: column; align-items: center; justify-content: center; min-width: 0; height: 100%; margin: 0; }
.lbx-img { display: block; flex: 0 1 auto; min-height: 0; max-width: 100%; max-height: calc(100dvh - 9rem); width: auto; height: auto; object-fit: contain; background: #222; }
.lbx-cap { flex: 0 0 auto; max-width: 70ch; margin-top: 0.75rem; padding-bottom: env(safe-area-inset-bottom); font: 0.875rem/1.45 var(--font-ui, system-ui, sans-serif); color: #e0e0e0; text-align: center; }
.lbx-cap .credit, .lbx-cap .mg-credit { color: #b8b8b8; font-style: italic; }
.lbx-btn { display: inline-flex; flex: 0 0 auto; align-items: center; justify-content: center; width: 48px; height: 48px; padding: 0; border: 1px solid rgb(255 255 255 / 0.3); background: rgb(0 0 0 / 0.5); color: #fff; cursor: pointer; }
.lbx-btn svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.lbx-btn:hover:not(:disabled) { background: rgb(255 255 255 / 0.15); }
.lbx-btn:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.lbx-btn:disabled { opacity: 0.3; cursor: default; }
.lbx-btn[hidden] { display: none; }
/* phones: the arrows sit over the photo's edges, the photo uses the whole width */
@media (max-width: 599px) {
  .lbx-stage { padding-inline: 0; }
  .lbx-prev, .lbx-next { position: absolute; top: 50%; z-index: 1; transform: translateY(-50%); }
  .lbx-prev { left: 0.25rem; } .lbx-next { right: 0.25rem; }
}

/* ---------- video, audio, embeds ---------- */
:is(.prose, .dyn-article-body, .page-body, .rt-content) figure.media { margin-inline: auto; text-align: center; font-size: var(--fs-base, 1rem); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) figure.media > figcaption { text-align: center; }
/* the width chosen in the editor's video dialog (full width otherwise); phones always use the full width */
:is(.prose, .dyn-article-body, .page-body, .rt-content) figure.media.media-w75 { max-width: 75%; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) figure.media.media-w50 { max-width: 50%; }
@media (max-width: 575px) { :is(.prose, .dyn-article-body, .page-body, .rt-content) figure.media:is(.media-w75, .media-w50) { max-width: 100%; } }
/* vertical video (YouTube Shorts): phone-sized, centred */
:is(.prose, .dyn-article-body, .page-body, .rt-content) figure.media-vertical { max-width: min(100%, 360px); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) video { display: block; width: 100%; height: auto; margin-inline: auto; background: #000; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) audio { display: block; width: 100%; }
/* iframes: never wider than the text; App\Html gives every video and map frame its aspect ratio */
:is(.prose, .dyn-article-body, .page-body, .rt-content) iframe { display: block; max-width: 100%; margin-inline: auto; border: 0; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) iframe[style*="aspect-ratio"],
:is(.prose, .dyn-article-body, .page-body, .rt-content) iframe:is([src*="youtube.com/embed"], [src*="youtube-nocookie.com/embed"], [src*="player.vimeo.com"], [src*="dailymotion.com/embed"]) { width: 100%; height: auto; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) iframe:is([src*="youtube.com/embed"], [src*="youtube-nocookie.com/embed"], [src*="player.vimeo.com"], [src*="dailymotion.com/embed"]):not([style*="aspect-ratio"]) { aspect-ratio: 16 / 9; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) iframe:is([src*="google.com/maps"], [src*="maps.google."], [src*="bing.com/maps"]) { width: 100%; min-height: 280px; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) iframe[src*="facebook.com/plugins"] { width: min(100%, 500px); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) iframe[src*="instagram.com"] { width: 100%; max-width: 400px; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) iframe[src*="open.spotify.com"] { width: 100%; }
/* a responsive box for HTML written by hand: <div class="embed-responsive [embed-4x3 | embed-1x1 | embed-9x16]"><iframe …> */
:is(.prose, .dyn-article-body, .page-body, .rt-content) .embed-responsive { position: relative; width: 100%; aspect-ratio: 16 / 9; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) .embed-responsive.embed-4x3 { aspect-ratio: 4 / 3; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) .embed-responsive.embed-1x1 { aspect-ratio: 1; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) .embed-responsive.embed-9x16 { max-width: 360px; margin-inline: auto; aspect-ratio: 9 / 16; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) .embed-responsive > :is(iframe, video) { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) :is(.twitter-tweet, .instagram-media, .tiktok-embed) { margin-inline: auto !important; }   /* embeds set inline margins */

/* ---------- tables ----------
   App\Html wraps every table in <div class="table-wrap" role="region" tabindex="0" aria-label="Table: caption">: the
   table fills the text width, and a table wider than that scrolls inside the box (never the page); columns keep a
   readable minimum width instead of squeezing. */
:is(.prose, .dyn-article-body, .page-body, .rt-content) .table-wrap { max-width: 100%; overflow-x: auto; overscroll-behavior-x: contain; -webkit-overflow-scrolling: touch; margin-block: var(--ty-figure-space); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) .table-wrap:focus-visible { outline: 2px solid var(--ty-link); outline-offset: 2px; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) figure.table { display: block; max-width: 100%; overflow-x: auto; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) figure.table > .table-wrap { margin: 0; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) table {
  display: table; width: 100% !important; max-width: none; border-collapse: collapse; border-spacing: 0;
  font-family: var(--ty-font-ui); font-size: var(--ty-table); line-height: 1.45; font-variant-numeric: tabular-nums; color: var(--ty-ink);
}
:is(.prose, .dyn-article-body, .page-body, .rt-content) caption { caption-side: top; padding: 0 0 0.5em; text-align: left; font-size: var(--ty-caption); font-weight: var(--ty-w-ui); color: var(--ty-strong-ink); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) table tr :is(th, td) { min-width: 7em; padding: var(--ty-table-pad); border: 1px solid var(--ty-line); text-align: left; vertical-align: top; overflow-wrap: break-word; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) :is(th, td) :is(a, code) { overflow-wrap: anywhere; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) table thead th { border-bottom: 2px solid var(--ty-strong-ink); background: var(--ty-fill); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) th { font-weight: var(--ty-w-ui); color: var(--ty-strong-ink); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) tbody th[scope="row"] { background: color-mix(in srgb, var(--ty-fill) 55%, transparent); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) table tfoot :is(th, td) { border-top: 2px solid var(--ty-line-2); font-weight: var(--ty-w-ui); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) :is(td, th) > :first-child { margin-top: 0; }

/* ---------- details, sections, other semantic blocks ---------- */
:is(.prose, .dyn-article-body, .page-body, .rt-content) details { padding: 0.75em 1em; border: 1px solid var(--ty-line-2); }
:is(.prose, .dyn-article-body, .page-body, .rt-content) summary { display: list-item; font-family: var(--ty-font-ui); font-weight: var(--ty-w-ui); color: var(--ty-strong-ink); cursor: pointer; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) summary:focus-visible { outline: 2px solid var(--ty-link); outline-offset: 2px; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) details[open] > summary { margin-bottom: 0.5em; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) details > summary + * { margin-top: 0; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) :is(section, article, header, footer, nav) { display: block; min-width: 0; }
:is(.prose, .dyn-article-body, .page-body, .rt-content) aside { display: flow-root; padding: 1em 1.1em; border-left: 3px solid var(--ty-link); background: var(--ty-fill); font-size: 0.94em; }

/* forms and buttons placed in page text (contact page) keep the interface font */
:is(.prose, .dyn-article-body, .page-body, .rt-content) :is(button, input, select, textarea, .btn, .form) { font-family: var(--ty-font-ui); }

/* ---------- phones: a little less space, nothing wider than the screen ---------- */
@media (max-width: 575px) {
  :is(.prose, .dyn-article-body, .page-body, .rt-content) { --ty-head-before: 1.6em; --ty-figure-space: 1.3em; --ty-list-indent: 1.35em; --ty-quote-pad: 1rem; --ty-code-pad: 0.85em 0.9em; --ty-table-pad: 0.5em 0.6em; }
}

/* ---------- print ---------- */
@media print {
  :is(.prose, .dyn-article-body, .page-body) :is(pre, .table-wrap) { overflow: visible; white-space: pre-wrap; }
  :is(.prose, .dyn-article-body, .page-body) figure { break-inside: avoid; }
}
