/* Light and dark reading switch for blog posts: a moon at night, a sun by day */
.blog-theme-toggle-wrap { margin-top: 1.5rem; }

.theme-switch {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: 0;
  padding: 4px;
  margin: 0 0 0 -4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  -webkit-tap-highlight-color: transparent;
}

.theme-switch-track {
  position: relative;
  display: block;
  width: 62px;
  height: 32px;
  border-radius: 999px;
  background: #141a14;
  border: 1px solid rgba(255, 255, 255, 0.18);
  overflow: hidden;
  transition: background-color 0.4s ease, border-color 0.4s ease;
}

.theme-switch:hover .theme-switch-track { border-color: #4a7c43; }
.theme-switch:focus-visible { outline: none; }
.theme-switch:focus-visible .theme-switch-track { outline: 2px solid #4a7c43; outline-offset: 3px; }

/* Stars for night */
.theme-switch-star {
  position: absolute;
  border-radius: 50%;
  background: #e8e4dc;
  transition: opacity 0.3s ease, transform 0.4s ease;
}
.theme-switch-star.s1 { width: 3px; height: 3px; top: 8px; right: 13px; opacity: 0.85; }
.theme-switch-star.s2 { width: 2px; height: 2px; top: 18px; right: 22px; opacity: 0.6; }
.theme-switch-star.s3 { width: 2px; height: 2px; top: 21px; right: 9px; opacity: 0.7; }

/* A small cloud for day */
.theme-switch-cloud {
  position: absolute;
  left: 8px;
  top: 16px;
  width: 15px;
  height: 6px;
  border-radius: 6px;
  background: #ffffff;
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.3s ease, transform 0.45s ease;
}
.theme-switch-cloud::before {
  content: "";
  position: absolute;
  left: 3px;
  top: -4px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ffffff;
}

/* The knob is a crescent moon by night and a sun by day */
.theme-switch-knob {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #e8e4dc;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  overflow: hidden;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.4s ease, box-shadow 0.4s ease;
}
.theme-switch-knob::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #141a14;
  top: -5px;
  left: 9px;
  transition: transform 0.4s ease;
}

/* Day */
.theme-switch[aria-checked="true"] .theme-switch-track {
  background: #8fbf86;
  border-color: rgba(0, 0, 0, 0.12);
}
.theme-switch[aria-checked="true"]:hover .theme-switch-track { border-color: #3f7838; }
.theme-switch[aria-checked="true"] .theme-switch-knob {
  transform: translateX(30px) rotate(180deg);
  background: #f5b941;
  box-shadow: 0 0 0 3px rgba(245, 185, 65, 0.3), 0 0 10px rgba(245, 185, 65, 0.6);
}
.theme-switch[aria-checked="true"] .theme-switch-knob::after { transform: translate(14px, -14px) scale(0); }
.theme-switch[aria-checked="true"] .theme-switch-star { opacity: 0; transform: translateY(6px); }
.theme-switch[aria-checked="true"] .theme-switch-cloud { opacity: 0.95; transform: translateX(0); }

@media (prefers-reduced-motion: reduce) {
  .theme-switch-track,
  .theme-switch-knob,
  .theme-switch-knob::after,
  .theme-switch-star,
  .theme-switch-cloud { transition: none; }
}
