/*
Theme Name: GeneratePress Clarity
Theme URI: https://blog.nets.kr/
Description: GeneratePress 자식 테마. 현대적이고 심플한 정보성 블로그용. h2·h3 소제목 꾸밈, 모바일에서 옆으로 밀리는 표, 한글 가독성(줄 간격·줄바꿈)을 다듬었습니다. 자바스크립트 0개, CSS 파일 1개라 가볍고, 색은 사용자정의하기의 강조색(accent)을 그대로 물려받습니다.
Author: gwang
Template: generatepress
Version: 1.0.1
Requires at least: 6.5
Tested up to: 6.9
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: generatepress-clarity
Tags: blog, one-column, custom-colors, editor-style, translation-ready
*/

/* =========================================================
   목차
   01. 토큰(색·글꼴·크기)
   02. 기본(글꼴·선택·포커스·페이지 전환)
   03. 틀(헤더·카드형 컨테이너)
   04. 글 머리(제목·메타)
   05. 본문 기본(문단·링크·강조·목록)
   06. 소제목 h2 · h3 · h4
   07. 표
   08. 인용·코드·이미지·구분선
   09. 글 목록(홈·카테고리)
   10. 모바일
   11. 움직임 줄이기·인쇄

   ※ 본문 규칙은 대부분 `.entry-content > 요소` (바로 아래 자식) 로만 겁니다.
     +디자인 글처럼 자체 CSS 를 가진 레이아웃 안쪽 요소에는 스며들지 않습니다.
   ========================================================= */

/* =========================================================
   01. 토큰
   ========================================================= */
:root {
	/* 색 — 사용자정의하기 팔레트(--accent, --contrast …)를 물려받는다 */
	--cl-accent: var(--accent, #2563eb);
	--cl-text: var(--contrast, #1d2129);
	--cl-muted: var(--contrast-2, #5b6270);
	--cl-surface: var(--base-3, #ffffff);
	--cl-line: color-mix(in srgb, var(--cl-text) 11%, transparent);
	--cl-line-strong: color-mix(in srgb, var(--cl-text) 18%, transparent);
	--cl-tint: color-mix(in srgb, var(--cl-accent) 7%, var(--cl-surface));
	--cl-tint-2: color-mix(in srgb, var(--cl-accent) 13%, var(--cl-surface));
	--cl-zebra: color-mix(in srgb, var(--cl-text) 2.5%, transparent);
	--cl-mark: color-mix(in srgb, var(--cl-accent) 20%, transparent);

	/* 글꼴 — Pretendard(함수에서 불러옴) → 없으면 시스템 글꼴 */
	--cl-sans: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
		"Apple SD Gothic Neo", "Malgun Gothic", "맑은 고딕", system-ui, sans-serif;
	--cl-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

	/* 크기 — 화면 폭에 따라 자연스럽게 커지는 유동 크기 */
	--cl-fs-body: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);  /* 16 → 17px */
	--cl-fs-h1: clamp(1.625rem, 1.3rem + 1.6vw, 2.25rem);
	--cl-fs-h2: clamp(1.375rem, 1.18rem + 0.9vw, 1.6875rem);
	--cl-fs-h3: clamp(1.1563rem, 1.06rem + 0.45vw, 1.3125rem);
	--cl-fs-h4: 1.0625rem;
	--cl-lh: 1.8;

	/* 모양 */
	--cl-radius: 12px;
	--cl-radius-lg: 16px;
	--cl-shadow: 0 1px 2px rgb(16 24 40 / 4%), 0 1px 3px rgb(16 24 40 / 3%);
}

/* =========================================================
   02. 기본
   ========================================================= */
html {
	-webkit-text-size-adjust: 100%;
	text-size-adjust: 100%;
}

body,
button,
input,
select,
textarea {
	font-family: var(--cl-sans);
}

body {
	-webkit-font-smoothing: antialiased;
	-moz-osx-font-smoothing: grayscale;
	word-break: keep-all;          /* 한글 단어 중간에서 끊지 않기 */
	overflow-wrap: break-word;     /* 긴 주소·영문은 넘치지 않게 */
}

::selection {
	background: var(--cl-tint-2);
	color: var(--cl-text);
}

:focus-visible {
	outline: 2px solid var(--cl-accent);
	outline-offset: 2px;
	border-radius: 4px;
}

/* 페이지 이동 시 부드러운 화면 전환 (자바스크립트 없이 브라우저 기본 기능) */
@media (prefers-reduced-motion: no-preference) {
	@view-transition {
		navigation: auto;
	}
}

/* =========================================================
   03. 틀
   ========================================================= */
.site-header {
	border-bottom: 1px solid var(--cl-line);
}

.main-title {
	font-weight: 800;
	letter-spacing: -0.02em;
}

.main-navigation .main-nav ul li a {
	font-weight: 500;
}

/* 카드형 컨테이너(분리된 컨테이너 레이아웃) */
.separate-containers .inside-article,
.separate-containers .comments-area,
.separate-containers .page-header,
.separate-containers .paging-navigation,
.one-container .site-content {
	border: 1px solid var(--cl-line);
	border-radius: var(--cl-radius-lg);
	box-shadow: var(--cl-shadow);
}

.separate-containers .inside-article {
	overflow: clip;  /* 위쪽 대표 이미지 모서리를 둥글게 */
}

/* 메뉴에 항목이 하나도 없으면 빈 햄버거 버튼·빈 메뉴 줄을 숨긴다.
   외모 → 메뉴에서 메뉴를 지정하면 자동으로 다시 나타난다. */
body:not(:has(#primary-menu li)) :is(#site-navigation, .mobile-menu-control-wrapper) {
	display: none;
}

/* 광고(애드센스 반응형) 자리 미리 확보 — 늦게 들어온 광고가 본문을 밀어내는 화면 밀림(CLS) 방지.
   광고가 안 채워지면(unfilled) 자리를 접는다. 크기는 10. 모바일에서 지정 */
.code-block ins.adsbygoogle[data-ad-status="unfilled"] {
	min-height: 0 !important;
}

/* =========================================================
   04. 글 머리
   ========================================================= */
.entry-header .entry-title,
h1.entry-title {
	font-size: var(--cl-fs-h1);
	font-weight: 800;
	line-height: 1.35;
	letter-spacing: -0.025em;
	color: var(--cl-text);
	text-wrap: balance;
}

.entry-meta {
	margin-top: 0.75em;
	font-size: 0.875rem;
	color: var(--cl-muted);
}

.entry-meta a {
	color: inherit;
	text-decoration: none;
}

.entry-meta a:hover {
	color: var(--cl-accent);
}

.single .entry-header {
	margin-bottom: 2rem;
	padding-bottom: 1.5rem;
	border-bottom: 1px solid var(--cl-line);
}

/* =========================================================
   05. 본문 기본
   ========================================================= */
.entry-content {
	font-size: var(--cl-fs-body);
	line-height: var(--cl-lh);
	color: var(--cl-text);
}

.entry-content > p {
	margin: 0 0 1.4em;
	text-wrap: pretty;   /* 마지막 줄에 글자 한두 개만 남는 것 방지 */
}

.entry-content a {
	color: var(--cl-accent);
	text-decoration-line: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.22em;
	text-decoration-color: color-mix(in srgb, var(--cl-accent) 45%, transparent);
	transition: text-decoration-color 0.15s, text-decoration-thickness 0.15s;
}

.entry-content a:hover {
	text-decoration-color: currentColor;
	text-decoration-thickness: 2px;
}

/* 굵은 글씨 = 형광펜 밑줄. 훑어 읽을 때 핵심이 눈에 들어온다 */
.entry-content > p strong,
.entry-content > ul strong,
.entry-content > ol strong {
	font-weight: 700;
	background: linear-gradient(transparent 62%, var(--cl-mark) 0);
	-webkit-box-decoration-break: clone;
	box-decoration-break: clone;
}

.entry-content > ul,
.entry-content > ol {
	margin: 0 0 1.5em;
	padding-left: 1.4em;
}

.entry-content > ul li,
.entry-content > ol li {
	margin-bottom: 0.45em;
	padding-left: 0.2em;
}

.entry-content > ul li::marker {
	color: var(--cl-accent);
}

.entry-content > ol li::marker {
	color: var(--cl-accent);
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}

.entry-content li > ul,
.entry-content li > ol {
	margin: 0.45em 0 0;
}

/* =========================================================
   06. 소제목
   h2 = 아래 얇은 선 + 강조색 짧은 막대
   h3 = 왼쪽 강조색 세로 막대
   ========================================================= */
.entry-content > :is(h2, h3, h4) {
	color: var(--cl-text);
	text-wrap: balance;
	scroll-margin-top: 5.5rem;    /* 목차·#주소로 이동할 때 고정 메뉴에 가리지 않게 */
}

.entry-content > h2 {
	position: relative;
	margin: 2.8em 0 1.1em;
	padding: 0 0 0.6em;
	font-size: var(--cl-fs-h2);
	font-weight: 800;
	line-height: 1.4;
	letter-spacing: -0.022em;
	border-bottom: 1px solid var(--cl-line);
}

.entry-content > h2::after {
	content: "";
	position: absolute;
	left: 0;
	bottom: -2px;
	width: 2.75rem;
	height: 3px;
	border-radius: 3px;
	background: var(--cl-accent);
}

.entry-content > h3 {
	position: relative;
	margin: 2.1em 0 0.8em;
	padding-left: 0.85em;
	font-size: var(--cl-fs-h3);
	font-weight: 700;
	line-height: 1.45;
	letter-spacing: -0.015em;
}

.entry-content > h3::before {
	content: "";
	position: absolute;
	left: 0;
	top: 0.28em;
	bottom: 0.28em;
	width: 4px;
	border-radius: 4px;
	background: color-mix(in srgb, var(--cl-accent) 70%, transparent);
}

.entry-content > h4 {
	margin: 1.8em 0 0.6em;
	font-size: var(--cl-fs-h4);
	font-weight: 700;
	line-height: 1.5;
	color: var(--cl-text);
}

/* 첫 요소가 소제목이면 위 여백 제거, h2 바로 뒤 h3 는 간격 축소 */
.entry-content > :is(h2, h3):first-child {
	margin-top: 0;
}

.entry-content > h2 + h3 {
	margin-top: 1.4em;
}

/* =========================================================
   07. 표
   functions.php 가 본문 표를 <div class="cl-table"> 로 감싼다.
   → 좁은 화면에서 표만 옆으로 밀리고 페이지는 흔들리지 않는다.
   ========================================================= */
.entry-content > .cl-table,
.entry-content > .wp-block-table {
	margin: 1.75em 0 2em;
	overflow-x: auto;
	overscroll-behavior-x: contain;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: thin;
	scrollbar-color: var(--cl-line-strong) transparent;
	border: 1px solid var(--cl-line);
	border-radius: var(--cl-radius);
	background: var(--cl-surface);
	container-type: scroll-state;   /* 아래 "옆으로 더 있음" 표시용 */
}

/* 표가 오른쪽으로 더 이어질 때만 오른쪽 끝을 흐리게 → 밀어 볼 수 있다는 신호.
   최신 브라우저 기능(스크롤 상태 조회). 지원하지 않는 브라우저는 그냥 표시 없음 */
@container scroll-state(scrollable: right) {
	.entry-content > :is(.cl-table, .wp-block-table) > table {
		-webkit-mask-image: linear-gradient(to right, #000 calc(100% - 2.5rem), transparent);
		mask-image: linear-gradient(to right, #000 calc(100% - 2.5rem), transparent);
	}
}

.entry-content > :is(.cl-table, .wp-block-table) table {
	width: 100%;
	margin: 0;
	border: 0;
	border-collapse: collapse;
	font-size: 0.9375em;
	line-height: 1.6;
	font-variant-numeric: tabular-nums;   /* 숫자 자릿수 맞춤 */
}

.entry-content > :is(.cl-table, .wp-block-table) :is(th, td) {
	padding: 0.8em 1em;
	border: 0;
	border-bottom: 1px solid var(--cl-line);
	text-align: left;
	vertical-align: top;
}

.entry-content > :is(.cl-table, .wp-block-table) thead th {
	background: var(--cl-tint);
	color: var(--cl-text);
	font-weight: 700;
	white-space: nowrap;
	border-bottom: 1px solid color-mix(in srgb, var(--cl-accent) 28%, transparent);
}

.entry-content > :is(.cl-table, .wp-block-table) tbody tr:nth-child(even) {
	background: var(--cl-zebra);
}

.entry-content > :is(.cl-table, .wp-block-table) tbody tr:last-child > :is(th, td) {
	border-bottom: 0;
}

/* 첫 칸은 항목 이름인 경우가 많아 살짝 굵게 */
.entry-content > :is(.cl-table, .wp-block-table) tbody :is(td, th):first-child {
	font-weight: 600;
	color: var(--cl-text);
}

@media (hover: hover) {
	.entry-content > :is(.cl-table, .wp-block-table) tbody tr:hover {
		background: var(--cl-tint);
	}
}

/* 마크다운 표의 정렬 지정(style="text-align:…")은 그대로 존중 */
.entry-content > :is(.cl-table, .wp-block-table) [style*="text-align: center"],
.entry-content > :is(.cl-table, .wp-block-table) [style*="text-align:center"],
.entry-content > :is(.cl-table, .wp-block-table) [align="center"] {
	text-align: center;
}

.entry-content > :is(.cl-table, .wp-block-table) [style*="text-align: right"],
.entry-content > :is(.cl-table, .wp-block-table) [style*="text-align:right"],
.entry-content > :is(.cl-table, .wp-block-table) [align="right"] {
	text-align: right;
}

.entry-content > .wp-block-table figcaption,
.entry-content > .cl-table caption {
	padding: 0.6em 1em;
	font-size: 0.8125rem;
	color: var(--cl-muted);
	text-align: left;
}

/* =========================================================
   08. 인용·코드·이미지·구분선
   ========================================================= */
.entry-content > blockquote {
	margin: 1.75em 0;
	padding: 1em 1.25em;
	border: 0;
	border-left: 4px solid var(--cl-accent);
	border-radius: 0 var(--cl-radius) var(--cl-radius) 0;
	background: var(--cl-tint);
	font-style: normal;
	font-size: 1em;
	color: var(--cl-text);
}

.entry-content > blockquote p:last-child {
	margin-bottom: 0;
}

.entry-content :not(pre) > code {
	padding: 0.15em 0.4em;
	border-radius: 6px;
	background: color-mix(in srgb, var(--cl-text) 6%, transparent);
	font-family: var(--cl-mono);
	font-size: 0.875em;
}

.entry-content > pre {
	margin: 1.75em 0;
	padding: 1em 1.25em;
	overflow-x: auto;
	border-radius: var(--cl-radius);
	background: #1e2330;
	color: #e6e9ef;
	font-family: var(--cl-mono);
	font-size: 0.875rem;
	line-height: 1.65;
	word-break: normal;
}

.entry-content > :is(p, figure) img,
.entry-content > img {
	border-radius: 10px;
}

.entry-content > figure {
	margin: 1.75em 0;
}

.entry-content figcaption {
	margin-top: 0.6em;
	font-size: 0.8125rem;
	color: var(--cl-muted);
	text-align: center;
}

.entry-content > hr {
	margin: 2.5em auto;
	border: 0;
	height: 1px;
	background: var(--cl-line);
}

/* =========================================================
   09. 글 목록(홈·카테고리·검색)
   ========================================================= */
:is(.blog, .archive, .search) .entry-title {
	font-size: clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem);
	line-height: 1.45;
}

:is(.blog, .archive, .search) .entry-title a {
	color: var(--cl-text);
	transition: color 0.15s;
}

:is(.blog, .archive, .search) .entry-title a:hover {
	color: var(--cl-accent);
}

.entry-summary {
	color: var(--cl-muted);
	line-height: 1.75;
}

.read-more-container a,
a.read-more {
	font-weight: 600;
	text-decoration: none;
}

.page-header .page-title {
	font-weight: 800;
	letter-spacing: -0.02em;
}

/* 페이지 번호 */
.paging-navigation .page-numbers {
	display: inline-grid;
	place-items: center;
	min-width: 2.25em;
	height: 2.25em;
	padding: 0 0.5em;
	border-radius: 8px;
	text-decoration: none;
}

.paging-navigation .page-numbers.current {
	background: var(--cl-accent);
	color: #fff;
}

/* =========================================================
   10. 모바일
   ========================================================= */
@media (max-width: 768px) {
	:root {
		--cl-lh: 1.75;
		--cl-radius-lg: 12px;
	}

	.entry-content > h2 {
		margin-top: 2.4em;
	}

	/* 휴대폰: 카드를 화면 끝까지 평평하게 (양 끝에 붙은 둥근 테두리 제거, 읽는 폭 확보) */
	.separate-containers .inside-article,
	.separate-containers .comments-area,
	.separate-containers .page-header,
	.separate-containers .paging-navigation {
		border-left: 0;
		border-right: 0;
		border-radius: 0;
		box-shadow: none;
	}

	/* 휴대폰 반응형 광고는 대부분 높이 250~280px 로 채워진다 → 그만큼 미리 비워 둔다 */
	.code-block ins.adsbygoogle:not([data-ad-status="unfilled"]) {
		min-height: 280px;
	}

	/* 좁은 화면: 칸을 내용 폭만큼(최대 15em) 두고 표 전체를 옆으로 밀어 본다.
	   칸이 한두 글자 폭으로 찌그러져 세로로 길어지는 것을 막는다. */
	.entry-content > :is(.cl-table, .wp-block-table) table {
		width: max-content;
		min-width: 100%;
	}

	.entry-content > :is(.cl-table, .wp-block-table) :is(th, td) {
		min-width: 5em;
		max-width: 15em;
		padding: 0.7em 0.85em;
	}

	.single .entry-header {
		margin-bottom: 1.5rem;
		padding-bottom: 1.25rem;
	}
}

/* =========================================================
   11. 움직임 줄이기·인쇄
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
	*,
	*::before,
	*::after {
		transition: none !important;
		animation: none !important;
	}
}

@media print {
	.site-header,
	.main-navigation,
	.site-footer,
	.comments-area,
	.paging-navigation {
		display: none !important;
	}

	.separate-containers .inside-article {
		border: 0;
		box-shadow: none;
	}

	.entry-content > .cl-table {
		overflow: visible;
	}
}
