/*
 * Base layer: reset, typography, container, focus and the canonical breakpoints.
 *
 * BREAKPOINTS (desktop-first, max-width). Custom properties cannot be used inside
 * @media, so the literals below are the single source of truth for the whole theme.
 * Every section stylesheet uses these five values and no others.
 *
 *   base            >= 1280px  Figma layout. Gutter 112px, container capped at 1216px.
 *   max-width: 1279px  1024-1279  Gutter 40px, fluid container.
 *   max-width: 1023px  768-1023   Gutter 32px. Header collapses to the red bar, footer in 2 columns.
 *   max-width: 767px   480-767    Gutter 24px. Stacking, carousels with peek, full screen modals.
 *   max-width: 479px   < 480      Gutter 20px. CTA groups and metric grids go single column.
 */

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

html {
	-webkit-text-size-adjust: 100%;
	scroll-behavior: smooth;
}

body {
	margin: 0;
	background-color: var(--color-surface);
	color: var(--color-text);
	font-family: var(--font-body);
	font-size: var(--font-p2);
	font-weight: 400;
	line-height: 1.4;
	letter-spacing: var(--ls-body);
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}

/*
 * Figma sets the tracking of each text at -1 % of its own size. A letter-spacing in em is
 * inherited as px, so the body rule alone would give every child the -0.18px of 18px.
 * Zero specificity: any rule that sets its own tracking still wins (desktop-fidelity G4).
 */
:where(body *) {
	letter-spacing: var(--ls-body);
}

h1,
h2,
h3,
h4,
h5,
h6 {
	margin: 0;
	color: var(--color-heading);
	font-family: var(--font-heading);
	font-weight: var(--weight-heading);
	line-height: var(--lh-heading);
	letter-spacing: var(--ls-heading);
	/* Long unbroken words blow the layout at 375px otherwise. */
	overflow-wrap: anywhere;
}

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

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

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

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

h6 {
	font-size: var(--font-h7);
}

p,
ul,
ol,
dl,
dd,
figure,
table {
	margin: 0;
}

ul,
ol {
	padding: 0;
	list-style: none;
}

a {
	color: inherit;
	text-decoration: none;
}

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

img {
	height: auto;
}

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

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

table {
	border-collapse: collapse;
}

/* Layout */

.container {
	width: 100%;
	max-width: calc(var(--container-max) + var(--container-gutter) * 2);
	margin-inline: auto;
	padding-inline: var(--container-gutter);
}

.section {
	padding-block: var(--section-padding-start) var(--section-padding-end);
}

/*
 * Minimal typography for the generic templates. Inner pages are out of scope for this
 * task, so this only keeps them readable instead of sitting under the sticky header.
 */
.site-main.container {
	padding-block: var(--space-7);
}

.entry {
	max-width: 720px;
	margin-inline: auto;
}

.entry__content {
	margin-block-start: var(--space-4);
}

.entry__content > * + * {
	margin-block-start: var(--space-4);
}

/* Utilities */

.visually-hidden:not(:focus):not(:active) {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

.skip-link:focus {
	position: absolute;
	z-index: var(--z-dialog);
	top: var(--space-1);
	left: var(--space-1);
	padding: var(--space-2) var(--space-3);
	border-radius: var(--radius-pill);
	background-color: var(--color-cta-primary-bg);
	color: var(--color-cta-primary-text);
	font-size: var(--font-p3);
	font-weight: 500;
}

/*
 * Entry animation. The prototype uses MOUSE_ENTER with SMART_ANIMATE EASE_OUT 1200ms,
 * which is the Figma idiom for "animates on appear": opacity 0 to 1 plus a 32px rise.
 *
 * The default state is visible on purpose. Only the script marks an element as animatable,
 * so without JavaScript, or with reduced motion, the content is never left invisible.
 */
[data-enter][data-entered='false'] {
	opacity: 0;
	transform: translateY(32px);
}

[data-enter][data-animatable] {
	transition: opacity var(--duration-enter) var(--ease-out),
		transform var(--duration-enter) var(--ease-out);
}

[data-enter][data-entered='true'] {
	opacity: 1;
	transform: none;
}

@media (prefers-reduced-motion: reduce) {
	[data-enter] {
		opacity: 1 !important;
		transform: none !important;
		transition: none !important;
	}
}

/* Focus: white on the red surfaces, dark red everywhere else. */

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

.is-on-dark :focus-visible,
.site-header :focus-visible,
.site-footer :focus-visible {
	outline-color: var(--color-focus-ring-on-brand);
}

/* Section heading block, shared by Produtos, Seu Negócio and Escola do Queijo. */

.section-heading {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: var(--space-3);
	width: 100%;
	max-width: var(--section-title-max);
	margin-inline: auto;
	text-align: center;
}

.section-heading__title {
	margin: 0;
}

.section-heading__description {
	margin: 0;
	color: var(--color-text);
	font-size: var(--font-p2);
	line-height: 1.4;
}

@media (max-width: 1279px) {
	:root {
		--container-gutter: 40px;
		/*
		 * The institutional values of the header do not fit four links at 1024px, where
		 * the institutional site shrinks them in vw. Here the main links step down to the
		 * 19px of the top bar, never less: Sand on Main Red is 3.46:1 and needs large text
		 * (findings F3). The gap drops to 32px and the links start one gap after the logo.
		 */
		--font-nav-main: var(--font-nav-top);
		--space-nav-main: var(--space-5);
		--header-nav-offset: calc(var(--logo-header-width) + var(--space-5));
	}
}

@media (max-width: 1023px) {
	:root {
		/* The Sand bar hides here: the header is the red bar alone, 70px in the institutional site. */
		--header-height: 72px;
		--logo-header-width: 100px;
		/* From here down the header follows the gutter of the page again. */
		--header-gutter: var(--container-gutter);
		--container-gutter: 32px;
		--section-padding-start: 96px;
		--section-padding-end: 80px;
	}
}

@media (max-width: 767px) {
	:root {
		--container-gutter: 24px;
		--section-padding-start: 64px;
		--section-padding-end: 56px;
		--font-p1: var(--font-p1-mobile);
	}
}

@media (max-width: 479px) {
	:root {
		--container-gutter: 20px;
	}
}

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