/* ==========================================================================
   Dark mode toggle block
   --------------------------------------------------------------------------
   Structural styling for the toggle control. Colors use the theme's design
   tokens (with fallbacks) so the control themes itself in dark mode via the
   same token overrides as everything else. Which state is visible is driven by
   the data-dark-mode-preference attribute on <html>.
   ========================================================================== */

.darkmode-toggle-wrapper {
  display: inline-block;
}

/* The toggle looks like a menu link, not a button. Selectors are prefixed
   with the button element so they beat the theme's global button styling
   (background, border, padding) regardless of stylesheet load order. */
button.darkmode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  padding: 0;
  font: inherit;
  font-weight: 500;
  line-height: inherit;
  color: var(--color-link, #2563eb);
  background: none;
  border: 0;
  border-radius: 0;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

button.darkmode-toggle:hover,
button.darkmode-toggle:focus {
  color: var(--color-link-hover, #1e40af);
  background: none;
  border: 0;
  text-decoration: underline;
  box-shadow: none;
}

button.darkmode-toggle:focus-visible {
  outline: 2px solid var(--color-primary, #2563eb);
  outline-offset: 2px;
}

/* Only the state matching the current preference is shown. Default to "auto"
   until the attribute is present (e.g. before the head script runs). */
.darkmode-toggle__state {
  display: none;
  align-items: center;
  gap: 0.4em;
}

html[data-dark-mode-preference="auto"] .darkmode-toggle__state--auto,
html[data-dark-mode-preference="light"] .darkmode-toggle__state--light,
html[data-dark-mode-preference="dark"] .darkmode-toggle__state--dark,
html:not([data-dark-mode-preference]) .darkmode-toggle__state--auto {
  display: inline-flex;
}

.darkmode-toggle__icon::before {
  font-size: 1.1em;
  line-height: 1;
}

.darkmode-toggle__state--auto .darkmode-toggle__icon::before {
  content: "\25D0"; /* ◐ half-filled circle */
}

.darkmode-toggle__state--light .darkmode-toggle__icon::before {
  content: "\2600"; /* ☀ sun */
}

.darkmode-toggle__state--dark .darkmode-toggle__icon::before {
  content: "\263E"; /* ☾ moon */
}

/* Visually hidden but available to assistive technology. */
.darkmode-toggle__sr {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
