/* Theme switch — inactive side shows hint icon; knob shows active icon only */

.theme-switch {
  flex-shrink: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.theme-switch:focus-visible .theme-switch-track {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
}

.theme-switch-track {
  position: relative;
  display: block;
  width: 60px;
  height: 30px;
  border-radius: 999px;
  background: var(--sf);
  border: 1px solid var(--b2);
  box-shadow: inset 0 1px 2px var(--shadow-elevated);
  overflow: hidden;
}

.theme-switch-bg {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  color: var(--tx3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, color 0.2s ease;
}

.theme-switch-bg--sun {
  right: 9px;
  left: auto;
}

.theme-switch-bg--moon {
  left: 9px;
  right: auto;
}

.theme-switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--teal);
  color: var(--on-teal);
  box-shadow: 0 1px 4px var(--shadow-elevated);
  transition: transform 0.32s cubic-bezier(0.34, 1.4, 0.64, 1);
  pointer-events: none;
  overflow: hidden;
}

.theme-switch-knob-icon {
  display: block;
  flex-shrink: 0;
  width: 13px;
  height: 13px;
  transition: opacity 0.2s ease;
}

.theme-switch-knob-icon--light {
  position: absolute;
  opacity: 0;
}

.theme-switch-knob-icon--dark {
  position: absolute;
  opacity: 1;
}

/* Dark theme — knob left (moon); hint sun on the right only */
html.theme-dark .theme-switch-bg--moon,
html[data-theme="dark"] .theme-switch-bg--moon {
  opacity: 0;
}

html.theme-dark .theme-switch-bg--sun,
html[data-theme="dark"] .theme-switch-bg--sun {
  opacity: 0.38;
}

/* Light theme — knob right (sun); hint moon on the left only */
html.theme-light .theme-switch-knob,
html[data-theme="light"] .theme-switch-knob {
  transform: translateX(30px);
}

html.theme-light .theme-switch-knob-icon--dark,
html[data-theme="light"] .theme-switch-knob-icon--dark {
  opacity: 0;
}

html.theme-light .theme-switch-knob-icon--light,
html[data-theme="light"] .theme-switch-knob-icon--light {
  opacity: 1;
}

html.theme-light .theme-switch-bg--sun,
html[data-theme="light"] .theme-switch-bg--sun {
  opacity: 0;
}

html.theme-light .theme-switch-bg--moon,
html[data-theme="light"] .theme-switch-bg--moon {
  opacity: 0.38;
}

@media (prefers-reduced-motion: reduce) {
  .theme-switch-knob {
    transition: none;
  }
}
