/* .theme-toggle — styles for src/lib/expand.mjs's `x-theme-toggle`, and the
   same markup x-header embeds via its `theme-toggle` boolAttr (themeToggleHtml()
   is the single source of the HTML; this is the single source of how it
   looks). Load AFTER tokens.css. See public/components/README.md for load
   order and the split rationale.

   Ported from design/auto-microsite-page.dc.html and
   design/apricotter-homepage.dc.html's day/night dial — both design comps
   had this animated toggle; the real site had a plain text button instead,
   because nothing forced a reconciliation between the two (see
   features/component-passthrough-gaps.md's sibling finding on the same
   design/code drift, and .claude/skills/sync-design-components for the
   process fix). This file is what closes that specific gap.

   THE ANIMATION, for whoever edits this next: .theme-toggle__sky rotates
   180deg on theme change, swinging the sun out of view and the moon into
   it. Each orb's OWN inner .theme-toggle__orb-icon counter-rotates at the
   same time, so the icon itself stays upright instead of appearing to flip
   upside down as it swings around the sky's rotation. The moon's icon
   starts pre-rotated 180deg for exactly this reason — after the sky's own
   180deg flip, the two rotations cancel and the moon lands upright. */

.theme-toggle {
  flex: none;
  position: relative;
  width: var(--theme-toggle-size);
  height: var(--theme-toggle-size);
  margin-left: 10px;
  padding: 0;
  overflow: hidden;
  border: var(--border-width-hairline) solid var(--theme-toggle-border);
  border-radius: var(--radius-pill);
  background: var(--theme-toggle-background);
  color: var(--theme-toggle-icon);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color var(--duration-fast) var(--easing-standard),
    border-color var(--duration-fast) var(--easing-standard);
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  background-color: var(--color-surface-hover);
}

.theme-toggle:focus-visible {
  outline: var(--focus-ring-width) solid var(--color-focus-ring);
  outline-offset: var(--focus-ring-offset);
}

/* --- the star field, visible only in dark mode ---------------------------- */

.theme-toggle__stars {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity var(--theme-toggle-duration-icon) ease;
}

[data-theme="dark"] .theme-toggle__stars {
  opacity: 1;
}

.theme-toggle__star {
  position: absolute;
  border-radius: var(--radius-pill);
  background: currentColor;
}

.theme-toggle__star--1 {
  left: 9px;
  top: 11px;
  width: 2px;
  height: 2px;
}

.theme-toggle__star--2 {
  left: 28px;
  top: 8px;
  width: 1.5px;
  height: 1.5px;
  opacity: 0.75;
}

.theme-toggle__star--3 {
  left: 18px;
  top: 26px;
  width: 1.5px;
  height: 1.5px;
  opacity: 0.6;
}

/* --- the sun/moon orbit ---------------------------------------------------- */

.theme-toggle__sky {
  position: absolute;
  left: 50%;
  top: 100%;
  width: 0;
  height: 0;
  transition: transform var(--theme-toggle-duration-orbit) var(--theme-toggle-easing-orbit);
}

[data-theme="dark"] .theme-toggle__sky {
  transform: rotate(180deg);
}

.theme-toggle__orb {
  position: absolute;
  left: 0;
  top: 0;
  display: block;
}

.theme-toggle__orb--sun {
  transform: translate(-50%, -50%) translateY(-20px);
}

.theme-toggle__orb--moon {
  transform: translate(-50%, -50%) translateY(20px);
}

.theme-toggle__orb-icon {
  display: block;
  transition: transform var(--theme-toggle-duration-orbit) var(--theme-toggle-easing-orbit);
}

.theme-toggle__orb--moon .theme-toggle__orb-icon {
  transform: rotate(180deg);
}

[data-theme="dark"] .theme-toggle__orb--sun .theme-toggle__orb-icon {
  transform: rotate(-180deg);
}

[data-theme="dark"] .theme-toggle__orb--moon .theme-toggle__orb-icon {
  transform: rotate(0deg);
}

.theme-toggle__orb--sun svg {
  display: block;
  width: 17px;
  height: 17px;
}

.theme-toggle__orb--moon svg {
  display: block;
  width: 16px;
  height: 16px;
}
