/* ==========================================================
   Michigan Roofing Pro — Layout CSS v1.0.1 (Bug Fix)
   Header | Navigation | Footer | Mobile
   ========================================================== */

/* ── Top Emergency Bar ───────────────────────────────────── */
.mr-top-bar {
	background: var(--mr-red);
	color: #fff;
	font-size: .8125rem;
	font-weight: 600;
	padding: .45rem 0;
}
.mr-top-bar__inner {
	max-width: var(--mr-max-w); margin: 0 auto; padding: 0 1.5rem;
	display: flex; justify-content: space-between; align-items: center;
	flex-wrap: wrap; gap: .5rem;
}
.mr-top-bar a { color: #fff; font-weight: 700; text-decoration: none; }
.mr-top-bar a:hover { text-decoration: underline; }
.mr-top-bar__license { color: rgba(255,255,255,.8); font-size: .78rem; }
.mr-top-bar__badge {
	background: #fff; color: var(--mr-red); padding: .2rem .625rem;
	border-radius: 999px; font-size: .73rem; font-weight: 800;
	letter-spacing: .04em; text-transform: uppercase;
	text-decoration: none !important;
}

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

.mr-header-inner {
	max-width: var(--mr-max-w); margin: 0 auto; padding: 0 1.5rem;
	display: flex; align-items: center; justify-content: space-between;
	gap: 1rem; min-height: 72px;
	/* CRITICAL: never wrap — keeps logo/nav/cta on one line */
	flex-wrap: nowrap;
}

/* Branding */
.site-branding { flex-shrink: 0; }
.site-branding img { max-height: 52px; width: auto; display: block; }
.mr-title-link { text-decoration: none; display: flex; align-items: center; gap: .5rem; }
.mr-site-title {
	font-size: 1.4rem; font-weight: 800; color: #fff;
	letter-spacing: -.02em; line-height: 1.1;
	white-space: nowrap;
}
.mr-site-title span { color: var(--mr-red); }

/* ── Primary Navigation ──────────────────────────────────── */
.main-navigation {
	flex: 1;
	min-width: 0;
	/* position relative so dropdown aligns to nav, not viewport */
	position: relative;
}

#primary-menu {
	list-style: none; margin: 0; padding: 0;
	display: flex; align-items: center;
	gap: 0; /* gap handled by padding on <a> */
	/* CRITICAL: no wrapping on desktop — all items stay on one row */
	flex-wrap: nowrap;
}

#primary-menu > li { position: relative; flex-shrink: 0; }

#primary-menu > li > a {
	display: block; padding: .5rem .8rem;
	color: rgba(255,255,255,.88); 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(255,255,255,.1); color: #fff;
}

/* ── Dropdown — FIXED: z-index above everything, no overflow clip ── */
#primary-menu .sub-menu {
	display: none;
	position: absolute;
	top: calc(100% + 8px);
	left: 0;
	/* Prevent clipping by parent overflow */
	z-index: 99999;
	background: var(--mr-black-soft, #1c1c1c);
	border: 1px solid rgba(255,255,255,.1);
	border-top: 3px solid var(--mr-red);
	border-radius: 0 0 6px 6px;
	box-shadow: 0 8px 32px rgba(0,0,0,.6);
	min-width: 240px;
	list-style: none;
	padding: .5rem 0;
}

/* Show on hover AND focus-within (keyboard navigation) */
#primary-menu li:hover > .sub-menu,
#primary-menu li:focus-within > .sub-menu { display: block; }

#primary-menu .sub-menu li { position: relative; }
#primary-menu .sub-menu li a {
	display: block; padding: .65rem 1.25rem;
	color: rgba(255,255,255,.82); 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: rgba(255,255,255,.08); color: #fff; }

/* ── Header Phone CTA ────────────────────────────────────── */
.mr-header-cta { flex-shrink: 0; }
.mr-header-cta a {
	display: inline-flex; align-items: center; gap: .4rem;
	background: var(--mr-red); color: #fff;
	padding: .625rem 1.25rem; border-radius: 4px;
	font-weight: 700; font-size: .875rem; text-decoration: none;
	transition: background .15s; white-space: nowrap;
	border: 2px solid var(--mr-red);
}
.mr-header-cta a:hover { background: var(--mr-red-dark, #962d22); border-color: var(--mr-red-dark, #962d22); text-decoration: none; }

/* ── Hamburger ───────────────────────────────────────────── */
.menu-toggle {
	display: none;
	background: none; border: 1.5px solid rgba(255,255,255,.3);
	border-radius: 4px; cursor: pointer;
	flex-direction: column; gap: 5px; align-items: center;
	justify-content: center; width: 42px; height: 42px; flex-shrink: 0;
	padding: 0;
}
.menu-toggle__bar {
	display: block; width: 20px; height: 2px;
	background: #fff; 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); }

/* ── Utility Buttons ─────────────────────────────────────── */
.mr-btn {
	display: inline-flex; align-items: center; justify-content: center;
	padding: .75rem 1.875rem; border-radius: 4px; font-weight: 700;
	font-size: 1rem; text-decoration: none; border: 2px solid transparent;
	transition: filter .15s, transform .1s; white-space: nowrap; cursor: pointer;
}
.mr-btn:hover { filter: brightness(.9); transform: translateY(-1px); text-decoration: none; }
.mr-btn--red    { background: var(--mr-red);   color: #fff; border-color: var(--mr-red); }
.mr-btn--black  { background: var(--mr-black); color: #fff; border-color: var(--mr-black); }
.mr-btn--outline{ background: transparent; color: #fff; border-color: rgba(255,255,255,.7); }

/* ── Footer ──────────────────────────────────────────────── */
.site-footer { background: var(--mr-black, #111); color: rgba(255,255,255,.82); }

.mr-footer-cta {
	background: var(--mr-red);
	padding: 4rem 1.5rem; text-align: center;
	border-bottom: 4px solid rgba(0,0,0,.2);
}
.mr-footer-cta__inner { max-width: var(--mr-max-w); margin: 0 auto; }
.mr-footer-cta h2 { color: #fff; font-size: clamp(1.5rem,3vw,2.25rem); margin-bottom: .75rem; }
.mr-footer-cta p  { color: rgba(255,255,255,.9); font-size: 1.1rem; margin-bottom: 2rem; }
.mr-footer-cta .mr-btn-row { display: flex; flex-wrap: wrap; gap: 1rem; justify-content: center; }

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

.mr-footer-bar {
	background: rgba(0,0,0,.45); padding: 1.125rem 1.5rem;
	border-top: 1px solid rgba(255,255,255,.07);
}
.mr-footer-bar__inner {
	max-width: var(--mr-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);
}
.mr-footer-bar a { color: rgba(255,255,255,.45); }
.mr-footer-bar a:hover { color: #fff; }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE NAV — BREAKPOINTS
   At 1080px: nav items get smaller font
   At 920px:  switch to hamburger
   ═══════════════════════════════════════════════════════════ */

/* Tighten nav slightly on mid-width screens before hamburger */
@media (max-width: 1080px) and (min-width: 921px) {
	#primary-menu > li > a { padding: .5rem .6rem; font-size: .82rem; }
	.mr-header-cta a { padding: .5rem 1rem; font-size: .82rem; }
	.mr-site-title { font-size: 1.2rem; }
}

/* ── Mobile hamburger menu ───────────────────────────────── */
@media (max-width: 920px) {

	/* Show hamburger, hide desktop phone CTA */
	.menu-toggle { display: flex; }
	.mr-header-cta { display: none; }

	/* Nav wrapper — reset position so dropdown is position:fixed */
	.main-navigation { flex: none; margin-left: auto; position: static; }

	/* Collapsed mobile panel — slides down below full header */
	#primary-menu {
		display: none;
		flex-direction: column;
		align-items: stretch;
		/* Fixed to viewport edge so it can't be clipped */
		position: fixed;
		top: 72px; /* matches min-height of .mr-header-inner */
		left: 0;
		right: 0;
		width: 100%;
		background: #1c1c1c;
		border-top: 3px solid var(--mr-red);
		border-bottom: 1px solid rgba(255,255,255,.08);
		box-shadow: 0 8px 24px rgba(0,0,0,.6);
		z-index: 99998;
		padding: .5rem 0;
		max-height: calc(100vh - 120px);
		overflow-y: auto;
		/* Re-allow wrapping in mobile column layout */
		flex-wrap: wrap;
	}
	/* Adjust for WP admin bar */
	.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 rgba(255,255,255,.07);
		color: rgba(255,255,255,.9);
		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: rgba(255,255,255,.06); color: #fff; }

	/* Arrow hint for parent items */
	#primary-menu li:has(.sub-menu) > a::after { content: '▾'; font-size: .75rem; color: rgba(255,255,255,.5); }
	#primary-menu li.is-open:has(.sub-menu) > a::after { content: '▴'; }

	/* Sub-menu — inline expansion on mobile */
	#primary-menu .sub-menu {
		display: none;
		position: static;
		box-shadow: none;
		border: none;
		border-top: 1px solid rgba(255,255,255,.07);
		border-radius: 0;
		padding: 0;
		background: rgba(0,0,0,.3);
		width: 100%;
		min-width: 0;
		z-index: auto;
	}
	#primary-menu li.is-open > .sub-menu { display: block; }

	/* Override desktop hover rule on mobile */
	#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(255,255,255,.05);
		font-size: .9rem;
		color: rgba(255,255,255,.75);
	}
	#primary-menu .sub-menu li:last-child a { border-bottom: none; }
	#primary-menu .sub-menu li a:hover { background: rgba(255,255,255,.05); color: #fff; }

	/* Smaller header on phones */
	.mr-header-inner { padding: 0 .875rem; min-height: 62px; }
	.mr-site-title { font-size: 1.2rem; }
	#primary-menu { top: 62px; }
	.admin-bar #primary-menu { top: 94px; }
}

/* Show compact phone CTA on mid-tablets */
@media (min-width: 541px) and (max-width: 920px) {
	.mr-header-cta { display: block; }
	.mr-header-cta a { padding: .5rem .875rem; font-size: .8rem; }
}

/* Small phones */
@media (max-width: 540px) {
	.mr-top-bar__inner { flex-direction: column; text-align: center; gap: .2rem; }
	.mr-top-bar__license { display: none; }
	.mr-footer-bar__inner { flex-direction: column; text-align: center; }
	.mr-footer-grid { grid-template-columns: 1fr 1fr; gap: 2rem; }
	.mr-header-inner { padding: 0 .75rem; min-height: 56px; }
	.mr-site-title { font-size: 1.05rem; }
	#primary-menu { top: 56px; }
	.admin-bar #primary-menu { top: 88px; }
}
@media (max-width: 380px) {
	.mr-footer-grid { grid-template-columns: 1fr; }
	.mr-site-title { font-size: .95rem; }
}
