/**
 * Theme Toggle — Pill-shaped switch
 *
 * A clearly visible slider toggle with sun/moon icons
 * injected into the navbar. Knob slides left ↔ right.
 *
 * Dependencies: child theme design tokens (style.css)
 */

/* ============================================
   MENU ITEM WRAPPER
   ============================================ */

/* When inside nav menu (before JS moves it) */
.theme-toggle-item {
	display: flex !important;
	align-items: center !important;
	margin-left: 0.75rem;
}

/* When repositioned by JS — direct child of header row */
header [data-row] > .theme-toggle {
	margin-left: 0.75rem;
	flex-shrink: 0;
}

/* ============================================
   TOGGLE BUTTON (reset)
   ============================================ */

.theme-toggle {
	position: relative;
	display: inline-flex;
	align-items: center;
	padding: 0;
	margin: 0;
	background: none;
	border: none;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

.theme-toggle:focus-visible {
	outline: 2px solid var(--color-accent);
	outline-offset: 4px;
	border-radius: 100px;
}

/* ============================================
   TRACK — The pill-shaped background
   ============================================ */

.theme-toggle__track {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: space-between;
	width: 64px;
	height: 32px;
	padding: 0 6px;
	background: var(--color-border);
	border: 1px solid var(--color-border-hover);
	border-radius: 100px;
	transition: background var(--transition-base),
	            border-color var(--transition-base);
}

.theme-toggle:hover .theme-toggle__track {
	border-color: var(--color-accent);
}

/* Light mode track */
[data-theme="light"] .theme-toggle__track {
	background: var(--color-border);
	border-color: var(--color-border-hover);
}

[data-theme="light"] .theme-toggle:hover .theme-toggle__track {
	border-color: var(--color-accent);
}

/* ============================================
   ICONS — Moon (left) & Sun (right)
   Fixed inside the track, visible behind the knob.
   ============================================ */

.theme-toggle__icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 16px;
	height: 16px;
	font-size: 0.75rem;
	z-index: 1;
	transition: opacity var(--transition-base);
}

/* Dark mode: moon dimmed (knob covers it), sun visible */
.theme-toggle__icon--moon {
	color: #fbbf24;
	opacity: 0.4;
}

.theme-toggle__icon--sun {
	color: #fbbf24;
	opacity: 1;
}

/* Light mode: moon visible, sun dimmed (knob covers it) */
[data-theme="light"] .theme-toggle__icon--moon {
	opacity: 1;
}

[data-theme="light"] .theme-toggle__icon--sun {
	opacity: 0.4;
}

/* ============================================
   KNOB — The sliding circle
   ============================================ */

.theme-toggle__knob {
	position: absolute;
	top: 3px;
	left: 3px;
	width: 26px;
	height: 26px;
	background: var(--color-bg-primary);
	border-radius: 50%;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
	transition: transform var(--transition-base),
	            background var(--transition-base);
	z-index: 2;
}

/* Light mode: slide knob to the right */
[data-theme="light"] .theme-toggle__knob {
	transform: translateX(32px);
	background: var(--color-bg-primary);
}

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

@media (max-width: 767px) {
	.theme-toggle__track {
		width: 56px;
		height: 28px;
		padding: 0 5px;
	}

	.theme-toggle__knob {
		width: 22px;
		height: 22px;
		top: 3px;
		left: 3px;
	}

	[data-theme="light"] .theme-toggle__knob {
		transform: translateX(28px);
	}

	.theme-toggle__icon {
		font-size: 0.625rem;
		width: 14px;
		height: 14px;
	}

	.theme-toggle-item {
		margin-left: 0.5rem;
	}
}

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

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