/* =========================================================================
   보숲 base.css (design_v2.md v2.1)
   - 리셋, 기본 타이포, 접근성 기본값, 전환 애니메이션
   - §4-0 규칙: 요소 선택자는 reset 한정. 시각 타이포는 클래스 기반.
     (LLM 리포트 본문 `.report-generated` 내부로 글로벌 스타일이 새 나가지 않도록)
   ========================================================================= */

/* -------------------------------------------------------------------------
   1) 리셋 — §4-0 규칙에 따라 .report-generated 내부로 누수 위험이 있는
      요소 리셋(h1-h6, p, ul, ol, blockquote, img 등 margin/display)은
      **의도적으로 제거**. LLM 리포트 본문의 문단 간격을 보존한다.
      타이포 margin은 §4 클래스에서만, 본문 문단 rhythm은 `.prose`에서.
   ------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

/* attribute selector — 무클래스 ul/ol(= LLM 본문 리스트)은 건드리지 않음 */
ul[class],
ol[class] {
  padding: 0;
  list-style: none;
}

/* form 컨트롤 — LLM 리포트에서 거의 사용 안 됨, 안전 */
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

/* -------------------------------------------------------------------------
   2) 바디 기본 — 폰트 스택 · 본문 색 · 배경
   (요소 선택자지만 body는 최상위. `.report-generated`는 LLM <style>이 덮어씀)
   ------------------------------------------------------------------------- */
html {
  /* §9.1 테마 전환 애니메이션 (토큰 기반 팔레트가 자식 요소까지 자연 전파) */
  transition:
    background-color 200ms var(--ease),
    color 200ms var(--ease);
}

body {
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.75;
  letter-spacing: -0.005em;
  color: var(--ink-900);
  background: var(--paper);
  min-height: 100vh;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* -------------------------------------------------------------------------
   3) 링크 — 뉴트럴 베이스만. 시각 스타일은 컨테이너/클래스 단에서 결정.
   ------------------------------------------------------------------------- */
a {
  color: inherit;
  text-decoration: none;
}

/* 본문 영역 내 링크는 Navy 밑줄 (§2 navy-underline) */
.prose a,
.body-read a {
  color: var(--navy);
  text-decoration: underline;
  text-decoration-color: var(--navy-underline);
  text-underline-offset: 3px;
  transition:
    text-decoration-color 150ms var(--ease),
    color 150ms var(--ease);
}

.prose a:hover,
.body-read a:hover {
  color: var(--navy-hover);
  text-decoration-color: var(--navy);
}

/* -------------------------------------------------------------------------
   4) 타이포 위계 — 클래스 기반 (§3)
   ------------------------------------------------------------------------- */

/* Hero Display — 홈 히어로 (fluid: 32→56px) */
.h-hero {
  font-size: var(--fs-hero);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--ink-900);
}

/* Page Title — 리포트 상세 H1 (fluid: 26→36px) */
.h-page {
  font-size: var(--fs-page);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--ink-900);
}

/* Section Heading (fluid: 20→24px) */
.h-section {
  font-size: var(--fs-section);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.015em;
  color: var(--ink-900);
}

/* Sub-heading — 카드 타이틀, 위젯 헤더, 콜아웃 라벨 */
.h-sub {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: -0.01em;
  color: var(--ink-900);
}

/* Body Large — 리포트 본문 정독 표준 (§3 비타협) */
.body-read {
  font-size: 17px;
  font-weight: 400;
  line-height: 1.8;
  letter-spacing: -0.005em;
  color: var(--ink-900);
}

/* Body — 리스트 설명·일반 본문 */
.body {
  font-size: 16px;
  font-weight: 400;
  line-height: 1.75;
  letter-spacing: -0.005em;
  color: var(--ink-900);
}

/* 강조 */
.body-emphasis {
  font-weight: 600;
  color: var(--ink-900);
}

/* Meta / Caption */
.meta {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  letter-spacing: 0;
  color: var(--ink-500);
}

/* Mono Kicker — "INVESTMENT NOTE" 등 UPPERCASE */
.kicker {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--forest);
}

/* Mono Meta — 카테고리 라벨, 섹션 인덱스 */
.mono-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-500);
}

/* Ticker Mono — 종목코드·출처 라벨 */
.ticker {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  letter-spacing: 0;
}

/* Pull Quote (Serif) */
.serif {
  font-family: var(--font-serif);
  font-weight: 700;
  letter-spacing: -0.015em;
}

/* 숫자 — 모든 수치·퍼센트는 반드시 tabular-nums */
.numeric,
.num {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

/* -------------------------------------------------------------------------
   4-b) Prose 컨테이너 — 편집자가 쓴 본문(.prose)에만 자동 문단 rhythm 부여.
        LLM 리포트(.report-generated)에는 적용되지 않으므로 누수 위험 없음.
   ------------------------------------------------------------------------- */
.prose {
  font-size: 17px;
  line-height: 1.8;
  letter-spacing: -0.005em;
  color: var(--ink-900);
}

.prose > * + * {
  margin-top: 1.3em;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4 {
  margin-top: 2em;
  margin-bottom: 0.6em;
  line-height: 1.35;
  letter-spacing: -0.015em;
  color: var(--ink-900);
}

.prose h1 { font-size: 32px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.3; }
.prose h2 { font-size: 24px; font-weight: 700; }
.prose h3 { font-size: 20px; font-weight: 700; }
.prose h4 { font-size: 18px; font-weight: 600; }

.prose ul,
.prose ol {
  padding-left: 1.4em;
}

.prose li {
  margin-top: 0.4em;
}

.prose strong {
  font-weight: 600;
  color: var(--ink-900);
}

.prose blockquote {
  margin: 1.5em 0;
  padding: 0 0 0 16px;
  border-left: 3px solid var(--hairline);
  color: var(--ink-700);
}

.prose figure {
  margin: 1.5em 0;
}

.prose figcaption {
  margin-top: 8px;
  font-size: 13px;
  color: var(--ink-500);
  text-align: center;
}

.prose img {
  max-width: 100%;
  height: auto;
  border-radius: var(--r-8);
}

.prose table {
  width: 100%;
  font-variant-numeric: tabular-nums;
  border-collapse: collapse;
  margin: 1.5em 0;
}

.prose th,
.prose td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--hairline-soft);
  text-align: left;
}

.prose th {
  font-weight: 600;
  color: var(--ink-900);
  background: var(--paper-warm);
}

/* -------------------------------------------------------------------------
   5) 반응형 타이포 (§7) — 2026-04-29 fluid 전환
   디스플레이 3종은 tokens.css의 --fs-* (clamp())로 320~1280px 구간 자동 스케일.
   본문(.body-read 17px / .body 16px)·meta·mono는 모든 구간 고정 (비타협).
   ------------------------------------------------------------------------- */

/* -------------------------------------------------------------------------
   6) 접근성 기본값 (§6.1, §7.1)
   ------------------------------------------------------------------------- */

/* (1) Skip-link — 본문 바로가기 */
.skip-link {
  position: absolute;
  left: -9999px;
  top: -9999px;
  background: var(--navy);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--r-8);
  font-size: 14px;
  font-weight: 600;
  z-index: 100;
  text-decoration: none;
}

.skip-link:focus {
  left: 16px;
  top: 16px;
}

/* (2) SR-only — 스크린리더 전용 */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* (3) Focus-visible 전역 (§6.1) */
:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
  border-radius: var(--r-4);
}

:focus:not(:focus-visible) {
  outline: none;
}

/* 주요 인터랙티브 요소는 outline + focus ring 중첩 */
.btn:focus-visible,
.icon-btn:focus-visible,
.chip:focus-visible,
.nav a:focus-visible,
.back:focus-visible,
.toc a:focus-visible,
.faq summary:focus-visible,
.related a:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
  box-shadow: var(--sh-focus);
}

/* -------------------------------------------------------------------------
   7) 상태 훅 — 레이아웃 전환용 body 클래스 (§4-1-a 보존)
   ------------------------------------------------------------------------- */
body.detail-page {
  background: var(--paper);
}

body.detail-page .site-main {
  padding: 0;
}

body.full-width .site-main {
  padding: 0;
}

@media (max-width: 768px) {
  body.detail-page .site-main {
    padding: 0;
  }
}

/* -------------------------------------------------------------------------
   8) 스크롤바 (WebKit)
   ------------------------------------------------------------------------- */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--hairline);
  border-radius: var(--r-4);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}

/* -------------------------------------------------------------------------
   9) Reduced motion (§8)
   ------------------------------------------------------------------------- */
@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;
  }

  html {
    transition: none;
  }
}

/* -------------------------------------------------------------------------
   10) 유틸 컨테이너
   ------------------------------------------------------------------------- */
.container {
  max-width: var(--w-site);
  margin: 0 auto;
  padding: 0 24px;
}

.read-container {
  max-width: var(--w-read);
  margin: 0 auto;
  padding: 0 24px;
}

@media (max-width: 640px) {
  .container,
  .read-container {
    padding: 0 20px;
  }
}
