/* ================= THEME SWITCH ================= */
/* Original behavior preserved (critical offsets kept) */

.theme-switch {
  --toggle-size: 10px;
  --container-width: 5.625em;
  --container-height: 2.5em;
  --container-radius: 6.25em;

  --container-light-bg: #3D7EAE;
  --container-night-bg: #1D1F2C;

  --circle-container-diameter: 3.375em;
  --circle-container-offset: calc(
    (var(--circle-container-diameter) - var(--container-height)) / -2
  );

  --sun-moon-diameter: 2.125em;
  --sun-bg: #ECCA2F;
  --moon-bg: #C4C9D1;
  --spot-color: #959DB1;

  --stars-color: #fff;
  --clouds-color: #F3FDFF;
  --back-clouds-color: #AACADF;

  --transition: .5s cubic-bezier(0, -0.02, 0.4, 1.25);
  --circle-transition: .3s cubic-bezier(0, -0.02, 0.35, 1.17);

  display: flex;
  align-items: center;
  font-size: var(--toggle-size);
}

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

/* ================= CONTAINER ================= */
.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;
  position: relative;
  transition: var(--transition);
  box-shadow:
    0 -0.062em 0.062em rgba(0, 0, 0, 0.25),
    0 0.062em 0.125em rgba(255, 255, 255, 0.94);
}

.theme-switch__container::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0.05em 0.187em rgba(0, 0, 0, 0.25) inset;
}

/* ================= CHECKBOX ================= */
.theme-switch__checkbox {
  display: none;
}

/* ================= MOVING CIRCLE ================= */
.theme-switch__circle-container {
  width: var(--circle-container-diameter);
  height: var(--circle-container-diameter);
  position: absolute;
  left: var(--circle-container-offset);
  top: var(--circle-container-offset);
  border-radius: var(--container-radius);

  background-color: rgba(255, 255, 255, 0.1);
  box-shadow:
    inset 0 0 0 3.375em rgba(255, 255, 255, 0.1),
    0 0 0 0.625em rgba(255, 255, 255, 0.1),
    0 0 0 1.25em rgba(255, 255, 255, 0.1);

  display: flex;
  transition: var(--circle-transition);
  pointer-events: none;
  z-index: 3;
}

/* hover micro-interaction */
.theme-switch__circle-container:hover {
  left: calc(var(--circle-container-offset) + 0.187em);
}

/* ================= SUN / MOON ================= */
.theme-switch__sun-moon-container {
  margin: auto;
  width: var(--sun-moon-diameter);
  height: var(--sun-moon-diameter);
  border-radius: 50%;
  background: var(--sun-bg);
  overflow: hidden;
  position: relative;
  z-index: 2;

  box-shadow:
    0.062em 0.062em 0.062em rgba(254, 255, 239, 0.61) inset,
    0 -0.062em 0.062em #a1872a inset;

  filter: drop-shadow(0.062em 0.125em 0.125em rgba(0, 0, 0, 0.25));
  transition: var(--transition);
}

/* ================= MOON ================= */
.theme-switch__moon {
  width: 100%;
  height: 100%;
  background: var(--moon-bg);
  border-radius: inherit;
  transform: translateX(100%);
  transition: var(--transition);
  position: relative;

  box-shadow:
    0.062em 0.062em 0.062em rgba(254, 255, 239, 0.61) inset,
    0 -0.062em 0.062em #969696 inset;
}

/* moon spots */
.theme-switch__spot {
  position: absolute;
  background: var(--spot-color);
  border-radius: 50%;
}

.theme-switch__spot:nth-child(1) {
  width: 0.75em;
  height: 0.75em;
  top: 0.75em;
  left: 0.312em;
}

.theme-switch__spot:nth-child(2) {
  width: 0.375em;
  height: 0.375em;
  top: 0.937em;
  left: 1.375em;
}

.theme-switch__spot:nth-child(3) {
  width: 0.25em;
  height: 0.25em;
  top: 0.312em;
  left: 0.812em;
}

/* ================= CLOUDS ================= */
.theme-switch__clouds {
  position: absolute;
  bottom: -0.25em; /* was -0.625em */
  left: 0.5em;

  width: 1.25em;
  height: 1.25em;

  background: var(--clouds-color);
  border-radius: 50%;

  z-index: 2; /* ✅ bring above background */

  transition: var(--transition);
  box-shadow:
    0.937em 0.312em var(--clouds-color),
    -0.312em -0.312em var(--back-clouds-color),
    1.437em 0.375em var(--clouds-color);
}

/* ================= STARS ================= */
.theme-switch__stars-container {
  position: absolute;
  top: -100%;
  left: 0.312em;
  color: var(--stars-color);
  transition: var(--transition);
}

/* ================= CHECKED STATE ================= */
.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-diameter) - var(--circle-container-offset)
  );
}

.theme-switch__checkbox:checked + .theme-switch__container
.theme-switch__moon {
  transform: translateX(0);
}

.theme-switch__checkbox:checked + .theme-switch__container
.theme-switch__clouds {
  bottom: -4em;
}

.theme-switch__checkbox:checked + .theme-switch__container
.theme-switch__stars-container {
  top: 50%;
  transform: translateY(-50%);
}
