html, body {
  margin: 0;
  overflow: hidden;
}

.stage {
  box-sizing: border-box;
  min-height: 100vh;
  display: grid;
  place-items: center;
  margin: 0;
  background: #ff4d1f;
  font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
  padding: clamp(8px, 4vw, 24px);
}

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: clamp(10px, 3vw, 14px);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.switch__input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.switch__track {
  position: relative;
  overflow: hidden;
  width: clamp(56px, 15vw, 66px);
  height: clamp(28px, 7.5vw, 32px);
  border-radius: 999px;
  background-image: linear-gradient(90deg, #ffd23f 0%, #ffd23f 50%, #17141a 50%, #17141a 100%);
  background-size: 200% 100%;
  background-position: 0% 0%;
  transition: background-position 600ms ease-out;
}

.switch__star {
  position: absolute;
  top: 30%;
  width: 2.5px;
  height: 2.5px;
  border-radius: 50%;
  background: #fff7e6;
  opacity: 0;
  transition: opacity 600ms ease-out;
}

.switch__star--1 {
  left: 62%;
  top: 26%;
}

.switch__star--2 {
  left: 74%;
  top: 55%;
}

.switch__star--3 {
  left: 84%;
  top: 34%;
}

.switch__knob {
  position: absolute;
  top: 3px;
  left: 3px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: clamp(22px, 6vw, 26px);
  height: clamp(22px, 6vw, 26px);
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 14px 24px rgba(23, 20, 26, 0.32);
  color: #ff4d1f;
  transform: translateX(0);
  transition: transform 600ms cubic-bezier(0.34, 1.56, 0.64, 1), color 600ms ease-out, box-shadow 600ms ease-out;
}

.switch__icon {
  grid-area: 1/1;
  transition: opacity 600ms ease-out;
}

.switch__icon--sun {
  opacity: 1;
}

.switch__icon--moon {
  opacity: 0;
}

.switch__label {
  color: #17141a;
  font-weight: 600;
  font-size: clamp(14px, 4vw, 17px);
  line-height: 1;
  font-family: inherit;
}

.switch__input:checked ~ .switch__track {
  background-position: 100% 0%;
}

.switch__input:checked ~ .switch__track .switch__star {
  opacity: 1;
}

.switch__input:checked ~ .switch__track .switch__knob {
  transform: translateX(clamp(28px, 8vw, 34px));
  color: #17141a;
  box-shadow: 0 20px 32px rgba(23, 20, 26, 0.4);
}

.switch__input:checked ~ .switch__track .switch__icon--sun {
  opacity: 0;
}

.switch__input:checked ~ .switch__track .switch__icon--moon {
  opacity: 1;
}

.switch__input:focus-visible ~ .switch__track {
  outline: 2px solid #17141a;
  outline-offset: 3px;
}

.switch.is-demo .switch__track {
  animation: sky-loop 2s ease-out infinite;
}

.switch.is-demo .switch__star--1,
.switch.is-demo .switch__star--2,
.switch.is-demo .switch__star--3 {
  animation: star-loop 2s ease-out infinite;
}

.switch.is-demo .switch__knob {
  animation: knob-spring-loop 2s ease-out infinite, knob-shadow-loop 2s ease-out infinite;
}

.switch.is-demo .switch__icon--sun {
  animation: sun-loop 2s ease-out infinite;
}

.switch.is-demo .switch__icon--moon {
  animation: moon-loop 2s ease-out infinite;
}

@keyframes sky-loop {
  0%, 15% {
    background-position: 0% 0%;
  }
  40%, 60% {
    background-position: 100% 0%;
  }
  85%, 100% {
    background-position: 0% 0%;
  }
}
@keyframes star-loop {
  0%, 15% {
    opacity: 0;
  }
  40%, 60% {
    opacity: 1;
  }
  85%, 100% {
    opacity: 0;
  }
}
@keyframes knob-loop {
  0%, 15% {
    transform: translateX(0);
  }
  40%, 60% {
    transform: translateX(34px);
  }
  85%, 100% {
    transform: translateX(0);
  }
}
@keyframes knob-spring-loop {
  0%, 15% {
    transform: translateX(0) scaleX(1) scaleY(1);
  }
  38% {
    transform: translateX(37px) scaleX(1.25) scaleY(0.85);
  }
  43% {
    transform: translateX(33px) scaleX(1.08) scaleY(0.94);
  }
  47%, 60% {
    transform: translateX(34px) scaleX(1) scaleY(1);
  }
  84% {
    transform: translateX(-2px) scaleX(0.92) scaleY(1.06);
  }
  85%, 100% {
    transform: translateX(0) scaleX(1) scaleY(1);
  }
}
@keyframes knob-shadow-loop {
  0%, 15% {
    box-shadow: 0 14px 24px rgba(23, 20, 26, 0.32);
  }
  40%, 60% {
    box-shadow: 0 20px 32px rgba(23, 20, 26, 0.4);
  }
  85%, 100% {
    box-shadow: 0 14px 24px rgba(23, 20, 26, 0.32);
  }
}
@keyframes sun-loop {
  0%, 15% {
    opacity: 1;
  }
  40%, 60% {
    opacity: 0;
  }
  85%, 100% {
    opacity: 1;
  }
}
@keyframes moon-loop {
  0%, 15% {
    opacity: 0;
  }
  40%, 60% {
    opacity: 1;
  }
  85%, 100% {
    opacity: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  .switch.is-demo .switch__track, .switch.is-demo .switch__star--1, .switch.is-demo .switch__star--2,
  .switch.is-demo .switch__star--3, .switch.is-demo .switch__knob, .switch.is-demo .switch__icon--sun,
  .switch.is-demo .switch__icon--moon {
    animation: none !important;
  }
  .switch__track, .switch__star, .switch__knob, .switch__icon {
    transition: none;
  }
}
