:root {
  --theme-dark-bg: #000000;
  --theme-dark-surface: #111111;
  --theme-dark-text: #ffffff;
  --theme-dark-muted: #a0a0a0;
  --theme-dark-border: rgba(255, 255, 255, 0.15);
  --theme-light-bg: #ffffff;
  --theme-light-surface: #f4f4f4;
  --theme-light-text: #000000;
  --theme-light-muted: #6b6b6b;
  --theme-light-border: rgba(0, 0, 0, 0.15);
  --theme-wipe-duration: 500ms;
  --theme-wipe-curve: ease-in-out;
}

:root,
:root[data-theme="dark"] {
  --theme-bg: var(--theme-dark-bg);
  --theme-surface: var(--theme-dark-surface);
  --theme-text: var(--theme-dark-text);
  --theme-muted: var(--theme-dark-muted);
  --theme-border: var(--theme-dark-border);
}

:root[data-theme="light"] {
  --theme-bg: var(--theme-light-bg);
  --theme-surface: var(--theme-light-surface);
  --theme-text: var(--theme-light-text);
  --theme-muted: var(--theme-light-muted);
  --theme-border: var(--theme-light-border);
}

body {
  background-color: var(--theme-bg);
  color: var(--theme-text);
}

:root.theme-animating body {
  transition:
    background-color 250ms var(--theme-wipe-curve) 250ms,
    color var(--theme-wipe-duration) var(--theme-wipe-curve);
}

:root.theme-animating :where(header, main, section, aside, footer, nav, article, button, input, select, textarea, .card, .navbar, .hero, .stats, .tool-card, .about-inner, .cta, .footer) {
  transition:
    background-color 350ms var(--theme-wipe-curve) 120ms,
    color 350ms var(--theme-wipe-curve) 120ms,
    border-color 350ms var(--theme-wipe-curve) 120ms;
}

.theme-wipe {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  clip-path: circle(0 at var(--wipe-x, 50%) var(--wipe-y, 0));
  animation: theme-wipe-grow var(--theme-wipe-duration) var(--theme-wipe-curve) forwards;
}

.theme-wipe[data-to="dark"] {
  background-color: var(--theme-dark-bg);
}

.theme-wipe[data-to="light"] {
  background-color: var(--theme-light-bg);
}

@keyframes theme-wipe-grow {
  from {
    clip-path: circle(0 at var(--wipe-x, 50%) var(--wipe-y, 0));
  }
  to {
    clip-path: circle(var(--wipe-r, 150vmax) at var(--wipe-x, 50%) var(--wipe-y, 0));
  }
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp3, 1rem);
  padding: 0.875rem;
  color: var(--theme-muted);
  background-color: var(--theme-surface);
  border: 1px solid var(--theme-border);
  border-radius: var(--radius-md, 10px);
  cursor: pointer;
  transition:
    background-color 250ms ease-in-out 100ms,
    border-color 180ms ease-out;
}

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

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

.theme-toggle__icon {
  width: 1.5rem;
  height: 1.5rem;
  flex: none;
  transition: color 180ms ease-out, transform 250ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.theme-toggle[aria-checked="false"] .theme-toggle__icon--sun,
.theme-toggle[aria-checked="true"] .theme-toggle__icon--moon {
  color: var(--theme-text);
  transform: scale(1.15);
}

.theme-toggle__track {
  position: relative;
  flex: none;
  width: 3.375rem;
  height: 2rem;
  background-color: var(--theme-text);
  border-radius: var(--radius-pill, 999px);
}

.theme-toggle__thumb {
  position: absolute;
  bottom: 0.3125rem;
  left: 0.3125rem;
  width: 1.375rem;
  height: 1.375rem;
  background-color: var(--theme-bg);
  border-radius: 50%;
  transition: transform 350ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.theme-toggle[aria-checked="true"] .theme-toggle__thumb {
  transform: translateX(1.375rem);
}

@media (prefers-reduced-motion: reduce) {
  .theme-wipe {
    display: none;
  }

  :root.theme-animating body,
  :root.theme-animating :where(header, main, section, aside, footer, nav, article, button, input, select, textarea, .card, .navbar, .hero, .stats, .tool-card, .about-inner, .cta, .footer),
  .theme-toggle,
  .theme-toggle__icon,
  .theme-toggle__thumb {
    transition-duration: 1ms;
    transition-delay: 0s;
  }
}
