/* Page coordinates (CSS px): slab 40..500 x 99..441, padding 36 44 44 (the cap height sits 44 under the top edge). Track 84..456 x 211..397, thumb 150, inset 18. */
.cl {
  width: 540px;
  height: 540px;
  box-sizing: border-box;
  padding: 99px 40px;
  background: radial-gradient(120% 100% at 30% 0%, #fdf6e1 0%, #f6ebcd 55%, #efe0b9 100%);
  color: #3b2a59;
  font-family: "Bricolage Grotesque Variable", sans-serif;
}

.cl * { box-sizing: border-box; }

/* The track colour travels round the hue wheel (apricot, butter, lime, mint) instead of through grey. */
@property --cl-mix {
  syntax: "<percentage>";
  inherits: true;
  initial-value: 0%;
}

.cl-slab {
  display: flex;
  flex-direction: column;
  gap: 32px;
  width: 460px;
  height: 342px;
  padding: 36px 44px 44px;
  border-radius: 64px;
  background: linear-gradient(160deg, #d9c8f8 0%, #c9b4f0 55%, #bfa8ea 100%);
  box-shadow:
    inset 0 12px 18px #ffffff8c,
    inset 0 -16px 24px #7a56b84d,
    0 34px 44px -14px #8a6a4a66,
    0 8px 12px -4px #8a6a4a33;
  user-select: none;
}

.cl-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 44px;
  font-size: 40px;
  font-weight: 800;
  line-height: 44px;
  letter-spacing: -0.02em;
}

.cl-label { text-shadow: 0 2px 0 #ffffff59; }

.cl-state {
  position: relative;
  width: 70px;
  height: 44px;
  overflow: hidden;
}

.cl-state span {
  position: absolute;
  right: 0;
  top: 0;
  transition: translate 280ms cubic-bezier(0.3, 0.9, 0.4, 1);
}

.cl-state span:first-child { color: #3b2a598c; }
.cl-state span:last-child { translate: 0 46px; color: #1f7f5e; text-shadow: 0 2px 0 #ffffff59; }
.cl-state[data-on] span:first-child { translate: 0 -46px; }
.cl-state[data-on] span:last-child { translate: 0 0; }

.cl-switch {
  position: relative;
  display: flex;
  align-items: center;
  width: 372px;
  height: 186px;
  padding: 18px;
  border: 0;
  border-radius: 999px;
  background-color: color-mix(in oklch, #86e0bb var(--cl-mix), #ffbf94);
  box-shadow:
    inset 0 14px 20px #5a2f1a59,
    inset 0 -10px 14px #ffffff80,
    0 3px 0 #ffffff73,
    0 -2px 0 #7a56b833;
  outline: none;
  transition: --cl-mix 380ms ease;
}

.cl-switch[data-checked] { --cl-mix: 100%; }

.cl-switch:focus-visible { box-shadow: inset 0 14px 20px #5a2f1a59, inset 0 -10px 14px #ffffff80, 0 0 0 6px #3b2a59; }

.cl-thumb {
  position: relative;
  display: grid;
  place-items: center;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: radial-gradient(90% 90% at 34% 26%, #ffffff 0%, #fff6e6 42%, #f1dfc4 100%);
  box-shadow:
    inset 0 -14px 20px #b98e5a59,
    inset 0 10px 12px #ffffff,
    0 16px 18px -4px #5a2f1a73,
    0 4px 6px #5a2f1a40;
  transition: translate 420ms cubic-bezier(0.3, 1.45, 0.5, 1), scale 130ms ease-out;
}

.cl-switch:hover .cl-thumb { scale: 1.03; }
.cl-switch:active .cl-thumb { scale: 1.1 0.9; }

.cl-thumb[data-checked] {
  translate: 186px 0;
  animation: cl-stretch 420ms ease-out;
}

@keyframes cl-stretch {
  0% { scale: 1.1 0.9; }
  30% { scale: 1.22 0.86; }
  62% { scale: 0.93 1.05; }
  82% { scale: 1.04 0.98; }
  100% { scale: 1.03; }
}

.cl-thumb svg {
  grid-area: 1 / 1;
  width: 70px;
  height: 70px;
  stroke-width: 2.4;
  transition: opacity 130ms ease, rotate 420ms cubic-bezier(0.3, 1.45, 0.5, 1), scale 420ms cubic-bezier(0.3, 1.45, 0.5, 1);
}

.cl-bell { color: #e58a4f; }
.cl-moon { color: #27a179; fill: #27a17933; opacity: 0; rotate: -90deg; scale: 0.6; }
.cl-thumb[data-checked] .cl-bell { opacity: 0; rotate: 90deg; scale: 0.6; }
.cl-thumb[data-checked] .cl-moon { opacity: 1; rotate: 0deg; scale: 1; transition-delay: 120ms, 0ms, 0ms; }
