/* QFC Accessibility Toolbar */
.qfc-a11y-wrapper {
  position: relative;
}

.qfc-a11y-menu {
  position: relative;
  display: inline-block;
}

.qfc-a11y-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 0px;
  padding-right: 1.5rem;
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
  font-size: inherit;
  transition: opacity 0.2s;
}

.qfc-a11y-trigger:hover {
  opacity: 0.8;
}

.qfc-a11y-trigger:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.qfc-a11y-trigger img {
  width: 20px;
  height: 20px;
}

.qfc-a11y-panel {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1050;
  overflow: hidden;
  font-family: system-ui, -apple-system, sans-serif;
}

.qfc-a11y-menu.open .qfc-a11y-panel {
  display: block;
}

html[dir="rtl"] .qfc-a11y-panel {
  right: auto;
  left: 0;
}

.qfc-a11y-section {
  padding: 8px 0;
}

.qfc-a11y-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-subtle);
  padding: 8px 14px 4px;
  margin: 0;
}

.qfc-a11y-option {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  border-radius: 0;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background-color 0.12s;
}

.qfc-a11y-option:hover {
  background-color: var(--surface-2);
}

.qfc-a11y-option:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.qfc-a11y-option.active {
  color: var(--primary-accent);
  font-weight: 700;
}

.qfc-a11y-option.active::after {
  content: '✓';
  margin-left: auto;
  font-weight: 700;
}

.qfc-a11y-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
  border: none;
}

/* 1. Base Dark Mode Variables (Bootstrap Native overrides) */
html.dark-mode body,
html.dark-mode {
  /* Core body colors */
  --bs-body-bg: #121212;
  --bs-body-color: #e0e0e0;
  --bs-body-bg-rgb: 18, 18, 18;
  --bs-body-color-rgb: 224, 224, 224;

  /* Redefine Bootstrap white/light to dark */
  --bs-white: #1e1e1e;
  --bs-white-rgb: 30, 30, 30;
  --bs-light: #2d2d2d;
  --bs-light-rgb: 45, 45, 45;
  --bs-light-bg-subtle: #1e1e1e;

  /* Component backgrounds (Cards, Modals, Offcanvas, Dropdowns) */
  --bs-tertiary-bg: #1e1e1e;
  --bs-secondary-bg: #2d2d2d;
  --bs-card-bg: #1e1e1e;
  --bs-card-color: #ffffff;
  --bs-dropdown-bg: #1e1e1e;
  --bs-dropdown-color: #ffffff;
  --bs-modal-bg: #1e1e1e;
  --bs-modal-color: #ffffff;
  --bs-offcanvas-bg: #1e1e1e;
  --bs-offcanvas-color: #ffffff;

  background-color: var(--bs-body-bg);
  color: var(--bs-body-color);
}

/* 2. Echo Success image treatment (functional — not a colour token) */
html.dark-mode .success .echo-success.home-page {
  background-image: none !important;
}

html.dark-mode .success .echo-success::before {
  background-image: linear-gradient(to right, var(--bs-tertiary-bg) 0%, var(--bs-tertiary-bg) 35%, rgba(30, 30, 30, 0) 75%), url(../../assets/images/echoes-background.jpg) !important;
  background-size: 100% 100%, contain !important;
  background-position: left top, right center !important;
  background-repeat: no-repeat, no-repeat !important;
}

html.dark-mode .success .echo-success .testimonial-slider::before {
  display: none !important;
}

/* 3. Component dark fixes tokens can't reach (raster icons / translucent controls) */
html.dark-mode .resource-center .resource-icon-box img {
  filter: brightness(0) invert(1);
}

html.dark-mode .qfc-a11y-trigger img {
  filter: brightness(0) invert(1);
}

/* app.css .site-header.is-scrolled .top-nav ul li img darkens icons for light-mode
   contrast; higher specificity needed here to win over it in dark mode.
   invert(70%) on black ≈ #b3b3b3, matching --text-muted used by the sibling nav links. */
html.dark-mode .site-header.is-scrolled .top-nav ul li .qfc-a11y-trigger img {
  filter: brightness(0) invert(70%);
}

/* Header is always dark in dark mode (transparent over hero, or solid surface when
   scrolled) — show the white logo in every state. */
html.dark-mode header.site-header .main-nav .navbar-brand img.dark {
  display: none !important;
}

html.dark-mode header.site-header .main-nav .navbar-brand img.light {
  display: inline !important;
}

/* Generic fix for every slick carousel's prev/next arrow button (testimonial-slider,
   single-slider, explore, ...) — all share the .slick-arrow.slick-prev/.slick-next
   classes with a translucent white bg + hardcoded purple border/icon that disappears
   on a dark surface. */
html.dark-mode .slick-arrow.slick-prev,
html.dark-mode .slick-arrow.slick-next {
  background: var(--surface-3);
  border-color: var(--border-strong);
}

html.dark-mode .slick-arrow.slick-prev::before,
html.dark-mode .slick-arrow.slick-next::before,
html.dark-mode .slick-arrow.slick-prev::after,
html.dark-mode .slick-arrow.slick-next::after {
  color: var(--on-primary);
}

/* Same problem, same fix, for Swiper's nav buttons. */
html.dark-mode .swiper-button-next,
html.dark-mode .swiper-button-prev {
  background: var(--surface-3);
  border-color: var(--border-strong);
}

html.dark-mode .swiper-button-next::after,
html.dark-mode .swiper-button-prev::after {
  color: var(--on-primary);
}

html.dark-mode .swiper-button-disabled {
  opacity: 0.5;
}

/* QFC-1143 re-open: components that hardcode a brand/navy hex directly on
   `color:` (no --colors-* token to reach), so the token layer can't flip them.
   Brand-purple text → light purple tint; neutral navy headings → light text. */
html.dark-mode .ci-headline,
html.dark-mode .ci-eyebrow,
html.dark-mode .subtitle-main-title__sub,
html.dark-mode .ccg-category-headline,
html.dark-mode .faqs-list__title {
  color: var(--primary-accent);
}

html.dark-mode .timeline-item__title,
html.dark-mode .subtitle-main-title__main {
  color: var(--text);
}

/* select2 filter dropdowns (news/events/blogs/reports/…) keep a white surface
   with dark text in dark mode → invert surface + lift text. */
html.dark-mode .select2-dropdown,
html.dark-mode .select2-results__option,
html.dark-mode .select2-container--default .select2-selection--single {
  background: var(--surface-2);
  color: var(--text);
}

html.dark-mode .select2-results__option--highlighted {
  background: var(--surface-3);
}

html.dark-mode .select2-box .select2-container--default .select2-selection--single .select2-selection__rendered {
  color: var(--primary-accent);
}

/* QFC-1143 follow-up: panels/cards that hardcode a light background directly
   (about.css / financial-service-banking.css), not via --colors-* tokens, so
   the token layer can't reach them. Higher specificity beats the source rules. */

/* KeyAdvantagesTabs / new-tabs content panel (#f4f4f4) + its rich-text body */
html.dark-mode .new-tabs .tab-content {
  background: var(--surface-2);
  color: var(--text);
}

html.dark-mode .new-tabs .tab-content .p-content h2,
html.dark-mode .new-tabs .tab-content .p-content h3,
html.dark-mode .new-tabs .tab-content .p-content h4,
html.dark-mode .new-tabs .tab-content .p-content p,
html.dark-mode .new-tabs .tab-content .p-content li,
html.dark-mode .new-tabs .tab-content .rich-text-list,
html.dark-mode .new-tabs .tab-content .rich-text-list li {
  color: var(--text);
}

/* Financial-services "What we offer" panel (#f9fafb) + its text */
html.dark-mode .fsb-what-we-offer-section-inner {
  background-color: var(--surface-2);
}

html.dark-mode .fsb-what-we-offer-section-inner .section-heading .sub-title,
html.dark-mode .fsb-what-we-offer-section-inner .section-heading p,
html.dark-mode .fsb-what-we-offer-section-inner-col ul li,
html.dark-mode .fsb-what-we-offer-section-inner-col ul li p {
  color: var(--text);
}

html.dark-mode .fsb-what-we-offer-section-inner .section-heading .title,
html.dark-mode .fsb-what-we-offer-section-inner .section-heading h2,
html.dark-mode .fsb-what-we-offer-section-inner-col .heading,
html.dark-mode .fsb-what-we-offer-section-inner-col h3,
html.dark-mode .fsb-what-we-offer-section-inner-col .sub-heading,
html.dark-mode .fsb-what-we-offer-section-inner-col h4 {
  color: var(--primary-accent);
}

/* cardSwiper cards that hardcode #FFFFFF (about.css) — elevate to a visible dark
   surface (also lifts the home/style variants off the too-dark var(--surface)). */
html.dark-mode .cardSwiper .card {
  background: var(--surface-2);
}

html[data-font-scale="small"] {
  font-size: 90%;
}

html[data-font-scale="large"] {
  font-size: 110%;
}

html[data-font-scale="x-large"] {
  font-size: 120%;
}

html[data-font-scale="xx-large"] {
  font-size: 130%;
}

@media (max-width: 768px) {
  .qfc-a11y-panel {
    width: 200px;
  }

  .qfc-a11y-mobile .qfc-a11y-panel {
    position: static;
    border: 1px solid var(--border);
    box-shadow: none;
    margin-top: 8px;
  }
}
