/* ==========================================================
   components/header.css — 상단 헤더
   .hdr · .logo · .hdr-search(검색 열기) · .my-pill(내 학교) · .icon-btn
   · .subnav(데스크톱 메뉴) · .mobile-menu(767px 이하 서랍 메뉴)
   마크업은 tools/lib/layout.js 의 header() 에서 만든다.
   ========================================================== */

.hdr {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s, box-shadow .2s;
}
.hdr.is-scrolled { border-bottom-color: var(--line); box-shadow: 0 6px 20px -14px rgba(29, 36, 51, .25); }
.hdr-top { height: var(--hdr-h); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.hdr-actions { display: flex; align-items: center; gap: 4px; min-width: 0; }

/* ---------- 로고 ---------- */
.logo { display: flex; align-items: center; gap: 8px; min-height: 40px; font-size: 20px; font-weight: 800; letter-spacing: -.05em; color: var(--ink); }
.logo svg { width: 32px; height: 32px; }
.logo b { color: var(--brand); font-weight: 800; }

/* ---------- 검색 열기 버튼 (데스크톱은 입력창 모양, 모바일은 아이콘) ---------- */
.hdr-search {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px;
  border-radius: 12px; background: var(--surface-2); color: var(--ink-3);
  font-size: 14px; font-weight: 600; transition: background .15s;
}
.hdr-search:hover { background: var(--surface-3); }
.hdr-search .ico { width: 18px; height: 18px; }
.hdr-search kbd {
  margin-left: 20px; padding: 0 6px; border-radius: 6px; border: 1px solid var(--line);
  background: #fff; font: 700 11px/1.6 var(--font); color: var(--ink-4);
}

/* ---------- 내 학교 알약 ---------- */
.my-pill {
  display: inline-flex; align-items: center; gap: 5px; max-width: 38vw; height: 36px; padding: 0 12px 0 10px;
  border-radius: 999px; background: var(--brand-soft); color: var(--brand-deep);
  font-size: 13.5px; font-weight: 700; white-space: nowrap; transition: background .15s;
}
.my-pill:hover { background: var(--brand-soft-2); }
.my-pill .ico { width: 15px; height: 15px; fill: currentColor; stroke-width: 1.6; }
.my-pill .txt { overflow: hidden; text-overflow: ellipsis; }
.my-pill b { font-weight: 800; color: var(--navy); }

/* ---------- 아이콘 버튼 ---------- */
.icon-btn {
  position: relative; width: 40px; height: 40px; flex: none; border-radius: 12px;
  display: grid; place-items: center; color: var(--ink-2); transition: background .15s;
}
.icon-btn:hover { background: var(--surface-2); }
.menu-toggle { display: none; }

/* ---------- 데스크톱 서브내비 ---------- */
.subnav {
  height: var(--nav-h); display: flex; align-items: center; gap: 4px;
  overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px 6px;
}
.subnav::-webkit-scrollbar { display: none; }
.subnav a {
  flex: none; height: 36px; display: inline-flex; align-items: center; gap: 6px; padding: 0 14px;
  border-radius: 999px; font-size: 14px; font-weight: 600; color: var(--ink-2); transition: background .2s, color .2s;
}
.subnav a:hover { background: var(--surface-2); color: var(--ink); }
.subnav a.is-active { background: var(--brand-soft); color: var(--brand-deep); font-weight: 700; }

/* ---------- 모바일 서랍 메뉴 ---------- */
.menu-dim, .menu-shell { display: none; }

@media (max-width: 767px) {
  .hdr { background: rgba(255, 255, 255, .96); }
  .subnav { display: none; }
  .menu-toggle { display: grid; }

  .hdr-search { width: 40px; padding: 0; justify-content: center; background: none; color: var(--ink-2); }
  .hdr-search:hover { background: var(--surface-2); }
  .hdr-search .ico { width: 21px; height: 21px; }
  .hdr-search span, .hdr-search kbd { display: none; }

  /* 닫힌 서랍이 문서 가로 폭을 늘리지 않게 뷰포트 크기 셸로 잘라낸다 */
  .menu-shell { position: fixed; inset: 0; z-index: 120; display: block; overflow: hidden; pointer-events: none; }
  .menu-dim {
    position: fixed; inset: 0; z-index: 110; display: block;
    background: rgba(29, 36, 51, .28); opacity: 0; pointer-events: none; transition: opacity .24s ease;
  }
  .menu-dim.open { opacity: 1; pointer-events: auto; }
  .mobile-menu {
    position: absolute; top: 0; right: 0; bottom: 0;
    display: flex; flex-direction: column; width: min(86vw, 340px);
    padding-bottom: env(safe-area-inset-bottom); background: #fff; pointer-events: auto;
    box-shadow: -18px 0 46px -20px rgba(29, 36, 51, .32);
    transform: translateX(104%); visibility: hidden;
    transition: transform .3s var(--ease), visibility 0s linear .3s;
  }
  .mobile-menu.open { transform: none; visibility: visible; transition-delay: 0s; }
  body.menu-open { overflow: hidden; }

  .mobile-menu-head {
    min-height: 64px; display: flex; align-items: center; justify-content: space-between;
    padding: 0 16px 0 20px; border-bottom: 1px solid var(--line);
  }
  .mobile-menu-head strong { font-size: 19px; font-weight: 800; letter-spacing: -.035em; }
  .mobile-menu-nav { min-height: 0; display: grid; gap: 4px; padding: 14px 12px; overflow-y: auto; }
  .mobile-menu-nav a, .mobile-menu-nav button {
    width: 100%; min-height: 48px; display: flex; align-items: center; gap: 10px;
    padding: 0 14px; border-radius: 14px; color: var(--ink-2); font-size: 15px; font-weight: 700; text-align: left;
  }
  .mobile-menu-nav .ico { color: var(--ink-4); }
  .mobile-menu-nav a.is-active { background: var(--brand-soft); color: var(--brand-deep); }
  .mobile-menu-nav a.is-active .ico { color: var(--brand); }
  .mobile-menu-nav .grp { margin: 10px 0 2px; padding: 0 14px; font-size: 12px; font-weight: 800; letter-spacing: .02em; color: var(--ink-4); }
  .mobile-menu-util { display: grid; gap: 2px; margin-top: auto; padding: 12px; border-top: 1px solid var(--line); }
  .mobile-menu-util a {
    min-height: 44px; display: flex; align-items: center; padding: 0 14px;
    border-radius: 14px; color: var(--ink-3); font-size: 14px; font-weight: 600;
  }
  .mobile-menu-util a:hover { background: var(--surface-2); }
}
