/**
 * AENS — Base : polices, reset, typographie, éléments natifs, accessibilité.
 *
 * @package aens-theme
 */

/* -------------------------------------------------------------------------
 * 1. POLICES AUTO-HÉBERGÉES (variables, latin + latin-ext)
 * ---------------------------------------------------------------------- */

@font-face {
	font-family: "Montserrat";
	font-style: normal;
	font-weight: 100 900;
	font-display: swap;
	src: url("../fonts/montserrat-var-latin.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: 100 900;
	font-display: swap;
	src: url("../fonts/montserrat-var-latin-ext.woff2") format("woff2");
	unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308,
		U+0329, 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: "Inter";
	font-style: normal;
	font-weight: 100 900;
	font-display: swap;
	src: url("../fonts/inter-var-latin.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: "Inter";
	font-style: normal;
	font-weight: 100 900;
	font-display: swap;
	src: url("../fonts/inter-var-latin-ext.woff2") format("woff2");
	unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308,
		U+0329, 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;
}

/* -------------------------------------------------------------------------
 * 2. RESET RAISONNÉ
 * ---------------------------------------------------------------------- */

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

html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
	scroll-behavior: smooth;
	/* Décalage d'ancre pour le header sticky. */
	scroll-padding-top: 6rem;
}

@media (prefers-reduced-motion: reduce) {
	html {
		scroll-behavior: auto;
	}
}

body {
	margin: 0;
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	background-color: var(--color-bg-base);
	color: var(--color-text-primary);
	font-family: var(--font-body);
	font-size: var(--text-body-md);
	line-height: 1.6;
	font-weight: 400;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	text-rendering: optimizeLegibility;
}

/* Transition de thème limitée aux propriétés sûres. */
body,
.aens-card,
.aens-btn,
.aens-field input,
.aens-field select,
.aens-field textarea,
.aens-header,
.aens-footer {
	transition:
		color var(--dur-base) var(--ease),
		background-color var(--dur-base) var(--ease),
		border-color var(--dur-base) var(--ease);
}

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

/* -------------------------------------------------------------------------
 * 3. TYPOGRAPHIE
 * ---------------------------------------------------------------------- */

h1, h2, h3, h4, h5, h6 {
	font-family: var(--font-heading);
	color: var(--color-text-primary);
	margin: 0 0 var(--space-xs);
	text-wrap: balance;
}

h1 {
	font-size: var(--text-display-xl);
	line-height: 1.2;
	letter-spacing: -0.02em;
	font-weight: 700;
}

h2 {
	font-size: var(--text-headline-lg);
	line-height: 1.2;
	letter-spacing: -0.015em;
	font-weight: 700;
}

h3 {
	font-size: var(--text-headline-md);
	line-height: 1.27;
	font-weight: 600;
}

h4 {
	font-size: var(--text-headline-sm);
	line-height: 1.36;
	font-weight: 600;
}

h5 {
	font-size: var(--text-title-md);
	line-height: 1.44;
	font-weight: 600;
}

h6 {
	font-size: var(--text-body-md);
	line-height: 1.5;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

p,
ul,
ol,
dl,
blockquote,
figure,
table,
pre {
	margin: 0 0 var(--space-sm);
}

p:last-child,
ul:last-child,
ol:last-child {
	margin-bottom: 0;
}

/* Jamais de texte justifié. */
p {
	text-align: start;
	text-wrap: pretty;
}

strong, b { font-weight: 600; }
em, i { font-style: italic; }
small { font-size: var(--text-body-sm); }

/* Le texte légal ne descend jamais sous 12px. */
.aens-legal,
.aens-legal small {
	font-size: 0.75rem;
	line-height: 1.5;
}

blockquote {
	padding-inline-start: var(--space-md);
	border-inline-start: 3px solid var(--color-cta-vivid);
	color: var(--color-text-primary);
	font-family: var(--font-heading);
	font-size: var(--text-headline-sm);
	line-height: 1.45;
	font-weight: 600;
}

blockquote cite {
	display: block;
	margin-top: var(--space-2xs);
	font-family: var(--font-body);
	font-size: var(--text-body-sm);
	font-weight: 400;
	font-style: normal;
	color: var(--color-text-secondary);
}

hr {
	border: 0;
	border-top: 1px solid var(--color-border-subtle);
	margin: var(--space-lg) 0;
}

code, kbd, samp, pre {
	font-family: ui-monospace, "Cascadia Code", "Segoe UI Mono", Menlo, Consolas, monospace;
	font-size: 0.9em;
}

pre {
	overflow-x: auto;
	padding: var(--space-sm);
	background: var(--color-bg-subtle);
	border-radius: var(--radius-md);
}

/* -------------------------------------------------------------------------
 * 4. LIENS
 * ---------------------------------------------------------------------- */

a {
	color: var(--color-text-link);
	text-decoration-thickness: 1px;
	text-underline-offset: 0.2em;
	transition: color var(--dur-fast) var(--ease);
}

a:hover,
a:focus-visible {
	color: var(--color-text-link-hover);
}

/* -------------------------------------------------------------------------
 * 5. FOCUS VISIBLE — jamais supprimé, toujours 3px
 * ---------------------------------------------------------------------- */

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

/* Les navigateurs qui ne gèrent pas :focus-visible gardent un focus visible. */
:focus:not(:focus-visible) {
	outline: none;
}

/* -------------------------------------------------------------------------
 * 6. MÉDIAS
 * ---------------------------------------------------------------------- */

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

img {
	background-color: var(--color-bg-subtle);
}

figure {
	margin-inline: 0;
}

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

/* En mode sombre, léger voile de lisibilité sur les photos. */
.dark .aens-media img,
.dark .wp-block-image img {
	filter: brightness(0.92);
}

/* -------------------------------------------------------------------------
 * 7. TABLEAUX
 * ---------------------------------------------------------------------- */

table {
	width: 100%;
	border-collapse: collapse;
	font-size: var(--text-body-sm);
}

th,
td {
	padding: var(--space-2xs) var(--space-xs);
	border-bottom: 1px solid var(--color-border-subtle);
	text-align: start;
	vertical-align: top;
}

th {
	font-weight: 600;
	color: var(--color-text-primary);
}

.aens-table-scroll {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

/* -------------------------------------------------------------------------
 * 8. UTILITAIRES D'ACCESSIBILITÉ
 * ---------------------------------------------------------------------- */

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

.screen-reader-text:focus,
.aens-skip-link:focus {
	position: fixed !important;
	top: var(--space-2xs);
	left: var(--space-2xs);
	z-index: calc(var(--z-toast) + 1);
	width: auto;
	height: auto;
	padding: var(--space-2xs) var(--space-sm);
	margin: 0;
	overflow: visible;
	clip: auto;
	clip-path: none;
	background: var(--color-cta);
	color: var(--color-cta-text);
	font-family: var(--font-heading);
	font-size: var(--text-label-lg);
	font-weight: 600;
	text-decoration: none;
	border-radius: var(--radius-md);
	box-shadow: var(--shadow-2);
}

/* Le lien d'évitement n'occupe aucune place tant qu'il n'a pas le focus. */
.aens-skip-link {
	position: absolute;
	left: -9999px;
	top: 0;
}

/* Cible tactile minimale sur mobile. */
@media (max-width: 1023px) {
	.aens-tap-target {
		min-width: var(--tap-target);
		min-height: var(--tap-target);
		display: inline-flex;
		align-items: center;
		justify-content: center;
	}
}

/* -------------------------------------------------------------------------
 * 9. SÉLECTION & DIVERS
 * ---------------------------------------------------------------------- */

::selection {
	background: var(--color-surface-leaf);
	color: var(--color-text-primary);
}

[hidden] {
	display: none !important;
}

/* Icônes du sprite SVG local. */
.aens-icon {
	width: 1.25em;
	height: 1.25em;
	flex: none;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.75;
	stroke-linecap: round;
	stroke-linejoin: round;
	display: inline-block;
	vertical-align: -0.25em;
}

.aens-icon--sm { width: 1em;    height: 1em; }
.aens-icon--lg { width: 1.5rem; height: 1.5rem; }
.aens-icon--xl { width: 2rem;   height: 2rem; }

/* Largeur de lecture confortable : 50–75 caractères. */
.aens-prose {
	max-width: var(--measure);
}

.aens-prose > * + * {
	margin-top: var(--space-sm);
}

.aens-prose h2,
.aens-prose h3,
.aens-prose h4 {
	margin-top: var(--space-lg);
}

.aens-prose ul,
.aens-prose ol {
	padding-inline-start: var(--space-md);
}

.aens-prose li + li {
	margin-top: var(--space-3xs);
}
