/*
 * 사업 검색 (project-search.js) — 상단 검색칸 · 후보 목록 · 가운데 사업 창.
 * 이 기능을 지우려면 이 파일과 project-search.js, index.html 에서 둘을 싣는 두 줄만 지운다.
 * 색은 styles.css 의 변수만 쓴다(밝은·어두운 화면 모두 따라간다).
 */

/* 상단 메뉴: 1줄 로고 + 검색칸, 2줄 메뉴. has-ps 는 project-search.js 가 검색칸을 붙일 때 단다. */
.appbar-inner.has-ps { row-gap: 6px; padding-top: 10px; padding-bottom: 6px; }
.appbar-inner.has-ps .app-tabs { order: 3; flex-basis: 100%; }

.ps { position: relative; margin-left: auto; flex: 0 1 380px; min-width: 0; display: flex; align-items: center; }
.ps-icon {
  position: absolute; left: 12px; top: 50%; width: 14px; height: 14px; margin-top: -8px;
  border: 2px solid var(--muted); border-radius: 50%; pointer-events: none;
}
.ps-icon::after {
  content: ""; position: absolute; right: -6px; bottom: -5px; width: 7px; height: 2px;
  background: var(--muted); transform: rotate(45deg); border-radius: 1px;
}
.ps-input {
  width: 100%; min-height: 38px; padding: 7px 34px 7px 36px;
  background: var(--bg); border-radius: 999px;
}
.ps-input::placeholder { color: var(--muted); }
.ps-kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  min-width: 20px; padding: 0 5px; border: 1px solid var(--line); border-radius: 5px;
  color: var(--muted); font-size: 11px; font-weight: 600; line-height: 18px; text-align: center; pointer-events: none;
}
.ps-input:focus + .ps-kbd, .ps-input:not(:placeholder-shown) + .ps-kbd { display: none; }

/* 후보 목록 */
.ps-list {
  position: absolute; z-index: 40; top: calc(100% + 6px); right: 0;
  width: min(520px, calc(100vw - 32px)); max-height: min(70vh, 560px); overflow-y: auto;
  padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 12px 32px rgb(0 0 0 / 28%);
}
.ps-list[hidden] { display: none; }
.ps-opt {
  display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 10px;
  border-radius: 8px; cursor: pointer;
}
.ps-opt[aria-selected="true"] { background: color-mix(in srgb, var(--brand) 14%, transparent); }
.ps-opt-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ps-opt-title {
  font-weight: 700; font-size: 14px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.ps-opt-meta { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ps-opt-src { flex: none; color: var(--muted); font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.ps-note { margin: 6px 10px; color: var(--muted); font-size: 12.5px; }
.ps-warn { color: var(--danger); }
.ps-dot { flex: none; display: inline-block; width: 9px; height: 9px; border-radius: 50%; }

/* 사업 창 (가운데) */
.ps-dialog {
  width: min(780px, calc(100vw - 32px)); max-width: none; max-height: min(88vh, 880px);
  padding: 0; border-radius: 14px; overflow: hidden;
}
.ps-dialog[open] { display: flex; flex-direction: column; }
.ps-dialog::backdrop { background: rgb(0 0 0 / 55%); }
body:has(.ps-dialog[open]) { overflow: hidden; }

.ps-head {
  flex: none; display: flex; align-items: flex-start; gap: 12px;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--line);
}
.ps-head-main { flex: 1; min-width: 0; }
.ps-kicker { display: flex; align-items: center; gap: 7px; margin: 0; color: var(--muted); font-size: 13px; font-weight: 600; }
.ps-head h2 { margin: 4px 0 2px; font-size: 21px; line-height: 1.3; letter-spacing: -0.02em; }
.ps-owner { margin: 0; font-size: 14px; }
.ps-count { margin: 4px 0 0; color: var(--muted); font-size: 12.5px; }
.ps-close {
  flex: none; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text); font-size: 16px; cursor: pointer;
}
.ps-close:hover { border-color: var(--brand); }

.ps-body { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 20px 16px; }
.ps-sec { margin-top: 16px; }
.ps-sec h3 { margin: 0 0 8px; color: var(--muted); font-size: 13px; letter-spacing: 0.01em; }
.ps-sec-note { margin: 6px 0 0; color: var(--muted); font-size: 12px; }

.ps-facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.ps-facts dt { color: var(--muted); font-size: 13px; white-space: nowrap; }
.ps-facts dd { margin: 0; font-size: 14px; }

.ps-tl { list-style: none; margin: 0; padding: 0; }
.ps-ev {
  display: grid; grid-template-columns: 82px 64px 1fr; gap: 10px; align-items: baseline;
  padding: 8px 0; border-top: 1px solid var(--line);
}
.ps-ev[hidden] { display: none; }
.ps-ev-date { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ps-ev.is-future .ps-ev-date { color: var(--brand); font-weight: 700; }
.ps-ev-src { color: var(--c); font-size: 12px; font-weight: 700; white-space: nowrap; }
.ps-ev-src::before {
  content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 5px; vertical-align: 1px;
  border-radius: 50%; background: var(--c);
}
.ps-ev-text { min-width: 0; }
.ps-ev-text b { display: block; font-size: 14px; font-weight: 600; }
.ps-ev-sub { display: block; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }
.ps-more-btn { margin-top: 8px; }

.ps-link {
  padding: 0; border: 0; background: none; color: var(--offshore); font: inherit; font-size: 12.5px;
  cursor: pointer; text-decoration: none;
}
.ps-link:hover { text-decoration: underline; }

.ps-news { list-style: none; margin: 0; padding: 0; }
.ps-news li { padding: 6px 0; border-top: 1px solid var(--line); }
.ps-news-meta { display: block; color: var(--muted); font-size: 12px; }
.ps-news a { color: var(--text); font-weight: 600; font-size: 14px; text-decoration: none; }
.ps-news a:hover { color: var(--brand); text-decoration: underline; }

.ps-maybe { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ps-maybe-btn {
  display: flex; align-items: baseline; gap: 9px; width: 100%; min-height: 44px; padding: 8px 12px;
  border: 1px dashed var(--line); border-radius: 10px; background: none; color: var(--text);
  font: inherit; font-size: 14px; text-align: left; cursor: pointer;
}
.ps-maybe-btn:hover { border-color: var(--brand); }

.ps-basis { margin: 18px 0 0; color: var(--muted); font-size: 12px; }

.ps-foot {
  flex: none; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px;
  padding: 12px 20px; border-top: 1px solid var(--line);
}

/* 손가락으로 쓰는 화면: 단축키 표시를 숨기고, 창은 화면 전체로 */
@media (hover: none) { .ps-kbd { display: none; } }
@media (max-width: 640px) {
  .appbar-inner.has-ps { column-gap: 12px; }
  .ps { flex: 1 1 0; } /* 기본 폭을 0 으로 — 입력칸 고유 폭 때문에 로고 아래 줄로 내려가지 않게 */
  .ps-kbd { display: none; }
  .ps-dialog {
    width: 100vw; height: 100dvh; max-height: none; margin: 0;
    border: 0; border-radius: 0;
  }
  .ps-head { padding: 14px 16px 12px; }
  .ps-body { padding: 4px 16px 16px; }
  .ps-foot { padding: 10px 16px; }
  .ps-foot .btn { min-height: 44px; }
  .ps-foot-close { display: none; } /* 위쪽 ✕ 로 닫는다 — 바닥 버튼이 한 줄에 들어가게 */
  .ps-facts { grid-template-columns: 1fr; gap: 0; }
  .ps-facts dd { margin-bottom: 8px; }
  .ps-ev { grid-template-columns: 70px 1fr; gap: 2px 10px; }
  .ps-ev-src { grid-column: 2; grid-row: 1; }
  .ps-ev-text { grid-column: 2; }
}
