/**
 * Sanaa base: reset, typography, layout primitives, accessibility.
 * Everything consumes tokens — no hardcoded palette values.
 */

/* ---------------------------------------------------------------- Reset */

*,
*::before,
*::after {
	box-sizing: border-box;
}

html {
	text-size-adjust: 100%;
	scroll-behavior: smooth;
	scroll-padding-top: 88px;
}

/* Admin bar adds 32px above the sticky header. */
html:has(> body.admin-bar) {
	scroll-padding-top: 120px;
}

body {
	margin: 0;
	font-family: var(--sanaa-font-body);
	font-size: var(--sanaa-text-base);
	font-weight: var(--sanaa-body-weight);
	line-height: var(--sanaa-leading-body);
	color: var(--sanaa-text);
	background-color: var(--sanaa-bg);
	-webkit-font-smoothing: antialiased;
}

img,
video,
svg {
	display: block;
	max-width: 100%;
	height: auto;
}

figure {
	margin: 0;
}

a {
	color: var(--sanaa-primary);
	text-decoration-thickness: 1px;
	text-underline-offset: 0.18em;
	transition: color var(--sanaa-duration) var(--sanaa-ease);
}

a:hover {
	color: var(--sanaa-heading-color);
}

/* --------------------------------------------------------- Typography */

h1,
h2,
h3,
h4,
h5,
h6 {
	font-family: var(--sanaa-font-heading);
	font-weight: var(--sanaa-heading-weight);
	line-height: var(--sanaa-leading-tight);
	text-transform: var(--sanaa-heading-transform);
	letter-spacing: var(--sanaa-heading-tracking);
	color: var(--sanaa-heading-color);
	margin: 0 0 0.5em;
	text-wrap: balance;
}

h1 {
	font-size: var(--sanaa-display-md);
}

h2 {
	font-size: var(--sanaa-display-sm);
}

h3 {
	font-size: var(--sanaa-text-xl);
}

h4 {
	font-size: var(--sanaa-text-lg);
}

p {
	margin: 0 0 1.25em;
}

strong {
	font-weight: 600;
	color: var(--sanaa-heading-color);
}

blockquote {
	margin: 2em 0;
	padding: 0 0 0 1.5em;
	border-left: 2px solid var(--sanaa-accent);
	font-family: var(--sanaa-font-heading);
	font-size: var(--sanaa-text-lg);
	line-height: var(--sanaa-leading-snug);
	color: var(--sanaa-heading-color);
}

ul,
ol {
	padding-left: 1.4em;
}

hr {
	border: 0;
	border-top: 1px solid var(--sanaa-border);
	margin: var(--sanaa-section-gap) 0;
}

code,
pre {
	font-size: 0.9em;
}

pre {
	background: var(--sanaa-surface);
	border: 1px solid var(--sanaa-border);
	border-radius: var(--sanaa-radius-md);
	padding: 1.25rem;
	overflow-x: auto;
}

/* ------------------------------------------------------------- Layout */

.sanaa-container {
	width: min(
		100% - (var(--sanaa-layout-pad, var(--sanaa-gutter)) * 2),
		var(--sanaa-layout-width, var(--sanaa-container))
	);
	margin-inline: auto;
}

.sanaa-container--narrow {
	width: min(100% - (var(--sanaa-gutter) * 2), var(--sanaa-container-narrow));
}

.sanaa-section {
	padding-block: var(--sanaa-section-gap);
}

/* ------------------------------------------------------- Accessibility */

.screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.screen-reader-text:focus,
.skip-link:focus {
	position: fixed;
	top: 0.75rem;
	left: 0.75rem;
	z-index: 100000;
	width: auto;
	height: auto;
	clip: auto;
	padding: 0.75rem 1.25rem;
	font-weight: 600;
	color: var(--sanaa-on-primary);
	background: var(--sanaa-primary);
	border-radius: var(--sanaa-radius-sm);
}

:focus-visible {
	outline: 2px solid var(--sanaa-primary);
	outline-offset: 2px;
	border-radius: 2px;
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}
}

/* -------------------------------------------------------------- Forms */

input[type='text'],
input[type='email'],
input[type='url'],
input[type='tel'],
input[type='search'],
input[type='number'],
input[type='password'],
input[type='date'],
input[type='time'],
textarea,
select {
	width: 100%;
	padding: 0.7rem 0.9rem;
	font: inherit;
	color: var(--sanaa-text);
	background: var(--sanaa-surface);
	border: 1px solid var(--sanaa-border);
	border-radius: var(--sanaa-radius-sm);
	transition: border-color var(--sanaa-duration) var(--sanaa-ease);
}

input:focus,
textarea:focus,
select:focus {
	border-color: var(--sanaa-primary);
	outline: none;
}

label {
	display: block;
	margin-bottom: 0.35rem;
	font-size: var(--sanaa-text-sm);
	font-weight: 600;
	color: var(--sanaa-heading-color);
}

fieldset {
	border: 1px solid var(--sanaa-border);
	border-radius: var(--sanaa-radius-md);
	padding: 1.25rem;
	margin: 0 0 1.25rem;
}

legend {
	padding: 0 0.5rem;
	font-weight: 600;
	color: var(--sanaa-heading-color);
}

/* ------------------------------------------------------------- Tables */

table {
	width: 100%;
	border-collapse: collapse;
	font-size: var(--sanaa-text-sm);
}

th,
td {
	padding: 0.75rem 1rem;
	text-align: left;
	border-bottom: 1px solid var(--sanaa-border);
}

th {
	font-family: var(--sanaa-font-accent);
	font-weight: 600;
	letter-spacing: var(--sanaa-track-eyebrow);
	text-transform: uppercase;
	font-size: 0.72rem;
	color: var(--sanaa-text-muted);
}

/* ------------------------------------------- Smooth scrolling (Lenis) */

/* Classes Lenis toggles on <html> while it drives native scroll. */
html.lenis,
html.lenis body {
	height: auto;
}

/* Lenis owns easing once active — CSS smooth would double-smooth. */
.lenis.lenis-smooth {
	scroll-behavior: auto !important;
}

.lenis.lenis-smooth [data-lenis-prevent] {
	overscroll-behavior: contain;
}

.lenis.lenis-stopped {
	overflow: hidden;
}
