/* 교과서·분류 좌측 탐색 패널 (archive-product.php · textbook-grade-nav.php)
   넓은 화면: 컨테이너(1200px) 왼쪽 '바깥 공간(gutter)'에 떠 있는 플로팅 패널.
   좁은 화면: gutter 가 부족하므로 상단 접이식(기본 접힘)으로 강등.
   최상위 개폐는 체크박스 토글 — 넓은 화면은 CSS 로 항상 펼침. */

/* ── 기본(좁은 화면): 상단 접이식 카드 ── */
.tb-gradenav {
  margin: 0 var(--s-5) var(--s-4);
  background: #fff;
  border: 1px solid var(--c-border);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.tb-gradenav-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px var(--s-4);
  font-size: 15px;
  font-weight: 700;
  color: var(--c-fg-1);
  background: var(--c-bg-2, #f7f8fa);
  border-bottom: 2px solid var(--c-primary);
  cursor: pointer;
  user-select: none;
}
.tb-gradenav-title > i[data-lucide="graduation-cap"] { width: 18px; height: 18px; color: var(--c-primary); }
.tb-gradenav-caret { width: 18px; height: 18px; margin-left: auto; color: var(--c-fg-4); transition: transform .15s ease; }
.tb-gradenav-toggle:checked ~ .tb-gradenav-title .tb-gradenav-caret { transform: rotate(180deg); }

.tb-gradenav-body { display: none; padding: var(--s-3); }
.tb-gradenav-toggle:checked ~ .tb-gradenav-body { display: block; }

/* 학기 아코디언 */
.tb-grade { border-bottom: 1px solid var(--c-border); }
.tb-grade:last-child { border-bottom: 0; }
.tb-grade-sum {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--c-fg-1);
  list-style: none;
  cursor: pointer;
}
.tb-grade-sum::-webkit-details-marker { display: none; }
.tb-grade-sum::after { content: "＋"; color: var(--c-fg-4); font-weight: 400; }
.tb-grade[open] > .tb-grade-sum::after { content: "－"; }
.tb-grade-sum:hover { color: var(--c-primary); }

/* 출판사 아코디언 */
.tb-pub { margin: 2px 0 2px 6px; }
.tb-pub-sum {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  font-size: 13px;
  color: var(--c-fg-2);
  list-style: none;
  cursor: pointer;
}
.tb-pub-sum::-webkit-details-marker { display: none; }
.tb-pub-sum:hover { color: var(--c-primary); }
.tb-pub-logo { flex: 0 0 auto; width: 58px; height: 20px; object-fit: contain; object-position: left center; }
.tb-pub-name { font-weight: 600; }
.tb-pub-note { font-style: normal; font-weight: 400; font-size: 12px; color: var(--c-fg-4); }

/* 단원 링크 */
.tb-units { list-style: none; margin: 0 0 6px 12px; padding: 0 0 0 10px; border-left: 2px solid var(--c-border); }
.tb-units a { display: block; padding: 5px 8px; font-size: 12.5px; color: var(--c-fg-2); border-radius: var(--r-md, 6px); }
.tb-units a:hover { background: var(--c-bg-2, #f5f6f8); color: var(--c-primary); text-decoration: none; }
.tb-units a.is-active { background: var(--c-primary); color: #fff; font-weight: 600; }
.tb-unit-all a { font-weight: 600; color: var(--c-fg-1); }

/* 초등공통 — 학기 그룹과 같은 레벨/사이즈의 직접 링크(6-1 아래) */
.tb-grade-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--c-fg-1);
}
.tb-grade-link:hover { color: var(--c-primary); text-decoration: none; }
.tb-grade-link.is-active { color: #fff; background: var(--c-primary); border-radius: var(--r-md, 6px); }

/* 그 외 분류 — 초등공통 아래 점선 구분선 + 재귀 트리(타이틀 없음) */
.tb-others { margin-top: var(--s-4); padding-top: var(--s-3); border-top: 1px dashed var(--c-border); }
.tb-tree { list-style: none; margin: 0; padding: 0; }
.tb-tree .tb-tree { margin-left: 8px; padding-left: 10px; border-left: 1px solid var(--c-border); }
.tb-branch-sum {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--c-fg-1);
  list-style: none;
  cursor: pointer;
}
.tb-branch-sum::-webkit-details-marker { display: none; }
.tb-branch-sum::after { content: "＋"; color: var(--c-fg-4); font-weight: 400; }
.tb-branch[open] > .tb-branch-sum::after { content: "－"; }
.tb-branch-sum:hover { color: var(--c-primary); }
.tb-tree a { display: block; padding: 5px 8px; font-size: 12.5px; color: var(--c-fg-2); border-radius: var(--r-md, 6px); }
.tb-tree a:hover { background: var(--c-bg-2, #f5f6f8); color: var(--c-primary); text-decoration: none; }
.tb-tree a.is-active { background: var(--c-primary); color: #fff; font-weight: 600; }

/* 최상위 '그 외 분류'의 하위 없는 항목(공통실험기구·DIY KIT·소모품·케이스)도
   하위 있는 항목(tb-branch-sum)과 동일한 크기·굵기로 — 초라해 보이지 않게 */
.tb-others > .tb-tree > li > a { padding: 6px 8px; font-size: 13px; font-weight: 600; color: var(--c-fg-1); }

.tb-count { color: var(--c-fg-4); font-size: 11px; font-variant-numeric: tabular-nums; }
.is-active .tb-count { color: rgba(255, 255, 255, .85); }

/* ── 넓은 화면(≥1740px): 컨테이너 왼쪽 바깥 gutter 에 플로팅 고정 ──
   right edge 를 컨테이너 왼쪽에서 12px 떨어뜨려 배치. qs-tab(z:1002)은
   그대로 위에 떠 있어 클릭 가능(퀵서치 무변경). */
@media (min-width: 1740px) {
  .tb-gradenav {
    position: fixed;
    top: 132px;
    left: calc((100vw - var(--container)) / 2 - 12px);
    transform: translateX(-100%);
    width: 248px;
    margin: 0;
    max-height: calc(100vh - 160px);
    overflow: auto;
    z-index: 40;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .10);
  }
  .tb-gradenav-body { display: block; }             /* 항상 펼침 */
  .tb-gradenav-caret { display: none; }
  .tb-gradenav-title { pointer-events: none; cursor: default; } /* 접힘 불가 */
}
