/* Theme Toggle Component
 * ==========================================================================
 * Switch-style toggle for switching between light and dark color schemes
 */

.theme-toggle {
  display: inline-block;
  width: 48px;
  height: 24px;
  cursor: pointer;
  vertical-align: middle;
  position: relative;
  flex-shrink: 0;
}

.theme-toggle__input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.theme-toggle__slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--color-primary);
  border-radius: 24px;
  transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--color-primary);
}

.theme-toggle__slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: var(--color-white);
  border-radius: 50%;
  transition: all 300ms cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2v2'/%3E%3Cpath d='M12 20v2'/%3E%3Cpath d='m4.93 4.93 1.41 1.41'/%3E%3Cpath d='m17.66 17.66 1.41 1.41'/%3E%3Cpath d='M2 12h2'/%3E%3Cpath d='M20 12h2'/%3E%3Cpath d='m6.34 17.66-1.41 1.41'/%3E%3Cpath d='m19.07 4.93-1.41 1.41'/%3E%3C/svg%3E");
  background-size: 14px 14px;
  background-position: center;
  background-repeat: no-repeat;
}

.theme-toggle__input:checked + .theme-toggle__slider:before {
  transform: translateX(24px);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z'/%3E%3C/svg%3E");
}

.theme-toggle:hover .theme-toggle__slider {
  box-shadow: 0 0 0 2px var(--color-primary);
}

/* When used in dropdown */
.dropdown__item .theme-toggle {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.dropdown__item .theme-toggle__text {
  flex: 1;
  color: var(--color-ink--inverse);
}

.dropdown__item .theme-toggle__control {
  display: inline-block;
  width: 48px;
  height: 24px;
  position: relative;
  flex-shrink: 0;
}
