/*
 * CD Mafra SAD — Base: ordem das camadas, fontes, reset, tipografia, primitivos de layout.
 * Inline no <head> com tokens.css quando os dois somam ≤ 14 KB (inc/assets.php).
 * Os url(../fonts/…) são reescritos para URLs absolutos quando inline.
 * Documentação: docs/02-design-system.md, docs/09-convencoes-codigo.md
 */
@layer tokens, base, components, utilities, pages;

/* ---- Fontes self-hosted (OFL). Latin cobre pt/en/es/fr/de/da; latin-ext só desce se a página o pedir. ---- */
@font-face {
	font-family: "Barlow Condensed";
	font-style: normal;
	font-weight: 600;
	font-display: swap;
	src: url(../fonts/barlow-condensed-latin-600-normal.woff2) format("woff2");
	unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
	font-family: "Barlow Condensed";
	font-style: normal;
	font-weight: 700;
	font-display: swap;
	src: url(../fonts/barlow-condensed-latin-700-normal.woff2) format("woff2");
	unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
	font-family: "Barlow Condensed";
	font-style: normal;
	font-weight: 800;
	font-display: swap;
	src: url(../fonts/barlow-condensed-latin-800-normal.woff2) format("woff2");
	unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
	font-family: "Barlow Condensed";
	font-style: normal;
	font-weight: 600;
	font-display: swap;
	src: url(../fonts/barlow-condensed-latin-ext-600-normal.woff2) format("woff2");
	unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
	font-family: "Barlow Condensed";
	font-style: normal;
	font-weight: 700;
	font-display: swap;
	src: url(../fonts/barlow-condensed-latin-ext-700-normal.woff2) format("woff2");
	unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
	font-family: "Barlow Condensed";
	font-style: normal;
	font-weight: 800;
	font-display: swap;
	src: url(../fonts/barlow-condensed-latin-ext-800-normal.woff2) format("woff2");
	unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* Montserrat variável: um ficheiro cobre 400, 500 e 700. */
@font-face {
	font-family: "Montserrat";
	font-style: normal;
	font-weight: 400 700;
	font-display: swap;
	src: url(../fonts/montserrat-latin-wght-normal.woff2) format("woff2-variations"), url(../fonts/montserrat-latin-wght-normal.woff2) format("woff2");
	unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
	font-family: "Montserrat";
	font-style: normal;
	font-weight: 400 700;
	font-display: swap;
	src: url(../fonts/montserrat-latin-ext-wght-normal.woff2) format("woff2-variations"), url(../fonts/montserrat-latin-ext-wght-normal.woff2) format("woff2");
	unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* Fallbacks métricos (tools/font-metrics.php): a fonte de sistema ocupa o mesmo espaço até a web chegar. */
@font-face {
	font-family: "Barlow Condensed Fallback";
	src: local("Arial Narrow Bold"), local("ArialNarrow-Bold"), local("Arial Narrow");
	size-adjust: 82.04%;
	ascent-override: 121.89%;
	descent-override: 24.38%;
	line-gap-override: 0%;
}
@font-face {
	font-family: "Montserrat Fallback";
	src: local("Arial"), local("ArialMT");
	size-adjust: 108.4%;
	ascent-override: 89.3%;
	descent-override: 23.16%;
	line-gap-override: 0%;
}

@layer base {
	/* ---- Reset ---- */
	*,
	*::before,
	*::after {
		box-sizing: border-box;
	}

	* {
		margin: 0;
	}

	html {
		-webkit-text-size-adjust: 100%;
		text-size-adjust: 100%;
		scroll-padding-block-start: var(--cdm-header-h);
	}

	@media (prefers-reduced-motion: no-preference) {
		html {
			scroll-behavior: smooth;
		}
	}

	body {
		min-block-size: 100vh;
		font-family: var(--cdm-font-body);
		font-size: var(--cdm-fs-base);
		font-weight: var(--cdm-fw-regular);
		line-height: var(--cdm-lh-base);
		color: var(--cdm-fg);
		background: var(--cdm-bg);
		-webkit-font-smoothing: antialiased;
		overflow-wrap: break-word;
	}

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

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

	button {
		cursor: pointer;
	}

	/* ---- Tipografia ---- */
	h1,
	h2,
	h3,
	h4,
	h5,
	h6 {
		font-family: var(--cdm-font-display);
		font-weight: var(--cdm-fw-display);
		line-height: var(--cdm-lh-tight);
		letter-spacing: var(--cdm-ls-display);
		text-transform: uppercase;
		color: var(--cdm-heading);
		overflow-wrap: anywhere;
		hyphens: auto;
		text-wrap: balance;
	}

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

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

	h3 {
		font-size: var(--cdm-fs-xl);
		line-height: var(--cdm-lh-snug);
	}

	h4,
	h5,
	h6 {
		font-size: var(--cdm-fs-lg);
		line-height: var(--cdm-lh-snug);
	}

	:where(p, ul, ol, dl, blockquote, figure, table, pre) {
		margin-block-end: var(--cdm-stack);
	}

	:where(p, ul, ol, dl, blockquote, figure, table, pre):last-child {
		margin-block-end: 0;
	}

	:where(ul, ol) {
		padding-inline-start: var(--cdm-sp-6);
	}

	a {
		color: var(--cdm-link);
		text-decoration-thickness: from-font;
		text-underline-offset: 0.15em;
	}

	a:hover {
		color: var(--cdm-link-hover);
	}

	strong,
	b {
		font-weight: var(--cdm-fw-bold);
	}

	small {
		font-size: var(--cdm-fs-sm);
	}

	hr {
		border: 0;
		border-block-start: var(--cdm-border-w) solid var(--cdm-border);
	}

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

	/* Foco sempre visível; o outline transparente mantém-se visível em modo de alto contraste. */
	:focus-visible {
		outline: var(--cdm-border-w-strong) solid transparent;
		box-shadow: var(--cdm-focus-ring);
	}

	::selection {
		color: var(--cdm-on-accent);
		background: var(--cdm-accent);
	}

	/* Ícones do sprite (marcador icon): seguem o tamanho e a cor do texto. */
	.cdm-icon {
		display: inline-block;
		flex-shrink: 0;
		inline-size: 1.25em;
		block-size: 1.25em;
		vertical-align: -0.25em;
	}

	/* ---- Primitivos de layout ---- */
	.cdm-container {
		inline-size: 100%;
		max-inline-size: calc(var(--cdm-container) + var(--cdm-gutter) * 2);
		margin-inline: auto;
		padding-inline: var(--cdm-gutter);
	}

	.cdm-container--narrow {
		max-inline-size: calc(var(--cdm-container-narrow) + var(--cdm-gutter) * 2);
	}

	.cdm-container--wide {
		max-inline-size: calc(var(--cdm-container-wide) + var(--cdm-gutter) * 2);
	}

	.cdm-section {
		padding-block: var(--cdm-section-y);
		color: var(--cdm-fg);
		background: var(--cdm-bg);
	}

	.cdm-section--alt {
		background: var(--cdm-bg-alt);
	}

	.cdm-section--tight {
		padding-block: var(--cdm-section-y-sm);
	}

	.cdm-grid {
		display: grid;
		grid-template-columns: repeat(var(--cols, 12), minmax(0, 1fr));
		gap: var(--cdm-grid-gap);
	}

	.cdm-grid--2,
	.cdm-grid--3,
	.cdm-grid--4 {
		--cols: 1;
	}

	@media (min-width: 40em) {
		.cdm-grid--3,
		.cdm-grid--4 {
			--cols: 2;
		}
	}

	@media (min-width: 48em) {
		.cdm-grid--2 {
			--cols: 2;
		}
	}

	@media (min-width: 64em) {
		.cdm-grid--3 {
			--cols: 3;
		}

		.cdm-grid--4 {
			--cols: 4;
		}
	}

	.cdm-eyebrow {
		font-size: var(--cdm-fs-sm);
		font-weight: var(--cdm-fw-bold);
		letter-spacing: var(--cdm-ls-caps);
		text-transform: uppercase;
		color: var(--cdm-link);
	}

	/* Skip-link: primeiro elemento focável da página. */
	.cdm-skip {
		position: absolute;
		inset-block-start: var(--cdm-sp-2);
		inset-inline-start: var(--cdm-sp-2);
		z-index: var(--cdm-z-toast);
		display: inline-flex;
		align-items: center;
		min-block-size: var(--cdm-touch-target);
		padding-inline: var(--cdm-sp-4);
		border-radius: var(--cdm-radius);
		font-weight: var(--cdm-fw-bold);
		color: var(--cdm-on-accent);
		background: var(--cdm-accent);
		transform: translateY(-200%);
	}

	.cdm-skip:focus {
		color: var(--cdm-on-accent);
		transform: none;
	}
}

@layer utilities {
	.u-visually-hidden {
		position: absolute !important;
		inline-size: 1px !important;
		block-size: 1px !important;
		padding: 0 !important;
		margin: -1px !important;
		overflow: hidden !important;
		clip: rect(0, 0, 0, 0) !important;
		white-space: nowrap !important;
		border: 0 !important;
	}
}
