/* säm · floating header. No bar of its own: it takes the ink of the chapter under it. */

.site-header {
	--h-ink: var(--paper);
	position: fixed;
	inset: 0 0 auto;
	z-index: 60;
	display: flex;
	align-items: center;
	gap: clamp(16px, 3vw, 56px);
	height: var(--header-h);
	padding-inline: var(--margin);
	color: var(--h-ink);
	pointer-events: none;
	transition: color 300ms;
}
.site-header > * { pointer-events: auto; }
html[data-ink="dark"] .site-header { --h-ink: var(--blue-900); }

/* The wordmark is painted through its own alpha, so it follows the ink. */
.mark {
	display: block;
	width: clamp(108px, 11vw, 188px);
	aspect-ratio: 2400 / 325;
	background: currentColor;
	-webkit-mask: var(--mark) center / 100% auto no-repeat;
	mask: var(--mark) center / 100% auto no-repeat;
	transition: transform 300ms var(--ease-out);
}
.site-header__mark { display: block; padding-block: 12px; }
.site-header__mark:hover .mark { transform: scaleX(1.06); }

.menu-panel__list,
.menu-panel__social,
.social { list-style: none; margin: 0; padding: 0; }

.site-header__tools { display: flex; align-items: center; gap: clamp(16px, 2vw, 28px); margin-left: auto; }

.social { display: flex; gap: 12px; }
.social a { display: grid; place-items: center; width: 34px; height: 34px; color: inherit; transition: transform 180ms var(--ease-out), color 180ms; }
.social a:hover { transform: translateY(-2px); color: var(--crimson-light); }

.cart-link { display: inline-flex; align-items: center; gap: 8px; padding-block: 12px; font-weight: 650; text-decoration: none; }
.cart-link[hidden] { display: none; }
/* Just added: the count arrives with a small pop. */
.cart-link.is-new .cart-link__count { animation: cart-pop 700ms var(--ease-out) 200ms both; }
@keyframes cart-pop { 0% { transform: scale(0.4); } 55% { transform: scale(1.35); background: var(--sky); color: var(--wine); } 100% { transform: scale(1); } }
.cart-link__count {
	display: inline-grid;
	place-items: center;
	min-width: 28px;
	height: 28px;
	padding: 0 7px;
	background: var(--crimson);
	color: var(--paper);
	font-size: var(--step-small);
	font-variant-numeric: tabular-nums;
}

/* The menu icon is säm's own samburger mark: three rows of SAM, the outer two
   mirrored like a reflection. Open, it folds into a cross. */
.menu-toggle {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 12px;
	height: 48px;
	padding: 0;
	border: 0;
	background: none;
	color: inherit;
	font: inherit;
	cursor: pointer;
}
/* The word before the icon: "menüü", or "sulge" while the menu is open. */
.menu-toggle__label { font-size: 1rem; font-weight: 700; letter-spacing: 0.01em; }
.menu-toggle__icon {
	width: 58px;
	aspect-ratio: 1600 / 766;
	background: currentColor;
	-webkit-mask: var(--burger) center / 100% auto no-repeat;
	mask: var(--burger) center / 100% auto no-repeat;
	transition: transform 300ms var(--ease-out), opacity 200ms;
}
.menu-toggle:hover .menu-toggle__icon { transform: scaleX(1.12); }
.menu-toggle::before,
.menu-toggle::after {
	content: "";
	position: absolute;
	right: 12px;
	top: 50%;
	width: 34px;
	height: 4px;
	margin: -2px 0 0 0;
	background: currentColor;
	opacity: 0;
	transition: transform 300ms var(--ease-out), opacity 200ms;
}
.menu-toggle[aria-expanded="true"] .menu-toggle__icon { opacity: 0; transform: scaleY(0.2); }
.menu-toggle[aria-expanded="true"]::before { opacity: 1; transform: rotate(45deg); }
.menu-toggle[aria-expanded="true"]::after { opacity: 1; transform: rotate(-45deg); }
.menu-toggle__close { display: none; }
.menu-toggle[aria-expanded="true"] .menu-toggle__open { display: none; }
.menu-toggle[aria-expanded="true"] .menu-toggle__close { display: inline; }

/* The whole menu: the album blue field, the pages at display size on the
   left, the ways to reach säm on the right. */
.menu-panel {
	position: fixed;
	inset: 0;
	z-index: 55;
	display: grid;
	grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
	align-items: end;
	gap: 48px clamp(32px, 5vw, 96px);
	padding: calc(var(--header-h) + 32px) var(--margin) clamp(32px, 6vh, 72px);
	background: var(--blue);
	color: var(--paper);
	overflow-y: auto;
	animation: menu-in 420ms var(--ease-out);
}
.menu-panel[hidden] { display: none; }
.menu-panel a { color: inherit; }
.menu-panel__list li { overflow: hidden; }
.menu-panel__list a {
	display: block;
	padding-block: 2px;
	font-size: clamp(3.25rem, 1rem + 8vw, 10rem);
	font-weight: 700;
	font-stretch: 74%;
	line-height: 0.9;
	letter-spacing: -0.035em;
	text-transform: lowercase;
	text-decoration: none;
	animation: menu-word 560ms var(--ease-out) backwards;
	transition: color 160ms, transform 300ms var(--ease-out);
}
.menu-panel__list li:nth-child(2) a { animation-delay: 50ms; }
.menu-panel__list li:nth-child(3) a { animation-delay: 100ms; }
.menu-panel__list li:nth-child(4) a { animation-delay: 150ms; }
.menu-panel__list li:nth-child(5) a { animation-delay: 200ms; }
.menu-panel__list li:nth-child(n+6) a { animation-delay: 250ms; }
.menu-panel__list a:hover { color: var(--sky); transform: translateX(0.12em); }
.menu-panel__list .current-menu-item > a { color: var(--sky); }

.menu-panel__contact { display: grid; gap: 18px; justify-items: start; padding-bottom: 0.6em; animation: menu-word 560ms var(--ease-out) 180ms backwards; }
.menu-panel__nav:focus { outline: none; }
.menu-panel__line { margin: 0; padding-top: 14px; border-top: 2px solid var(--paper); justify-self: stretch; font-size: var(--step-statement); font-weight: 600; line-height: 1.25; }
.menu-panel__email { font-size: clamp(1.5rem, 1rem + 1.6vw, 2.5rem); font-weight: 700; font-stretch: 80%; line-height: 1.05; word-break: break-word; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 6px; }
.menu-panel__email:hover { color: var(--sky); }
.menu-panel__social { display: grid; gap: 2px; justify-self: stretch; }
.menu-panel__social a { display: flex; align-items: center; gap: 12px; padding-block: 6px; font-weight: 650; text-decoration: none; transition: color 160ms, padding 220ms var(--ease-out); }
.menu-panel__social a:hover { color: var(--sky); padding-left: 8px; }
.menu-panel__social svg { width: 20px; height: 20px; flex: none; }

@keyframes menu-in { from { opacity: 0; } }
@keyframes menu-word { from { transform: translateY(105%); } }

body.menu-open { overflow: hidden; }
body.menu-open .site-header { --h-ink: var(--paper); }

@media (max-width: 899px) {
	/* Phones: the word stays, set as a solid tag with the count, so a full
	   cart is easy to spot beside the menu icon. */
	.site-header__tools > .cart-link { gap: 0; padding: 0; background: var(--crimson); color: var(--paper); font-size: 0.9375rem; }
	.site-header__tools > .cart-link > span:first-child { padding: 0 10px; line-height: 36px; }
	.site-header__tools > .cart-link .cart-link__count { min-width: 34px; height: 36px; background: var(--paper); color: var(--wine); font-size: 0.9375rem; font-weight: 700; }
	.menu-panel { grid-template-columns: minmax(0, 1fr); align-items: start; align-content: space-between; }
	.menu-panel__list a { font-size: clamp(3.25rem, 16vw, 7rem); }
}

/* The videos page: the grid scrolls under a solid header, as in the shop. */
.post-type-archive-sam_video .site-header { background: var(--blue-950); }
/* With the menu open the header sits on the menu's own blue. */
body.menu-open .site-header { background: transparent; }

/* Phones: logo, cart tag, "menüü" and the icon must all fit in one row. */
@media (max-width: 479px) {
	.site-header { gap: 10px; }
	.site-header .mark { width: 92px; }
	.site-header__tools { gap: 10px; }
	.site-header__tools > .cart-link > span:first-child { padding: 0 8px; }
	.menu-toggle { gap: 8px; }
	.menu-toggle__icon { width: 46px; }
	.menu-toggle::before,
	.menu-toggle::after { right: 8px; width: 30px; }
}
/* The narrowest phones: with something in the cart, the icon stands alone. */
@media (max-width: 379px) {
	.site-header__tools:has(.cart-link:not([hidden])) .menu-toggle__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
}
