/**
 * Iosevka Sawala Mono — Modern CSS Reset & Browser Surface Theming
 * Enforces box-sizing, dark-first canvas anchor, focus rings, custom scrollbars,
 * and WCAG 2.1 AA reduced-motion compliance (CON-002, CON-007).
 */

*,
*::before,
*::after {
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

html {
	background-color: var(--canvas);
	color: var(--ink);
	color-scheme: dark;
	font-family: var(--font-body);
	font-size: 16px;
	line-height: 1.5;
	letter-spacing: -0.05px;
	scroll-behavior: smooth;
	scroll-padding-top: calc(var(--nav-height) + var(--space-lg));
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	text-rendering: optimizeLegibility;
	-webkit-text-size-adjust: 100%;
	scrollbar-width: thin;
	scrollbar-color: var(--hairline-strong) var(--canvas);
}

body {
	min-height: 100vh;
	background-color: var(--canvas);
	color: var(--ink);
	font-family: var(--font-body);
	font-size: 16px;
	font-weight: 400;
	line-height: 1.5;
	letter-spacing: -0.05px;
	overflow-x: hidden;
	caret-color: var(--primary-hover);
}

/* Browser Surface Theming (Craft Floor: Selection, Scrollbars, Focus Rings) */
::selection {
	background-color: var(--primary);
	color: var(--on-primary);
}

::-webkit-scrollbar {
	width: 8px;
	height: 8px;
}

::-webkit-scrollbar-track {
	background: var(--canvas);
}

::-webkit-scrollbar-thumb {
	background-color: var(--surface-4);
	border: 1px solid var(--hairline);
	border-radius: var(--radius-xs);
}

::-webkit-scrollbar-thumb:hover {
	background-color: var(--hairline-strong);
}

/* Media & Interactive Resets */
img,
picture,
svg,
video,
canvas {
	display: block;
	max-width: 100%;
}

button,
input,
select,
textarea {
	font: inherit;
	color: inherit;
	background: none;
	border: none;
}

button {
	cursor: pointer;
}

ul,
ol {
	list-style: none;
}

a {
	color: inherit;
	text-decoration: none;
	text-underline-offset: 0.22em;
}

code,
kbd,
samp,
pre {
	font-family: var(--font-mono);
	font-variant-ligatures: normal;
	font-feature-settings: "calt" 1, "liga" 1;
}

/* Accessible Keyboard Focus Rings (DESIGN.md:427 & CON-007) */
:focus {
	outline: none;
}

:focus-visible {
	outline: 2px solid var(--primary-focus);
	outline-offset: 2px;
}

/* Skip Navigation Link for Screen Readers & Keyboard Users */
.skip-link {
	position: fixed;
	top: -100px;
	left: var(--space-md);
	z-index: 9999;
	background-color: var(--primary);
	color: var(--on-primary);
	font-family: var(--font-body);
	font-size: 14px;
	font-weight: 500;
	padding: var(--space-xs) var(--space-md);
	border-radius: var(--radius-md);
	transition: top 0.15s cubic-bezier(0.16, 1, 0.3, 1);
}

.skip-link:focus-visible {
	top: var(--space-sm);
}

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Reduced Motion Invariant (CON-007 & Spec §7) */
@media (prefers-reduced-motion: reduce) {
	html {
		scroll-behavior: auto;
	}

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