/* ===== 디자인 토큰 ===== */
:root {
  /* 브랜드 컬러 */
  --color-brand: #e8380d;
  --color-brand-accent: #ff6b47;
  --color-tab-bg: #1c1c2e;

  /* 중립 */
  --color-bg: #f5f6f8;
  --color-surface: #fff;
  --color-text: #333;
  --color-text-muted: #444;
  --color-border: #ddd;
  --color-border-light: #eee;

  /* 서점 컬러 */
  --color-aladin: #2980b9;
  --color-yes24: #c0392b;
  --color-kyobo: #27ae60;

  /* 카드 크기 */
  --card-width: 172px;
  --cover-width: 116px;
  --cover-height: 164px;

  /* 형태 */
  --radius-card: 14px;

  /* 레이아웃 — 배경은 전체 폭, 내용은 컬럼 정렬선에 통일 */
  --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: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
       background: var(--color-bg); color: var(--color-text); }

header { background: var(--color-brand); color: white; padding: 28px var(--gutter); }
header h1 { font-size: 24px; font-weight: 800; }
header p { font-size: 13px; opacity: .8; margin-top: 4px; }

/* 시리즈 탭 */
.series-tabs { background: var(--color-tab-bg); display: flex;
                padding: 0 var(--gutter);
                border-bottom: 2px solid var(--color-brand); position: sticky; top: 0; z-index: 20; }
.series-btn { padding: 14px 32px; border: none; background: transparent;
               color: rgba(255,255,255,.55); font-size: 14px; font-weight: 700;
               cursor: pointer; transition: all .2s; position: relative; letter-spacing: .3px; }
.series-btn:hover { color: white; background: rgba(255,255,255,.06); }
.series-btn.active { color: var(--color-brand-accent); background: rgba(232,56,13,.12); }
.series-btn.active::after { content: ''; position: absolute; bottom: -2px; left: 0;
                             right: 0; height: 2px; background: var(--color-brand); }

.filters { background: var(--color-surface); padding: 14px var(--gutter); display: flex; gap: 8px;
            flex-wrap: wrap; border-bottom: 1px solid var(--color-border-light);
            position: sticky; top: 50px; z-index: 10; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.filter-btn { padding: 6px 16px; border-radius: 20px; border: 1.5px solid var(--color-border);
               background: var(--color-surface); font-size: 13px; font-weight: 600; cursor: pointer;
               transition: background-color .15s, color .15s, border-color .15s; }
.filter-btn:hover { border-color: var(--color-brand); color: var(--color-brand); }
.filter-btn.active { background: var(--color-brand); color: white; border-color: var(--color-brand); }

.content { padding: 28px var(--gutter); }
.search-wrap { margin-bottom: 28px; }
.search-wrap input { width: 100%; max-width: 400px; padding: 10px 16px;
                       border: 1.5px solid var(--color-border); border-radius: 24px; font-size: 14px; }
.search-wrap input:focus { outline: none; border-color: var(--color-brand); }

/* 카테고리 섹션 (Do it!, 된다! 공통) */
.section { margin-bottom: 100px; }
.section-header { display: flex; align-items: center; gap: 10px; margin-bottom: 20px;
                  padding-bottom: 12px; border-bottom: 2px solid var(--color-border-light); }
.section-header h2 { font-size: 18px; font-weight: 700; }
.section-count { font-size: 12px; color: #bbb; font-weight: 500; background: var(--color-bg);
                 padding: 2px 8px; border-radius: 12px; }

/* 도서 카드 */
.card-grid { display: flex; flex-wrap: wrap; gap: 16px; }
.card { display: flex; flex-direction: column; align-items: center; text-align: center;
        background: var(--color-surface); border-radius: var(--radius-card); padding: 16px 12px 14px;
        box-shadow: 0 2px 10px rgba(0,0,0,.08); cursor: pointer;
        transition: all .22s; width: var(--card-width); flex-shrink: 0; }
.card:hover { transform: translateY(-6px); box-shadow: 0 14px 36px rgba(0,0,0,.16); }
.card:hover .card-title { color: var(--color-text); }
.card img { width: var(--cover-width); height: var(--cover-height); object-fit: cover; border-radius: 7px;
            box-shadow: 0 4px 16px rgba(0,0,0,.22); margin-bottom: 10px; flex-shrink: 0; }
.card-title { font-size: 14px; font-weight: 700; line-height: 1.5; color: var(--color-text); word-break: keep-all; min-height: 66px; }

.no-result { text-align: center; color: #aaa; padding: 60px 0; font-size: 15px; display: none; }

/* 모달 */
#modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45);
                  z-index: 100; align-items: center; justify-content: center; }
#modal-overlay.open { display: flex; }
#modal-box { background: var(--color-surface); border-radius: 16px; padding: 28px 32px; min-width: 300px;
              max-width: 420px; width: 90%; box-shadow: 0 8px 40px rgba(0,0,0,.2);
              max-height: 86vh; overflow-y: auto; }
#modal-box h3 { font-size: 15px; font-weight: 700; margin-bottom: 12px; line-height: 1.5; }
#modal-desc { font-size: 13px; line-height: 1.65; color: var(--color-text-muted, #555);
              margin-bottom: 20px; white-space: pre-line;
              max-height: 38vh; overflow-y: auto; }
.store-btn { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 16px;
              border-radius: 10px; border: 1.5px solid var(--color-border-light); background: var(--color-surface);
              font-size: 14px; font-weight: 600; cursor: pointer; margin-bottom: 10px;
              text-decoration: none; color: var(--color-text); transition: all .15s; }
.store-btn:hover { border-color: currentColor; }
.store-btn.preview { color: #fff; border-color: #4f46e5; background: #4f46e5; margin-top: 4px; }
.store-btn.preview:hover { background: #4338ca; border-color: #4338ca; }
.store-btn.aladin { color: var(--color-aladin); } .store-btn.aladin:hover { background: #e8f4fd; }
.store-btn.yes24  { color: var(--color-yes24); } .store-btn.yes24:hover  { background: #fdf0ef; }
.store-btn.kyobo  { color: var(--color-kyobo); } .store-btn.kyobo:hover  { background: #eafaf1; }
.store-btn.disabled { color: #bbb; border-color: #f0f0f0; cursor: default; pointer-events: none; }
.modal-close { width: 100%; padding: 10px; border: none; background: var(--color-bg);
                border-radius: 8px; font-size: 13px; cursor: pointer; margin-top: 4px; }
.modal-close:hover { background: var(--color-border-light); }

/* ===== 이벤트 배너 (롤링 캐러셀) ===== */
#event-banner { position: relative; width: 100%; color: #fff;
                background: linear-gradient(100deg, #1c1c2e 0%, #2a3a6e 55%, #3858a8 100%); }
.eb-viewport { overflow: hidden; }
.eb-track { display: flex; transition: transform .5s ease; }
.eb-slide { flex: 0 0 100%; display: flex; align-items: center; gap: 14px;
            padding: 14px var(--gutter); text-decoration: none; color: #fff; cursor: pointer; }
.eb-emoji { font-size: 24px; flex-shrink: 0; }
.eb-text { display: flex; flex-direction: column; gap: 2px; line-height: 1.35; min-width: 0; }
.eb-text strong { font-size: 15px; font-weight: 800; }
.eb-text span { font-size: 12px; opacity: .82; }
.eb-cta { margin-left: auto; flex-shrink: 0; font-size: 12px; font-weight: 700;
          background: rgba(255,255,255,.16); padding: 7px 14px; border-radius: 20px;
          white-space: nowrap; transition: background .2s; }
.eb-slide:hover .eb-cta { background: rgba(255,255,255,.28); }
.eb-dots { position: absolute; bottom: 7px; left: 50%; transform: translateX(-50%);
           display: flex; gap: 6px; }
.eb-dots:empty { display: none; }
.eb-dot { width: 7px; height: 7px; padding: 0; border: none; border-radius: 50%;
          background: rgba(255,255,255,.4); cursor: pointer; transition: background .2s; }
.eb-dot.active { background: #fff; }

/* 이벤트 탭 버튼 강조 */
.series-btn-event.active { color: #ffd27a; }

/* 이벤트 카드 */
.event-grid { gap: 18px; }
.event-empty { color: #aaa; font-size: 14px; padding: 20px 4px; }
.event-card { display: flex; flex-direction: column; width: 260px; flex-shrink: 0;
              background: var(--color-surface); border-radius: var(--radius-card); overflow: hidden;
              box-shadow: 0 2px 10px rgba(0,0,0,.08); cursor: pointer; transition: all .22s;
              text-decoration: none; color: inherit; }
.event-card:hover { transform: translateY(-6px); box-shadow: 0 14px 36px rgba(0,0,0,.16); }
/* 무지 배경 + 책 표지 */
.event-card-poster { height: 150px; display: flex; align-items: center; justify-content: center;
                     background: #eef1f6; position: relative; }
.event-card-poster .event-book-cover { height: 116px; width: auto; border-radius: 4px;
                                       box-shadow: 0 5px 16px rgba(0,0,0,.25); }
.event-card-body { padding: 14px 16px 16px; }
.event-card-title { font-size: 14.5px; font-weight: 700; line-height: 1.45; word-break: keep-all; }
.event-card-period { font-size: 12px; color: var(--color-text-muted); margin-top: 8px; }
/* 종료된 이벤트 */
.event-card.ended { opacity: .75; }
.event-card.ended .event-card-poster { filter: grayscale(1) brightness(.96); }
.event-card.ended .event-card-period { color: #999; font-weight: 700; }

/* ===== 교강사 카톡방 팝업 ===== */
#popup-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5);
                 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-radius: 18px;
             padding: 34px 30px 22px; width: 100%; max-width: 360px; text-align: center;
             box-shadow: 0 12px 48px rgba(0,0,0,.28); }
.popup-x { position: absolute; top: 12px; right: 14px; border: none; background: none;
           font-size: 24px; line-height: 1; color: #bbb; cursor: pointer; padding: 4px; }
.popup-x:hover { color: #666; }
.popup-emoji { font-size: 44px; margin-bottom: 8px; }
#popup-box h3 { font-size: 18px; font-weight: 800; line-height: 1.4; margin-bottom: 12px; }
#popup-text { font-size: 14px; line-height: 1.65; color: var(--color-text-muted);
              margin-bottom: 22px; white-space: pre-line; }
.popup-join { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
              padding: 14px 16px; border-radius: 12px; background: #fee500; color: #191600;
              font-size: 15px; font-weight: 800; text-decoration: none; transition: filter .15s; }
.popup-join::before { content: "💬"; font-size: 16px; }
.popup-join:hover { filter: brightness(.96); }
.popup-dismiss { width: 100%; margin-top: 12px; padding: 8px; border: none; background: none;
                 font-size: 12.5px; color: #999; cursor: pointer; }
.popup-dismiss:hover { color: #666; text-decoration: underline; }

/* ===== 반응형 ===== */
@media (max-width: 768px) {
  /* 좌우 여백 축소 (--gutter가 따라감) */
  :root { --content-pad: 24px; }
  header h1 { font-size: 20px; }
  /* 시리즈 탭: 좁은 화면에서 가로 스크롤 (스크롤바 숨김) */
  .series-tabs { overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
  .series-tabs::-webkit-scrollbar { display: none; }
  .series-btn { padding: 14px 20px; white-space: nowrap; }
  /* 세로 클리핑 시 밑줄이 잘리지 않도록 박스 안쪽으로 */
  .series-btn.active::after { bottom: 0; }
  /* 필터: 여러 줄 대신 한 줄 가로 스크롤 칩 (터치 스와이프) */
  .filters { flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden;
             scrollbar-width: none; }
  .filters::-webkit-scrollbar { display: none; }
  .filter-btn { flex-shrink: 0; }
}

@media (max-width: 480px) {
  /* 여백·카드 축소 → 카드 2열 */
  :root {
    --content-pad: 16px;
    --card-width: 150px;
    --cover-width: 104px;
    --cover-height: 148px;
  }
  header { padding-top: 20px; padding-bottom: 20px; }
  .card-grid { gap: 12px; }
}
