/* 수업 주제 페이지 (src/build-topics.js 가 만든 /topics/*.html) — theme.css 의 B 토큰 사용 */
.tp { max-width: 1196px; padding: 28px 32px 0; box-sizing: border-box; }
/* 목록 페이지는 영상·건축물처럼 화면 끝까지 쓰고 카드 수가 창 너비에 따라 바뀐다(주제 본문 페이지는 읽기 좋게 폭을 둔다) */
.tp-wide { max-width: none; }
.tp-wide .tp-cards { grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 1.25rem; }
.tp-preview-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  margin-bottom: 18px; padding: 10px 14px; border-radius: 10px;
  background: #3A2C12; border: 1px solid #5A4520; color: var(--b-challenge); font-size: 14px;
}
.tp-preview-bar a { color: var(--b-text); font-weight: 700; text-decoration: none; padding: 6px 12px; border-radius: 8px; background: var(--b-raised); }
.tp-preview-bar a:hover { background: var(--b-hover); }
.tp-crumb { display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--b-muted); }
.tp-crumb a { color: var(--b-muted); text-decoration: none; }
.tp-crumb a:hover { color: var(--b-text); }
.tp-head { margin: 14px 0 28px; }
.tp-head h1 { display: flex; align-items: center; gap: 12px; margin: 0; font-size: 32px; line-height: 1.3; color: var(--b-text); }
.tp-icon { font-size: 30px; }
.tp-head p { margin: 10px 0 0; font-size: 16px; color: var(--b-muted); }
.tp-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.tp-meta span {
  padding: 4px 10px; border-radius: 8px; font-size: 13px;
  background: var(--b-surface); border: 1px solid var(--b-border); color: var(--b-text);
}
.tp-meta .tp-type { background: var(--b-accent-soft); border-color: transparent; color: var(--b-accent); font-weight: 700; }

.tp-layout { display: flex; flex-wrap: wrap; gap: 32px; align-items: flex-start; }
.tp-body { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 18px; }
.tp-toc {
  flex: 1 1 220px; position: sticky; top: 24px; box-sizing: border-box;
  padding: 16px; border-radius: 14px; background: var(--b-surface); border: 1px solid var(--b-border);
}
.tp-toc h2 { margin: 0 0 10px; font-size: 12px; font-weight: 700; color: var(--b-muted); }
.tp-toc ol { margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 2px; }
.tp-toc a { display: block; padding: 6px 8px; border-radius: 8px; font-size: 13px; line-height: 1.4; color: var(--b-muted); text-decoration: none; }
.tp-toc a:hover { background: var(--b-raised); color: var(--b-text); }

/* 본문 구획 */
.tp-sec {
  padding: 22px 24px; border-radius: 14px; background: var(--b-surface); border: 1px solid var(--b-border);
  scroll-margin-top: 24px; line-height: 1.7; color: var(--b-text);
}
.tp-sec > h2 { margin: 0 0 12px; font-size: 20px; line-height: 1.4; }
.tp-md p { margin: 0 0 10px; }
.tp-md ul, .tp-md ol { margin: 0 0 12px; padding-left: 22px; }
.tp-md li { margin: 3px 0; }
.tp-md strong { color: #fff; }
.tp-md a { color: var(--b-accent); }
.tp-md code { padding: 1px 6px; border-radius: 6px; background: var(--b-raised); font-family: var(--b-mono); font-size: .9em; }
.tp-md pre { padding: 12px 14px; border-radius: 10px; background: var(--b-bg); overflow-x: auto; }
.tp-md pre code { padding: 0; background: none; }
.tp-md blockquote { margin: 0 0 12px; padding: 10px 14px; border-radius: 10px; background: var(--b-raised); color: var(--b-muted); }
.tp-md table { width: 100%; border-collapse: collapse; margin: 0 0 12px; font-size: 14px; display: block; overflow-x: auto; }
.tp-md th, .tp-md td { padding: 8px 10px; border-bottom: 1px solid var(--b-border); text-align: left; vertical-align: top; }
.tp-md th { color: var(--b-muted); font-weight: 700; white-space: nowrap; }
.tp-md > :last-child { margin-bottom: 0; }

.tp-fig { margin: 4px 0 12px; }
.tp-fig img { display: block; width: 100%; height: auto; border-radius: 10px; background: var(--b-bg); }
.tp-fig figcaption { margin-top: 6px; font-size: 13px; color: var(--b-muted); }
.tp-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 4px 0 12px; }
.tp-cols .tp-fig { margin: 0; }

/* 교사용 메모 */
.tp-note { border-radius: 14px; background: var(--b-bg); border: 1px dashed var(--b-border); scroll-margin-top: 24px; }
.tp-note > summary {
  display: flex; align-items: center; gap: 8px; padding: 14px 18px; cursor: pointer;
  font-size: 14px; font-weight: 700; color: var(--b-muted); list-style: none;
}
.tp-note > summary::-webkit-details-marker { display: none; }
.tp-note > summary::before { content: '+'; font-family: var(--b-mono); color: var(--b-accent); }
.tp-note[open] > summary::before { content: '−'; }
.tp-note .tp-md { padding: 0 20px 16px; font-size: 14px; color: var(--b-muted); line-height: 1.7; }

/* 아래 참고 영역 */
.tp-more { margin-top: 40px; display: flex; flex-direction: column; gap: 32px; }
.tp-more h2 { margin: 0 0 14px; font-size: 18px; color: var(--b-text); }
.tp-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.tp-card {
  display: flex; flex-direction: column; overflow: hidden; text-decoration: none; color: var(--b-text);
  background: var(--b-surface); border: 1px solid var(--b-border); border-radius: 14px;
}
.tp-card:hover { border-color: var(--b-accent); }
.tp-card img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; background: var(--b-raised); display: block; }
.tp-card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; }
.tp-card-badge { align-self: flex-start; padding: 2px 8px; border-radius: 6px; font-size: 12px; font-weight: 700; }
.tp-card-badge.v { background: #3A1F22; color: #F08A8D; }
.tp-card-badge.l { background: #1E2D45; color: var(--b-lesson); }
.tp-card-badge.t { background: var(--b-accent-soft); color: var(--b-accent); }

/* 주제 종류(활동·개념…)마다 고유한 색 — 태그 버튼·카드 표시·상세 머리에 같이 쓴다 */
.ty-concept  { --ty: #8AB8FF; }
.ty-tool     { --ty: #F5B841; }
.ty-activity { --ty: #3FCF8E; }
.ty-case     { --ty: #FF8FA3; }
.ty-world    { --ty: #5CD6E5; }
.ty-etc      { --ty: #A1A6AE; }
.tp-card-badge[class*="ty-"],
.tp-meta .tp-type[class*="ty-"] { background: color-mix(in srgb, var(--ty) 16%, transparent); color: var(--ty); border-color: transparent; }
.tp-card h3 { margin: 0; font-size: 15px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tp-card p { margin: 0; font-size: 13px; color: var(--b-muted); }
.tp-links .tp-md { line-height: 1.8; }
.tp-sources { margin: 0; padding-left: 20px; font-size: 13px; color: var(--b-muted); line-height: 1.8; }

/* 주제 목록 (/topics/) */
/* 목록 제목은 화면에서 숨기고 화면 읽기·검색엔진용으로만 남긴다(개수는 검색창 안내 글자에 들어 있다) */
.tp-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.tp-search { position: relative; max-width: 720px; margin: 6px 0 0; }
.tp-search span { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--b-faint); font-size: 18px; pointer-events: none; }
.tp-search input {
  width: 100%; box-sizing: border-box; padding: 14px 16px 14px 44px; font: inherit; font-size: 1rem;
  background: var(--b-surface); color: var(--b-text); border: 1px solid var(--b-border); border-radius: 12px;
}
.tp-search input:focus { outline: none; border-color: var(--b-accent); }
.tp-types { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.tp-type-btn {
  padding: 6px 14px; border-radius: 999px; cursor: pointer; font: inherit; font-size: 14px; font-weight: 700;
  background: transparent; color: var(--ty); border: 2px solid color-mix(in srgb, var(--ty) 60%, transparent);
  transition: background .15s, transform .15s;
}
.tp-type-btn small { font-family: var(--b-mono); font-size: 12px; font-weight: 500; opacity: .8; }
.tp-type-btn:hover { background: color-mix(in srgb, var(--ty) 14%, transparent); transform: translateY(-1px); }
.tp-type-btn[aria-pressed="true"] { background: var(--ty); border-color: var(--ty); color: var(--b-accent-ink); }
.tp-search-info { margin: 12px 0 0; min-height: 1.4em; font-size: 14px; color: var(--b-muted); }
.tp-search-info a { color: var(--b-accent); }
/* 검색·태그를 안 쓸 때는 안내 줄이 비어 있으니 자리를 차지하지 않게 하고, 첫 대주제는 태그 바로 아래에 붙인다 */
.tp-search-info:empty { display: none; }
#tpGroups > .tp-group:first-child { margin-top: 22px; }
#tpResults { margin-top: 14px; }
[hidden]#tpResults, [hidden]#tpGroups, .tp-group[hidden], .tp-card[hidden] { display: none; }
.tp-group { margin-top: 30px; }
.tp-group h2 { margin: 0 0 14px; font-size: 18px; color: var(--b-text); }
.tp-group .tp-card-body p { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tp-card-icon { font-size: 22px; }

@media (max-width: 768px) {
  .tp { padding: 18px 16px 0; }
  .tp-head h1 { font-size: 24px; }
  .tp-toc { display: none; }
  .tp-sec { padding: 18px 16px; }
}
