/* GP Theme Switcher — toggle button styling. */

.ms4gp-toggle {
	display: inline-flex;
	align-items: center;
	gap: 0.4em;
	padding: var(--ms4gp-btn-padding-y, 0.45em) var(--ms4gp-btn-padding-x, 0.6em);
	margin: 0;
	border: 1px solid var(--contrast-3, #b2b2be);
	border-radius: var(--ms4gp-btn-radius, 6px);
	background: var(--ms4gp-btn-bg-light, var(--base-3, #fff));
	color: var(--ms4gp-btn-color-light, var(--contrast, #222));
	cursor: pointer;
	line-height: 1;
	transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.ms4gp-toggle:hover,
.ms4gp-toggle:focus-visible {
	border-color: var(--accent, #1e73be);
	color: var(--accent, #1e73be);
}

.ms4gp-toggle__icon,
.ms4gp-toggle__label {
	display: none;
	align-items: center;
}

.ms4gp-toggle__svg,
.ms4gp-toggle__img {
	display: block;
	width: var(--ms4gp-btn-icon-size, 20px);
	height: var(--ms4gp-btn-icon-size, 20px);
}

/* Reveal the icon/label matching the active mode. */
html[data-ms4gp="light"] .ms4gp-toggle__icon--light,
html[data-ms4gp="light"] .ms4gp-toggle__label--light,
html[data-ms4gp="dark"] .ms4gp-toggle__icon--dark,
html[data-ms4gp="dark"] .ms4gp-toggle__label--dark,
html:not([data-ms4gp]) .ms4gp-toggle__icon--light,
html:not([data-ms4gp]) .ms4gp-toggle__label--light {
	display: inline-flex;
}

/* Navigation variant — strip all button chrome; inherit nav menu item styles. */
.ms4gp-toggle--nav {
	border: none;
	border-radius: 0;
	background: transparent;
	color: inherit;
	padding: 0;
	line-height: inherit;
}

/* Icon sizes at 1em so they scale with the nav's font-size. */
.ms4gp-toggle--nav .ms4gp-toggle__svg,
.ms4gp-toggle--nav .ms4gp-toggle__img {
	width: 1em;
	height: 1em;
}

.ms4gp-nav-toggle {
	display: inline-flex;
	align-items: center;
}

/* Floating variant. */
.ms4gp-floating {
	position: fixed;
	z-index: 9999;
}

.ms4gp-floating--bottom-right { right: var(--ms4gp-offset-x, 1.25rem); bottom: var(--ms4gp-offset-y, 1.25rem); }
.ms4gp-floating--bottom-left  { left:  var(--ms4gp-offset-x, 1.25rem); bottom: var(--ms4gp-offset-y, 1.25rem); }
.ms4gp-floating--top-right    { right: var(--ms4gp-offset-x, 1.25rem); top:    var(--ms4gp-offset-y, 1.25rem); }
.ms4gp-floating--top-left     { left:  var(--ms4gp-offset-x, 1.25rem); top:    var(--ms4gp-offset-y, 1.25rem); }

.ms4gp-toggle--floating {
	border-radius: 50%;
	width: 3rem;
	height: 3rem;
	padding: 0;
	justify-content: center;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* When a label shows in the floating button, allow it to grow into a pill. */
.ms4gp-toggle--floating:has(.ms4gp-toggle__label) {
	width: auto;
	border-radius: 999px;
	padding: 0.45em 1em;
}

/* ── Switch style (pill track + sliding thumb) ───────────────────────── */

.ms4gp-toggle--switch {
	padding: 0;
	border: none;
	background: transparent;
	gap: 0.5em;
}

.ms4gp-switch__track {
	position: relative;
	display: inline-flex;
	align-items: center;
	width: 3.25rem;
	height: 1.75rem;
	border-radius: 999px;
	flex-shrink: 0;
	background: var(--ms4gp-switch-bg-light, var(--contrast-3, #b2b2be));
	transition: background-color 0.25s ease;
}

html[data-ms4gp="dark"] .ms4gp-switch__track {
	background: var(--ms4gp-switch-bg-dark, var(--accent, #1e73be));
}

/* Thumb — slides from left (light) to right (dark). */
/* Travel = track-width − thumb-width − 2 × inset = 3.25rem − 1.375rem − 0.375rem = 1.5rem */
.ms4gp-switch__thumb {
	position: absolute;
	left: 0.1875rem;
	width: 1.375rem;
	height: 1.375rem;
	border-radius: 50%;
	background: var(--base-3, #fff);
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.25s ease;
}

html[data-ms4gp="dark"] .ms4gp-switch__thumb {
	transform: translateX(1.5rem);
}

/* Thumb icons — show only the active mode's icon. */
.ms4gp-switch__thumb-icon {
	display: none;
	align-items: center;
	justify-content: center;
	width: 14px;
	height: 14px;
}

html[data-ms4gp="light"] .ms4gp-switch__thumb-icon--light,
html:not([data-ms4gp]) .ms4gp-switch__thumb-icon--light {
	display: inline-flex;
}

html[data-ms4gp="dark"] .ms4gp-switch__thumb-icon--dark {
	display: inline-flex;
}

.ms4gp-switch__thumb-icon .ms4gp-toggle__svg,
.ms4gp-switch__thumb-icon .ms4gp-toggle__img {
	width: 14px;
	height: 14px;
}

/* Track-ends icon placement (.ms4gp-toggle--switch-ends). */
.ms4gp-toggle--switch-ends .ms4gp-switch__track {
	width: 4rem;
	padding: 0 0.3rem;
	justify-content: space-between;
}

/* In ends mode the thumb sits between flex children — pull it out of absolute flow. */
.ms4gp-toggle--switch-ends .ms4gp-switch__thumb {
	position: relative;
	left: auto;
	flex-shrink: 0;
}

.ms4gp-switch__end {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 14px;
	height: 14px;
	flex-shrink: 0;
	opacity: 0.5;
	transition: opacity 0.25s ease;
}

.ms4gp-switch__end .ms4gp-toggle__svg,
.ms4gp-switch__end .ms4gp-toggle__img {
	width: 12px;
	height: 12px;
}

/* Active end is fully opaque. */
html[data-ms4gp="light"] .ms4gp-switch__end--light,
html:not([data-ms4gp]) .ms4gp-switch__end--light {
	opacity: 1;
}

html[data-ms4gp="dark"] .ms4gp-switch__end--dark {
	opacity: 1;
}

/* Floating + switch: strip the circle shape from the button; the .ms4gp-floating
   wrapper provides the pill/shadow around the track instead. */
.ms4gp-toggle--switch.ms4gp-toggle--floating {
	width: auto;
	height: auto;
	border-radius: 0;
	box-shadow: none;
	padding: 0.5rem;
}

.ms4gp-floating:has(.ms4gp-toggle--switch) {
	border-radius: 999px;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
	background: var(--base-3, #fff);
}

/* Strip the base hover accent-color change — switch has its own hover feedback. */
.ms4gp-toggle--switch:hover {
	color: inherit;
	border-color: transparent;
}

/* Focus ring on the track instead of the button outline. */
.ms4gp-toggle--switch:focus-visible {
	outline: none;
	color: inherit;
	border-color: transparent;
}

.ms4gp-toggle--switch:focus-visible .ms4gp-switch__track {
	outline: 2px solid var(--accent, #1e73be);
	outline-offset: 2px;
}

/* ── Dark-mode button bg / color (button-style only; switch + nav excluded) ── */
html[data-ms4gp="dark"] .ms4gp-toggle:not(.ms4gp-toggle--switch):not(.ms4gp-toggle--nav) {
	background: var(--ms4gp-btn-bg-dark, var(--base-3, #fff));
	color: var(--ms4gp-btn-color-dark, var(--contrast, #222));
}

@media (prefers-reduced-motion: reduce) {
	.ms4gp-switch__track,
	.ms4gp-switch__thumb,
	.ms4gp-switch__end {
		transition: none;
	}
}
