/* ============================================================
   Solverra Theme Toggle -- segmented control + mobile dropdown
   ------------------------------------------------------------
   - Reads ONLY --color-* aliases emitted by solverra-design-system
     (the dual-token contract from STANDARDS Section 2.1).
   - 44px hit target minimum (WCAG 2.5.5).
   - focus-visible: 2px outline in brand primary.
   - Lucide stroke icons inlined by PHP at stroke-width=1.5.
   - prefers-reduced-motion respected via body class added by JS.
   ASCII-only per STANDARDS Section 19.1.
   ============================================================ */

.solverra-theme-toggle-wrap {
  list-style: none;
  display: inline-flex;
  align-items: center;
  margin-left: auto;
}

.solverra-theme-toggle {
  display: inline-flex;
  align-items: stretch;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  background: var(--color-bg-soft, rgba(0, 0, 0, 0.04));
  border: 1px solid var(--color-border, rgba(0, 0, 0, 0.12));
  box-shadow: var(--shadow-1, 0 1px 2px rgba(0, 0, 0, 0.06));
}

.solverra-theme-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--color-text-muted, currentColor);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.solverra-theme-btn:hover {
  color: var(--color-text, currentColor);
  background: var(--color-bg-elev, rgba(255, 255, 255, 0.5));
}

.solverra-theme-btn[aria-pressed="true"] {
  background: var(--color-bg-elev, #fff);
  color: var(--color-text, currentColor);
  box-shadow: var(--shadow-1, 0 1px 2px rgba(0, 0, 0, 0.08));
}

.solverra-theme-btn:focus-visible {
  outline: 2px solid var(--color-primary, currentColor);
  outline-offset: 2px;
}

.solverra-theme-btn-icon {
  display: inline-flex;
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  color: currentColor;
}

.solverra-theme-btn-icon svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  stroke-width: 1.5;
}

.solverra-theme-btn-label {
  display: inline-block;
}

/* Sticky header positioning -- only when the wrap is a direct child of header
   layouts. Themes may opt out by setting --solverra-theme-toggle-position. */
header .solverra-theme-toggle-wrap,
.site-header .solverra-theme-toggle-wrap {
  position: sticky;
  top: 16px;
  right: 16px;
  z-index: 200;
}

/* SR-only live region */
.solverra-theme-sr-live {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* -----------------------------------------------------------------------
   Mobile -- compact icon-only buttons, integrate into hamburger row
   ----------------------------------------------------------------------- */
@media (max-width: 720px) {
  .solverra-theme-toggle {
    gap: 0;
    padding: 2px;
  }
  .solverra-theme-btn {
    padding: 0 10px;
    font-size: 13px;
  }
  .solverra-theme-btn-label {
    /* Hide labels on mobile but keep them in the DOM for AT */
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  .solverra-theme-btn {
    min-width: 44px;
    padding: 0 12px;
  }
  header .solverra-theme-toggle-wrap,
  .site-header .solverra-theme-toggle-wrap {
    top: 8px;
    right: 8px;
  }
}

/* -----------------------------------------------------------------------
   Reduced motion -- disable transitions on icon swap
   ----------------------------------------------------------------------- */
body.solverra-theme-reduced-motion .solverra-theme-btn,
body.solverra-theme-reduced-motion .solverra-theme-btn-icon svg,
@media (prefers-reduced-motion: reduce) {
  transition: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .solverra-theme-btn,
  .solverra-theme-btn-icon svg {
    transition: none !important;
  }
}

/* -----------------------------------------------------------------------
   Theme transitions on body -- only when the user has NOT requested
   reduced motion. Damps the harsh flash when flipping modes.
   ----------------------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  html[data-theme-effective] body {
    transition: background-color 220ms ease, color 220ms ease;
  }
}

/* -----------------------------------------------------------------------
   Brand tweaks -- per-brand small adjustments via data-brand attribute
   ----------------------------------------------------------------------- */

/* Cap & Stem dark-by-default -- mint-glow ring on selected */
html[data-brand="cap-stem"] .solverra-theme-btn[aria-pressed="true"] {
  box-shadow: 0 0 0 1px var(--color-primary, #7FE0D2), 0 0 16px -4px var(--color-primary, #7FE0D2);
}

/* BeeChill -- honey halo on selected */
html[data-brand="beechill"] .solverra-theme-btn[aria-pressed="true"] {
  box-shadow: 0 0 0 1px var(--color-primary, #F0B020), 0 0 14px -4px var(--color-primary, #F0B020);
}

/* Apawthecary -- soft sage shadow */
html[data-brand="apawthecary"] .solverra-theme-btn[aria-pressed="true"] {
  box-shadow: 0 2px 6px -2px var(--color-primary, #7bb190);
}
