/*
 * Base: reset mínimo, tipografia, links, listas, mídia, formulários, foco e utilitários de acessibilidade.
 * Nada específico de página. Depende de tokens.css.
 */

/* ---- Reset mínimo ---- */
*,
*::before,
*::after {
	box-sizing: border-box;
}

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	scroll-padding-top: calc(var(--header-height) + var(--space-4));
}

body {
	margin: 0;
	background: var(--surface-page);
	color: var(--text-primary);
	font-family: var(--font-sans);
	font-size: var(--text-body);
	line-height: var(--leading-body);
	font-weight: var(--weight-regular);
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	text-rendering: optimizeLegibility;
}

/* ---- Títulos ---- */
h1,
h2,
h3,
h4,
h5,
h6 {
	margin: 0 0 var(--space-4);
	color: var(--text-primary);
	font-family: var(--font-sans);
	font-weight: var(--weight-extrabold);
	line-height: var(--leading-heading);
	letter-spacing: var(--tracking-tight);
	text-wrap: balance;
}

/* H1 é editorial (serif); demais níveis são de sistema (Inter). */
h1 {
	font-family: var(--font-editorial);
	font-weight: var(--weight-semibold);
	font-size: var(--text-display-2);
	line-height: var(--leading-editorial);
}

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

h3 {
	font-size: var(--text-heading-2);
	font-weight: var(--weight-bold);
}

h4 {
	font-size: var(--text-heading-3);
	font-weight: var(--weight-bold);
}

h5,
h6 {
	font-size: var(--text-body);
	font-weight: var(--weight-bold);
}

/* Escalas reutilizáveis (uso explícito, independente do nível semântico) */
.ma-display-1,
.ma-display-2 {
	font-family: var(--font-editorial);
	font-weight: var(--weight-semibold);
	line-height: var(--leading-tight);
	letter-spacing: var(--tracking-tight);
}

.ma-display-1 {
	font-size: var(--text-display-1);
}

.ma-display-2 {
	font-size: var(--text-display-2);
	line-height: var(--leading-editorial);
}

.ma-heading-1 {
	font-size: var(--text-heading-1);
}

.ma-heading-2 {
	font-size: var(--text-heading-2);
}

.ma-heading-3 {
	font-size: var(--text-heading-3);
}

.ma-lead {
	font-size: var(--text-body-lg);
	color: var(--text-secondary);
}

.ma-serif {
	font-family: var(--font-editorial);
}

/* ---- Parágrafos e texto ---- */
p {
	margin: 0 0 var(--space-4);
	text-wrap: pretty;
}

small {
	font-size: var(--text-body-sm);
}

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

blockquote {
	margin: var(--space-5) 0;
	padding: 0 0 0 var(--space-5);
	border-left: var(--index-rule-weight) solid var(--accent-secondary);
	font-family: var(--font-editorial);
	font-size: var(--text-heading-2);
	line-height: var(--leading-editorial);
}

hr {
	height: 0;
	margin: var(--space-6) 0;
	border: 0;
	border-top: var(--rule-weight) solid var(--border-default);
}

code,
kbd,
pre {
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 0.9em;
}

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

/* ---- Links ---- */
/* Links de texto usam Deep Green: Mid Green sobre Off-white tem 4,491:1 e NÃO atinge AA (4,5:1). */
a {
	color: var(--accent-primary);
	text-decoration-thickness: 1px;
	text-underline-offset: 0.2em;
	transition: color var(--duration-fast) var(--ease-standard);
}

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

/* ---- Listas ---- */
ul,
ol {
	margin: 0 0 var(--space-4);
	padding-left: var(--space-5);
}

li + li {
	margin-top: var(--space-1);
}

/* ---- Mídia ---- */
img,
svg,
video,
canvas {
	display: block;
	max-width: 100%;
	height: auto;
}

figure {
	margin: 0 0 var(--space-5);
}

figcaption {
	margin-top: var(--space-2);
	color: var(--text-secondary);
	font-size: var(--text-body-sm);
}

/* ---- Tabelas ---- */
table {
	width: 100%;
	border-collapse: collapse;
}

th,
td {
	padding: var(--space-3) var(--space-3);
	border-bottom: var(--rule-weight) solid var(--border-default);
	text-align: left;
}

/* ---- Formulários ---- */
button,
input,
select,
textarea {
	font: inherit;
	color: inherit;
}

input[type="text"],
input[type="search"],
input[type="email"],
input[type="url"],
input[type="password"],
input[type="number"],
select,
textarea {
	width: 100%;
	padding: var(--space-3) var(--space-4);
	border: var(--rule-weight) solid var(--border-strong);
	border-radius: var(--radius-sm);
	background: var(--surface-card);
	color: var(--text-primary);
}

input::placeholder,
textarea::placeholder {
	color: var(--text-secondary);
	opacity: 1;
}

label {
	font-size: var(--text-body-sm);
	font-weight: var(--weight-medium);
}

/* Botões nus recebem só o reset; o visual vem de .ma-button */
button {
	cursor: pointer;
}

[disabled],
[aria-disabled="true"] {
	cursor: not-allowed;
	opacity: 0.6;
}

/* ---- Foco visível ---- */
:focus {
	outline: none;
}

:focus-visible {
	outline: 2px solid var(--focus-ring);
	outline-offset: 2px;
}

/* ---- Seleção ---- */
::selection {
	background: var(--accent-soft);
	color: var(--text-primary);
}

/* ---- Acessibilidade ---- */
.screen-reader-text {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

.screen-reader-text:focus-visible {
	position: static;
	width: auto;
	height: auto;
	margin: 0;
	overflow: visible;
	clip-path: none;
	white-space: normal;
}

.ma-skip-link {
	position: absolute;
	top: var(--space-2);
	left: var(--space-2);
	z-index: var(--z-skip-link);
	padding: var(--space-3) var(--space-4);
	background: var(--accent-primary);
	color: var(--text-on-accent);
	font-size: var(--text-body-sm);
	font-weight: var(--weight-semibold);
	border-radius: var(--radius-md);
	text-decoration: none;
	transform: translateY(-200%);
}

.ma-skip-link:focus-visible {
	transform: translateY(0);
	color: var(--text-on-accent);
}

@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		transition-duration: 0.01ms !important;
		animation-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}
}
