/* 통합 검색 · 라이브러리 페이지 (styles.css 의 다크 테마 변수를 사용) */
/* 다른 목록 메뉴처럼 화면 끝까지 쓴다. 맨 위 소개·검색창·예시 질문만 읽기 좋은 폭으로 둔다 */
.search-page { padding: 32px 32px 0; box-sizing: border-box; }
.search-hero { margin: 0 0 14px; max-width: 960px; font-size: 1.45rem; font-weight: 700; line-height: 1.4; color: var(--b-text); }
.search-page .search-box, .search-examples { max-width: 960px; }

/* 예시 질문(처음 화면) — 누르면 바로 AI 검색 */
.search-examples { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 12px; }
.search-examples span { margin-right: 4px; font-size: .85rem; color: var(--text-secondary); }
.search-examples button {
  padding: 6px 13px; border-radius: 999px; cursor: pointer; font: inherit; font-size: .86rem;
  background: transparent; color: var(--b-accent); border: 1px solid color-mix(in srgb, var(--b-accent) 45%, transparent);
}
.search-examples button:hover, .search-examples button:focus-visible { background: color-mix(in srgb, var(--b-accent) 12%, transparent); outline: none; }
.search-examples[hidden] { display: none; }

.search-box { display: flex; gap: 8px; }
/* styles.css 의 옛 .search-box(영상 페이지용: 가운데 정렬·줄바꿈·휴대폰 세로 쌓기)가 단추를 납작하게 만들지 않게 */
.search-page .search-box { align-items: stretch; flex-wrap: nowrap; flex-direction: row; padding: 0; margin-bottom: 0; }
.search-box input {
  flex: 1; min-width: 0; padding: 14px 16px; font-size: 1.05rem;
  background: var(--bg-secondary); color: var(--text-primary);
  border: 1px solid var(--bg-border); border-radius: 10px;
}
.search-box input:focus { outline: none; border-color: var(--b-accent); }
.search-box button {
  padding: 0 22px; border: 0; border-radius: 10px; cursor: pointer; white-space: nowrap; flex-shrink: 0;
  background: var(--b-accent); color: var(--b-accent-ink); font-size: 1rem; font-weight: 700;
}
.search-box button:hover { filter: brightness(1.08); }


/* AI 추천 */
.ai-panel {
  margin: 16px 0 4px; padding: 16px; border-radius: 12px;
  background: var(--b-accent-soft); border: 1px solid color-mix(in srgb, var(--b-accent) 35%, transparent);
}
.ai-head { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--b-accent); font-size: .92rem; }
.ai-head img { border-radius: 4px; }
.ai-answer { margin: 10px 0 0; color: var(--text-primary); line-height: 1.65; }
.ai-panel.is-loading .ai-answer { color: var(--text-secondary); animation: ai-pulse 1.4s ease-in-out infinite; }
@keyframes ai-pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .ai-panel.is-loading .ai-answer { animation: none; } }

.ai-picks { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(380px, 100%), 1fr)); gap: 8px; }
.ai-picks:empty { display: none; }
.pick {
  display: flex; gap: 10px; padding: 10px; border-radius: 10px;
  background: var(--bg-secondary); border: 1px solid var(--bg-border);
}
.pick:hover { background: var(--bg-tertiary); }
.pick-thumb { flex: 0 0 96px; }
.pick-thumb img, .pick-thumb .res-noimg { width: 96px; height: 54px; object-fit: cover; border-radius: 6px; background: var(--bg-tertiary); display: block; }
.pick .res-title { font-size: .92rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pick-why { margin: 4px 0 0; font-size: .82rem; color: var(--text-secondary); line-height: 1.45; }

.ai-next { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.ai-next:empty { display: none; }
.ai-next button {
  padding: 5px 12px; border-radius: 999px; cursor: pointer; font-size: .82rem;
  background: transparent; color: var(--b-accent); border: 1px solid color-mix(in srgb, var(--b-accent) 45%, transparent);
}
.ai-next button:hover { background: color-mix(in srgb, var(--b-accent) 12%, transparent); }
.ai-next button::before { content: '→ '; }

.src-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 16px 0 4px; }
.src-tabs button {
  padding: 7px 14px; border-radius: 999px; cursor: pointer; font-size: .9rem;
  background: var(--bg-secondary); color: var(--text-secondary); border: 1px solid var(--bg-border);
}
.src-tabs button:hover { background: var(--bg-hover); }
.src-tabs button[aria-selected="true"] {
  background: var(--b-accent); color: var(--b-accent-ink); border-color: transparent; font-weight: 700;
}
.src-tabs small { opacity: .75; margin-left: 2px; }

.info { margin: 16px 0 10px; color: var(--text-secondary); font-size: .92rem; min-height: 1.4em; }

/* 결과는 목록 모양 그대로, 넓은 화면에서 2열 */
.results { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(640px, 100%), 1fr)); gap: 10px; align-items: start; }
.res {
  display: flex; gap: 14px; padding: 12px; border-radius: 10px;
  background: var(--bg-secondary); border: 1px solid var(--bg-border);
}
.res:hover { background: var(--bg-tertiary); }
.res-thumb { flex: 0 0 150px; }
.res-thumb img, .res-noimg {
  width: 150px; height: 84px; object-fit: cover; border-radius: 6px; background: var(--bg-tertiary); display: block;
}
.res-body { min-width: 0; }
.res-badge {
  display: inline-block; padding: 1px 8px; margin-right: 6px; border-radius: 4px;
  font-size: .72rem; font-weight: 700; color: #111; vertical-align: 1px;
}
.res-badge-v { background: var(--b-challenge); }
.res-badge-t { background: var(--b-accent); }
.res-badge-l { background: var(--b-lesson); }
.res-badge-s { background: var(--b-support); }
/* 지원 문서는 썸네일이 없어 표시만 그린다 */
/* 그림 대신 자료 종류 아이콘(📖 수업 · 🏆 챌린지 · 📘 수업 가이드) */
.res-noimg, .pick-thumb .res-noimg { display: flex; align-items: center; justify-content: center; font-size: 2rem; line-height: 1; }
.pick-thumb .res-noimg { font-size: 1.4rem; }
.res-s .res-noimg { display: flex; align-items: center; justify-content: center; color: var(--b-support); }
.res-s .res-noimg::after { content: '지원 문서'; font-size: .8rem; font-weight: 700; letter-spacing: .02em; }
.res-title { color: var(--text-primary); font-weight: 600; text-decoration: none; }
.res-title:hover { text-decoration: underline; }
.res-sub { margin: 4px 0 2px; font-size: .8rem; color: var(--text-tertiary); }
.res-snip { margin: 2px 0 0; font-size: .88rem; color: var(--text-secondary); line-height: 1.5; overflow-wrap: anywhere; }

/* 결과 사이 광고 1개(search.js 의 AD). 광고가 실제로 채워졌을 때만 틀과 '광고' 표시를 보인다.
   결과 카드와 헷갈리지 않게 점선 테두리·다른 바탕을 쓴다 */
/* 여백은 처음부터 둔다 — 애드센스가 광고를 넣는 순간의 너비로 광고 크기를 정하므로, 채워진 뒤에 여백이 생기면 광고가 틀 밖으로 삐져나온다 */
.res-ad { min-width: 0; padding: 8px 12px 12px; border-radius: 10px; border: 1px dashed transparent; }
.res-ad ins { max-width: 100%; overflow: hidden; }
.res-ad[hidden], .res-ad:has(ins[data-ad-status="unfilled"]) { display: none; }
.res-ad-label { display: none; }
.res-ad:has(ins[data-ad-status="filled"]) { background: var(--bg-primary); border-color: var(--bg-border); }
.res-ad:has(ins[data-ad-status="filled"]) .res-ad-label {
  display: block; margin-bottom: 6px; font-size: .72rem; font-weight: 700; color: var(--text-tertiary);
}

/* '더 보기' 단추 모양은 theme.css (모든 목록 메뉴 공통) */

/* 검색어가 없을 때 보이는 추천 영상 (카드 모양은 styles.css 의 .featured-card) */
.search-featured { margin: 8px 0 40px; }
.search-featured h2 { margin: 0 0 14px; font-size: 1.05rem; font-weight: 700; color: var(--b-text); }
.search-featured .video-grid { grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr)); gap: 18px; padding: 0; margin-top: 0; }
.search-featured .card-header { padding: 14px 16px 12px; margin-bottom: 0; }
.search-featured .card-header h2 { margin: 0 0 4px; font-size: 1.05rem; }
.search-featured .card-header p { font-size: .86rem; }
.search-featured .video-card img { height: auto; aspect-ratio: 16 / 9; }
.search-featured .video-card h3 { font-size: .95rem; padding: 12px 16px 0; margin-bottom: 8px; min-height: 0; max-height: calc(3em + 12px); }

@media (max-width: 600px) {
  .res { flex-direction: column; }
  .res-thumb, .res-thumb img, .res-noimg { width: 100%; flex-basis: auto; height: auto; aspect-ratio: 16 / 9; }
}

@media (max-width: 768px) {
  .ai-picks { grid-template-columns: 1fr; }
  .search-page { padding: 20px 16px 0; }
  .search-hero { font-size: 1.15rem; }
}
