/* Theme toggle control */
.jms-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin: 0 4px 0 12px;
  padding: 0;
  border: 1px solid var(--jms-line, #e6e6e6);
  border-radius: 0;
  background: transparent;
  color: var(--jms-ink, #111111);
  cursor: pointer;
  line-height: 1;
  vertical-align: middle;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.jms-theme-toggle:hover,
.jms-theme-toggle:focus {
  background: rgba(0, 0, 0, 0.04);
  outline: none;
}
.jms-theme-toggle:focus-visible {
  outline: 1px dotted #1d2f4e;
  outline-offset: 2px;
}
.jms-theme-toggle svg {
  width: 18px;
  height: 18px;
  display: block;
}
.jms-theme-toggle .jms-icon-sun { display: none; }
.jms-theme-toggle .jms-icon-moon { display: block; }
html[data-theme="dark"] .jms-theme-toggle .jms-icon-sun { display: block; }
html[data-theme="dark"] .jms-theme-toggle .jms-icon-moon { display: none; }

.menu-item.jms-theme-li {
  display: flex;
  align-items: center;
  list-style: none;
}
.menu-item.jms-theme-li .menu-link {
  display: none;
}

/* Light tokens (default) */
:root,
html[data-theme="light"] {
  --jms-ink: #111111;
  --jms-navy: #1d2f4e;
  --jms-line: #e6e6e6;
  --jms-bg: #fafafa;
  --jms-surface: #ffffff;
  --jms-muted: #454f5e;
  color-scheme: light;
}

/* Dark tokens */
html[data-theme="dark"] {
  --jms-ink: #e8eaed;
  --jms-navy: #8ab4f8;
  --jms-line: #2a2f3a;
  --jms-bg: #0f1115;
  --jms-surface: #161a22;
  --jms-muted: #9aa3b2;
  color-scheme: dark;
}

html[data-theme="dark"] body,
html[data-theme="dark"] .ast-separate-container {
  background-color: var(--jms-bg) !important;
  color: var(--jms-ink);
}

html[data-theme="dark"] .ast-separate-container .ast-article-single:not(.ast-related-post),
html[data-theme="dark"] .ast-separate-container .ast-article-post,
html[data-theme="dark"] .ast-plain-container,
html[data-theme="dark"] .ast-separate-container .ast-article-post,
html[data-theme="dark"] .ast-separate-container .ast-article-single:not(.ast-related-post) {
  background-color: var(--jms-surface) !important;
  color: var(--jms-ink);
}

html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] h5,
html[data-theme="dark"] h6,
html[data-theme="dark"] .entry-content :where(h1, h2, h3, h4, h5, h6),
html[data-theme="dark"] .entry-title,
html[data-theme="dark"] body,
html[data-theme="dark"] .entry-content {
  color: var(--jms-ink) !important;
}

html[data-theme="dark"] .main-header-bar,
html[data-theme="dark"] .ast-primary-header-bar,
html[data-theme="dark"] .ast-mobile-header-wrap .ast-primary-header-bar,
html[data-theme="dark"] .ast-mobile-popup-drawer.active .ast-mobile-popup-inner,
html[data-theme="dark"] .ast-mobile-header-content,
html[data-theme="dark"] .ast-desktop-header-content {
  background-color: var(--jms-surface) !important;
  border-bottom-color: var(--jms-line) !important;
}

html[data-theme="dark"] .site-primary-footer-wrap[data-section="section-primary-footer-builder"],
html[data-theme="dark"] .site-footer,
html[data-theme="dark"] .ast-footer-copyright {
  background-color: var(--jms-surface) !important;
  border-top-color: var(--jms-line) !important;
  color: var(--jms-ink) !important;
}

html[data-theme="dark"] .ast-builder-menu-1 .menu-item > .menu-link,
html[data-theme="dark"] .ast-builder-menu-mobile .main-navigation .main-header-menu .menu-item > .menu-link,
html[data-theme="dark"] #astra-footer-menu .menu-item > a,
html[data-theme="dark"] .site-header .site-title a,
html[data-theme="dark"] a {
  color: var(--jms-ink);
}

html[data-theme="dark"] .entry-content a,
html[data-theme="dark"] a:hover,
html[data-theme="dark"] .ast-builder-menu-1 .menu-item > .menu-link:hover {
  color: var(--jms-navy);
}

html[data-theme="dark"] .jms-theme-toggle {
  border-color: var(--jms-line);
  color: var(--jms-ink);
}
html[data-theme="dark"] .jms-theme-toggle:hover,
html[data-theme="dark"] .jms-theme-toggle:focus {
  background: rgba(255, 255, 255, 0.06);
}

html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select,
html[data-theme="dark"] .wp-block-search__input {
  background-color: var(--jms-bg) !important;
  color: var(--jms-ink) !important;
  border-color: var(--jms-line) !important;
}

@media (max-width: 921px) {
  .menu-item.jms-theme-li {
    padding: 8px 0;
  }
  .jms-theme-toggle {
    margin-left: 0;
  }
}
