/* ===========================================
   xav.ai Shared Styles
   =========================================== */

/* CSS Variables - Light Theme (default) */
:root {
	--bg: #fff;
	--text: #111;
	--text-muted: #666;
	--link-underline: #999;
	--link-underline-hover: #111;
	--toggle-bg: #e0e0e0;
	--toggle-knob: #fff;
}

/* Dark Theme (system preference) */
@media (prefers-color-scheme: dark) {
	:root {
		--bg: #1a1a1a;
		--text: #eee;
		--text-muted: #999;
		--link-underline: #666;
		--link-underline-hover: #eee;
		--toggle-bg: #444;
		--toggle-knob: #1a1a1a;
	}
}

/* Light Theme (explicit) */
[data-theme="light"] {
	--bg: #fff;
	--text: #111;
	--text-muted: #666;
	--link-underline: #999;
	--link-underline-hover: #111;
	--toggle-bg: #e0e0e0;
	--toggle-knob: #fff;
}

/* Dark Theme (explicit) */
[data-theme="dark"] {
	--bg: #1a1a1a;
	--text: #eee;
	--text-muted: #999;
	--link-underline: #666;
	--link-underline-hover: #eee;
	--toggle-bg: #444;
	--toggle-knob: #1a1a1a;
}

/* Base Reset */
* {
	box-sizing: border-box;
}

/* Body */
body {
	font-family: 'Source Sans Pro', sans-serif;
	margin: 0;
	padding: clamp(1.5rem, 5vw, 4rem);
	line-height: 1.7;
	background-color: var(--bg);
	color: var(--text);
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	align-items: center;
	transition: background-color 0.3s ease, color 0.3s ease;
}

/* Content Containers */
header,
main {
	width: 100%;
	max-width: 650px;
}

/* Typography */
h1 {
	font-size: clamp(2.5rem, 8vw, 4rem);
	font-weight: 300;
	margin-bottom: 1.5rem;
	letter-spacing: -0.02em;
}

h2 {
	font-size: clamp(1.5rem, 5vw, 2rem);
	font-weight: 300;
	margin-bottom: 1rem;
	letter-spacing: -0.01em;
}

p {
	font-size: clamp(1.1rem, 3vw, 1.35rem);
	margin-bottom: 1.25rem;
}

/* Links */
a {
	color: var(--text);
	text-decoration-color: var(--link-underline);
	text-underline-offset: 0.15em;
	transition: text-decoration-color 0.2s ease, transform 0.2s ease, text-shadow 0.2s ease;
	display: inline-block;
}

a:hover {
	text-decoration-color: var(--link-underline-hover);
	transform: translateY(-1px);
	text-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

a:focus {
	outline: 2px solid var(--link-underline-hover);
	outline-offset: 3px;
	border-radius: 2px;
}

a:focus:not(:focus-visible) {
	outline: none;
}

a:focus-visible {
	outline: 2px solid var(--link-underline-hover);
	outline-offset: 3px;
	border-radius: 2px;
}

/* Small Text */
small {
	display: block;
	margin-top: 2.5rem;
	font-size: clamp(0.9rem, 2.5vw, 1rem);
	color: var(--text-muted);
}

/* Theme Toggle */
.theme-toggle {
	position: fixed;
	top: 1rem;
	right: 1rem;
	display: flex;
	align-items: center;
	gap: 0.5rem;
	z-index: 100;
}

.theme-toggle span {
	font-size: 1rem;
	opacity: 0.6;
	transition: opacity 0.2s ease;
}

.theme-toggle span.active {
	opacity: 1;
}

.toggle-switch {
	position: relative;
	width: 50px;
	height: 26px;
	background: var(--toggle-bg);
	border-radius: 13px;
	cursor: pointer;
	transition: background-color 0.3s ease;
	border: none;
	padding: 0;
}

.toggle-switch::after {
	content: '';
	position: absolute;
	top: 3px;
	left: 3px;
	width: 20px;
	height: 20px;
	background: var(--toggle-knob);
	border-radius: 50%;
	transition: transform 0.3s ease, background-color 0.3s ease;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .toggle-switch::after,
@media (prefers-color-scheme: dark) {
	.toggle-switch::after {
		transform: translateX(24px);
	}
}

[data-theme="light"] .toggle-switch::after {
	transform: translateX(0);
}

[data-theme="dark"] .toggle-switch::after {
	transform: translateX(24px);
}

/* Text Selection Colors */
::selection {
	background: rgba(167, 139, 250, 0.3);
	color: var(--text);
}

[data-theme="dark"] ::selection {
	background: rgba(167, 139, 250, 0.4);
}

/* Page Fade-in Animation */
header,
main,
.theme-toggle {
	animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
	from {
		opacity: 0;
		transform: translateY(10px);
	}

	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {

	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
	}
}
