/* Document typography for rich-text content.
 *
 * Shared by the admin editor surface (what you see while writing) and the
 * public policy page (what visitors read), so both render a document the same
 * way. Every value comes from the design tokens, so the content follows
 * whichever theme the page uses. A page can tune the document through the
 * --rc-* properties instead of overriding individual rules.
 *
 * Only the tags and alignment classes the sanitizer allows are styled here
 * (services/rich_text.py): h2-h4, p, lists, blockquote, hr, links, tables and
 * the inline formats.
 */

.rich-content {
  --rc-font-size: var(--font-size-md);
  --rc-line-height: 1.75;
  --rc-text: var(--color-text);
  --rc-heading: var(--color-text);
  --rc-muted: var(--color-text-muted);
  --rc-accent: var(--color-brand);
  --rc-link: var(--color-primary);
  --rc-line: var(--color-border);
  --rc-line-strong: var(--color-border-strong);
  --rc-tint: var(--color-surface-muted);
  --rc-block-gap: 1em;

  color: var(--rc-text);
  font-size: var(--rc-font-size);
  line-height: var(--rc-line-height);
  overflow-wrap: break-word;
}

.rich-content > :first-child {
  margin-top: 0;
}

.rich-content > :last-child {
  margin-bottom: 0;
}

/* --------------------------------------------------------------- Blocks */

.rich-content p {
  margin: 0 0 var(--rc-block-gap);
}

.rich-content h2,
.rich-content h3,
.rich-content h4 {
  color: var(--rc-heading);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  letter-spacing: -0.015em;
  text-wrap: balance;
  scroll-margin-top: calc(var(--header-height) + var(--space-lg));
}

.rich-content h2 {
  margin: 2em 0 0.65em;
  font-size: 1.5em;
}

.rich-content h3 {
  margin: 1.6em 0 0.5em;
  font-size: 1.22em;
}

.rich-content h4 {
  margin: 1.4em 0 0.4em;
  font-size: 1.05em;
  font-weight: var(--font-weight-semibold);
}

.rich-content ul,
.rich-content ol {
  margin: 0 0 var(--rc-block-gap);
  padding-inline-start: 1.6em;
}

.rich-content li {
  padding-inline-start: 0.25em;
}

.rich-content li + li,
.rich-content li > ul,
.rich-content li > ol,
.rich-content ul > ul,
.rich-content ol > ol {
  margin-top: 0.4em;
}

.rich-content li > ul,
.rich-content li > ol,
.rich-content ul > ul,
.rich-content ol > ol {
  margin-bottom: 0;
}

.rich-content li::marker {
  color: var(--rc-muted);
}

.rich-content ol > li::marker {
  font-variant-numeric: tabular-nums;
}

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

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

.rich-content ol ol {
  list-style-type: lower-alpha;
}

.rich-content ol ol ol {
  list-style-type: lower-roman;
}

.rich-content blockquote {
  margin: 1.4em 0;
  padding: 0.85em 1.25em;
  border-inline-start: 3px solid var(--rc-accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  background-color: var(--rc-tint);
  color: var(--rc-muted);
}

.rich-content blockquote p:last-child {
  margin-bottom: 0;
}

.rich-content hr {
  height: 1px;
  margin: 2.25em 0;
  border: 0;
  background-color: var(--rc-line-strong);
}

/* --------------------------------------------------------------- Inline */

.rich-content a {
  color: var(--rc-link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

.rich-content a:hover {
  text-decoration-thickness: 2px;
}

.rich-content strong,
.rich-content b {
  font-weight: var(--font-weight-bold);
}

.rich-content sub,
.rich-content sup {
  font-size: 0.75em;
  line-height: 0;
}

/* ---------------------------------------------------------------- Tables */

.rich-content table {
  width: 100%;
  margin: 1.4em 0;
  border-collapse: collapse;
  font-size: 0.94em;
  line-height: var(--line-height-normal);
  font-variant-numeric: lining-nums tabular-nums;
}

.rich-content th,
.rich-content td {
  min-width: 5em;
  padding: 0.6em 0.85em;
  border: 1px solid var(--rc-line-strong);
  text-align: start;
  vertical-align: top;
}

.rich-content th {
  background-color: var(--rc-tint);
  color: var(--rc-heading);
  font-weight: var(--font-weight-semibold);
}

.rich-content td p:last-child,
.rich-content th p:last-child {
  margin-bottom: 0;
}

/* Wide tables scroll inside their own box on narrow screens (the public page
   wraps each table in this element). */
.rich-content .rc-table-scroll {
  margin: 1.4em 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-sm);
}

.rich-content .rc-table-scroll > table {
  margin: 0;
}

.rich-content .rc-table-scroll:focus-visible {
  outline-offset: 4px;
}

/* ------------------------------------------------------------ Alignment */

.rich-content .rc-align-left {
  text-align: left;
}

.rich-content .rc-align-center {
  text-align: center;
}

.rich-content .rc-align-right {
  text-align: right;
}

.rich-content .rc-align-justify {
  text-align: justify;
  hyphens: auto;
}
