/* 통합 검색 판 — layouts/partials/search-panel, search/partials/field · results, search-panel.js */

/* 입력칸 — 둥근 막대 하나 안에 돋보기 · 입력 · 지우기 · 검색. 누르면 막대 전체에 파란 테두리. */
.search-field {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    max-width: 40rem;
    height: 2.75rem;
    padding: 0 0.25rem 0 1rem;
    /* 흰 칸 — 회색 바탕 위에서 입력칸이 또렷하게. 어두운 화면은 카드보다 한 단계 밝은 면. */
    background: #fff;
    color: var(--tx);
    border: 1px solid var(--ln);
    border-radius: 999px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

[data-bs-theme="dark"] .search-field {
    background: var(--sf-hover);
}

.search-field-input::placeholder {
    color: var(--tx-faint);
}

.search-field:focus-within {
    border-color: var(--theme-primary);
    box-shadow: 0 0 0 0.2rem rgba(var(--theme-primary-rgb), 0.15);
}

.search-field-icon {
    width: 1.125rem;
    height: 1.125rem;
    flex-shrink: 0;
    color: var(--theme-secondary-color);
}

.search-field-input {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    padding: 0 0.5rem;
    border: 0;
    outline: 0;
    background: transparent;
    color: inherit;
    font-size: 0.9375rem;
}
/* 손가락 기기: 판이 열린 동안 뒤 화면을 잠근다 — 입력칸 · 빈 곳 · 어두운 막을 세로로 끌면 뒤 화면이 스크롤되던 것.
   (PC 는 스크롤바가 사라지며 화면이 밀리므로 걸지 않는다) */
@media (hover: none) and (pointer: coarse) {
    html.is-search-open,
    html.is-search-open body {
        overflow: hidden;
    }
    .search-backdrop {
        touch-action: none;
    }
}
/* 손가락 기기(휴대폰 · 태블릿): 16px 글자 — 아이폰 · 아이패드는 그보다 작은 입력칸을 누르면 화면을 확대한다 */
@media (hover: none) and (pointer: coarse) {
    .search-field-input {
        font-size: 16px;
    }
}

.search-field-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--theme-secondary-color);
}

.search-field-clear:hover {
    background: var(--theme-light);
    color: var(--theme-body-color);
}

.search-field-submit {
    flex-shrink: 0;
    height: calc(100% - 0.5rem);
    padding: 0 1.125rem;
    border-radius: 999px;
}

/* 판 — 상단바 바로 아래, 위에서 아래로 펼쳐진다(clip-path). 화면 폭 전체. */
.search-panel {
    position: fixed;
    top: var(--theme-topbar-height);
    left: 0;
    right: 0;
    z-index: 1035;
    max-height: calc(100vh - var(--theme-topbar-height) - 1rem);
    max-height: calc(100dvh - var(--theme-topbar-height) - 1rem);
    overflow: hidden;
    background: var(--theme-body-bg);
    border-bottom: 1px solid var(--ln);
    box-shadow: 0 0.75rem 1.5rem rgba(15, 23, 42, 0.12);
    clip-path: inset(0 0 100% 0);
    visibility: hidden;
    transition: clip-path 0.25s ease-in-out, visibility 0s linear 0.25s;
}
.search-panel.is-open {
    clip-path: inset(0 0 -2rem 0);   /* 아래 그림자까지 보이게 */
    visibility: visible;
    transition: clip-path 0.25s ease-in-out;
}
.search-panel-inner {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: inherit;
    padding: 1.5rem 1.5rem 2rem;
}
.search-panel .search-field {
    flex-shrink: 0;
    width: 100%;
    margin: 0.5rem auto 0;
}
.search-backdrop {
    position: fixed;
    inset: var(--theme-topbar-height) 0 0 0;
    z-index: 1034;
    background: rgba(15, 23, 42, 0.3);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease-in-out, backdrop-filter 0.25s ease-in-out;
}
.search-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}

/* 어두운 화면 — 판과 뒤 화면이 같은 바탕색이라 막을 더 짙게, 판 아래 경계를 또렷하게 */
[data-bs-theme="dark"] .search-backdrop {
    background: rgba(0, 0, 0, 0.6);
}
[data-bs-theme="dark"] .search-panel {
    border-bottom-color: rgba(255, 255, 255, 0.12);
    box-shadow: 0 0.75rem 2rem rgba(0, 0, 0, 0.6);
}

/* 최근 검색어 — 입력칸 아래 알약 한 줄(넘치면 다음 줄) */
.search-recent {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    flex-shrink: 0;
    width: 100%;
    max-width: 40rem;
    margin: 0 auto;
}
.search-recent[hidden] {
    display: none;
}
.search-recent-title {
    margin-right: 0.25rem;
    font-size: 0.8125rem;
    color: var(--theme-secondary-color);
}
.search-recent-item {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--ln);
    border-radius: 999px;
    background: var(--sf-card);
    font-size: 0.8125rem;
}
.search-recent-link {
    padding: 0.25rem 0.25rem 0.25rem 0.75rem;
    border: 0;
    background: none;
    color: inherit;
}
.search-recent-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    margin-right: 0.125rem;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--theme-secondary-color);
}
.search-recent-remove svg {
    width: 0.875rem;
    height: 0.875rem;
}
.search-recent-link:hover,
.search-recent-remove:hover {
    color: var(--theme-body-color);
}

/* 결과 — 묶음 열이 옆으로 이어지고 넘치면 옆으로 민다. 열 안은 따로 세로 스크롤. */
/* 판 높이가 모자라면(가로로 눕힌 휴대폰) 입력칸 · 최근 검색어는 그대로, 결과만 줄고 안에서 스크롤 */
.search-results {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;   /* 끝까지 밀어도 뒤 화면이 따라 스크롤되지 않게 */
}
/* 결과 없음 · 찾는 중 · 오류 안내 — 판 가운데 보통 글자보다 크게 */
.search-empty {
    padding: 2rem 0;
    text-align: center;
    font-size: 1.0625rem;
    color: var(--theme-secondary-color);
}
.search-columns {
    display: flex;
    align-items: flex-start;   /* 열마다 제 내용 높이 — 가장 긴 열에 맞추면 짧은 열 아래가 비었다 */
    gap: 1rem;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    padding-bottom: 0.5rem;
}
.search-column {
    display: flex;
    flex: 0 0 20rem;
    flex-direction: column;
    min-width: 0;
    max-height: min(28rem, calc(100dvh - var(--theme-topbar-height) - 11rem));
    border: 1px solid var(--ln);
    border-radius: 0.625rem;
    background: var(--sf-card);
    scroll-snap-align: start;
    overflow: hidden;
}
.search-column-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.875rem;
    border-bottom: 1px solid var(--ln);
}
.search-column-title {
    font-weight: 600;
}
.search-column-count {
    color: var(--theme-secondary-color);
    font-size: 0.8125rem;
}
.search-column-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.search-column-more {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.25rem;
    padding: 0.5rem 0.875rem;
    border-top: 1px solid var(--ln);
    font-size: 0.8125rem;
    text-decoration: none;
}

@media (max-width: 575.98px) {
    .search-panel-inner {
        padding: 1rem 1rem 1.5rem;
    }
    /* 휴대폰은 열 하나가 화면 폭 가까이 — 옆 열이 살짝 보여 밀 수 있다는 것을 알린다 */
    .search-column {
        flex-basis: calc(100vw - 3.5rem);
    }
}
@media (prefers-reduced-motion: reduce) {
    .search-panel,
    .search-panel.is-open,
    .search-backdrop {
        transition: none;
    }
}
.search-avatar {
    width: 1.75rem;
    height: 1.75rem;
    flex-shrink: 0;
    font-size: 0.75rem;
}
