/* ============================================================================
   Base layer — reset, element defaults, accessibility utilities
   ============================================================================
   Load class: RENDER-CRITICAL. Enqueued directly after tokens.css.

   Rules honoured here:
   - Logical properties only. No `left`/`right`/`margin-left` for direction.
   - Focus is always visible and uses the two-tone token ring.
   - Nothing animates when the user asked for reduced motion.
   ========================================================================= */

/* --- Reset ---------------------------------------------------------------- */

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

* {
	margin: 0;
}

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	tab-size: 4;
	overflow-x: hidden;
}

body {
	min-block-size: 100vh;
	background-color: var(--ma-bg);
	color: var(--ma-text);
	font-family: var(--ma-font-sans);
	font-size: var(--ma-fs-body);
	font-weight: var(--ma-fw-regular);
	line-height: var(--ma-lh-body);
	letter-spacing: var(--ma-track-body);
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	overflow-wrap: break-word;
	overflow-x: hidden;
}

/* --- Media ---------------------------------------------------------------- */

img,
picture,
video,
canvas,
svg {
	display: block;
	max-inline-size: 100%;
}

img,
video {
	block-size: auto;
}

/* --- Type ----------------------------------------------------------------- */

h1,
h2,
h3,
h4,
h5,
h6 {
	color: var(--ma-text-strong);
	font-weight: var(--ma-fw-semibold);
	line-height: var(--ma-lh-heading);
	letter-spacing: var(--ma-track-heading);
	text-wrap: balance;
}

h1 {
	font-size: var(--ma-fs-h1);
}

h2 {
	font-size: var(--ma-fs-h2);
}

h3 {
	font-size: var(--ma-fs-h3);
}

h4,
h5,
h6 {
	font-size: var(--ma-fs-h4);
}

p,
li,
figcaption {
	max-inline-size: var(--ma-measure);
	text-wrap: pretty;
}

strong,
b {
	font-weight: var(--ma-fw-semibold);
}

small {
	font-size: var(--ma-fs-xs);
}

hr {
	border: 0;
	border-block-start: var(--ma-border-width) solid var(--ma-border);
}

/* --- Links ---------------------------------------------------------------- */

a {
	color: var(--ma-accent);
	text-decoration-thickness: 1px;
	text-underline-offset: 0.2em;
}

a:hover {
	color: var(--ma-accent-hover);
}

/* --- Lists ---------------------------------------------------------------- */

ul[class],
ol[class] {
	list-style: none;
	padding-inline-start: 0;
}

/* --- Forms ---------------------------------------------------------------- */

input,
button,
textarea,
select {
	font: inherit;
	letter-spacing: inherit;
	color: inherit;
}

button {
	background: none;
	border: 0;
	cursor: pointer;
}

fieldset {
	border: 0;
	padding: 0;
}

::placeholder {
	color: var(--ma-text-muted);
	opacity: 1;
}

/* --- Tables --------------------------------------------------------------- */

table {
	border-collapse: collapse;
	inline-size: 100%;
}

/* --- Selection ------------------------------------------------------------ */

::selection {
	background-color: var(--ma-accent-soft);
	color: var(--ma-text-strong);
}

/* --- Focus (single, consistent, two-tone) --------------------------------- */

:focus-visible {
	outline: var(--ma-focus-width) solid var(--ma-focus-ring);
	outline-offset: var(--ma-focus-offset);
	box-shadow: 0 0 0 var(--ma-focus-halo-width) var(--ma-focus-halo);
	border-radius: var(--ma-radius-xs);
}

/* Pointer users do not get a ring; keyboard users always do. */
:focus:not(:focus-visible) {
	outline: none;
}

/* --- Accessibility utilities ---------------------------------------------- */

.ma-visually-hidden {
	position: absolute !important;
	inline-size: 1px;
	block-size: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/*
 * Skip link is revealed on focus, not merely focusable — a hidden target is not
 * a usable target (WCAG 2.2 §2.4.7).
 */
.ma-skip-link {
	position: absolute;
	inset-block-start: var(--ma-space-2);
	inset-inline-start: var(--ma-space-2);
	z-index: var(--ma-z-toast);
	padding: var(--ma-space-2) var(--ma-space-4);
	background-color: var(--ma-surface);
	color: var(--ma-text-strong);
	border-radius: var(--ma-radius-sm);
	box-shadow: var(--ma-elev-2);
	font-size: var(--ma-fs-sm);
	text-decoration: none;
	transform: translateY(calc(-100% - var(--ma-space-4)));
	transition: transform var(--ma-dur-fast) var(--ma-ease-standard);
}

.ma-skip-link:focus-visible {
	transform: translateY(0);
}

/* --- Vertical rhythm between sibling blocks ------------------------------- */

.ma-flow > * + * {
	margin-block-start: var(--ma-space-5);
}

/* --- Global reduced-motion safety net ------------------------------------- */

@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;
	}
}
