/* ==========================================================================
   중앙대매경 총정리본 — 모바일 학습노트
   디자인 컨셉: "손에 들고 다니는 정리노트" — 종이 카드 + 형광펜 강조 + 빨간펜 오답노트
   ========================================================================== */

:root{
  /* --- 색상 토큰 --- */
  --bg:            #F5F6F8;   /* 앱 배경: 차분한 쿨톤 페이퍼 */
  --bg-elevated:   #FFFFFF;   /* 카드/섹션 배경 */
  --ink:           #1B2333;   /* 본문 텍스트 */
  --ink-soft:      #57607A;   /* 보조 텍스트 */
  --ink-faint:     #8A93AC;   /* 캡션/메타 */
  --border:        #E3E6ED;
  --border-strong: #C9CEDC;

  --accent:        #2A5DB0;   /* 코발트블루 — 링크, 포인트 */
  --accent-ink:    #17417F;
  --accent-bg:     #E9F0FB;

  --mark-bg:       #E4F17A;   /* 형광펜 라임 */
  --mark-ink:      #2B3400;

  --danger:        #B23A2E;   /* 빨간펜 — 기출함정 */
  --danger-ink:    #7C2A21;
  --danger-bg:     #FBEBE8;

  --formula:       #9C7409;   /* 앰버/골드 — 핵심공식 */
  --formula-ink:   #6E5206;
  --formula-bg:    #FFF6DE;

  --example:       #127A6B;   /* 틸 — 사례/기출예시/비유 */
  --example-ink:   #0C5C50;
  --example-bg:    #E7F5F1;

  --radius-sm: 8px;
  --radius: 14px;
  --radius-lg: 18px;
  --shadow: 0 1px 2px rgba(20,30,50,.05), 0 6px 16px rgba(20,30,50,.05);

  --font: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Pretendard", "Malgun Gothic", "Segoe UI", sans-serif;

  --content-max: 720px;
}

*, *::before, *::after{ box-sizing: border-box; }
html{ -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
html, body{ overflow-x: hidden; max-width: 100%; }

body{
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  word-break: keep-all;         /* 한글 단어 단위 줄바꿈 */
  overflow-wrap: break-word;
}

img, svg{ max-width: 100%; height: auto; display: block; }

a{ color: var(--accent); text-decoration: none; }
a:hover, a:focus-visible{ text-decoration: underline; }

::selection{ background: var(--mark-bg); color: var(--mark-ink); }

/* --- 스킵링크(접근성) --- */
.skip-link{
  position: absolute; left: -999px; top: 0; z-index: 200;
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 0 0 8px 0;
}
.skip-link:focus{ left: 0; }

/* ==========================================================================
   헤더
   ========================================================================== */
.site-header{
  padding: 28px 20px 20px;
  background: linear-gradient(180deg, #1B2333 0%, #263156 100%);
  color: #F4F6FB;
}
.site-header__eyebrow{
  font-size: 12.5px; font-weight: 700; letter-spacing: .06em;
  color: #9FB3E8; text-transform: uppercase; margin: 0 0 8px;
}
.site-header__title{
  font-size: 21px; font-weight: 800; line-height: 1.4; margin: 0 0 6px;
  letter-spacing: -.01em;
}
.site-header__subtitle{
  font-size: 13.5px; color: #C3CCE6; margin: 0; line-height: 1.6;
}

/* ==========================================================================
   주제별 바로가기 nav (sticky)
   ========================================================================== */
.chapter-nav{
  position: sticky; top: 0; z-index: 100;
  background: rgba(27,35,51,.97);
  backdrop-filter: saturate(150%) blur(6px);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.chapter-nav__scroll{
  display: flex; gap: 8px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding: 10px 14px;
  scrollbar-width: none;
}
.chapter-nav__scroll::-webkit-scrollbar{ display: none; }
.chapter-nav__pill{
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  color: #E4E9F7;
  font-size: 13.5px; font-weight: 600; white-space: nowrap;
  border: 1px solid rgba(255,255,255,.06);
}
.chapter-nav__pill.is-active{
  background: var(--accent); color: #fff; border-color: var(--accent);
}

/* 챕터 내부 소목차 (접이식) */
.chapter-toc{
  margin: 0 16px 22px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.chapter-toc > summary{
  list-style: none; cursor: pointer;
  padding: 13px 16px;
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; font-size: 14.5px; color: var(--ink);
}
.chapter-toc > summary::-webkit-details-marker{ display:none; }
.chapter-toc > summary::after{
  content: "▾"; color: var(--ink-faint); transition: transform .2s;
  font-size: 12px;
}
.chapter-toc[open] > summary::after{ transform: rotate(180deg); }
.chapter-toc__list{
  margin: 0; padding: 2px 16px 14px 34px;
  font-size: 13.8px; color: var(--ink-soft);
  border-top: 1px solid var(--border);
  padding-top: 10px;
}
.chapter-toc__list li{ margin: 7px 0; }
.chapter-toc__list a{ color: var(--ink-soft); }
.chapter-toc__list a:hover{ color: var(--accent); }

/* ==========================================================================
   본문 레이아웃
   ========================================================================== */
main{ display: block; padding-bottom: 60px; }

.chapter{
  padding: 34px 16px 10px;
  border-top: 8px solid var(--bg);
}
.chapter:first-of-type{ border-top: none; }

.chapter__head{ margin-bottom: 22px; }
.chapter__badge{
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 700; color: var(--accent-ink);
  background: var(--accent-bg);
  padding: 5px 12px; border-radius: 999px;
  margin-bottom: 10px;
}
h1, h2, h3, h4{
  font-weight: 800; letter-spacing: -.01em; color: var(--ink);
  line-height: 1.4;
}
.chapter h2.chapter__title{
  font-size: 22px; margin: 0 0 8px;
}
.chapter__desc{
  font-size: 14px; color: var(--ink-soft); margin: 0; line-height: 1.7;
}

section.topic{ margin: 0 0 6px; }

h3.topic__title{
  font-size: 18px;
  margin: 34px 0 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--ink);
  display: flex; gap: 8px; align-items: baseline;
}
h4.topic__sub{
  font-size: 15.5px;
  margin: 22px 0 10px;
  color: var(--accent-ink);
}
h4.topic__sub::before{
  content: "◆"; font-size: 10px; margin-right: 6px; color: var(--accent);
}

p{ margin: 0 0 14px; font-size: 15.3px; }
.chapter ul, .chapter ol{ margin: 0 0 16px; padding-left: 1.3em; font-size: 15.3px; }
.chapter li{ margin: 0 0 9px; }
.chapter li > ul, .chapter li > ol{ margin-top: 8px; }

strong{ font-weight: 700; color: var(--ink); }

mark{
  background: var(--mark-bg); color: var(--mark-ink);
  padding: 0.02em 0.15em; border-radius: 3px;
}

/* ==========================================================================
   강조 박스 (콜아웃)
   ========================================================================== */
.box{
  margin: 18px 0; padding: 16px 16px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}
.box__label{
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 800; letter-spacing: .01em;
  margin: 0 0 10px;
  text-transform: uppercase;
}
.box p:last-child, .box ul:last-child, .box ol:last-child{ margin-bottom: 0; }
.box p, .box ul, .box ol{ font-size: 14.6px; }

.box--case{ border-left: 5px solid var(--accent); background: var(--accent-bg); }
.box--case .box__label{ color: var(--accent-ink); }

.box--pitfall{ border-left: 5px solid var(--danger); background: var(--danger-bg); }
.box--pitfall .box__label{ color: var(--danger-ink); }
.box--pitfall .box__wrong{ color: var(--danger-ink); }
.box--pitfall .box__right{ color: var(--ink); }

.box--formula{ border-left: 5px solid var(--formula); background: var(--formula-bg); }
.box--formula .box__label{ color: var(--formula-ink); }
.box--formula code, .box--formula .formula-line{
  display: block; font-weight: 700; font-size: 14.8px;
  color: var(--formula-ink); margin: 4px 0; font-family: var(--font);
}

.box--example{ border-left: 5px solid var(--example); background: var(--example-bg); }
.box--example .box__label{ color: var(--example-ink); }

.box--step{ border: 1px dashed var(--border-strong); background: var(--bg-elevated); }
.box--step + .box--step{ margin-top: -6px; }
.box--step .box__label{ color: var(--ink-soft); }

/* ==========================================================================
   표
   ========================================================================== */
.table-wrap{
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  margin: 18px 0; border-radius: var(--radius); border: 1px solid var(--border);
  box-shadow: var(--shadow);
  background: var(--bg-elevated);
}
table{
  border-collapse: collapse; width: 100%; min-width: 480px;
  font-size: 13.6px;
}
table caption{
  text-align: left; font-size: 12.5px; font-weight: 700; color: var(--ink-soft);
  padding: 10px 14px 0;
}
th, td{
  padding: 10px 12px; text-align: left; vertical-align: top;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
th:last-child, td:last-child{ border-right: none; }
thead th{
  background: #EFF2F8; color: var(--ink); font-weight: 700;
  white-space: nowrap;
}
tbody tr:last-child td{ border-bottom: none; }
tbody tr:nth-child(even){ background: #FAFBFD; }

/* ==========================================================================
   차트 / 이미지
   ========================================================================== */
figure.chart{
  margin: 20px 0; padding: 14px 12px 12px;
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
figure.chart .chart-svg{ width: 100%; height: auto; }
figure.chart figcaption{
  margin-top: 10px; font-size: 12.8px; color: var(--ink-soft);
  text-align: center; line-height: 1.6;
}
figure.chart figcaption .cap-index{ font-weight: 700; color: var(--ink); }

/* ==========================================================================
   푸터 / 맨 위로
   ========================================================================== */
.back-to-top{
  position: fixed; right: 16px; bottom: 16px; z-index: 90;
  width: 46px; height: 46px; border-radius: 50%;
  background: var(--ink); color: #fff; border: none;
  font-size: 18px; box-shadow: 0 4px 14px rgba(20,30,50,.25);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transform: translateY(8px);
  transition: opacity .2s, transform .2s;
}
.back-to-top.is-visible{ opacity: 1; pointer-events: auto; transform: translateY(0); }

.site-footer{
  padding: 26px 20px 40px; text-align: center;
  color: var(--ink-faint); font-size: 12.5px; line-height: 1.8;
}

/* ==========================================================================
   반응형 — 태블릿 이상
   ========================================================================== */
@media (min-width: 640px){
  body{ font-size: 16.5px; }
  .chapter{ padding-left: 24px; padding-right: 24px; }
  .site-header{ padding: 34px 24px 24px; }
  .chapter-toc{ margin-left: 24px; margin-right: 24px; }
}
@media (min-width: 760px){
  main, .site-header__inner, .chapter-nav__inner{
    max-width: var(--content-max); margin: 0 auto;
  }
  .chapter-nav__scroll{ max-width: var(--content-max); margin: 0 auto; }
}

/* 작은 화면(320px) 안전장치 */
@media (max-width: 340px){
  body{ font-size: 15px; }
  h3.topic__title{ font-size: 16.5px; }
  .site-header__title{ font-size: 19px; }
}

/* 모션 최소화 선호 */
@media (prefers-reduced-motion: reduce){
  html{ scroll-behavior: auto; }
  .back-to-top{ transition: none; }
}
