/* ==========================================================================
   val.fr 2027 — « Deux lectures »
   Design tokens + base components (header, switch, mobile menu, footer).
   Reference: docs/cahier-des-charges.md §3–4, docs/maquettes/.
   ========================================================================== */

/* ---------- Fonts (self-hosted, SIL OFL 1.1, no Google request) ---------- */

@font-face {
	font-family: "Bricolage Grotesque";
	src: url("../fonts/bricolage-grotesque-var.woff2") format("woff2-variations"),
		url("../fonts/bricolage-grotesque-var.woff2") format("woff2");
	font-weight: 300 700;
	font-style: normal;
	font-display: swap;
}

@font-face {
	font-family: "JetBrains Mono";
	src: url("../fonts/jetbrains-mono-var.woff2") format("woff2-variations"),
		url("../fonts/jetbrains-mono-var.woff2") format("woff2");
	font-weight: 400 500;
	font-style: normal;
	font-display: swap;
}

/* ---------- Tokens ---------- */

:root {
	--bg: #FFFFFF;
	--sf: #F4F5F7;
	--ink: #0F1115;
	--mu: #5B6270;
	--ln: #E6E8EC;
	--ac: #2A33E0;
	--acs: #E6E8FF;

	/* Provenance « Avec l’IA » (amber), Article.dc.html. */
	--exp-bg: #FFF8E6;
	--exp-bd: #E5C66A;
	--exp-fg: #7A5A00;

	/* Machine view: identical in both themes. */
	--mbg: #0E1020;
	--mtx: #C9CEF0;
	--mkey: #8A90FF;
	--mstr: #F2D58A;
	--mnum: #9FE3C0;
	--mcm: #8A90B8;

	--val-font: "Bricolage Grotesque", system-ui, -apple-system, "Segoe UI", sans-serif;
	--val-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
	--val-container: 1320px;
	--val-gutter: clamp(16px, 3vw, 40px);
	--val-header-h: 68px;
	--val-radius-btn: 12px;
	--val-radius-card: 18px;
	--val-radius-pill: 999px;
	--val-ease: 600ms ease;
	--val-top: var(--wp-admin--admin-bar--height, 0px);

	color-scheme: light;
}

:root[data-theme="dark"] {
	--bg: #0B0C0F;
	--sf: #16181D;
	--ink: #F2F3F5;
	--mu: #9AA1AD;
	--ln: #272A32;
	--ac: #8A90FF;
	--acs: rgba(138, 144, 255, .16);
	--exp-bg: rgba(242, 213, 138, .08);
	--exp-bd: rgba(242, 213, 138, .45);
	--exp-fg: #F2D58A;

	color-scheme: dark;
}

/* Blocksy reads its palette from these variables: feed it our tokens so
   content rendered by the parent theme follows the sun too. */
:root:root {
	--theme-palette-color-1: var(--ac);
	--theme-palette-color-2: var(--ac);
	--theme-palette-color-3: var(--ink);
	--theme-palette-color-4: var(--ink);
	--theme-palette-color-5: var(--ln);
	--theme-palette-color-6: var(--sf);
	--theme-palette-color-7: var(--bg);
	--theme-palette-color-8: var(--bg);
	--theme-text-color: var(--ink);
	--theme-headings-color: var(--ink);
	--theme-link-initial-color: var(--ac);
	--theme-link-hover-color: var(--ac);
	--theme-border-color: var(--ln);
	--theme-font-family: var(--val-font);
}

/* ---------- Base ---------- */

html {
	background: var(--bg);
}

body {
	margin: 0;
	background: var(--bg);
	color: var(--ink);
	font-family: var(--val-font);
	font-size: 18px;
	line-height: 1.55;
	font-optical-sizing: auto;
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
	font-family: var(--val-font);
	font-weight: 600;
	letter-spacing: -0.03em;
	color: var(--ink);
}

h1 { letter-spacing: -0.045em; }

.val-mono,
code, kbd, pre, samp {
	font-family: var(--val-mono);
	letter-spacing: 0;
}

body,
.val-header,
.val-header *,
.val-footer,
.val-footer *,
.val-menu,
.val-menu * {
	transition: background-color var(--val-ease), color var(--val-ease), border-color var(--val-ease), fill var(--val-ease);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
	outline: 2px solid var(--ac);
	outline-offset: 3px;
}

.val-container {
	box-sizing: border-box;
	max-width: var(--val-container);
	margin-inline: auto;
	padding-inline: var(--val-gutter);
}

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

/* ---------- Breadcrumb (articles, archives) ---------- */

.val-breadcrumb {
	display: flex;
	flex-wrap: wrap;
	gap: 0 8px;
	font-size: 13px;
	color: var(--mu);
}
.val-breadcrumb a {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	margin-block: -12px; /* 44 px target without changing the line */
	color: var(--mu);
}
.val-breadcrumb a:hover { color: var(--ac); }
.val-breadcrumb__current { color: var(--ink); }
.val-page-intro .val-breadcrumb + .val-display { margin-top: 24px; }

/* ---------- Two readings: human / machine zones ---------- */

html[data-lecture="machine"] .val-humain { display: none !important; }
html:not([data-lecture="machine"]) .val-machine { display: none !important; }

/* Machine code blocks (same palette in both themes). */
.val-code {
	box-sizing: border-box;
	font-family: var(--val-mono);
	font-size: 15px;
	line-height: 1.75;
	padding: clamp(20px, 3vw, 36px);
	border-radius: 16px;
	background: var(--mbg);
	color: var(--mtx);
	overflow-x: auto;
}
.val-code p { margin: 0; }
.val-code__k { color: var(--mkey); }
.val-code__s { color: var(--mstr); }
.val-code__n { color: var(--mnum); }
.val-code__c { color: var(--mcm); }

/* ---------- Header ---------- */

#header {
	position: sticky;
	top: var(--val-top);
	z-index: 30;
	background: var(--bg);
	border-bottom: 1px solid var(--ln);
}

.val-header__bar {
	min-height: var(--val-header-h);
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
}

.val-logo {
	display: inline-flex;
	align-items: center;
	gap: 12px;
	min-height: 44px;
	min-width: 44px; /* Mobile: the name is hidden, the sign alone is 25 px wide. */
	text-decoration: none;
	color: var(--ink);
	font-weight: 600;
	font-size: 17px;
	letter-spacing: -0.01em;
	white-space: nowrap;
}
.val-logo:hover { color: var(--ink); }
.val-logo__mark { flex: none; display: block; }
.val-logo__mark path { transition: fill var(--val-ease); }
/* Human logo (currentColor) or machine logo (indigo outline), per reading. */
.val-logo__mark--m,
html[data-lecture="machine"] .val-logo__mark--h { display: none; }
html[data-lecture="machine"] .val-logo__mark--m { display: block; }
.val-logo__sr {
	position: absolute;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

.val-sun {
	margin: 0;
	display: inline-flex;
	align-items: center;
	gap: 10px;
	font-size: 12px;
	line-height: 1.4;
	color: var(--mu);
}
.val-sun svg { flex: none; }
/* Header: always on one line; hidden under 1100 px, where the header links
   need the room (decision of 23.11.2026). Still in the footer and the mobile menu. */
.val-header__sun { white-space: nowrap; }
@media (max-width: 1099.98px) {
	.val-header__sun { display: none; }
}
:root[data-theme="dark"] .val-sun__day,
:root:not([data-theme="dark"]) .val-sun__night { display: none; }

.val-header__actions {
	display: inline-flex;
	align-items: center;
	gap: 12px;
}

.val-header__links {
	display: inline-flex;
	align-items: center;
	gap: 12px;
}

.val-header__link {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	padding-inline: 2px;
	font-size: 15px;
	font-weight: 500;
	color: var(--ink);
	text-decoration: underline;
	text-underline-offset: 5px;
	text-decoration-thickness: 1px;
}
.val-header__link:hover,
.val-header__link[aria-current="page"] { color: var(--ac); }

/* Switch « Humain | machine » */
.val-switch {
	display: inline-flex;
	padding: 4px;
	border-radius: var(--val-radius-pill);
	border: 1px solid var(--ln);
	background: var(--sf);
}
html:not(.val-js) .val-switch { display: none; }

.val-switch__btn {
	position: relative;
	min-height: 40px;
	padding: 0 16px;
	border: 0;
	border-radius: var(--val-radius-pill);
	background: transparent;
	color: var(--ink);
	font-family: var(--val-font);
	font-size: 15px;
	font-weight: 500;
	line-height: 1;
	cursor: pointer;
}
/* Visual height 38–40 px (mock-up), hit area 44 px (accessibility rule). */
.val-switch__btn::after {
	content: "";
	position: absolute;
	left: 0;
	right: 0;
	top: 50%;
	height: 44px;
	transform: translateY(-50%);
}
.val-switch__btn--machine {
	font-family: var(--val-mono);
	font-size: 13px;
	font-weight: 400;
}
/* Visual state comes from <html data-lecture>, set before paint: no flash. */
html:not([data-lecture="machine"]) .val-switch__btn--humain {
	background: var(--ink);
	color: var(--bg);
}
html[data-lecture="machine"] .val-switch__btn--machine {
	background: var(--mbg);
	color: var(--mtx);
}
.val-switch__btn:hover { color: var(--ac); }
html:not([data-lecture="machine"]) .val-switch__btn--humain:hover { color: var(--bg); }
html[data-lecture="machine"] .val-switch__btn--machine:hover { color: var(--mtx); }

/* Menu button (mobile only) */
.val-menu-btn {
	display: none;
	width: 44px;
	height: 44px;
	flex: none;
	align-items: center;
	justify-content: center;
	padding: 0;
	border-radius: var(--val-radius-btn);
	border: 1px solid var(--ln);
	background: transparent;
	color: var(--ink);
	cursor: pointer;
}
.val-menu-btn__close { display: none; }
.val-menu-btn[aria-expanded="true"] .val-menu-btn__open { display: none; }
.val-menu-btn[aria-expanded="true"] .val-menu-btn__close { display: block; }

/* ---------- Mobile menu ---------- */

.val-menu { display: none; }

@media (max-width: 759.98px) {
	:root { --val-header-h: 60px; }

	.val-header__bar {
		padding-inline: 16px;
		gap: 10px;
	}
	.val-logo { gap: 10px; font-size: 15px; }
	.val-logo__mark { width: 25px; height: 24px; }
	.val-logo__name {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0 0 0 0);
		white-space: nowrap;
	}
	.val-header__sun,
	.val-header__links { display: none; }
	.val-header__actions { gap: 8px; }

	.val-switch { padding: 3px; }
	.val-switch__btn { min-height: 38px; padding: 0 12px; font-size: 14px; }
	.val-switch__btn--machine { font-size: 12px; }

	html.val-js .val-menu-btn { display: inline-flex; }

	html.val-js .val-menu:not([hidden]) {
		position: fixed;
		/* Under the header, wherever it is (measured by lectures.js on opening). */
		top: var(--val-menu-top, calc(var(--val-top) + var(--val-header-h)));
		left: 0;
		right: 0;
		bottom: 0;
		z-index: 40;
		box-sizing: border-box;
		padding: 24px 20px;
		display: flex;
		flex-direction: column;
		overflow-y: auto;
		overscroll-behavior: contain;
		background: var(--bg);
		animation: val-menu-in 320ms cubic-bezier(.2, .8, .2, 1);
	}

	/*
	 * Scroll locked on <html> only: overflow on <body> too would make <body>
	 * the scroll container of the sticky header, which then went back to its
	 * place at the top of the page (out of sight once scrolled, close button
	 * included) and left a gap above the menu (fix of 24.11.2026).
	 */
	html.val-menu-open { overflow: hidden; }
	/* Blocksy sets overflow-x: hidden on <body>: once <html> is locked, that
	   alone makes <body> a scroll container. Neutral while the menu is open. */
	html.val-menu-open body { overflow: visible; }
}

/* Logged in, under 600 px: WordPress's admin bar scrolls with the page, so the
   header must stick to the very top, not under a bar that is gone. */
@media (max-width: 600px) {
	:root { --val-top: 0px; }
}

@keyframes val-menu-in {
	from { opacity: 0; transform: translateY(-12px); }
	to { opacity: 1; transform: none; }
}

.val-menu__list {
	list-style: none;
	margin: 0;
	padding: 0;
	border-top: 1px solid var(--ink);
}
.val-menu__list li { margin: 0; }

.val-menu__link {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	padding: 18px 0;
	border-bottom: 1px solid var(--ln);
	color: var(--ink);
	text-decoration: none;
	font-size: 32px;
	font-weight: 600;
	line-height: 1.15;
	letter-spacing: -0.03em;
}
.val-menu__link:hover,
.val-menu__link[aria-current="page"] { color: var(--ac); }

.val-menu__num {
	font-size: 11px;
	font-weight: 400;
	letter-spacing: 0;
	color: var(--mu);
}
.val-menu__link[aria-current="page"] .val-menu__num { color: inherit; }

.val-menu__chips {
	list-style: none;
	margin: 24px 0 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}
.val-menu__chips li { margin: 0; }

.val-chip {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	min-height: 44px;
	padding: 0 16px;
	box-sizing: border-box;
	border-radius: var(--val-radius-pill);
	border: 1px solid var(--ln);
	color: var(--ink);
	text-decoration: none;
	font-size: 15px;
}
.val-chip:hover { color: var(--ac); border-color: currentColor; }

.val-menu__foot {
	margin-top: auto;
	padding-top: 20px;
	border-top: 1px solid var(--ln);
}
.val-menu__foot .val-sun { gap: 8px; font-size: 11px; }
.val-menu__note {
	margin: 8px 0 0;
	font-size: 11px;
	color: var(--mu);
}

/* Short screens (iPhone SE, small Android): tighter menu, so that the links,
   the chips and the foot fit without scrolling. Links stay ≥ 44 px (50 px).
   Decision of 24.11.2026 (7 links in the mobile menu). */
@media (max-width: 759.98px) and (max-height: 760px) {
	html.val-js .val-menu:not([hidden]) { padding-top: 12px; padding-bottom: 16px; }
	.val-menu__link { padding: 10px 0; font-size: 26px; }
	.val-menu__chips { margin-top: 16px; }
	.val-menu__foot { padding-top: 12px; }
}

/* ---------- Footer ---------- */

#footer {
	background: var(--bg);
	color: var(--ink);
}

.val-footer {
	padding-top: 140px;
	padding-bottom: 40px;
}

.val-footer__human {
	border-top: 2px solid var(--ink);
	padding-top: 28px;
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: space-between;
	gap: 24px 48px;
}

.val-footer__title {
	margin: 0;
	font-size: clamp(28px, 3vw, 42px);
	font-weight: 600;
	letter-spacing: -0.03em;
	line-height: 1.1;
}

.val-footer__email {
	margin-top: 10px;
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	font-size: 19px;
	color: var(--ink);
	text-underline-offset: 6px;
}

.val-footer__nav {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 24px;
	font-size: 16px;
}
.val-footer__nav a {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	min-width: 44px;
	color: var(--ink);
}
.val-footer__nav a.val-footer__muted { color: var(--mu); }
.val-footer a:hover { color: var(--ac); }

.val-footer__ria-line { margin: 20px 0 0; }
.val-footer__ria {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	min-height: 44px;
	font-size: 12px;
	color: var(--mu);
	text-decoration: none;
}
.val-footer__ria:hover { color: var(--ac); }
.val-ria-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--ac); }
.val-footer__ria-line + .val-footer__meta { margin-top: 2px; }

.val-footer__meta {
	margin: 24px 0 0;
	font-size: 12px;
	color: var(--mu);
}

/* ---------- Reduced motion ---------- */

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

/* ---------- Provenance badge (article banner, Écrits) ---------- */

.val-prov-badge {
	display: inline-flex;
	align-items: center;
	padding: 3px 10px;
	border-radius: var(--val-radius-pill);
	border: 1px solid var(--ln);
	background: var(--sf);
	color: var(--ink);
	font-size: 12px;
	font-weight: 500;
	line-height: 1.5;
	white-space: nowrap;
}
.val-prov-badge--ia { background: var(--exp-bg); border-color: var(--exp-bd); color: var(--exp-fg); }
