/*
 * Site header, built to match the Poparide design system web header
 * (poparide-client apps/web/src/components/Header.module.css + Button.module.css):
 * white bar with a light border, 12px-radius controls, navy text, hover tint, and a filled
 * "action" button (orange-600) for the primary call to action.
 *
 * Markup: header.php (.site-header). Mobile menu toggle: assets/js/custom.js.
 * Breakpoints: below 1024px the links collapse into a menu (the French labels do not fit next to the
 * logo any earlier); below 768px the bar is also made more compact (the theme's usual phone breakpoint).
 * Replaces the legacy #header-page rules that were copied into main.css (now unused).
 */

.site-header {
	/* Design system tokens (poparide-client globals.css) */
	--ds-action: #d23f00;           /* --color-action (orange-600) */
	--ds-action-dark: #a53000;      /* --color-action-dark (orange-700) */
	--ds-primary: #183154;          /* --color-primary (navy-500) */
	--ds-text: #466682;             /* --color-text-tertiary (navy-400) */
	--ds-tint: #f1faff;             /* --color-primary-tint (blue-100) */
	--ds-subtle: #e0f5fc;           /* --color-primary-subtle (blue-200) */
	--ds-border: #edeff2;           /* --color-border (neutral-300) */
	--ds-border-strong: #d7e6ed;    /* --color-border-strong (navy-200) */
	--ds-focus: #4aa6db;            /* blue-500 */
	--ds-radius: 12px;              /* --radius-md */

	position: relative;
	z-index: 500;
	/* Page content used to start ~40px below the old header's bottom edge. */
	margin-bottom: 40px;
	background: #fff;
	border-bottom: 1px solid var(--ds-border);
	font-family: "proxima-soft", system-ui, sans-serif;
}

.site-header__inner {
	box-sizing: border-box;
	display: flex;
	align-items: center;
	gap: 8px;
	width: 100%;
	height: 72px;
	margin: 0 auto;
	padding: 0 15px;
}

/* Same widths and 15px gutters as the theme's .container, so the logo and Sign in line up
   with the edges of the content below (cards, post body) at every width. */
@media (min-width: 768px) {
	.site-header__inner {
		max-width: 750px;
	}
}

@media (min-width: 992px) {
	.site-header__inner {
		max-width: 970px;
	}
}

@media (min-width: 1200px) {
	.site-header__inner {
		max-width: 1170px;
	}
}

/* ─── Brand ─────────────────────────────────────────────────────────────── */

.site-header__brand {
	display: flex;
	align-items: center;
	gap: 14px;
	min-width: 0;
	margin-right: auto;
}

.site-header__logo {
	display: flex;
	flex-shrink: 0;
	border: 0;
	line-height: 0;
}

.site-header__logo:hover {
	opacity: 0.9;
}

.site-header__logo img {
	display: block;
	width: auto;
	height: 30px;
}

.site-header__tagline {
	padding-left: 14px;
	border-left: 1px solid var(--ds-border-strong);
	font-size: 16px;
	font-weight: 600;
	line-height: 20px;
	color: var(--ds-text);
	white-space: nowrap;
}

/* ─── Links and buttons ─────────────────────────────────────────────────── */

.site-header__nav {
	display: flex;
	align-items: center;
	gap: 4px;
}

.site-header__link {
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	height: 44px;
	padding: 0 16px;
	border: 0;
	border-radius: var(--ds-radius);
	background: transparent;
	font-size: 16px;
	font-weight: 600;
	line-height: 20px;
	color: var(--ds-text);
	text-decoration: none;
	white-space: nowrap;
	cursor: pointer;
	transition: background 0.15s, color 0.15s;
}

/* The website header's 40px-grid icons, drawn at 28px. Their built-in padding is trimmed so the glyph sits on
   the button's padding edge and the gap to the label matches www.poparide.com. */
.site-header__icon {
	flex-shrink: 0;
	width: 28px;
	height: 28px;
	margin: 0 -2px 0 -6px;
}

/* main.css underlines and recolors every link on :focus (blue, underlined, e.g. after a click), which beat the buttons'
   own colors. Keep the resting color and no underline in the focused state. */
.site-header__link:focus {
	color: var(--ds-text);
	text-decoration: none;
}

.site-header__link:hover,
.site-header__link:focus-visible {
	background: var(--ds-tint);
	color: var(--ds-primary);
	text-decoration: none;
}

.site-header__link:active {
	background: var(--ds-subtle);
}

.site-header__link:focus-visible,
.site-header__toggle:focus-visible {
	outline: 2px solid var(--ds-focus);
	outline-offset: 2px;
}

/* Sign in: the filled action button */
.site-header__link--primary {
	margin-left: 8px;
	background: var(--ds-action);
	color: #fff;
}

.site-header__link--primary:hover,
.site-header__link--primary:focus-visible,
.site-header__link--primary:active {
	background: var(--ds-action-dark);
	color: #fff;
	text-decoration: none;
}

/* Focused (e.g. clicked) but not hovered: plain white text on the action button. */
.site-header__link--primary:focus {
	color: #fff;
}

.site-header__label-narrow {
	display: none;
}

/* ─── Language switcher ─────────────────────────────────────────────────── */

/* Desktop: a button (globe, EN / FR, caret) that opens a small dropdown with the two blogs, styled like the
   design system's dropdown (poparide-client Header.module.css .dropdown): 1px border, large radius, soft shadow,
   12px-radius items with the light blue hover. Markup in header.php, open/close in assets/js/custom.js. */

.site-header__lang {
	position: relative;
	margin-left: 4px;
}

.site-header__lang-toggle {
	font-family: inherit;
	gap: 6px;
	padding: 0 12px;
}

.site-header__lang-code {
	letter-spacing: 0.02em;
}

/* The full language name is only shown in the phone / tablet menu; the "How it works" icon likewise. */
.site-header__lang-name,
.site-header__icon--mobile-only {
	display: none;
}

.site-header__lang-toggle .chevron {
	width: 7px;
	height: 10px;
	margin-left: 2px;
	transition: transform 0.15s;
}

.site-header__lang.is-open .site-header__lang-toggle {
	background: var(--ds-tint);
	color: var(--ds-primary);
}

.site-header__lang.is-open .site-header__lang-toggle .chevron {
	transform: rotate(-90deg);
}

.site-header__lang-menu {
	position: absolute;
	top: calc(100% + 10px);
	right: 0;
	z-index: 10;
	display: none;
	min-width: 180px;
	margin: 0;
	padding: 8px;
	list-style: none;
	border: 1px solid var(--ds-border);
	border-radius: 20px;
	background: #fff;
	box-shadow: 0 12px 24px -12px rgba(24, 49, 84, 0.18);
}

.site-header__lang.is-open .site-header__lang-menu {
	display: block;
}

.site-header__lang-link {
	box-sizing: border-box;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	height: 44px;
	padding: 0 14px;
	border: 0;
	border-radius: var(--ds-radius);
	font-size: 16px;
	font-weight: 400;
	line-height: 20px;
	color: var(--ds-text);
	text-decoration: none;
	white-space: nowrap;
	transition: background 0.15s, color 0.15s;
}

.site-header__lang-link:hover,
.site-header__lang-link:focus,
.site-header__lang-link:focus-visible {
	background: var(--ds-tint);
	color: var(--ds-primary);
	text-decoration: none;
}

.site-header__lang-link[aria-current] {
	font-weight: 600;
	color: var(--ds-primary);
}

/* 1024-1199px: the French labels plus the language button only just fit next to the logo, so the nav buttons get
   tighter side padding in this range. */
@media (min-width: 1024px) and (max-width: 1199px) {
	.site-header__nav > .site-header__link,
	.site-header__lang-toggle {
		padding-right: 10px;
		padding-left: 10px;
	}

	.site-header__icon {
		margin-left: -8px;
	}
}

/* ─── Mobile menu toggle (hidden on desktop) ────────────────────────────── */

.site-header__toggle {
	display: none;
}

/* ─── Collapsed (< 1024px): logo, Sign in, menu button; the other links drop down ─ */

@media (max-width: 1023px) {
	.site-header__link--primary {
		margin-left: 0;
	}

	.site-header__toggle {
		box-sizing: border-box;
		display: inline-flex;
		flex-shrink: 0;
		align-items: center;
		justify-content: center;
		width: 44px;
		height: 44px;
		margin: 0;
		padding: 0;
		border: 1.5px solid var(--ds-border-strong);
		border-radius: var(--ds-radius);
		background: #fff;
		color: var(--ds-primary);
		cursor: pointer;
		transition: background 0.15s;
	}

	.site-header__toggle:hover {
		background: var(--ds-tint);
	}

	.site-header__toggle-close,
	.site-header.is-open .site-header__toggle-open {
		display: none;
	}

	.site-header.is-open .site-header__toggle-close {
		display: block;
	}

	/* Dropdown panel under the bar */
	.site-header__nav {
		position: absolute;
		top: 100%;
		right: 0;
		left: 0;
		display: none;
		flex-direction: column;
		align-items: stretch;
		gap: 4px;
		padding: 8px 15px 16px;
		border-bottom: 1px solid var(--ds-border);
		background: #fff;
		box-shadow: 0 12px 24px -12px rgba(24, 49, 84, 0.18);
	}

	.site-header.is-open .site-header__nav {
		display: flex;
	}

	.site-header__nav .site-header__link {
		justify-content: flex-start;
		height: 48px;
		font-size: 17px;
	}

	/* "How it works" gets its icon (from the website's mobile menu) in this menu only. */
	.site-header__icon--mobile-only {
		display: block;
	}

	/* Language switcher: a full-width row like the other links (globe, language name, caret) that opens the same
	   dropdown card, shown inline under the row. */
	.site-header__lang {
		margin: 8px 0 0;
		padding-top: 8px;
		border-top: 1px solid var(--ds-border);
	}

	.site-header__lang-toggle {
		gap: 8px; /* same gap as the other links, so the language name lines up with the labels of the rows above */
		width: 100%;
		padding: 0 16px;
	}

	.site-header__lang-code {
		display: none;
	}

	.site-header__lang-name {
		display: inline;
	}

	.site-header__lang-toggle .chevron {
		margin-left: auto;
	}

	.site-header__lang-menu {
		position: static;
		margin-top: 8px;
		box-shadow: none;
	}
}

/* Keep the dropdown's rows on the same 750px / 970px column as the bar above it. */
@media (min-width: 768px) and (max-width: 991px) {
	.site-header__nav {
		padding-right: calc((100% - 750px) / 2 + 15px);
		padding-left: calc((100% - 750px) / 2 + 15px);
	}
}

@media (min-width: 992px) and (max-width: 1023px) {
	.site-header__nav {
		padding-right: calc((100% - 970px) / 2 + 15px);
		padding-left: calc((100% - 970px) / 2 + 15px);
	}
}

/* ─── Phones (< 768px): more compact bar ────────────────────────────────── */

@media (max-width: 767px) {
	.site-header {
		margin-bottom: 16px;
	}

	.site-header__inner {
		height: 60px;
	}

	.site-header__brand {
		gap: 12px;
	}

	.site-header__logo img {
		height: 26px;
	}

	.site-header__tagline {
		padding-left: 12px;
		font-size: 15px;
	}

	.site-header__label-wide {
		display: none;
	}

	.site-header__label-narrow {
		display: inline;
	}

	.site-header__link--primary {
		height: 40px;
		padding: 0 14px;
		font-size: 15px;
	}

	.site-header__toggle {
		width: 40px;
		height: 40px;
	}

}

/* Narrow phones: drop the "Blog" label so logo + Sign in + menu fit */
@media (max-width: 359px) {
	.site-header__tagline {
		display: none;
	}
}
