/**
 * Atlas Guide — base layer.
 * Reset, element defaults, typography scale, layout primitives.
 */

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

html {
	scroll-behavior: smooth;
}

body {
	margin: 0;
	background: var(--mg-surface-page);
	color: var(--mg-text-body);
	font-family: var(--mg-font-body);
	font-size: var(--mg-text-base);
	line-height: var(--mg-leading-body);
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	overflow-x: hidden;
}

body.mg-menu-open {
	overflow: hidden;
}

img,
picture,
video {
	max-width: 100%;
	display: block;
}

/*
 * Links carry no underline anywhere by default (theme.json sets this for the
 * editor too). Navigation, cards and buttons express their own hover states;
 * running prose re-enables the underline in archive.css.
 *
 * The hover colour lives here rather than in theme.json because WordPress
 * serialises an ":hover" entry on elements.link into an invalid selector.
 */
a {
	color: inherit;
	text-decoration: none;
}

.mg-prose a:hover,
.mg-lead a:hover {
	color: var(--mg-color-terracotta-dark);
}

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

button {
	cursor: pointer;
}

:focus-visible {
	outline: 3px solid var(--mg-focus-ring);
	outline-offset: 4px;
}

::selection {
	background: var(--mg-color-sand-light);
	color: var(--mg-color-charcoal);
}

/* ---- Headings ---- */

h1,
h2,
h3,
h4 {
	margin: 0 0 var(--mg-space-4);
	font-family: var(--mg-font-display);
	font-weight: 500;
	letter-spacing: var(--mg-tracking-heading);
	line-height: var(--mg-leading-heading);
}

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

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

h3 {
	font-size: var(--mg-text-h3);
	font-weight: 600;
}

h4 {
	font-size: 1.125rem;
	font-weight: 600;
}

p {
	margin: 0 0 var(--mg-space-4);
}

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

/* ---- Editorial type utilities ---- */

.mg-display-xl {
	font-family: var(--mg-font-display);
	font-size: var(--mg-text-display-xl);
	font-weight: 500;
	line-height: var(--mg-leading-tight);
	letter-spacing: var(--mg-tracking-display);
	margin: 0;
}

.mg-display-l {
	font-family: var(--mg-font-display);
	font-size: var(--mg-text-display-l);
	font-weight: 500;
	line-height: 0.98;
	letter-spacing: -0.025em;
	margin: 0;
}

.mg-display-xl em,
.mg-display-l em,
.mg-heading em {
	font-style: italic;
	color: var(--mg-color-terracotta);
}

.mg-eyebrow {
	margin: 0 0 var(--mg-space-3);
	color: var(--mg-color-terracotta);
	font-family: var(--mg-font-body);
	font-size: var(--mg-text-eyebrow);
	font-weight: 700;
	letter-spacing: var(--mg-tracking-eyebrow);
	line-height: 1.3;
	text-transform: uppercase;
}

.mg-lead {
	font-size: var(--mg-text-lead);
	line-height: var(--mg-leading-body);
	color: var(--mg-text-muted);
}

.mg-small {
	font-size: var(--mg-text-small);
	line-height: 1.45;
}

/* ---- Layout primitives ---- */

.mg-container {
	width: min(calc(100% - var(--mg-gutter) * 2), var(--mg-container));
	margin-inline: auto;
}

.mg-container--wide {
	max-width: var(--mg-container-wide);
}

.mg-container--text {
	max-width: var(--mg-container-text);
}

.mg-section {
	padding-block: var(--mg-section-y);
}

.mg-section--tight {
	padding-block: var(--mg-space-9);
}

.mg-section--dark {
	background: var(--mg-surface-dark);
	color: var(--mg-color-white);
}

.mg-section--sand {
	background: var(--mg-color-sand-light);
}

.mg-section--paper {
	background: var(--mg-surface-raised);
}

/* ---- Accessibility helpers ---- */

.mg-skip-link {
	position: absolute;
	top: -100px;
	left: var(--mg-space-4);
	z-index: 999;
	padding: var(--mg-space-3) var(--mg-space-5);
	background: var(--mg-color-terracotta);
	color: var(--mg-color-white);
	border-radius: var(--mg-radius-pill);
	font-size: var(--mg-text-small);
	font-weight: 700;
	transition: top var(--mg-transition-fast);
}

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

.screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

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