/*
 * Global typography mode overlays.
 *
 * The generated token files remain the source of truth for Luna primitives and
 * semantic type styles. This layer only remaps semantic typography roles for
 * the selected, independently configurable typography mode.
 */

body {
  --luna-typography-heading-emphasis-color: var(--luna-color-text-primary);
  --luna-typography-heading-emphasis-font-style: var(
    --luna-typography-heading-heading-1-italics-font-style
  );
  --luna-typography-heading-emphasis-font-weight: var(
    --luna-typography-heading-heading-1-italics-font-weight
  );
}

body
  :where(
    [data-luna-color-context='default'],
    [data-background-theme='light'],
    [data-theme-mode='light'],
    [data-dark-mode='false'],
    [data-theme='light'],
    [data-form-theme='light']
  ) {
  --luna-typography-heading-emphasis-color: var(--luna-color-text-primary);
}

body
  :where(
    [data-luna-color-context='inverse'],
    [data-background-theme='dark'],
    [data-theme-mode='dark'],
    [data-dark-mode='true'],
    [data-theme='dark'],
    [data-form-theme='dark']
  ) {
  --luna-typography-heading-emphasis-color: var(
    --luna-color-context-inverse-text-primary
  );
}

body[data-luna-typography-theme='medium-subtle-emphasis'] {
  --luna-typography-theme-heading-letter-spacing: -0.02em;
  --luna-typography-heading-fallback-font-weight: var(
    --luna-primitive-font-weight-700
  );
  --luna-typography-label-label-0-font-family: var(
    --luna-primitive-font-family-heading
  );
  --luna-typography-label-label-1-font-family: var(
    --luna-primitive-font-family-heading
  );
  --luna-typography-label-label-2-font-family: var(
    --luna-primitive-font-family-heading
  );
  --luna-typography-label-label-3-font-family: var(
    --luna-primitive-font-family-heading
  );
  --luna-typography-label-label-4-font-family: var(
    --luna-primitive-font-family-heading
  );
  --luna-typography-display-display-4xl-font-family: var(
    --luna-primitive-font-family-heading
  );
  --luna-typography-display-display-4xl-font-weight: var(
    --luna-primitive-font-weight-700
  );
  --luna-typography-display-display-3xl-font-family: var(
    --luna-primitive-font-family-heading
  );
  --luna-typography-display-display-3xl-font-weight: var(
    --luna-primitive-font-weight-700
  );
  --luna-typography-display-display-2xl-font-family: var(
    --luna-primitive-font-family-heading
  );
  --luna-typography-display-display-2xl-font-weight: var(
    --luna-primitive-font-weight-700
  );
  --luna-typography-display-display-xl-font-family: var(
    --luna-primitive-font-family-heading
  );
  --luna-typography-display-display-xl-font-weight: var(
    --luna-primitive-font-weight-700
  );
  --luna-typography-display-display-lg-font-family: var(
    --luna-primitive-font-family-heading
  );
  --luna-typography-display-display-lg-font-weight: var(
    --luna-primitive-font-weight-700
  );
  --luna-typography-display-display-md-font-family: var(
    --luna-primitive-font-family-heading
  );
  --luna-typography-display-display-md-font-weight: var(
    --luna-primitive-font-weight-700
  );
  --luna-typography-display-display-sm-font-family: var(
    --luna-primitive-font-family-heading
  );
  --luna-typography-display-display-sm-font-weight: var(
    --luna-primitive-font-weight-700
  );
  --luna-typography-heading-heading-1-font-family: var(
    --luna-primitive-font-family-heading
  );
  --luna-typography-heading-heading-1-font-weight: var(
    --luna-primitive-font-weight-700
  );
  --luna-typography-heading-heading-1-letter-spacing: var(
    --luna-typography-theme-heading-letter-spacing
  );
  --luna-typography-heading-heading-2-font-family: var(
    --luna-primitive-font-family-heading
  );
  --luna-typography-heading-heading-2-font-weight: var(
    --luna-primitive-font-weight-700
  );
  --luna-typography-heading-heading-2-letter-spacing: var(
    --luna-typography-theme-heading-letter-spacing
  );
  --luna-typography-heading-heading-3-font-family: var(
    --luna-primitive-font-family-heading
  );
  --luna-typography-heading-heading-3-font-weight: var(
    --luna-primitive-font-weight-700
  );
  --luna-typography-heading-heading-3-letter-spacing: var(
    --luna-typography-theme-heading-letter-spacing
  );
  --luna-typography-heading-heading-4-font-family: var(
    --luna-primitive-font-family-heading
  );
  --luna-typography-heading-heading-4-font-weight: var(
    --luna-primitive-font-weight-700
  );
  --luna-typography-heading-heading-4-letter-spacing: var(
    --luna-typography-theme-heading-letter-spacing
  );
  --luna-typography-heading-heading-5-font-family: var(
    --luna-primitive-font-family-heading
  );
  --luna-typography-heading-heading-5-font-weight: var(
    --luna-primitive-font-weight-700
  );
  --luna-typography-heading-heading-5-letter-spacing: var(
    --luna-typography-theme-heading-letter-spacing
  );
  --luna-typography-heading-heading-6-font-family: var(
    --luna-primitive-font-family-heading
  );
  --luna-typography-heading-heading-6-font-weight: var(
    --luna-primitive-font-weight-700
  );
  --luna-typography-heading-heading-6-letter-spacing: var(
    --luna-typography-theme-heading-letter-spacing
  );
  --luna-typography-heading-heading-7-font-family: var(
    --luna-primitive-font-family-heading
  );
  --luna-typography-heading-heading-7-font-weight: var(
    --luna-primitive-font-weight-700
  );
  --luna-typography-heading-heading-7-letter-spacing: var(
    --luna-typography-theme-heading-letter-spacing
  );
  --luna-typography-heading-heading-8-font-family: var(
    --luna-primitive-font-family-heading
  );
  --luna-typography-heading-heading-8-font-weight: var(
    --luna-primitive-font-weight-700
  );
  --luna-typography-heading-heading-8-letter-spacing: var(
    --luna-typography-theme-heading-letter-spacing
  );
  --luna-typography-heading-heading-1-italics-font-family: var(
    --luna-primitive-font-family-heading
  );
  --luna-typography-heading-heading-1-italics-font-style: var(
    --luna-primitive-font-style-normal
  );
  --luna-typography-heading-heading-1-italics-font-weight: var(
    --luna-primitive-font-weight-700
  );
  --luna-typography-heading-heading-1-italics-letter-spacing: var(
    --luna-typography-theme-heading-letter-spacing
  );
  --luna-typography-heading-heading-2-italics-font-family: var(
    --luna-primitive-font-family-heading
  );
  --luna-typography-heading-heading-2-italics-font-style: var(
    --luna-primitive-font-style-normal
  );
  --luna-typography-heading-heading-2-italics-font-weight: var(
    --luna-primitive-font-weight-700
  );
  --luna-typography-heading-heading-2-italics-letter-spacing: var(
    --luna-typography-theme-heading-letter-spacing
  );
  --luna-typography-heading-heading-3-italics-font-family: var(
    --luna-primitive-font-family-heading
  );
  --luna-typography-heading-heading-3-italics-font-style: var(
    --luna-primitive-font-style-normal
  );
  --luna-typography-heading-heading-3-italics-font-weight: var(
    --luna-primitive-font-weight-700
  );
  --luna-typography-heading-heading-3-italics-letter-spacing: var(
    --luna-typography-theme-heading-letter-spacing
  );
  --luna-typography-heading-heading-4-italics-font-family: var(
    --luna-primitive-font-family-heading
  );
  --luna-typography-heading-heading-4-italics-font-style: var(
    --luna-primitive-font-style-normal
  );
  --luna-typography-heading-heading-4-italics-font-weight: var(
    --luna-primitive-font-weight-700
  );
  --luna-typography-heading-heading-4-italics-letter-spacing: var(
    --luna-typography-theme-heading-letter-spacing
  );
  --luna-typography-heading-heading-5-italics-font-family: var(
    --luna-primitive-font-family-heading
  );
  --luna-typography-heading-heading-5-italics-font-style: var(
    --luna-primitive-font-style-normal
  );
  --luna-typography-heading-heading-5-italics-font-weight: var(
    --luna-primitive-font-weight-700
  );
  --luna-typography-heading-heading-5-italics-letter-spacing: var(
    --luna-typography-theme-heading-letter-spacing
  );
  --luna-typography-heading-heading-6-italics-font-family: var(
    --luna-primitive-font-family-heading
  );
  --luna-typography-heading-heading-6-italics-font-style: var(
    --luna-primitive-font-style-normal
  );
  --luna-typography-heading-heading-6-italics-font-weight: var(
    --luna-primitive-font-weight-700
  );
  --luna-typography-heading-heading-6-italics-letter-spacing: var(
    --luna-typography-theme-heading-letter-spacing
  );
  --luna-typography-heading-heading-7-italics-font-family: var(
    --luna-primitive-font-family-heading
  );
  --luna-typography-heading-heading-7-italics-font-style: var(
    --luna-primitive-font-style-normal
  );
  --luna-typography-heading-heading-7-italics-font-weight: var(
    --luna-primitive-font-weight-700
  );
  --luna-typography-heading-heading-7-italics-letter-spacing: var(
    --luna-typography-theme-heading-letter-spacing
  );
  --luna-typography-heading-heading-8-italics-letter-spacing: var(
    --luna-typography-theme-heading-letter-spacing
  );
  --luna-typography-editorial-blog-header-font-family: var(
    --luna-primitive-font-family-heading
  );
  --luna-typography-editorial-blog-header-font-weight: var(
    --luna-primitive-font-weight-700
  );
  --luna-typography-heading-emphasis-color: var(
    --luna-color-text-heading-emphasis-subtle
  );
  --luna-typography-heading-emphasis-font-style: var(
    --luna-primitive-font-style-normal
  );
  --luna-typography-heading-emphasis-font-weight: var(
    --luna-primitive-font-weight-700
  );
}

body[data-luna-typography-theme='medium-subtle-emphasis']
  :where(
    [data-luna-color-context='default'],
    [data-background-theme='light'],
    [data-theme-mode='light'],
    [data-dark-mode='false'],
    [data-theme='light'],
    [data-form-theme='light']
  ) {
  --luna-typography-heading-emphasis-color: var(
    --luna-color-text-heading-emphasis-subtle
  );
}

body[data-luna-typography-theme='medium-subtle-emphasis']
  :where(
    [data-luna-color-context='inverse'],
    [data-background-theme='dark'],
    [data-theme-mode='dark'],
    [data-dark-mode='true'],
    [data-theme='dark'],
    [data-form-theme='dark']
  ) {
  --luna-typography-heading-emphasis-color: var(
    --luna-color-context-inverse-text-heading-emphasis-subtle
  );
}

/*
 * HubSpot rich text and legacy template content can emit semantic headings
 * without a Luna component class. Keep this deliberately narrow fallback
 * scoped to em/i descendants of headings so body, quote, caption, and other
 * non-heading italics retain their existing typography.
 */
body[data-luna-typography-theme='medium-subtle-emphasis']
  :is(h1, h2, h3, h4, h5, h6)
  :is(em, i) {
  color: var(--luna-typography-heading-emphasis-color);
  font-style: var(--luna-typography-heading-emphasis-font-style);
  font-weight: var(--luna-typography-heading-emphasis-font-weight);
}
