/**
 * Navigation — menu, sub-menu and footer columns at Apparence's scale (ISS-0068).
 *
 * The reference is EmDash's Apparence (ADR-0009), measured on demo.ubeez.site at
 * 1440 px: menu links 15 px (fs-small), regular weight, 12 px above and below
 * (a 48 px target); footer column titles at the size of their links, weight 600;
 * footer links 8 px above and below, no extra gap between them. The size itself
 * lives in theme.json (semantic.typography.ui.nav), this file only places it.
 *
 * Preconise, don't impose: every default below is written so a choice made in the
 * editor still wins — a font size picked on the block (a `has-*-font-size` class,
 * !important in core) or typed (inline style), a block gap (layout class), a
 * colour (has-* classes). Apparence has no sub-menu: its panel is drawn here from
 * the same tokens (header zone surface and text, hairline, surface radius) and,
 * like Apparence's default « Plat » surfaces, it casts no shadow.
 */

/* 1. One size, applied once. ----------------------------------------------------
 *
 * WordPress writes the font-size class of the block on <nav> AND on the <ul> it
 * holds. The text presets are relative (1em, 1.1em…): applied twice they multiply
 * — Text small came out at 0.882 × 0.882. The list takes the size of its <nav>.
 * !important is the only way past core's own !important on the preset class.
 */
.wp-block-navigation .wp-block-navigation__container[class*="-font-size"] {
	font-size: inherit !important;
}

/* 2. Footer columns: a vertical menu is a list of links, not a row of tabs. ------
 *
 * Apparence: 8 px above and below each link, no gap between them (a 40 px row).
 *
 * The gap itself is theme.json's (styles.blocks.core/navigation.spacing.blockGap),
 * the only default a block gap set in the editor still overrides: WordPress prints
 * the block's own gap later, in core-block-supports, at the same weight. A rule
 * here would load before global styles and lose to the site-wide flex gap, or beat
 * the editor's gap if made heavier. theme.json cannot tell a vertical menu from a
 * horizontal one, so its value reads this variable, set on vertical menus only;
 * horizontal menus keep the stack gap they had.
 */
.wp-block-navigation.is-vertical {
	--jetstream-navigation-gap: 0px;
}

:where(.wp-block-navigation.is-vertical .wp-block-navigation-item__content) {
	padding-block: var(--wp--custom--semantic--spacing--base-100);
}

/*
 * A heading right before a menu, in the footer, is that menu's column title: at
 * the size of its links, semibold — not a page title. The gap between title and
 * list stays the flow gap of the column (global styles print it after this file,
 * at the same weight: a margin here would be dead). SSK's
 * footer used h2, rendered at the size of a section title (« Informatio-ns » broke
 * over two lines). (0,1,0) beats the h1–h6 element styles (0,0,1); a size or
 * weight picked on the heading still wins (has-* class, inline style).
 *
 * "In the footer" is any <footer> (a template part or a group given that tag) or
 * the last block of the page: a footer part can be saved as a <div>, as
 * navigation-mobile.css notes for the header.
 */
:root :where(:is(footer, .wp-site-blocks > :last-child) .wp-block-heading:has(+ .wp-block-navigation)) {
	margin-block-end: 0;
	font-size: var(--wp--custom--semantic--typography--ui--nav--font-size);
	font-weight: var(--wp--custom--primitive--font--weight--semibold, 600);
	line-height: var(--wp--custom--primitive--font--line-height--normal, 1.4);
	letter-spacing: normal;
}

/* 3. Sub-menu: a panel, not a stack of large lines. ------------------------------
 *
 * Measured on SSK before this file: entries at the size of the menu (20 px), core's
 * 0.5em 1em padding grown with them, a 200 px panel that broke « Financement
 * FIFPL/DPC » over two lines, and core's translucent rgba border.
 *
 * The panel and its entries take the SURFACE radius family, never the control
 * one: a Studio « Arrondi complet » turns controls into pills (control.* = full)
 * and the panel came out as an oval on SSK (0.28.0), its white entries spilling
 * past the curve. Apparence does the same: « Pilule » rounds buttons and fields,
 * the rest stays at a card radius (surface.* = 16 px there).
 *
 * The panel is as wide as its longest entry, up to 20rem; entries are regular
 * weight at the size of the menu, 8 px × 16 px. 20rem is a literal: the DS has no
 * width token. The panel is a level-2 surface of Apparence's « Style des surfaces »
 * (ISS-0070): `semantic.elevated.2` gives its surface, text, border and shadow.
 * The theme ships « Plat », Apparence's default (a tinted surface, ramp 200, no
 * border, no shadow); JetStream Studio writes « Bordé » or « En relief » into the
 * child theme by overriding those tokens, and the panel follows — nothing else to
 * change here. Without colours picked in the editor the panel wears that surface
 * (core painted it #fff / #000, white on a dark site).
 * Colours picked in the editor still win (preset classes are !important in core),
 * and a menu given its own background keeps core's `inherit` (:not(.has-background)).
 * A menu given only a text colour gets the zone's panel and text, not its own text
 * colour: readable either way, and the zone is what the header around it wears.
 * Specificity (0,5,0) beats core's (0,3,0)/(0,4,0); scoped out of
 * the phone overlay, which navigation-mobile.css designs, and out of menus that
 * keep their sub-pages always open (.open-always: a list, not a panel).
 */
.wp-block-navigation .has-child:not(.open-always) .wp-block-navigation__submenu-container:not(.is-menu-open *) {
	padding-block: var(--wp--custom--semantic--spacing--base-100);
	border: var(--wp--custom--semantic--elevated--2--border);
	border-radius: var(--wp--custom--semantic--border--radius--surface--s);
	box-shadow: var(--wp--custom--semantic--elevated--2--shadow);
}

.wp-block-navigation:not(.has-background) .has-child:not(.open-always) .wp-block-navigation__submenu-container:not(.is-menu-open *) {
	background-color: var(--wp--custom--semantic--elevated--2--surface);
	color: var(--wp--custom--semantic--elevated--2--on-surface);
}

/* A menu given a background of its own but no text colour: core paints the panel's
 * text #000 (`:not(.has-text-color)`), black on a dark palette surface in dark
 * mode (1.08:1 measured). The panel inherits the text around the menu instead. */
.wp-block-navigation.has-background:not(.has-text-color) .has-child:not(.open-always) .wp-block-navigation__submenu-container:not(.has-text-color, .is-menu-open *) {
	color: inherit;
}

.wp-block-navigation .has-child .wp-block-navigation__submenu-container:not(.is-menu-open *) {
	max-width: 20rem;
}

.wp-block-navigation .has-child:not(.open-always):is(:hover, :focus-within) > .wp-block-navigation__submenu-container:not(.is-menu-open *),
.wp-block-navigation .has-child:not(.open-always) .wp-block-navigation-submenu__toggle[aria-expanded="true"] ~ .wp-block-navigation__submenu-container:not(.is-menu-open *) {
	width: max-content;
}

.wp-block-navigation .has-child .wp-block-navigation__submenu-container:not(.is-menu-open *) > .wp-block-navigation-item > .wp-block-navigation-item__content {
	padding: var(--wp--custom--semantic--spacing--base-100) var(--wp--custom--semantic--spacing--base-200);
	border-radius: var(--wp--custom--semantic--border--radius--surface--xs);
	font-weight: var(--wp--custom--primitive--font--weight--regular, 400);
	line-height: var(--wp--custom--primitive--font--line-height--normal, 1.4);
	transition: background-color var(--wp--custom--semantic--control--transition--duration) var(--wp--custom--semantic--control--transition--easing);
}

/* 4. States: hover, keyboard focus, current page. ---------------------------------
 *
 * Measured before: no state at all in the panel — nothing told the pointer or the
 * keyboard where it was, nor the visitor which page they were on.
 *
 * - Sub-menu entries sit inset in the panel (8 px all round). On hover and keyboard
 *   focus they take a tint when the panel is a light surface of the theme with a
 *   dark text of the theme: no colour picked, or the palette's own pairs. The tint
 *   is `semantic.elevated.2.hover`: the panel's text mixed 8 % into the panel's
 *   surface, as Apparence does (state.hover) — opaque, and visible whatever the
 *   surface style (plat, bordé, relief) and the mode. `surface-dim` is left out
 *   (it is the plat surface itself), `text-muted` too (too light on a tint). Anything else — a custom colour (inline style), a block
 *   background, another preset — is underlined instead, in its own colour: a theme
 *   tint under a white text measured 1.27:1.
 * - Keyboard focus is the DS focus ring on every menu link and on the sub-menu
 *   toggle — inset in the panel, where an outside ring would be clipped by its edge.
 * - The current page (core writes aria-current="page" on its link) is underlined
 *   like Apparence's menu (2 px, offset 8 px) in the bar, and semibold in a panel.
 * - No motion for visitors who ask their device for less.
 *
 * The entry rules repeat the weight of the entry rule above (0,6,0): a lighter
 * state rule would lose to it (the semibold and the reduced motion did).
 */
.wp-block-navigation .has-child:not(.open-always) .wp-block-navigation__submenu-container:not(.is-menu-open *) {
	padding-inline: var(--wp--custom--semantic--spacing--base-100);
}

.wp-block-navigation:not(.has-background) .has-child .wp-block-navigation__submenu-container:is(:not(.has-background), .has-surface-white-background-color, .has-surface-soft-background-color, .has-surface-bright-background-color):is(:not(.has-text-color), .has-text-primary-color, .has-text-secondary-color):not([style*="color"], .is-menu-open *) > .wp-block-navigation-item > .wp-block-navigation-item__content:is(:hover, :focus-visible) {
	background-color: var(--wp--custom--semantic--elevated--2--hover);
}

.wp-block-navigation.has-background .has-child .wp-block-navigation__submenu-container:not(.is-menu-open *) > .wp-block-navigation-item > .wp-block-navigation-item__content:is(:hover, :focus-visible),
.wp-block-navigation .has-child .wp-block-navigation__submenu-container:is([style*="color"], .has-background:not(.has-surface-white-background-color, .has-surface-soft-background-color, .has-surface-bright-background-color), .has-text-color:not(.has-text-primary-color, .has-text-secondary-color)):not(.is-menu-open *) > .wp-block-navigation-item > .wp-block-navigation-item__content:is(:hover, :focus-visible) {
	text-decoration: underline;
	text-decoration-thickness: var(--wp--custom--primitive--border--width--1, 1px);
	text-underline-offset: var(--wp--custom--semantic--spacing--base-050);
}

.wp-block-navigation :is(.wp-block-navigation-item__content, .wp-block-navigation-submenu__toggle):focus-visible {
	outline: var(--wp--custom--semantic--control--focus-ring--width) solid var(--wp--custom--semantic--control--focus-ring--color);
	outline-offset: var(--wp--custom--primitive--border--width--2, 2px);
}

.wp-block-navigation .wp-block-navigation__submenu-container:not(.is-menu-open *) .wp-block-navigation-item__content:focus-visible {
	outline-offset: calc(-1 * var(--wp--custom--primitive--border--width--2, 2px));
}

.wp-block-navigation:not(.is-vertical) .wp-block-navigation__container > .wp-block-navigation-item > .wp-block-navigation-item__content[aria-current="page"]:not(.is-menu-open *) {
	text-decoration: underline;
	text-decoration-thickness: var(--wp--custom--primitive--border--width--2, 2px);
	text-underline-offset: var(--wp--custom--semantic--spacing--base-100);
}

.wp-block-navigation .has-child .wp-block-navigation__submenu-container:not(.is-menu-open *) > .wp-block-navigation-item > .wp-block-navigation-item__content[aria-current="page"] {
	font-weight: var(--wp--custom--primitive--font--weight--semibold, 600);
}

@media (prefers-reduced-motion: reduce) {
	.wp-block-navigation .has-child .wp-block-navigation__submenu-container:not(.is-menu-open *) > .wp-block-navigation-item > .wp-block-navigation-item__content {
		transition: none;
	}
}

/* 5. The sub-menu toggle is a 24 px target. ---------------------------------------
 *
 * Core sizes the chevron button at 0.6em: 9 × 9 px measured at the menu's 15 px,
 * glued to its link — under WCAG 2.2 AA « Target Size (Minimum) » (24 × 24 px). The
 * button grows to `size.xs` (24 px) around a chevron that keeps its 0.6em, and loses
 * core's 0.25em left margin so the label does not drift away. Out of the phone
 * overlay, where core hides it (the overlay has its own fold buttons, ISS-0071). A
 * menu set to always show its sub-menus (.open-always) still renders the toggle: it
 * grows there too, deliberately — a larger target never hurts.
 */
.wp-block-navigation .wp-block-navigation-submenu__toggle.wp-block-navigation__submenu-icon:not(.is-menu-open *) {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--wp--custom--semantic--size--xs);
	height: var(--wp--custom--semantic--size--xs);
	margin-inline-start: 0;
}

.wp-block-navigation .wp-block-navigation-submenu__toggle.wp-block-navigation__submenu-icon:not(.is-menu-open *) svg {
	width: 0.6em;
	height: 0.6em;
	margin-top: 0;
	transition: transform var(--wp--custom--semantic--control--transition--duration) var(--wp--custom--semantic--control--transition--easing);
}

/* The chevron turns instead of jumping: core flips it 180° on aria-expanded with no
   transition (owner: « il se met haut/bas instantanément »). The rotation is core's,
   only its timing is ours — DS control transition, none on reduced motion. */
@media (prefers-reduced-motion: reduce) {
	.wp-block-navigation .wp-block-navigation-submenu__toggle.wp-block-navigation__submenu-icon:not(.is-menu-open *) svg {
		transition: none;
	}
}

/* 6. Menu buttons are not call-to-action buttons (ISS-0071). ------------------------
 *
 * The theme paints every <button> with the primary action on hover
 * (forms/_button.css, `:where(button):hover`) — the menu's burger, close button and
 * sub-menu chevrons too: a dark blue square under a black cross, unreadable (owner,
 * 28/10/2026). They keep their own background. The burger and the close button get
 * Apparence's menu-button frame instead — a 48 px target (core's burger was 24 px), a
 * hairline ring, the control radius.
 *
 * Hover and keyboard focus thicken that ring to 2 px in the icon's own colour
 * (`currentColor`), not a tinted background: the button can sit on a header or an
 * overlay whose colours were picked in the editor, and a tint mixed into the theme's
 * header surface measured 1.04:1 under a light icon there. The icon's colour is, by
 * construction, the one that reads on that background. Same state for the phone
 * menu's fold buttons (navigation-mobile.css).
 */
.wp-block-navigation :is(.wp-block-navigation__responsive-container-open, .wp-block-navigation__responsive-container-close, .wp-block-navigation-submenu__toggle):is(:hover, :active):not(:disabled) {
	background: none;
	color: inherit;
}

.wp-block-navigation :is(.wp-block-navigation__responsive-container-open, .wp-block-navigation__responsive-container-close) {
	align-items: center;
	justify-content: center;
	min-width: var(--wp--custom--semantic--size--control--l);
	min-height: var(--wp--custom--semantic--size--control--l);
	border-radius: var(--wp--custom--semantic--border--radius--control--s);
	box-shadow: inset 0 0 0 var(--wp--custom--semantic--border--width--hairline) var(--wp--custom--semantic--color--neutral--outline-variant);
	transition: box-shadow var(--wp--custom--semantic--control--transition--duration) var(--wp--custom--semantic--control--transition--easing);
}

.wp-block-navigation :is(.wp-block-navigation__responsive-container-open, .wp-block-navigation__responsive-container-close):is(:hover, :focus-visible):not(:disabled) {
	box-shadow: inset 0 0 0 var(--wp--custom--primitive--border--width--2, 2px) currentColor;
}

@media (prefers-reduced-motion: reduce) {
	.wp-block-navigation :is(.wp-block-navigation__responsive-container-open, .wp-block-navigation__responsive-container-close) {
		transition: none;
	}
}
