/**
 * [hafez_dark_light_switcher] — dark / light switcher of the site.
 *
 * «استایل اول» (.hafez-dls--simple) is a plain switch; «استایل دوم»
 * (.hafez-dls--animated) is the sun / moon toggle from the design file,
 * scoped under .hafez-dls--animated so its rules never reach the page.
 * Width: --hafez-dls-width (shortcode size="…").
 */

.hafez-dls {
	display: inline-flex;
	vertical-align: middle;
	line-height: 0;
	/* Drawn left to right; an RTL page must not mirror the parts inside. */
	direction: ltr;
}

/* Themes and the Elementor kit style every button; the switcher keeps its own look. */
.hafez-dls button {
	all: unset;
	box-sizing: border-box;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

.hafez-dls button:focus-visible {
	outline: 2px solid var(--hafez-color-focus, #2563eb);
	outline-offset: 3px;
}

/* No slide on page load: the state is set before the switch is shown. */
.hafez-dls:not(.is-ready),
.hafez-dls:not(.is-ready) * {
	transition: none !important;
}

/* «استایل اول» ---------------------------------------------------------- */

.hafez-dls--simple {
	--width: var(--hafez-dls-width, 52px);
}

.hafez-dls--simple .hafez-dls__switch {
	position: relative;
	display: inline-block;
	width: var(--width);
	height: calc(var(--width) * 0.54);
	border-radius: 999px;
	background: #d6cdc6;
	transition: background 0.2s ease;
}

.hafez-dls--simple .hafez-dls__thumb {
	position: absolute;
	top: calc(var(--width) * 0.05);
	left: calc(var(--width) * 0.05);
	display: grid;
	place-items: center;
	width: calc(var(--width) * 0.44);
	height: calc(var(--width) * 0.44);
	border-radius: 50%;
	background: #fff;
	color: #f59e0b;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
	transition: transform 0.2s ease, color 0.2s ease;
}

.hafez-dls--simple .hafez-dls__icon {
	display: grid;
	place-items: center;
	grid-area: 1 / 1;
	width: 70%;
	height: 70%;
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.hafez-dls--simple .hafez-dls__icon svg {
	width: 100%;
	height: 100%;
}

.hafez-dls--simple .hafez-dls__icon--moon {
	opacity: 0;
	transform: rotate(-60deg) scale(0.6);
}

.hafez-dls--simple [aria-checked="true"] {
	background: var(--hafez-color-primary, #1f2937);
}

.hafez-dls--simple [aria-checked="true"] .hafez-dls__thumb {
	color: #1f2937;
	transform: translateX(calc(var(--width) * 0.46));
}

.hafez-dls--simple [aria-checked="true"] .hafez-dls__icon--sun {
	opacity: 0;
	transform: rotate(60deg) scale(0.6);
}

.hafez-dls--simple [aria-checked="true"] .hafez-dls__icon--moon {
	opacity: 1;
	transform: none;
}

/* «استایل دوم» (from the design file, scoped) --------------------------- */

/* The reset above leaves the button inline; the toggle needs a box for its width. */
.hafez-dls--animated .toggle {
	display: block;
}

.hafez-dls--animated *,
.hafez-dls--animated *:after,
.hafez-dls--animated *:before {
	box-sizing: border-box;
}

.hafez-dls--animated {
  --slide-ease: cubic-bezier(.4,-0.3,.6,1.3);

	--easing: var(--slide-ease);
	--speed: 0.5s;
	--width: var(--hafez-dls-width, 140px);
	--ar: 8 / 3;
	--ray: hsl(0 0% 100% / 0.5);
	--sun: hsl(47, 91%, 58%);
	--moon: hsl(212, 13%, 82%);
	--crater: hsl(221, 16%, 68%);
	--bg: hsl(219, 30%, 88%);
	--bear-speed: 10s;
  --color: hsl(219 30% 20%);
}

.hafez-dls--animated .toggle__backdrop:first-of-type .clouds path:first-of-type {
	fill: var(--ray);
}

.hafez-dls--animated .toggle {
  -webkit-tap-highlight-color: transparent;
	width: var(--width);
  
  z-index: 10;
  will-change: transform;
  isolation: isolate;
  transform: translate3d(0, 0, 0);
  
	aspect-ratio: var(--ar);
	border-radius: 100vh;
	border: 0;
	position: relative;
	padding: 0;
	overflow: hidden;
	cursor: pointer;
	transition: background var(--speed) var(--easing);
	--sky: hsl(204, 53%, 47%);
	--night: hsl(229, 25%, 16%);
	outline-color: transparent;
	background: hsl(
		calc(204 + (var(--dark, 0) * 25))
		calc((53 - (var(--dark, 0) * 28)) * 1%)
		calc((47 - (var(--dark, 0) * 31)) * 1%)
	);
	box-shadow:
		calc(var(--width) * 0) calc(var(--width) * 0.02) calc(var(--width) * 0.01) calc(var(--width) * -0.0025) hsl(210 10% 100% / 0.95),
		calc(var(--width) * 0) calc(var(--width) * -0.02) calc(var(--width) * 0.01) calc(var(--width) * -0.0025) hsl(210 10% 10% / 0.2),
		calc(var(--width) * 0) calc(var(--width) * 0.02) calc(var(--width) * 0.5) 0 hsl(210 10% 100% / 0.15);
}

.hafez-dls--animated .toggle:after {
	content: "";
	position: absolute;
	inset: 0;
	box-shadow:
		calc(var(--width) * 0) calc(var(--width) * -0.025) calc(var(--width) * 0.025) 0 hsl(210 10% 10% / 0.15) inset,
		calc(var(--width) * 0) calc(var(--width) * 0.025) calc(var(--width) * 0.025) 0 hsl(210 10% 10% / 0.65) inset;
	border-radius: 100vh;
}

.hafez-dls--animated .toggle__content {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  border-radius: 100vh;
  display: block;
  clip-path: inset( 0 0 0 0 round 100vh);
  container-type: inline-size;
}

.hafez-dls--animated .toggle__backdrop {
  overflow: visible !important;
	position: absolute;
	bottom: 0;
	width: 100%;
	left: 0;
	transition: translate var(--speed) var(--easing);
	translate: 0 calc(
		var(--dark, 0) * (100% - (3 / 8 * var(--width)))
	);
}

.hafez-dls--animated [aria-pressed=false] .toggle__backdrop:last-of-type {
	transition-timing-function: cubic-bezier(.2,-0.6,.7,1.6);
}

.hafez-dls--animated [aria-pressed=false] .stars path {
	transition-delay: 0s;
}

.hafez-dls--animated .stars path {
	transform-box: fill-box;
	transform-origin: 25% 50%;
	scale: calc(0.25 + (var(--dark, 0) * 0.75));
	transition: scale var(--speed) calc(var(--speed) * 0.5) var(--easing);
}

.hafez-dls--animated .toggle__indicator {
	height: 100%;
	aspect-ratio: 1;
	border-radius: 0%;
	display: grid;
	place-items: center;
	padding: 3%;
  transition: translate var(--speed) var(--slide-ease);
  translate: calc(var(--dark, 0) * (100cqi - 100%)) 0;
}

.hafez-dls--animated .pilot-bear {
	position: absolute;
	width: 25%;
}

.hafez-dls--animated .toggle__star {
	height: 100%;
	aspect-ratio: 1;
	border-radius: 50%;
	position: relative;
	transition: translate var(--speed) var(--easing);
	translate: calc((var(--dark, 0) * -10%) + 5%) 0;

}

.hafez-dls--animated .sun {
	background: var(--sun);
	position: absolute;
	inset: 0;
	border-radius: 50%;
	overflow: hidden;
	box-shadow:
		calc(var(--width) * 0.01) calc(var(--width) * 0.01) calc(var(--width) * 0.02) 0 hsl(210 10% 100% / 0.95) inset,
		calc(var(--width) * -0.01) calc(var(--width) * -0.01) calc(var(--width) * 0.02) 0 hsl(210 10% 20% / 0.5) inset;
}

.hafez-dls--animated .moon {
	position: absolute;
	inset: -1%;
	border-radius: 50%;
	background: var(--moon);
  transition: translate var(--speed) ease-in-out;
	translate: calc((100 - (var(--dark, 0) * 100)) * 1%) 0%;
	box-shadow:
		calc(var(--width) * 0.01) calc(var(--width) * 0.01) calc(var(--width) * 0.02) 0 hsl(210 10% 100% / 0.95) inset,
		calc(var(--width) * -0.01) calc(var(--width) * -0.01) calc(var(--width) * 0.02) 0 hsl(210 10% 10% / 0.95) inset;
}

.hafez-dls--animated .moon__crater {
	position: absolute;
	background: var(--crater);
	border-radius: 50%;
	width: calc(var(--size, 10) * 1%);
	aspect-ratio: 1;
	left: calc(var(--x) * 1%);
	top: calc(var(--y) * 1%);
	box-shadow:
		calc(var(--width) * 0.01) calc(var(--width) * 0.01) calc(var(--width) * 0.01) 0 hsl(210 10% 6% / 0.25) inset,
		0 calc(var(--width) * 0.005) calc(var(--width) * 0.01) 0 hsl(210 10% 100% / 0.25);
}

.hafez-dls--animated .moon__crater:nth-of-type(1) {
	--size: 18;
	--x: 40;
	--y: 15;
}

.hafez-dls--animated .moon__crater:nth-of-type(2) {
	--size: 20;
	--x: 65;
	--y: 58;
}

.hafez-dls--animated .moon__crater:nth-of-type(3) {
	--size: 34;
	--x: 18;
	--y: 40;
}

.hafez-dls--animated .toggle__star:before {
	content: "";
	z-index: -1;
	width: 356%;
	background:
		radial-gradient(hsl(0 0% 100% / 0.25) 40%, transparent 40.5%),
		radial-gradient(hsl(0 0% 100% / 0.25) 56%, transparent 56.5%)
	  hsl(0 0% 100% / 0.25);
	border-radius: 50%;
	aspect-ratio: 1;
	position: absolute;
	top: 50%;
	left: 50%;
	transition: translate var(--speed) var(--easing);
	translate: calc(
		(50 - (var(--dark, 0) * 4)) *
		-1%
	)
	-50%;
}

.hafez-dls--animated .toggle__star:after {
	content: "";
	position: absolute;
	inset: 0;
	display: block;
	background: hsl(0 0% 0% / 0.5);
	filter: blur(4px);
	translate: 2% 4%;
	border-radius: 50%;
	z-index: -1;
}

.hafez-dls--animated .toggle__indicator-wrapper {
	position: absolute;
	inset: 0;
}

.hafez-dls--animated [aria-pressed=true] {
	--dark: 1;
}

.hafez-dls--animated .stars g {
	transform-box: fill-box;
	transform-origin: 50% 50%;
}

.hafez-dls--animated .stars g:nth-of-type(3) {
	animation: hafez-dls-twinkle 4s -2s infinite;
}

.hafez-dls--animated .stars g:nth-of-type(11) {
	animation: hafez-dls-twinkle 6s -2s infinite;
}

.hafez-dls--animated .stars g:nth-of-type(9) {
	animation: hafez-dls-twinkle 4s -1s infinite;
}

@keyframes hafez-dls-twinkle {
	0%, 40%, 60%, 100% {
		transform: scale(1);
	}
	50% {
		transform: scale(0);
	}
}

.hafez-dls--animated .astrobear {
	width: 12%;
	position: absolute;
	top: 100%;
	left: 0%;
	transition: translate calc(var(--speed) + (var(--dark, 0) * (var(--bear-speed) - var(--speed))))
		calc(var(--bear-speed) * (0.4 * var(--dark, 0))) linear;
	translate: calc(var(--dark, 0) * 400%) calc(var(--dark, 0) * -350%);
}

.hafez-dls--animated .astrobear svg {
	transform-origin: 50% 75%;
	scale: var(--dark, 0);
	rotate: calc(var(--dark, 0) * 360deg);
	transition: rotate calc(var(--speed) + (var(--dark, 0) * (var(--bear-speed) - var(--speed)))) calc(var(--bear-speed) * 0.4) linear, scale var(--speed) ease-in-out;
}

.hafez-dls--animated .astrobear__container {
	position: absolute;
	overflow: hidden;
	inset: 0;
	clip-path: inset(0 0 0 0);
	opacity: var(--dark, 0);
	translate: 0 calc(-200% + (var(--dark, 0) * 200%));
	transition: opacity var(--speed) var(--easing), translate var(--speed) var(--easing);
}

.hafez-dls--animated .pilot__container {
	position: absolute;
	overflow: hidden;
	inset: 0;
	clip-path: inset(0 0 0 0);
	opacity: calc(1 - var(--dark, 0));
	translate: 0 calc(var(--dark, 0) * 200%);
	transition: opacity var(--speed) var(--easing), translate var(--speed) var(--easing);
}

.hafez-dls--animated .pilot-bear {
	width: 18%;
	position: absolute;
	top: 70%;
	left: 100%;
	transition:
		translate
			calc(
				var(--speed) + ((1 - var(--dark, 0)) *
					((var(--bear-speed) * 0.5) - var(--speed))))
			calc((var(--bear-speed) * 0.5) * ((1 - var(--dark, 0)) * 0.4)) linear;
	translate:
		calc(
			(0 - (1 - var(--dark, 0))) * (var(--width) + 100%)
		) calc(
		(0 - (1 - var(--dark, 0))) * (200%)
	);
}

.hafez-dls--animated .pilot {
	rotate: 12deg;
	animation: hafez-dls-fly 4s infinite ease-in-out;
}

@keyframes hafez-dls-fly {
	50% { translate: 0 -25%; }
}
