/* 헤더 파트 — 헤더 · 로고 · 메뉴 · 햄버거 · 모바일 메뉴 패널. global.css가 먼저 로드된다(--thesmc-ease는 거기서 정의) */

/* ── 헤더 ─────────────────────────────────────────────────────────────────
 * 화면 위에 고정되어 콘텐츠 위에 뜬다. 스크롤 방향에 따라 숨고 나타나는 움직임은 global.js 「헤더」(GSAP transform).
 * 고정이라 헤더 자리만큼 문서 흐름에서 빠진다 — 첫 섹션이 헤더 밑으로 들어가는 것을 전제로 한 시안 구성.
 * 히어로가 없는 템플릿은 첫 섹션에 padding-top: var(--thesmc-header-height)를 주면 헤더에 가려지지 않는다
 * (global.js가 헤더의 실제 높이로 채운다).
 *
 * 선택자가 `.wp-site-blocks:not(.is-root-container) >`로 시작하는 이유: 이 파일은 에디터에도 로드되는데, 사이트 에디터에서 템플릿을 열면
 * 캔버스 최상위도 .wp-site-blocks이고 헤더 파트도 header.wp-block-template-part다. 그대로 두면 에디터에서 헤더가 떠서 따라오고 흰 글자가 된다.
 * 에디터 캔버스의 최상위에만 붙는 .is-root-container로 에디터를 뺀다 — 에디터에서는 헤더가 문서 맨 위에 평범하게 놓인다.
 */
html {
	scroll-padding-top: var(--thesmc-header-height, 0px);
	/* 앵커·건너뛰기 링크로 이동한 곳이 헤더에 가려지지 않게 */
}

.wp-site-blocks:not(.is-root-container)>header.wp-block-template-part {
	position: fixed;
	top: var(--wp-admin--admin-bar--height, 0px);
	/* 로그인 시 관리자 바 아래로 */
	right: 0;
	left: 0;
	z-index: 300;
	color: #ffffff;
	mix-blend-mode: difference;
	/* 흰색 × difference — 밝은 배경에선 검게, 어두운 배경·사진 위에선 희게 */
	will-change: transform;
	/* 자주 오르내리므로 미리 별도 레이어로 */
}

.wp-site-blocks:not(.is-root-container)>header.wp-block-template-part a {
	color: inherit;
}

/* 로고 이미지는 파일 색(#111)과 상관없이 흰색으로 — 반전이 제대로 되려면 헤더의 모든 요소가 흰색이어야 한다 */
.wp-site-blocks:not(.is-root-container)>header.wp-block-template-part img {
	filter: brightness(0) invert(1);
}

/* 로고 크기 — 화면 크기별로 다르다(global.css --thesmc-brand-size: 모바일 30 / 태블릿 32 / 데스크탑 34).
 * 이미지 블록의 크기 설정은 하나뿐이라 데스크탑 값(34px)을 넣어 두고, 블록이 이미지에 인라인으로 쓰는 폭 · 높이를 여기서 덮는다(!important).
 * 칸 폭(flexSize)은 블록이 클래스 하나로 정해서 같은 클래스를 두 번 써 이긴다 */
.part-header__brand.part-header__brand {
	flex-basis: var(--thesmc-brand-size);
}

.part-header__brand img {
	width: var(--thesmc-brand-size) !important;
	height: var(--thesmc-brand-size) !important;
}

/* ── 헤더 로고 호버 ───────────────────────────────────────────────────────────────
 * 심볼이 작아지며 사라지고, 같은 자리에서 워드마크 (The SMC)가 아래에서 올라온다(시안 「② 심볼 호버」).
 * 워드마크는 링크의 ::after 글자라 이미지 블록(로고 교체·링크 수정)은 그대로 쓴다. 빈 대체 텍스트(/ "")로 화면 낭독기가 읽지 않는다 —
 * 링크 이름은 이미지 alt("The SMC")가 맡는다. 글꼴은 body에서 물려받는다(굵기만 500).
 * 글자를 위아래만 자르려고 링크에 clip-path를 쓴다(오른쪽은 열어 둔다 — 로고 폭보다 글자가 넓다). clip-path는 눌리는 영역도 자르므로
 * 눌리는 영역을 넓힌 링크 전체를 자르는 상자로 쓰고, 숨은 글자는 그 상자 밖으로 내려 둔다.
 * 에디터에는 적용하지 않는다(.wp-site-blocks:not(.is-root-container)): 에디터는 링크에 인라인 스타일로 display: inline을 붙여
 * 링크 높이가 이미지보다 낮아지고, 그 상태로 clip-path를 쓰면 로고 윗부분이 잘린다. 에디터에서는 링크가 눌리지 않아 효과도 필요 없다.
 */
.wp-site-blocks:not(.is-root-container) .part-header__brand a {
	/* 눌리는 영역을 넓힌다(햄버거와 같은 방식): 안쪽 여백만큼 링크를 키우고 같은 만큼 음수 마진으로 되돌려 보이는 위치는 그대로 */
	--brand-size: var(--thesmc-brand-size);
	/* 로고 이미지 폭 — 화면 크기별 값은 global.css */
	--brand-pad: 14px;
	position: relative;
	display: block;
	box-sizing: content-box;
	width: var(--brand-size);
	height: var(--brand-size);
	margin: calc(var(--brand-pad) * -1);
	padding: var(--brand-pad);
	clip-path: inset(0 -200px 0 0);
}

.wp-site-blocks:not(.is-root-container) .part-header__brand a::after {
	content: "(The SMC)";
	content: "(The SMC)" / "";
	position: absolute;
	top: var(--brand-pad);
	/* 여백을 뺀 로고 자리에 맞춘다 */
	left: var(--brand-pad);
	display: flex;
	align-items: center;
	height: var(--brand-size);
	font-size: 17px;
	font-weight: 500;
	line-height: 1.2;
	letter-spacing: -0.01em;
	white-space: nowrap;
	transform: translateY(calc(100% + var(--brand-pad) + 2px));
	/* 기본: 넓어진 링크 영역의 아래 밖에 가려져 있다 */
	transition: transform var(--thesmc-dur-slow) var(--thesmc-ease);
	/* pointer-events를 끄지 않는다 — 글자 위도 링크의 일부라 호버가 이어지고 클릭이 된다(숨어 있을 때는 clip-path가 막는다) */
}

.wp-site-blocks:not(.is-root-container) .part-header__brand img {
	transform-origin: left center;
	transition: opacity var(--thesmc-dur) ease, transform var(--thesmc-dur-slow) var(--thesmc-ease);
}

/* 호버는 마우스 기기에서만. 키보드로 들어왔을 때(:focus-visible)는 지연 없이 바로 */
@media (hover: hover) {
	.wp-site-blocks:not(.is-root-container) .part-header__brand a:hover img {
		opacity: 0;
		transform: scale(0.6);
	}

	.wp-site-blocks:not(.is-root-container) .part-header__brand a:hover::after {
		transform: translateY(0);
		transition-delay: 0.06s;
	}
}

.wp-site-blocks:not(.is-root-container) .part-header__brand a:focus-visible img {
	opacity: 0;
}

.wp-site-blocks:not(.is-root-container) .part-header__brand a:focus-visible::after {
	transform: translateY(0);
}

/* ── 헤더 메뉴 ────────────────────────────────────────────────────────────
 * 링크 양옆에 괄호 ( )가 한가운데서부터 커지며 나타난다(scale 0 → 1).
 *   마우스를 올렸을 때 · 키보드로 들어왔을 때(:focus-visible) · 지금 보고 있는 메뉴(aria-current, inc/header.php)
 * 괄호는 가상 요소라 메뉴 HTML(문단 블록)을 건드리지 않고, `content: "(" / ""`의 빈 대체 텍스트로 화면 낭독기가 읽지 않는다
 * (이 문법을 모르는 오래된 브라우저는 앞 줄의 content만 쓴다).
 * transform만 바꾸므로 괄호가 커져도 옆 메뉴가 밀리지 않는다.
 */
/* 메뉴 사이 간격 — 시안 .nav__links의 gap. 1545px부터 34px, 내려갈수록 줄어 730px 아래는 16px.
 * 워드프레스가 그룹 블록에 붙이는 gap(클래스 하나)보다 이기려고 같은 클래스를 두 번 쓴다.
 * 부모를 따지는 선택자(header …)는 쓰지 않는다 — 헤더 파트를 직접 열어 고칠 때는 header 요소가 없다.
 * 링크는 템플릿 파트(nav-links)를 헤더와 모바일 패널이 같이 쓴다 — 모양(글자 크기 · 배치)은 부모(.part-header__nav · .mobile-menu__nav)가 정한다 */
.part-header__nav {
	padding-top: 1px;
	font-size: 14px;
	letter-spacing: 0.04em;
	/* 헤더 그룹(16px)에 걸린 0.04em은 px로 상속돼 14px 글자에 맞지 않아 여기서 다시 잡는다 */
	line-height: 1.7;
}

.part-header__nav .nav-links.nav-links {
	gap: clamp(16px, calc(2.2 * var(--wp--custom--vwc)), 34px);
}

.nav-links a {
	position: relative;
	display: inline-block;
	/* 인라인이면 링크 높이가 글자 높이(16px)라 줄 높이를 받은 괄호(top: 0)가 아래로 처진다 */
	text-decoration: none;
}

.nav-links a::before,
.nav-links a::after {
	position: absolute;
	top: 0;
	transform: scale(0);
	transform-origin: 50% 50%;
	/* 괄호 한가운데 기준 — 가운데서 위아래로 퍼지는 느낌 */
	transition: transform var(--thesmc-dur) var(--thesmc-ease);
	pointer-events: none;
}

.nav-links a::before {
	content: "(";
	content: "(" / "";
	left: -0.5em;
}

.nav-links a::after {
	content: ")";
	content: ")" / "";
	right: -0.5em;
}

/* 호버는 마우스 기기에서만 — 휴대폰에서 누른 뒤 괄호가 남아 있지 않게 */
@media (hover: hover) {

	.nav-links a:hover::before,
	.nav-links a:hover::after {
		transform: scale(1);
	}
}

.nav-links a:focus-visible::before,
.nav-links a:focus-visible::after,
.nav-links a[aria-current]::before,
.nav-links a[aria-current]::after {
	transform: scale(1);
}

/* ── 헤더 햄버거 ──────────────────────────────────────────────────────────────────
 * 모바일(767px 이하)에서만 보인다 — 보이고 숨기는 건 코어의 「화면 크기별 숨기기」(theme.json settings.viewport, parts/header.html).
 * 버튼 블록(<button>)이고 글자는 화면 낭독기용이라 화면에서는 숨긴다. 선 3개는 CSS로 그린다(시안 .nav__burger: 24×16px, 선 2px).
 * 열리면 위 · 아래 선이 가운데로 모이며 X가 되고 가운데 선은 사라진다. 상태는 스크립트가 붙이는 .is-open
 */
.part-header__burger .wp-block-button__link {
	/* 눌리는 영역을 넓힌다: 선은 24×16px 그대로 두고 안쪽 여백(--burger-pad-x · y)만큼 버튼을 키운 뒤 같은 만큼 음수 마진으로 되돌려,
	 * 보이는 모양과 헤더 안 위치는 그대로다 */
	--burger-w: 24px;
	--burger-h: 16px;
	--burger-line: 2px;
	/* 선 두께. 가운데 선은 (높이 − 두께) ÷ 2, 아래 선은 높이 − 두께에 놓인다 */
	--burger-pad-x: 14px;
	--burger-pad-y: 14px;
	position: relative;
	display: block;
	/* 인라인 블록이면 글줄 높이(23px)가 생겨 선이 로고보다 아래로 밀린다 */
	box-sizing: content-box;
	width: var(--burger-w);
	height: var(--burger-h);
	margin: calc(var(--burger-pad-y) * -1) calc(var(--burger-pad-x) * -1);
	padding: var(--burger-pad-y) var(--burger-pad-x);
	border-radius: 0;
	background: linear-gradient(currentColor, currentColor) 0 calc((var(--burger-h) - var(--burger-line)) / 2) / 100% var(--burger-line) no-repeat;
	background-origin: content-box;
	/* 가운데 선은 여백이 아니라 24×16 안에서 그린다 */
	background-clip: content-box;
	color: inherit;
	font-size: 0;
	/* 글자는 화면 낭독기만 읽는다 */
	transition: background-size var(--thesmc-dur) var(--thesmc-ease);
}

.part-header__burger .wp-block-button__link:hover {
	background-color: transparent;
	color: inherit;
}

.part-header__burger .wp-block-button__link::before,
.part-header__burger .wp-block-button__link::after {
	content: "";
	position: absolute;
	left: var(--burger-pad-x);
	right: var(--burger-pad-x);
	height: var(--burger-line);
	background: currentColor;
	transition: top var(--thesmc-dur) var(--thesmc-ease), transform var(--thesmc-dur) var(--thesmc-ease);
}

.part-header__burger .wp-block-button__link::before {
	top: var(--burger-pad-y);
}

.part-header__burger .wp-block-button__link::after {
	top: calc(var(--burger-pad-y) + var(--burger-h) - var(--burger-line));
}

.part-header__burger .wp-block-button__link.is-open {
	background-size: 100% 0;
}

.part-header__burger .wp-block-button__link.is-open::before {
	top: calc(var(--burger-pad-y) + (var(--burger-h) - var(--burger-line)) / 2);
	transform: rotate(45deg);
}

.part-header__burger .wp-block-button__link.is-open::after {
	top: calc(var(--burger-pad-y) + (var(--burger-h) - var(--burger-line)) / 2);
	transform: rotate(-45deg);
}

/* ── 모바일 메뉴 패널 ─────────────────────────────────────────────────────────────
 * 헤더 자리까지 덮는 ink 색 전체 화면(헤더는 그 위). 파트(parts/mobile-menu.html)는 inc/header.php가 헤더 밖 문서 끝에 그린다
 * (헤더의 mix-blend-mode에 섞이지 않게). display: none이 아니라 투명 + visibility로 숨겨서 페이드가 된다 —
 * 닫힌 동안 visibility: hidden이라 탭 이동 · 화면 낭독기에서도 빠진다(스크립트가 inert도 건다).
 * 열고 닫기는 assets/js/mobile-menu.js가 .is-open을 붙인다. 태블릿 이상에서는 코어의 「화면 크기별 숨기기」(inc/header.php가 파트에 건다)로 숨는다.
 */
.mobile-menu {
	position: fixed;
	inset: 0;
	/* 헤더 자리까지 검게 덮는다. 헤더(300)가 위에 있어 헤더 글자는 반전으로 흰색이 된다 */
	z-index: 290;
	/* 위아래를 같게 비워 링크 묶음이 헤더를 포함한 화면 전체의 세로 중앙에 오게 한다(위만 비우면 헤더 아래 영역의 중앙이 된다).
	 * 위쪽이 헤더 높이만큼 비어 있어 링크가 헤더에 가려지지도 않는다 */
	padding-block: calc(var(--wp-admin--admin-bar--height, 0px) + var(--thesmc-header-height, 70px));
	display: flex;
	/* 안쪽 영역이 남은 높이를 채우게 한다 — 100vh는 폰에서 주소창을 뺀 실제 화면보다 커서 쓰지 않는다 */
	flex-direction: column;
	overflow-y: auto;
	/* 가로로 눕힌 폰처럼 내용이 더 길 때만 스크롤 */
	overscroll-behavior: contain;
	/* 끝까지 가도 뒤 화면이 따라 스크롤되지 않게 */
	background: var(--wp--preset--color--ink);
	color: var(--wp--preset--color--white);
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 0.4s var(--thesmc-ease), visibility 0s linear 0.4s;
	/* 닫을 때는 투명해진 뒤에 숨긴다 */
}

.mobile-menu.is-open {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	transition: opacity 0.4s var(--thesmc-ease);
}

.mobile-menu__inner {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	flex: 1 0 auto;
	/* 남은 높이를 채우되, 내용이 더 길면 늘어난다 */
	padding: clamp(24px, 6vh, 56px) var(--wp--preset--spacing--gutter);
	/* 시안 .nav__mobile-links */
	text-align: center;
}

/* 메뉴 글자: 시안 .nav__mobile .nav-link — 390px에서 39px, 460px부터 46px */
.mobile-menu__nav {
	font-size: clamp(30px, calc(10 * var(--wp--custom--vwc)), 46px);
	letter-spacing: -0.01em;
}

.mobile-menu__nav .nav-links.nav-links {
	flex-direction: column;
	align-items: center;
	gap: 0;
}

.mobile-menu__nav .nav-links a {
	/* 링크 위아래 간격은 패딩이 아니라 줄 높이로 — 괄호(::before · ::after, top: 0)가 글자와 같은 줄 상자를 쓰도록.
	 * 시안: 줄 높이 1.7배 + 위아래 패딩 clamp(10px, 2.2vh, 18px). 화면이 낮을수록 촘촘하게 */
	line-height: calc(1.7em + 2 * clamp(10px, 2.2vh, 18px));
}

/* 가로로 눕힌 폰: 4개 항목이 한 화면에 들어오도록(시안 P1-5) */
@media (max-height: 500px) and (orientation: landscape) {
	.mobile-menu {
		padding-bottom: 0;
		/* 낮은 화면에서는 아래를 비우지 않아야 4개 항목이 한 화면에 들어온다 */
	}

	.mobile-menu__inner {
		padding-top: 12px;
		padding-bottom: 12px;
	}

	.mobile-menu__nav {
		font-size: 26px;
	}

	.mobile-menu__nav .nav-links a {
		line-height: calc(1.7em + 12px);
	}
}

html.has-menu-open {
	overflow: hidden;
	/* 열려 있는 동안 뒤 화면이 스크롤되지 않게 */
}

/* ── 움직임 줄이기 ─────────────────────────────────────────────────────────────
 * 시스템에서 움직임을 줄이는 설정이면 이 파일의 전환(로고 워드마크 · 괄호 · 햄버거 · 모바일 패널)을 모두 끈다. 한 곳에 모아 둔다 */
@media (prefers-reduced-motion: reduce) {

	.wp-site-blocks:not(.is-root-container) .part-header__brand a::after,
	.wp-site-blocks:not(.is-root-container) .part-header__brand img,
	.nav-links a::before,
	.nav-links a::after,
	.part-header__burger .wp-block-button__link,
	.part-header__burger .wp-block-button__link::before,
	.part-header__burger .wp-block-button__link::after,
	.mobile-menu,
	.mobile-menu.is-open {
		transition: none;
	}
}