/*
 * Dark-mode contrast contract.
 * Loaded after legacy CSS. It separates two semantic roles that must never be
 * conflated: foreground ON an accent fill, and accent used AS text/ink.
 */

html[data-theme='dark'] {
  --aiwp-on-accent: #07111a;
  --aiwp-accent-ink: #79bcff;
  /* Legacy aliases are deliberately mapped to the contract. Existing theme JS
     writes these inline without !important; this late owner remains authoritative. */
  --sv-btn-text-on-primary: var(--aiwp-on-accent) !important;
  --smart-btn-text-on-primary: var(--aiwp-on-accent) !important;
  --sv-accent-ink: var(--aiwp-accent-ink) !important;
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme='light']) {
    --aiwp-on-accent: #07111a;
    --aiwp-accent-ink: #79bcff;
    --sv-btn-text-on-primary: var(--aiwp-on-accent) !important;
    --smart-btn-text-on-primary: var(--aiwp-on-accent) !important;
    --sv-accent-ink: var(--aiwp-accent-ink) !important;
  }
}

/* Filled accent controls. :is() intentionally carries the highest selector
   specificity in the list so this final owner beats historical !important rules. */
html[data-theme='dark'] body :is(
  .archive-hero__eyebrow,
  .page-hero__eyebrow,
  .hero-carousel__category,
  .entry-card__cta,
  .entry-card__link,
  .button--primary,
  .btn--primary,
  .btn-primary,
  .btn-ai,
  .btn-resume,
  .btn-linkedin,
  .btn-github,
  .wp-block-button:not(.is-style-outline) .wp-block-button__link,
  .wp-block-group a[href^='#'],
  .newsletter-cta,
  .newsletter-cta--mobile,
  .primary-nav .menu .menu-item--cta > a,
  .header-search-toggle[aria-expanded='true'],
  .theme-panel__option[aria-checked='true'],
  .pagination .page-numbers.current,
  .pagination a.prev:hover,
  .pagination a.next:hover,
  .archive-topics__see-all:hover,
  .aiwp-chat-launcher-visible,
  .orbchat-suggest-btn,
  .orbchat-send,
  .orbchat-website-action,
  .orbchat-articles-toggle
) {
  color: var(--aiwp-on-accent) !important;
  -webkit-text-fill-color: var(--aiwp-on-accent) !important;
}

html[data-theme='dark'] body :is(
  .archive-hero__eyebrow,
  .page-hero__eyebrow,
  .hero-carousel__category,
  .newsletter-cta,
  .newsletter-cta--mobile,
  .aiwp-chat-launcher-visible,
  .orbchat-send,
  .orbchat-website-action
) :is(svg, path, line, polyline, circle) {
  color: var(--aiwp-on-accent) !important;
  stroke: var(--aiwp-on-accent) !important;
}

/* Accent used as ink on dark surfaces. */
html[data-theme='dark'] body :is(
  a:not([class]),
  .link-inline,
  .archive-topics__eyebrow,
  .archive-topics__cta,
  .archive-feed__eyebrow,
  .entry-card__category,
  .post-card__category,
  .entry-card__badge,
  .post-card__read-time,
  .platform-rail__count,
  .article-count__value,
  .article-count__number,
  .orbchat-info-card__content a,
  .theme-panel-toggle[aria-expanded='true']
) {
  color: var(--aiwp-accent-ink) !important;
  -webkit-text-fill-color: var(--aiwp-accent-ink) !important;
}

/* Category/count chips use a subtle surface instead of a competing accent fill. */
html[data-theme='dark'] body :is(
  .entry-card__category,
  .post-card__category,
  .archive-topics__count,
  .entry-card__badge,
  .post-card__read-time,
  .platform-rail__count
) {
  background: color-mix(in srgb, var(--aiwp-accent-ink) 14%, transparent) !important;
  color: var(--aiwp-accent-ink) !important;
  -webkit-text-fill-color: var(--aiwp-accent-ink) !important;
  filter: none !important;
}

@supports not (background: color-mix(in srgb, white 50%, black)) {
  html[data-theme='dark'] body :is(
    .entry-card__category,
    .post-card__category,
    .archive-topics__count,
    .entry-card__badge,
    .post-card__read-time,
    .platform-rail__count
  ) {
    background: rgba(121, 188, 255, 0.14) !important;
  }
}

/* Outline controls remain outline controls until hover. */
html[data-theme='dark'] body :is(.button--outline, .btn-secondary, .wp-block-button.is-style-outline .wp-block-button__link) {
  background: transparent !important;
  border-color: var(--aiwp-accent-ink) !important;
  color: var(--aiwp-accent-ink) !important;
  -webkit-text-fill-color: var(--aiwp-accent-ink) !important;
}
html[data-theme='dark'] body :is(.button--outline, .btn-secondary, .wp-block-button.is-style-outline .wp-block-button__link):hover {
  background: var(--color-primary) !important;
  border-color: var(--color-primary) !important;
  color: var(--aiwp-on-accent) !important;
  -webkit-text-fill-color: var(--aiwp-on-accent) !important;
}

/* Text-sized theme-toggle UI must clear normal-text AA. */
html[data-theme='dark'] body .theme-toggle {
  color: #93c5fd !important;
  -webkit-text-fill-color: #93c5fd !important;
}

/* Explicit hooks for future components. */
html[data-theme='dark'] body [data-aiwp-color-role='on-accent'] {
  color: var(--aiwp-on-accent) !important;
  -webkit-text-fill-color: var(--aiwp-on-accent) !important;
}
html[data-theme='dark'] body [data-aiwp-color-role='accent-ink'] {
  color: var(--aiwp-accent-ink) !important;
  -webkit-text-fill-color: var(--aiwp-accent-ink) !important;
}


/* Deterministic late-control fix: these two families historically transition
   their text color after theme activation. Keep visual motion, but never
   interpolate the foreground through a sub-AA state. */
html[data-theme='dark'] body .footer-newsletter .footer-newsletter__input-group > button[type='submit'],
html[data-theme='dark'] body .contact-form-card .aiwp-contact-form__actions > button.button {
  color: var(--aiwp-on-accent) !important;
  -webkit-text-fill-color: var(--aiwp-on-accent) !important;
  transition-property: background-color, border-color, transform, box-shadow, opacity !important;
}
html[data-theme='dark'] body .footer-newsletter .footer-newsletter__input-group > button[type='submit'] *,
html[data-theme='dark'] body .contact-form-card .aiwp-contact-form__actions > button.button * {
  color: var(--aiwp-on-accent) !important;
  -webkit-text-fill-color: var(--aiwp-on-accent) !important;
  transition-property: none !important;
}
