/* 기본 스타일 — Simche: 리셋, 타이포그래피, 레이아웃 도구, 본문(prose)
   tokens.css 다음에 불러온다(functions.php). 서체는 시스템 서체 스택이다(theme.json fontFamilies) — 웹 서체는 자식 테마가 fontFace로 더한다.
   영문 사이트 기준이다. 한글 조판 규칙(keep-all, 행간 1.7)을 쓰지 않는다.
   의미 토큰만 쓴다. 원시 값과 임의 값을 직접 쓰지 않는다. */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  /* 붙어 있는 헤더가 앵커로 이동한 제목과 포커스된 요소를 가리지 않게 한다 */
  scroll-padding-top: calc(var(--header-height) + var(--space-6));
}

/* 글자색·바탕·서체·크기·행간은 theme.json의 styles가 body에 준다(사이트 편집기 Styles가 바꿀 수 있어야 하므로 여기서 다시 선언하지 않는다).
   여기에는 theme.json으로 표현할 수 없는 것만 둔다 */
body {
  margin: 0;
  overflow-wrap: break-word;
  font-variant-numeric: tabular-nums; /* 장 번호와 절 번호가 세로로 줄을 선다 */
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p, ul, ol, dl, dd, figure, blockquote, pre { margin: 0; }
/* 클래스가 붙은 목록은 컴포넌트다 — 코어의 목록 블록(.wp-block-list)은 예외: 글머리표와 번호를 지킨다.
   :where로 명시도를 낮게 두어 컴포넌트 CSS가 항상 이긴다 */
:where(ul, ol)[class]:where(:not(.wp-block-list)) { padding: 0; list-style: none; }
img, svg, video { display: block; max-width: 100%; }
img, video { height: auto; }
button, input, select, textarea { font: inherit; letter-spacing: inherit; color: inherit; }
button { cursor: pointer; }
table { border-collapse: collapse; width: 100%; }
th { text-align: left; }
/* 링크의 기본 색과 밑줄은 theme.json(styles.elements.link)이 준다 — 별색. 자기 색을 가진 컴포넌트의 링크(.brand, .site-nav__link, .pager__link …)는 그 색을 적는다 */
[hidden] { display: none !important; }

:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-offset);
  border-radius: var(--radius-tag);
}

::selection { background: var(--color-highlight); color: var(--color-text); }

/* ── 타이포그래피 ── */

/* 제목 요소(h1~h6)의 서체·굵기·크기·행간·자간은 theme.json의 styles.elements가 준다. 여기서는 줄바꿈 균형만.
   .text-* 는 요소와 무관하게 그 단계의 크기를 쓰는 유틸리티다 */
h1, h2, h3, h4, .text-display, .text-h1, .text-h2, .text-h3 { text-wrap: balance; }
.text-display, .text-h1, .text-h2, .text-h3, .text-h4 { font-family: var(--font-heading); font-weight: var(--weight-heading); }

.text-display { font-size: var(--text-display); line-height: var(--leading-display); letter-spacing: var(--tracking-display); font-weight: var(--weight-display); }
.text-h1 { font-size: var(--text-h1); line-height: 1.12; letter-spacing: var(--tracking-display); }
.text-h2 { font-size: var(--text-h2); line-height: var(--leading-heading); letter-spacing: var(--tracking-heading); }
.text-h3 { font-size: var(--text-h3); line-height: 1.3; letter-spacing: var(--tracking-heading); }
.text-h4 { font-size: var(--text-body); line-height: 1.4; }

p { text-wrap: pretty; }

.text-body-lg { font-size: var(--text-body-lg); line-height: 1.5; }
.text-body { font-size: var(--text-body); line-height: var(--leading-body); }
.text-small { font-size: var(--text-small); line-height: var(--leading-small); }
.text-label { font-size: var(--text-label); line-height: var(--leading-label); font-weight: var(--weight-semibold); }
.text-muted { color: var(--color-text-muted); }

/* 코드 서체는 코드에만 쓴다. 라벨이나 수치의 장식으로 쓰지 않는다 */
code, kbd, samp, pre { font-family: var(--font-code); font-variant-ligatures: none; }
code { font-size: var(--text-code); }
pre code { font-size: inherit; }

/* ── 레이아웃 도구 ── */

.container { width: 100%; max-width: calc(var(--container-base) + var(--space-page) * 2); margin-inline: auto; padding-inline: var(--space-page); }
.container--wide { max-width: calc(var(--container-wide) + var(--space-page) * 2); }
.container--prose { max-width: calc(var(--container-prose) + var(--space-page) * 2); }

.section { padding-block: var(--space-section); }
.section--tight { padding-block: var(--space-section-tight); }
.section--loose { padding-block: var(--space-section-loose); }
.section--sunken { background: var(--color-surface-sunken); }
.section--inverse { background: var(--color-surface-inverse); color: var(--color-text-inverse); }
.section--ruled { border-block-start: var(--border-1) solid var(--color-border); }

/* 세로 흐름: 자식 사이 간격만 준다. --flow로 간격을 바꾼다 */
.flow > * + * { margin-block-start: var(--flow, var(--space-4)); }

.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap, var(--space-3)); }

.measure { max-width: var(--container-prose); }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

.skip-link {
  position: absolute; left: var(--space-3); top: -4rem; z-index: var(--z-toast);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface-inverse); color: var(--color-text-inverse);
  border-radius: var(--radius-control);
}
.skip-link:focus { top: var(--space-3); }
@media (width <= 1023px) { .skip-link--wide { display: none; } }

/* 아이콘 원본(symbol)을 담는 svg */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ── 아이콘: 선형, 24 그리드, currentColor ── */

.icon {
  width: 1.25rem; height: 1.25rem; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
}
.icon--sm { width: 1rem; height: 1rem; stroke-width: 2; }
/* 문장 속에 놓이는 아이콘 */
.icon--inline { display: inline-block; width: 0.9em; height: 0.9em; margin-inline-start: 0.3em; vertical-align: -0.08em; }

/* ── 본문(prose): 동기화가 가이드 원본에서 만들어 내는 긴 글 ──
   문단과 목록은 읽는 폭(--container-prose)에서 끊고, 표와 코드는 칸의 폭을 다 쓴다. */

.prose > * + * { margin-block-start: var(--space-5); }
.prose > :where(p, ul, ol, blockquote, h2, h3, h4) { max-width: var(--container-prose); }

.prose h2 { margin-block-start: var(--space-16); scroll-margin-top: calc(var(--header-height) + var(--space-6)); }
.prose h3 { margin-block-start: var(--space-10); scroll-margin-top: calc(var(--header-height) + var(--space-6)); }
.prose h2 + *, .prose h3 + * { margin-block-start: var(--space-4); }
.prose > :first-child { margin-block-start: 0; }

/* 클래스가 붙은 링크와 목록은 컴포넌트다. 본문 규칙이 건드리지 않는다(코어 목록 블록은 본문 목록으로 본다).
   링크의 색은 theme.json의 styles.elements.link가 준다 — 여기서는 밑줄의 두께와 위치만 */
.prose a:not([class]) { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
.prose a:not([class]):hover { text-decoration-thickness: 2px; }
.prose strong { font-weight: var(--weight-semibold); }
.prose :is(ul, ol):where(:not([class]), .wp-block-list) { padding-inline-start: 1.5em; }
.prose :is(ul, ol):where(:not([class]), .wp-block-list) > li + li { margin-block-start: var(--space-2); }
.prose li > ul, .prose li > ol { margin-block-start: var(--space-2); }
.prose li::marker { color: var(--color-text-muted); }
.prose blockquote {
  padding: var(--space-4) var(--space-5);
  border-inline-start: var(--border-2) solid var(--color-border-strong);
  background: var(--color-surface-sunken);
  color: var(--color-text);
}
.prose hr { border: 0; border-block-start: var(--border-1) solid var(--color-border); margin-block: var(--space-12); }

/* 문장 속 코드. 긴 토막(jikji_post('title', $post))이 넘치면 아무 데서나 끊는다 */
.prose :not(pre) > code {
  padding: 0.08em 0.22em;
  background: var(--color-surface-sunken);
  border-radius: var(--radius-tag);
  overflow-wrap: anywhere;
}
.prose a > code { color: inherit; }
/* 제목 속 코드(5.2의 함수 서명 등): 바탕 없이, 제목보다 한 단계 작게 */
.prose :is(h2, h3) > code { padding: 0; font-size: 0.8em; font-weight: var(--weight-medium); letter-spacing: -0.02em; background: none; }
/* j: 와 wp: 속성 이름은 어디서나 별색이다(보라색인 것이 Jikji가 처리하는 것) */
.prose :not(pre) > code.is-jikji, code.is-jikji { color: var(--code-jikji); background: var(--code-jikji-bg); }

/* 절 번호: 넓은 화면에서는 본문 왼쪽 여백에 걸린다. 본문이 번호로 서로를 인용한다(Styles 4.1) */
.secno { color: var(--color-text-muted); font-weight: var(--weight-regular); margin-inline-end: 0.4em; }

@media (width > 1023px) {
  .prose--numbered, .has-secno-gutter { padding-inline-start: var(--secno-width); }
  .prose--numbered h2 { position: relative; }
  .prose--numbered h2 > .secno {
    position: absolute; inset-inline-end: 100%; inset-block-start: 0;
    margin-inline-end: var(--space-4);
    font-size: var(--text-h3); line-height: calc(var(--text-h2) * var(--leading-heading)); letter-spacing: 0;
    white-space: nowrap;
  }
}

/* 제목 옆의 고리: 그 절의 주소. 포인터를 올리거나 포커스하면 보이고, 터치 화면에서는 항상 보인다 */
.heading-anchor {
  margin-inline-start: 0.35em;
  color: var(--color-text-muted); text-decoration: none; font-weight: var(--weight-regular);
  opacity: 0;
}
.prose .heading-anchor { color: var(--color-text-muted); text-decoration: none; }
.heading-anchor:focus-visible, :is(h2, h3):hover > .heading-anchor { opacity: 1; }
@media (hover: none) { .heading-anchor { opacity: 1; } }

/* ── 모션 줄이기 ── */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
