/**
 * Design system institutionnel MEEFQ.
 *
 * Tokens, primitives et composants réutilisables.
 * Palette républicaine : vert porteur d'identité, jaune en accent d'action,
 * rouge réservé aux alertes. Glassmorphism sobre : surfaces réduites,
 * flou contenu, lisibilité prioritaire.
 *
 * Les couleurs sont injectées en variables CSS depuis config-ministere.json
 * (voir functions.php) : ce fichier n'utilise que des tokens.
 */

/* ---------- 1. Tokens ---------- */

:root {
	/* Couleurs (surchargées depuis la config du ministère) */
	--c-primary: #006b3f;
	--c-primary-600: #005a35;
	--c-primary-050: #e9f4ef;
	--c-secondary: #fcd116;
	--c-accent: #d21034;
	--c-dark: #071b14;
	--c-light: #f7faf8;
	--c-white: #ffffff;
	--c-ink: #14231c;
	--c-ink-soft: #47584f;
	--c-line: rgba(7, 27, 20, 0.12);
	--c-glass: rgba(255, 255, 255, 0.72);
	--c-glass-border: rgba(255, 255, 255, 0.55);

	/* Typographie : stack système fiable et rapide */
	--font-base: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
		"Helvetica Neue", Arial, sans-serif;
	--fs-xs: 0.8125rem;
	--fs-sm: 0.9375rem;
	--fs-md: 1.0625rem;
	--fs-lg: clamp(1.15rem, 1rem + 0.6vw, 1.375rem);
	--fs-xl: clamp(1.45rem, 1.2rem + 1vw, 1.875rem);
	--fs-2xl: clamp(1.9rem, 1.4rem + 2vw, 2.75rem);
	--lh-body: 1.65;
	--lh-heading: 1.2;

	/* Espacement et rayons */
	--sp-1: 0.375rem;
	--sp-2: 0.75rem;
	--sp-3: 1.25rem;
	--sp-4: 2rem;
	--sp-5: 3rem;
	--sp-6: 4.5rem;
	--radius-sm: 8px;
	--radius-md: 14px;
	--radius-lg: 22px;

	/* Ombres douces */
	--shadow-sm: 0 1px 3px rgba(7, 27, 20, 0.08);
	--shadow-md: 0 6px 24px rgba(7, 27, 20, 0.1);
	--shadow-lg: 0 16px 48px rgba(7, 27, 20, 0.14);

	/* Transitions */
	--ease: cubic-bezier(0.25, 0.6, 0.3, 1);
	--t-fast: 160ms var(--ease);
	--t-med: 280ms var(--ease);

	/* Largeur de contenu */
	--container: 76rem;
}

/* ---------- 2. Base ---------- */

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

body {
	margin: 0;
	font-family: var(--font-base);
	font-size: var(--fs-md);
	line-height: var(--lh-body);
	color: var(--c-ink);
	background-color: var(--c-light);
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
	line-height: var(--lh-heading);
	color: var(--c-dark);
	margin: 0 0 var(--sp-2);
	font-weight: 700;
	letter-spacing: -0.01em;
}

h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }

p { margin: 0 0 var(--sp-2); }

a {
	color: var(--c-primary);
	text-decoration-thickness: 1px;
	text-underline-offset: 3px;
	transition: color var(--t-fast);
}

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

img {
	max-width: 100%;
	height: auto;
	display: block;
}

/* Focus visible : accessibilité clavier prioritaire */
:focus-visible {
	outline: 3px solid var(--c-secondary);
	outline-offset: 2px;
	border-radius: 4px;
}

/* Lien d'évitement */
.skip-link {
	position: absolute;
	left: -9999px;
	top: 0;
	z-index: 999;
	background: var(--c-dark);
	color: var(--c-white);
	padding: var(--sp-2) var(--sp-3);
	border-radius: 0 0 var(--radius-sm) 0;
}

.skip-link:focus {
	left: 0;
	color: var(--c-white);
}

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

.container {
	max-width: var(--container);
	margin-inline: auto;
	padding-inline: var(--sp-3);
}

/* ---------- 3. Surfaces glass institutionnelles ---------- */

/* Règle d'or : le glass ne porte jamais de texte long sur fond chargé.
   Surfaces limitées, opacité ≥ 0.72, repli net sans backdrop-filter. */
.glass {
	background: var(--c-glass);
	border: 1px solid var(--c-glass-border);
	border-radius: var(--radius-md);
	box-shadow: var(--shadow-md);
}

@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
	.glass {
		-webkit-backdrop-filter: blur(14px) saturate(1.15);
		backdrop-filter: blur(14px) saturate(1.15);
	}
}

.glass--deep {
	background: rgba(7, 27, 20, 0.66);
	border-color: rgba(255, 255, 255, 0.16);
	color: var(--c-white);
}

.glass--deep h1,
.glass--deep h2,
.glass--deep h3 {
	color: var(--c-white);
}

/* Décor poly : halos et facettes discrets, jamais au-dessus du texte */
.poly-decor {
	position: absolute;
	inset: 0;
	overflow: hidden;
	pointer-events: none;
	z-index: 0;
}

.poly-decor span {
	position: absolute;
	border-radius: 30% 70% 60% 40% / 50% 40% 60% 50%;
	filter: blur(60px);
	opacity: 0.35;
}

.poly-decor .p1 {
	width: 34rem;
	height: 34rem;
	top: -12rem;
	right: -8rem;
	background: radial-gradient(circle, var(--c-secondary), transparent 70%);
}

.poly-decor .p2 {
	width: 28rem;
	height: 28rem;
	bottom: -10rem;
	left: -6rem;
	background: radial-gradient(circle, var(--c-primary), transparent 70%);
}

/* ---------- 4. Boutons ---------- */

.btn {
	display: inline-flex;
	align-items: center;
	gap: 0.5em;
	padding: 0.72em 1.5em;
	min-height: 44px; /* zone tactile suffisante */
	border-radius: var(--radius-sm);
	border: 2px solid transparent;
	font-size: var(--fs-sm);
	font-weight: 600;
	text-decoration: none;
	cursor: pointer;
	transition: background-color var(--t-fast), color var(--t-fast),
		border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}

.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn--primary {
	background: var(--c-primary);
	color: var(--c-white);
}

.btn--primary:hover {
	background: var(--c-primary-600);
	color: var(--c-white);
	box-shadow: var(--shadow-md);
}

.btn--secondary {
	background: transparent;
	color: var(--c-primary);
	border-color: var(--c-primary);
}

.btn--secondary:hover {
	background: var(--c-primary-050);
	color: var(--c-primary-600);
}

/* Bouton institutionnel : fond sombre, usage protocolaire */
.btn--institutional {
	background: var(--c-dark);
	color: var(--c-white);
}

.btn--institutional:hover {
	background: #10281f;
	color: var(--c-secondary);
}

/* Appel à l'action : jaune doré, réservé aux actions citoyennes clés */
.btn--cta {
	background: var(--c-secondary);
	color: var(--c-dark);
}

.btn--cta:hover {
	background: #ffdc4a;
	color: var(--c-dark);
	box-shadow: var(--shadow-md);
}

.btn--download {
	background: var(--c-white);
	color: var(--c-primary);
	border-color: var(--c-line);
	box-shadow: var(--shadow-sm);
}

.btn--download:hover { border-color: var(--c-primary); color: var(--c-primary-600); }

.btn--download::before {
	content: "";
	width: 1em;
	height: 1em;
	background-color: currentColor;
	-webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3v12"/><path d="M6 11l6 6 6-6"/><path d="M4 21h16"/></svg>') center / contain no-repeat;
	mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round"><path d="M12 3v12"/><path d="M6 11l6 6 6-6"/><path d="M4 21h16"/></svg>') center / contain no-repeat;
}

.btn--filter {
	background: var(--c-white);
	color: var(--c-ink-soft);
	border-color: var(--c-line);
	min-height: 40px;
	padding: 0.45em 1.1em;
}

.btn--filter[aria-pressed="true"],
.btn--filter.is-active {
	background: var(--c-primary);
	border-color: var(--c-primary);
	color: var(--c-white);
}

.btn--alert {
	background: var(--c-accent);
	color: var(--c-white);
}

.btn--alert:hover { background: #b30d2c; color: var(--c-white); }

/* ---------- 5. Badges ---------- */

.badge {
	display: inline-block;
	padding: 0.22em 0.75em;
	border-radius: 999px;
	font-size: var(--fs-xs);
	font-weight: 700;
	letter-spacing: 0.02em;
	text-transform: uppercase;
}

.badge--theme {
	background: var(--c-primary-050);
	color: var(--c-primary-600);
}

.badge--ouvert {
	background: #e6f6ec;
	color: #0c6b34;
}

.badge--cloture {
	background: #f2f2f2;
	color: #5a5a5a;
}

.badge--en-evaluation {
	background: #fdf3d5;
	color: #7a5c00;
}

.badge--resultats-publies {
	background: #e7effb;
	color: #1d4e94;
}

.badge--soon {
	background: #fdeaea;
	color: var(--c-accent);
	margin-left: 0.4em;
}

.badge--type {
	background: var(--c-dark);
	color: var(--c-white);
}

/* ---------- 6. Cards ---------- */

.card {
	position: relative;
	display: flex;
	flex-direction: column;
	background: var(--c-white);
	border: 1px solid var(--c-line);
	border-radius: var(--radius-md);
	box-shadow: var(--shadow-sm);
	overflow: hidden;
	transition: transform var(--t-med), box-shadow var(--t-med), border-color var(--t-med);
}

.card:hover,
.card:focus-within {
	transform: translateY(-3px);
	box-shadow: var(--shadow-md);
	border-color: rgba(0, 107, 63, 0.35);
}

.card__media {
	aspect-ratio: 16 / 10;
	background: var(--c-primary-050);
}

.card__media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.card__body {
	display: flex;
	flex-direction: column;
	gap: var(--sp-1);
	padding: var(--sp-3);
	flex: 1;
}

.card__meta {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 0.5em;
	font-size: var(--fs-xs);
	color: var(--c-ink-soft);
}

.card__title {
	font-size: var(--fs-lg);
	margin: 0;
}

.card__title a {
	color: var(--c-dark);
	text-decoration: none;
}

/* Toute la card est cliquable via le pseudo-élément du lien titre */
.card__title a::after {
	content: "";
	position: absolute;
	inset: 0;
}

.card__title a:hover { color: var(--c-primary); }

.card__excerpt {
	color: var(--c-ink-soft);
	font-size: var(--fs-sm);
	margin: 0;
}

.card__footer {
	margin-top: auto;
	padding-top: var(--sp-2);
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--sp-2);
	font-size: var(--fs-sm);
}

/* Variante glass : réservée aux fonds décorés (hero, bandeaux) */
.card--glass {
	background: var(--c-glass);
	border-color: var(--c-glass-border);
}

/* Card document : rangée compacte avec icône de type */
.card--document .card__body { flex-direction: row; align-items: center; gap: var(--sp-3); }

.doc-icon {
	flex: none;
	width: 52px;
	height: 52px;
	display: grid;
	place-items: center;
	border-radius: var(--radius-sm);
	background: var(--c-primary-050);
	color: var(--c-primary);
	font-size: 0.8rem;
	font-weight: 800;
	letter-spacing: 0.04em;
}

/* ---------- 7. Formulaires ---------- */

input[type="text"],
input[type="search"],
input[type="email"],
input[type="date"],
select,
textarea {
	width: 100%;
	padding: 0.65em 0.9em;
	border: 1.5px solid var(--c-line);
	border-radius: var(--radius-sm);
	font: inherit;
	color: var(--c-ink);
	background: var(--c-white);
	transition: border-color var(--t-fast);
}

input:focus,
select:focus,
textarea:focus {
	border-color: var(--c-primary);
	outline: none;
	box-shadow: 0 0 0 3px rgba(0, 107, 63, 0.15);
}

label {
	font-weight: 600;
	font-size: var(--fs-sm);
	display: inline-block;
	margin-bottom: 0.3em;
}

/* ---------- 8. Utilitaires ---------- */

.section {
	padding-block: var(--sp-5);
}

.section--tinted { background: var(--c-white); }

.section__head {
	display: flex;
	align-items: end;
	justify-content: space-between;
	gap: var(--sp-3);
	margin-bottom: var(--sp-4);
}

.section__head h2 { margin: 0; }

.section__head .section__link { white-space: nowrap; font-weight: 600; }

.grid {
	display: grid;
	gap: var(--sp-3);
}

.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
.grid--4 { grid-template-columns: repeat(4, 1fr); }

.empty-state {
	text-align: center;
	padding: var(--sp-5) var(--sp-3);
	color: var(--c-ink-soft);
	background: var(--c-white);
	border: 1px dashed var(--c-line);
	border-radius: var(--radius-md);
}
