/*
 * base.css — remise à zéro, réglages de document, états globaux.
 *
 * Transposé de src/styles/global.css du thème Astro Lipi (MIT).
 * Ne contient aucune règle de mise en page : voir layout.css.
 */

/* ─── Remise à zéro minimale ─────────────────────────────────────────────── */

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

body,
h1,
h2,
h3,
h4,
h5,
h6,
p,
figure,
blockquote,
dl,
dd {
	margin: 0;
}

/* ─── Document ───────────────────────────────────────────────────────────── */

html {
	/* Le corps de texte grandit légèrement avec la fenêtre, puis se stabilise. */
	font-size: clamp(16px, 1rem + 0.15vw, 18px);
	scroll-behavior: smooth;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	text-rendering: optimizeLegibility;

	/* Sur macOS, scrollbar-color est ignoré tant que scrollbar-width n'est pas
	   défini : les barres de défilement natives sont en surimpression. */
	scrollbar-width: auto;
	scrollbar-color: var(--muted) transparent;

	/* Cases à cocher, curseurs et champs natifs prennent la couleur d'accent. */
	accent-color: var(--primary);
}

body {
	margin: 0;
	background-color: var(--background);
	color: var(--foreground);
	font-family: var(--font-content);
	font-size: var(--text-base);
	line-height: var(--leading-relaxed);

	/* Literata porte un axe optique (opsz 7-72) : le rendu s'ajuste tout seul
	   à la taille de rendu, avec des empattements plus fins dans les titres. */
	font-optical-sizing: auto;

	/* Cale la hauteur d'x de Georgia sur celle de Literata pendant le swap :
	   le texte ne saute plus quand la police web finit de charger. */
	font-size-adjust: from-font;

	display: flex;
	flex-direction: column;
	min-height: 100vh;
}

/* ─── Texture papier ─────────────────────────────────────────────────────────
   Bruit fractal en SVG, superposé à toute la fenêtre et insensible aux clics.
   Reproduit le grain du fond parchemin de Lipi.
   ────────────────────────────────────────────────────────────────────────── */

body::before {
	content: "";
	position: fixed;
	inset: 0;
	z-index: 9999;
	pointer-events: none;
	opacity: var(--texture-opacity);
	background-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/></filter><rect width='200' height='200' filter='url(%23n)'/></svg>");
	background-repeat: repeat;
	background-size: 200px 200px;
}

/* ─── Rendu du texte ─────────────────────────────────────────────────────── */

h1,
h2,
h3 {
	text-wrap: balance;
}

p,
li,
blockquote,
figcaption {
	text-wrap: pretty;
}

:target {
	scroll-margin-block: 6rem;
}

/* ─── Liens et boutons ───────────────────────────────────────────────────── */

a {
	color: inherit;
	text-decoration-color: var(--border);
	text-underline-offset: 0.25em;
	transition: color 200ms ease, text-decoration-color 200ms ease;
}

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

button {
	font: inherit;
	color: inherit;
}

button:not(:disabled),
[role="button"]:not(:disabled) {
	cursor: pointer;
}

button:not(:disabled) {
	transition: transform 150ms ease;
}

button:not(:disabled):active {
	transform: scale(0.96);
}

/* ─── Focus ──────────────────────────────────────────────────────────────────
   Contour pointillé repris de Lipi, appliqué uniquement au parcours clavier.
   ────────────────────────────────────────────────────────────────────────── */

:focus-visible {
	outline: 2px dashed var(--accent-foreground);
	outline-offset: 2px;
	border-radius: 2px;
}

a:focus-visible,
button:focus-visible {
	text-decoration: none;
}

/* ─── Sélection ──────────────────────────────────────────────────────────── */

::selection {
	background: color-mix(in srgb, var(--primary) 15%, transparent);
	color: var(--foreground);
}

/* ─── Médias et formulaires ──────────────────────────────────────────────── */

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

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

/* ─── Accessibilité ──────────────────────────────────────────────────────────
   .screen-reader-text est la classe attendue par WordPress : le core et les
   extensions l'appliquent à des libellés qui doivent rester audibles.
   ────────────────────────────────────────────────────────────────────────── */

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

.skip-link:focus {
	position: fixed !important;
	top: 0.5rem;
	left: 0.5rem;
	z-index: 10000;
	width: auto;
	height: auto;
	margin: 0;
	padding: 0.75rem 1.25rem;
	clip-path: none;
	background: var(--background);
	color: var(--foreground);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	font-family: var(--font-ui);
	font-size: var(--text-sm);
	text-decoration: none;
}

/* ─── Mouvement réduit ───────────────────────────────────────────────────── */

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

	body::before {
		display: none;
	}

	*,
	*::before,
	*::after {
		animation-duration: 0.01ms !important;
		animation-iteration-count: 1 !important;
		transition-duration: 0.01ms !important;
		scroll-behavior: auto !important;
	}
}
