/* ==========================================================================
   AbstractRealmss — Dark & light theme tokens
   ========================================================================== */

:root,
html[data-arss-theme="light"] {
  color-scheme: light;

  /* Stitch light palette */
  --arss-surface: #f5f4f0;
  --arss-on-surface: #0a1a3f;
  --arss-on-surface-variant: #5c6577;
  --arss-primary: #0a1a3f;
  --arss-primary-container: #e8e6e0;
  --arss-secondary: #5c6577;
  --arss-outline: #5c6577;
  --arss-outline-variant: #d1d5db;
  --arss-surface-container-lowest: #f5f4f0;
  --arss-surface-container-low: #e8e6e0;
  --arss-surface-container: #e8e6e0;
  --arss-tertiary: #5c6577;
  --arss-mist: #5c6577;

  /* Legacy tokens */
  --arss-midnight: #0a1a3f;
  --arss-silver: #c8cdd6;
  --arss-ether: #f5f4f0;
  --arss-night: #06112b;
  --arss-twilight: #e8e6e0;
  --arss-line: rgba(10, 26, 63, 0.12);
  --arss-muted: #5c6577;
  --arss-body: #5c6577;
  --arss-paper: #e8e6e0;
  --arss-azure: #2e5aa8;
  --arss-aqua: #5fa6c4;

  /* Semantic surfaces */
  --arss-header-bg: rgba(245, 244, 240, 0.92);
  --arss-overlay-bg: rgba(245, 244, 240, 0.98);
  --arss-border-subtle: rgba(10, 26, 63, 0.1);
  --arss-border: rgba(10, 26, 63, 0.14);
  --arss-border-strong: rgba(10, 26, 63, 0.2);
  --arss-border-hover: rgba(10, 26, 63, 0.28);
  --arss-hover-surface: rgba(10, 26, 63, 0.05);
  --arss-hover-surface-strong: rgba(10, 26, 63, 0.08);
  --arss-accent-surface: rgba(10, 26, 63, 0.06);
  --arss-noise-opacity: 0;
  --arss-shadow: 0 24px 64px rgba(10, 26, 63, 0.08);

  /* Header & band surfaces */
  --arss-header-fg: #0a1a3f;
  --arss-header-fg-hover: #2e5aa8;
  --arss-band-bg: #0a1a3f;
  --arss-band-fg: #f5f4f0;
  --arss-band-fg-muted: #c8cdd6;
  --arss-btn-emphasis-bg: #0a1a3f;
  --arss-btn-emphasis-fg: #f5f4f0;
  --arss-btn-emphasis-border: #0a1a3f;
  --arss-btn-outline-fg: #0a1a3f;
  --arss-btn-outline-border: #5c6577;
  --arss-btn-outline-hover-bg: rgba(10, 26, 63, 0.08);
  --arss-band-btn-fg: #f5f4f0;
  --arss-band-btn-border: rgba(200, 205, 214, 0.55);
  --arss-realm-card-bg: #f5f4f0;
  --arss-realm-card-fg: #0a1a3f;
  --arss-realm-card-fg-muted: #5c6577;
  --arss-realm-card-num: #5c6577;
  --arss-realm-card-border: rgba(10, 26, 63, 0.14);
  --arss-realm-card-btn-fg: #0a1a3f;
  --arss-realm-card-btn-border: rgba(10, 26, 63, 0.28);
  --arss-realm-card-btn-hover-bg: rgba(10, 26, 63, 0.06);
}

html[data-arss-theme="dark"] {
  color-scheme: dark;

  /* Stitch palette */
  --arss-surface: #121412;
  --arss-on-surface: #e3e2df;
  --arss-on-surface-variant: #c5c6cf;
  --arss-primary: #b7c5f4;
  --arss-primary-container: #0a1a3f;
  --arss-secondary: #c2c7d0;
  --arss-outline: #8f9099;
  --arss-outline-variant: #45464e;
  --arss-surface-container-lowest: #0d0f0d;
  --arss-surface-container-low: #1b1c1a;
  --arss-surface-container: #1f201e;
  --arss-tertiary: #bcc6e8;
  --arss-mist: #5c6577;

  /* Legacy tokens */
  --arss-midnight: #0a1a3f;
  --arss-silver: #c2c7d0;
  --arss-ether: #e3e2df;
  --arss-night: #0d0f0d;
  --arss-twilight: #1b1c1a;
  --arss-line: rgba(69, 70, 78, 0.45);
  --arss-muted: #8f9099;
  --arss-body: #c5c6cf;
  --arss-paper: #1b1c1a;
  --arss-azure: #b7c5f4;
  --arss-aqua: #bcc6e8;

  /* Semantic surfaces */
  --arss-header-bg: rgba(10, 26, 63, 0.92);
  --arss-overlay-bg: rgba(13, 15, 13, 0.98);
  --arss-border-subtle: rgba(69, 70, 78, 0.25);
  --arss-border: rgba(69, 70, 78, 0.35);
  --arss-border-strong: rgba(69, 70, 78, 0.45);
  --arss-border-hover: rgba(194, 199, 208, 0.45);
  --arss-hover-surface: rgba(194, 199, 208, 0.08);
  --arss-hover-surface-strong: rgba(194, 199, 208, 0.1);
  --arss-accent-surface: rgba(183, 197, 244, 0.08);
  --arss-noise-opacity: 0;
  --arss-shadow: 0 24px 64px rgba(6, 17, 43, 0.12);

  /* Header & band surfaces */
  --arss-header-fg: #c5c6cf;
  --arss-header-fg-hover: #b7c5f4;
  --arss-band-bg: #0a1a3f;
  --arss-band-fg: #e3e2df;
  --arss-band-fg-muted: #8f9099;
  --arss-btn-emphasis-bg: #e3e2df;
  --arss-btn-emphasis-fg: #0a1a3f;
  --arss-btn-emphasis-border: #c2c7d0;
  --arss-btn-outline-fg: #b7c5f4;
  --arss-btn-outline-border: #c2c7d0;
  --arss-btn-outline-hover-bg: rgba(194, 199, 208, 0.1);
  --arss-band-btn-fg: #e3e2df;
  --arss-band-btn-border: rgba(143, 144, 153, 0.65);
  --arss-realm-card-bg: #e8e6e0;
  --arss-realm-card-fg: #0a1a3f;
  --arss-realm-card-fg-muted: #5c6577;
  --arss-realm-card-num: #5c6577;
  --arss-realm-card-border: rgba(10, 26, 63, 0.16);
  --arss-realm-card-btn-fg: #0a1a3f;
  --arss-realm-card-btn-border: rgba(10, 26, 63, 0.28);
  --arss-realm-card-btn-hover-bg: rgba(10, 26, 63, 0.06);
}

/* --- Theme toggle --- */
.arss-theme-toggle {
  position: relative;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  font: inherit;
}

.arss-theme-toggle__icon {
  display: block;
}

.arss-theme-toggle__icon--moon {
  display: none;
}

html[data-arss-theme="light"] .arss-theme-toggle__icon--sun {
  display: none;
}

html[data-arss-theme="light"] .arss-theme-toggle__icon--moon {
  display: block;
}

/* ==========================================================================
   Contrast repairs — neutralize legacy public/spec rules per theme
   ========================================================================== */

body.arss-branded {
  background: var(--arss-surface) !important;
  color: var(--arss-on-surface-variant) !important;
}

body.arss-branded .arss-header__bar {
  background: var(--arss-header-bg) !important;
  border-color: var(--arss-border) !important;
  box-shadow: none !important;
}

body.arss-branded .arss-header .arss-brand__name,
body.arss-branded .arss-header .arss-nav__list a,
body.arss-branded .arss-header .arss-nav__realms-btn,
body.arss-branded .arss-header .arss-tool,
body.arss-branded .arss-header .arss-theme-toggle,
body.arss-branded .arss-header .arss-menu-btn {
  color: var(--arss-header-fg) !important;
}

body.arss-branded .arss-header .arss-nav__list a:hover,
body.arss-branded .arss-header .arss-nav__list a.is-active,
body.arss-branded .arss-header .arss-nav__realms-btn:hover,
body.arss-branded .arss-header .arss-nav__realms-btn[aria-expanded="true"],
body.arss-branded .arss-header .arss-tool:hover,
body.arss-branded .arss-header .arss-theme-toggle:hover {
  color: var(--arss-header-fg-hover) !important;
}

body.arss-branded .arss-section--midnight,
body.arss-branded .arss-video.arss-section--midnight {
  background: var(--arss-band-bg) !important;
  color: var(--arss-band-fg-muted) !important;
}

body.arss-branded .arss-section--midnight .arss-h2,
body.arss-branded .arss-section--midnight .arss-h2--light,
body.arss-branded .arss-video.arss-section--midnight .arss-h2,
body.arss-branded .arss-video.arss-section--midnight .arss-h2--light {
  color: var(--arss-band-fg) !important;
}

body.arss-branded .arss-section--midnight .arss-kicker,
body.arss-branded .arss-section--midnight .arss-kicker--light,
body.arss-branded .arss-video.arss-section--midnight .arss-kicker,
body.arss-branded .arss-video.arss-section--midnight .arss-kicker--light {
  color: var(--arss-band-fg-muted) !important;
}

body.arss-branded .arss-section--midnight .arss-section__lead,
body.arss-branded .arss-section--midnight .arss-section__lead--light,
body.arss-branded .arss-video.arss-section--midnight .arss-section__lead,
body.arss-branded .arss-video.arss-section--midnight .arss-section__lead--light {
  color: var(--arss-band-fg-muted) !important;
}

body.arss-branded .arss-section--midnight .arss-realm-card--dark,
body.arss-branded .arss-realm-card--dark {
  background: var(--arss-realm-card-bg) !important;
  border-color: var(--arss-realm-card-border) !important;
}

body.arss-branded .arss-section--midnight .arss-realm-card--dark .arss-realm-card__title,
body.arss-branded .arss-realm-card--dark .arss-realm-card__title {
  color: var(--arss-realm-card-fg) !important;
}

body.arss-branded .arss-section--midnight .arss-realm-card--dark .arss-realm-card__text,
body.arss-branded .arss-realm-card--dark .arss-realm-card__text {
  color: var(--arss-realm-card-fg-muted) !important;
}

body.arss-branded .arss-section--midnight .arss-realm-card--dark .arss-realm-card__num,
body.arss-branded .arss-realm-card--dark .arss-realm-card__num {
  color: var(--arss-realm-card-num) !important;
}

body.arss-branded .arss-section--midnight .arss-realm-card--dark .arss-realm-card__link,
body.arss-branded .arss-realm-card--dark .arss-realm-card__link {
  color: var(--arss-realm-card-btn-fg) !important;
  border-color: var(--arss-realm-card-btn-border) !important;
}

body.arss-branded .arss-section--midnight .arss-realm-card--dark:hover .arss-realm-card__link,
body.arss-branded .arss-realm-card--dark:hover .arss-realm-card__link {
  background: var(--arss-realm-card-btn-hover-bg) !important;
  color: var(--arss-realm-card-btn-fg) !important;
  border-color: var(--arss-realm-card-btn-fg) !important;
}

body.arss-branded .arss-btn--light {
  background: var(--arss-btn-emphasis-bg) !important;
  color: var(--arss-btn-emphasis-fg) !important;
  border-color: var(--arss-btn-emphasis-border) !important;
}

body.arss-branded .arss-btn--light:hover {
  background: var(--arss-btn-emphasis-fg) !important;
  color: var(--arss-btn-emphasis-bg) !important;
  border-color: var(--arss-btn-emphasis-border) !important;
}

body.arss-branded .arss-steps--light .arss-step--light {
  background: var(--arss-surface-container) !important;
  border-color: var(--arss-border) !important;
}

body.arss-branded .arss-steps--light .arss-step__title {
  color: var(--arss-on-surface) !important;
}

body.arss-branded .arss-steps--light .arss-step__text {
  color: var(--arss-on-surface-variant) !important;
}

body.arss-branded .arss-steps--light .arss-step__num {
  color: var(--arss-primary) !important;
}

body.arss-branded .arss-footer__title {
  color: #c8cdd6 !important;
}

body.arss-branded .arss-footer__tagline {
  color: #5fa6c4 !important;
}

body.arss-branded .arss-footer__links a:hover {
  color: #5fa6c4 !important;
}

body.arss-branded .arss-intent,
body.arss-branded .arss-panel__content {
  background: var(--arss-surface-container) !important;
  color: var(--arss-on-surface-variant) !important;
  border-color: var(--arss-border) !important;
}

body.arss-branded .arss-intent__label,
body.arss-branded .arss-label,
body.arss-branded .arss-intent__option-title,
body.arss-branded .arss-panel__title {
  color: var(--arss-on-surface) !important;
}

body.arss-branded .arss-intent__option {
  background: var(--arss-surface-container-low) !important;
  border-color: var(--arss-border) !important;
  color: var(--arss-on-surface-variant) !important;
}

body.arss-branded .arss-intent__option.is-active {
  border-color: var(--arss-primary) !important;
  background: var(--arss-accent-surface) !important;
}

body.arss-branded .woocommerce ul.products li.product {
  background: var(--arss-surface-container) !important;
  border-color: var(--arss-border) !important;
}

body.arss-branded .woocommerce ul.products li.product .woocommerce-loop-product__title {
  color: var(--arss-on-surface) !important;
}

body.arss-branded .woocommerce ul.products li.product .price {
  color: var(--arss-on-surface-variant) !important;
}

body.arss-branded .woocommerce-checkout #payment {
  background: var(--arss-surface-container) !important;
  color: var(--arss-on-surface-variant) !important;
}

body.arss-branded .woocommerce form .form-row input.input-text,
body.arss-branded .woocommerce form .form-row textarea,
body.arss-branded .woocommerce form .form-row select {
  background: var(--arss-surface-container-lowest) !important;
  border-color: var(--arss-border-strong) !important;
  color: var(--arss-on-surface) !important;
}

body.arss-branded .arss-gift-fields label {
  color: var(--arss-on-surface) !important;
}
