/* ==========================================================================
   FTS: typography.css
   Purpose: Type scale, headings, body copy, and BB rich text defaults.
   ========================================================================== */

/* --- Type Scale --- */
/* NOTE: Use a small, stable scale. BB pages need consistency more than novelty. */
:root {
  /* Base */
  --fts-text-base: 1rem;      /* 16px */
  --fts-text-sm: 0.875rem;    /* 14px */
  --fts-text-lg: 1.125rem;    /* 18px */

  /* Headings */
  --fts-h1: 3.25rem;         /* 52px */
  --fts-h2: 2.25rem;           /* 40px */
  --fts-h3: 1.75rem;             /* 32px */
  --fts-h4: 1.5rem;           /* 24px */
  --fts-h5: 1.25rem;          /* 20px */
  --fts-h6: 1.125rem;         /* 18px */

  /* Line heights */
  --fts-leading-body: 1.6;
  --fts-leading-heading: 1.15;

}

/* --- Body Copy --- */
body {
  font-size: var(--fts-text-base);
  line-height: var(--fts-leading-body);
}

p {
  font-size: var(--fts-text-base);
  line-height: var(--fts-leading-body);
}

/* --- Lists --- */
.fl-rich-text :where(ul, ol) {
  padding-left: 1.25em;
}

.fl-rich-text :where(li) {
  line-height: var(--fts-leading-body);
}

/* --- Blockquote --- */
.fl-rich-text blockquote {
  margin-left: 0;
  margin-right: 0;
  border-color: var(--cream);
}

/* --- Headings --- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-serif);
  line-height: var(--fts-leading-heading);
  color: var(--midnight);
}

h1 { font-size: var(--fts-h1); font-weight: var(--weight-light); }
h2 { font-size: var(--fts-h2); font-weight: var(--weight-semibold); }
h3 { font-size: var(--fts-h3); font-weight: var(--weight-light); }
h4 { font-size: var(--fts-h4); font-weight: var(--weight-bold); }
h5 { font-size: var(--fts-h5); font-weight: var(--weight-regular); }
h6 { font-size: var(--fts-h6); font-weight: var(--weight-regular); }

/* --- Rich Text Module Defaults --- */
/* NOTE: BB rich text should feel like normal editorial content.
   We zero margins and then re-add spacing via the rhythm rules below.
   This prevents double-spacing from competing rules. */

.fl-rich-text :where(p, ul, ol, blockquote, pre, table, hr) {
  margin: 0;
}

.fl-rich-text :where(h1, h2, h3, h4, h5, h6) {
  margin: 0;
}

/* --- Small Text Helpers --- */
.fts-text-sm { font-size: var(--fts-text-sm); }
.fts-text-lg { font-size: var(--fts-text-lg); }

/* --- Responsive Adjustments --- */
/* NOTE: Match BB breakpoints. */
@media (max-width: 991.98px) {
  :root {
    --fts-h1: 2.75rem;  /* 44px */
    --fts-h2: 2.25rem;  /* 36px */
    --fts-h3: 1.875rem; /* 30px */
  }
}

@media (max-width: 767.98px) {
  :root {
    --fts-h1: 2.25rem;  /* 36px */
    --fts-h2: 1.875rem; /* 30px */
    --fts-h3: 1.5rem;   /* 24px */
  }
}

/* --- Rich Text Rhythm --- */
/* NOTE: Treat BB rich text like an editorial block with consistent spacing. */
.fl-rich-text {
  --fts-flow: 1rem;
  --fts-flow-tight: 0.5rem;
  --fts-flow-loose: 1.5rem;
}

/* Default spacing between common block elements */
.fl-rich-text :where(p, ul, ol, blockquote, pre, table, hr) + :where(p, ul, ol, blockquote, pre, table, hr) {
  margin-top: var(--fts-flow);
}

.fl-rich-text :where(h1, h2, h3, h4, h5, h6) + :where(p, ul, ol) {
  margin-top: var(--fts-flow-tight);
}

.fl-rich-text :where(p, ul, ol, blockquote, pre, table, hr) + :where(h1, h2, h3, h4, h5, h6) {
  margin-top: var(--fts-flow-loose);
}

/* NOTE: Text rhythm should never be affected by background fills */
.fl-rich-text :where(
  p,
  span,
  strong,
  em,
  b,
  i,
  u,
  small,
  code,
  mark
) {
  background: transparent !important;
}

/* NOTE: Ensure inline elements do not disrupt line rhythm */
.fl-rich-text :where(strong, em, b, i, u, small, code) {
  line-height: inherit;
}

/* NOTE: Prevent editor-injected background highlights from affecting layout */
.fl-rich-text * {
  background-clip: padding-box;
}