/* ==========================================================================
   Blue Diamond Society — header
   Top bar + main header that stays fixed on scroll + mobile off-canvas menu.

   Styles only the header's own .bds-* elements: no resets, no Divi overrides.
   Colours and fonts come from the :root tokens in style.css, with fallbacks.
   980px matches Divi's tablet breakpoint.
   ========================================================================== */

/* ---------- Layout ---------- */
.bds-wrap {
	box-sizing: border-box;
	width: 100%;
	max-width: var(--wrap, 1200px);
	margin: 0 auto;
	padding: 0 24px;
}

.bds-topbar,
.bds-header {
	font-family: var(--body, "Source Sans 3", system-ui, sans-serif);
	-webkit-font-smoothing: antialiased;
}

/* Visually hidden, still read by screen readers (search labels) */
.bds-sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* ---------- Buttons ---------- */
.bds-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	box-sizing: border-box;
	padding: 14px 24px;
	border: 0;
	border-radius: 999px;
	font-family: var(--body, "Source Sans 3", system-ui, sans-serif);
	font-size: 16px;
	font-weight: 700;
	line-height: 1;
	white-space: nowrap;
	text-decoration: none;
	cursor: pointer;
	transition: background-color .2s, transform .2s;
}
.bds-btn--blue,
.bds-btn--blue:hover { color: #fff; }
.bds-btn--blue { background: var(--blue, #2340D6); }
.bds-btn--blue:hover { background: var(--navy, #101A5C); }
.bds-btn--sun,
.bds-btn--sun:hover { color: var(--ink, #0D1230); }
.bds-btn--sun { background: var(--sun, #FFC83D); }
.bds-btn--sun:hover { background: #ffd666; transform: translateY(-1px); }
.bds-btn--block { width: 100%; }

/* ---------- Top bar ---------- */
.bds-topbar {
	background: var(--navy, #101A5C);
	color: #C9D1FF;
	font-size: 14px;
	line-height: 1.4;
}
.bds-topbar__inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	min-height: 42px;
}
.bds-topbar__group {
	display: flex;
	align-items: center;
	gap: 20px;
	min-width: 0;
}

.bds-topbar .bds-help-pill {
	padding: 5px 14px;
	border-radius: 999px;
	background: var(--pink, #E8388F);
	color: #fff;
	font-weight: 600;
	white-space: nowrap;
	text-decoration: none;
	transition: background-color .2s;
}
.bds-topbar .bds-help-pill:hover { background: #cf2a7b; color: #fff; }

.bds-secondary-menu {
	display: flex;
	gap: 20px;
	margin: 0;
	padding: 0;
	list-style: none;
}
.bds-topbar .bds-secondary-menu a {
	color: #fff;
	font-weight: 600;
	text-decoration: none;
}
.bds-topbar .bds-secondary-menu a:hover { color: var(--sun, #FFC83D); }

.bds-lang {
	display: flex;
	flex-shrink: 0;
	overflow: hidden;
	border: 1px solid rgba(255, 255, 255, .3);
	border-radius: 999px;
}
.bds-lang .bds-lang__link {
	padding: 3px 12px;
	color: #fff;
	font-weight: 600;
	text-decoration: none;
}
.bds-lang .bds-lang__link.is-current {
	background: #fff;
	color: var(--navy, #101A5C);
}

/* ---------- Main header ---------- */
/*
 * The header is fixed by JS (is-fixed) once the top bar scrolls away, rather than
 * position: sticky, because Divi's #page-container has overflow-y: hidden, which
 * stops sticky from working. .bds-header-holder keeps its space so nothing jumps.
 */
.bds-header-holder { position: relative; }

.bds-header {
	position: relative;
	z-index: 9990; /* above Divi sections, below the WP admin bar */
	border-bottom: 1px solid var(--line, #E3E6F3);
	background: rgba(255, 255, 255, .97);
	-webkit-backdrop-filter: blur(10px);
	backdrop-filter: blur(10px);
	transition: box-shadow .25s;
}
.bds-header.is-fixed {
	position: fixed;
	top: var(--bds-fixed-top, 0px); /* height of the WP admin bar when it is fixed, set by JS */
	right: 0;
	left: 0;
}
.bds-header.is-scrolled { box-shadow: 0 8px 30px rgba(16, 26, 92, .08); }

.bds-header__inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 20px;
	height: 84px;
	transition: height .25s;
}
.bds-header.is-scrolled .bds-header__inner { height: 70px; }

/* Logo */
.bds-logo {
	display: flex;
	flex-shrink: 0;
	align-items: center;
	gap: 12px;
	text-decoration: none;
}
.bds-logo .bds-logo__img {
	display: block;
	width: auto;
	height: 56px;
	transition: height .25s;
}
.bds-header.is-scrolled .bds-logo .bds-logo__img { height: 46px; }
.bds-logo__text {
	display: flex;
	flex-direction: column;
	gap: 3px;
	font-family: var(--display, "Barlow Condensed", "Arial Narrow", sans-serif);
	text-transform: uppercase;
}
.bds-logo__name {
	color: var(--navy, #101A5C);
	font-size: 22px;
	font-weight: 800;
	line-height: .95;
}
.bds-logo__tagline {
	color: var(--blue, #2340D6);
	font-size: 13px;
	font-weight: 700;
	line-height: 1;
	letter-spacing: 3px;
}

/* Desktop menu */
.bds-menu,
.bds-menu .sub-menu {
	margin: 0;
	padding: 0;
	list-style: none;
}
.bds-menu {
	display: flex;
	align-items: center;
	gap: 4px;
}
.bds-menu li { position: relative; }
.bds-menu a {
	display: block;
	padding: 10px 14px;
	border-radius: 999px;
	color: var(--ink, #0D1230);
	font-size: 16px;
	font-weight: 600;
	line-height: 1.3;
	text-decoration: none;
	transition: background-color .2s, color .2s;
}
.bds-menu > li > a:hover,
.bds-menu > li:focus-within > a,
.bds-menu > .current-menu-item > a,
.bds-menu > .current-menu-ancestor > a,
.bds-menu > .current_page_item > a {
	background: var(--sky, #EEF2FF);
	color: var(--blue, #2340D6);
}
.bds-menu > .menu-item-has-children > a { padding-right: 30px; }
.bds-menu > .menu-item-has-children > a::after {
	content: "";
	position: absolute;
	top: 50%;
	right: 14px;
	width: 7px;
	height: 7px;
	border-right: 2px solid currentColor;
	border-bottom: 2px solid currentColor;
	transform: translateY(-70%) rotate(45deg);
}

/* Desktop dropdowns */
.bds-menu .sub-menu {
	position: absolute;
	top: calc(100% + 10px);
	left: 0;
	z-index: 10;
	min-width: 240px;
	padding: 8px;
	border: 1px solid var(--line, #E3E6F3);
	border-radius: 16px;
	background: #fff;
	box-shadow: 0 24px 50px rgba(16, 26, 92, .14);
	opacity: 0;
	visibility: hidden;
	transform: translateY(6px);
	transition: opacity .2s, transform .2s, visibility .2s;
}
.bds-menu .sub-menu::before { /* hover bridge across the 10px gap */
	content: "";
	position: absolute;
	top: -12px;
	right: 0;
	left: 0;
	height: 12px;
}
.bds-menu li:hover > .sub-menu,
.bds-menu li:focus-within > .sub-menu {
	opacity: 1;
	visibility: visible;
	transform: none;
}
.bds-menu .sub-menu a {
	border-radius: 10px;
	font-size: 15px;
}
.bds-menu .sub-menu a:hover,
.bds-menu .sub-menu .current-menu-item > a {
	background: var(--sky, #EEF2FF);
	color: var(--blue, #2340D6);
}
.bds-menu .sub-menu .sub-menu {
	top: -9px;
	left: 100%;
}

.bds-submenu-toggle,
.bds-nav__extra { display: none; }

/* Actions */
.bds-header__actions {
	display: flex;
	flex-shrink: 0;
	align-items: center;
	gap: 10px;
}
.bds-icon-btn {
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--ink, #0D1230);
	cursor: pointer;
	transition: background-color .2s, color .2s;
}
.bds-icon-btn:hover,
.bds-icon-btn[aria-expanded="true"] {
	background: var(--sky, #EEF2FF);
	color: var(--blue, #2340D6);
}

.bds-burger {
	display: none;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	cursor: pointer;
}
.bds-burger span {
	display: block;
	width: 24px;
	height: 2px;
	margin: 6px auto;
	border-radius: 2px;
	background: var(--ink, #0D1230);
	transition: transform .25s, opacity .25s;
}
.bds-burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
.bds-burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.bds-burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

/* Search */
.bds-search-bar {
	padding: 16px 0;
	border-top: 1px solid var(--line, #E3E6F3);
	background: #fff;
}
.bds-search-bar[hidden] { display: none; }
.bds-search-form {
	display: flex;
	gap: 10px;
	box-sizing: border-box;
	padding: 6px;
	border: 1px solid var(--line, #E3E6F3);
	border-radius: 999px;
	background: #fff;
}
.bds-search-form .bds-search-form__input {
	flex: 1;
	min-width: 0;
	padding: 8px 16px;
	border: 0;
	outline: 0;
	background: transparent;
	color: var(--ink, #0D1230);
	font: inherit;
	font-size: 16px; /* 16px stops iOS zooming in on focus */
}
.bds-search-form .bds-btn { padding: 12px 22px; }

/* ==========================================================================
   Tablet & mobile
   ========================================================================== */
@media (max-width: 1180px) {
	.bds-menu a {
		padding: 10px;
		font-size: 15px;
	}
	.bds-menu > .menu-item-has-children > a { padding-right: 26px; }
	.bds-menu > .menu-item-has-children > a::after { right: 10px; }
}

@media (max-width: 980px) {
	.bds-topbar__hours,
	.bds-topbar__links { display: none; }

	/* A backdrop-filter would make the fixed panel position against the header, not the screen. */
	.bds-header {
		-webkit-backdrop-filter: none;
		backdrop-filter: none;
		background: #fff;
	}
	.bds-header__inner,
	.bds-header.is-scrolled .bds-header__inner { height: 72px; }

	.bds-burger { display: block; }
	.bds-search-toggle { display: none; }

	/* Off-canvas panel, opens below the header */
	.bds-nav__panel {
		position: fixed;
		top: var(--bds-nav-top, 0px);
		right: 0;
		bottom: 0;
		z-index: 2;
		box-sizing: border-box;
		width: min(400px, 100vw);
		padding: 16px 20px 32px;
		overflow-y: auto;
		overscroll-behavior: contain;
		background: #fff;
		box-shadow: -20px 0 50px rgba(16, 26, 92, .12);
		transform: translateX(100%);
		visibility: hidden;
		transition: transform .3s ease, visibility .3s;
	}
	.bds-nav.is-open .bds-nav__panel {
		transform: none;
		visibility: visible;
	}

	.bds-nav-overlay {
		position: fixed;
		top: var(--bds-nav-top, 0px);
		right: 0;
		bottom: 0;
		left: 0;
		z-index: 9989;
		background: rgba(13, 18, 48, .45);
		opacity: 0;
		transition: opacity .3s;
	}
	.bds-nav-overlay.is-visible { opacity: 1; }
	.bds-nav-overlay[hidden] { display: none; }

	/* Stacked menu */
	.bds-menu {
		flex-direction: column;
		align-items: stretch;
		gap: 0;
	}
	.bds-menu li { border-bottom: 1px solid var(--line, #E3E6F3); }
	.bds-menu a {
		padding: 15px 52px 15px 4px;
		border-radius: 0;
		font-family: var(--display, "Barlow Condensed", "Arial Narrow", sans-serif);
		font-size: 24px;
		font-weight: 700;
		letter-spacing: .3px;
		text-transform: uppercase;
	}
	.bds-menu > li > a:hover,
	.bds-menu > li:focus-within > a,
	.bds-menu > .current-menu-item > a,
	.bds-menu > .current-menu-ancestor > a,
	.bds-menu > .current_page_item > a {
		background: transparent;
		color: var(--blue, #2340D6);
	}
	.bds-menu > .menu-item-has-children > a { padding-right: 52px; }
	.bds-menu > .menu-item-has-children > a::after { display: none; }

	/* Accordion sub-menus */
	.bds-menu .sub-menu,
	.bds-menu .sub-menu .sub-menu {
		position: static;
		display: none;
		min-width: 0;
		margin: 0 0 12px;
		padding: 4px 12px;
		border: 0;
		border-radius: 12px;
		background: var(--sky, #EEF2FF);
		box-shadow: none;
		opacity: 1;
		visibility: visible;
		transform: none;
	}
	.bds-menu .sub-menu::before { display: none; }
	.bds-menu li.is-expanded > .sub-menu { display: block; }
	.bds-menu .sub-menu li { border-bottom: 1px solid rgba(35, 64, 214, .1); }
	.bds-menu .sub-menu li:last-child { border-bottom: 0; }
	.bds-menu .sub-menu a {
		padding: 12px 44px 12px 4px;
		font-family: var(--body, "Source Sans 3", system-ui, sans-serif);
		font-size: 17px;
		letter-spacing: 0;
		text-transform: none;
	}

	.bds-submenu-toggle {
		position: absolute;
		top: 8px;
		right: 0;
		display: grid;
		place-items: center;
		width: 40px;
		height: 40px;
		padding: 0;
		border: 0;
		border-radius: 50%;
		background: var(--sky, #EEF2FF);
		color: var(--blue, #2340D6);
		cursor: pointer;
	}
	.sub-menu .bds-submenu-toggle {
		top: 4px;
		width: 36px;
		height: 36px;
		background: #fff;
	}
	.bds-submenu-toggle svg { transition: transform .25s; }
	.is-expanded > .bds-submenu-toggle svg { transform: rotate(180deg); }

	/* Extras inside the panel */
	.bds-nav__extra {
		display: grid;
		gap: 18px;
		margin-top: 24px;
	}
	.bds-nav__links .bds-secondary-menu {
		flex-wrap: wrap;
		gap: 8px 20px;
	}
	.bds-nav__links a {
		color: var(--navy, #101A5C);
		font-weight: 600;
		text-decoration: none;
	}
	.bds-nav__helpline {
		display: flex;
		flex-direction: column;
		padding: 18px 20px;
		border-radius: 16px;
		background: var(--navy, #101A5C);
		color: #C9D1FF;
		font-size: 15px;
		line-height: 1.5;
	}
	.bds-nav__helpline a {
		color: var(--sun, #FFC83D);
		font-family: var(--display, "Barlow Condensed", "Arial Narrow", sans-serif);
		font-size: 30px;
		font-weight: 800;
		text-decoration: none;
	}

	body.bds-menu-open { overflow: hidden; }
}

@media (max-width: 640px) {
	.bds-wrap { padding: 0 16px; }
	.bds-topbar__inner {
		gap: 10px;
		min-height: 38px;
	}
	.bds-topbar .bds-help-pill {
		padding: 4px 12px;
		font-size: 13px;
	}
	.bds-help-pill__label { display: none; } /* number only on phones */
	.bds-help-pill::before { content: "☎ "; }

	.bds-header__inner { gap: 10px; }
	.bds-logo .bds-logo__img { height: 46px; }
	.bds-logo__name { font-size: 18px; }
	.bds-logo__tagline {
		font-size: 11px;
		letter-spacing: 2px;
	}
	.bds-header__donate.bds-btn {
		padding: 11px 16px;
		font-size: 15px;
	}
}

@media (max-width: 400px) {
	.bds-logo .bds-logo__img { height: 40px; }
	.bds-logo__name { font-size: 16px; }
	.bds-logo__tagline { display: none; }
}

@media (max-width: 340px) {
	.bds-logo__text { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	.bds-header,
	.bds-header *,
	.bds-nav-overlay { transition: none; }
}
