/* View Transitions API - Disable default animation for custom ripple effect */
/* stylelint-disable selector-pseudo-element-no-unknown */
::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}
/* stylelint-enable selector-pseudo-element-no-unknown */

/* From Uiverse.io by Galahhad */
.theme-switch {
  --toggle-size: 20px;
  --container-width: 3.75em;
  --container-height: 1.7em;
  --container-radius: 3.5em;
  --container-light-bg: #3d7eae;
  --container-night-bg: #1d1f2c;
  --circle-container-diameter: 2.1em;
  --sun-moon-diameter: 1.3em;
  --sun-bg: #ecca2f;
  --moon-bg: #c4c9d1;
  --spot-color: #959db1;
  --circle-container-offset: calc(
    (var(--circle-container-diameter) - var(--container-height)) / 2 * -1
  );
  --stars-color: #fff;
  --clouds-color: #f3fdff;
  --back-clouds-color: #aacadf;
  --transition: 0.5s cubic-bezier(0, -0.02, 0.4, 1.25);
  --circle-transition: 0.3s cubic-bezier(0, -0.02, 0.35, 1.17);
}

.theme-switch,
.theme-switch *,
.theme-switch *::before,
.theme-switch *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-size: var(--toggle-size);
}

.theme-switch-container {
  width: var(--container-width);
  height: var(--container-height);
  background-color: var(--container-light-bg);
  border-radius: var(--container-radius);
  overflow: hidden;
  cursor: pointer;
  box-shadow: 0 -0.062em 0.062em rgba(0, 0, 0, 25%),
    0 0.062em 0.125em rgba(255, 255, 255, 94%);
  transition: var(--transition);
  position: relative;
}

.theme-switch-container::before {
  content: '';
  position: absolute;
  z-index: 1;
  inset: 0;
  box-shadow: 0 0.05em 0.187em rgba(0, 0, 0, 25%) inset;
  border-radius: var(--container-radius);
}

.theme-switch-checkbox {
  display: none;
}

.theme-switch-circle-container {
  width: var(--circle-container-diameter);
  height: var(--circle-container-diameter);
  background-color: rgba(255, 255, 255, 10%);
  position: absolute;
  left: var(--circle-container-offset);
  top: var(--circle-container-offset);
  border-radius: var(--container-radius);
  box-shadow: inset 0 0 0 3.375em rgba(255, 255, 255, 10%),
    0 0 0 0.625em rgba(255, 255, 255, 10%),
    0 0 0 1.25em rgba(255, 255, 255, 10%);
  display: flex;
  transition: var(--circle-transition);
  pointer-events: none;
}

.theme-switch-sun-moon-container {
  pointer-events: auto;
  position: relative;
  z-index: 2;
  width: var(--sun-moon-diameter);
  height: var(--sun-moon-diameter);
  margin: auto;
  border-radius: var(--container-radius);
  background-color: var(--sun-bg);
  box-shadow: 0.062em 0.062em 0.062em 0 rgba(254, 255, 239, 61%) inset,
    0 -0.062em 0.062em 0 #a1872a inset;
  filter: drop-shadow(0.062em 0.125em 0.125em rgba(0, 0, 0, 25%))
    drop-shadow(0 0.062em 0.125em rgba(0, 0, 0, 25%));
  overflow: hidden;
  transition: var(--transition);
}

.theme-switch-moon {
  transform: translateX(100%);
  width: 100%;
  height: 100%;
  background-color: var(--moon-bg);
  border-radius: inherit;
  box-shadow: 0.062em 0.062em 0.062em 0 rgba(254, 255, 239, 61%) inset,
    0 -0.062em 0.062em 0 #969696 inset;
  transition: var(--transition);
  position: relative;
}

.theme-switch-spot {
  position: absolute;
  top: 0.75em;
  left: 0.312em;
  width: 0.75em;
  height: 0.75em;
  border-radius: var(--container-radius);
  background-color: var(--spot-color);
  box-shadow: 0 0.0312em 0.062em rgba(0, 0, 0, 25%) inset;
}

.theme-switch-spot:nth-of-type(2) {
  width: 0.375em;
  height: 0.375em;
  top: 0.937em;
  left: 1.375em;
}

.theme-switch-spot:nth-last-of-type(3) {
  width: 0.25em;
  height: 0.25em;
  top: 0.312em;
  left: 0.812em;
}

.theme-switch-clouds {
  width: 1.25em;
  height: 1.25em;
  background-color: var(--clouds-color);
  border-radius: var(--container-radius);
  position: absolute;
  bottom: -0.625em;
  left: 0.312em;
  box-shadow: 0.937em 0.312em var(--clouds-color),
    -0.312em -0.312em var(--back-clouds-color),
    1.437em 0.375em var(--clouds-color), 0.5em -0.125em var(--back-clouds-color),
    2.187em 0 var(--clouds-color), 1.25em -0.062em var(--back-clouds-color),
    2.937em 0.312em var(--clouds-color), 2em -0.312em var(--back-clouds-color),
    3.625em -0.062em var(--clouds-color), 2.625em 0 var(--back-clouds-color),
    4.5em -0.312em var(--clouds-color),
    3.375em -0.437em var(--back-clouds-color),
    4.625em -1.75em 0 0.437em var(--clouds-color),
    4em -0.625em var(--back-clouds-color),
    4.125em -2.125em 0 0.437em var(--back-clouds-color);
  transition: var(--transition);
}

.theme-switch-stars-container {
  position: absolute;
  color: var(--stars-color);
  top: -100%;
  left: 0.312em;
  width: 2.75em;
  height: auto;
  transition: var(--transition);
}

/* actions */

.theme-switch-checkbox:checked + .theme-switch-container {
  background-color: var(--container-night-bg);
}

.theme-switch-checkbox:checked
  + .theme-switch-container
  .theme-switch-circle-container {
  left: calc(
    100% - var(--circle-container-offset) - var(--circle-container-diameter)
  );
}

.theme-switch-checkbox:checked
  + .theme-switch-container
  .theme-switch-circle-container:hover {
  left: calc(
    100% - var(--circle-container-offset) - var(--circle-container-diameter) -
      0.187em
  );
}

.theme-switch-circle-container:hover {
  left: calc(var(--circle-container-offset) + 0.187em);
}

.theme-switch-checkbox:checked + .theme-switch-container .theme-switch-moon {
  transform: translate(0);
}

.theme-switch-checkbox:checked + .theme-switch-container .theme-switch-clouds {
  bottom: -4.062em;
}

.theme-switch-checkbox:checked
  + .theme-switch-container
  .theme-switch-stars-container {
  top: 50%;
  transform: translateY(-50%);
}
