/* ============================================================================
   Digital Handbook PMBM SIFA 2027/2028 — handbook.css
   Layout membaca, navigasi, pencarian, dan mode cetak.
   Dimuat setelah style.css.
   ========================================================================== */

/* ---------- Reading progress ---------- */
.reading-progress { position: fixed; inset: 0 0 auto 0; height: 3px; z-index: 95; pointer-events: none; }
.reading-progress__bar {
  display: block; height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--green-700), var(--gold-600));
  transition: width 90ms linear;
}

/* ---------- Shell ---------- */
.hb-shell { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 clamp(1rem, 4vw, 2rem); }

@media (min-width: 1024px) {
  .hb-shell { display: grid; grid-template-columns: 264px minmax(0, 1fr); gap: clamp(1.5rem, 3vw, 3rem); align-items: start; }
  .hb-nav-toggle { display: none; }
  .drawer.hb-sidebar {
    position: sticky; top: var(--header-h); inset: auto; width: auto;
    max-height: calc(100vh - var(--header-h)); transform: none; visibility: visible;
    background: transparent; border-right: 1px solid var(--line);
    padding: var(--s6) var(--s4) var(--s6) 0;
  }
  .drawer.hb-sidebar .drawer__close { display: none; }
  .hb-shell + .overlay, .overlay.hb-overlay { display: none; }
}

.hb-main { padding: var(--s5) 0 var(--s8); min-width: 0; }

.hb-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--s5); align-items: start; }
@media (min-width: 1280px) {
  .hb-grid { grid-template-columns: minmax(0, 1fr) 212px; gap: var(--s6); }
  .hb-grid > .hb-body { order: 1; }
  .hb-grid > .toc { order: 2; position: sticky; top: calc(var(--header-h) + var(--s5)); margin-bottom: 0; }
}

.hb-section { margin: 0 0 var(--s7); scroll-margin-top: calc(var(--header-h) + 1rem); }
.hb-section:last-of-type { margin-bottom: 0; }
.hb-section > h2 { margin-bottom: var(--s4); }
.hb-body p, .hb-body li { max-width: var(--measure); }

/* ---------- Page head ---------- */
.hb-head { margin-bottom: var(--s6); }
.breadcrumb { margin: 0 0 var(--s4); font-size: var(--fs-cap); }
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; margin: 0; padding: 0; }
.breadcrumb li { margin: 0; color: var(--muted); display: flex; align-items: center; gap: .4rem; }
.breadcrumb li + li::before { content: "/"; color: var(--line-strong); }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--green-700); text-decoration: underline; }
.breadcrumb [aria-current="page"] { color: var(--green-900); font-weight: 600; }

.hb-indicator {
  display: inline-flex; align-items: center; gap: .55rem; margin: 0 0 var(--s3);
  padding: .34rem .8rem; border-radius: var(--r-pill);
  background: var(--green-100); color: var(--green-700);
  font-family: var(--font-display); font-size: var(--fs-label); font-weight: 700;
  letter-spacing: var(--ls-label); text-transform: uppercase;
}
.hb-indicator__track { width: 54px; height: 4px; border-radius: var(--r-pill); background: rgba(20,81,63,.2); overflow: hidden; }
.hb-indicator__fill { display: block; height: 100%; background: var(--green-700); border-radius: inherit; }

/* ---------- Local TOC ---------- */
.toc { border: 1px solid var(--line); background: var(--surface); border-radius: var(--r-md); padding: .35rem .9rem; margin-bottom: var(--s5); }
.toc > summary {
  cursor: pointer; list-style: none; padding: .65rem 0; min-height: 44px;
  display: flex; align-items: center; gap: .5rem;
  font-family: var(--font-display); font-weight: 700; font-size: var(--fs-sm); color: var(--green-900);
}
.toc > summary::-webkit-details-marker { display: none; }
.toc > summary::after {
  content: ""; margin-left: auto; width: 8px; height: 8px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: rotate(45deg) translateY(-2px); transition: transform var(--tr-fast);
}
.toc[open] > summary::after { transform: rotate(-135deg) translateY(-2px); }
.toc ol { list-style: none; margin: 0 0 .7rem; padding: .2rem 0 0; border-top: 1px solid var(--line); }
.toc li { margin: 0; }
.toc a { display: block; padding: .55rem 0; font-size: var(--fs-sm); color: var(--ink-soft); text-decoration: none; border-bottom: 1px solid var(--paper-alt); }
.toc li:last-child a { border-bottom: 0; }
.toc a:hover { color: var(--green-700); text-decoration: underline; }
@media (min-width: 1280px) {
  .toc { padding: .9rem 1rem; }
  .toc > summary { pointer-events: none; padding-top: 0; min-height: 0; }
  .toc > summary::after { display: none; }
  .toc ol { margin-top: .5rem; }
}

/* ---------- Cards & konten handbook ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: clamp(1rem, 2.5vw, 1.4rem); box-shadow: var(--sh1); }

.facts { display: grid; gap: .7rem; grid-template-columns: minmax(0, 1fr); margin-bottom: var(--s4); }
@media (min-width: 560px) { .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1000px) { .facts--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.fact { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--gold-600); border-radius: var(--r-sm); padding: .95rem 1rem; }
.fact__label { display: block; font-size: var(--fs-label); font-weight: 700; letter-spacing: var(--ls-label); text-transform: uppercase; color: var(--muted); margin-bottom: .3rem; }
.fact__value { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; color: var(--green-900); line-height: 1.35; }
.fact__note { margin: .3rem 0 0; font-size: var(--fs-cap); color: var(--muted); }

/* Daftar tindakan bernomor (reset lokal, tidak melanjutkan numbering dokumen) */
.actions { counter-reset: act; list-style: none; margin: 0 0 var(--s4); padding: 0; }
.actions > li { position: relative; counter-increment: act; padding-left: 2.15rem; margin-bottom: .7rem; }
.actions > li::before {
  content: counter(act); position: absolute; left: 0; top: .05rem;
  width: 1.55rem; height: 1.55rem; border-radius: 50%;
  background: var(--green-050); border: 1px solid var(--line); color: var(--green-900);
  font-family: var(--font-display); font-size: .76rem; font-weight: 700;
  display: grid; place-items: center;
}

/* Checklist non-interaktif (bullet centang) */
.ticks { list-style: none; margin: 0 0 var(--s4); padding: 0; display: grid; gap: .55rem; }
.ticks > li { position: relative; margin: 0; padding-left: 1.9rem; font-size: var(--fs-sm); }
.ticks > li::before {
  content: ""; position: absolute; left: .25rem; top: .48rem;
  width: .62rem; height: .34rem; border-left: 2px solid var(--green-600);
  border-bottom: 2px solid var(--green-600); transform: rotate(-45deg);
}

/* Timeline 8 tahap */
.timeline { list-style: none; margin: 0 0 var(--s4); padding: 0; }
.timeline > li { position: relative; margin: 0; padding: 0 0 var(--s5) 2.7rem; }
.timeline > li::before { content: ""; position: absolute; left: .95rem; top: 2rem; bottom: 0; width: 2px; background: var(--line); }
.timeline > li:last-child { padding-bottom: 0; }
.timeline > li:last-child::before { display: none; }
.timeline__num {
  position: absolute; left: 0; top: .05rem; width: 2rem; height: 2rem; border-radius: 50%;
  background: var(--green-100); color: var(--green-700); border: 1px solid rgba(20,81,63,.2);
  font-family: var(--font-display); font-weight: 800; font-size: .84rem; display: grid; place-items: center;
}
.timeline__title { margin: .2rem 0 .25rem; font-family: var(--font-display); font-weight: 700; font-size: 1.03rem; color: var(--green-900); }
.timeline__desc { margin: 0; font-size: var(--fs-sm); color: var(--muted); max-width: 58ch; }

/* Label UI portal */
.ui {
  display: inline; font-family: var(--font-display); font-size: .86em; font-weight: 700;
  line-height: 1.35; padding: .12em .5em; border-radius: var(--r-sm);
  background: var(--navy-100); border: 1px solid #CBD2DE; color: var(--navy-700);
  /* Label panjang boleh membungkus agar tidak meluber pada layar 320 px */
  overflow-wrap: break-word;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}
.ui--field { background: var(--paper-alt); border-color: var(--line-strong); color: var(--ink-soft); }

/* Agenda / jadwal */
.schedule { display: grid; gap: var(--s3); grid-template-columns: minmax(0, 1fr); background: var(--green-900); color: #fff; border-radius: var(--r-md); padding: 1.2rem; margin-bottom: var(--s4); }
@media (min-width: 700px) { .schedule { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.schedule__item { border-left: 2px solid rgba(224,192,138,.5); padding-left: .8rem; }
.schedule__label { margin: 0 0 .25rem; font-size: var(--fs-label); letter-spacing: var(--ls-label); text-transform: uppercase; color: #9FC0B0; font-weight: 700; }
.schedule__value { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; color: #fff; }

/* Kartu navigasi (cover handbook) */
.navcards { display: grid; gap: .7rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .navcards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1100px) { .navcards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.navcard {
  display: grid; grid-template-columns: 2.6rem minmax(0, 1fr); gap: .9rem; align-items: start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 1.05rem 1.1rem; text-decoration: none; color: inherit; box-shadow: var(--sh1);
  transition: border-color var(--tr-fast), box-shadow var(--tr-fast), transform var(--tr-fast);
}
.navcard:hover { border-color: var(--green-700); box-shadow: var(--sh2); transform: translateY(-2px); color: inherit; }
.navcard__icon { width: 2.6rem; height: 2.6rem; border-radius: var(--r-sm); background: var(--green-100); color: var(--green-700); display: grid; place-items: center; }
.navcard__num { display: block; font-family: var(--font-display); font-size: var(--fs-label); font-weight: 700; letter-spacing: var(--ls-label); color: var(--muted); margin-bottom: .15rem; }
.navcard__title { display: flex; align-items: center; gap: .4rem; margin: 0 0 .25rem; font-family: var(--font-display); font-weight: 700; font-size: 1.02rem; color: var(--green-900); }
.navcard__title::after { content: "→"; color: var(--gold-600); transition: transform var(--tr-fast); }
.navcard:hover .navcard__title::after { transform: translateX(3px); }
.navcard__desc { display: block; font-size: var(--fs-sm); color: var(--muted); line-height: 1.55; }

/* ---------- Prev / next ---------- */
.pager { display: grid; gap: var(--s3); grid-template-columns: minmax(0, 1fr); margin-top: var(--s7); padding-top: var(--s5); border-top: 1px solid var(--line); }
@media (min-width: 700px) { .pager { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.pager__card {
  display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 1rem 1.1rem; text-decoration: none; color: inherit; box-shadow: var(--sh1);
  transition: border-color var(--tr-fast), box-shadow var(--tr-fast);
}
.pager__card:hover { border-color: var(--green-700); box-shadow: var(--sh2); color: inherit; }
.pager__dir {
  display: flex; align-items: center; gap: .4rem; margin-bottom: .3rem;
  font-family: var(--font-display); font-size: var(--fs-label); font-weight: 700;
  letter-spacing: var(--ls-label); text-transform: uppercase; color: var(--gold-700);
}
.pager__card--next { text-align: right; }
.pager__card--next .pager__dir { justify-content: flex-end; }
.pager__title { display: block; margin-bottom: .2rem; font-family: var(--font-display); font-weight: 700; font-size: 1.02rem; color: var(--green-900); }
.pager__desc { display: block; font-size: var(--fs-cap); color: var(--muted); line-height: 1.5; }

/* Jalan keluar tambahan: tidak ada dead end */
.exits { display: grid; gap: .6rem; margin-top: var(--s5); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 640px) { .exits { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.exits a {
  display: flex; align-items: center; justify-content: center; gap: .45rem; min-height: 46px;
  padding: .6rem .9rem; border: 1px dashed var(--line-strong); border-radius: var(--r-md);
  background: var(--surface); text-decoration: none; color: var(--ink-soft);
  font-size: var(--fs-sm); font-weight: 600; text-align: center;
}
.exits a:hover { border-style: solid; border-color: var(--green-700); color: var(--green-900); background: var(--green-050); }

/* ---------- Salin tautan bagian ---------- */
.anchor-copy {
  appearance: none; border: 0; background: transparent; color: var(--line-strong);
  cursor: pointer; padding: .35rem; border-radius: var(--r-sm); line-height: 0;
  vertical-align: middle; margin-left: .35rem; transition: color var(--tr-fast), background var(--tr-fast);
}
.anchor-copy:hover { color: var(--green-700); background: var(--green-050); }

/* ---------- Search modal ---------- */
.search-modal {
  position: fixed; inset: 0; z-index: 130; display: none;
  padding: clamp(.5rem, 4vh, 4rem) clamp(.5rem, 4vw, 2rem);
  background: rgba(10, 50, 38, .5); overflow-y: auto;
}
.search-modal.is-open { display: block; }
.search-panel {
  max-width: 720px; margin: 0 auto; background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--sh3); overflow: hidden; display: flex; flex-direction: column; max-height: min(86vh, 720px);
}
.search-panel__head { display: flex; align-items: center; gap: .6rem; padding: .7rem .8rem; border-bottom: 1px solid var(--line); }
.search-input { flex: 1; border: 0; outline: none; font: inherit; font-size: 1.05rem; padding: .6rem .3rem; background: transparent; color: var(--ink); min-width: 0; }
.search-results { overflow-y: auto; padding: .5rem; -webkit-overflow-scrolling: touch; }
.search-hint { padding: 1rem; font-size: var(--fs-sm); color: var(--muted); }
.search-hint ul { margin: .5rem 0 0; padding-left: 1.2rem; }
.search-result { display: block; padding: .75rem .8rem; border-radius: var(--r-sm); text-decoration: none; color: inherit; border-bottom: 1px solid var(--paper-alt); }
.search-result:last-child { border-bottom: 0; }
.search-result:hover, .search-result:focus-visible { background: var(--green-050); color: inherit; }
.search-result__crumb { display: block; margin-bottom: .15rem; font-size: var(--fs-label); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.search-result__title { display: block; margin-bottom: .15rem; font-family: var(--font-display); font-weight: 700; font-size: .98rem; color: var(--green-900); }
.search-result__snippet { display: block; font-size: var(--fs-cap); color: var(--ink-soft); line-height: 1.5; }
.search-result mark { background: #FBEFD3; color: inherit; padding: 0 .1em; border-radius: 3px; }
.search-count { padding: .4rem .9rem; font-size: var(--fs-cap); color: var(--muted); }

/* ============================================================================
   PRINT / SAVE AS PDF — hanya handbook
   ========================================================================== */
@media print {
  @page { margin: 16mm 14mm; }
  html { scroll-behavior: auto; }
  body { background: #fff; color: #000; font-size: 11pt; line-height: 1.5; padding-bottom: 0 !important; }

  .site-header, .drawer, .overlay, .reading-progress, .search-modal, .to-top, .toast,
  .toc, .pager, .exits, .anchor-copy, .skip-link, .sticky-cta, .btn-row, .hb-cta { display: none !important; }

  .hb-shell { display: block; max-width: none; padding: 0; }
  .hb-main { padding: 0; }
  .hb-grid { display: block; }

  h1, h2, h3 { color: #000; break-after: avoid; page-break-after: avoid; }
  h1 { font-size: 20pt; } h2 { font-size: 15pt; margin-top: 14pt; } h3 { font-size: 12.5pt; }
  p, li { orphans: 3; widows: 3; }

  .card, .fact, .navcard, .callout, .schedule, .timeline > li {
    border: .6pt solid #B9BDB8 !important; box-shadow: none !important; background: #fff !important;
    break-inside: avoid; page-break-inside: avoid;
  }
  .callout { border-left: 3pt solid #14513F !important; background: #F7F7F4 !important; }
  .schedule { color: #000 !important; }
  .schedule__label, .schedule__value { color: #000 !important; }
  .timeline > li { padding: 6pt 8pt 6pt 2.7rem; margin-bottom: 5pt; }
  .timeline > li::before { display: none; }
  .timeline__num { background: #14513F !important; color: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }

  table.rt { border: .6pt solid #B9BDB8; font-size: 10pt; }
  table.rt thead { display: table-header-group; background: #F2F2EF !important; }
  table.rt tr { break-inside: avoid; page-break-inside: avoid; }
  table.rt th, table.rt td { border-bottom: .5pt solid #D5D8D3; }

  .acc:not([open]) .acc__body { display: block !important; }
  .acc > summary::after { display: none; }

  a { color: #000; text-decoration: underline; }
  .hb-body a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 8.5pt; color: #444; word-break: break-all; }
  .breadcrumb a::after { content: ""; }

  .site-footer { background: #fff !important; color: #000; border-top: 1pt solid #14513F; margin-top: 14pt; padding: 10pt 0 0; }
  .site-footer a, .site-footer h2, .site-footer__brand, .site-footer__tag, .site-footer__legal { color: #000 !important; }

  .print-only { display: block !important; }
  .print-masthead {
    display: flex !important; flex-direction: column; gap: 2pt;
    border-bottom: 1pt solid #14513F; padding-bottom: 6pt; margin-bottom: 12pt; font-size: 9.5pt;
  }
  .print-masthead strong { font-size: 11pt; }
  .print-masthead span { color: #444; }
}
