/*
 * JustGetDeal Core — header styles.
 * Values come from CSS custom properties printed by Assets::inline_css_vars(),
 * which read the admin settings, so this file rarely needs hand-editing.
 */

.jgd-header,
.jgd-header * {
	box-sizing: border-box;
}

.jgd-header {
	/* Always a positioning context — the dropdown panel is an
	   absolutely-positioned sibling and needs this regardless of
	   whether sticky is enabled. */
	position: relative;
	z-index: 999;
	background: var(--jgd-bg);
	border-bottom: var(--jgd-border-width) solid var(--jgd-border);
	height: var(--jgd-header-height);
	display: flex;
	align-items: center;
	transition: height 0.25s ease, box-shadow 0.25s ease;
}

.jgd-header--sticky {
	position: sticky;
	top: 0;
}

.jgd-header.is-scrolled {
	height: var(--jgd-header-sticky-height);
	box-shadow: var(--jgd-shadow);
}

.jgd-header__container {
	width: 100%;
	max-width: var(--jgd-container-width);
	margin: 0 auto;
	padding: 0 24px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 24px;
	height: 100%;
}

/* Logo — scales to fit the header's own *rendered* height, including
   the tighter mobile height set below, then respects the admin's
   max-width setting. Using percentages tied to the actual box height
   (rather than the raw --jgd-header-height variable, which doesn't
   change at mobile breakpoints) is what keeps this correctly sized
   everywhere instead of just on desktop. */
.jgd-header__logo {
	height: 100%;
	max-height: 100%;
	display: flex;
	align-items: center;
	flex-shrink: 0;
	overflow: hidden;
}

.jgd-header__logo img,
.jgd-header__logo svg,
.jgd-header__logo > a {
	max-width: var(--jgd-logo-width);
	/* 58% of the header's own height (not the full height) so the logo
	   sits smaller within the bar instead of touching edge to edge —
	   this scales correctly at every breakpoint since it's relative to
	   whatever height .jgd-header__logo actually has. */
	max-height: 100%;
	width: auto;
	height: 100%;
	object-fit: contain;
	display: block;
}

.jgd-site-title {
	font-weight: 700;
	font-size: 1.25rem;
	color: var(--jgd-text);
	text-decoration: none;
}

/* Primary nav */
.jgd-header__nav {
	flex: 1;
	display: flex;
	justify-content: center;
}

.jgd-menu {
	list-style: none;
	display: flex;
	align-items: center;
	gap: 32px;
	margin: 0;
	padding: 0;
}

.jgd-menu li {
	position: relative;
}

.jgd-menu a {
	color: var(--jgd-text);
	text-decoration: none;
	font-weight: 500;
	font-size: 0.95rem;
	padding: 6px 0;
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 6px;
}

.jgd-menu a::after {
	content: "";
	position: absolute;
	left: 0;
	right: 100%;
	bottom: -2px;
	height: 2px;
	background: var(--jgd-primary);
	transition: right 0.2s ease;
}

.jgd-menu a:hover::after,
.jgd-menu li.current-menu-item a::after {
	right: 0;
}

.jgd-menu li[aria-current="page"] a,
.jgd-menu li.current-menu-item a {
	color: var(--jgd-primary);
}

/* Dropdown trigger chevron — injected as a real <svg> by header.js
   (see attachChevrons()) rather than a CSS border-trick, so it renders
   identically and predictably on every device, including mobile. */
.jgd-chevron {
	display: inline-flex;
	transition: transform 0.2s ease;
	flex-shrink: 0;
}

.jgd-menu li.menu-item-has-children.is-open > a .jgd-chevron {
	transform: rotate(180deg);
}

/* Native WordPress submenu (real child items added under "Find Deals"
   in Appearance → Menus) — this is what actually needed styling.
   WordPress nests these as <ul class="sub-menu"> inside the parent
   <li>, and browsers render that with default bullets/positioning
   unless a theme or plugin styles it, which is exactly what was
   happening before. */
.jgd-menu li.menu-item-has-children {
	position: relative;
}

.jgd-menu .sub-menu {
	position: absolute;
	top: calc(100% + 10px);
	left: 0;
	background: var(--jgd-bg);
	border-radius: 14px;
	box-shadow: 0 20px 45px rgba(17, 24, 39, 0.14);
	min-width: 240px;
	margin: 0;
	padding: 10px 8px;
	list-style: none !important;
	list-style-type: none !important;
	opacity: 0;
	visibility: hidden;
	transform: translateY(-8px);
	transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
	z-index: 998;
}

.jgd-menu li.menu-item-has-children:hover > .sub-menu,
.jgd-menu li.menu-item-has-children.is-open > .sub-menu {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

.jgd-menu .sub-menu li {
	list-style: none !important;
	margin: 0;
}

.jgd-menu .sub-menu li::marker {
	content: "";
}

.jgd-menu .sub-menu a {
	display: block;
	padding: 12px 16px;
	border-radius: 10px;
	color: var(--jgd-text);
	text-decoration: none;
	font-size: 0.95rem;
	font-weight: 500;
	white-space: nowrap;
}

.jgd-menu .sub-menu a::after {
	display: none;
}

.jgd-menu .sub-menu a:hover {
	background: rgba(26, 169, 177, 0.08);
	color: var(--jgd-primary);
}

/* Actions / CTA */
.jgd-header__actions {
	display: flex;
	align-items: center;
	gap: 16px;
	flex-shrink: 0;
}

.jgd-search-trigger,
.jgd-mobile-toggle {
	background: transparent;
	border: none;
	cursor: pointer;
	color: var(--jgd-text);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 6px;
	border-radius: 8px;
	flex-shrink: 0;
}

.jgd-search-trigger:hover,
.jgd-mobile-toggle:hover {
	background: rgba(17, 24, 39, 0.05);
}

.jgd-mobile-toggle {
	display: none;
}

.jgd-cta-button {
	background: var(--jgd-btn-color);
	color: #fff;
	text-decoration: none;
	font-weight: 600;
	font-size: 0.9rem;
	padding: var(--jgd-btn-padding);
	border-radius: var(--jgd-btn-radius);
	display: inline-block;
	white-space: nowrap;
	transition: background 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
	box-shadow: 0 2px 8px rgba(26, 169, 177, 0.25);
}

.jgd-cta-button:hover {
	background: var(--jgd-btn-hover);
	color: #fff;
	transform: translateY(-2px);
	box-shadow: 0 6px 16px rgba(26, 169, 177, 0.35);
}

.jgd-cta-button--block {
	display: block;
	text-align: center;
}

/* Mobile off-canvas menu */
.jgd-mobile-menu {
	position: fixed;
	inset: 0;
	z-index: 1001;
	visibility: hidden;
	pointer-events: none;
}

.jgd-mobile-menu.is-open {
	visibility: visible;
	pointer-events: auto;
}

.jgd-mobile-menu::before {
	content: "";
	position: absolute;
	inset: 0;
	background: rgba(17, 24, 39, 0.4);
	opacity: 0;
	transition: opacity 0.25s ease;
}

.jgd-mobile-menu.is-open::before {
	opacity: 1;
}

.jgd-mobile-menu__panel {
	position: absolute;
	top: 0;
	left: 0;
	bottom: 0;
	width: 300px;
	max-width: 85vw;
	background: var(--jgd-bg);
	padding: 24px;
	transform: translateX(-100%);
	transition: transform 0.3s ease;
	display: flex;
	flex-direction: column;
	overflow-y: auto;
}

.jgd-mobile-menu.is-open .jgd-mobile-menu__panel {
	transform: translateX(0);
}

.jgd-mobile-menu__close {
	align-self: flex-end;
	background: transparent;
	border: none;
	cursor: pointer;
	color: var(--jgd-text);
	margin-bottom: 16px;
}

.jgd-mobile-menu__nav .jgd-menu {
	flex-direction: column;
	align-items: flex-start;
	gap: 4px;
	width: 100%;
}

.jgd-mobile-menu__nav .jgd-menu a {
	display: flex;
	width: 100%;
	padding: 12px 0;
	border-bottom: 1px solid var(--jgd-border);
	justify-content: space-between;
}

.jgd-mobile-menu__nav .jgd-menu a::after {
	display: none;
}

.jgd-mobile-menu__cta {
	margin-top: auto;
	padding-top: 16px;
}

/* Mobile: the real .sub-menu already sits in the DOM right where
   WordPress put it (nested inside the parent <li>) — no cloning
   needed. It's just collapsed by default and expands in place as an
   accordion when the parent item is tapped. */
.jgd-mobile-menu__nav .jgd-menu .sub-menu {
	position: static;
	visibility: visible;
	opacity: 1;
	transform: none;
	box-shadow: none;
	background: transparent;
	border-radius: 0;
	padding: 0 0 0 16px;
	max-height: 0;
	overflow: hidden;
	transition: max-height 0.25s ease;
}

.jgd-mobile-menu__nav .jgd-menu li.menu-item-has-children.is-open > .sub-menu {
	max-height: 600px;
}

.jgd-mobile-menu__nav .jgd-menu .sub-menu a {
	padding: 10px 0;
	border-bottom: none;
	font-size: 0.9rem;
}

/* Fullscreen search popup */
.jgd-search-popup {
	position: fixed;
	inset: 0;
	z-index: 1002;
	background: rgba(255, 255, 255, 0.98);
	visibility: hidden;
	opacity: 0;
	transform: scale(0.98);
	transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
	overflow-y: auto;
}

.jgd-search-popup.is-open {
	visibility: visible;
	opacity: 1;
	transform: scale(1);
}

.jgd-search-popup__close {
	position: absolute;
	top: 24px;
	right: 24px;
	background: transparent;
	border: none;
	cursor: pointer;
	color: var(--jgd-text);
}

.jgd-search-popup__inner {
	max-width: 640px;
	margin: 0 auto;
	padding: 100px 24px 60px;
}

.jgd-search-popup__field-wrap {
	display: flex;
	align-items: center;
	gap: 12px;
	border-bottom: 2px solid var(--jgd-border);
	padding-bottom: 16px;
	color: #9ca3af;
}

.jgd-search-popup__input {
	flex: 1;
	border: none;
	outline: none;
	font-size: 1.25rem;
	color: var(--jgd-text);
	background: transparent;
}

.jgd-search-popup__group {
	margin-top: 28px;
}

.jgd-search-popup__group h3 {
	font-size: 0.85rem;
	color: #6b7280;
	margin: 0 0 12px;
}

.jgd-search-popup__group ul {
	list-style: none;
	margin: 0;
	padding: 0;
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

.jgd-search-popup__group a {
	display: inline-block;
	padding: 8px 14px;
	border: 1px solid var(--jgd-border);
	border-radius: 999px;
	color: var(--jgd-text);
	text-decoration: none;
	font-size: 0.875rem;
}

.jgd-search-popup__group a:hover {
	border-color: var(--jgd-primary);
	color: var(--jgd-primary);
}

.jgd-search-popup__results {
	margin-top: 20px;
}

.jgd-search-popup__results .jgd-results-group h3 {
	font-size: 0.8rem;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	color: #9ca3af;
	margin: 20px 0 8px;
}

.jgd-search-popup__results ul {
	list-style: none;
	margin: 0;
	padding: 0;
}

.jgd-search-popup__results li a {
	display: block;
	padding: 10px 12px;
	border-radius: 8px;
	color: var(--jgd-text);
	text-decoration: none;
	font-size: 0.95rem;
}

.jgd-search-popup__results li a:hover,
.jgd-search-popup__results li a.is-active {
	background: rgba(26, 169, 177, 0.08);
	color: var(--jgd-primary);
}

.jgd-search-popup__view-all {
	display: block;
	margin-top: 16px;
	text-align: center;
	color: var(--jgd-primary);
	font-weight: 600;
	text-decoration: none;
}

.jgd-search-popup__no-results {
	color: #9ca3af;
	padding: 20px 12px;
	text-align: center;
}

.jgd-search-popup__hint {
	margin-top: 32px;
	text-align: center;
	color: #9ca3af;
	font-size: 0.8rem;
}

/* Focus visibility for accessibility */
.jgd-header a:focus-visible,
.jgd-header button:focus-visible,
.jgd-search-popup__input:focus-visible {
	outline: 2px solid var(--jgd-primary);
	outline-offset: 2px;
}

/* Responsive */
@media (max-width: 900px) {
	.jgd-header__nav {
		display: none;
	}

	.jgd-mobile-toggle {
		display: flex;
	}

	/* Tighter header on mobile. Because sizing above is now based on
	   the box's own rendered height (100%) rather than the raw
	   --jgd-header-height variable, changing height here is now
	   enough on its own to correctly resize the logo too. */
	.jgd-header {
		height: 64px;
	}

	.jgd-header.is-scrolled {
		height: 56px;
	}

	.jgd-header__container {
		padding: 0 16px;
		gap: 10px;
	}

	.jgd-header__actions {
		gap: 8px;
	}

	.jgd-header__logo img,
	.jgd-header__logo svg,
	.jgd-header__logo > a {
		max-width: 130px;
	}

	/* Compact the CTA so it never wraps next to the search + hamburger
	   icons — this was the cause of the "Browse / Deals" two-line
	   wrapping seen on phones. */
	.jgd-header__actions > .jgd-cta-button {
		font-size: 0.8rem;
		padding: 9px 14px;
	}
}

@media (max-width: 380px) {
	.jgd-header__logo img,
	.jgd-header__logo svg,
	.jgd-header__logo > a {
		max-width: 100px;
	}

	.jgd-header__actions > .jgd-cta-button {
		padding: 8px 10px;
		font-size: 0.75rem;
	}
}

/* Mobile off-canvas menu: larger tap targets, safe-area aware */
@media (max-width: 900px) {
	.jgd-mobile-menu__panel {
		width: min(320px, 88vw);
		padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0px));
	}

	.jgd-mobile-menu__nav .jgd-menu a {
		font-size: 1.05rem;
		padding: 14px 4px;
	}

	.jgd-mobile-toggle,
	.jgd-search-trigger {
		padding: 10px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.jgd-header,
	.jgd-menu .sub-menu,
	.jgd-mobile-menu__panel,
	.jgd-search-popup,
	.jgd-cta-button,
	.jgd-menu a::after,
	.jgd-chevron {
		transition: none !important;
	}
}
