/**
 * Chantilo — header and « Les projets » (design-system.md §5). Markup: inc/20-menu.php, behaviour: assets/js/menu.js.
 * ≥ 1024 px: soft pills, menu-card mega panels, search panel, pistachio devis pill.
 * < 1024 px: burger (two lines + a tilted mustard brick, like the last brick of the logo) opening a bottom sheet with a measuring-line top edge.
 */

/* ── Header bar (white, not sticky) ───────────────── */
.ch-site-header { position: relative; z-index: 60; }
.ch-header { position: relative; background: var(--ch-base); border-bottom: 1px solid var(--ch-a6); }
.ch-header__bar {
	box-sizing: border-box; max-width: calc(var(--ch-wide) + 2 * var(--ch-gutter)); margin: 0 auto !important;
	padding: 12px var(--ch-gutter); min-height: 72px; gap: 12px !important; align-items: center !important;
}
.ch-logo { flex: none; margin: 0; line-height: 0; }
.ch-logo a { display: inline-flex; align-items: center; min-height: 44px; }
.ch-logo img { width: 132px !important; height: auto; }

.ch-menu { flex: 1; display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-width: 0; }
.ch-menu__list { display: none; list-style: none; margin: 0; padding: 0; }
.ch-menu__item { margin: 0; }
.ch-menu__pill {
	position: relative; box-sizing: border-box; display: inline-flex; align-items: center; gap: .3rem; min-height: 44px; padding: .5rem .95rem;
	border: 0; border-radius: var(--ch-radius); background: transparent; color: var(--ch-contrast); cursor: pointer;
	font-family: var(--ch-font-h); font-weight: 600; font-size: 1rem; line-height: 1.1; text-decoration: none; white-space: nowrap;
	transition: background-color .15s ease, color .15s ease;
}
.ch-menu__pill:hover, .ch-menu__pill[aria-expanded="true"] { background: var(--ch-a2); color: var(--ch-contrast); }
.ch-menu__chev { width: 18px; height: 18px; transition: transform .2s ease; }
.ch-menu__pill[aria-expanded="true"] .ch-menu__chev { transform: rotate(180deg); }
.ch-menu__short { display: none; }
/* Active item: raspberry pill with a light rule under the label. */
.ch-menu__item.is-active > .ch-menu__pill { background: var(--ch-a3); color: var(--ch-base); padding-bottom: .7rem; }
.ch-menu__item.is-active > .ch-menu__pill::after {
	content: ""; position: absolute; left: 50%; bottom: 6px; width: 24px; height: 5px; transform: translateX(-50%); background: var(--ch-a5);
	background: linear-gradient(var(--ch-a1), var(--ch-a1)) left bottom / 100% 2px no-repeat, var(--ch-ticks) left bottom / 100% 6px no-repeat; -webkit-mask: none; mask: none;
}

.ch-menu__tools { display: flex; align-items: center; gap: 8px; flex: none; }
.ch-menu__search {
	display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border-radius: 50%; border: 1.5px solid var(--ch-a6);
	background: var(--ch-base); color: var(--ch-contrast); cursor: pointer;
}
.ch-menu__search:hover, .ch-menu__search[aria-expanded="true"] { background: var(--ch-a2); border-color: var(--ch-a2); }
.ch-menu__search .ch-icon { width: 22px; height: 22px; }
.ch-menu__cta { display: none; min-height: 44px; padding: .55rem 1.2rem; white-space: nowrap; }

.ch-burger {
	display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 16px 0 14px; border-radius: var(--ch-radius);
	border: 1.5px solid var(--ch-contrast); background: var(--ch-base); color: var(--ch-contrast); cursor: pointer;
	font-family: var(--ch-font-h); font-weight: 700; font-size: 1rem;
}
.ch-burger:hover { background: var(--ch-a2); }
.ch-burger__lines { position: relative; display: grid; gap: 5px; width: 24px; }
.ch-burger__lines span { display: block; height: 2.5px; border-radius: 2px; background: currentColor; }
.ch-burger__lines span:nth-child(2) { width: 16px; }
.ch-burger__lines i { position: absolute; right: -1px; bottom: -3px; width: 10px; height: 6px; border-radius: 1.5px; background: var(--ch-a1); transform: rotate(-14deg); }
.ch-burger-nojs { display: none; }
html:not(.ch-js) .ch-burger { display: none; }
html:not(.ch-js) .ch-burger-nojs { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: var(--ch-radius); border: 1.5px solid var(--ch-contrast); color: var(--ch-contrast); font-family: var(--ch-font-h); font-weight: 700; text-decoration: none; }
html:not(.ch-js) .ch-menu__search { display: none; }

/* ── Mega panel: a menu card ──────────────────────── */
.ch-mega { position: absolute; left: 0; right: 0; top: 100%; z-index: 70; box-sizing: border-box; padding: 10px var(--ch-gutter) 0; }
.ch-mega:not([hidden]) { animation: ch-drop .18s ease-out; }
html:not(.ch-js) .ch-menu__item--cat:is(:hover, :focus-within) .ch-mega { display: block; }
/* ── Search panel ─────────────────────────────────── */
.ch-search-panel { position: absolute; left: 0; right: 0; top: 100%; z-index: 70; box-sizing: border-box; padding: 10px var(--ch-gutter) 0; }
.ch-search-panel:not([hidden]) { animation: ch-drop .18s ease-out; }
.ch-search-panel__inner { box-sizing: border-box; max-width: 640px; margin-left: auto; padding: 22px; background: var(--ch-base); border-radius: 24px; box-shadow: var(--ch-shadow-lg); border: 1px solid var(--ch-a6); }
@media (min-width: 1304px) { .ch-search-panel__inner { margin-right: calc((100% - var(--ch-wide)) / 2); } }

/* ── Bottom sheet (< 1024 px) ─────────────────────── */
.ch-sheet {
	position: fixed; inset: auto 0 0 0; width: 100%; max-width: 100%; max-height: 100%; margin: auto 0 0; padding: 0;
	border: 0; background: transparent; color: var(--ch-contrast); overflow: visible;
}
.ch-sheet::backdrop { background: rgba(28, 43, 37, .5); }
.ch-sheet[open]::backdrop { animation: ch-fade .25s ease-out; }
.ch-sheet__inner { position: relative; display: flex; flex-direction: column; max-height: min(88vh, 88dvh); background: var(--ch-a5); }
/* Top edge of the sheet: rounded, with a fine measuring line under the handle. */
.ch-sheet__inner { border-radius: 26px 26px 0 0; }
.ch-sheet__inner::before { content: none; }
.ch-sheet[open] .ch-sheet__inner { animation: ch-up .32s cubic-bezier(.2, .8, .2, 1); }
.ch-sheet.is-closing .ch-sheet__inner { animation: ch-down .26s ease-in forwards; }
.ch-sheet.is-closing::backdrop { opacity: 0; transition: opacity .26s; }
.ch-sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px var(--ch-gutter) 6px; }
.ch-sheet__head::before { content: ""; position: absolute; left: 50%; top: 6px; width: 44px; height: 5px; margin-left: -22px; border-radius: 3px; background: var(--ch-a6); }
.ch-sheet__title { margin: 8px 0 0; font-family: var(--ch-font-h); font-weight: 800; font-size: 1.35rem; letter-spacing: -.02em; }
.ch-sheet__close { display: grid; place-items: center; width: 44px; height: 44px; margin-top: 6px; padding: 0; border-radius: 50%; border: 0; background: var(--ch-base); color: var(--ch-contrast); cursor: pointer; box-shadow: inset 0 0 0 1.5px var(--ch-a6); }
.ch-sheet__body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 6px var(--ch-gutter) 16px; }
.ch-search--sheet { margin-bottom: 16px; }
.ch-search--sheet .ch-search__label { font-size: .95rem; }
.ch-sheet__list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ch-sheet__link, .ch-acc__btn {
	box-sizing: border-box; display: flex; align-items: center; gap: 12px; width: 100%; min-height: 58px; padding: 6px 20px;
	border: 1px solid var(--ch-a6); border-radius: var(--ch-radius); background: var(--ch-base); color: var(--ch-contrast);
	font-family: var(--ch-font-h); font-weight: 700; font-size: 1.15rem; line-height: 1.2; text-align: left; text-decoration: none; cursor: pointer;
}
.ch-acc__btn { padding-left: 10px; }
.ch-acc__label { flex: 1; }
.ch-acc__chev { width: 22px; height: 22px; transition: transform .2s ease; }
.ch-acc__btn[aria-expanded="true"] { background: var(--ch-a2); border-color: var(--ch-a2); border-radius: 29px 29px 0 0; }
.ch-acc__btn[aria-expanded="true"] .ch-acc__chev { transform: rotate(180deg); }
.ch-sheet__item.is-active .ch-sheet__link, .ch-acc.is-active .ch-acc__btn:not([aria-expanded="true"]) { background: var(--ch-a3); border-color: var(--ch-a3); color: var(--ch-base); }
.ch-acc.is-active .ch-acc__btn:not([aria-expanded="true"]) .ch-disc { background: var(--ch-base); color: var(--ch-a3); }
.ch-acc__panel { padding: 6px 20px 16px; background: var(--ch-a2); border-radius: 0 0 26px 26px; }
.ch-acc__desc { margin: 4px 0 10px; font-size: .95rem; }
.ch-acc__all { display: inline-flex; align-items: center; min-height: 44px; font-family: var(--ch-font-h); font-weight: 700; color: var(--ch-sapin-text); }
.ch-topics--sheet .ch-topic__line { display: none; }
.ch-sheet__foot { padding: 12px var(--ch-gutter) calc(12px + env(safe-area-inset-bottom)); background: var(--ch-base); border-top: 1px solid var(--ch-a6); }
html.ch-sheet-open { overflow: hidden; }

@keyframes ch-drop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes ch-up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes ch-down { from { transform: none; } to { transform: translateY(100%); } }
@keyframes ch-fade { from { opacity: 0; } to { opacity: 1; } }

/* ── Breakpoints ──────────────────────────────────── */
@media (min-width: 600px) {
	.ch-logo img { width: 140px !important; }
	.ch-menu__cta { display: inline-flex; }
}
@media (min-width: 1024px) {
	.ch-header__bar { min-height: 84px; }
	.ch-logo img { width: 150px !important; }
	.ch-menu { justify-content: space-between; }
	.ch-menu__list { display: flex; align-items: center; gap: 2px; margin-left: clamp(8px, 2vw, 28px); }
	.ch-burger, html:not(.ch-js) .ch-burger-nojs { display: none; }
	.ch-sheet { display: none; }
}
/* Laptops: short category labels keep the bar on one line (the full label stays for screen readers). */
@media (min-width: 1024px) and (max-width: 1279px) {
	.ch-menu__full { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
	.ch-menu__short { display: inline; }
	.ch-menu__pill { padding-inline: .8rem; }
}
@media (min-width: 1440px) {
	.ch-logo img { width: 160px !important; }
	.ch-menu__list { gap: 6px; }
}

/* ── « Les projets » mega panel: menu card with eight tiles ── */
.ch-menu__logo { width: 26px; height: auto; }
.ch-tile__head { display: flex; align-items: center; gap: 10px; min-height: 48px; color: var(--ch-contrast); text-decoration: none; }
.ch-tile__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ch-tile__name { font-family: var(--ch-font-h); font-weight: 700; font-size: 1rem; line-height: 1.2; }
.ch-tile__head:hover .ch-tile__name { color: var(--ch-sapin-text); text-decoration: underline; }
.ch-tile__count { font-size: .8rem; color: var(--ch-a4); }
.ch-tile__topics { list-style: none; margin: 6px 0 0; padding: 0 0 0 46px; }
.ch-tile__topics a, .ch-tile__topics .is-soon { display: inline-flex; align-items: center; min-height: 32px; font-size: .9rem; line-height: 1.25; color: var(--ch-contrast); }
.ch-tile__topics a:hover { color: var(--ch-sapin-text); }
.ch-tile__topics .is-soon { color: var(--ch-a4); }
.ch-tile__topics .is-soon::after { content: "bientôt"; margin-left: 6px; padding: 0 .45rem; border-radius: 999px; background: var(--ch-moutarde-claire); color: var(--ch-contrast); font-size: .72rem; font-weight: 700; }
.ch-sheet__group { margin-bottom: 8px; }
.ch-sheet__label { margin: 4px 0 8px 8px; font-family: var(--ch-font-h); font-weight: 700; color: var(--ch-sapin-text); }
.ch-sheet__accs { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ch-acc__btn .ch-soon { margin-right: 4px; }

/* ── « Les projets » mega panel (inc/20-menu.php ch_menu_mega()) ── */
/* Panel: 24 px padding, soft shadow, never taller than ~75 % of the viewport. */
.ch-mega__card {
	box-sizing: border-box; display: flex; flex-direction: column; max-width: var(--ch-wide); max-height: 75vh; margin: 0 auto; overflow: hidden;
	padding: 24px; background: var(--ch-base); border-radius: 26px; border: 1px solid var(--ch-a6);
	box-shadow: 0 2px 0 rgba(28, 43, 37, .03), 0 24px 48px -28px rgba(28, 43, 37, .35);
}
.ch-mega__main { display: grid; grid-template-columns: minmax(0, 250px) minmax(0, 1fr); gap: 24px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 2px; margin: -2px; }
.ch-mega__intro { display: flex; flex-direction: column; align-items: stretch; gap: 8px; padding: 4px 4px 0 0; }
.ch-mega__intro > * { margin: 0; }
.ch-mega__kicker { font-family: var(--ch-font-h); font-weight: 700; font-size: .9rem; color: var(--ch-sapin-text); }
.ch-mega__title { font-family: var(--ch-font-h); font-weight: 800; font-size: 1.5rem; line-height: 1.1; letter-spacing: -.02em; }
.ch-mega__desc { color: var(--ch-a4); font-size: .92rem; line-height: 1.5; }
/* « À la une » with its measuring line right under the word. */
.ch-mega__label { display: inline-flex; flex-direction: column; align-self: flex-start; gap: 4px; margin: 10px 0 4px !important; font-family: var(--ch-font-h); font-weight: 700; font-size: .9rem; color: var(--ch-contrast); }
.ch-mega__label::after { content: ""; display: block; width: 100%; min-width: 40px; height: 6px; background: linear-gradient(var(--ch-a1), var(--ch-a1)) left bottom / 100% 2px no-repeat, var(--ch-ticks) left bottom / 100% 6px no-repeat; }
.ch-featured { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 18px; background: var(--ch-a5); border: 1px solid transparent; color: var(--ch-contrast); text-decoration: none; transition: background-color .15s ease, border-color .15s ease; }
.ch-featured:hover, .ch-featured:focus-visible { background: var(--ch-a2); border-color: var(--ch-a3); }
.ch-featured__img { flex: none; width: 64px; height: 64px; border-radius: 14px; object-fit: cover; }
.ch-featured__img--empty { display: grid; place-items: center; background: var(--ch-a2); color: var(--ch-a3); }
.ch-featured__img--empty .ch-icon { width: 26px; height: 26px; }
.ch-featured__text { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.ch-featured__title { font-family: var(--ch-font-h); font-weight: 700; font-size: .95rem; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.ch-featured:hover .ch-featured__title { color: var(--ch-sapin-text); }
.ch-featured .ch-level__label { font-size: .78rem; }

/* 4 × 2 category cards, equal heights, one structure. */
.ch-tiles { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: 1fr; gap: 10px; }
.ch-tile {
	position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-width: 0; box-sizing: border-box; padding: 12px 14px; border-radius: 18px;
	border: 1px solid var(--ch-a6); background: var(--ch-base); transition: background-color .18s ease, border-color .18s ease;
}
.ch-tile:hover, .ch-tile:focus-within, .ch-tile.is-active { background: var(--ch-sauge-light); border-color: var(--ch-a3); }
.ch-tile__head { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; width: 100%; color: var(--ch-contrast); text-decoration: none; }
.ch-tile__head::after { content: ""; position: absolute; inset: 0; border-radius: inherit; } /* whole card → category */
.ch-tile__head:focus-visible { outline: none; }
.ch-tile:has(.ch-tile__head:focus-visible) { outline: 3px solid var(--ch-focus); outline-offset: 2px; }
.ch-tile__icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 28%; background: var(--ch-a2); color: var(--ch-a3); transition: background-color .18s ease, color .18s ease; }
.ch-tile__icon .ch-icon { width: 22px; height: 22px; }
.ch-tile:hover .ch-tile__icon, .ch-tile:focus-within .ch-tile__icon, .ch-tile.is-active .ch-tile__icon { background: var(--ch-a1); color: var(--ch-contrast); }
.ch-tile__name { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.5em; font-family: var(--ch-font-h); font-weight: 700; font-size: 1rem; line-height: 1.25; }
.ch-tile__count { position: absolute; top: 14px; right: 14px; display: inline-flex; align-items: center; padding: .1rem .55rem; border-radius: var(--ch-radius); background: var(--ch-a5); border: 1px solid var(--ch-a6); font-size: .76rem; font-weight: 600; color: var(--ch-a4); }
.ch-tile__count.is-soon { background: var(--ch-moutarde-claire); border-color: var(--ch-moutarde-claire); color: var(--ch-contrast); }
/* Guide rows (also in the bottom sheet): no underline, brick bullet, sapin on hover. */
.ch-guides { position: relative; z-index: 1; list-style: none; margin: 2px 0 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; width: 100%; min-width: 0; }
.ch-guides li { position: relative; min-width: 0; padding: 4px 0 4px 18px; }
.ch-guides__link, .ch-guides__more { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; color: var(--ch-contrast); text-decoration: none; font-size: .86rem; line-height: 1.4; transition: color .15s ease; }
.ch-guides li:has(.ch-guides__link)::before { content: ""; position: absolute; left: 0; top: calc(4px + .62em); width: 10px; height: 6px; border-radius: 1.5px; background: var(--ch-a1); transform: rotate(-12deg); }
.ch-guides__link:hover, .ch-guides__link:focus-visible { color: var(--ch-sapin-text); }
.ch-guides__link { min-height: 0; }
.ch-guides__more { font-family: var(--ch-font-h); font-weight: 700; font-size: .82rem; color: var(--ch-sapin-text); }
.ch-guides__more:hover { color: var(--ch-contrast); }

/* Footer row under a thin measuring line. */
.ch-mega__foot { flex: none; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 20px; margin-top: 18px; padding-top: 16px;
	background: linear-gradient(var(--ch-a1), var(--ch-a1)) left top / 100% 1.5px no-repeat, var(--ch-ticks) left top / 100% 5px no-repeat; }
.ch-mega__foot-right { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; }
.ch-mega__all, .ch-mega__link { display: inline-flex; align-items: center; gap: .45rem; min-height: 44px; font-family: var(--ch-font-h); font-weight: 700; color: var(--ch-contrast); text-decoration: none; }
.ch-mega__all:hover, .ch-mega__link:hover { color: var(--ch-sapin-text); }
.ch-mega__link .ch-icon { width: 20px; height: 20px; color: var(--ch-a3); }
@media (prefers-reduced-motion: reduce) { .ch-tile, .ch-tile__icon, .ch-featured, .ch-guides__link { transition: none; } }
@media (min-width: 1024px) and (max-width: 1279px) {
	.ch-mega__main { grid-template-columns: minmax(0, 1fr); }
	.ch-mega__intro { display: none; }
	.ch-tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
/* Bottom sheet: the same guide rows. */
.ch-acc__panel .ch-guides { margin: 6px 0 4px; }
.ch-acc__panel .ch-guides li { padding-top: 0; padding-bottom: 0; }
.ch-acc__panel .ch-guides__link, .ch-acc__panel .ch-guides__more { display: flex; align-items: center; min-height: 44px; white-space: normal; font-size: .95rem; }
.ch-acc__panel .ch-guides li:has(.ch-guides__link)::before { top: 50%; margin-top: -3px; }
.ch-acc__all { text-decoration: none; }
.ch-acc__all:hover { color: var(--ch-contrast); text-decoration: underline; text-underline-offset: .22em; }
