/**
 * Rizon Theme Mode - Toggle CSS
 * Compact, premium theme switcher button.
 * Works in both light and dark contexts.
 */

/* ================================
   TOGGLE BUTTON BASE
   ================================ */

.rizon-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  text-decoration: none;
}

/* High-contrast focus ring */
.rizon-theme-toggle:focus-visible {
  outline: 2px solid var(--rizon-focus-ring, #2563EB);
  outline-offset: 3px;
}

/* Active/pressed state */
.rizon-theme-toggle:active {
  transform: scale(0.94);
}

/* ================================
   TOGGLE ICON SLOTS
   ================================ */

.rizon-theme-toggle__icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition:
    opacity 0.25s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.rizon-theme-toggle__icon svg {
  flex-shrink: 0;
}

/* ================================
   SUN ICON (shown in dark mode = switch to light)
   ================================ */

html[data-rizon-theme="dark"] .rizon-theme-toggle__icon--sun {
  opacity: 0;
  transform: scale(0.5) rotate(-90deg);
}

html[data-rizon-theme="dark"] .rizon-theme-toggle:hover .rizon-theme-toggle__icon--sun {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

html[data-rizon-theme="dark"] .rizon-theme-toggle__icon--moon {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

html[data-rizon-theme="dark"] .rizon-theme-toggle:hover .rizon-theme-toggle__icon--moon {
  opacity: 0;
  transform: scale(0.5) rotate(90deg);
}

/* ================================
   MOON ICON (shown in light mode = switch to dark)
   ================================ */

html[data-rizon-theme="light"] .rizon-theme-toggle__icon--moon {
  opacity: 0;
  transform: scale(0.5) rotate(-90deg);
}

html[data-rizon-theme="light"] .rizon-theme-toggle:hover .rizon-theme-toggle__icon--moon {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

html[data-rizon-theme="light"] .rizon-theme-toggle__icon--sun {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

html[data-rizon-theme="light"] .rizon-theme-toggle:hover .rizon-theme-toggle__icon--sun {
  opacity: 0;
  transform: scale(0.5) rotate(90deg);
}

/* ================================
   THEME TRANSITION OVERLAY
   ================================ */

/* Smooth page transition effect */
html[data-rizon-theme] {
  transition:
    background-color 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Disable transitions on initial page load to prevent theme flash */
html:not(.js-rizon-ready) {
  transition: none !important;
}

html:not(.js-rizon-ready) * {
  transition: none !important;
}

/* ================================
   DARK MODE TOGGLE STYLES
   ================================ */

html[data-rizon-theme="dark"] .rizon-theme-toggle {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(113, 169, 255, 0.18);
  color: rgba(255, 255, 255, 0.75);
}

html[data-rizon-theme="dark"] .rizon-theme-toggle:hover {
  background: rgba(255, 255, 255, 0.10);
  border-color: rgba(113, 169, 255, 0.35);
  color: #fff;
}

html[data-rizon-theme="dark"] .rizon-theme-toggle:active {
  background: rgba(255, 255, 255, 0.08);
}

/* ================================
   LIGHT MODE TOGGLE STYLES
   ================================ */

html[data-rizon-theme="light"] .rizon-theme-toggle {
  background: #EDF3FA;
  border-color: #D4DEEA;
  color: #4A5D72;
}

html[data-rizon-theme="light"] .rizon-theme-toggle:hover {
  background: #E1E8F0;
  border-color: #B8C9DA;
  color: #1A2B3E;
}

html[data-rizon-theme="light"] .rizon-theme-toggle:active {
  background: #D8E3EE;
}

/* ================================
   RESPONSIVE SIZING
   ================================ */

@media (max-width: 480px) {
  .rizon-theme-toggle {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }

  .rizon-theme-toggle__icon svg {
    width: 16px;
    height: 16px;
  }
}

/* Large touch targets on mobile */
@media (pointer: coarse) {
  .rizon-theme-toggle {
    min-width: 44px;
    min-height: 44px;
  }
}

/* ================================
   REDUCED MOTION
   ================================ */

@media (prefers-reduced-motion: reduce) {
  .rizon-theme-toggle__icon {
    transition: none;
  }

  html[data-rizon-theme] {
    transition: none !important;
  }

  html[data-rizon-theme] * {
    transition: none !important;
  }

  /* Show both icons statically in reduced motion mode */
  html[data-rizon-theme="dark"] .rizon-theme-toggle__icon--sun,
  html[data-rizon-theme="dark"] .rizon-theme-toggle__icon--moon,
  html[data-rizon-theme="light"] .rizon-theme-toggle__icon--sun,
  html[data-rizon-theme="light"] .rizon-theme-toggle__icon--moon {
    opacity: 1;
    transform: none;
  }

  /* Show only the active one in reduced motion */
  html[data-rizon-theme="dark"] .rizon-theme-toggle__icon--sun {
    opacity: 0;
  }

  html[data-rizon-theme="light"] .rizon-theme-toggle__icon--moon {
    opacity: 0;
  }
}

/* ================================
   FLOATING VARIANT (CART PAGE)
   ================================ */

.rizon-theme-toggle-floating {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  box-shadow: var(--rizon-shadow-md, 0 8px 24px rgba(0,0,0,0.15));
}

/* Ensure the floating toggle is always on top */
.rizon-theme-toggle-floating:focus-visible {
  outline: 2px solid var(--rizon-focus-ring, #2563EB);
  outline-offset: 3px;
  z-index: 99999;
}

/* Mobile adjustments */
@media (max-width: 480px) {
  .rizon-theme-toggle-floating {
    bottom: 20px;
    right: 20px;
  }
}

/* ================================
   PRINT
   ================================ */

@media print {
  .rizon-theme-toggle {
    display: none;
  }
}