/**
 * Site header — yosegi-kaikan.com aligned with mega menu.
 */

.sanpuku-site-header {
	background: var(--sanpuku-white);
	border-bottom: 1px solid var(--sanpuku-accent);
	color: var(--sanpuku-text);
	position: relative;
}

.sanpuku-site-header a {
	color: inherit;
	text-decoration: none;
}

/* wpautop sometimes injects br/p into the shortcode block — neutralize in header */
.sanpuku-site-header br {
	display: none;
}

.sanpuku-header-main > p,
.sanpuku-header-mega__item > p {
	display: contents;
	margin: 0;
	padding: 0;
}

/* Top bar — language only, right aligned (compact row) */
.sanpuku-header-top {
	background: var(--sanpuku-accent);
	color: var(--sanpuku-white);
	height: 26px;
	padding: 0;
	box-sizing: border-box;
	display: flex;
	align-items: center;
}

.sanpuku-header-top__inner {
	max-width: var(--sanpuku-container-wide);
	margin-inline: auto;
	padding: 0 var(--sanpuku-gutter);
	width: 100%;
	height: 100%;
	display: flex;
	justify-content: flex-end;
	align-items: center;
}

.sanpuku-header-top__lang {
	height: 100%;
	display: flex;
	align-items: center;
	line-height: 1;
}

.sanpuku-header-top .sanpuku-language-switcher {
	height: 100%;
	display: flex;
	align-items: center;
	line-height: 1;
}

.sanpuku-header-top .sanpuku-language-switcher__list {
	margin: 0;
	padding: 0;
	height: 100%;
	display: flex;
	flex-wrap: nowrap;
	align-items: center;
	justify-content: flex-end;
	gap: 0 0.5rem;
	line-height: 1;
}

.sanpuku-header-top .sanpuku-language-switcher__list li,
.sanpuku-header-top .sanpuku-language-switcher__list .lang-item {
	margin: 0;
	padding: 0;
	height: auto;
	max-height: 26px;
	display: flex;
	align-items: center;
	line-height: 1;
	list-style: none;
}

.sanpuku-header-top .sanpuku-language-switcher__list a {
	display: inline-flex;
	align-items: center;
	gap: 0.25rem;
	color: var(--sanpuku-white);
	font-size: 0.8125rem;
	line-height: 1;
	padding: 0;
	margin: 0;
	vertical-align: top;
	text-underline-offset: 0.08em;
}

.sanpuku-header-top .sanpuku-language-switcher__list li.is-active a {
	color: var(--sanpuku-white);
}

.sanpuku-header-top .sanpuku-language-switcher__list img {
	display: block;
	width: 14px !important;
	height: 10px !important;
	margin: 0;
	flex-shrink: 0;
}

.sanpuku-header-top .sanpuku-language-switcher__list span {
	line-height: 1;
	margin: 0;
	padding: 0;
}

.sanpuku-site-header__inner {
	max-width: var(--sanpuku-container-wide);
	margin-inline: auto;
	padding: 0 var(--sanpuku-gutter);
}

.sanpuku-header-wrap,
.sanpuku-header-wrap.wp-block-group {
	margin: 0;
	padding: 0;
}

/* Main row — logo left, banner right */
.sanpuku-header-main {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	min-height: var(--sanpuku-header-brand-height);
	height: var(--sanpuku-header-brand-height);
	padding-block: 0;
	box-sizing: border-box;
}

.sanpuku-header-main__logo {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	height: var(--sanpuku-header-brand-height);
	max-width: var(--sanpuku-header-logo-max-width);
	margin-left: 4px;
	line-height: 0;
}

.sanpuku-header-main__logo a {
	display: flex;
	align-items: center;
	height: 100%;
	line-height: 0;
}

.sanpuku-header-main__logo img {
	display: block;
	max-width: var(--sanpuku-header-logo-max-width);
	width: auto;
	height: var(--sanpuku-header-logo-height);
	max-height: var(--sanpuku-header-logo-height);
	object-fit: contain;
}

.sanpuku-header-banner {
	flex: 0 0 auto;
	margin-left: auto;
	display: block;
	width: min(var(--sanpuku-header-banner-width), 72vw);
	height: var(--sanpuku-header-item-height);
	background-size: 100% 100%;
	background-position: center;
	background-repeat: no-repeat;
	border-radius: var(--sanpuku-radius);
}

.sanpuku-header-banner:hover,
.sanpuku-header-banner:focus-visible {
	opacity: 0.92;
}

/* Mega menu bar */
.sanpuku-header-mega {
	border-top: 1px solid color-mix(in srgb, var(--sanpuku-accent) 25%, transparent);
}

.sanpuku-header-mega__list {
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	list-style: none;
	margin: 0;
	padding: 0;
}

.sanpuku-header-mega__item {
	position: relative;
	margin: 0;
}

.sanpuku-header-mega__label {
	display: block;
	padding: 0.75rem 1rem;
	font-size: 1.15rem;
	font-weight: 700;
	text-align: center;
	color: var(--sanpuku-accent);
	font-family: var(--sanpuku-font-sans);
	border-right: 1px solid color-mix(in srgb, var(--sanpuku-accent) 12%, transparent);
	cursor: default;
}

.sanpuku-header-mega__item:last-child .sanpuku-header-mega__label {
	border-right: 0;
}

.sanpuku-header-mega__submenu {
	position: absolute;
	top: 100%;
	left: 0;
	z-index: 200;
	min-width: 15rem;
	margin: 0;
	padding: 0.5rem 0;
	list-style: none;
	background: var(--sanpuku-white);
	border: 1px solid var(--sanpuku-border);
	box-shadow: 0 8px 24px rgb(0 0 0 / 0.12);
	opacity: 0;
	visibility: hidden;
	transform: translateY(4px);
	transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}

.sanpuku-header-mega__item:hover .sanpuku-header-mega__submenu,
.sanpuku-header-mega__item:focus-within .sanpuku-header-mega__submenu {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

.sanpuku-header-mega__submenu a {
	display: block;
	padding: 0.5rem 1rem;
	font-size: 1.15rem;
	line-height: 1.5;
	color: var(--sanpuku-text);
	white-space: nowrap;
}

.sanpuku-header-mega__submenu a:hover,
.sanpuku-header-mega__submenu a:focus-visible {
	background: var(--sanpuku-bg-soft);
	color: var(--sanpuku-accent);
}

/* Mobile menu button */
.sanpuku-hmenu-btn {
	display: none;
	flex: 0 0 auto;
}

.sanpuku-hmenu-overlay,
.sanpuku-hmenu-panel {
	display: none;
}

@media (max-width: 900px) {
	.sanpuku-header-top .sanpuku-language-switcher {
		max-width: 100%;
		overflow: hidden;
	}

	.sanpuku-header-top .sanpuku-language-switcher__list {
		overflow-x: auto;
		overflow-y: hidden;
		flex-wrap: nowrap;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
	}

	.sanpuku-header-top .sanpuku-language-switcher__list::-webkit-scrollbar {
		display: none;
	}

	.sanpuku-header-top .sanpuku-language-switcher__list a {
		font-size: 0.75rem;
		gap: 0;
	}

	.sanpuku-header-top .sanpuku-language-switcher__list a span {
		display: none;
	}

	.sanpuku-header-top .sanpuku-language-switcher__list img {
		width: 18px !important;
		height: 13px !important;
	}

	.sanpuku-header-banner {
		display: none;
	}

	.sanpuku-header-main {
		flex-wrap: wrap;
		align-items: center;
		min-height: auto;
		height: auto;
		padding-block: 0.5rem;
		gap: 0.75rem;
	}

	.sanpuku-header-main__logo {
		order: 1;
		flex: 1 1 auto;
		min-width: 0;
		height: auto;
		max-width: none;
		margin-left: 0;
	}

	.sanpuku-header-main__logo img {
		max-width: min(100%, 220px);
		height: auto;
		max-height: 52px;
	}

	.sanpuku-hmenu-btn {
		order: 2;
		display: inline-flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		gap: 5px;
		width: 44px;
		height: 44px;
		margin-left: auto;
		flex-shrink: 0;
		border: 0;
		border-radius: var(--sanpuku-radius-pill);
		background: var(--sanpuku-accent);
		cursor: pointer;
	}

	.sanpuku-hmenu-btn__bar {
		display: block;
		width: 22px;
		height: 2px;
		background: #fff;
		border-radius: var(--sanpuku-radius);
		transition: transform 0.2s ease, opacity 0.2s ease;
		transform-origin: center;
	}

	.sanpuku-hmenu-btn.is-open .sanpuku-hmenu-btn__bar:nth-child(1) {
		transform: translateY(7px) rotate(45deg);
	}

	.sanpuku-hmenu-btn.is-open .sanpuku-hmenu-btn__bar:nth-child(2) {
		opacity: 0;
	}

	.sanpuku-hmenu-btn.is-open .sanpuku-hmenu-btn__bar:nth-child(3) {
		transform: translateY(-7px) rotate(-45deg);
	}

	.sanpuku-header-mega {
		display: none;
	}

	.sanpuku-hmenu-overlay {
		display: block;
		position: fixed;
		inset: 0;
		background: rgb(0 0 0 / 0.45);
		z-index: 10000;
	}

	.sanpuku-hmenu-overlay[hidden] {
		display: none !important;
	}

	.sanpuku-hmenu-panel {
		display: flex;
		flex-direction: column;
		position: fixed;
		top: 0;
		right: 0;
		height: 100dvh;
		max-height: 100dvh;
		width: min(88vw, 360px);
		background: #fff;
		z-index: 10001;
		transform: translateX(100%);
		transition: transform 0.25s ease;
		padding: 0;
		box-shadow: -12px 0 30px rgb(0 0 0 / 0.18);
		overflow: hidden;
	}

	.sanpuku-hmenu-panel[hidden] {
		display: none !important;
	}

	.sanpuku-hmenu-panel.is-open {
		transform: translateX(0);
	}

	.sanpuku-hmenu-panel__head {
		display: flex;
		align-items: center;
		justify-content: space-between;
		gap: 1rem;
		flex-shrink: 0;
		margin: 0;
		padding: 0.875rem 1rem;
		background: #fff;
		border-bottom: 1px solid var(--sanpuku-border);
	}

	.sanpuku-hmenu-panel__body {
		flex: 1 1 auto;
		min-height: 0;
		overflow-x: hidden;
		overflow-y: auto;
		-webkit-overflow-scrolling: touch;
		overscroll-behavior: contain;
		touch-action: pan-y;
		padding: 0.75rem 1rem 1.25rem;
	}

	.sanpuku-hmenu-panel__title {
		margin: 0;
		font-size: 1rem;
		font-weight: 700;
		color: var(--sanpuku-accent);
		font-family: var(--sanpuku-font-sans);
	}

	.sanpuku-hmenu-panel__close {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 40px;
		height: 40px;
		border: 0;
		border-radius: var(--sanpuku-radius-pill);
		background: var(--sanpuku-bg-panel);
		color: var(--sanpuku-text);
		font-size: 1.75rem;
		line-height: 1;
		cursor: pointer;
	}

	.sanpuku-hmenu-panel__close:hover,
	.sanpuku-hmenu-panel__close:focus-visible {
		background: var(--sanpuku-bg-soft);
		color: var(--sanpuku-accent);
	}

	.sanpuku-hmenu-list {
		list-style: none;
		margin: 0;
		padding: 0;
		display: grid;
		gap: 0.35rem;
	}

	.sanpuku-hmenu-list a {
		display: block;
		padding: 0.75rem;
		border-radius: var(--sanpuku-radius);
		background: var(--sanpuku-bg-panel);
		color: var(--sanpuku-text) !important;
		font-size: 0.9375rem;
		line-height: 1.5;
	}

	.sanpuku-hmenu-group {
		margin-top: 1rem;
	}

	.sanpuku-hmenu-group__title {
		margin: 0 0 0.5rem;
		padding: 0 0.25rem;
		font-size: 0.8125rem;
		font-weight: 700;
		color: var(--sanpuku-accent);
	}
}

body.sanpuku-hmenu-open {
	overflow: hidden;
}
