/* ==========================================================================
   My Spectacles – header (promo bar, logo, search, links, mega menu)
   Markup: inc/header.php   Behaviour: assets/js/header.js
   ========================================================================== */

/* The old Elementor / Astra headers are never shown when this one is on. */
body.ms-has-header .elementor-location-header,
body.ms-has-header header#masthead,
body.ms-has-header #ast-desktop-header,
body.ms-has-header #ast-mobile-header { display: none !important; }

/* "overflow-x: hidden" on html/body would break position: sticky; clip does not. */
html:has(body.ms-has-header),
body.ms-has-header { overflow-x: clip !important; }

.ms-header {
	--hd-navy: #333974;
	--hd-purple: #575d9b;
	--hd-purple-dark: #454a85;
	--hd-ink: #1d1f2b;
	--hd-text: #3a3a3a;
	--hd-line: #e2e4ea;
	--hd-soft: #f3f4fa;
	--hd-sale: #c8102e;
	--hd-font: "Poppins", "Helvetica Neue", Arial, sans-serif;

	position: sticky;
	top: 0;
	z-index: 9990;
	background: #fff;
	font-family: var(--hd-font);
	font-size: 14px;
	line-height: 1.4;
	color: var(--hd-ink);
	transition: box-shadow .25s;
}
body.admin-bar .ms-header { top: 32px; }
@media (max-width: 782px) { body.admin-bar .ms-header { top: 46px; } }
@media (max-width: 600px) { body.admin-bar .ms-header { top: 0; } }
.ms-header.is-scrolled { box-shadow: 0 6px 22px rgba(29, 31, 43, .10); }

.ms-header *,
.ms-header *::before,
.ms-header *::after { box-sizing: border-box; }
:where(.ms-header) ul { list-style: none; margin: 0; padding: 0; }
:where(.ms-header) a { text-decoration: none; color: inherit; }
:where(.ms-header) button { font-family: inherit; cursor: pointer; }
.ms-header :focus-visible { outline: 2px solid var(--hd-purple); outline-offset: 2px; border-radius: 4px; }
.ms-hd-ico { display: block; flex: none; }

/* ---------- 1. Promo bar ---------- */
.ms-hd__promo { background: #000; color: #ffc928; overflow: hidden; max-height: 60px; transition: max-height .25s, padding .25s; }
.ms-hd__promo-text { margin: 0; padding: 9px 16px; text-align: center; font-weight: 600; font-size: 14px; }
.ms-hd__promo-text a { color: #fff; font-weight: 700; margin-left: 8px; white-space: nowrap; }
.ms-hd__promo-text a:hover { text-decoration: underline; text-underline-offset: 3px; }
.ms-header.is-scrolled .ms-hd__promo { max-height: 0; }

/* ---------- 2. Main row ---------- */
.ms-hd__row {
	display: flex;
	align-items: center;
	gap: 28px;
	max-width: 1320px;
	margin: 0 auto;
	padding: 12px 20px;
	min-height: 84px;
}
.ms-hd__burger { display: none; }

.ms-hd__logo { flex: none; display: block; width: 150px; }
.ms-hd__logo-img { display: block; width: 100%; height: auto; max-height: 64px; object-fit: contain; }
.ms-hd__logo-text { font-weight: 700; font-size: 1.25rem; color: var(--hd-navy); }

/* Search = [aws_search_form] */
.ms-hd__search { flex: 1 1 auto; min-width: 0; max-width: 580px; margin-inline: auto; }
.ms-hd__search .aws-container { width: 100%; margin: 0; }
.ms-hd__search .aws-search-form { position: relative; display: flex !important; align-items: stretch; width: 100%; height: 46px; margin: 0; background: var(--hd-soft); border: 1.5px solid transparent; border-radius: 999px; overflow: hidden; transition: border-color .2s, background-color .2s, box-shadow .2s; }
.ms-hd__search .aws-search-form:focus-within { background: #fff; border-color: var(--hd-purple); box-shadow: 0 0 0 3px rgba(87, 93, 155, .15); }
.ms-hd__search .aws-wrapper { flex: 1 1 auto; position: relative; display: block; min-width: 0; }
.ms-hd__search .aws-search-label { display: none; }
.ms-hd__search .aws-search-field { width: 100% !important; height: 46px !important; margin: 0 !important; padding: 0 44px 0 20px !important; background: transparent !important; border: 0 !important; border-radius: 0 !important; box-shadow: none !important; font-family: var(--hd-font) !important; font-size: 14px !important; color: var(--hd-ink) !important; outline: 0 !important; }
.ms-hd__search .aws-search-field::placeholder { color: #7a7f8e; opacity: 1; }
.ms-hd__search .aws-search-clear { right: 10px !important; }
.ms-hd__search .aws-search-btn { flex: none; display: flex !important; align-items: center; justify-content: center; width: 54px; height: 100% !important; margin: 0 !important; padding: 0 !important; background: var(--hd-purple) !important; border: 0 !important; border-radius: 0 !important; color: #fff; cursor: pointer; transition: background-color .2s; }
.ms-hd__search .aws-search-btn:hover { background: var(--hd-purple-dark) !important; }
.ms-hd__search .aws-search-btn svg { width: 22px !important; height: 22px !important; fill: #fff !important; }
.ms-hd__search .aws-search-btn_icon { display: flex; }

/* Right-hand block */
.ms-hd__util { flex: none; display: flex; align-items: center; gap: 6px; margin-left: auto; }
.ms-hd__country { display: flex; align-items: center; margin-right: 4px; }
.ms-hd__links { display: flex; align-items: center; gap: 4px; margin-right: 6px; }
.ms-hd__links a { display: block; padding: 8px 9px; font-weight: 500; font-size: 13.5px; color: var(--hd-ink); border-radius: 6px; transition: color .2s, background-color .2s; }
.ms-hd__links a:hover { color: var(--hd-purple); background: var(--hd-soft); }

.ms-hd__icon { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; color: var(--hd-ink); border-radius: 50%; transition: color .2s, background-color .2s; }
.ms-hd__icon:hover { color: var(--hd-purple); background: var(--hd-soft); }
.ms-hd__account { display: none; }
.ms-hd__count { position: absolute; top: 1px; right: 0; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 999px; background: var(--hd-sale); color: #fff; font-size: 11px; font-weight: 700; line-height: 19px; text-align: center; }
.ms-hd__count.is-empty { display: none; }

/* ---------- 3. Menu row ---------- */
.ms-hd__navbar { position: relative; border-top: 1px solid var(--hd-line); background: #fff; }
.ms-nav__head,
.ms-nav__extra { display: none; }
.ms-nav { max-width: 1320px; margin: 0 auto; padding-inline: 20px; }
.ms-nav__list { display: flex; flex-wrap: wrap; align-items: stretch; justify-content: center; gap: 2px; }

.ms-nav__item { position: static; display: flex; align-items: center; }
.ms-nav__link { position: relative; display: block; padding: 15px 4px 15px 14px; font-weight: 600; font-size: 14.5px; color: var(--hd-navy); transition: color .2s; }
.ms-nav__item:not(.has-mega) > .ms-nav__link { padding-right: 14px; }
.ms-nav__link::after { content: ""; position: absolute; left: 14px; right: 6px; bottom: 7px; height: 2px; background: var(--hd-purple); transform: scaleX(0); transform-origin: left; transition: transform .25s; }
.ms-nav__item:not(.has-mega) > .ms-nav__link::after { right: 14px; }
.ms-nav__item:hover > .ms-nav__link,
.ms-nav__item.is-open > .ms-nav__link,
.ms-nav__item.is-current > .ms-nav__link { color: var(--hd-purple); }
.ms-nav__item:hover > .ms-nav__link::after,
.ms-nav__item.is-open > .ms-nav__link::after,
.ms-nav__item.is-current > .ms-nav__link::after { transform: scaleX(1); }
.ms-nav__item.ms-nav-sale > .ms-nav__link { color: var(--hd-sale); }
.ms-nav__item.ms-nav-sale > .ms-nav__link::after { background: var(--hd-sale); }

.ms-nav__toggle { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 28px; margin: 0 6px 0 0; padding: 0; background: transparent; border: 0; color: var(--hd-navy); }
.ms-nav__toggle .ms-hd-ico { width: 15px; height: 15px; transition: transform .2s; }
.ms-nav__item.is-open > .ms-nav__toggle .ms-hd-ico { transform: rotate(180deg); }
.ms-nav__item.ms-nav-sale > .ms-nav__toggle { color: var(--hd-sale); }

/* Mega panel (full width, under the menu row) */
.ms-mega {
	position: absolute;
	left: 0;
	right: 0;
	top: 100%;
	z-index: 20;
	background: #fff;
	border-top: 1px solid var(--hd-line);
	box-shadow: 0 22px 36px rgba(29, 31, 43, .13);
	visibility: hidden;
	opacity: 0;
	transform: translateY(8px);
	pointer-events: none;
	transition: opacity .18s ease, transform .18s ease, visibility 0s linear .18s;
}
.ms-mega__inner { max-width: 1320px; margin: 0 auto; padding: 28px 20px 22px; max-height: calc(100vh - 190px); overflow-y: auto; }
.ms-nav__item.is-open > .ms-mega {
	visibility: visible;
	opacity: 1;
	transform: none;
	pointer-events: auto;
	transition-delay: 0s;
}
/* Works without JavaScript too (mouse + keyboard focus) */
@media (hover: hover) and (min-width: 1025px) {
	.ms-nav__item:hover > .ms-mega,
	.ms-nav__item:focus-within > .ms-mega { visibility: visible; opacity: 1; transform: none; pointer-events: auto; transition-delay: 0s; }
}

.ms-mega__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 26px 32px; align-items: start; }
.ms-mega--flat .ms-mega__grid { display: block; column-width: 200px; column-gap: 32px; columns: 5 200px; }
.ms-mega--flat .ms-mega__col { break-inside: avoid; }

.ms-mega__title { display: block; margin: 0 0 8px; padding-bottom: 9px; border-bottom: 2px solid var(--hd-line); font-weight: 700; font-size: 13px; letter-spacing: .05em; text-transform: uppercase; color: var(--hd-navy); transition: color .2s, border-color .2s; }
.ms-mega__title:hover { color: var(--hd-purple); border-color: var(--hd-purple); }
.ms-mega__desc { display: block; margin: -4px 0 8px; font-size: 12.5px; color: #6b7080; }
.ms-mega__list { margin: 0; }
.ms-mega__link { display: block; padding: 6px 0; font-size: 14px; font-weight: 500; color: var(--hd-text); transition: color .15s, transform .15s; }
.ms-mega__link:hover { color: var(--hd-purple); transform: translateX(3px); }
.ms-mega__col.is-current > .ms-mega__link,
.ms-mega__item.is-current > .ms-mega__link { color: var(--hd-purple); font-weight: 600; }

.ms-mega__all { display: inline-flex; align-items: center; gap: 8px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--hd-line); width: 100%; font-weight: 600; font-size: 14px; color: var(--hd-purple); }
.ms-mega__all .ms-hd-ico { width: 18px; height: 18px; transition: transform .2s; }
.ms-mega__all:hover { color: var(--hd-purple-dark); }
.ms-mega__all:hover .ms-hd-ico { transform: translateX(4px); }

.ms-hd__overlay { display: none; }

/* AWS live-search results must sit above the sticky header */
.aws-search-result { z-index: 99999 !important; }

/* ==========================================================================
   Tablet + phone (drawer menu)
   ========================================================================== */
@media (max-width: 1024px) {
	.ms-hd__row { gap: 12px; min-height: 68px; padding-block: 10px; }
	.ms-hd__burger { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 44px; height: 44px; margin-left: -8px; background: transparent; border: 0; border-radius: 50%; color: var(--hd-ink); }
	.ms-hd__burger:hover { background: var(--hd-soft); }
	.ms-hd__logo { width: 118px; }
	.ms-hd__logo-img { max-height: 52px; }
	.ms-hd__search { max-width: none; }
	.ms-hd__links { display: none; }
	.ms-hd__account { display: inline-flex; }
	.ms-hd__country { margin-right: 0; }

	.ms-hd__navbar { border-top: 0; }
	.ms-nav {
		position: fixed;
		top: 0;
		bottom: 0;
		left: 0;
		z-index: 10001;
		width: min(88vw, 400px);
		max-width: none;
		margin: 0;
		padding: 0 0 24px;
		background: #fff;
		overflow-y: auto;
		overscroll-behavior: contain;
		transform: translateX(-102%);
		visibility: hidden;
		transition: transform .28s ease, visibility 0s linear .28s;
		box-shadow: 8px 0 30px rgba(0, 0, 0, .18);
	}
	body.admin-bar .ms-nav { top: 32px; }
	@media (max-width: 782px) { body.admin-bar .ms-nav { top: 46px; } }
	@media (max-width: 600px) { body.admin-bar .ms-nav { top: 0; } }
	.ms-header.is-nav-open .ms-nav { transform: none; visibility: visible; transition-delay: 0s; }
	.ms-hd__overlay { position: fixed; inset: 0; z-index: 10000; background: rgba(20, 22, 40, .5); display: block; }
	.ms-hd__overlay[hidden] { display: none; }
	html.ms-nav-lock { overflow: hidden; }

	.ms-nav__head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 10px 14px 10px 20px; background: #fff; border-bottom: 1px solid var(--hd-line); }
	.ms-nav__title { font-weight: 700; font-size: 16px; color: var(--hd-navy); }
	.ms-nav__close { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; background: var(--hd-soft); border: 0; border-radius: 50%; color: var(--hd-ink); }

	.ms-nav__list { display: block; padding: 6px 0; }
	.ms-nav__item { flex-wrap: wrap; border-bottom: 1px solid var(--hd-line); }
	.ms-nav__link { flex: 1 1 0; min-width: 0; padding: 15px 8px 15px 20px; font-size: 15.5px; }
	.ms-nav__item:not(.has-mega) > .ms-nav__link { padding-right: 20px; }
	.ms-nav__link::after { display: none; }
	.ms-nav__toggle { flex: none; width: 52px; height: 52px; margin: 0; border-left: 1px solid var(--hd-line); }
	.ms-nav__toggle .ms-hd-ico { width: 20px; height: 20px; }

	/* mega panel becomes an accordion */
	.ms-mega { position: static; flex: 0 0 100%; display: none; visibility: visible; opacity: 1; transform: none; pointer-events: auto; border: 0; box-shadow: none; background: var(--hd-soft); transition: none; }
	.ms-nav__item.is-open > .ms-mega { display: block; }
	.ms-mega__inner { padding: 8px 20px 14px; max-height: none; overflow: visible; }
	.ms-mega__grid { display: block; columns: auto; }
	.ms-mega--flat .ms-mega__grid { display: block; columns: 2 130px; column-gap: 18px; }
	.ms-mega__col { margin: 0 0 6px; }
	.ms-mega__title { margin: 8px 0 2px; padding-bottom: 6px; font-size: 12.5px; }
	.ms-mega__link { padding: 9px 0; font-size: 14.5px; }
	.ms-mega__link:hover { transform: none; }
	.ms-mega__all { margin-top: 10px; padding-top: 12px; }

	.ms-nav__extra { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 18px 20px 0; }
	.ms-nav__extra a { display: block; padding: 11px 14px; text-align: center; font-weight: 600; font-size: 14px; color: var(--hd-navy); background: var(--hd-soft); border-radius: 8px; }
}

/* Phone: search drops to its own row */
@media (max-width: 767px) {
	.ms-hd__row { flex-wrap: wrap; row-gap: 10px; padding: 8px 14px 12px; min-height: 0; }
	.ms-hd__logo { width: 104px; }
	.ms-hd__util { gap: 2px; }
	.ms-hd__icon { width: 40px; height: 40px; }
	.ms-hd__search { order: 5; flex: 1 1 100%; width: 100%; }
	.ms-hd__search .aws-search-form,
	.ms-hd__search .aws-search-field { height: 44px !important; }
	.ms-hd__promo-text { padding: 8px 12px; font-size: 12.5px; }
}
@media (max-width: 380px) {
	.ms-hd__logo { width: 92px; }
	.ms-hd__account { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	.ms-header *, .ms-header *::before, .ms-header *::after { transition: none !important; }
}
