/**
 * 사이트 헤더 상단 고정
 * body.hw-sticky-site-header 는 PHP에서 UM 코어 페이지( um-page )가 아닐 때만 부여
 *
 * 홈: .wp-site-blocks > header 직계
 * 단일 글 등: .wp-block-group:has(> header) 로 그룹 전체 sticky
 */

:root {
	--hw-sticky-header-offset: 0px;
}

body.admin-bar.hw-sticky-site-header {
	--hw-sticky-header-offset: 32px;
}

@media screen and (max-width: 782px) {
	body.admin-bar.hw-sticky-site-header {
		--hw-sticky-header-offset: 46px;
	}
}

/* 클래식 테마·첫 블록 안 배너 등 (FSE 직계 header 는 파일 하단 !important 블록) */
body.hw-sticky-site-header .wp-site-blocks > *:first-child header[role="banner"],
body.hw-sticky-site-header .wp-site-blocks > *:first-child > header[role="banner"],
body.hw-sticky-site-header #masthead,
body.hw-sticky-site-header #site-header,
body.hw-sticky-site-header .site-header-wrap,
body.hw-sticky-site-header .ast-primary-header,
body.hw-sticky-site-header .ast-header,
body.hw-sticky-site-header .ast-mobile-header-wrap .ast-primary-header,
body.hw-sticky-site-header .generate-header,
body.hw-sticky-site-header .site-header {
	position: -webkit-sticky;
	position: sticky;
	top: var(--hw-sticky-header-offset);
	left: 0;
	right: 0;
	z-index: 99990;
	width: 100%;
	max-width: 100%;
	box-sizing: border-box;
}

/* 패딩 40→20: template-part 직계 div */
body.hw-sticky-site-header .wp-site-blocks > header > div,
body.hw-sticky-site-header .wp-site-blocks > .wp-block-group > header > div {
	padding-top: 20px !important;
	padding-bottom: 20px !important;
}

body.hw-sticky-site-header .wp-site-blocks {
	overflow-x: visible !important;
	overflow-y: visible !important;
}

body.hw-sticky-site-header .wp-site-blocks > .wp-block-group:has(> header) {
	overflow: visible !important;
}

@supports (overflow: clip) {
	body.hw-sticky-site-header {
		overflow-x: clip;
	}
}

body.hw-sticky-site-header .wp-site-blocks > header.wp-block-template-part,
body.hw-sticky-site-header .wp-site-blocks > header[role="banner"],
body.hw-sticky-site-header #masthead,
body.hw-sticky-site-header #site-header,
body.hw-sticky-site-header .site-header-wrap,
body.hw-sticky-site-header .ast-primary-header,
body.hw-sticky-site-header .generate-header,
body.hw-sticky-site-header .site-header {
	background-color: var(--wp--preset--color--base, #fff);
}

@supports (backdrop-filter: blur(8px)) or (-webkit-backdrop-filter: blur(8px)) {
	body.hw-sticky-site-header .wp-site-blocks > header.wp-block-template-part,
	body.hw-sticky-site-header #masthead,
	body.hw-sticky-site-header .wp-site-blocks > header[role="banner"] {
		-webkit-backdrop-filter: saturate(1.2) blur(10px);
		backdrop-filter: saturate(1.2) blur(10px);
	}
}

/*
 * FSE / 블록 테마: 테마 global-styles 가 position 을 덮는 경우 대비 (구 wp_add_inline_style)
 */
body.hw-sticky-site-header .wp-site-blocks > header[role="banner"],
body.hw-sticky-site-header .wp-site-blocks > header.wp-block-template-part,
body.hw-sticky-site-header .wp-site-blocks > header {
	position: -webkit-sticky !important;
	position: sticky !important;
	top: var(--hw-sticky-header-offset) !important;
	z-index: 99990 !important;
}

body.hw-sticky-site-header .wp-site-blocks > .wp-block-group:has(> header) {
	position: -webkit-sticky !important;
	position: sticky !important;
	top: var(--hw-sticky-header-offset) !important;
	z-index: 99990 !important;
	background-color: var(--wp--preset--color--base, #fff);
}

body.hw-sticky-site-header .wp-site-blocks > .wp-block-group:has(> header) > header {
	position: static !important;
	top: auto !important;
}

body.hw-sticky-site-header .wp-site-blocks > .wp-block-group > header {
	position: -webkit-sticky !important;
	position: sticky !important;
	top: var(--hw-sticky-header-offset) !important;
	z-index: 99990 !important;
}
