/*
 * Base layer: reset, element defaults, typography and accessibility
 * primitives. Mobile-first — no media queries here; breakpoint overrides
 * live in responsive.css.
 */

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

/* Guarantee the native hidden-attribute behavior survives component
   `display` rules of equal specificity (e.g. `.card { display: flex }`). */
[hidden] {
	display: none !important;
}

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	scroll-behavior: smooth;
}

body {
	margin: 0;
	background-color: var(--color-surface);
	color: var(--color-ink);
	font-family: var(--font-sans);
	font-size: var(--text-base);
	line-height: var(--leading-normal);
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

img,
svg,
video,
canvas {
	display: block;
	max-width: 100%;
	height: auto;
}

img {
	font-style: italic; /* alt text is legible if an image fails to load */
}

svg {
	fill: currentColor;
}

figure {
	margin: 0;
}

table {
	width: 100%;
	border-collapse: collapse;
}

h1,
h2,
h3,
h4,
h5,
h6 {
	margin: 0 0 var(--space-4);
	font-weight: var(--weight-bold);
	line-height: var(--leading-tight);
	color: var(--color-ink);
	text-wrap: balance;
}

h1 {
	font-size: var(--text-4xl);
}

h2 {
	font-size: var(--text-3xl);
}

h3 {
	font-size: var(--text-2xl);
}

h4 {
	font-size: var(--text-xl);
}

h5 {
	font-size: var(--text-lg);
}

h6 {
	font-size: var(--text-md);
}

p {
	margin: 0 0 var(--space-4);
	max-width: 70ch;
}

p:last-child {
	margin-bottom: 0;
}

ul,
ol {
	margin: 0 0 var(--space-4);
	padding-left: var(--space-6);
}

a {
	color: var(--color-primary);
	text-decoration-thickness: 1px;
	text-underline-offset: 0.15em;
	transition: color var(--transition-fast);
}

a:hover {
	color: var(--color-primary-dark);
}

a:not([class]) {
	text-decoration-line: underline;
}

button,
input,
select,
textarea {
	font-family: inherit;
	font-size: inherit;
	color: inherit;
}

button {
	cursor: pointer;
}

hr {
	border: 0;
	border-top: 1px solid var(--color-border);
	margin: var(--space-8) 0;
}

blockquote {
	margin: var(--space-6) 0;
	padding-left: var(--space-5);
	border-left: 3px solid var(--color-primary);
	color: var(--color-ink-soft);
	font-size: var(--text-md);
}

code,
kbd,
pre,
samp {
	font-family: var(--font-mono);
	font-size: 0.9em;
}

pre {
	overflow-x: auto;
	padding: var(--space-4);
	background: var(--color-surface-alt);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-md);
}

/* Accessibility primitives */

.skip-link {
	position: absolute;
	top: -100%;
	left: var(--space-4);
	z-index: 1000;
	padding: var(--space-3) var(--space-5);
	background: var(--color-ink);
	color: #fff;
	border-radius: var(--radius-sm);
	text-decoration: none;
	font-weight: var(--weight-semibold);
	transition: top var(--transition-fast);
}

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

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

.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 {
	position: fixed;
	top: var(--space-4);
	left: var(--space-4);
	width: auto;
	height: auto;
	padding: var(--space-3) var(--space-5);
	background: var(--color-ink);
	color: #fff;
	clip: auto;
	z-index: 1000;
	border-radius: var(--radius-sm);
}

@media (prefers-reduced-motion: reduce) {
	html {
		scroll-behavior: auto;
	}

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