/*
 * Header — Naccarato Insurance
 *
 * Measured from the approved design (SUBPAGES auto -4.png, 1300px wide, so
 * measurements are 1:1 CSS px):
 *
 *   header height   158px
 *   logo            x 66,  ~200×122
 *   utility row     y 23–43,  starts x 420
 *   nav             y 82–100, starts x 422
 *   CTA button      x 1029–1241 (212×46)
 *   chat link       y 127–141, right aligned
 *
 * Note there is no rule under the utility row: header and navigation read as
 * one block, not two stacked bands.
 * Depends on tokens.css.
 */

/*
 * Pinned to the top on every page (Task 016). The background lives on
 * ::before — see "Sticky header" at the end of this file.
 */
.site-header {
	position: sticky;
	z-index: var(--z-header);
	top: 0;
}

.site-header__inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-6);
	/* El diseño da 158px de alto total; con más padding se pasa. */
	padding-block: var(--space-2);
}

/*
 * Wider than the 1140 content column (client, 2026-11-05: logo bigger).
 * The logo has no fixed size: it takes what the menu and the CTA leave, and
 * the menu type grows with the frame up to 1300px, so in a full-screen
 * window it was down to 112×67. The extra 160px all go to the logo, which
 * reaches its 122px cap (205×122) from 1366px; the menu does not change.
 */
@media (min-width: 1024px) {
	.site-header__inner {
		max-width: calc(1300px + (var(--gutter) * 2));
	}
}

/* ===================================================================
 * Branding
 * =================================================================== */

.site-branding__link {
	display: inline-block;
}

.site-branding__logo,
.custom-logo {
	width: auto;
	max-width: 100%;
	height: auto;
	max-height: 60px;
}

@media (min-width: 1024px) {
	.site-branding__logo,
	.custom-logo {
		max-height: 122px;
	}
}

/* ===================================================================
 * Mobile phone — between the logo and the hamburger (client, 2026-12-01)
 *
 * Gold, bold, one tap to call. Below 1024px only: from there the utility row
 * carries the number. nowrap + a clamped size keep it on one line down to a
 * 320px screen without pushing the menu button out.
 * =================================================================== */

.site-header__phone {
	flex: 0 1 auto;
	margin-inline: auto;
	color: var(--color-accent);
	font-family: var(--font-display);
	font-size: clamp(0.8125rem, 4.2vw, 1.0625rem);
	font-weight: var(--fw-extrabold);
	line-height: 1;
	text-decoration: none;
	white-space: nowrap;
}

.site-header__phone:hover,
.site-header__phone:focus-visible {
	color: var(--color-primary);
}

@media (min-width: 1024px) {
	.site-header__phone {
		display: none;
	}
}

/* ===================================================================
 * Mobile toggle — hamburger
 * =================================================================== */

.nav-toggle {
	display: flex;
	width: 44px;
	height: 44px;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: 0;
	background: none;
	color: var(--color-primary);
}

.nav-toggle__bars,
.nav-toggle__bars::before,
.nav-toggle__bars::after {
	display: block;
	width: 26px;
	height: 3px;
	border-radius: var(--radius-sm);
	background-color: currentColor;
	transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.nav-toggle__bars {
	position: relative;
}

.nav-toggle__bars::before,
.nav-toggle__bars::after {
	position: absolute;
	left: 0;
	content: "";
}

.nav-toggle__bars::before {
	top: -8px;
}

.nav-toggle__bars::after {
	top: 8px;
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bars {
	background-color: transparent;
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bars::before {
	top: 0;
	transform: rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bars::after {
	top: 0;
	transform: rotate(-45deg);
}

@media (min-width: 1024px) {
	.nav-toggle {
		display: none;
	}
}

/* ===================================================================
 * Header body — the two rows beside the logo
 *
 * Off-canvas below 1024px; the stacked rows from the design above it.
 * =================================================================== */

@media (max-width: 1023px) {
	.site-header__body {
		position: fixed;
		z-index: var(--z-overlay);
		top: 0;
		right: 0;
		display: flex;
		width: min(22rem, 85vw);
		height: 100dvh;
		flex-direction: column;
		gap: var(--space-6);
		padding: var(--space-16) var(--space-6) var(--space-8);
		background-color: var(--color-bg);
		box-shadow: var(--shadow-md);
		overflow-y: auto;
		overscroll-behavior: contain;
		transform: translateX(100%);
		transition: transform var(--transition-base);
		visibility: hidden;
	}

	.site-header__body.is-open {
		transform: translateX(0);
		visibility: visible;
	}

	.nav-overlay {
		position: fixed;
		z-index: var(--z-dropdown);
		inset: 0;
		background-color: rgba(26, 23, 27, 0.5);
	}
}

@media (min-width: 1024px) {
	.site-header__body {
		display: flex;
		flex: 1;
		flex-direction: column;
		gap: var(--space-2);
	}

	/* Contact row pushed down, closer to the nav, so it does not get
	   lost against the top of the window (client, 2026-11-04). */
	.site-header__body > .utility-bar {
		margin-top: var(--space-5);
	}

	/* Navigation and CTA share the lower row. */
	.site-header__row {
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: var(--space-8);
	}
}

/* ===================================================================
 * Utility row — phone, email, social
 * =================================================================== */

.utility-bar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--space-3) var(--space-8);
	font-size: var(--fs-sm);
}

.utility-bar__contact,
.utility-bar__social {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--space-2) var(--space-6);
	margin: 0;
	padding: 0;
	list-style: none;
}

.utility-bar__contact li,
.utility-bar__social li {
	margin: 0;
}

/* Brand red, so the contact row stands out (client, 2026-11-03). */
.utility-bar__contact a {
	color: var(--color-primary);
	font-weight: var(--fw-medium);
	text-decoration: none;
	white-space: nowrap;
}

.utility-bar__contact a:hover,
.utility-bar__contact a:focus {
	color: var(--color-accent);
}

.utility-bar__social {
	gap: var(--space-2);
}

/* 44px touch target around a 20px ring. */
.utility-bar__social-link {
	display: flex;
	width: 44px;
	height: 44px;
	align-items: center;
	justify-content: center;
	color: var(--color-primary);
	transition: color var(--transition-fast);
}

.utility-bar__social-link:hover,
.utility-bar__social-link:focus {
	color: var(--color-accent);
}

@media (min-width: 1024px) {
	/*
	 * Bold, in the nav's face (client, 2026-11-10: "as bold and as big as the
	 * main navigation"). Size stays --fs-sm (18px at full width), which already
	 * matches the nav's cap height; no uppercase, so the email stays legible.
	 */
	.utility-bar__contact a {
		font-family: var(--font-display);
		font-weight: var(--fw-extrabold);
		letter-spacing: -0.025em;
	}

	/* Bigger ring with a heavier stroke, to match. */
	.utility-bar__social-link {
		width: 36px;
		height: 36px;
	}

	.utility-bar__social .social-icon {
		width: 28px;
		height: 28px;
	}

	.utility-bar__social .social-icon circle {
		stroke-width: 2.2;
	}
}

/* ===================================================================
 * Primary nav
 * =================================================================== */

.site-nav__list {
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
	margin: 0;
	padding: 0;
	list-style: none;
}

.site-nav__item {
	margin: 0;
}

/*
 * Two selectors because the fallback emits .site-nav__link and wp_nav_menu's
 * markup does not. Restricted to direct children: the mega-menu panel lives
 * inside the Insurance Services <li>, and an unscoped `.site-nav__list a` beats
 * .mega-menu__link on specificity — every link in the panel would come out
 * in this face and, above 1024px, nowrap.
 *
 * Type and colour from "NACC - MAIN NAVEGATION WEB D" (Task 013): Inter,
 * uppercase, its own burgundy. The labels stay in sentence case in the HTML so
 * screen readers do not spell them out.
 */
.site-nav__link,
.site-nav__list > li > a {
	--nav-link-pad-block: var(--space-3);

	position: relative;
	display: block;
	padding: var(--nav-link-pad-block) 0;
	color: var(--color-nav);
	font-family: var(--font-display);
	font-size: 1.0625rem;
	font-weight: var(--fw-extrabold);
	letter-spacing: -0.025em;
	line-height: 1;
	text-decoration: none;
	text-transform: uppercase;
}

/* Hover is colour only; the underline is kept for "you are here". */
.site-nav__link:hover,
.site-nav__link:focus,
.site-nav__list > li > a:hover,
.site-nav__list > li > a:focus {
	color: var(--color-nav-active);
}

/*
 * Current page, or any page inside the item's section (is-current-section from
 * the fallback; the current-* classes are what wp_nav_menu emits).
 */
.site-nav__list > li > a[aria-current],
.site-nav__list > .is-current-section > a,
.site-nav__list > .current-menu-item > a,
.site-nav__list > .current-menu-ancestor > a,
.site-nav__list > .current-page-ancestor > a {
	color: var(--color-nav-active);
}

/*
 * The art's underline: 24×1px, 8px below the baseline. With line-height 1 the
 * Inter baseline sits 0.136em above the content box, hence the 0.38em.
 */
.site-nav__list > li > a[aria-current]::after,
.site-nav__list > .is-current-section > a::after,
.site-nav__list > .current-menu-item > a::after,
.site-nav__list > .current-menu-ancestor > a::after,
.site-nav__list > .current-page-ancestor > a::after {
	position: absolute;
	top: calc(100% - var(--nav-link-pad-block) + 0.38em);
	left: 0;
	width: 24px;
	height: 1px;
	background-color: var(--color-nav-active);
	content: "";
}

@media (min-width: 1024px) {
	.site-nav__list {
		flex-direction: row;
		align-items: center;
		gap: 0;
	}

	/* Flex so the divider centres on the label. */
	.site-nav__list > li {
		display: flex;
		align-items: center;
	}

	/* 1×27px rule between items, centred on the cap height. */
	.site-nav__list > li + li::before {
		width: 1px;
		height: 27px;
		flex: none;
		background-color: var(--color-nav);
		content: "";
	}

	.site-nav__link,
	.site-nav__list > li > a {
		--nav-link-pad-block: 0px;
		--nav-pad-left: var(--nav-item-pad);
		--nav-pad-right: var(--nav-item-pad);

		padding-inline: var(--nav-pad-left) var(--nav-pad-right);
		font-size: var(--fs-nav);
		/* The design keeps every item on a single line. */
		white-space: nowrap;
	}

	/* No outer air, so the first label starts where the menu always did. */
	.site-nav__list > li:first-child > a {
		--nav-pad-left: 0px;
	}

	.site-nav__list > li:last-child > a {
		--nav-pad-right: 0px;
	}

	/*
	 * Centred under the label. The box includes the padding, which is uneven on
	 * the first and last items, so shift by half the difference.
	 */
	.site-nav__list > li > a[aria-current]::after,
	.site-nav__list > .is-current-section > a::after,
	.site-nav__list > .current-menu-item > a::after,
	.site-nav__list > .current-menu-ancestor > a::after,
	.site-nav__list > .current-page-ancestor > a::after {
		left: calc(50% + (var(--nav-pad-left) - var(--nav-pad-right)) / 2);
		transform: translateX(-50%);
	}
}

/* ===================================================================
 * Actions — CTA and chat link
 * =================================================================== */

.site-header__actions {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: var(--space-3);
}

.site-header__chat {
	color: var(--color-text);
	font-size: var(--fs-sm);
	font-weight: var(--fw-medium);
	text-decoration: none;
	white-space: nowrap;
}

.site-header__chat:hover,
.site-header__chat:focus {
	color: var(--color-accent);
}

@media (min-width: 1024px) {
	.site-header__actions {
		align-items: flex-end;
		text-align: right;
	}
}

/* Prevents background scrolling while the off-canvas panel is open. */
body.has-nav-open {
	overflow: hidden;
}

/* ===================================================================
 * Sticky header (Task 016)
 *
 * The client asked for the logo, the menu and the CTA to stay on screen
 * with the page scrolling underneath, slightly see-through.
 *
 * Below 1024px, and above it without JS, the header is plain sticky. Above
 * 1024px main.js pins it (html.has-fixed-header) and adds .is-compact once
 * the page scrolls: the utility row and the chat link go, the logo shrinks.
 * Pinned rather than sticky because a sticky header that shrinks takes its
 * height out of the flow and the whole page jumps; the slot keeps the full
 * height instead, measured by main.js into --header-full-h.
 *
 * Never put transform, filter or backdrop-filter on .site-header itself:
 * any of them makes it the containing block of the off-canvas panel, which
 * is position: fixed below 1024px and would collapse into the header. The
 * blur is on ::before for that reason.
 * =================================================================== */

:root {
	--header-bg: rgba(255, 255, 255, 0.9);
}

.site-header::before {
	position: absolute;
	z-index: -1;
	inset: 0;
	background-color: var(--header-bg);
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
	content: "";
}

/* No box of its own until it has a height to hold, so sticky still works. */
.site-header-slot {
	display: contents;
}

/* WordPress pins the admin bar from 601px; below that it scrolls away. */
@media (min-width: 601px) {
	.admin-bar .site-header {
		top: var(--wp-admin--admin-bar--height, 0px);
	}
}

@media (min-width: 1024px) {
	.has-fixed-header .site-header-slot {
		display: block;
		min-height: var(--header-full-h);
	}

	/* Within the page width, like body. */
	.has-fixed-header .site-header {
		position: fixed;
		right: 0;
		left: 0;
		max-width: var(--page-max);
		margin-inline: auto;
		transition: box-shadow var(--transition-base);
	}

	.has-fixed-header .site-header__inner,
	.has-fixed-header .site-branding__logo,
	.has-fixed-header .custom-logo {
		transition:
			padding var(--transition-base),
			max-height var(--transition-base);
	}

	.site-header.is-compact {
		box-shadow: var(--shadow-sm);
	}

	.site-header.is-compact .site-header__inner {
		padding-block: var(--space-1);
	}

	.site-header.is-compact .site-branding__logo,
	.site-header.is-compact .custom-logo {
		max-height: 56px;
	}

	.site-header.is-compact .site-header__body {
		gap: 0;
	}

	.site-header.is-compact .utility-bar,
	.site-header.is-compact .site-header__chat {
		display: none;
	}
}

@media print {
	.site-header {
		position: static;
	}

	.site-header::before {
		content: none;
	}
}
