/* --- 1. 변수 및 기본 스타일 --- */
:root {
	--bg-page: #ffffff;
	--text-primary: #232323;
	--text-link: #4a4a4a;
	--text-link-hover: #000000;
	--border-color: #dcdfe3;
	--button-bg: #e9e9ed;
}

body[data-theme="dark"] {
	--bg-page: #1a1a1b;
	--text-primary: #d7dadc;
	--text-link: #a7a9be;
	--text-link-hover: #ffffff;
	--border-color: #4d4d50;
	--button-bg: #4a4a4d;
}

/* --- 2. CSS 리셋 및 기본 설정 --- */
*,
::before,
::after {
	margin: 0;
	padding: 0;
	box-sizing: border-box;
}

html {
	font-size: 62.5%;
}

body {
	font-family: "SpoqaHanSansNeo", -apple-system, BlinkMacSystemFont, "Segoe UI",
		Roboto, "Helvetica Neue", Arial, sans-serif;
	font-size: 1.6rem;
	min-width: 320px;
	background-color: var(--bg-page);
	color: var(--text-primary);
	transition: background-color 0.3s, color 0.3s;
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
}
/* 모바일 메뉴 열렸을 때 스크롤 방지 */
body.menu-open {
	overflow: hidden;
}

a {
	color: var(--text-link);
	text-decoration: none;
	transition: color 0.2s;
}

a:hover {
	color: var(--text-link-hover);
}

button {
	font-family: inherit;
	background-color: transparent;
	border: none;
	cursor: pointer;
}

ul {
	list-style: none;
}

/* --- 3. 반응형 헤더 스타일 --- */
.site-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	width: 100%;
	padding: 1.5rem 3rem;
	border-bottom: 1px solid var(--border-color);
	background-color: var(--bg-page);
	position: sticky;
	top: 0;
	z-index: 900;
	/* 옅은 그림자 추가 */
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.logo-image {
	width: 17rem;
	height: auto;
}

/* 데스크톱 내비게이션 (기본) */
.nav-links ul {
	display: flex;
	flex-direction: row;
	gap: 1rem;
}
.nav-links ul .dropdown-menu {
	display: block;
}
.nav-links li {
	position: relative;
}

.nav-links a {
	display: block;
	padding: 1rem 1.5rem;
	font-size: 1.6rem;
	font-weight: 500;
	border-radius: 8px;
	transition: background-color 0.2s;
}

.nav-links a:hover {
	background-color: var(--button-bg);
	text-decoration: none;
}

/* 데스크톱 드롭다운 메뉴 (애니메이션 추가) */
.dropdown-menu {
	display: block; /* display:none 대신 visibility 사용 */
	position: absolute;
	top: 100%;
	right: 0;
	background-color: var(--bg-page);
	border: 1px solid var(--border-color);
	border-radius: 8px;
	padding: 0.5rem 0;
	min-width: 20rem;
	z-index: 1000;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);

	flex-direction: column;
	gap: 0;

	/* 애니메이션 속성 */
	opacity: 0;
	visibility: hidden;
	transform: translateY(5px); /* 살짝 아래에서 위로 */
	transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
	display: flex; /* <-- 이렇게 변경 */
	position: absolute;
	/* ... (중간 생략) ... */
	flex-direction: column; /* (이 속성은 여기에 그대로 둡니다) */
}

.dropdown-menu a {
	padding: 1rem 1.5rem;
	width: 100%;
	border-radius: 0;
}

/* 호버 시 드롭다운 보이기 */
.dropdown:hover > .dropdown-menu {
	display: block;
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

/* 모바일 토글 버튼 (햄버거/닫기) */
#mobile-toggle {
	z-index: 949;
}
#mobile-close {
	display: none;
	cursor: pointer;
	z-index: 999;
}

nav.nav-links {
	padding-right: 50px;
}
/* --- 4. 모바일 반응형 (768px 이하) --- */
@media (max-width: 768px) {
	/* 1. 모바일 토글(햄버거) 버튼 */
	#mobile-toggle {
		display: block;
		padding: 1rem;
	}
	#mobile-toggle .icon-bar {
		display: block;
		width: 22px;
		height: 2px;
		background-color: var(--text-primary);
		border-radius: 1px;
	}
	#mobile-toggle .icon-bar + .icon-bar {
		margin-top: 4px;
	}

	/* 2. 내비게이션 메뉴 (슬라이드) */
	.nav-links {
		position: fixed;
		top: 0;
		right: 0;
		width: 90%;
		max-width: 90%;
		height: 100vh;
		background-color: var(--bg-page);
		box-shadow: -3px 0 10px rgba(0, 0, 0, 0.1);
		padding: 6rem 2rem 2rem 2rem;
		z-index: 950;

		/* transform으로 변경 (더 부드러움) */
		transform: translateX(100%);
		transition: transform 0.3s ease-in-out;

		/* ★★★ 이 줄을 추가하세요 ★★★ */
		overflow-y: auto;
	}

	/* 메뉴 활성화 */
	.nav-links.active {
		transform: translateX(0);
	}

	/* 3. 모바일 메뉴 닫기 버튼 */
	#mobile-close {
		display: block;
		position: absolute;
		top: 1.5rem;
		right: 1.5rem;
		font-size: 3rem;
		line-height: 1;
		color: var(--text-primary);
	}

	/* 4. 모바일 메뉴 (세로 정렬) */
	.nav-links ul {
		flex-direction: column;
		gap: 0.5rem;
	}
	.nav-links a {
		padding: 1.5rem 1rem;
		border-bottom: 1px solid var(--border-color);
	}

	/* 5. 모바일 드롭다운 (펼쳐진 상태) */
	.dropdown-menu {
		display: block;
		position: static;
		border: none;
		box-shadow: none;
		padding: 0;
		min-width: auto;

		/* 애니메이션 속성 리셋 */
		opacity: 1;
		visibility: visible;
		transform: none;
		transition: none;
	}
	.dropdown-menu a {
		padding-left: 3rem;
		border-bottom: none;
	}
	.dropdown > a {
		border-bottom: 1px solid var(--border-color);
	}
}

/* --- 5. 백드롭 및 기타 스타일 --- */

/* 모바일 메뉴 백드롭 */
#mobile-backdrop {
	display: none; /* 평소엔 숨김 */
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.5);
	z-index: 940; /* 메뉴(950)보다 낮게 */
	opacity: 0;
	transition: opacity 0.3s ease;
}
#mobile-backdrop.active {
	display: block;
	opacity: 1;
}

/* 테마 버튼 */
#theme-toggle-btn {
	position: fixed;
	top: 1.6rem;
	right: 2rem;
	background: var(--button-bg);
	border: 1px solid var(--border-color);
	color: var(--text-primary);
	font-size: 2rem;
	width: 4rem;
	height: 4rem;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background-color 0.3s, transform 0.2s, border-color 0.3s,
		opacity 0.3s ease, visibility 0.3s ease;
	z-index: 999;
}
@media (max-width: 768px) {
	#theme-toggle-btn {
		top: 1.8rem;
		right: 7rem; /* 햄버거 버튼 피해서 이동 */
	}
}
#theme-toggle-btn:hover {
	transform: scale(1.1);
}

/* 메인 콘텐츠 영역 */
.main-layout {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 80vh;
	padding: 3rem;
}
