/* =========================================================
   Starfruit Studio: Dark Mode – UI (Toggle Button) v2.0
   Supports: icon mode & switch mode
   Supports: menu placement & fixed corner placement
   ========================================================= */

/* --- Container --- */

.sf-darkmode-container {
  display: inline-flex;
  align-items: center;
}

/* --- Icon Toggle --- */

.sf-darkmode-toggle {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: #9aa4ad;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}

.sf-darkmode-toggle:hover {
  background: rgba(255,255,255,0.08);
}

.sf-darkmode-toggle:focus-visible {
  outline: 3px solid var(--sfdm-accent, #5cac43);
  outline-offset: 2px;
}

/* Icon */

.sf-icon::before {
  content: "☾";
  font-size: 20px;
  display: inline-block;
  transition: transform 0.3s ease, opacity 0.2s ease;
}

html[data-sf-theme="dark"] .sf-icon::before {
  content: "☀";
  color: #f0c040;
}

/* --- Switch Toggle --- */

[data-style="switch"] .sf-darkmode-toggle {
  width: auto;
  height: auto;
  border-radius: 0;
  padding: 4px;
}

.sf-switch-track {
  display: block;
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: #ccd0d4;
  position: relative;
  transition: background 0.25s ease;
}

html[data-sf-theme="dark"] .sf-switch-track {
  background: var(--sfdm-accent, #5cac43);
}

.sf-switch-thumb {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 3px;
  left: 3px;
  transition: transform 0.25s ease;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

html[data-sf-theme="dark"] .sf-switch-thumb {
  transform: translateX(20px);
}

/* --- Menu item placement --- */

li.sf-darkmode-menu-item {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  margin: 0 0 0 8px !important;
  height: 100% !important;
  list-style: none !important;
}

li.sf-darkmode-menu-item > .sf-darkmode-container {
  display: inline-flex;
  align-items: center;
}

/* --- Fixed position placement --- */

.sf-darkmode-fixed {
  position: fixed;
  z-index: 99999;
  pointer-events: auto;
}

.sf-darkmode-fixed .sf-darkmode-toggle {
  width: 48px;
  height: 48px;
  background: var(--sfdm-surface, #1c2a35);
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
  border: 1px solid rgba(255,255,255,0.1);
}

html[data-sf-theme="light"] .sf-darkmode-fixed .sf-darkmode-toggle {
  background: #fff;
  box-shadow: 0 2px 12px rgba(0,0,0,0.12);
  border: 1px solid rgba(0,0,0,0.08);
  color: #333;
}

.sf-darkmode-fixed .sf-darkmode-toggle:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.sf-darkmode-fixed--bottom-right {
  bottom: 24px;
  right: 24px;
}

.sf-darkmode-fixed--bottom-left {
  bottom: 24px;
  left: 24px;
}

.sf-darkmode-fixed--top-right {
  top: 24px;
  right: 24px;
}

.sf-darkmode-fixed--top-left {
  top: 24px;
  left: 24px;
}

/* --- Screen reader text --- */

.screen-reader-text {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* --- Print: disable dark mode --- */

@media print {
  html[data-sf-theme="dark"] body {
    background: #fff !important;
    color: #000 !important;
  }
  .sf-darkmode-container,
  .sf-darkmode-fixed {
    display: none !important;
  }
}

/* --- Reduced motion --- */

@media (prefers-reduced-motion: reduce) {
  .sf-darkmode-toggle,
  .sf-switch-thumb,
  .sf-switch-track,
  .sf-icon::before {
    transition: none !important;
  }
}
