/* ===== SELF-HOSTED FONTS (Zero CLS — fontpie metric fallbacks) ===== */

/* Source Serif 4 — variable, latin, self-hosted */
@font-face {
  font-family: 'Source Serif 4';
  font-style: normal;
  font-weight: 200 900;
  font-display: swap;
  src: url('./fonts/source-serif-4-latin-wght-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC,
    U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* JetBrains Mono — variable, latin, self-hosted */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url('./fonts/jetbrains-mono-latin-wght-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6,
    U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC,
    U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Fallback: Times New Roman adjusted to Source Serif 4 metrics (fontpie) */
@font-face {
  font-family: 'Source Serif 4 Fallback';
  font-style: normal;
  font-weight: 400;
  src: local('Times New Roman');
  ascent-override: 87.45%;
  descent-override: 28.28%;
  line-gap-override: 0.00%;
  size-adjust: 118.46%;
}

/* Fallback: Courier New adjusted to JetBrains Mono metrics (fontpie) */
@font-face {
  font-family: 'JetBrains Mono Fallback';
  font-style: normal;
  font-weight: 400;
  src: local('Courier New');
  ascent-override: 102.02%;
  descent-override: 30.00%;
  line-gap-override: 0.00%;
  size-adjust: 99.98%;
}

:root {
  color-scheme: light;
  --bg: #faf8f4;
  --fg: #1a1a18;
  --muted: #8a8680;
  --accent: #c43e2a;
  --rule: #d5d0c8;
  --card-bg: #f2efe9;
  --prose: #3a3a36;
  --secondary: #6a6862;
  --serif: 'Source Serif 4', 'Source Serif 4 Fallback', 'Pretendard Variable', 'Pretendard', serif;
  --mono: 'JetBrains Mono', 'JetBrains Mono Fallback', 'Courier New', monospace;
}

/* Dark Mode */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1c1b18;
  --fg: #e2ded6;
  --muted: #8a8680;
  --accent: #e0604e;
  --rule: #3a3632;
  --card-bg: #26241f;
  --prose: #c4bfb6;
  --secondary: #9a9690;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  touch-action: manipulation;        /* 모바일 300ms 탭 딜레이 제거, 즉시 스크롤 */
}

body {
  font-family: var(--serif);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.85;
  -webkit-font-smoothing: antialiased;
  font-variant-numeric: lining-nums tabular-nums;
  overscroll-behavior-y: none;        /* pull-to-refresh / 스크롤 체이닝 방지 */
}

.page {
  max-width: 780px;
  margin: 0 auto;
  padding: 80px 40px 100px;
}

/* MASTHEAD */
.masthead {
  text-align: center;
  padding-bottom: 56px;
  border-bottom: 1px solid var(--fg);
  margin-bottom: 64px;
}

.masthead .issue {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 32px;
}

.masthead h1 {
  font-size: 3.2rem;
  font-weight: 400;
  line-height: 1.2;
  letter-spacing: -1.5px;
  color: var(--fg);
  margin-bottom: 16px;
}

.masthead h1 strong {
  font-weight: 900;
  color: var(--accent);
}

.masthead .deck {
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--muted);
  max-width: 520px;
  margin: 0 auto;
  line-height: 1.7;
}

/* SECTION HEADERS */
.section-head {
  margin-top: 72px;
  margin-bottom: 40px;
}

.section-head .num {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 5px;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  display: block;
  margin-bottom: 10px;
}

.section-head h2 {
  font-size: 2rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.5px;
}

.section-head h2 strong {
  color: var(--accent);
}

/* PROSE */
.prose {
  font-size: 1.05rem;
  font-weight: 400;
  line-height: 1.9;
  color: var(--prose);
  margin-bottom: 28px;
}

.prose strong {
  font-weight: 700;
  color: var(--fg);
}

/* THREE COLUMN */
.mechanism-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  margin: 40px 0 48px;
}

.mechanism {
  background: var(--bg);
  padding: 32px 24px;
}

.mechanism .m-label {
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 500;
  margin-bottom: 12px;
}

.mechanism h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 10px;
  line-height: 1.3;
}

.mechanism p {
  font-size: 0.88rem;
  color: var(--secondary);
  line-height: 1.7;
}

/* PULL QUOTE */
.pull-quote {
  margin: 48px 0;
  padding: 44px 0;
  border-top: 1px solid var(--fg);
  border-bottom: 1px solid var(--fg);
  text-align: center;
}

.pull-quote p {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.6;
  color: var(--fg);
  max-width: 580px;
  margin: 0 auto;
}

.pull-quote .attr {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  margin-top: 20px;
}

/* TECHNIQUE BLOCKS */
.technique {
  margin: 48px 0;
  padding: 0 0 48px;
  border-bottom: 1px solid var(--rule);
}

.technique:last-of-type { border-bottom: none; }

.technique-header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 14px;
}

.technique-header .t-num {
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.technique-header h3 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.technique .t-sub {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 18px;
  padding-left: 52px;
}

.technique .t-body {
  background: var(--card-bg);
  padding: 24px 28px;
  font-size: 0.92rem;
  line-height: 1.85;
  color: var(--prose);
}

.technique .t-body .formula {
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent);
  display: block;
  margin: 10px 0 6px;
  letter-spacing: 0.5px;
}

/* WARNING BOX */
.warning-box {
  margin: 56px 0;
  border: 1px solid var(--fg);
  padding: 32px 36px;
  overflow-wrap: break-word;
}

.warning-box .w-title {
  font-family: var(--serif);
  font-size: 0.8rem;
  letter-spacing: 2px;
  color: var(--accent);
  font-weight: 700;
  margin-bottom: 18px;
}

.warning-list {
  list-style: none;
  counter-reset: warn;
}

.warning-list li {
  font-size: 0.9rem;
  color: var(--prose);
  padding: 8px 0 8px 28px;
  position: relative;
  border-bottom: 1px solid var(--rule);
  counter-increment: warn;
}

.warning-list li:last-child { border-bottom: none; }

.warning-list li::before {
  content: counter(warn, decimal-leading-zero);
  font-family: var(--mono);
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--accent);
  position: absolute;
  left: 0;
  top: 10px;
}

/* CLOSING */
.closing {
  margin-top: 72px;
  padding-top: 48px;
  border-top: 1px solid var(--fg);
  text-align: center;
}

.closing .big,
.closing h2 {
  font-size: 2.2rem;
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: -0.5px;
  margin-bottom: 16px;
}

.closing .big strong,
.closing h2 strong {
  font-weight: 900;
  color: var(--accent);
}

.closing .sub {
  font-size: 0.95rem;
  color: var(--muted);
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.8;
}

.footer {
  margin-top: 64px;
  padding-top: 20px;
  border-top: 1px solid var(--rule);
  text-align: center;
}

.footer p {
  font-family: var(--mono);
  font-size: 0.55rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--muted);
}

/* SCROLL PERFORMANCE — 블록 단위 레이아웃·페인트 격리로 리플로우/리페인트 범위 제한 */
.section-head,
.technique,
.mechanism-row,
.pull-quote,
.warning-box,
.closing {
  contain: layout style paint;
}

/* 뷰포트 밖 섹션의 렌더링을 건너뛰어 스크롤 성능 향상 */
.section-head,
.technique,
.pull-quote,
.warning-box,
.closing {
  content-visibility: auto;
  contain-intrinsic-size: auto 200px;
}

/* RESPONSIVE */
@media (max-width: 700px) {
  .page { padding: 48px 24px 60px; }
  .masthead h1 { font-size: 2.2rem; }
  .mechanism-row { grid-template-columns: 1fr; }
  .section-head h2 { font-size: 1.5rem; }
  .pull-quote p { font-size: 1.2rem; }
  .closing .big,
  .closing h2 { font-size: 1.6rem; }
}

@media print {
  body { background: #fff; }
  .page { padding: 40px 20px; }
}
