/* Rich text content — applies to any WYSIWYG editor output */

.rich-text {
  width: min(100% - calc(var(--space-md) * 2), 62rem);
  margin-inline: auto;
}

/* Embedded media */

.rich-text img {
  max-width: 100%;
  height: auto;
  margin-block: var(--space-md);
}

/* --------------------------------------------------------------------------
   Pasted / editor content. Everything an editor can paste into a WYSIWYG field
   (Word, Google Docs, the WP editor) gets a theme-consistent look here, so
   nothing falls back to raw browser defaults. Inline typography styles are
   stripped server-side (inc/functions/richtext.php).
   -------------------------------------------------------------------------- */

/* Contain floated images and stop long pasted URLs / unbroken strings from
   pushing the column wider than the screen. */
.rich-text {
  display: flow-root;
  overflow-wrap: anywhere;
}

/* Nested lists: the inner list opens up a little and changes marker. */
.rich-text li > :is(ul, ol) {
  margin-top: var(--space-sm);
}

.rich-text ul ul {
  list-style-type: circle;
}

.rich-text ul ul ul {
  list-style-type: square;
}

/* Vertical rhythm for block elements, matching the sibling rules in typography.css */
.rich-text * + :is(table, figure, pre, dl) {
  margin-top: var(--space-md);
}

/* Tables: contained, scroll sideways on narrow screens rather than overflow. */
.rich-text table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: var(--font-sm);
}

.rich-text :is(th, td) {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--grey-20);
  text-align: left;
  vertical-align: top;
}

.rich-text th {
  background: var(--secondary-10);
  font-weight: 700;
}

/* Horizontal rule */
.rich-text hr {
  border: 0;
  border-top: 1px solid var(--grey-20);
  margin-block: var(--space-lg);
}

/* Figures + captions (also WP's classic .wp-caption) */
.rich-text figure,
.rich-text .wp-caption {
  max-width: 100%;
  margin-block: var(--space-md);
}

.rich-text figure img,
.rich-text .wp-caption img {
  margin-block: 0;
}

.rich-text :is(figcaption, .wp-caption-text) {
  margin-top: var(--space-xs);
  font-size: var(--font-sm);
  color: var(--grey-70);
}

/* Embeds: fill the column at 16:9 rather than the fixed pixel size they paste in with. */
.rich-text video {
  max-width: 100%;
  height: auto;
}

.rich-text iframe {
  max-width: 100%;
  border: 0;
}

.rich-text iframe:is([src*="youtube"], [src*="youtu.be"], [src*="vimeo"]) {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
}

/* Code */
.rich-text code {
  padding: 0.1em 0.35em;
  border-radius: var(--br-sm);
  background: var(--secondary-10);
}

.rich-text pre {
  padding: var(--space-md);
  border-radius: var(--br-md);
  background: var(--secondary-10);
  overflow-x: auto;
}

.rich-text pre code {
  padding: 0;
  background: none;
}

/* Definition lists */
.rich-text dt {
  font-weight: 700;
}

.rich-text dd {
  margin-left: var(--space-md);
}

.rich-text dd + dt {
  margin-top: var(--space-sm);
}

/* Inline extras */
.rich-text mark {
  padding: 0 0.15em;
  background: var(--primary-10);
  color: inherit;
}

.rich-text del {
  color: var(--grey-70);
}

.rich-text :is(sub, sup) {
  line-height: 0; /* don't let super/subscripts open up the line */
}

/* WordPress alignment classes (the editor adds these to images/figures). Centred
   everywhere; floated left/right only where there's room (tablet up). */
.rich-text .aligncenter {
  display: block;
  margin-inline: auto;
}

@media (min-width: 48rem) {
  .rich-text .alignleft {
    float: left;
    max-width: 50%;
    margin: 0 var(--space-md) var(--space-sm) 0;
  }

  .rich-text .alignright {
    float: right;
    max-width: 50%;
    margin: 0 0 var(--space-sm) var(--space-md);
  }
}

/* --------------------------------------------------------------------------
   Blog post blocks — the ACF `post_blocks` (inc/template-parts/post-blocks.php),
   rendered before the_content() inside .single-post-content.rich-text, so the
   rules above already space the figures and size the video iframe at 16:9.
   -------------------------------------------------------------------------- */

/* Image + video: rounded like the featured image (.single-post-img). */
:is(.post-block-image, .post-block-video) :is(img, iframe) {
  display: block;
  border-radius: var(--br-md);
}

/* Image: its own size up to the column width, centred. The caption is contained
   so a long one wraps under the image instead of widening the figure. */
.post-block-image {
  width: fit-content;
  margin-inline: auto;
}

.post-block-image figcaption {
  contain: inline-size;
}

/* Pull quote: more air than a plain figure, quote at the h4/h5 step. */
.rich-text .post-quote {
  margin-block: var(--space-lg);
}

.post-quote blockquote {
  font-family: var(--heading-font);
  font-size: var(--h4-h5-fs);
  line-height: var(--h4-h5-lh);
}

/* Who said it: avatar + name over business, lined up with the quote text
   (the blockquote's padding + 4px rule). */
.rich-text .post-quote__person {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-md);
  padding-left: calc(var(--space-md) + 4px);
  font-size: inherit;
  color: var(--text-color);
}

.post-quote__person :is(.avatar, .initials) {
  width: 3rem;
  height: 3rem;
  flex-shrink: 0;
  font-size: var(--font-sm);
}

.post-quote__who {
  display: flex;
  flex-direction: column;
}

.post-quote__name {
  font-weight: 700;
}

/* Profile link: the cue is the pink colour only, like the testimonial card name. */
.post-quote__person a.post-quote__name {
  color: inherit;
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease);
}

.post-quote__person a.post-quote__name:is(:hover, :focus-visible) {
  color: var(--primary-color);
}

/* The testimonial card's business label (small-uppercase purple). */
.post-quote__business {
  font-size: var(--font-sm);
  font-weight: 700;
  letter-spacing: var(--label-letter-spacing);
  text-transform: uppercase;
  color: var(--secondary-color);
}

/* Call to action: a lone button, or (with a heading/text) the Large CTA's pink
   panel — .large-cta__inner in sections.css. */
.rich-text .post-cta {
  margin-block: var(--space-lg);
}

.post-cta__heading {
  margin: 0;
  color: var(--primary-color);
}

/* Columns: stacked on phones, then 2–3 equal columns (--post-columns, set inline)
   from tablet, the standard two-column gap. Each column is its own run of blocks,
   so its first/last block drops the outer margin (figures, quotes, CTAs carry one). */
.rich-text .post-columns {
  display: grid;
  gap: var(--space-md-lg-d);
  margin-block: var(--space-lg);
}

.rich-text .post-columns__col > :first-child {
  margin-top: 0;
}

.rich-text .post-columns__col > :last-child {
  margin-bottom: 0;
}

@media (min-width: 48rem) {
  .rich-text .post-columns {
    grid-template-columns: repeat(var(--post-columns, 2), minmax(0, 1fr));
  }
}

/* Hive text (event description / agenda / notes, group introduction, member
   biography — wibn_clean_hive_html()). It sits in a card, under the page's own
   headings, so a heading typed in Hive's editor stays at the h4/h5 step whatever
   level it was (h1 arrives as h2) instead of growing to the page-title scale. */
.rich-text--hive :is(h1, h2, h3) {
  font-size: var(--h4-h5-fs);
  line-height: var(--h4-h5-lh);
  letter-spacing: normal;
  font-weight: 600;
}
