/* ============================================================
   Home Improvement Pro v2 — layout.css
   Copied from Michigan Roofing Pro dev guide §19.
   Palette: Navy #1a2e4a, Orange #e8711a
   Bug 3 fixes applied:
     (a) flex-wrap:nowrap on desktop #primary-menu
     (b) z-index:99999 on dropdown
     (c) position:fixed on mobile panel
   ============================================================ */

/* ── Top Bar ────────────────────────────────────────────────*/
.hi-top-bar {
	background: var(--hi-navy);
	color: rgba(255,255,255,.85);
	font-size: .8125rem; font-weight: 500; padding: .45rem 0;
}
.hi-top-bar__inner {
	max-width: var(--hi-max-w); margin: 0 auto; padding: 0 1.5rem;
	display: flex; justify-content: space-between; align-items: center;
	flex-wrap: wrap; gap: .375rem;
}
.hi-top-bar a { color: rgba(255,255,255,.85); text-decoration: none; transition: color .12s; }
.hi-top-bar a:hover { color: #fff; }
.hi-top-bar__phone { font-weight: 700; color: #fff; }
.hi-top-bar__badge {
	background: var(--hi-orange); color: #fff;
	padding: .2rem .625rem; border-radius: 999px;
	font-size: .73rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
}

/* ── Site Header ────────────────────────────────────────────*/
.site-header {
	background: #fff;
	border-bottom: 3px solid var(--hi-orange);
	position: sticky; top: 0; z-index: 9000;
	box-shadow: 0 2px 12px rgba(0,0,0,.1);
}
.admin-bar .site-header { top: 32px; }
@media screen and (max-width: 782px) { .admin-bar .site-header { top: 46px; } }

.hi-header-inner {
	max-width: var(--hi-max-w); margin: 0 auto; padding: 0 1.5rem;
	display: flex; align-items: center; justify-content: space-between;
	gap: 1rem; min-height: 72px;
	flex-wrap: nowrap; /* CRITICAL — Bug 3a: never wrap */
}

/* ── Branding ───────────────────────────────────────────────*/
.site-branding { flex-shrink: 0; }
.site-branding img { max-height: 54px; width: auto; display: block; }
.hi-title-link { text-decoration: none !important; display: flex; align-items: center; }
.hi-site-title {
	font-size: 1.25rem; font-weight: 800; color: var(--hi-navy);
	letter-spacing: -.02em; line-height: 1.15; white-space: nowrap;
}

/* ── Primary Navigation ─────────────────────────────────────*/
.main-navigation { flex: 1; min-width: 0; }

#primary-menu {
	list-style: none; margin: 0; padding: 0;
	display: flex; align-items: center;
	flex-wrap: nowrap; /* CRITICAL — Bug 3a: all nav items stay on one row */
}
#primary-menu > li { position: relative; flex-shrink: 0; }
#primary-menu > li > a {
	display: block; padding: .5rem .8rem;
	color: var(--hi-navy); font-weight: 600; font-size: .875rem;
	text-decoration: none; border-radius: 4px;
	transition: background .12s, color .12s; white-space: nowrap;
}
#primary-menu > li > a:hover,
#primary-menu > .current-menu-item > a,
#primary-menu > .current-page-ancestor > a {
	background: rgba(26,46,74,.08); color: var(--hi-navy);
}

/* ── Dropdown ───────────────────────────────────────────────*/
#primary-menu .sub-menu {
	display: none; position: absolute;
	top: calc(100% + 8px); left: 0;
	z-index: 99999; /* CRITICAL — Bug 3b: above all content */
	background: #fff;
	border: 1px solid var(--hi-border);
	border-top: 3px solid var(--hi-orange);
	border-radius: 0 0 6px 6px;
	box-shadow: 0 8px 32px rgba(0,0,0,.18);
	min-width: 240px; list-style: none; padding: .5rem 0;
}
#primary-menu li:hover > .sub-menu,
#primary-menu li:focus-within > .sub-menu { display: block; }
#primary-menu .sub-menu li a {
	display: block; padding: .625rem 1.25rem;
	color: var(--hi-navy); font-size: .875rem; font-weight: 500;
	text-decoration: none; white-space: nowrap;
	transition: background .1s, color .1s;
}
#primary-menu .sub-menu li a:hover { background: var(--hi-grey-light); color: var(--hi-orange); }

/* ── Header CTA ─────────────────────────────────────────────*/
.hi-header-cta { flex-shrink: 0; }
.hi-header-cta a {
	display: inline-flex; align-items: center; gap: .375rem;
	background: var(--hi-orange); color: #fff;
	padding: .625rem 1.25rem; border-radius: var(--hi-radius);
	font-weight: 700; font-size: .875rem; text-decoration: none !important;
	transition: background .15s; white-space: nowrap;
}
.hi-header-cta a:hover { background: var(--hi-orange-dark); }

/* ── Hamburger ──────────────────────────────────────────────*/
.menu-toggle {
	display: none;
	background: none; border: 1.5px solid var(--hi-border);
	border-radius: var(--hi-radius); cursor: pointer;
	flex-direction: column; gap: 5px; align-items: center;
	justify-content: center; width: 44px; height: 44px; flex-shrink: 0; padding: 0;
}
.menu-toggle__bar {
	display: block; width: 22px; height: 2px;
	background: var(--hi-navy); border-radius: 2px;
	transition: transform .2s, opacity .2s, width .2s;
}
.menu-toggle.is-open .menu-toggle__bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-toggle.is-open .menu-toggle__bar:nth-child(2) { opacity: 0; width: 0; }
.menu-toggle.is-open .menu-toggle__bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* ── Button Utility Classes ─────────────────────────────────*/
.hi-btn {
	display: inline-flex; align-items: center; justify-content: center;
	padding: .75rem 2rem; border-radius: var(--hi-radius);
	font-weight: 700; font-size: 1rem; text-decoration: none !important;
	border: 2px solid transparent; transition: filter .15s, transform .1s; white-space: nowrap;
}
.hi-btn:hover { filter: brightness(.9); transform: translateY(-1px); }
.hi-btn--orange  { background: var(--hi-orange); color: #fff; border-color: var(--hi-orange); }
.hi-btn--navy    { background: var(--hi-navy);   color: #fff; border-color: var(--hi-navy); }
.hi-btn--outline { background: transparent; color: #fff; border-color: rgba(255,255,255,.7); }
.hi-btn-row { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: center; }

/* ── Footer ─────────────────────────────────────────────────*/
.site-footer { background: var(--hi-navy); color: rgba(255,255,255,.82); }

.hi-footer-cta { background: var(--hi-orange); padding: 3.5rem 1.5rem; text-align: center; }
.hi-footer-cta__inner { max-width: var(--hi-max-w); margin: 0 auto; }
.hi-footer-cta h2 { color: #fff; font-size: clamp(1.5rem,3vw,2.25rem); margin-bottom: .75rem; }
.hi-footer-cta p  { color: rgba(255,255,255,.92); font-size: 1.1rem; margin-bottom: 2rem; }

.hi-footer-body { padding: 3.5rem 1.5rem; }
.hi-footer-grid {
	max-width: var(--hi-max-w); margin: 0 auto;
	display: grid; grid-template-columns: repeat(auto-fit,minmax(190px,1fr)); gap: 2.5rem;
}
.hi-footer-col h3 {
	color: #fff; font-size: .9375rem; margin-bottom: 1.125rem;
	padding-bottom: .625rem; border-bottom: 2px solid var(--hi-orange); display: inline-block;
}
.hi-footer-col p  { color: rgba(255,255,255,.65); font-size: .875rem; margin-bottom: .5rem; }
.hi-footer-col ul { list-style: none; padding: 0; margin: 0; }
.hi-footer-col ul li { margin-bottom: .4rem; }
.hi-footer-col a  { color: rgba(255,255,255,.65); font-size: .875rem; text-decoration: none; transition: color .12s; }
.hi-footer-col a:hover { color: #fff; text-decoration: underline; }
.hi-footer-brand { font-size: 1.25rem; font-weight: 800; color: #fff; display: block; margin-bottom: .875rem; }
.hi-footer-tagline { color: rgba(255,255,255,.45) !important; font-style: italic; font-size: .82rem !important; }
.hi-footer-col #footer-menu, .hi-footer-col ul.menu { list-style: none; padding: 0; margin: 0; }

.hi-footer-bar { background: rgba(0,0,0,.4); padding: 1.125rem 1.5rem; border-top: 1px solid rgba(255,255,255,.07); }
.hi-footer-bar__inner {
	max-width: var(--hi-max-w); margin: 0 auto;
	display: flex; justify-content: space-between; align-items: center;
	flex-wrap: wrap; gap: .5rem; font-size: .8rem; color: rgba(255,255,255,.4);
}
.hi-footer-bar a { color: rgba(255,255,255,.45); }
.hi-footer-bar a:hover { color: #fff; }

/* ── Responsive ─────────────────────────────────────────────*/
/* 1080px: tighten nav before hamburger */
@media (max-width: 1080px) and (min-width: 921px) {
	#primary-menu > li > a { padding: .5rem .6rem; font-size: .82rem; }
	.hi-header-cta a { padding: .5rem 1rem; font-size: .82rem; }
	.hi-site-title { font-size: 1.1rem; }
}

/* 920px: hamburger */
@media (max-width: 920px) {
	.menu-toggle { display: flex; }
	.hi-header-cta { display: none; }
	.main-navigation { flex: none; margin-left: auto; position: static; }

	/* CRITICAL — Bug 3c: position:fixed attaches to viewport, never clipped by parent */
	#primary-menu {
		display: none; flex-direction: column; align-items: stretch;
		position: fixed; /* Bug 3c fix */
		top: 72px; left: 0; right: 0; width: 100%;
		background: #fff;
		border-top: 3px solid var(--hi-orange);
		border-bottom: 1px solid var(--hi-border);
		box-shadow: 0 8px 24px rgba(0,0,0,.15);
		z-index: 99998;
		padding: .5rem 0;
		max-height: calc(100vh - 120px); overflow-y: auto;
		flex-wrap: wrap;
	}
	.admin-bar #primary-menu { top: 104px; }
	@media screen and (max-width: 782px) { .admin-bar #primary-menu { top: 118px; } }

	#primary-menu.is-open { display: flex; }
	#primary-menu > li { width: 100%; }
	#primary-menu > li > a {
		padding: .875rem 1.375rem; border-radius: 0; font-size: .9375rem;
		border-bottom: 1px solid var(--hi-border); color: var(--hi-navy);
		display: flex; justify-content: space-between; align-items: center;
	}
	#primary-menu > li:last-child > a { border-bottom: none; }
	#primary-menu > li > a:hover,
	#primary-menu > .current-menu-item > a { background: var(--hi-grey-light); color: var(--hi-navy); }
	#primary-menu li:has(.sub-menu) > a::after { content: '\25BE'; font-size: .75rem; color: var(--hi-grey-text); }
	#primary-menu li.is-open:has(.sub-menu) > a::after { content: '\25B4'; }

	#primary-menu .sub-menu {
		display: none; position: static;
		box-shadow: none; border: none; border-radius: 0;
		border-top: 1px solid var(--hi-border);
		padding: 0; background: var(--hi-grey-light);
		width: 100%; min-width: 0; z-index: auto;
	}
	#primary-menu li.is-open > .sub-menu { display: block; }
	#primary-menu li:hover > .sub-menu { display: none; }
	#primary-menu li.is-open > .sub-menu { display: block; }
	#primary-menu .sub-menu li a {
		padding: .75rem 1.375rem .75rem 2.25rem;
		border-bottom: 1px solid rgba(26,46,74,.08);
		font-size: .9rem; color: var(--hi-navy);
	}
	#primary-menu .sub-menu li:last-child a { border-bottom: none; }
	#primary-menu .sub-menu li a:hover { background: var(--hi-grey-mid); color: var(--hi-orange); }

	.hi-header-inner { padding: 0 .875rem; min-height: 62px; }
	.hi-site-title { font-size: 1.1rem; }
	#primary-menu { top: 62px; }
	.admin-bar #primary-menu { top: 94px; }
}

@media (min-width: 541px) and (max-width: 920px) {
	.hi-header-cta { display: block; }
	.hi-header-cta a { padding: .5rem .875rem; font-size: .8rem; }
}
@media (max-width: 540px) {
	.hi-top-bar__inner { flex-direction: column; text-align: center; gap: .2rem; }
	.hi-footer-bar__inner { flex-direction: column; text-align: center; }
	.hi-footer-grid { grid-template-columns: 1fr 1fr; gap: 2rem; }
	.hi-header-inner { padding: 0 .75rem; min-height: 56px; }
	.hi-site-title { font-size: 1rem; }
	#primary-menu { top: 56px; }
	.admin-bar #primary-menu { top: 88px; }
}
@media (max-width: 380px) {
	.hi-footer-grid { grid-template-columns: 1fr; }
	.hi-site-title { font-size: .95rem; }
}
