/* Header Basketmon — layout, sticky on scroll, mobile-first.
 *
 * Estructura: brand | nav | actions | toggle. En mobile, nav y actions se ocultan
 * y se muestran al activar el toggle (drawer desde la derecha).
 *
 * Depende de las variables definidas en variables.css (--bm-color-*, --bm-font-*).
 */

/* Keyframe utilitzat per l'entrada esglaonada dels ítems del drawer mobile. */
@keyframes bm-drawer-item-in {
	from { opacity: 0; transform: translateX(-12px); }
	to   { opacity: 1; transform: translateX(0); }
}

/* ── Skip link (accesibilidad) ─────────────────────────────────────── */
.bm-skip-link.screen-reader-text {
	position: absolute;
	left: -9999px;
	top: auto;
	width: 1px;
	height: 1px;
	overflow: hidden;
}
.bm-skip-link.screen-reader-text:focus {
	left: 12px;
	top: 12px;
	width: auto;
	height: auto;
	z-index: 100000;
	padding: 8px 16px;
	background: var(--bm-color-accent);
	color: #fff;
	border-radius: var(--bm-radius-sm);
	font-weight: var(--bm-fw-medium);
}

/* ── Header wrapper ────────────────────────────────────────────────── */
.bm-site-header {
	position: sticky;
	top: 0;
	z-index: 1000;
	background: var(--bm-color-bg-alt);
	border-bottom: none;
	box-shadow: none;
	transition: box-shadow .25s ease, background .25s ease;
}
.bm-site-header.is-scrolled {
	box-shadow: 0 2px 12px rgba(0,0,0,.06);
}

/* Header overlay sobre hero (en home-page o cualquier body.bm-has-hero) */
body.bm-has-hero .bm-site-header:not(.is-scrolled) {
	background: transparent;
}
body.bm-has-hero .bm-site-header:not(.is-scrolled) .bm-menu a,
body.bm-has-hero .bm-site-header:not(.is-scrolled) .bm-lang-switcher__current,
body.bm-has-hero .bm-site-header:not(.is-scrolled) .bm-site-header__site-title {
	color: #FFFFFF;
}
body.bm-has-hero .bm-site-header:not(.is-scrolled) .bm-lang-switcher__current {
	border-color: rgba(255,255,255,0.4);
}
body.bm-has-hero .bm-site-header:not(.is-scrolled) .bm-menu-toggle__bar {
	background: #FFFFFF;
}
/* Logo: doble — color por defecto, blanco sobre hero sin scroll. */
.bm-site-header__brand-link {
	display: inline-flex;
	align-items: center;
	text-decoration: none;
}
.bm-logo {
	display: block;
	max-height: 52px;
	width: auto;
	height: auto;
	transition: opacity 0.25s ease;
}
.bm-logo--light { display: none; }

body.bm-has-hero .bm-site-header:not(.is-scrolled) .bm-logo--dark { display: none; }
body.bm-has-hero .bm-site-header:not(.is-scrolled) .bm-logo--light { display: block; }

.bm-site-header__inner {
	max-width: 1640px;
	margin: 0 auto;
	padding: 0 40px;
	display: grid;
	grid-template-columns: auto 1fr auto;
	align-items: center;
	gap: 40px;
	min-height: 88px;
}
.bm-site-header__nav { justify-content: flex-end; }

/* ── Logo / brand ──────────────────────────────────────────────────── */
.bm-site-header__brand {
	display: flex;
	align-items: center;
}
/* Compat: si en algún punto vuelve a usarse `the_custom_logo()` directo */
.bm-site-header__brand .custom-logo-link img,
.bm-site-header__brand .custom-logo {
	max-height: 52px;
	width: auto;
	display: block;
}
.bm-site-header__site-title {
	font-family: var(--bm-font-heading);
	font-weight: var(--bm-fw-heavy);
	font-size: 28px;
	color: var(--bm-color-text);
	text-decoration: none;
	letter-spacing: -0.02em;
}
.bm-site-header__site-title:hover { color: var(--bm-color-accent); }

/* ── Navegación principal ──────────────────────────────────────────── */
/* Menú alineado a la DERECHA (decidido con cliente). El grid del header
 * usa la columna central como 1fr expandible — el nav ocupa esa columna
 * pero su contenido se empuja al final. */
.bm-site-header__nav { display: flex; justify-content: flex-end; }
.bm-menu {
	display: flex;
	align-items: center;
	gap: 32px;
	list-style: none;
	margin: 0;
	padding: 0;
}
.bm-menu li { position: relative; }
.bm-menu a {
	display: inline-flex;
	align-items: center;
	height: 80px;
	padding: 0 4px;
	font-family: var(--bm-font-body);
	font-size: 13px;
	font-weight: var(--bm-fw-bold);
	color: var(--bm-color-text);
	text-decoration: none;
	text-transform: uppercase;
	letter-spacing: 0.12em;
	border-bottom: 2px solid transparent;
	transition: color .15s ease, border-color .15s ease;
}
.bm-menu a:hover {
	color: var(--bm-color-accent);
	border-bottom-color: var(--bm-color-accent);
}
/* Item activo (persistente, no solo hover) — subrayado rojo bajo el link */
.bm-menu .current-menu-item > a,
.bm-menu .current-menu-ancestor > a,
.bm-menu .current_page_item > a,
.bm-menu li.is-current > a {
	color: var(--bm-color-accent);
	border-bottom-color: var(--bm-color-accent);
}

/* ── Actions (idioma + CTA) ────────────────────────────────────────── */
.bm-site-header__actions {
	display: flex;
	align-items: center;
	gap: 16px;
}

/* ── Selector de idiomas custom (dropdown con bandera) ───────────────── */
.bm-lang-switcher {
	position: relative;
	font-family: var(--bm-font-body);
}
.bm-lang-switcher__current {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	background: transparent;
	border: none;
	padding: 6px 4px;
	font-size: 13px;
	font-weight: var(--bm-fw-bold);
	text-transform: uppercase;
	letter-spacing: 0.12em;
	color: var(--bm-color-text);
	cursor: pointer;
	transition: color .15s ease;
}
.bm-lang-switcher__current:hover,
.bm-lang-switcher__current:focus-visible {
	color: var(--bm-color-accent);
	outline: none;
}
.bm-lang-switcher__flag {
	display: block;
	width: 20px;
	height: 14px;
	object-fit: cover;
	border-radius: 2px;
}
.bm-lang-switcher__caret {
	transition: transform .2s ease;
	color: currentColor;
}
.bm-lang-switcher.is-open .bm-lang-switcher__caret {
	transform: rotate(180deg);
}

.bm-lang-switcher__list {
	position: absolute;
	top: calc(100% + 6px);
	right: 0;
	min-width: 140px;
	background: var(--bm-color-bg-alt);
	border: 1px solid var(--bm-color-border);
	border-radius: var(--bm-radius-md);
	box-shadow: var(--bm-shadow-md);
	list-style: none;
	margin: 0;
	padding: 4px;
	opacity: 0;
	visibility: hidden;
	transform: translateY(-4px);
	transition: opacity .15s ease, transform .15s ease, visibility .15s;
	z-index: 1100;
}
.bm-lang-switcher.is-open .bm-lang-switcher__list {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}
.bm-lang-switcher__list a {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 12px;
	border-radius: var(--bm-radius-sm);
	font-size: 14px;
	color: var(--bm-color-text);
	text-decoration: none;
	transition: background .15s ease;
}
.bm-lang-switcher__list a:hover,
.bm-lang-switcher__list a:focus-visible {
	background: rgba(0, 0, 0, 0.04);
	color: var(--bm-color-accent);
	outline: none;
}

/* CTA Inscripcions — pill rounded, estilo Tornados */
.bm-btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	font-family: var(--bm-font-body);
	font-weight: var(--bm-fw-bold);
	font-size: 13px;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	text-decoration: none;
	padding: 14px 28px;
	border-radius: 9999px;
	border: none;
	cursor: pointer;
	transition: background .15s ease, transform .15s ease, box-shadow .15s ease;
	white-space: nowrap;
}
.bm-btn--accent {
	background: var(--bm-color-accent);
	color: #fff;
}
.bm-btn--accent:hover,
.bm-btn--accent:focus-visible {
	background: var(--bm-color-accent-hover);
	color: #fff;
	transform: translateY(-1px);
	box-shadow: var(--bm-shadow-md);
}

/* ── Toggle mobile ─────────────────────────────────────────────────── */
.bm-menu-toggle {
	display: none;
	width: 44px;
	height: 44px;
	background: transparent;
	border: none;
	padding: 0;
	cursor: pointer;
	gap: 5px;
	flex-direction: column;
	justify-content: center;
	align-items: center;
}
.bm-menu-toggle__bar {
	display: block;
	width: 24px;
	height: 2px;
	background: var(--bm-color-text);
	transition: transform .25s ease, opacity .15s ease;
}
.bm-menu-toggle[aria-expanded="true"] .bm-menu-toggle__bar:nth-child(1) {
	transform: translateY(7px) rotate(45deg);
}
.bm-menu-toggle[aria-expanded="true"] .bm-menu-toggle__bar:nth-child(2) {
	opacity: 0;
}
.bm-menu-toggle[aria-expanded="true"] .bm-menu-toggle__bar:nth-child(3) {
	transform: translateY(-7px) rotate(-45deg);
}

/* ── Responsive ──────────────────────────────────────────────────────
 *
 * Drawer mobile: en mobile, el .bm-site-header__inner pasa de ser un grid
 * 3-columnas (brand | nav | actions+toggle) a un grid de áreas que apila
 * verticalmente al abrir el drawer:
 *
 *   "brand    toggle"    ← siempre visible
 *   "actions  actions"   ← solo cuando .is-mobile-open (idiomas + Inscripcions)
 *   "nav      nav"       ← solo cuando .is-mobile-open (menú)
 *
 * Esto permite reordenar nav y actions sin tocar el HTML (en desktop el
 * nav vive entre brand y actions; en mobile, actions arriba y nav debajo).
 */
@media (max-width: 980px) {
	.bm-site-header__inner {
		grid-template-columns: 1fr auto;
		grid-template-areas: "brand toggle";
		gap: 12px 16px;
		min-height: 72px;
		padding: 0 20px;
		align-items: center;
	}
	.bm-site-header__brand { grid-area: brand; }
	.bm-menu-toggle { grid-area: toggle; display: inline-flex; }
	.bm-logo { max-height: 40px; }

	/* En reposo, nav y actions ocultos */
	.bm-site-header__nav,
	.bm-site-header__actions {
		display: none;
	}

	/* Drawer abierto: actions arriba (lang + CTA de costat), nav a continuación. */
	.bm-site-header.is-mobile-open .bm-site-header__inner {
		grid-template-areas:
			"brand   toggle"
			"actions actions"
			"nav     nav";
		padding-bottom: 20px;
		background: var(--bm-color-bg-alt);
	}

	/* ╔══════════════════════════════════════════════════════════════════╗
	 * ║  EDITORIAL SPORT — Mobile drawer                                 ║
	 * ║  Concepte: cada ítem del menú és una "entrada" d'un programa     ║
	 * ║  esportiu, numerada. Accent vertical a l'esquerra (no bottom     ║
	 * ║  border genèric). Entrada en stagger amb spring. Tactile press.  ║
	 * ╚══════════════════════════════════════════════════════════════════╝ */

	/* Actions row (arriba): lang switcher + CTA Inscripcions de costat.
	 * Sense border-top per evitar fragmentar visualment el drawer; la
	 * separació es fa amb espai i el background unificat. */
	.bm-site-header.is-mobile-open .bm-site-header__actions {
		grid-area: actions;
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: 14px;
		padding: 14px 0 18px;
	}

	/* Lang switcher: pill compacta, neutra. Tactile feedback en press. */
	.bm-lang-switcher__label {
		display: none;
	}
	.bm-lang-switcher__current {
		gap: 8px;
		padding: 10px 14px;
		background: rgba(15, 15, 18, 0.04);
		border: none;
		border-radius: 999px;
		transition: background .2s cubic-bezier(0.16, 1, 0.3, 1),
		            transform .15s cubic-bezier(0.16, 1, 0.3, 1);
	}
	.bm-lang-switcher__current:hover {
		background: rgba(15, 15, 18, 0.08);
	}
	.bm-lang-switcher__current:active {
		transform: scale(0.97);
	}
	.bm-lang-switcher__flag {
		width: 22px;
		height: 16px;
		border-radius: 3px;
		box-shadow: 0 0 0 1px rgba(15, 15, 18, 0.08);
	}
	.bm-lang-switcher__list {
		left: 0;
		right: auto;
	}

	/* CTA Inscripcions: pill amb fletxa que llisca. Diffusion shadow tintada,
	 * no glow genèric. Tactile press feedback. */
	.bm-site-header.is-mobile-open .bm-site-header__actions .bm-btn {
		flex: 0 1 auto;
		position: relative;
		justify-content: center;
		text-align: center;
		padding: 13px 22px 13px 24px;
		font-size: 12px;
		letter-spacing: 0.14em;
		box-shadow: 0 10px 24px -10px rgba(var(--bm-color-accent-rgb), 0.55);
		transition: transform .15s cubic-bezier(0.16, 1, 0.3, 1),
		            box-shadow .2s cubic-bezier(0.16, 1, 0.3, 1),
		            background .2s ease;
	}
	.bm-site-header.is-mobile-open .bm-site-header__actions .bm-btn::after {
		content: '';
		display: inline-block;
		width: 7px;
		height: 7px;
		margin-left: 10px;
		border-right: 2px solid currentColor;
		border-top: 2px solid currentColor;
		transform: rotate(45deg);
		transition: transform .25s cubic-bezier(0.16, 1, 0.3, 1);
	}
	.bm-site-header.is-mobile-open .bm-site-header__actions .bm-btn:hover {
		transform: translateY(-1px);
		box-shadow: 0 14px 28px -10px rgba(var(--bm-color-accent-rgb), 0.7);
	}
	.bm-site-header.is-mobile-open .bm-site-header__actions .bm-btn:hover::after {
		transform: rotate(45deg) translate(2px, -2px);
	}
	.bm-site-header.is-mobile-open .bm-site-header__actions .bm-btn:active {
		transform: translateY(0) scale(0.98);
	}

	/* ── Nav (menu list) ──────────────────────────────────────────────── */
	.bm-site-header.is-mobile-open .bm-site-header__nav {
		grid-area: nav;
		display: flex;
		flex-direction: column;
		max-height: calc(100vh - 240px);
		overflow-y: auto;
		padding-top: 4px;
		border-top: 1px solid rgba(15, 15, 18, 0.08);
	}
	.bm-site-header.is-mobile-open .bm-menu {
		flex-direction: column;
		gap: 0;
		align-items: stretch;
		width: 100%;
	}
	.bm-site-header.is-mobile-open .bm-menu li {
		width: 100%;
		opacity: 0;
		transform: translateX(-12px);
		animation: bm-drawer-item-in .5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
	}
	/* Stagger: cada ítem entra amb un petit retard, com una llista que
	 * es desplega per ordre. */
	.bm-site-header.is-mobile-open .bm-menu li:nth-child(1) { animation-delay: 40ms; }
	.bm-site-header.is-mobile-open .bm-menu li:nth-child(2) { animation-delay: 90ms; }
	.bm-site-header.is-mobile-open .bm-menu li:nth-child(3) { animation-delay: 140ms; }
	.bm-site-header.is-mobile-open .bm-menu li:nth-child(4) { animation-delay: 190ms; }
	.bm-site-header.is-mobile-open .bm-menu li:nth-child(5) { animation-delay: 240ms; }
	.bm-site-header.is-mobile-open .bm-menu li:nth-child(6) { animation-delay: 290ms; }
	.bm-site-header.is-mobile-open .bm-menu li:nth-child(7) { animation-delay: 340ms; }

	/* Cada link: padding compacte, marca editorial a l'esquerra (tally mark)
	 * + chevron a la dreta. Grid 3-cols: [mark] [label] [chevron]. */
	.bm-site-header.is-mobile-open .bm-menu a {
		position: relative;
		display: grid;
		grid-template-columns: 24px 1fr auto;
		align-items: center;
		gap: 14px;
		width: 100%;
		height: auto;
		padding: 14px 4px 14px 16px;
		font-family: var(--bm-font-heading);
		font-size: 19px;
		font-weight: var(--bm-fw-bold);
		letter-spacing: -0.01em;
		text-transform: none;
		color: var(--bm-color-text);
		border-bottom: none;
		transition: color .25s cubic-bezier(0.16, 1, 0.3, 1),
		            transform .25s cubic-bezier(0.16, 1, 0.3, 1);
	}

	/* Marca editorial a l'esquerra — petita barra horitzontal que creix
	 * i s'acolora en hover/active. Anti-slop: no és un bullet point ni un
	 * icone genèric, és un accent gràfic propi. */
	.bm-site-header.is-mobile-open .bm-menu a::before {
		content: '';
		display: block;
		width: 14px;
		height: 2px;
		background: var(--bm-color-text-mute);
		border-radius: 2px;
		transition: width .3s cubic-bezier(0.16, 1, 0.3, 1),
		            background .25s ease;
	}

	/* Chevron a la dreta — el text fa de cel·la central (1fr) */
	.bm-site-header.is-mobile-open .bm-menu a::after {
		content: '';
		display: inline-block;
		width: 8px;
		height: 8px;
		border-right: 1.5px solid var(--bm-color-text-mute);
		border-top: 1.5px solid var(--bm-color-text-mute);
		transform: rotate(45deg);
		transition: transform .3s cubic-bezier(0.16, 1, 0.3, 1),
		            border-color .25s ease;
	}

	/* Hairline divider entre items (no en l'últim) — més fina i diluïda
	 * que un border-bottom genèric. */
	.bm-site-header.is-mobile-open .bm-menu li:not(:last-child) > a {
		box-shadow: inset 0 -1px 0 rgba(15, 15, 18, 0.06);
	}

	/* Barra accent vertical a l'esquerra (pseudo en el <li>). Anclada
	 * fora del padding, escala des de baix en hover/active. */
	.bm-site-header.is-mobile-open .bm-menu li {
		position: relative;
	}
	.bm-site-header.is-mobile-open .bm-menu li::before {
		content: '';
		position: absolute;
		left: 0;
		top: 14px;
		bottom: 14px;
		width: 3px;
		background: var(--bm-color-accent);
		border-radius: 2px;
		transform: scaleY(0);
		transform-origin: center bottom;
		transition: transform .35s cubic-bezier(0.16, 1, 0.3, 1);
	}

	/* Hover/focus: la barra apareix, número i text passen a accent, el
	 * link es desplaça lleugerament a la dreta, chevron llisca. */
	.bm-site-header.is-mobile-open .bm-menu li:hover::before,
	.bm-site-header.is-mobile-open .bm-menu li:focus-within::before {
		transform: scaleY(1);
	}
	.bm-site-header.is-mobile-open .bm-menu a:hover,
	.bm-site-header.is-mobile-open .bm-menu a:focus-visible {
		color: var(--bm-color-accent);
		transform: translateX(4px);
		outline: none;
	}
	.bm-site-header.is-mobile-open .bm-menu a:hover::before,
	.bm-site-header.is-mobile-open .bm-menu a:focus-visible::before {
		width: 22px;
		background: var(--bm-color-accent);
	}
	.bm-site-header.is-mobile-open .bm-menu a:hover::after,
	.bm-site-header.is-mobile-open .bm-menu a:focus-visible::after {
		border-color: var(--bm-color-accent);
		transform: rotate(45deg) translate(3px, -3px);
	}
	.bm-site-header.is-mobile-open .bm-menu a:active {
		transform: translateX(4px) scale(0.99);
	}

	/* Estat actiu (pàgina actual): barra sempre visible, text + número en
	 * accent, sense efecte hover-translate (ja "està allà"). */
	.bm-site-header.is-mobile-open .bm-menu .current-menu-item::before,
	.bm-site-header.is-mobile-open .bm-menu .current-menu-ancestor::before,
	.bm-site-header.is-mobile-open .bm-menu .current_page_item::before {
		transform: scaleY(1);
	}
	.bm-site-header.is-mobile-open .bm-menu .current-menu-item > a,
	.bm-site-header.is-mobile-open .bm-menu .current-menu-ancestor > a,
	.bm-site-header.is-mobile-open .bm-menu .current_page_item > a {
		color: var(--bm-color-accent);
	}
	.bm-site-header.is-mobile-open .bm-menu .current-menu-item > a::before,
	.bm-site-header.is-mobile-open .bm-menu .current_page_item > a::before {
		width: 22px;
		background: var(--bm-color-accent);
	}
	.bm-site-header.is-mobile-open .bm-menu .current-menu-item > a::after,
	.bm-site-header.is-mobile-open .bm-menu .current_page_item > a::after {
		border-color: var(--bm-color-accent);
	}

	/* Reduced motion: respectem prefer-reduced-motion. */
	@media (prefers-reduced-motion: reduce) {
		.bm-site-header.is-mobile-open .bm-menu li {
			opacity: 1;
			transform: none;
			animation: none;
		}
	}

	/* ── Drawer abierto sobre HERO: forzamos estilo sólido aunque no haya scroll.
	 * Sobreescribe las reglas `body.bm-has-hero .bm-site-header:not(.is-scrolled) …`
	 * que dejan el header transparente con tipografía/iconografía blanca. */
	body.bm-has-hero .bm-site-header.is-mobile-open:not(.is-scrolled) {
		background: var(--bm-color-bg-alt);
	}
	body.bm-has-hero .bm-site-header.is-mobile-open:not(.is-scrolled) .bm-menu a,
	body.bm-has-hero .bm-site-header.is-mobile-open:not(.is-scrolled) .bm-lang-switcher__current,
	body.bm-has-hero .bm-site-header.is-mobile-open:not(.is-scrolled) .bm-site-header__site-title {
		color: var(--bm-color-text);
	}
	body.bm-has-hero .bm-site-header.is-mobile-open:not(.is-scrolled) .bm-lang-switcher__current {
		border-color: var(--bm-color-border);
	}
	body.bm-has-hero .bm-site-header.is-mobile-open:not(.is-scrolled) .bm-menu-toggle__bar {
		background: var(--bm-color-text);
	}
	body.bm-has-hero .bm-site-header.is-mobile-open:not(.is-scrolled) .bm-logo--dark { display: block; }
	body.bm-has-hero .bm-site-header.is-mobile-open:not(.is-scrolled) .bm-logo--light { display: none; }
}
