/*
 * Theme toggle button (shared by all pages)
 * A sun that morphs into a crescent moon, boxed like the menu tabs.
 */
:root {
  --toggle-fg: #388e3c;
  --toggle-bg: #ffffff;
  --toggle-shadow: #1b5e20;
}

[data-theme="dark"] {
  --toggle-fg: #00e676;
  --toggle-bg: #282c34;
  --toggle-shadow: #00a152;
}

.theme-toggle {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--toggle-fg);
  background-color: var(--toggle-bg);
  border: 1px solid var(--toggle-fg);
  border-radius: 10px;
  box-shadow: 4px 4px 0 var(--toggle-shadow);
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease,
              color 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
}

.theme-toggle:hover {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--toggle-shadow);
}

.theme-toggle:active {
  transform: translate(4px, 4px);
  box-shadow: 0 0 0 var(--toggle-shadow);
}

.theme-toggle:focus-visible {
  outline: 2px dashed var(--toggle-fg);
  outline-offset: 4px;
}

.theme-toggle svg {
  width: 24px;
  height: 24px;
  overflow: visible;
}

/* Sun/moon parts: scale and rotate around the icon centre */
.theme-toggle-disc,
.theme-toggle-cutout,
.theme-toggle-rays {
  transform-origin: 12px 12px;
  transition: transform 0.5s cubic-bezier(0.5, 1.5, 0.5, 1), opacity 0.3s ease;
}

/* Light theme: small sun with rays, moon cutout parked off the disc */
.theme-toggle-disc {
  transform: scale(0.55);
}
.theme-toggle-cutout {
  transform: translate(8px, -8px);
}

/* Dark theme: rays retract, disc grows and the cutout carves a crescent */
[data-theme="dark"] .theme-toggle-disc {
  transform: scale(1);
}
[data-theme="dark"] .theme-toggle-cutout {
  transform: translate(0, 0);
}
[data-theme="dark"] .theme-toggle-rays {
  transform: rotate(45deg) scale(0.4);
  opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle,
  .theme-toggle-disc,
  .theme-toggle-cutout,
  .theme-toggle-rays {
    transition: none;
  }
}

@media screen and (max-width: 768px) {
  .theme-toggle {
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    box-shadow: 3px 3px 0 var(--toggle-shadow);
  }

  .theme-toggle svg {
    width: 20px;
    height: 20px;
  }
}
