/*
 * Pagefind 검색 버튼·모달을 테마(_settings.styl) 톤에 맞춘다.
 * pagefind-component-ui.css 가 :is(*, #\#) x3 로 우선순위를 높여 두었으므로
 * 같은 접두어를 붙이고 이 파일을 그 뒤에 불러 덮어쓴다.
 */
:root {
    --pf-font: 'Source Sans Pro', 'Helvetica Neue', Arial, sans-serif;
    --pf-text: #2c3e50;           /* $dark */
    --pf-text-secondary: #34495e; /* $medium */
    --pf-text-muted: #7f8c8d;     /* $light */
    --pf-border: #e8e8e8;
    --pf-border-focus: #42b983;   /* $green */
    --pf-outline-focus: #42b983;
    --pf-hover: #f4f6f6;
    --pf-mark: #42b983;
    --pf-border-radius: 6px;
}

/* 헤더·사이드바 검색 버튼: 테두리 없는 연회색 pill */
:is(*, #\#):is(*, #\#):is(*, #\#) .pf-trigger-btn {
    gap: 6px;
    height: 30px;
    padding: 0 12px;
    background: #f3f5f5;
    border: 0;
    border-radius: 15px;
    font-family: var(--pf-font);
    font-size: 0.9em;
    line-height: 30px;
    color: #7f8c8d;
    transition: background-color 0.15s, color 0.15s;
}
:is(*, #\#):is(*, #\#):is(*, #\#) .pf-trigger-btn:hover {
    background: #e9eded;
    color: #2c3e50;
}
:is(*, #\#):is(*, #\#):is(*, #\#) .pf-trigger-btn:hover .pf-trigger-text,
:is(*, #\#):is(*, #\#):is(*, #\#) .pf-trigger-btn:focus-visible .pf-trigger-text {
    color: #2c3e50;
}
:is(*, #\#):is(*, #\#):is(*, #\#) .pf-trigger-btn:hover .pf-trigger-icon,
:is(*, #\#):is(*, #\#):is(*, #\#) .pf-trigger-btn:focus-visible .pf-trigger-icon {
    background: #42b983;
}
:is(*, #\#):is(*, #\#):is(*, #\#) .pf-trigger-btn:focus-visible {
    outline: 2px solid #42b983;
    outline-offset: 1px;
}
:is(*, #\#):is(*, #\#):is(*, #\#) .pf-trigger-icon {
    width: 13px;
    height: 13px;
}
:is(*, #\#):is(*, #\#):is(*, #\#) .pf-trigger-text {
    color: inherit;
}

/*
 * 키캡: ⌘K(비 Mac 은 Ctrl K)를 pill 보다 한 단계 진한 작은 칩 하나로 묶는다.
 * 칩은 박스 기준으로 pill 세로 가운데(높이 18px, 위아래 6px)에 두고,
 * 칩 앞 간격(6 + 2 = 8px)을 아이콘-글자 간격(6px)보다 조금 넓게 둔다.
 * 칩은 가장자리가 또렷한 채워진 상자라 같은 12px 이면 아이콘 쪽보다 멀어 보인다.
 * 7·9·10·12px 를 확대 캡처로 비교해 왼쪽(아이콘 앞 12px)과 같아 보이는 10px 로 둔다.
 */
:is(*, #\#):is(*, #\#):is(*, #\#) .pf-trigger-btn:has(.pf-trigger-shortcut) {
    padding-inline-end: 10px;
}
:is(*, #\#):is(*, #\#):is(*, #\#) .pf-trigger-shortcut {
    display: inline-flex;
    align-items: center;
    gap: 1px;
    height: 18px;
    margin-inline-start: 2px;
    padding: 0 5px;
    background: #e4e9e9;
    border-radius: 4px;
    transition: background-color 0.15s;
}
:is(*, #\#):is(*, #\#):is(*, #\#) .pf-trigger-shortcut.is-word {
    gap: 3px;
}
:is(*, #\#):is(*, #\#):is(*, #\#) .pf-trigger-btn:hover .pf-trigger-shortcut {
    background: #dce2e2;
}
:is(*, #\#):is(*, #\#):is(*, #\#) .pf-trigger-key {
    min-width: 0;
    height: 18px;
    padding: 0;
    background: transparent;
    border: 0;
    font-size: 11px;
    font-weight: 500;
    line-height: 18px;
    color: #7f8c8d;
}
/*
 * ⌘ 아이콘(js/search-panel.js 가 글자를 SVG 로 바꾼다): K 의 cap height(11px x 0.66 ≈ 7px)에
 * 획 두께만큼 더한 8px 정사각으로 두고, 칩의 inline-flex 가운데 정렬로 K 와 시각 중심을 맞춘다.
 */
:is(*, #\#):is(*, #\#):is(*, #\#) .pf-trigger-key.is-icon {
    display: inline-flex;
    align-items: center;
}
:is(*, #\#):is(*, #\#):is(*, #\#) .pf-trigger-key-icon {
    display: block;
    width: 8px;
    height: 8px;
}

/*
 * #nav li 는 inline-block 이고 줄 높이가 40px 이다. vertical-align: middle 은
 * 줄 상자 가운데가 아니라 baseline + x-height/2 에 맞춰 버튼이 메뉴 글자보다 3~4px 처졌다.
 * li 를 줄 상자 위에 붙여 헤더 높이만큼 채우고 그 안에서 flex 로 가운데에 둔다.
 */
#nav .search-query-nav-wrapper {
    vertical-align: top;
    height: 100%;
}
#nav pagefind-modal-trigger {
    display: flex;
    align-items: center;
    height: 100%;
    line-height: normal;
}

/*
 * 모바일 메뉴(사이드바)·menu 페이지: 한 줄을 다 쓰는 pill
 * 사이드바 안쪽 여백이 왼쪽 20px·오른쪽 10px 이라 pill 이 오른쪽 끝에 붙어 보였다.
 * 오른쪽을 10px 더 띄워 좌우를 20px 로 맞추고, 아래 메뉴와는 메뉴 사이 간격(7px)보다
 * 넓은 12px 로 떼어 입력 칸과 목록을 구분한다.
 */
.main-menu .search-query-sidebar-wrapper,
#search-form {
    margin-bottom: 12px;
}
.main-menu .search-query-sidebar-wrapper {
    margin-right: 10px;
}
.main-menu pagefind-modal-trigger,
#search-form pagefind-modal-trigger {
    display: block;
    width: 100%;
}
:is(*, #\#):is(*, #\#):is(*, #\#) .main-menu .pf-trigger-btn,
:is(*, #\#):is(*, #\#):is(*, #\#) #search-form .pf-trigger-btn {
    height: 36px;
    border-radius: 18px;
    background: #fff;
    box-shadow: inset 0 0 0 1px #e8e8e8;
    font-size: 15px;
}

/* 모달: 결과 카드 hover·선택을 초록 톤으로 */
:is(*, #\#):is(*, #\#):is(*, #\#) dialog.pf-modal {
    font-family: var(--pf-font);
    color: var(--pf-text);
}
:is(*, #\#):is(*, #\#):is(*, #\#) .pf-result-title {
    font-weight: 600;
}

/*
 * 모달 본문 스크롤바: 기본 스크롤바(15px)가 본문 안쪽 폭을 먹어 결과 카드 오른쪽 끝이
 * 입력창보다 15px 안으로 들어갔다. 8px 짜리 얇은 막대를 항상 자리 잡게 두고
 * 오른쪽 안쪽 여백을 그만큼(16px - 8px) 줄여 카드와 입력창의 좌우 끝을 맞춘다.
 */
:is(*, #\#):is(*, #\#):is(*, #\#) .pf-modal-body {
    padding-right: 8px;
    scrollbar-gutter: stable;
}
.pf-modal-body::-webkit-scrollbar {
    width: 8px;
}
.pf-modal-body::-webkit-scrollbar-thumb {
    background: #d5dbdb;
    border: 2px solid transparent;
    border-radius: 4px;
    background-clip: padding-box;
}
.pf-modal-body::-webkit-scrollbar-track {
    background: transparent;
}
@supports not selector(::-webkit-scrollbar) {
    :is(*, #\#):is(*, #\#):is(*, #\#) .pf-modal-body {
        scrollbar-width: thin;
    }
}

/*
 * 결과 묶음: 결과 사이(8px)와 카드-하위 제목 사이(8px)가 같아 하위 제목이 어느 카드에
 * 딸렸는지 흐렸다. 묶음 안은 6px, 묶음 사이는 16px 로 나눈다. 하위 제목 칩은
 * 카드 글자 시작선(테두리 1px + 안쪽 12px = 13px)에 맞춘다.
 */
:is(*, #\#):is(*, #\#):is(*, #\#) .pf-results {
    gap: 16px;
}
:is(*, #\#):is(*, #\#):is(*, #\#) .pf-result {
    gap: 6px;
}
:is(*, #\#):is(*, #\#):is(*, #\#) .pf-heading-chips {
    padding-inline-start: 13px;
}

/* 검색어를 넣기 전 패널(partials/search_modal.ejs, js/search-panel.js) */
:is(*, #\#):is(*, #\#):is(*, #\#) .is-search-empty pagefind-summary,
:is(*, #\#):is(*, #\#):is(*, #\#) .is-search-empty pagefind-results {
    display: none;
}
.search-panel[hidden],
.search-panel-section[hidden] {
    display: none;
}
/* 본문 위아래 여백과 합쳐 입력창 아래·푸터 위가 모두 16px 이 되게 한다 */
.search-panel {
    padding: 8px 0 0;
    font-family: var(--pf-font);
}
/* 숨긴 구역 뒤에는 여백을 주지 않도록, 보이는 구역 다음 구역에만 띄운다 */
.search-panel-section:not([hidden]) ~ .search-panel-section {
    margin-top: 20px;
}
.search-panel ul {
    margin: 0;
    padding: 0;
    list-style: none;
}
.search-panel li {
    margin: 0;
}
.search-panel h2.search-panel-title,
.search-panel h3.search-shortcut-title {
    margin: 0;
    padding: 0;
    border: 0;
    font-family: inherit;
}
.search-panel h2.search-panel-title {
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 600;
    line-height: 16px;
    color: #7f8c8d;
}
.search-panel button {
    margin: 0;
    font-family: inherit;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}
.search-panel button:focus-visible,
.search-panel a:focus-visible {
    outline: 2px solid #42b983;
    outline-offset: 1px;
}

/*
 * 최근 검색어: 글자를 제목·칩과 같은 시작선에 두고, hover 배경만 양옆으로 8px 넓힌다.
 * × 버튼(24px)은 행(36px) 안에서 위아래가 선택 테두리(2px) 안쪽으로 4px 떨어진다.
 * 오른쪽도 4px 가 되도록 margin-right 6px 로 두어 × 가 선택 행 안에 한 덩어리로 들어가게 한다.
 */
/* .search-panel li { margin: 0 } 보다 우선하도록 .search-panel 을 붙인다 */
.search-panel .search-recent-item {
    display: flex;
    align-items: center;
    height: 36px;
    margin: 0 -8px;
    border-radius: 6px;
}
.search-panel .search-recent-item:hover,
.search-panel .search-recent-item:focus-within {
    background: #f4f6f6;
}
/*
 * 키보드로 고른 행은 글자 버튼이 아니라 행 전체(× 포함)에 초록 테두리를 둘러 한 덩어리로 보이게 한다.
 * × 에 포커스가 있으면 테두리 안에서 × 만 한 단계 진하게 표시한다.
 */
.search-panel .search-recent-term:focus-visible,
.search-panel .search-recent-remove:focus-visible {
    outline: none;
}
.search-panel .search-recent-item:has(:focus-visible) {
    box-shadow: inset 0 0 0 2px #42b983;
}
.search-recent-term {
    flex: 1;
    min-width: 0;
    height: 100%;
    padding: 0 8px;
    background: none;
    border: 0;
    border-radius: 6px;
    text-align: left;
    font-size: 14px;
    line-height: 36px;
    color: #34495e;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.search-recent-term:hover {
    color: #2c3e50;
}
.search-panel .search-recent-remove {
    display: flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-right: 6px;
    padding: 0;
    background: none;
    border: 0;
    border-radius: 12px;
    color: #a9b3b4;
}
.search-panel .search-recent-remove:hover,
.search-panel .search-recent-remove:focus-visible {
    background: #e4e9e9;
    color: #2c3e50;
}

/* 추천 검색어: 헤더 검색 버튼과 같은 연회색 pill */
.search-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.search-chip {
    height: 30px;
    padding: 0 12px;
    background: #f3f5f5;
    border: 0;
    border-radius: 15px;
    font-size: 13px;
    line-height: 30px;
    color: #34495e;
    transition: background-color 0.15s, color 0.15s;
}
.search-chip:hover {
    background: #e9eded;
    color: #2c3e50;
}

/* 가이드 바로가기: 가이드마다 한 칸, 좁은 화면에선 한 줄에 하나 */
.search-shortcuts {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}
.search-panel h3.search-shortcut-title {
    margin-bottom: 4px;
    font-size: 13px;
    font-weight: 600;
    line-height: 20px;
    color: #2c3e50;
}
.search-shortcut-link {
    display: block;
    padding: 3px 0;
    font-size: 14px;
    line-height: 20px;
    color: #34495e;
    text-decoration: none;
    word-break: keep-all;
    border-radius: 3px;
}
.search-shortcut-link:hover {
    color: #42b983;
}
@media screen and (max-width: 640px) {
    .search-shortcuts {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

/* 헤더가 좁아지는 폭에선 키캡을 숨긴다 */
@media screen and (max-width: 1100px) {
    :is(*, #\#):is(*, #\#):is(*, #\#) .pf-trigger-shortcut {
        display: none;
    }
    /* 키캡을 숨기면 칩용으로 줄인 오른쪽 여백을 왼쪽과 같게 되돌린다 */
    :is(*, #\#):is(*, #\#):is(*, #\#) .pf-trigger-btn:has(.pf-trigger-shortcut) {
        padding-inline-end: 12px;
    }
}
