/* ==========================================================================
   Safe & Cozy — site header

   Logo, the primary menu, and two icon buttons: the WooCommerce mini-cart
   and the account menu. Loaded on every page — the shop, cart and product
   pages included — so nothing here leans on the `.sc-page` scope; the header
   sets its own type and resets.
   ========================================================================== */

.sc-header {
	position: sticky;
	top: 0;
	z-index: 1000;
	background: var(--sc-surface);
	border-bottom: 1px solid transparent;
	color: var(--sc-ink);
	font-family: var(--sc-font);
	font-size: var(--sc-fs-body);
	line-height: 1.4;
	-webkit-font-smoothing: antialiased;
	transition: box-shadow var(--sc-dur) var(--sc-ease),
		border-color var(--sc-dur) var(--sc-ease);
}

/* Logged in, WordPress's toolbar sits on top of the page. */
.admin-bar .sc-header {
	top: 32px;
}

@media (max-width: 782px) {
	.admin-bar .sc-header {
		top: 46px;
	}
}

@media (max-width: 600px) {
	.admin-bar .sc-header {
		top: 0;
	}
}

.sc-header *,
.sc-header *::before,
.sc-header *::after {
	box-sizing: border-box;
}

.sc-header ul {
	margin: 0;
	padding: 0;
	list-style: none;
}

.sc-header a {
	text-decoration: none;
}

.sc-header--stuck {
	border-bottom-color: var(--sc-line-soft);
	box-shadow: 0 2px 14px rgb(20 40 30 / 7%);
}

.sc-header__inner {
	position: relative;
	display: flex;
	align-items: center;
	gap: var(--sc-space-6);
	width: 100%;
	/* Wider than the page content: in the design the logo and the buttons
	   sit about 40px from the edges of a desktop screen. */
	max-width: 1440px;
	min-height: 80px;
	margin-inline: auto;
	padding-inline: clamp(16px, 2.8vw, 40px);
}

/* --- Logo ------------------------------------------------------------------ */

.sc-logo {
	display: flex;
	align-items: center;
	gap: var(--sc-space-3);
	flex: none;
	color: var(--sc-green-900);
	font-size: 26px;
	font-weight: 800;
	letter-spacing: -0.02em;
	line-height: 1;
}

.sc-logo:hover {
	color: var(--sc-green-900);
}

.sc-logo svg {
	width: 64px;
	height: 42px;
}

.sc-logo img {
	display: block;
	width: auto;
	max-width: 220px;
	max-height: 52px;
}

/* --- Primary menu ------------------------------------------------------------ */

/* The theme paints every <nav> dark (styles-headers.css, `nav`). */
.sc-nav {
	margin-inline: auto;
	background: transparent;
}

.sc-nav__list {
	display: flex;
	align-items: center;
	gap: clamp(18px, 2px + 1.6vw, 36px);
}

.sc-nav__list > li {
	position: relative;
}

.sc-nav__list a {
	display: block;
	position: relative;
	padding-block: 10px;
	color: var(--sc-ink);
	font-size: var(--sc-fs-sm);
	font-weight: 600;
	white-space: nowrap;
	transition: color var(--sc-dur) var(--sc-ease);
}

.sc-nav__list a:hover,
.sc-nav__list a:focus-visible {
	color: var(--sc-green-900);
}

/* The page you are on, underlined as in the design. */
.sc-nav__list > .current-menu-item > a,
.sc-nav__list > .current_page_item > a,
.sc-nav__list > .current-menu-ancestor > a,
.sc-nav__list > .current-page-ancestor > a {
	color: var(--sc-green-900);
}

.sc-nav__list > .current-menu-item > a::after,
.sc-nav__list > .current_page_item > a::after,
.sc-nav__list > .current-menu-ancestor > a::after,
.sc-nav__list > .current-page-ancestor > a::after {
	content: "";
	position: absolute;
	right: 0;
	bottom: 2px;
	left: 0;
	height: 2px;
	border-radius: 2px;
	background: var(--sc-green-900);
}

/* A second level, if the menu has one. */
/* Block, not the theme's `header nav ul { display: inline-table }`. */
.sc-nav__list .sub-menu {
	display: block;
	position: absolute;
	top: 100%;
	left: -16px;
	z-index: 2;
	min-width: 220px;
	padding: var(--sc-space-2);
	border: 1px solid var(--sc-line-soft);
	border-radius: var(--sc-radius-md);
	background: var(--sc-surface);
	box-shadow: 0 16px 32px rgb(20 40 30 / 12%);
	opacity: 0;
	visibility: hidden;
	transform: translateY(6px);
	transition: opacity var(--sc-dur) var(--sc-ease),
		transform var(--sc-dur) var(--sc-ease),
		visibility var(--sc-dur);
}

.sc-nav__list li:hover > .sub-menu,
.sc-nav__list li:focus-within > .sub-menu {
	opacity: 1;
	visibility: visible;
	transform: none;
}

.sc-nav__list .sub-menu a {
	padding: 9px 12px;
	border-radius: var(--sc-radius-sm);
	font-weight: 500;
}

.sc-nav__list .sub-menu a:hover {
	background: var(--sc-cream);
}

/* --- Icon buttons -------------------------------------------------------------- */

.sc-header__actions {
	display: flex;
	align-items: center;
	gap: var(--sc-space-2);
	flex: none;
}

.sc-header__menu {
	position: relative;
}

.sc-icon-btn {
	position: relative;
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	margin: 0;
	padding: 0;
	border: 1px solid transparent;
	border-radius: var(--sc-radius-pill);
	background: none;
	color: var(--sc-green-900);
	cursor: pointer;
	transition: background-color var(--sc-dur) var(--sc-ease),
		border-color var(--sc-dur) var(--sc-ease);
}

.sc-icon-btn:hover,
.sc-icon-btn[aria-expanded="true"] {
	border-color: var(--sc-line);
	background: var(--sc-cream);
}

.sc-icon-btn:focus-visible {
	outline: 2px solid var(--sc-green-900);
	outline-offset: 2px;
}

.sc-icon-btn svg {
	width: 24px;
	height: 24px;
}

/* Signed in: the button carries the first initial instead of the outline. */
.sc-icon-btn--user {
	border-color: var(--sc-line);
}

.sc-avatar {
	display: grid;
	place-items: center;
	width: 34px;
	height: 34px;
	border-radius: var(--sc-radius-pill);
	background: var(--sc-green-900);
	color: var(--sc-on-dark);
	font-size: 15px;
	font-weight: 700;
	text-transform: uppercase;
}

.sc-cart-count {
	position: absolute;
	top: 2px;
	right: 0;
	display: grid;
	place-items: center;
	min-width: 19px;
	height: 19px;
	padding: 0 5px;
	border: 2px solid var(--sc-surface);
	border-radius: var(--sc-radius-pill);
	background: var(--sc-gold-500);
	color: var(--sc-on-dark);
	font-size: 11px;
	font-weight: 700;
	line-height: 1;
}

.sc-cart-count[data-count="0"] {
	display: none;
}

/* --- Drop-down panels ------------------------------------------------------------ */

.sc-panel {
	position: absolute;
	top: calc(100% + 12px);
	right: 0;
	z-index: 5;
	width: 300px;
	max-width: calc(100vw - 32px);
	padding: var(--sc-space-5);
	border: 1px solid var(--sc-line-soft);
	border-radius: var(--sc-radius-lg);
	background: var(--sc-surface);
	box-shadow: 0 18px 40px rgb(20 40 30 / 14%);
	text-align: left;
}

.sc-panel[hidden] {
	display: none;
}

.sc-panel__title {
	margin: 0 0 4px;
	color: var(--sc-green-900);
	font-size: var(--sc-fs-body);
	font-weight: 700;
	line-height: 1.3;
}

.sc-panel__text {
	margin: 0 0 var(--sc-space-4);
	color: var(--sc-muted);
	font-size: var(--sc-fs-xs);
	line-height: 1.45;
	overflow-wrap: anywhere;
}

.sc-panel__buttons {
	display: grid;
	gap: var(--sc-space-2);
}

.sc-panel .sc-btn {
	display: flex;
	width: 100%;
	text-decoration: none;
}

/* Account links, once signed in. */
.sc-account-links {
	margin: 0 calc(var(--sc-space-2) * -1);
}

.sc-account-links a {
	display: block;
	padding: 9px var(--sc-space-2);
	border-radius: var(--sc-radius-sm);
	color: var(--sc-ink);
	font-size: var(--sc-fs-sm);
	font-weight: 500;
}

.sc-account-links a:hover,
.sc-account-links .is-active a {
	background: var(--sc-cream);
	color: var(--sc-green-900);
}

.sc-account-links .is-logout {
	margin-top: var(--sc-space-2);
	padding-top: var(--sc-space-2);
	border-top: 1px solid var(--sc-line-soft);
}

.sc-account-links .is-logout a {
	color: var(--sc-muted);
}

/* --- Mini-cart ------------------------------------------------------------------
   WooCommerce's own mini-cart markup, restyled. Woo refreshes it in place
   after an add-to-cart, so its structure is left alone. Scoped under the
   header to outrank the widget styles WooCommerce and the theme both ship
   (`.woocommerce ul.product_list_widget li …`).
   -------------------------------------------------------------------------- */

.sc-panel--cart {
	width: 360px;
}

.sc-header .sc-panel--cart .woocommerce-mini-cart {
	max-height: 320px;
	margin: 0 0 var(--sc-space-4);
	overflow-y: auto;
}

.sc-header .sc-panel--cart .woocommerce-mini-cart-item {
	position: relative;
	display: block;
	min-height: 64px;
	margin: 0;
	padding: 10px 28px 10px 76px;
	border-bottom: 1px solid var(--sc-line-soft);
	color: var(--sc-body);
	font-size: var(--sc-fs-xs);
	list-style: none;
}

.sc-header .sc-panel--cart .woocommerce-mini-cart-item a:not(.remove) {
	display: block;
	color: var(--sc-green-900);
	font-size: var(--sc-fs-sm);
	font-weight: 600;
	line-height: 1.3;
}

.sc-header .sc-panel--cart .woocommerce-mini-cart-item img {
	float: none;
	position: absolute;
	top: 10px;
	left: 0;
	width: 60px;
	height: 44px;
	margin: 0;
	border-radius: var(--sc-radius-sm);
	object-fit: cover;
}

.sc-header .sc-panel--cart .woocommerce-mini-cart-item .remove {
	position: absolute;
	top: 10px;
	right: 0;
	display: grid;
	place-items: center;
	width: 22px;
	height: 22px;
	border-radius: var(--sc-radius-pill);
	color: var(--sc-muted) !important;
	font-size: 18px;
	line-height: 1;
}

.sc-header .sc-panel--cart .woocommerce-mini-cart-item .remove:hover {
	background: var(--sc-cream);
	color: var(--sc-ink) !important;
}

.sc-header .sc-panel--cart .woocommerce-mini-cart-item .quantity {
	display: block;
	margin-top: 2px;
	color: var(--sc-muted);
}

.sc-header .sc-panel--cart .woocommerce-mini-cart-item dl.variation {
	margin: 2px 0 0;
	color: var(--sc-muted);
	font-size: 12px;
}

.sc-header .sc-panel--cart .woocommerce-mini-cart__total {
	display: flex;
	justify-content: space-between;
	margin: 0 0 var(--sc-space-4);
	color: var(--sc-ink);
	font-size: var(--sc-fs-sm);
}

.sc-header .sc-panel--cart .woocommerce-mini-cart__total .amount {
	color: var(--sc-green-900);
	font-weight: 800;
}

.sc-header .sc-panel--cart .woocommerce-mini-cart__buttons {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: var(--sc-space-2);
	margin: 0;
}

.sc-header .sc-panel--cart .woocommerce-mini-cart__buttons .button {
	display: flex !important;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	margin: 0 !important;
	padding: 10px 14px !important;
	border: 1px solid var(--sc-green-900) !important;
	border-radius: var(--sc-radius-sm) !important;
	background: var(--sc-surface) !important;
	color: var(--sc-green-900) !important;
	font-family: var(--sc-font);
	font-size: var(--sc-fs-xs) !important;
	font-weight: 700 !important;
	line-height: 1.2 !important;
	text-align: center;
}

.sc-header .sc-panel--cart .woocommerce-mini-cart__buttons .button.checkout {
	background: var(--sc-green-900) !important;
	color: var(--sc-on-dark) !important;
}

.sc-header .sc-panel--cart .woocommerce-mini-cart__empty-message {
	margin: 0 0 var(--sc-space-4);
	color: var(--sc-muted);
	font-size: var(--sc-fs-sm);
}

/* --- Burger ------------------------------------------------------------------------ */

.sc-burger {
	display: none;
	flex-direction: column;
	justify-content: center;
	gap: 5px;
	width: 44px;
	height: 44px;
	margin: 0;
	padding: 0 11px;
	border: 1px solid var(--sc-line);
	border-radius: var(--sc-radius-sm);
	background: var(--sc-surface);
	cursor: pointer;
}

.sc-burger span {
	display: block;
	height: 2px;
	border-radius: 2px;
	background: var(--sc-green-900);
	transition: transform var(--sc-dur) var(--sc-ease),
		opacity var(--sc-dur) var(--sc-ease);
}

.sc-burger[aria-expanded="true"] span:nth-child(1) {
	transform: translateY(7px) rotate(45deg);
}

.sc-burger[aria-expanded="true"] span:nth-child(2) {
	opacity: 0;
}

.sc-burger[aria-expanded="true"] span:nth-child(3) {
	transform: translateY(-7px) rotate(-45deg);
}

.sc-visually-hidden {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

/* --- Below the full menu's width -------------------------------------------------- */

@media (max-width: 1099px) {
	.sc-burger {
		display: flex;
	}

	.sc-header__inner {
		gap: var(--sc-space-3);
	}

	.sc-header__actions {
		margin-left: auto;
	}

	/* Closed until the burger opens it — by class, so there is no flash of
	   an open menu before the script runs. */
	.sc-nav {
		position: absolute;
		inset: 100% 0 auto;
		margin: 0;
		padding: var(--sc-space-2) var(--sc-gutter, 24px) var(--sc-space-6);
		border-bottom: 1px solid var(--sc-line-soft);
		background: var(--sc-surface);
		box-shadow: 0 14px 24px rgb(20 40 30 / 9%);
	}

	.sc-header:not(.sc-header--open) .sc-nav,
	.sc-nav[hidden] {
		display: none;
	}

	.sc-nav__list {
		flex-direction: column;
		align-items: stretch;
		gap: 0;
	}

	.sc-nav__list a {
		padding-block: var(--sc-space-4);
		border-bottom: 1px solid var(--sc-line-soft);
		font-size: var(--sc-fs-body);
	}

	.sc-nav__list > .current-menu-item > a::after,
	.sc-nav__list > .current_page_item > a::after,
	.sc-nav__list > .current-menu-ancestor > a::after,
	.sc-nav__list > .current-page-ancestor > a::after {
		display: none;
	}

	.sc-nav__list .sub-menu {
		position: static;
		min-width: 0;
		padding: 0 0 0 var(--sc-space-4);
		border: 0;
		box-shadow: none;
		opacity: 1;
		visibility: visible;
		transform: none;
	}
}

@media (max-width: 767px) {
	.sc-header__inner {
		min-height: 68px;
	}

	.sc-logo {
		font-size: 21px;
	}

	.sc-logo svg {
		width: 50px;
		height: 33px;
	}

	.sc-logo img {
		max-width: 160px;
		max-height: 42px;
	}

	/* Anchored to the bar rather than the button, so it cannot run off the
	   left edge of a narrow screen. */
	.sc-header__menu {
		position: static;
	}

	.sc-panel {
		right: var(--sc-gutter, 16px);
		left: var(--sc-gutter, 16px);
		width: auto;
		max-width: none;
	}
}
