/* Nepal Health Laws compendium — faceted browse UI.
   Styling piggybacks the saacho design system (brand/css/saacho.css): every
   colour/spacing/radius below is pulled from its CSS custom properties, so the
   app inherits brand themes and dark mode automatically. */

.hlw {
  max-width: 1280px;
  margin: 0 auto;
  padding: 36px 20px 60px;
  color: var(--ink);
}

/* ---------- Hero ---------- */
.hlw-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  flex-wrap: wrap;
  margin-bottom: 26px;
}
.hlw-hero-copy { max-width: 720px; }
.hlw-hero .display { margin: 8px 0 10px; font-size: clamp(1.8rem, 4vw, 2.6rem); }
.hlw-lede { color: var(--ink-dim); margin: 0; font-size: 1.02rem; line-height: 1.6; max-width: 60ch; }

.hlw-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.hlw-stat {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 92px; padding: 14px 18px; border-radius: var(--radius-lg);
  background: var(--card-bg); border: 1px solid var(--border);
}
.hlw-stat strong { font-size: 1.5rem; color: var(--brand); line-height: 1.1; }
.hlw-stat span { font-size: 0.78rem; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 0.4px; }

/* ---------- Toolbar ---------- */
.hlw-toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 22px;
}
.hlw-search { flex: 1 1 320px; margin: 0; }
.hlw-search input { width: 100%; }
.hlw-count { font-size: 0.9rem; color: var(--ink-dim); white-space: nowrap; }
.hlw-sort {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--card-bg); color: var(--ink); font-size: 0.9rem; cursor: pointer;
}
.hlw-fbtn { display: none; align-items: center; gap: 8px; }
.hlw-fcount {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px;
  background: var(--gold); color: #fff; font-size: 0.72rem; font-weight: 700;
}
.hlw-fcount:empty { background: transparent; }

/* ---------- Layout ---------- */
.hlw-body {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 26px;
  align-items: start;
}

/* ---------- Sidebar facets ---------- */
.hlw-side {
  position: sticky; top: 20px;
  display: flex; flex-direction: column; gap: 6px;
  max-height: calc(100vh - 40px); overflow: auto;
  padding: 4px 2px;
}
.hlw-side-head { display: none; }
.hlw-facet {
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--card-bg);
}
.hlw-facet-title {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin: 0; font-size: 0.9rem;
}
.hlw-ft {
  flex: 1; text-align: left; padding: 12px 14px; border: 0; cursor: pointer;
  background: none; color: var(--ink); font-weight: 700; font-size: 0.88rem;
  letter-spacing: 0.2px;
}
.hlw-ft::after {
  content: '\25be'; float: right; color: var(--ink-dim); font-size: 0.8em; transition: transform .15s ease;
}
.hlw-facet.closed .hlw-ft::after { transform: rotate(-90deg); }
.hlw-facet.closed .hlw-facet-body { display: none; }
.hlw-facet-count {
  font-size: 0.72rem; color: var(--ink-dim); margin-right: 14px; white-space: nowrap;
}
.hlw-facet-count.is-active {
  color: var(--brand); font-weight: 700;
  background: var(--brand-light); border-radius: 999px; padding: 1px 7px;
}
.hlw-facet-body { padding: 2px 14px 14px; border-top: 1px solid var(--border); }
.hlw-facet-search {
  width: 100%; margin: 10px 0 8px; padding: 7px 10px; font-size: 0.84rem;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); color: var(--ink);
}
.hlw-facet-list { display: flex; flex-direction: column; }
.hlw-opt {
  display: flex; align-items: center; gap: 8px; padding: 5px 2px;
  font-size: 0.86rem; cursor: pointer; color: var(--ink);
}
.hlw-opt input { accent-color: var(--brand); width: 15px; height: 15px; flex-shrink: 0; }
.hlw-opt-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hlw-opt-count {
  font-size: 0.72rem; color: var(--ink-dim); background: var(--bg);
  border-radius: 999px; padding: 1px 7px; flex-shrink: 0;
}
.hlw-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.hlw-opt-none { font-size: 0.82rem; color: var(--ink-dim); margin: 6px 0; }

.hlw-years { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 8px; border-top: 0; }
.hlw-year.hlw-opt { border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; font-size: 0.82rem; gap: 6px; }
.hlw-year .hlw-opt-count { background: none; padding: 0; }

.hlw-more { border: 0; background: none; color: var(--brand); cursor: pointer; font-size: 0.8rem; padding: 6px 2px 2px; text-align: left; }
.hlw-more:hover { text-decoration: underline; }

.hlw-clear { margin-top: 10px; width: 100%; }

/* ---------- Active filters ---------- */
.hlw-active { display: flex; flex-wrap: wrap; gap: 8px; min-height: 8px; margin-bottom: 14px; }
.hlw-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--brand-light); color: var(--brand-dark);
  border-radius: 999px; padding: 4px 6px 4px 12px; font-size: 0.8rem;
}
.hlw-chip button {
  border: 0; background: none; color: var(--brand-dark); cursor: pointer;
  font-size: 1rem; line-height: 1; width: 20px; height: 20px; border-radius: 50%;
}
.hlw-chip button:hover { background: var(--brand); color: #fff; }

/* ---------- Results grid ---------- */
.hlw-results {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(255px, 1fr));
  gap: 16px;
}
.hlw-loading {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 12px;
  color: var(--ink-dim); padding: 40px 0; justify-content: center;
}
.hlw-spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--brand);
  animation: hlw-spin .8s linear infinite;
}
@keyframes hlw-spin { to { transform: rotate(360deg); } }
.hlw-empty { grid-column: 1 / -1; color: var(--ink-dim); padding: 40px 10px; text-align: center; }

.hlw-card {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px; transition: border-color .15s ease, transform .15s ease; box-shadow: var(--card-shadow);
}
.hlw-card:hover { border-color: var(--brand); transform: translateY(-1px); }
.hlw-card-top { display: flex; gap: 6px; align-items: center; }
.hlw-type {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  background: color-mix(in srgb, var(--tt, #6b7280) 12%, transparent);
  color: color-mix(in srgb, var(--tt, #6b7280) 82%, #000);
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.3px;
}
.hlw-file { font-size: 0.66rem; color: var(--ink-dim); border: 1px solid var(--border); border-radius: 6px; padding: 1px 5px; }
.hlw-card-title { margin: 0; font-size: 0.98rem; line-height: 1.4; }
.hlw-card-title a {
  border: 0; background: none; cursor: pointer; text-align: left; padding: 0;
  color: var(--ink); font: inherit; font-weight: 700; line-height: 1.4; text-decoration: none;
}
.hlw-card-title a:hover { color: var(--brand); text-decoration: underline; }
.hlw-card-sum { margin: 0; font-size: 0.84rem; color: var(--ink-dim); line-height: 1.5; flex: 1; }
.hlw-card-meta {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 0.76rem; color: var(--ink-dim); border-top: 1px solid var(--border); padding-top: 8px;
}
.hlw-card-pub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: var(--ink); }
.hlw-card-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.hlw-topic {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 0.7rem;
  background: color-mix(in srgb, var(--tt, #6b7280) 10%, transparent);
  color: color-mix(in srgb, var(--tt, #6b7280) 78%, #000);
}
.hlw-topic-more { font-size: 0.7rem; color: var(--ink-dim); align-self: center; }

/* ---------- Pagination ---------- */
.hlw-pager { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 26px; flex-wrap: wrap; }
.hlw-page {
  min-width: 36px; height: 36px; padding: 0 10px; border-radius: var(--radius-md);
  border: 1px solid var(--border); background: var(--card-bg); color: var(--ink);
  font-weight: 600; font-size: 0.86rem; cursor: pointer;
}
.hlw-page:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.hlw-page:disabled { opacity: .5; cursor: default; }
.hlw-page.is-current { background: var(--brand); border-color: var(--brand); color: #fff; }
.hlw-page-gap { color: var(--ink-dim); padding: 0 4px; }

/* ---------- FAQ ---------- */
.hlw-faq {
  max-width: 860px; margin: 8px auto 0; padding: 8px 20px 48px;
  color: var(--ink); border-top: 1px solid var(--border);
}
.hlw-faq h2 { font-size: 1.35rem; margin: 28px 0 4px; }
.hlw-faq details {
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--card-bg); margin-top: 10px; padding: 14px 16px;
}
.hlw-faq summary { cursor: pointer; font-weight: 600; color: var(--ink); }
.hlw-faq p { color: var(--ink-dim); margin: 8px 0 0; font-size: 0.96rem; line-height: 1.6; }

/* ---------- Detail modal ---------- */
.hlw-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(10, 20, 25, 0.55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.hlw-overlay[hidden],
.hlw-side-bg[hidden] { display: none; }
.hlw-modal {
  position: relative; width: min(720px, 100%); max-height: 88vh; overflow: auto;
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 30px 32px 26px; box-shadow: 0 18px 50px rgba(0,0,0,.22);
}
.hlw-modal-close {
  position: absolute; top: 14px; right: 16px; border: 0; background: none; cursor: pointer;
  font-size: 1.6rem; line-height: 1; color: var(--ink-dim); width: 34px; height: 34px; border-radius: 50%;
}
.hlw-modal-close:hover { background: var(--bg); color: var(--ink); }
.hlw-modal-title { margin: 0 0 10px; font-size: 1.25rem; line-height: 1.45; padding-right: 40px; }
.hlw-modal-sum { color: var(--ink-dim); line-height: 1.6; font-size: 0.95rem; margin: 0 0 18px; }
.hlw-modal-h {
  font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--ink-dim); margin: 20px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.hlw-kv-list { display: table; margin: 0; width: 100%; }
.hlw-kv { display: table-row; }
.hlw-kv dt, .hlw-kv dd {
  display: table-cell; padding: 7px 12px 7px 0; font-size: 0.9rem; vertical-align: top;
}
.hlw-kv dt { color: var(--ink-dim); width: 38%; font-weight: 600; }
.hlw-kv dd a { color: var(--brand); text-decoration: none; font-weight: 600; word-break: break-all; }
.hlw-kv dd a:hover { text-decoration: underline; }
.hlw-ext { font-size: 0.8em; }
.hlw-modal-actions { display: flex; gap: 10px; margin-top: 24px; flex-wrap: wrap; }

/* ---------- Mobile ---------- */
.hlw-side-bg { display: block; }

@media (max-width: 980px) {
  .hlw-body { grid-template-columns: 1fr; }
  .hlw-side {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 80;
    width: min(340px, 92vw); max-height: none;
    background: var(--bg); border-right: 1px solid var(--border);
    transform: translateX(-105%); transition: transform .25s ease;
    padding: 16px; gap: 8px;
  }
  .hlw-side.open { transform: translateX(0); }
  .hlw-side-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
  .hlw-side-title { font-weight: 700; font-size: 1rem; }
  .hlw-side-close { border: 0; background: none; font-size: 1.5rem; color: var(--ink-dim); cursor: pointer; line-height: 1; }
  .hlw-side-bg {
    position: fixed; inset: 0; z-index: 75; background: rgba(10, 20, 25, 0.4); border: 0;
  }
  .hlw-fbtn { display: inline-flex; }
  .hlw-results { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
}

@media (max-width: 620px) {
  .hlw { padding: 24px 14px 48px; }
  .hlw-hero { flex-direction: column; align-items: stretch; }
  .hlw-results { grid-template-columns: 1fr; }
  .hlw-modal { padding: 24px 20px 20px; }
  .hlw-kv dt { width: 42%; }
}