/* 가이드 사이트 공통 스타일. 색은 tokens.css의 역할 변수만 쓴다(순백·순흑·원시 brand 변수 금지, tools/guide.test.ts).
   구분선·표 테두리는 본문 글 색의 15% 알파 — 파생 색 규칙이 아직 없어서 color-mix로만 만든다. */
@font-face {
  font-family: Pretendard;
  font-weight: 400;
  src: url(fonts/Pretendard-Regular.ttf) format('truetype');
  font-display: swap;
}
@font-face {
  font-family: Pretendard;
  font-weight: 700;
  src: url(fonts/Pretendard-Bold.ttf) format('truetype');
  font-display: swap;
}

:root {
  --line: color-mix(in srgb, var(--color-text-body) 15%, transparent);
  --soft: color-mix(in srgb, var(--color-text-body) 62%, transparent);
  --tint: color-mix(in srgb, var(--color-text-emphasis) 10%, transparent);
  --card: var(--color-neutral-white);
  --top-h: 56px;
  /* ⚠️ 주의 콜아웃: 토큰에 노랑 계열이 없어서 패널 주의 띠(sidepanel.css --warn)와 같은 값을 쓴다 */
  --warn-bg: #fdf6e4;
  --warn-fg: #5c4610;
}
[data-theme='dark'] {
  /* 다크에서 카드는 배경 위 반투명 */
  --card: color-mix(in srgb, var(--color-neutral-white) 8%, transparent);
  --warn-bg: #3b3216;
  --warn-fg: #f1deaa;
}

* {
  box-sizing: border-box;
}
html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--top-h) + 16px);
}
body {
  margin: 0;
  background: var(--color-bg-canvas);
  color: var(--color-text-body);
  font:
    16px/1.7 Pretendard,
    -apple-system,
    'Apple SD Gothic Neo',
    'Malgun Gothic',
    sans-serif;
  overflow-wrap: anywhere;
}
a {
  color: var(--color-text-emphasis);
}
h1,
h2,
h3 {
  color: var(--color-text-heading);
  line-height: 1.35;
}
h1 {
  font-size: 2rem;
  margin: 0 0 0.4em;
}
h2 {
  font-size: 1.5rem;
  margin: 2.2em 0 0.6em;
}
h3 {
  font-size: 1.15rem;
  margin: 1.8em 0 0.4em;
}
img {
  max-width: 100%;
  height: auto;
}
code {
  font-size: 0.92em;
}

/* 상단바 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  height: var(--top-h);
  padding: 0 20px;
  background: var(--color-bg-canvas);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-text-heading);
  text-decoration: none;
  font-weight: 700;
  white-space: nowrap;
  min-width: 0;
}
.brand span:not(.brand-sub) {
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand-sub {
  font-weight: 400;
  font-size: 0.8rem;
  color: var(--soft);
}
.cta {
  display: inline-block;
  margin-left: auto;
  padding: 6px 16px;
  border-radius: 999px;
  background: var(--color-button-primary-bg);
  color: var(--color-button-primary-fg);
  font-size: 0.9rem;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.theme-btn {
  margin-left: auto;
  min-width: 44px;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: none;
  color: var(--color-text-heading);
  font-size: 0; /* 글자는 숨기고 아이콘은 ::before로 그린다 */
  cursor: pointer;
}
.theme-btn::before {
  content: '🌙';
  font-size: 1.15rem;
}
[data-theme='dark'] .theme-btn::before {
  content: '☀️';
}
.topbar .cta {
  margin-left: 0;
}
.menu-btn {
  display: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: none;
  color: var(--color-text-heading);
  font-size: 1.1rem;
  padding: 4px 10px;
}

/* 3단 배치: 사이드바 240 · 본문(최대 760) · 목차 200 */
.layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 760px) 200px;
  gap: 40px;
  justify-content: center;
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 20px;
}
main {
  min-width: 0;
  padding: 32px 0 80px;
}
.sidebar,
.toc {
  position: sticky;
  top: var(--top-h);
  align-self: start;
  max-height: calc(100vh - var(--top-h));
  overflow-y: auto;
  padding: 24px 0;
  font-size: 0.92rem;
}
.sidebar ul,
.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.sb-group {
  margin-bottom: 20px;
}
.sb-title,
.toc-title {
  margin-bottom: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--soft);
}
.sidebar a,
.toc a {
  display: block;
  padding: 4px 10px;
  border-radius: 6px;
  color: var(--color-text-body);
  text-decoration: none;
}
.sidebar a:hover,
.toc a:hover {
  background: var(--tint);
}
.sidebar a.is-active,
.sidebar a.is-current,
.toc a.is-current {
  color: var(--color-text-emphasis);
  font-weight: 700;
}
.sb-sub {
  margin: 2px 0 6px 10px;
  padding-left: 8px;
  border-left: 1px solid var(--line);
}
.toc {
  border-left: 1px solid var(--line);
  padding-left: 16px;
}
.toc .l3 a {
  padding-left: 22px;
  font-size: 0.86rem;
}

/* 배지 */
.badge {
  display: inline-block;
  margin-left: 6px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.6;
  vertical-align: middle;
}
.badge.new {
  background: var(--color-button-primary-bg);
  color: var(--color-button-primary-fg);
  border-color: transparent;
}

/* 홈 */
.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--color-text-body);
  text-decoration: none;
  font-size: 0.92rem;
}
.banner .badge {
  margin: 0;
}
.banner time {
  margin-left: auto;
  color: var(--soft);
}
.hero {
  padding: 32px 0 8px;
}
.hero .lead {
  margin: 0 0 4px;
  font-size: 1.1rem;
}
.hero .cta {
  margin: 16px 0 0;
  padding: 10px 24px;
}
.home h2 {
  margin-top: 2.6em;
}
/* 홈 h2만: 제목 위 짧은 포인트 라인(브랜드 요소) */
.home h2::before {
  content: '';
  display: block;
  width: 40px;
  height: 4px;
  margin-bottom: 12px;
  border-radius: 2px;
  background: var(--color-accent-line);
}
.home h2 em,
.hero h1 em {
  font-style: normal;
  color: var(--color-text-emphasis);
}
.cards {
  align-items: start;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.card {
  display: block;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--color-text-body);
  text-decoration: none;
}
a.card:hover {
  border-color: var(--color-text-emphasis);
}
.card .label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--color-text-emphasis);
}
.card-title {
  display: block;
  margin: 2px 0 4px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text-heading);
}
.card p {
  margin: 0;
  font-size: 0.92rem;
}
.shot {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 10px 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.card .shot {
  width: 100%;
  margin: 10px 0 0;
}
.chapter ol {
  margin: 10px 0 0;
  padding-left: 20px;
  font-size: 0.9rem;
}
.chapter li a {
  text-decoration: none;
}
.sub-lead {
  margin: -0.3em 0 1em;
  color: var(--soft);
}

/* 업데이트 기록 타임라인 */
.timeline {
  list-style: none;
  margin: 0;
  padding: 0 0 0 18px;
  border-left: 2px solid var(--line);
}
.tl-item {
  position: relative;
  padding: 0 0 18px 8px;
}
.tl-item::before {
  content: '';
  position: absolute;
  left: -25px;
  top: 9px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-text-emphasis);
}
.tl-item time {
  display: block;
  font-size: 0.82rem;
  color: var(--soft);
}
.tl-item .ver {
  margin-left: 8px;
  font-size: 0.82rem;
  color: var(--soft);
}

/* 시작하기 단계 */
.steps {
  list-style: none;
  counter-reset: step;
  margin: 0;
  padding: 0;
}
.step {
  position: relative;
  counter-increment: step;
  padding: 0 0 14px 44px;
}
.step::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--color-text-emphasis);
  color: var(--color-bg-canvas);
  font-weight: 700;
  text-align: center;
  line-height: 30px;
}
.step b {
  display: block;
  color: var(--color-text-heading);
}

/* 콜아웃 · 표 · 이미지 · 이전/다음 */
.callout {
  margin: 16px 0;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--tint);
}
.callout.warn {
  background: var(--warn-bg);
  color: var(--warn-fg);
}
.callout p {
  margin: 0;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.94rem;
}
th,
td {
  padding: 8px 10px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
th {
  background: var(--card);
}
.shot {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.pager {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 56px;
}
.pg {
  display: block;
  max-width: 48%;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--color-text-body);
  text-decoration: none;
}
.pg small {
  display: block;
  color: var(--soft);
}
.pg.next {
  margin-left: auto;
  text-align: right;
}
.foot {
  margin-top: 56px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 0.9rem;
}

/* FAQ */
.qa {
  list-style: none;
  margin: 0;
  padding: 0;
}
.qa-line {
  padding: 4px 0;
}
.qa-line > b {
  display: inline-block;
  min-width: 5.5em;
  margin-right: 8px;
  color: var(--color-text-emphasis);
}
.qa-line ul {
  margin: 4px 0 0;
  padding-left: 1.2em;
}

/* FAQ 토글: summary 줄은 터치 44px 이상, ▸/▾는 CSS로(글자에 섞지 않는다) */
.faq-hint {
  color: var(--soft);
}
.topic-meta {
  margin: 0 0 8px;
  color: var(--soft);
}
.toggle-all {
  min-height: 44px;
  margin-bottom: 8px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: none;
  color: var(--color-text-emphasis);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
details {
  border-bottom: 1px solid var(--line);
  scroll-margin-top: calc(var(--top-h) + 16px);
}
summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 0;
  color: var(--color-text-heading);
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
summary::-webkit-details-marker {
  display: none;
}
summary::before {
  content: '▸';
  flex: none;
  color: var(--color-text-emphasis);
}
details[open] > summary::before {
  content: '▾';
}
details > :not(summary) {
  margin-left: 22px;
}
details > .qa {
  padding: 0 0 12px;
}
details > :last-child {
  margin-bottom: 14px;
}
details > table {
  width: calc(100% - 22px);
}
.lbl {
  margin-right: 8px;
  color: var(--color-text-emphasis);
}
.intro {
  margin: 0 0 8px;
}
.related {
  color: var(--soft);
  font-size: 0.92rem;
}

/* 개인정보처리방침(본문은 옮기기 전 그대로) */
.meta {
  color: var(--soft);
  font-size: 0.9em;
}
.en {
  margin-top: 3em;
  padding-top: 1em;
  border-top: 2px solid var(--line);
  font-size: 0.95em;
}

.nav-backdrop {
  display: none;
}

/* 폰 폭: 사이드바는 햄버거로 접고 목차는 숨긴다. 가로 스크롤 없음 */
@media (max-width: 900px) {
  .layout {
    display: block;
    padding: 0 16px;
  }
  .toc {
    display: none;
  }
  .menu-btn {
    display: block;
  }
  .sidebar {
    position: fixed;
    top: var(--top-h);
    left: 0;
    bottom: 0;
    z-index: 15;
    width: min(280px, 85vw);
    max-height: none;
    align-self: stretch; /* 기본의 start면 abspos가 내용 높이로 줄어 화면 아래까지 안 덮는다 */
    padding: 16px;
    background: var(--color-bg-canvas);
    border-right: 1px solid var(--line);
    transform: translateX(-100%);
    transition: transform 0.2s;
  }
  .nav-open .sidebar {
    transform: none;
  }
  /* 열렸을 때 본문을 덮는 반투명 막(본문 글 색 알파). 누르면 닫힌다 */
  .nav-open .nav-backdrop {
    display: block;
    position: fixed;
    inset: var(--top-h) 0 0;
    z-index: 14;
    background: color-mix(in srgb, var(--color-text-body) 45%, transparent);
  }
  /* 다크에선 본문 글 색이 밝아서 막이 밝은 회색이 된다 → 어두운 canvas 색 기반 */
  [data-theme='dark'] .nav-open .nav-backdrop {
    background: color-mix(in srgb, var(--color-bg-canvas) 60%, transparent);
  }
  .cards {
    grid-template-columns: minmax(0, 1fr);
  }
  h1 {
    font-size: 1.6rem;
  }
  main table {
    display: block;
    overflow-x: auto;
  }
  .topbar {
    padding: 0 12px;
  }
  .brand-sub {
    display: none;
  }
}

/* 320px까지: 메뉴·이름·테마·웹스토어 버튼이 한 줄에 들어가게 줄인다(이름은 한 줄, 모자라면 말줄임) */
@media (max-width: 480px) {
  .topbar {
    gap: 6px;
    padding: 0 8px;
  }
  .brand {
    gap: 6px;
    font-size: 0.85rem;
  }
  .topbar .cta {
    padding: 6px 10px;
    font-size: 0.8rem;
  }
}
