/* ==========================================================================
   Accueil Bergues : en-tête, panneaux, « Je suis / Je veux », accès rapides.
   Valeurs reprises de la maquette « Ville de Bergues – Accueil » (repère 1440 px).
   Bascule bureau / mobile à 1200 px (comme la maquette).
   ========================================================================== */

body.bgx-on, body.bgx-inner {
	--bgx-ink: #2A2522;
	--bgx-rust: #B5643F;
	--bgx-brown: #8C7062;
	--bgx-brown-d: #6E5548;
	--bgx-cream: #F6F2EC;
	--bgx-line: #EEE8E1;
	--bgx-disp: "Familjen Grotesk", "Mulish", system-ui, sans-serif;
	--bgx-script: "Caveat", cursive;
	--bgx-e: cubic-bezier(.2, .7, .2, 1);
}

/* ---------- En-tête ---------- */
#masthead.bgx { position: fixed; top: 0; left: 0; right: 0; z-index: 60; background: transparent; color: #fff; box-shadow: none; font-family: "Mulish", system-ui, sans-serif; font-size: 17px; line-height: 1.6; transition: background .35s ease, color .35s ease, box-shadow .35s ease; }
.admin-bar #masthead.bgx { top: var(--wp-admin--admin-bar--height, 32px); }
#masthead.bgx, #masthead.bgx *, .bgx-rail, .bgx-rail *, .bgx-bar-m, .bgx-bar-m * { box-sizing: border-box; }
#masthead.bgx.is-solid { background: #fff; color: var(--bgx-ink); box-shadow: 0 1px 0 var(--bgx-line); }
#masthead.bgx.is-solid.is-scrolled { box-shadow: 0 8px 30px rgba(42, 37, 34, .08); }
#masthead.bgx :is(ul, li, p) { margin: 0; padding: 0; list-style: none; }
#masthead.bgx a { text-decoration: none; }
#masthead.bgx .bgx-i { display: block; flex: none; }

.bgx-bar { height: 104px; display: flex; align-items: center; gap: 20px; padding: 0 clamp(16px, 3vw, 48px); transition: height .3s ease; }
#masthead.bgx.is-scrolled .bgx-bar { height: 80px; }

/* Logo : clair sur la vidéo (ombre portée), foncé quand l'en-tête est blanc. */
#masthead.bgx .ssm-logo { display: block; flex: none; transition: opacity .2s; }
#masthead.bgx .ssm-logo:hover { opacity: .85; }
#masthead.bgx .ssm-logo__in { display: grid; }
#masthead.bgx .ssm-logo img { grid-area: 1 / 1; display: block; height: 54px; width: auto; max-width: none; transition: height .3s ease, opacity .35s ease, filter .35s ease; }
#masthead.bgx.is-scrolled .ssm-logo img { height: 44px; }
#masthead.bgx .ssm-logo__w { opacity: 1; filter: drop-shadow(0 1px 8px rgba(0, 0, 0, .35)); }
#masthead.bgx .ssm-logo__d { opacity: 0; }
#masthead.bgx.is-solid .ssm-logo__w { opacity: 0; }
#masthead.bgx.is-solid .ssm-logo__d { opacity: 1; }

/* Menu principal : capitales, soulignement terre cuite. */
.bgx-nav { display: flex; align-items: stretch; align-self: stretch; margin: 0 auto; }
.bgx-nav__list { display: flex; align-items: stretch; }
.bgx-nav__item { display: flex; }
#masthead.bgx .bgx-nav__a { position: relative; display: flex; align-items: center; padding: 0 20px; font-size: 13px; line-height: 1.6; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; white-space: nowrap; color: inherit; text-shadow: 0 1px 10px rgba(0, 0, 0, .35); transition: opacity .2s; }
#masthead.bgx.is-solid .bgx-nav__a { text-shadow: none; }
#masthead.bgx .bgx-nav__a:hover, #masthead.bgx .bgx-nav__a:focus-visible { opacity: .75; color: inherit; }
.bgx-nav__ul { position: absolute; left: 20px; right: 20px; bottom: 30%; height: 2px; background: var(--bgx-rust); transform: scaleX(0); transition: transform .3s ease; }
.bgx-nav__a[aria-expanded="true"] .bgx-nav__ul, .bgx-nav__a.is-current .bgx-nav__ul { transform: scaleX(1); }
.bgx-nav__a.is-current:not([aria-expanded="true"]) .bgx-nav__ul { transform: scaleX(0); }

/* Outils : Je suis / Je veux / Rechercher (+ burger en mobile). */
.bgx-tools { display: flex; align-items: stretch; align-self: stretch; border-left: 1px solid rgba(255, 255, 255, .28); transition: border-color .35s ease; }
#masthead.bgx.is-solid .bgx-tools { border-left-color: var(--bgx-line); }
#masthead.bgx .bgx-tool { width: 96px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; margin: 0; padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; color: inherit; font-family: inherit; font-size: 11px; line-height: 1.6; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; cursor: pointer; min-height: 0; transition: background .25s; }
#masthead.bgx .bgx-tool .bgx-i { color: #fff; transition: color .35s ease; }
#masthead.bgx.is-solid .bgx-tool .bgx-i { color: var(--bgx-brown); }
#masthead.bgx .bgx-tool:hover, #masthead.bgx .bgx-tool:focus-visible { background: rgba(255, 255, 255, .14); color: inherit; }
#masthead.bgx.is-solid .bgx-tool:hover, #masthead.bgx.is-solid .bgx-tool:focus-visible { background: var(--bgx-cream); }
#masthead.bgx.is-solid .bgx-tool[aria-expanded="true"] { background: var(--bgx-cream); }
#masthead.bgx .bgx-tool:focus-visible { outline: 3px solid var(--bgx-rust); outline-offset: -3px; }
#masthead.bgx .bgx-tool--burger { display: none; }
@media (max-width: 1479.98px) {
	#masthead.bgx .bgx-nav__a { padding: 0 12px; }
	.bgx-nav__ul { left: 12px; right: 12px; }
	#masthead.bgx .bgx-tool { width: 80px; }
}

/* ---------- Panneaux de rubrique ---------- */
.bgx-megas { position: absolute; top: 100%; left: 0; right: 0; pointer-events: none; }
.bgx-mega { position: absolute; top: 0; left: 0; right: 0; background: #fff; color: var(--bgx-ink); border-top: 1px solid var(--bgx-line); border-radius: 0 0 30px 30px; box-shadow: 0 30px 50px rgba(42, 37, 34, .12); opacity: 0; visibility: hidden; transform: translateY(-8px); pointer-events: none; transition: opacity .3s ease, transform .3s ease, visibility 0s linear .3s; }
.bgx-mega.is-open { opacity: 1; visibility: visible; transform: none; pointer-events: auto; transition: opacity .3s ease, transform .3s ease, visibility 0s; }
.bgx-mega__in { max-width: 1240px; margin: 0 auto; padding: 40px clamp(20px, 3vw, 48px); display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 1.2fr); gap: 48px; }
.bgx-mega__cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 32px; }
#masthead.bgx .bgx-mega__t { margin: 0 0 10px; min-height: 32px; font-family: var(--bgx-script); font-weight: 700; font-size: 32px; line-height: 1; color: var(--bgx-rust); }
#masthead.bgx .bgx-mega__t a { color: inherit; }
.bgx-mega__l { display: flex; flex-direction: column; }
#masthead.bgx .bgx-mega__l a { display: block; padding: 8px 0; border-bottom: 1px solid var(--bgx-line); color: var(--bgx-ink); font-size: 16px; line-height: 1.6; transition: color .2s, padding .25s; }
#masthead.bgx .bgx-mega__l a:hover, #masthead.bgx .bgx-mega__l a:focus-visible { color: var(--bgx-brown-d); padding-left: 6px; }
#masthead.bgx .bgx-mega__card { position: relative; display: block; border-radius: 16px; overflow: hidden; min-height: 250px; color: #fff; background: var(--bgx-brown-d); transition: transform .35s var(--bgx-e); }
#masthead.bgx .bgx-mega__card:hover, #masthead.bgx .bgx-mega__card:focus-visible { transform: scale(.985); color: #fff; }
.bgx-mega__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; max-width: none; }
.bgx-mega__shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(42, 37, 34, 0) 30%, rgba(42, 37, 34, .78)); }
.bgx-mega__txt { position: absolute; left: 20px; right: 20px; bottom: 18px; display: flex; flex-direction: column; gap: 4px; }
.bgx-mega__ct { font-family: var(--bgx-disp); font-weight: 600; letter-spacing: -.035em; font-size: 24px; line-height: 1.1; }
.bgx-mega__cd { font-size: 14.5px; line-height: 1.4; }

/* ---------- Je suis / Je veux ---------- */
.bgx-je { position: absolute; top: calc(100% + 12px); right: var(--bgx-je-r, 16px); width: 420px; max-width: calc(100vw - 32px); background: #fff; color: var(--bgx-ink); border-radius: 16px; padding: 24px; box-shadow: 0 30px 50px rgba(42, 37, 34, .16); opacity: 0; visibility: hidden; transform: translateY(-8px); pointer-events: none; transition: opacity .25s ease, transform .25s ease, visibility 0s linear .25s; }
.bgx-je.is-open { opacity: 1; visibility: visible; transform: none; pointer-events: auto; transition: opacity .25s ease, transform .25s ease, visibility 0s; }
.bgx-je__box[hidden] { display: none; }
#masthead.bgx .bgx-je__t { margin: 0 0 14px; font-family: var(--bgx-script); font-weight: 700; font-size: 34px; line-height: 1; color: var(--bgx-rust); }
.bgx-je__box ul { display: flex; flex-direction: column; }
#masthead.bgx .bgx-je__box a { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--bgx-line); color: var(--bgx-ink); font-weight: 700; line-height: 1.6; transition: color .2s; }
#masthead.bgx .bgx-je__box a:hover, #masthead.bgx .bgx-je__box a:focus-visible { color: var(--bgx-rust); }

/* ---------- Accès rapides : rail (≥ 1200 px) ---------- */
.bgx-rail { position: fixed; left: 14px; top: 50%; transform: translateY(-38%); z-index: 55; width: 68px; display: flex; flex-direction: column; gap: 2px; padding: 8px; background: #fff; border-radius: 16px; box-shadow: 0 18px 44px rgba(0, 0, 0, .28); overflow: hidden; color: var(--bgx-ink); font-family: "Mulish", system-ui, sans-serif; transition: width .4s var(--bgx-e), box-shadow .3s; }
.bgx-rail.is-open { width: 248px; }
body.bgx-scrolled .bgx-rail { box-shadow: 0 0 0 1px rgba(42, 37, 34, .08), 0 22px 50px rgba(42, 37, 34, .26); }
.bgx-rail__h { display: flex; align-items: center; gap: 12px; margin: 2px 0 10px; padding: 0 13px 12px; border-bottom: 1px solid var(--bgx-line); font-family: var(--bgx-script); font-weight: 700; font-size: 22px; line-height: 1.6; color: var(--bgx-rust); white-space: nowrap; }
.bgx-rail__h .bgx-i { margin-left: -1px; }
.bgx-rail__a { display: flex; align-items: center; gap: 14px; height: 46px; padding: 0 12px; border-radius: 10px; color: var(--bgx-ink) !important; font-size: 14.5px; line-height: 1.6; font-weight: 800; white-space: nowrap; text-decoration: none; transition: background .25s, color .25s; }
.bgx-rail__a:hover, .bgx-rail__a:focus-visible { background: var(--bgx-brown); color: #fff !important; }
.bgx-rail__a:focus-visible { outline: 3px solid var(--bgx-rust); outline-offset: -3px; }
.bgx-rail__l { opacity: 0; transition: opacity .3s; }
.bgx-rail.is-open .bgx-rail__l { opacity: 1; }
.bgx-i { display: block; flex: none; }

/* Barre du bas (< 1200 px) */
.bgx-bar-m { display: none; }

/* La page se décale de 84 px pour laisser le rail (1200 – 1439 px) ; le bandeau reste pleine largeur. */
@media (min-width: 1200px) and (max-width: 1439.98px) {
	body.bgx-on .bgh { padding-left: 84px; }
	body.bgx-on .bg-hero { margin-left: -84px; }
	body.bgx-on .bg-hero__txt { left: max(122px, calc(84px + max(clamp(16px, 4vw, 56px), calc((100vw - 84px - 1240px) / 2)))); }
}
@media (min-width: 1440px) {
	body.bgx-on .bg-hero__txt { left: max(122px, max(clamp(16px, 4vw, 56px), calc((100vw - 1240px) / 2))); }
}
@media (min-width: 1200px) {
	body.bgx-on .bg-hero { min-height: 520px; }
	body.bgx-on .bg-hero__play { bottom: clamp(24px, 4vh, 48px); }
	body.bgx-on .bg-hero__txt > * { transform: translateX(var(--bgx-shift, 0px)); transition: transform .45s var(--bgx-e); }
	body.bgx-on .bg-hero__kick { transform: translateX(var(--bgx-shift, 0px)) rotate(-3deg); }
}

/* ---------- Pages intérieures ---------- */
html.ssm-lock .bgx-rail, html.ssm-lock .bgx-bar-m { visibility: hidden; }
body.bgx-inner .bg-foot { margin-top: clamp(90px, 10vw, 130px); }
body.bgx-inner .bg-foot__sky { height: clamp(90px, 10vw, 130px); }
@media (min-width: 1200px) and (max-width: 1439.98px) { body.bgx-inner .ssm-wrap { padding-left: max(var(--ssm-gutter, 24px), 84px); } }

/* ---------- Mobile / tablette (< 1200 px) ---------- */
@media (max-width: 1199.98px) {
	.bgx-bar { height: 70px; }
	#masthead.bgx.is-scrolled .bgx-bar { height: 70px; }
	#masthead.bgx .ssm-logo img, #masthead.bgx.is-scrolled .ssm-logo img { height: 40px; }
	.bgx-nav, .bgx-megas, .bgx-je, #masthead.bgx .bgx-tool--je, .bgx-tool__l, .bgx-rail { display: none !important; }
	.bgx-tools { margin-left: auto; }
	#masthead.bgx .bgx-tool { width: 58px; }
	#masthead.bgx .bgx-tool--burger { display: flex; }
	body.bgx-on, body.bgx-inner { padding-bottom: 72px; }
	body.bgx-inner .ssm-toast { bottom: 84px; }
	body.bgx-on .bg-hero { height: calc(100svh - 72px); min-height: 300px; }
	body.bgx-on .bg-hero__play { bottom: auto; top: 86px; }
	.bgx-bar-m { position: fixed; left: 0; right: 0; bottom: 0; z-index: 55; height: 72px; display: flex; overflow-x: auto; scrollbar-width: none; background: #fff; box-shadow: 0 -6px 24px rgba(42, 37, 34, .12); font-family: "Mulish", system-ui, sans-serif; }
	.bgx-bar-m::-webkit-scrollbar { display: none; }
	.bgx-bar-m__a { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; margin: 0; padding: 6px 4px; border: 0; border-radius: 0; background: transparent; box-shadow: none; color: var(--bgx-ink) !important; font: inherit; font-size: 11px; line-height: 1.15; font-weight: 800; text-align: center; text-decoration: none; text-transform: none; letter-spacing: normal; cursor: pointer; transition: background .25s; }
	.bgx-bar-m__a .bgx-i { color: var(--bgx-brown); }
	.bgx-bar-m__a:hover, .bgx-bar-m__a:focus-visible { background: var(--bgx-cream); }
	.bgx-bar-m__a:focus-visible { outline: 3px solid var(--bgx-rust); outline-offset: -3px; }
}

@media (prefers-reduced-motion: reduce) {
	#masthead.bgx *, .bgx-rail, .bgx-rail * { transition: none !important; }
}
