/* ============================================================
   FRONTLENS Search Page
   공통 토큰(--blue, --ink, --border 등)은 style.css에서 상속한다.
   ============================================================ */

/* ── 검색 Hero: 입력창 영역 ────────────────────────────────── */

.search-hero {
  padding: 32px 0 24px;
  border-bottom: 1px solid var(--border-light);
}

/* 검색어 표시줄: "Searched for: [keyword ×]" */
.search-hero-query {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.search-hero-label {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--gray);
  letter-spacing: 0.04em;
}

.search-keyword-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  background: var(--bg-off);
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-keyword-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: var(--border);
  color: var(--gray-dark);
  font-size: 10px;
  cursor: pointer;
  flex-shrink: 0;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
}

.search-keyword-remove:hover {
  background: var(--ink);
  color: #fff;
}

/*
  검색 폼: content 영역 전폭으로 맞춘다 (IGNANT 레퍼런스 참고).
  max-width 제거 → 컨테이너 width에 따름.
*/
.search-hero-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-hero-form:focus-within {
  border-color: var(--ink);
}

.search-hero-input {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  border: none;
  font-size: 14px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

.search-hero-input::placeholder {
  color: var(--gray-light);
}

.search-hero-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: none;
  border-left: 1px solid var(--border-light);
  background: #fff;
  color: var(--gray);
  font-size: 14px;
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
  flex-shrink: 0;
}

.search-hero-btn:hover {
  color: var(--ink);
  background: var(--bg-off);
}

/* ── 전체 레이아웃: 사이드바 + 결과 ────────────────────────── */

.search-page-wrap {
  padding-top: 28px;
  padding-bottom: 72px;
}

/*
  데스크톱: 좌측 필터 트리 240px + 결과 그리드 flex-1
  모바일(≤768px): 단일 컬럼
*/
.search-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 48px;
  align-items: start;
}

/* ── 필터 사이드바 (카테고리 트리) ─────────────────────────── */

.search-sidebar {
  position: sticky;
  top: calc(var(--header-h) + 20px);
}

/*
  카테고리 트리 그룹: 하나의 상위 카테고리 + 자식 목록.
  border-bottom으로 그룹 간 구분선을 표시한다.
*/
.sr-tree-group {
  border-bottom: 1px solid var(--border-light);
}

.sr-tree-group:first-child {
  border-top: 1px solid var(--border-light);
}

/* 상위 카테고리 행: 이름 + 토글 화살표 */
.sr-tree-parent-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 2px;
}

/* 상위 카테고리 label (체크박스를 감싸 클릭 영역 전체를 활성화) */
.sr-tree-parent-link {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  text-decoration: none;
  min-width: 0;
  cursor: pointer;
  transition: color var(--transition);
}

.sr-tree-parent-link:hover {
  color: var(--blue);
}

/* 체크박스 스타일 인디케이터 */
.sr-tree-check {
  width: 14px;
  height: 14px;
  border: 1.5px solid var(--border);
  border-radius: 3px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--transition), background var(--transition);
}

/* 체크된 상태는 .sr-tree-cb:checked + .sr-tree-check 로 처리 (위 체크박스 섹션 참조) */

/* 토글 버튼: 자식 목록 열기/닫기 */
.sr-tree-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: none;
  background: none;
  color: var(--gray);
  font-size: 10px;
  cursor: pointer;
  border-radius: 4px;
  transition: color var(--transition), background var(--transition), transform var(--transition);
  flex-shrink: 0;
}

.sr-tree-toggle:hover {
  color: var(--ink);
  background: var(--bg-off);
}

/* 열린 상태 화살표 회전 */
.sr-tree-group.open .sr-tree-toggle {
  transform: rotate(180deg);
}

/* 자식 카테고리 목록: 접히는 영역 */
.sr-tree-children {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.28s ease;
  padding-left: 22px;
}

/* JS가 없을 때 CSS만으로 항상 펼쳐 보이게 (progressive enhancement) */
.sr-tree-group.open .sr-tree-children {
  /* max-height는 JS에서 scrollHeight로 설정 */
  max-height: 600px;
}

.sr-tree-children-inner {
  padding: 4px 0 10px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

/* 자식 카테고리 label */
.sr-tree-child-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 4px;
  font-size: 12.5px;
  color: var(--gray-dark);
  text-decoration: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
}

.sr-tree-child-link:hover {
  color: var(--ink);
  background: var(--bg-off);
}

/* 연도 필터 */
.search-year-filter {
  margin-top: 20px;
}

.search-year-title {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gray);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
}

.search-year-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.search-year-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 4px;
  font-size: 12.5px;
  color: var(--gray-dark);
  text-decoration: none;
  border-radius: var(--radius);
  transition: color var(--transition), background var(--transition);
}

.search-year-link:hover {
  color: var(--ink);
  background: var(--bg-off);
}

.search-year-link.active {
  color: var(--blue);
  font-weight: 500;
}

.search-year-link.active .sr-tree-check {
  border-color: var(--blue);
  background: var(--blue);
}

.search-year-link.active .sr-tree-check::after {
  content: '';
  display: block;
  width: 8px;
  height: 5px;
  border-left: 1.5px solid #fff;
  border-bottom: 1.5px solid #fff;
  transform: rotate(-45deg) translateY(-1px);
}

/* ── 체크박스: 네이티브 숨김 + CSS 인디케이터 연동 ─────────────── */

/*
  네이티브 체크박스는 시각적으로 숨기고, 인접한 .sr-tree-check 요소로 표현한다.
  label로 감싸져 있으므로 클릭 영역은 label 전체다.
*/
.sr-tree-cb {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

/* 체크된 상태: .sr-tree-check에 파란 배경 + 체크 마크 */
.sr-tree-cb:checked + .sr-tree-check {
  border-color: var(--blue);
  background: var(--blue);
}

.sr-tree-cb:checked + .sr-tree-check::after {
  content: '';
  display: block;
  width: 8px;
  height: 5px;
  border-left: 1.5px solid #fff;
  border-bottom: 1.5px solid #fff;
  transform: rotate(-45deg) translateY(-1px);
}

/* ── 칩 바: 활성 필터 pill 목록 ────────────────────────────── */

/*
  검색 결과 상단에 활성 필터를 pill 형태로 나열한다.
  카테고리 칩은 JS로 제거, keyword·year 칩은 <a href> 링크로 제거한다.
*/
.search-chips-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}

.search-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px 4px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg-off);
  font-size: 12px;
  font-weight: 500;
  max-width: 220px;
}

.search-chip-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
}

/* search-keyword-remove 스타일 재사용: × 버튼 */
.search-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: var(--border);
  color: var(--gray-dark);
  font-size: 10px;
  cursor: pointer;
  flex-shrink: 0;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
  padding: 0;
  line-height: 1;
}

.search-chip-remove:hover {
  background: var(--ink);
  color: #fff;
}

/* ── 검색 결과 본문 ─────────────────────────────────────────── */

.search-main {
  min-width: 0;
}

/* 정렬 탭 + 결과 수 한 줄 배치 */
.search-sort-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 24px;
}

.search-sort-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gray);
  margin-right: 6px;
}

.search-sort-tabs {
  display: flex;
  align-items: center;
  gap: 0;
}

/* IGNANT 스타일 정렬 탭: 활성 탭은 하단 밑줄로 표시 */
.search-sort-tab {
  padding: 4px 10px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gray);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  transition: color var(--transition), border-color var(--transition);
}

.search-sort-tab:hover {
  color: var(--ink);
}

.search-sort-tab.active {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

/* 결과 범위: "13-24 OF 6986" */
.search-result-count {
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gray);
  white-space: nowrap;
}

/* ── 3열 결과 그리드 ─────────────────────────────────────────── */

.sr-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 40px 24px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.sr-grid-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

/* 썸네일 */
.sr-gc-thumb {
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--bg-subtle);
  margin-bottom: 14px;
  position: relative;
}

.sr-gc-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.45s ease;
}

.sr-grid-link:hover .sr-gc-thumb img {
  transform: scale(1.04);
}

/* 이미지 없을 때 placeholder */
.sr-gc-thumb-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-subtle);
  color: var(--border);
  font-size: 32px;
}

/* 카테고리 태그: "PARENT · CHILD" */
.sr-gc-meta {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 8px;
  /* fc-section-tag tag-N 클래스와 함께 사용해 색상 적용 */
}

.sr-gc-meta-sep {
  color: var(--gray-light);
  margin: 0 3px;
  font-weight: 400;
}

/* 제목 */
.sr-gc-title {
  font-family: var(--serif);
  font-size: clamp(14px, 1.4vw, 17px);
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
  transition: opacity var(--transition);
}

.sr-grid-link:hover .sr-gc-title {
  opacity: 0.65;
}

/* ── Load More 버튼 ──────────────────────────────────────────── */

.search-load-more-wrap {
  display: flex;
  justify-content: center;
  margin-top: 48px;
}

/*
  IGNANT 스타일 Load More: 얇은 테두리, 넓은 패딩, 올 캡스 모노 폰트.
  hover 시 배경/글자 색 반전.
*/
.search-load-more-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 180px;
  height: 44px;
  padding: 0 28px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.search-load-more-btn:hover {
  background: var(--ink);
  color: #fff;
}

.search-load-more-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── Empty State ─────────────────────────────────────────────── */

.search-empty {
  padding: 60px 0;
  text-align: center;
}

.search-empty-icon {
  font-size: 36px;
  color: var(--border);
  margin-bottom: 14px;
}

.search-empty-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 8px;
}

.search-empty-desc {
  font-size: 13.5px;
  color: var(--gray);
  max-width: 38ch;
  margin: 0 auto;
  line-height: 1.65;
}

/* ── 반응형 ──────────────────────────────────────────────────── */

@media (max-width: 1100px) {
  .search-layout {
    grid-template-columns: 200px 1fr;
    gap: 32px;
  }

  .sr-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 32px 18px;
  }
}

@media (max-width: 768px) {
  /* 모바일: 레이아웃 단일 컬럼 */
  .search-layout {
    grid-template-columns: 1fr;
    gap: 0;
  }

  /* 사이드바: 수평 스크롤 필터 바 */
  .search-sidebar {
    position: static;
    overflow-x: auto;
    display: flex;
    gap: 0;
    padding-bottom: 12px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-light);
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .search-sidebar::-webkit-scrollbar { display: none; }

  /* 모바일에서 트리 그룹을 가로 나열 */
  .sr-tree-group {
    flex-shrink: 0;
    border-bottom: none;
    border-top: none;
    border-right: 1px solid var(--border-light);
    padding-right: 16px;
  }

  .sr-tree-group:last-child { border-right: none; }

  .sr-tree-parent-row { padding: 6px 0; }

  .sr-tree-toggle { display: none; }

  /* 모바일에서 자식 목록은 항상 표시 */
  .sr-tree-children {
    max-height: none !important;
    overflow: visible;
    padding-left: 0;
  }

  .sr-tree-children-inner { padding: 4px 0 6px; }

  .sr-tree-child-link { font-size: 12px; }

  .search-year-filter {
    flex-shrink: 0;
    margin-top: 0;
    padding-left: 16px;
    border-left: 1px solid var(--border-light);
  }

  /* 모바일 2열 그리드 */
  .sr-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 28px 14px;
  }

  .search-hero-form {
    grid-template-columns: 1fr auto;
  }
}
.sr-gc-thumb-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sr-gc-thumb-category {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--tag-1); /* 기본값, tag-bg에 맞게 아래서 분기 */
}

.tag-bg-1 { background: var(--tag-1-bg); }
.tag-bg-1 .sr-gc-thumb-category { color: var(--tag-1); }

.tag-bg-2 { background: var(--tag-2-bg); }
.tag-bg-2 .sr-gc-thumb-category { color: var(--tag-2); }

.tag-bg-3 { background: var(--tag-3-bg); }
.tag-bg-3 .sr-gc-thumb-category { color: var(--tag-3); }

.tag-bg-4 { background: var(--tag-4-bg); }
.tag-bg-4 .sr-gc-thumb-category { color: var(--tag-4); }

.tag-bg-5 { background: var(--tag-5-bg); }
.tag-bg-5 .sr-gc-thumb-category { color: var(--tag-5); }

.tag-bg-6 { background: var(--tag-6-bg); }
.tag-bg-6 .sr-gc-thumb-category { color: var(--tag-6); }

@media (max-width: 480px) {
  /* 모바일 1열 그리드 */
  .sr-grid {
    grid-template-columns: 1fr;
    gap: 24px 0;
  }

  .search-sort-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}
