/* ==============================================
   선택가이드 ver4 — 스타일
   원본: docs/gilbutschool_guide_ver4.html \3c style> (라인 9-548 추출)
   사이트 레이아웃 안에 삽입되므로 전역 리셋·body 룰은 #guide-v4-root 로 스코프.
   @font-face 경로는 /assets/fonts/ 로컬 폰트로 교체.
   ============================================== */

@font-face {
  font-family: 'HakgyoansimAllimjang';
  src: url('/assets/fonts/HakgyoansimAllimjang-R.ttf') format('truetype');
  font-weight: 400;
}
@font-face {
  font-family: 'HakgyoansimAllimjang';
  src: url('/assets/fonts/HakgyoansimAllimjang-B.ttf') format('truetype');
  font-weight: 700;
}

/* 전역 리셋 → 가이드 루트 하위로 스코프 (사이트 GNB/푸터 보호).
   :where()로 감싸 specificity 0 유지 → 가이드 자체 클래스 규칙(.filter-btn 등)이 정상 우선 적용됨.
   (#guide-v4-root * 로 쓰면 specificity (1,0,0)이 되어 가이드 패딩/마진을 모두 덮어쓰는 버그 발생) */
:where(#guide-v4-root, #guide-v4-root *) { box-sizing: border-box; margin: 0; padding: 0; }

#guide-v4-root {
  --brand:       #43A047;
  --brand-dark:  #2E7D32;
  --brand-light: #E8F5E9;
  --gray-100: #F5F5F5;
  --gray-200: #EEEEEE;
  --gray-300: #E0E0E0;
  --gray-500: #9E9E9E;
  --gray-600: #757575;
  --gray-800: #424242;
  --text:     #1A1A1A;
  --radius:   8px;
  --shadow:   0 2px 10px rgba(0,0,0,0.08);
  --shadow-lg:0 12px 40px rgba(0,0,0,0.18);
}

/* body 룰 → 가이드 루트로 스코프 (사이트 본문 스타일 보호) */
#guide-v4-root {
  font-family: 'Pretendard', 'Apple SD Gothic Neo', 'Noto Sans KR', 'Malgun Gothic', sans-serif;
  background: #ffffff;
  color: var(--text);
  line-height: 1.6;
}

/* ── 컨테이너 ── */
#guide-v4-root .guide-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

/* ── 상단 ── */
#guide-v4-root .guide-top {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 28px;
}
#guide-v4-root .guide-header h1 {
  font-size: 30px;
  font-weight: 800;
  color: var(--brand-dark);
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}
#guide-v4-root .guide-header p {
  font-size: 16px;
  color: var(--gray-600);
}

/* ── 필터 영역 ── */
#guide-v4-root .filter-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
}

/* 필터 행: 전체를 감싸는 회색 타원 */
#guide-v4-root .filter-row {
  display: inline-flex;
  align-items: center;
  gap: 0;
  background: #f0f0f0;
  border-radius: 999px;
  padding: 4px;
  align-self: flex-start;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.10);
}

/* ── 필터 버튼 (종류·연령·분야 공통) ── */
#guide-v4-root .filter-btn {
  padding: 9px 22px;
  border-radius: 999px;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  color: #777;
  transition: all 0.18s;
  white-space: nowrap;
  line-height: 1;
}
#guide-v4-root .filter-btn:hover { color: #333; }
#guide-v4-root .filter-btn.active {
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(140,198,63,0.4);
}

/* ── 다운로드 버튼 ── */
#guide-v4-root .download-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 6px;
  border: 1.5px solid var(--brand);
  background: #fff;
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s;
}
#guide-v4-root .download-btn svg {
  width: 15px; height: 15px;
  stroke: var(--brand-dark);
}
#guide-v4-root .download-btn:hover {
  background: var(--brand);
  color: #fff;
}
#guide-v4-root .download-btn:hover svg { stroke: #fff; }
#guide-v4-root .download-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

/* ── 안내 문구 ── */
#guide-v4-root .guide-hint {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-500);
  font-size: 14px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
#guide-v4-root .guide-hint .hint-icon {
  width: 52px;
  height: 52px;
  background: var(--brand-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
}
#guide-v4-root .guide-hint .hint-icon svg { width: 26px; height: 26px; fill: var(--brand); }

/* ── 로드맵 컨테이너 ── */
#guide-v4-root .roadmap-wrap {
  background: #fff;
  border-radius: var(--radius);   /* 카드 외곽 라운드 */
  overflow: visible;              /* 자식 스크롤 클리핑 방지 */
  box-shadow: var(--shadow);
  margin-top: 20px;
}
#guide-v4-root .roadmap-head {
  padding: 14px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  gap: 10px;
  border-radius: 8px 8px 0 0;   /* 상단 모서리만 */
}
#guide-v4-root .roadmap-head .dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
#guide-v4-root .roadmap-head h2 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
}
#guide-v4-root .roadmap-head .sub {
  font-size: 13px;
  font-weight: 400;
  color: var(--gray-600);
  margin-left: 4px;
}

#guide-v4-root .table-scroll {
  overflow-x: hidden;
  border-radius: 0 0 8px 8px;
}
@media (max-width: 768px) {
  #guide-v4-root .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  #guide-v4-root .thead-sticky-wrap { overflow-x: hidden; }

  /* 모바일 공통 래퍼 #gilbut 의 overflow:hidden(school_mobile.css)이 sticky 헤더의
     스크롤 컨테이너가 되어, PC와 달리 연령 헤더가 상단에 고정되지 않는 문제 해결.
     overflow:clip 은 hidden 처럼 클리핑하되(오프캔버스 메뉴 .side_nav_wrap 가림 유지)
     스크롤 컨테이너를 만들지 않아 sticky 가 뷰포트 기준으로 동작한다.
     clip 미지원 구형 브라우저는 앞선 hidden 을 유지 → 기존(무변화) 동작. */
  #gilbut { overflow: hidden; overflow: clip; }
}

/* thead 분리 sticky 래퍼 */
#guide-v4-root .thead-sticky-wrap {
  position: sticky;
  top: 0;
  z-index: 10;
  overflow-x: hidden; /* 스크롤바 숨김, JS로 동기화 */
  background: #fff;
  margin-bottom: -1px;
}

/* 분리된 헤더 테이블 */
#guide-v4-root #rmap-table-head,
#guide-v4-root #crmap-table-head {
  table-layout: fixed;
  min-width: 0;
}
#guide-v4-root .scroll-hint {
  display: none;
}
@media (max-width: 768px) {
  #guide-v4-root .scroll-hint {
    display: block;
    font-size: 12px;
    color: var(--gray-500);
    text-align: center;
    padding: 6px 0 4px;
    background: #fff;
  }
}

#guide-v4-root table {
  width: 100%;
  border-collapse: collapse;
}
#guide-v4-root #rmap-table {
  table-layout: fixed;
  min-width: 0;
}
#guide-v4-root #crmap-table {
  table-layout: fixed;
  min-width: 0;
}

/* 헤더 */
#guide-v4-root thead th {
  background: var(--brand);
  color: #fff;
  text-align: center;
  padding: 9px 10px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  border-right: 1px solid rgba(255,255,255,0.18);
  /* top sticky는 .thead-sticky-wrap이 담당 */
}
#guide-v4-root thead th:first-child {
  background: var(--brand-dark);
  text-align: left;
  padding-left: 16px;
  min-width: 110px;
  position: sticky;
  left: 0;
  z-index: 4;
  border-right: none;
  box-shadow: 1px 0 0 rgba(255,255,255,0.18);
}

/* 바디 */
#guide-v4-root tbody tr:nth-child(even) td { background: #FAFAFA; }

#guide-v4-root td {
  border: 1px solid var(--gray-200);
  vertical-align: middle;
  font-size: 12px;
}
#guide-v4-root td.cat-cell {
  font-weight: 700;
  color: #fff;
  padding: 12px 12px;
  white-space: nowrap;
  font-size: 14px;
  text-align: center;
  position: sticky;
  left: 0;
  z-index: 1;
  border-right: none;
}
#guide-v4-root tbody tr { height: 70px; }
#guide-v4-root td.empty-cell {
  background: #fff;
}
#guide-v4-root td.series-cell {
  cursor: pointer;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  padding: 10px 11px 10px 8px;
  line-height: 1.4;
  overflow: hidden;
  transition: filter 0.15s, transform 0.15s;
  border: none;
  outline: 1px solid rgba(0,0,0,0.06);
}
#guide-v4-root td.series-cell:hover {
  filter: brightness(0.93);
  transform: translateY(-1px);
  z-index: 3;
  position: relative;
  box-shadow: 0 3px 10px rgba(0,0,0,0.14);
}
#guide-v4-root td.series-cell:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: -2px;
}

/* ── 준비중 화면 ── */
#guide-v4-root .coming-soon {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
  padding: 80px 24px;
}
#guide-v4-root .cs-icon {
  width: 72px; height: 72px;
  background: var(--brand-light);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
}
#guide-v4-root .cs-icon svg { width: 36px; height: 36px; fill: var(--brand); }
#guide-v4-root .coming-soon h2 {
  font-size: 22px; font-weight: 800;
  color: var(--brand-dark); margin-bottom: 12px;
}
#guide-v4-root .coming-soon p {
  font-size: 14px; color: var(--gray-600); line-height: 1.9;
}

/* ── 팝업 모달 ── */
#guide-v4-root .modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  pointer-events: none;
  transition: background 0.28s;
}
#guide-v4-root .modal-overlay.open {
  background: rgba(0,0,0,0.52);
  pointer-events: auto;
}

#guide-v4-root .gv4-modal {
  background: #fff;
  border-radius: 14px;
  width: 100%;
  max-width: 480px;
  padding: 28px 24px 24px;
  position: relative;
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  transition: opacity 0.25s, transform 0.25s;
}
#guide-v4-root .modal-overlay.open .gv4-modal {
  opacity: 1;
  transform: none;
}
#guide-v4-root .modal-close {
  position: absolute; top: 14px; right: 14px;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--gray-200);
  border: none;
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--gray-800);
  transition: background 0.15s;
  line-height: 1;
}
#guide-v4-root .modal-close:hover { background: var(--gray-300); }

#guide-v4-root .modal-body { display: flex; gap: 20px; }

#guide-v4-root .book-cover {
  width: 100px; min-width: 100px; height: 140px;
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  font-size: 12px; font-weight: 800;
  color: #fff; line-height: 1.5;
  padding: 10px;
  box-shadow: 3px 4px 14px rgba(0,0,0,0.22);
  word-break: keep-all;
}

#guide-v4-root .modal-info { flex: 1; }
#guide-v4-root .modal-name {
  font-size: 17px; font-weight: 800;
  color: var(--text); margin-bottom: 8px;
  padding-right: 20px; line-height: 1.4;
}
#guide-v4-root .age-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px; font-weight: 700;
  margin-bottom: 12px;
}
#guide-v4-root .modal-desc {
  font-size: 13px; color: var(--gray-600);
  line-height: 1.75; margin-bottom: 18px;
  word-break: keep-all; overflow-wrap: break-word;
}
#guide-v4-root .modal-sub {
  font-size: 13px; font-weight: 400; color: var(--gray-600);
  display: block; line-height: 1.4;
}
#guide-v4-root .modal-cta {
  display: inline-block;
  padding: 10px 22px;
  background: var(--brand);
  color: #fff;
  border-radius: 6px;
  text-decoration: none;
  font-size: 13px; font-weight: 700;
  transition: background 0.18s;
}
#guide-v4-root .modal-cta:hover { background: var(--brand-dark); }

/* ── 교양·창의 테이블 헤더 전용 ── */
#guide-v4-root thead th.cr-cat-th {
  background: var(--brand-dark);
  text-align: left;
  padding-left: 16px;
  min-width: 130px;
  position: sticky;
  top: 0;
  left: 0;
  z-index: 4;
  vertical-align: middle;
}
#guide-v4-root thead th.cr-group-th {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.5px;
  border-bottom: 1px solid rgba(255,255,255,0.25);
}
#guide-v4-root thead th.cr-age-th {
  position: static !important;
  left: auto !important;
  min-width: 60px;
  padding-left: 10px;
}

/* ── 시리즈 셀 다중 텍스트 ── */
#guide-v4-root .ser-n1 { display:block; font-weight:700; font-size:15px; line-height:1.35; word-break:keep-all; overflow-wrap:break-word; }
#guide-v4-root .ser-n2 { display:block; font-weight:400; font-size:13px; line-height:1.3; margin-top:3px; word-break:keep-all; overflow-wrap:break-word; }
#guide-v4-root .ser-n3 { display:block; font-weight:400; font-size:12px; line-height:1.3; margin-top:1px; word-break:keep-all; overflow-wrap:break-word; }
#guide-v4-root td.series-cell { word-break:keep-all; overflow-wrap:break-word; }
/* ── 팝업 도서 이미지 ── */
#guide-v4-root .book-cover-img {
  width:100px; min-width:100px; height:auto;
  object-fit:unset; border-radius:6px;
  background:#ffffff;
  box-shadow:3px 4px 14px rgba(0,0,0,0.22);
}

/* ── 반응형 ── */
@media (max-width: 768px) {
  #guide-v4-root .download-btn { display: none; }
  #guide-v4-root td.cat-cell { white-space: normal; word-break: keep-all; font-size: 13px; }
  #guide-v4-root .guide-wrap { padding: 24px 14px 60px; }
  #guide-v4-root .guide-top { flex-direction: column; align-items: flex-start; gap: 16px; }
  #guide-v4-root .guide-header h1 { font-size: 20px; }
  #guide-v4-root .filter-area { align-items: flex-start; }
  #guide-v4-root .filter-area { gap: 8px; }
  #guide-v4-root .filter-row { gap: 2px; padding: 3px; }
  #guide-v4-root .filter-btn { padding: 7px 14px; font-size: 13px; }

  /* 모달: 하단 시트 */
  #guide-v4-root .modal-overlay { align-items: flex-end; padding: 0; }
  #guide-v4-root .gv4-modal {
    border-radius: 22px 22px 0 0;
    max-width: 100%;
    max-height: 85vh;
    padding: 0 20px 36px;
    transform: translateY(100%);
  }
  #guide-v4-root .modal-overlay.open .gv4-modal { transform: translateY(0); }
  #guide-v4-root .modal::before {
    content: '';
    display: block;
    width: 40px; height: 4px;
    background: var(--gray-300);
    border-radius: 2px;
    margin: 12px auto 20px;
  }
  #guide-v4-root .modal-close { top: 20px; right: 16px; }
  #guide-v4-root .modal-body { flex-direction: column; align-items: center; gap: 16px; }
  #guide-v4-root .modal-name { text-align: center; padding-right: 0; }
  #guide-v4-root .age-badge { display: block; text-align: center; }
  #guide-v4-root .modal-info { text-align: center; width: 100%; }
  #guide-v4-root .modal-cta { display: block; text-align: center; }
}

/* ── TOP 버튼 ── */
#guide-v4-root #top-btn {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 200;
}
#guide-v4-root #top-btn.visible {
  opacity: 1;
  pointer-events: auto;
}
#guide-v4-root #top-btn:hover { transform: translateY(-3px); }
@media (max-width: 768px) {
  #guide-v4-root #top-btn { bottom: 20px; right: 16px; }
}
