/* ===== 디자인 토큰 ===== */
:root {
  /* 브랜드 레드 + 먹색. 브랜드 컬러 변경 시 --color-accent만 교체 */
  --color-accent: #ad0707;
  --color-accent-hover: #be0808; /* 마우스를 올렸을 때의 밝은 붉은색 */
  --color-accent-contrast: #fff;

  /* 연한 회베이지 바탕 + 먹색 글자 (흰 표지와 배경이 구분되도록 완전 흰색은 피함) */
  --color-bg: #f1eee8;
  --color-surface: #fbfaf8;
  --color-text: #1e2a24;
  --color-text-muted: #4d554e;
  --color-border: rgba(30,42,36,.32);
  --color-border-light: rgba(30,42,36,.14);
  --color-hover-bg: rgba(30,42,36,.07);
  --color-lemon: #fff1a0; /* '최신간' 탭 바탕색 */
  --color-hover-dark: #3d3f3e; /* 서점 버튼 등 마우스를 올렸을 때의 어두운 회색 */
  --color-cover-border: rgba(30,42,36,.2); /* 표지·포스터 테두리: 있다는 것만 인지될 정도로 연하게 */
  --color-overlay: rgba(241,238,232,.86);

  /* 카드 그리드: 열 수·표지 폭·간격. 카테고리 필터 박스의 최대 폭도 이 값으로 표지 열과 맞춤 */
  --cols: 6;
  --cover-max: 170px;
  --card-gap: 26px;

  /* 서점 버튼 — 흑백 통일 */
  --color-aladin: #111;
  --color-yes24: #111;
  --color-kyobo: #111;

  /* 글꼴: 제목·본문 모두 Pretendard ('Do it!'만 Oswald) */
  --font-heading: var(--font-body); /* 한글·영문이 한 글꼴(Pretendard)로 이어지도록 제목도 본문과 동일 */
  --font-body: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  /* 레이아웃 — 배경은 전체 폭, 내용은 컬럼 정렬선에 통일 */
  --content-max: 1400px;
  --content-pad: 32px;
  --gutter: max(var(--content-pad), calc((100% - var(--content-max)) / 2 + var(--content-pad)));
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-body); background: var(--color-bg); color: var(--color-text);
       line-height: 1.3; }
a:hover { text-decoration: underline; }

/* 'Do it!' 표기는 사이트 전체에서 Oswald 500 */
.doit { font-family: "Oswald", Impact, "Arial Narrow", sans-serif; font-weight: 500; letter-spacing: -.03em; }

/* ===== 레이아웃: 왼쪽 고정 사이드바 + 오른쪽 본문 (스레드 PC 화면 방식) ===== */
.layout { display: flex; align-items: flex-start; min-height: 100vh; }
.sidebar { flex: 0 0 280px; width: 280px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
           padding: 36px 24px 32px 32px; scrollbar-width: thin; display: flex; flex-direction: column; }
.sidebar > * { flex-shrink: 0; }
.main { flex: 1; min-width: 0; }

/* 헤더 — 큰 세리프 제목 */
header { background: transparent; color: var(--color-text); padding: 0 0 16px; }
header h1 { font-family: var(--font-heading); font-size: 32px; font-weight: 800; line-height: 1.2; word-break: keep-all; }
header h1 .brand { color: var(--color-accent); display: block; transition: color .15s; }
header h1:hover .brand { color: var(--color-accent-hover); }
header h1 .line { display: block; font-size: 19px; font-weight: 600; color: var(--color-text-muted); margin: 0 0 4px; }
header h1 .line, header h1 .phrase { white-space: nowrap; } /* 좁은 화면에서도 어절 묶음 단위로만 줄바꿈 */
header p { font-size: 10.3px; color: var(--color-text-muted); margin-top: 10px; }

/* 이용 안내(제목 아래)와 문의처(사이드바 맨 아래) */
.side-guide { margin-bottom: 24px; }
.side-guide-box { padding: 12px 14px; background: rgba(255,255,255,0.75);
                  font-size: 13px; line-height: 1.55; color: var(--color-text-muted); word-break: keep-all; }
.side-guide strong { display: block; font-size: 13px; color: var(--color-text); margin-bottom: 4px; }
.side-contact { margin-top: auto; padding-top: 18px; border-top: 1px solid var(--color-border-light);
                font-size: 13px; line-height: 1.8; color: var(--color-text-muted); overflow-wrap: anywhere; }
.side-contact strong { display: block; color: var(--color-text); margin-bottom: 4px; }
.side-contact a { display: block; color: inherit; text-decoration: none; }
.side-contact a:hover { text-decoration: underline; }

/* 시리즈 탭 — 세로 메뉴, 선택 항목만 밑줄 */
.series-tabs { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 0 0 22px; }
.series-btn { padding: 6px 0; border: none; background: transparent; text-align: left;
               color: var(--color-text-muted); font-family: var(--font-heading); font-size: 20px; font-weight: 700;
               cursor: pointer; transition: color .15s; position: relative; }
.series-btn:hover { color: var(--color-text); text-decoration: underline; background: transparent; }
.series-btn.active { color: var(--color-text); background: transparent; text-decoration: underline;
                      text-underline-offset: 6px; text-decoration-thickness: 2px; text-decoration-color: var(--color-accent); }

/* 카테고리 필터 — 본문 상단, 각진 얇은 테두리 박스 (선택 시 주홍 반전) */
.filters { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 36px;
           max-width: calc(var(--cols) * var(--cover-max) + (var(--cols) - 1) * var(--card-gap)); }
.filters:empty { display: none; }
.filter-btn { padding: 6px 14px; border: 1px solid var(--color-border); border-radius: 0; background: transparent;
               color: var(--color-text); font-family: var(--font-body);
               font-size: 14px; font-weight: 400; cursor: pointer; transition: .15s ease; }
.filter-btn:hover { background: var(--color-hover-bg); }
.filter-btn.active { background: var(--color-accent); color: var(--color-accent-contrast); border-color: var(--color-accent); }
.filter-btn.active:hover { background: var(--color-accent-hover); border-color: var(--color-accent-hover); }

/* ===== 로드맵 ===== */
.rm-title { font-size: 30px; font-weight: 400; letter-spacing: -.04em; margin-bottom: 20px; word-break: keep-all; }
.filters.rm-courses { margin-bottom: 32px; }
/* 분야별 / 언어별 전환 */
.rm-view { display: flex; margin-bottom: 16px; }
.rm-view[hidden] { display: none; }
.rm-view .filter-btn { min-width: 88px; padding: 8px 18px; border-color: var(--color-text); }
.rm-view .filter-btn.active { background: var(--color-text); border-color: var(--color-text); color: #fff; }
.rm-panel { background: rgba(255,255,255,0.75); padding: 18px 20px 20px; margin-bottom: 20px; max-width: 986px; }
.rm-panel h3 { font-size: 18px; font-weight: 700; margin-bottom: 16px; }
.rm-panel h4 { font-size: 14px; font-weight: 700; padding-bottom: 8px; margin-bottom: 24px; border-bottom: 2px solid var(--color-accent); }
.rm-tracks { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 28px; }
/* 단계 칸은 책 2권 너비(278px)로 고정하고 왼쪽에 모음 */
.rm-stages { display: grid; grid-template-columns: repeat(3, minmax(0, 278px)); gap: 56px; }
@media (min-width: 901px) {
  .rm-stage { grid-row: 1; position: relative; }
  .rm-col-1 { grid-column: 1; }
  .rm-col-2 { grid-column: 2; }
  .rm-col-3 { grid-column: 3; }
  /* 다음 단계가 있으면 빨간 밑줄 끝을 화살촉(>)으로 */
  .rm-stage:not(:last-child) h4 { position: relative; }
  .rm-stage:not(:last-child) h4::after { content: ""; position: absolute; right: 2px; bottom: -6px; width: 10px; height: 10px;
                                         border: solid var(--color-accent); border-width: 2px 2px 0 0; transform: rotate(45deg); }
}
.rm-books { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 30px 18px; }
.rm-books .card { width: 130px; border: none; font-family: inherit; }
.rm-books .card-title { font-size: 14px; min-height: 0; overflow-wrap: break-word; }
.rm-books .badge-new { display: none; } /* 로드맵에는 '최신간' 표시 안 함 */
.rm-books.ordered .card + .card { margin-left: 26px; }
.rm-books.ordered .card + .card::before { content: "→"; position: absolute; left: -33px; top: 80px; font-size: 20px; }
.rm-toggle { display: block; width: 100%; max-width: 986px; text-align: left; padding: 12px 16px; margin-bottom: 20px; background: transparent;
             border: 1px solid var(--color-border); font-family: var(--font-body); font-size: 14px; color: var(--color-text); cursor: pointer; }
.rm-toggle:hover { background: var(--color-hover-bg); }

.content { padding: 36px 40px 28px; }
.search-wrap { margin-bottom: 24px; }
.search-wrap input { width: 100%; max-width: 400px; padding: 10px 0; background: transparent;
                       border: none; border-bottom: 1px solid var(--color-border); border-radius: 0;
                       font-family: var(--font-body); font-size: 16px; color: var(--color-text); }
.search-wrap input::placeholder { color: var(--color-text-muted); }
.search-wrap input:focus { outline: none; border-bottom-color: var(--color-accent); }

/* 카테고리 섹션 (Do it!, 된다! 공통) */
.section { margin-bottom: 100px; }
.section-header { display: flex; align-items: baseline; gap: 12px; margin-bottom: 40px;
                  padding-bottom: 10px; border-bottom: 1px solid var(--color-border-light); }
.section-header h2 { font-family: var(--font-heading); font-size: 30px; font-weight: 400; letter-spacing: -.04em; word-break: keep-all; }
.section-count { font-size: 14px; color: var(--color-text-muted); font-weight: 400; white-space: nowrap; }

/* 도서 카드 — 박스 없이 표지(테두리선)와 제목만 */
/* 표지 폭(170px)에 맞춘 고정 열 — 열이 늘어나 표지 사이가 벌어지지 않도록 왼쪽부터 촘촘히 배치 */
.card-grid { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, var(--cover-max))); justify-content: start; gap: 36px var(--card-gap); }
/* 표지는 최대 170px로 제한 (원본 해상도가 낮아 늘어나면 흐려짐) */
.card { display: flex; flex-direction: column; align-items: flex-start; text-align: left;
        background: transparent; padding: 0; cursor: pointer; width: 100%; min-width: 0;
        position: relative; }
.card:hover .card-title { text-decoration: underline; }
/* '최신간' 탭: 표지 윗변 왼쪽에 붙는 윤곽선 탭 (연한 레몬 바탕 + 먹색 얇은 테두리). 표지 글자를 가리지 않고, 카드 높이에는 영향 없음 */
.badge-new { position: absolute; top: -22px; left: 0; z-index: 1; box-sizing: border-box; height: 22px; padding: 0 10px;
             border: 1px solid var(--color-text); border-bottom: none;
             background: var(--color-lemon); color: var(--color-text);
             font-size: 12px; font-weight: 500; line-height: 21px; pointer-events: none; }
.card img { width: 100%; max-width: var(--cover-max); aspect-ratio: 116 / 164; height: auto; object-fit: cover; border-radius: 0;
            border: 1px solid var(--color-cover-border); box-shadow: none; margin-bottom: 12px; flex-shrink: 0; }
.card-title { width: 100%; max-width: var(--cover-max); font-size: 16px; font-weight: 600; line-height: 1.35; letter-spacing: .02em; color: var(--color-text);
              word-break: keep-all; overflow-wrap: break-word; min-height: 65px; }

.no-result { text-align: left; color: var(--color-text-muted); padding: 24px 0 60px; font-size: 16px; display: none; }

/* 모달 */
#modal-overlay { display: none; position: fixed; inset: 0; background: var(--color-overlay);
                  z-index: 100; align-items: center; justify-content: center; }
#modal-overlay.open { display: flex; }
#modal-box { background: var(--color-surface); border: 1px solid var(--color-text); border-radius: 0;
              padding: 28px 32px; min-width: 300px; max-width: 440px; width: 90%; box-shadow: none;
              max-height: 86vh; overflow-y: auto; }
#modal-box h3 { font-family: var(--font-heading); font-size: 24px; font-weight: 600; margin-bottom: 14px; line-height: 1.25; }
#modal-desc { font-size: 14px; line-height: 1.65; color: var(--color-text-muted);
              margin-bottom: 20px; white-space: pre-line;
              max-height: 38vh; overflow-y: auto; }
.store-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 11px 16px;
              border-radius: 999px; border: 1px solid var(--color-text); background: transparent;
              font-size: 15px; font-weight: 400; cursor: pointer; margin-bottom: 10px;
              text-decoration: none; color: var(--color-text); transition: background .15s, color .15s; }
.store-btn:hover { background: var(--color-hover-dark); color: #fff; text-decoration: none; }
.store-btn.preview { margin-top: 4px; border-style: dashed; }
.store-btn.preview:hover { border-style: solid; }
.store-btn.disabled { color: #a3a7a3; border-color: var(--color-border-light); cursor: default; pointer-events: none; }
.modal-close { width: 100%; padding: 10px; border: none; background: transparent; color: var(--color-text-muted);
                font-size: 14px; cursor: pointer; margin-top: 4px; }
.modal-close:hover { color: var(--color-text); text-decoration: underline; }

/* 이벤트 탭 버튼 */
.series-btn-event.active { color: var(--color-text); }

/* 이벤트 카드 — 박스 없이 이미지 영역에 얇은 테두리 */
.event-grid { display: flex; flex-wrap: wrap; gap: 28px 24px; }
.event-empty { color: var(--color-text-muted); font-size: 15px; padding: 20px 4px; }
.event-card { display: flex; flex-direction: column; width: 260px; flex-shrink: 0;
              background: transparent; cursor: pointer; text-decoration: none; color: inherit; }
.event-card:hover { text-decoration: none; }
.event-card:hover .event-card-title { text-decoration: underline; }
.event-card-poster { height: 150px; display: flex; align-items: center; justify-content: center;
                     background: transparent; border: 1px solid var(--color-cover-border); position: relative; }
.event-card-poster .event-book-cover { height: 116px; width: auto; border-radius: 0;
                                       border: 1px solid var(--color-cover-border); box-shadow: none; }
.event-card-body { padding: 12px 0 0; }
.event-card-title { font-size: 15px; font-weight: 400; line-height: 1.4; word-break: keep-all; }
.event-card-period { font-size: 14px; color: var(--color-text-muted); margin-top: 6px; }
/* 종료된 이벤트 */
.event-card.ended { opacity: .6; }
.event-card.ended .event-card-poster { filter: grayscale(1); }
.event-card.ended .event-card-period { color: var(--color-text-muted); }

/* ===== 교강사 카톡방 팝업 ===== */
#popup-overlay { display: none; position: fixed; inset: 0; background: var(--color-overlay);
                 z-index: 200; align-items: center; justify-content: center; padding: 20px; }
#popup-overlay.open { display: flex; }
#popup-box { position: relative; background: var(--color-surface); border: 1px solid var(--color-text);
             border-radius: 0; padding: 34px 30px 22px; width: 100%; max-width: 360px; text-align: center;
             box-shadow: none; }
.popup-x { position: absolute; top: 12px; right: 14px; border: none; background: none;
           font-size: 24px; line-height: 1; color: var(--color-text-muted); cursor: pointer; padding: 4px; }
.popup-x:hover { color: var(--color-text); }
.popup-emoji { font-size: 40px; margin-bottom: 8px; }
#popup-box h3 { font-family: var(--font-heading); font-size: 20px; font-weight: 400; line-height: 1.3; margin-bottom: 12px; text-wrap: balance; }
@media (max-width: 400px) { #popup-box h3 { font-size: 18px; } }
#popup-text { font-size: 15px; line-height: 1.65; color: var(--color-text-muted);
              margin-bottom: 22px; white-space: pre-line; word-break: keep-all; }
.popup-join { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
              padding: 13px 16px; border-radius: 0; background: #fee500; color: #191600;
              border: 1px solid var(--color-text);
              font-size: 15px; font-weight: 500; text-decoration: none; transition: filter .15s; }
.popup-join::before { content: "💬"; font-size: 16px; }
.popup-join:hover { filter: brightness(.96); text-decoration: none; }
.popup-dismiss { width: 100%; margin-top: 12px; padding: 8px; border: none; background: none;
                 font-size: 13px; color: var(--color-text-muted); cursor: pointer; }
.popup-dismiss:hover { color: var(--color-text); text-decoration: underline; }

/* ===== Top 버튼 (스크롤 시 우측 하단 고정) ===== */
#back-to-top { position: fixed; right: 24px; bottom: 24px; z-index: 50;
               padding: 8px 14px; background: var(--color-bg); color: var(--color-text);
               border: 1px solid var(--color-text); border-radius: 0;
               font-family: var(--font-body); font-size: 14px; cursor: pointer;
               opacity: 0; visibility: hidden; transform: translateY(8px);
               transition: opacity .18s ease, transform .18s ease, visibility .18s ease, background .15s, color .15s; }
#back-to-top.visible { opacity: 1; visibility: visible; transform: none; }
#back-to-top:hover { background: var(--color-accent-hover); border-color: var(--color-accent-hover); color: var(--color-accent-contrast); }

/* ===== 반응형 ===== */
/* 카드 열 수: PC 6열 → 4열 → 3열 → 모바일 2열 */
@media (max-width: 1280px) { :root { --cols: 5; } }
@media (max-width: 1100px) { :root { --cols: 4; } }

/* 900px 이하: 사이드바를 상단 헤더 + 가로 스크롤 탭/필터로 전환 */
@media (max-width: 900px) {
  .layout { display: flex; flex-direction: column; align-items: stretch; }
  .sidebar { display: contents; }
  .side-guide { margin: 0; padding: 0 24px 12px; }
  .side-contact { order: 1; margin: auto 24px 0; padding: 18px 0 80px; } /* 아래 여백: Top 버튼과 겹치지 않게 */
  header { padding: 24px 24px 16px; }
  header h1 { font-size: 28px; }
  header h1 .line { font-size: .68em; }
  .series-tabs { flex-direction: row; align-items: stretch; gap: 8px; padding: 0 24px;
                 background: var(--color-bg); border-bottom: 1px solid var(--color-border-light);
                 position: sticky; top: 0; z-index: 20;
                 overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
  .series-tabs::-webkit-scrollbar { display: none; }
  .series-btn { padding: 14px 16px 14px 0; margin-right: 16px; white-space: nowrap; font-size: 20px; display: inline-flex; align-items: center; }
  .filters { max-width: none; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; margin-bottom: 28px; }
  .filters::-webkit-scrollbar { display: none; }
  .filter-btn { flex-shrink: 0; }
  /* 로드맵: 버튼은 줄바꿈, 단계는 위에서 아래로, 표지 왼쪽·도서명 오른쪽 */
  .filters.rm-courses { flex-wrap: wrap; overflow: visible; margin-bottom: 20px; }
  .rm-panel { padding: 16px 14px; }
  .rm-stages { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .rm-books { flex-direction: column; align-items: stretch; gap: 14px; }
  .rm-books .card { flex-direction: row; align-items: center; gap: 12px; width: 100%; }
  .rm-books .card img { width: 64px; margin-bottom: 0; }
  .rm-books .card-title { flex: 1; width: auto; max-width: none; min-width: 0; }
  .rm-books.ordered .card + .card { margin: 14px 0 0; }
  .rm-books.ordered .card + .card::before { content: "↓"; left: 24px; top: -27px; }
  .content { padding: 28px 24px; }
  :root { --cols: 3; --card-gap: 16px; }
  .card-grid { gap: 36px var(--card-gap); }
}

@media (max-width: 480px) {
  header { padding: 24px 16px 16px; }
  .side-guide { padding-left: 16px; padding-right: 16px; }
  .side-contact { margin-left: 16px; margin-right: 16px; }
  header h1 { font-size: 26px; }
  .series-tabs { padding-left: 16px; padding-right: 16px; }
  .content { padding: 28px 16px; }
  #back-to-top { right: 16px; bottom: 16px; }
  /* 카드 2열 */
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 36px 12px; }
  .card-title { font-size: 15px; min-height: 61px; }
}
