/* ==========================================================================
   BASE
   --------------------------------------------------------------------------
   Element defaults only. Bootstrap's Reboot already normalises the browser,
   so this file just applies the design system's typography on top of it.
   ========================================================================== */


/* --------------------------------------------------------------------------
   Document
   -------------------------------------------------------------------------- */

/*
 * Smooth scrolling.
 *
 * Native, so it also covers the browser's back/forward navigation and a URL
 * opened straight at a #hash — a JS scroll library only catches clicks.
 *
 * scroll-padding-top keeps an anchored section clear of the sticky header:
 * without it the target lands underneath the pinned bar. It is set on the
 * scroll container, so it applies to every anchor without marking them up.
 */
html {
	scroll-behavior: smooth;
	scroll-padding-top: calc(var(--mtfs-header-h) + var(--mtfs-space-4));
}

/* Anything that can be an anchor target keeps the same clearance when it is
   scrolled to programmatically. */
[id] {
	scroll-margin-top: calc(var(--mtfs-header-h) + var(--mtfs-space-4));
}

body {
	font-family: var(--mtfs-font-body);
	font-size: var(--mtfs-size-body-1);
	line-height: var(--mtfs-line-height);
	color: var(--mtfs-color-body);
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

/* Push the footer to the bottom on short pages. */
.mtfs-site {
	display: flex;
	flex-direction: column;
	min-height: 100vh;
}

.mtfs-main {
	flex: 1 0 auto;
	padding-top: var(--mtfs-space-8);
	padding-bottom: var(--mtfs-space-8);
}

/*
 * A full-bleed band supplies its own spacing, so the main padding is pulled
 * back on whichever edge it touches — otherwise a white gap opens between
 * the header and the first band, or between the last band and the footer.
 */
.mtfs-main > .mtfs-section:first-child,
.mtfs-main > .mtfs-hero:first-child {
	margin-top: calc(var(--mtfs-space-8) * -1);
}

.mtfs-main > .mtfs-section:last-child {
	margin-bottom: calc(var(--mtfs-space-8) * -1);
}


/* --------------------------------------------------------------------------
   Headings
   --------------------------------------------------------------------------
   clamp() shrinks the big headings on narrow screens without a breakpoint.
   The upper bound is the token, so Theme Options still controls the size and
   the inline override from inc/dynamic-css.php always wins.
   -------------------------------------------------------------------------- */

/* The frames leave 37px of ink between paragraphs, which is a 24px margin on
   the 26px pitch. Bootstrap's reboot hardcodes 1rem, so it is set here. */
p {
	margin-bottom: var(--mtfs-para-space);
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
	font-family: var(--mtfs-font-heading);
	line-height: var(--mtfs-line-height-heading);
	color: var(--mtfs-color-heading);
	text-wrap: balance;
}

h1, .h1 {
	font-size: clamp(32px, 6vw, var(--mtfs-size-h1));
	line-height: var(--mtfs-line-height-display);
	font-weight: var(--mtfs-weight-h1);
	letter-spacing: var(--mtfs-tracking-heading);
}

h2, .h2 {
	font-size: clamp(25px, 4vw, var(--mtfs-size-h2));
	font-weight: var(--mtfs-weight-h2);
	letter-spacing: var(--mtfs-tracking-heading);
}

h3, .h3 {
	font-size: clamp(20px, 3vw, var(--mtfs-size-h3));
	font-weight: var(--mtfs-weight-h3);
}

h4, .h4 {
	font-size: var(--mtfs-size-h4);
	font-weight: var(--mtfs-weight-h4);
}

h5, .h5 {
	font-size: var(--mtfs-size-h5);
	font-weight: 600;
}

h6, .h6 {
	font-size: var(--mtfs-size-h6);
	font-weight: 600;
}


/* --------------------------------------------------------------------------
   Body text styles from the style guide
   --------------------------------------------------------------------------
   Body 1 is the default and needs no class.
   -------------------------------------------------------------------------- */

.mtfs-body-2 {
	font-size: var(--mtfs-size-body-2);
}

/* Body 3 — the small uppercase label. */
.mtfs-body-3 {
	font-size: var(--mtfs-size-body-3);
	font-weight: 500;
	letter-spacing: var(--mtfs-tracking-label);
	text-transform: uppercase;
}


/* --------------------------------------------------------------------------
   Links, media, quotes
   -------------------------------------------------------------------------- */

a {
	transition: color var(--mtfs-transition);
}

img,
svg,
video,
iframe {
	max-width: 100%;
}

img {
	height: auto;
}

blockquote {
	margin: 0 0 var(--mtfs-space-5);
	padding: var(--mtfs-space-4) var(--mtfs-space-5);
	border-left: 3px solid var(--mtfs-color-primary);
	background: var(--mtfs-color-surface);
	color: var(--mtfs-color-heading);
	font-style: italic;
}

pre {
	padding: var(--mtfs-space-4);
	background: var(--mtfs-color-surface);
	border-radius: var(--mtfs-radius);
	overflow-x: auto;
}


/* --------------------------------------------------------------------------
   Icons
   --------------------------------------------------------------------------
   Inline SVG from inc/icons.php. They inherit the surrounding text colour, so
   an icon almost never needs a colour rule of its own.
   -------------------------------------------------------------------------- */

.mtfs-icon {
	display: inline-block;
	flex: none;
	vertical-align: middle;
	color: currentColor;
}


/* --------------------------------------------------------------------------
   Focus
   -------------------------------------------------------------------------- */

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

/* The skip link stays off-screen until focused, then drops into view as the
   first tab stop on every page. */
.mtfs-skip-link {
	position: absolute;
	left: -9999px;
	top: 0;
	z-index: 1080;
}

.mtfs-skip-link:focus {
	left: var(--mtfs-space-3);
	top: var(--mtfs-space-3);
	padding: var(--mtfs-space-3) var(--mtfs-space-4);
	background: var(--mtfs-color-primary);
	color: var(--mtfs-white);
	border-radius: var(--mtfs-radius-sm);
}


/* --------------------------------------------------------------------------
   Reduced motion
   --------------------------------------------------------------------------
   Animation here is decoration, never the only signal for a state change, so
   removing it costs nothing.
   -------------------------------------------------------------------------- */

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