/* Editorial text hierarchy shared by all page templates.
 * Keep these tokens separate from the older palette variables: those also
 * control backgrounds. Product illustrations retain their own UI colors.
 */
:is(#main, #primary, .boss-bottom-demo) {
  --aq-content-color: #000;
  --aq-secondary-color: #667780;
  color: var(--aq-content-color);
}

/* Inverse sections need light text, including their secondary copy. */
:is(#main, #primary, .boss-bottom-demo) :is(
  .boss-ai-section, .boss-agent-section, .ind-agent, .boss-use-case .ind-final,
  .pm-ai-section, .pm-migration-banner, .ap-pricing .boss-plan-pro,
  .ap-pricing .ap-calculator, .in-contact-layout aside,
  .guide-card.featured, .guide-cta, .cmp-bottom-card, .sw-offer-card, .comms-cta,
  .cmp-showcase, .bcg-chart-header, .bg-dark, .bg-primary,
  .text-bg-dark, .text-bg-primary,
  .boss-feature-card:is(:hover, :focus-within) .boss-feature-copy,
  .in-related > a:hover
) {
  --aq-content-color: #fff;
  --aq-secondary-color: #c4d3da;
}

/* Light surfaces nested inside inverse sections. */
:is(#main, #primary, .boss-bottom-demo) :is(
  .boss-agent-chat, .boss-agent-result, .boss-agent-workspace,
  .boss-conversation, .ind-agent-scene, .ind-agent-chat,
  .pm-conversation, .bg-white, .bg-light
) {
  --aq-content-color: #000;
  --aq-secondary-color: #667780;
}

/* Override template-level paragraph colors, including their !important rules.
 * Do not recolor product mockups, controls, code, or semantic status messages.
 */
:is(#main, #primary, .boss-bottom-demo) :is(
  h1, h2, h3, h4, h5, h6, p, li, blockquote, dt, dd, td, th, summary
):not(:where(
  [data-nosnippet], [data-nosnippet] *,
  .mo-preview *, .pm-preview *, .pd-map *, .pd-locator *,
  .aqtos-preview *, .boss-hero-screen *, .boss-company-stream *,
  .boss-feed-scene *, .boss-context-board *, .fw-showcase *,
  button *, [role="button"] *, .btn *, pre *, code *,
  [role="alert"], [role="alert"] *, [role="status"], [role="status"] *,
  .is-error, .is-error *, .is-success, .is-success *, .is-saving *,
  .text-danger, .text-success, .text-white, .text-light,
  .mcp-error, .mcp-copy-fallback, .tour-form-status,
  .wpcf7-response-output, .wpcf7-not-valid-tip
)) {
  color: var(--aq-content-color) !important;
}

/* Headline accents and emphasized body text follow the same hierarchy.
 * Ordinary inline links and button colors keep their existing affordances.
 */
:is(#main, #primary, .boss-bottom-demo) :is(h1, h2, h3, h4, h5, h6) :is(span, em, strong, a) {
  color: inherit;
}
:is(#main, #primary, .boss-bottom-demo) :is(p, li, blockquote, dd) :is(strong, b):not(:where(
  [data-nosnippet] *, .mo-preview *, .pm-preview *, .pd-map *,
  .pd-locator *, .aqtos-preview *, .boss-feature-visual *, .boss-hero-screen *,
  .boss-company-stream *, .boss-feed-scene *, .boss-context-board *,
  .fw-showcase *, button *, [role="button"] *, .btn *,
  [role="alert"] *, [role="status"] *, .is-error *, .is-success *)) {
  color: inherit !important;
}

/* Captions, metadata, helper copy and small labels remain secondary.
 * Changing the token also covers nested paragraphs/list items in these groups.
 */
:is(#main, #primary, .boss-bottom-demo) :is(
  figcaption, caption, small, time, .text-muted,
  [class$="-eyebrow"], [class*="-eyebrow "], [class$="-kicker"],
  .boss-brand-definition, .boss-caption, .boss-small,
  .boss-price-note, .boss-price > span, .boss-tools-label, .boss-proof-strip > p,
  .boss-record-meta, .boss-comparison-head, .boss-mini-note,
  .boss-feature-caption, .boss-story-credit p span,
  .boss-demo-caption p, .boss-demo-controls > p,
  .boss-context-caption, .boss-ai-balance-note,
  .boss-ai-example-controls > span, .boss-ai-static-note,
  .boss-switch-help, .boss-offer-billing, .boss-offer-terms,
  .boss-workday-note, .boss-workday-toolbar > p,
  .boss-plan-note, .boss-plan-price > span, .boss-plan-billing,
  .boss-plan-comparison, .boss-plans-assurances,
  .boss-agent-example-meta, .boss-agent-created > p,
  .boss-agent-handoff-note, .boss-integration-directory-note,
  .boss-newsletter-submit > span,
  .in-page-nav, .in-archive-copy time, .in-archive-copy > span,
  .in-article-meta, .in-quiet-link, .guide-note, .guide-sources p,
  .cmp-note, .cmp-price-amount > span, .cmp-table th > span,
  .wf-breadcrumbs, .wf-pricing-note, .pm-preview-caption,
  .pm-example-note, .pm-proof span,
  .pd-reference-toolbar > p, .pd-map-caption, .pd-access-note,
  .pd-content-footer p, .pd-feature-path, .pd-nav-count,
  .mcp-caption, .mcp-url-builder > p:not(.mcp-error, .mcp-copy-fallback),
  .mcp-section-heading > p, .mcp-agent-name span,
  .mcp-plugin-status-list dt, .mcp-article-footer p,
  .mcp-reference, .mcp-facts,
  .aq-contact-note, .aq-contact-footnote, .aq-contact-form-hint, .aq-cost-note,
  .aqtos-blog-hub__card-meta, .aqtos-blog-hub__card-cat,
  .aqtos-blog-hub__tl-left, .dm-footnote, .dm-privacy
):not(:where([data-nosnippet] *, .mo-preview *, .pm-preview *, .pd-map *)) {
  --aq-content-color: var(--aq-secondary-color);
  color: var(--aq-content-color) !important;
}

/* Preserve system contrast preferences. */
@media (forced-colors: active) {
  :is(#main, #primary, .boss-bottom-demo),
  :is(#main, #primary, .boss-bottom-demo) * {
    --aq-content-color: CanvasText;
    --aq-secondary-color: CanvasText;
  }
}
