/**
 * Icon-only button, sized/bordered to match .hes-nav-bar__mobile-toggle
 * (the only other icon-only chrome button this theme already has) rather
 * than inventing a new shape for it.
 *
 * Which icon/label is visible is pure CSS, keyed off the exact same
 * data-theme attribute / prefers-color-scheme query color-system.css
 * uses for the palette itself - so the icon shown always matches the
 * current theme from first paint, with no dependency on theme-toggle.js
 * having run yet (see that file and theme-toggle.twig for why).
 *
 * The two `__label--*` spans carry core's `.visually-hidden` class
 * (clipped, not display:none, so they stay in the a11y tree) - the
 * display:none/block toggling below is layered on top of that, purely to
 * keep only ONE of the two exposed to assistive tech at a time. Without
 * it a screen reader would announce both ("Switch to dark theme Switch
 * to light theme") since visually-hidden alone doesn't remove either.
 */
.hes-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  background: none;
  border: 1px solid var(--hes-color-border);
  border-radius: var(--hes-radius-sm);
  color: var(--hes-color-text-primary);
  cursor: pointer;
}

.hes-theme-toggle:hover {
  color: var(--hes-color-link);
  border-color: var(--hes-color-link);
}

.hes-theme-toggle:focus-visible {
  outline: 2px solid var(--hes-color-link);
  outline-offset: 2px;
}

.hes-theme-toggle__icon {
  display: inline-flex;
}

/* Light theme (default, or an explicit override of a dark OS
   preference): show the moon ("switch to dark"), hide the sun. */
.hes-theme-toggle__icon--sun {
  display: none;
}
.hes-theme-toggle__label--to-light {
  display: none;
}

/* Explicit dark choice - reverses both pairs. */
:root[data-theme="dark"] .hes-theme-toggle__icon--moon {
  display: none;
}
:root[data-theme="dark"] .hes-theme-toggle__label--to-dark {
  display: none;
}
:root[data-theme="dark"] .hes-theme-toggle__icon--sun {
  display: inline-flex;
}
:root[data-theme="dark"] .hes-theme-toggle__label--to-light {
  display: block;
}

/* No explicit choice yet - follow the OS preference, same guard as
   color-system.css's matching block. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .hes-theme-toggle__icon--moon {
    display: none;
  }
  :root:not([data-theme="light"]) .hes-theme-toggle__label--to-dark {
    display: none;
  }
  :root:not([data-theme="light"]) .hes-theme-toggle__icon--sun {
    display: inline-flex;
  }
  :root:not([data-theme="light"]) .hes-theme-toggle__label--to-light {
    display: block;
  }
}
