/* Hallmark · Manuscript · tipografi dokumen ter-render.
 * Dokumen = lembar kertas serif di atas "meja". Warna dari variabel tema
 * (di-inject inline / lewat JS): --bg --fg --muted --border --link --code-* dst.
 */
:root {
  --font-doc-serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, 'Times New Roman', serif;
  --font-doc-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --font-doc-mono: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
  /* Font dokumen aktif — di-override server (view page) / JS (preview editor). */
  --font-doc: var(--font-doc-serif);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  /* "meja": turunan otomatis dari warna kertas tema (jalan di light & dark). */
  background: color-mix(in oklab, var(--bg) 88%, #80807a);
  color: var(--fg);
  font-family: var(--font-doc);
  font-size: 18px;
  line-height: 1.72;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Lembar kertas */
.doc {
  max-width: 760px;
  margin: clamp(20px, 5vw, 56px) auto;
  font-family: var(--font-doc);
  background: var(--bg);
  border: 1px solid color-mix(in oklab, var(--border) 75%, transparent);
  border-radius: 3px;
  box-shadow: 0 1px 2px rgba(24,24,20,.05), 0 14px 44px rgba(24,24,20,.09);
  padding: clamp(40px, 7vw, 80px) clamp(28px, 7vw, 88px);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.doc h1, .doc h2, .doc h3, .doc h4, .doc h5, .doc h6 {
  font-family: var(--font-doc);
  margin: 1.7em 0 .55em;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -.012em;
}
.doc h1 { font-size: 2.15em; padding-bottom: .28em; border-bottom: 1px solid var(--border); }
.doc h2 { font-size: 1.58em; padding-bottom: .26em; border-bottom: 1px solid var(--border); }
.doc h3 { font-size: 1.28em; }
.doc h4 { font-size: 1.05em; }
.doc h5, .doc h6 { font-size: .92em; color: var(--muted); }
.doc > :first-child { margin-top: 0; }

.doc p, .doc ul, .doc ol, .doc blockquote, .doc table, .doc pre { margin: 0 0 1.15em; }

.doc a { color: var(--link); text-decoration: underline; text-underline-offset: 2px; text-decoration-thickness: 1px; text-decoration-color: color-mix(in oklab, var(--link) 45%, transparent); }
.doc a:hover { text-decoration-color: var(--link); }

.doc ul, .doc ol { padding-left: 1.5em; }
.doc li { margin: .3em 0; }
.doc li input[type="checkbox"] { margin-right: .5em; }

.doc blockquote {
  margin-left: 0;
  padding: .3em 1.1em;
  color: var(--quote-fg);
  border-left: 3px solid var(--quote-border);
  font-style: italic;
}

/* Code & mono — kontras dari body serif */
.doc code {
  font-family: var(--font-doc-mono);
  font-size: .82em;
  background: var(--code-bg);
  color: var(--code-fg);
  padding: .15em .4em;
  border-radius: 4px;
  border: 1px solid color-mix(in oklab, var(--border) 60%, transparent);
}
.doc pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 20px;
  overflow-x: auto;
}
.doc pre code { background: none; border: 0; padding: 0; font-size: .8em; line-height: 1.6; }

/* Tombol Copy di code block (di-inject copy-code.js) */
.doc pre.has-copy { position: relative; }
.doc pre.has-copy .copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  font-family: var(--font-doc-sans);
  font-size: .72rem;
  line-height: 1;
  padding: 5px 9px;
  color: var(--muted);
  background: color-mix(in oklab, var(--bg) 80%, transparent);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .12s, color .12s, border-color .12s;
}
.doc pre.has-copy:hover .copy-btn,
.doc pre.has-copy .copy-btn:focus-visible { opacity: 1; }
.doc pre.has-copy .copy-btn:hover { color: var(--fg); border-color: var(--fg); }
.doc pre.has-copy .copy-btn.copied { opacity: 1; color: var(--fg); border-color: var(--fg); }
/* Layar sentuh: ga ada hover, tampilin terus biar bisa diakses */
@media (hover: none) {
  .doc pre.has-copy .copy-btn { opacity: 1; }
}

/* Syntax highlight MONOKROM — override tema hljs jadi hitam-putih.
 * Keyword tebal, komentar miring abu, sisanya abu/ink. Ga ada warna. */
.doc .hljs { color: var(--code-fg); background: none; }
.doc .hljs-comment, .doc .hljs-quote { color: var(--muted); font-style: italic; }
.doc .hljs-keyword, .doc .hljs-selector-tag, .doc .hljs-literal, .doc .hljs-section,
.doc .hljs-name, .doc .hljs-built_in, .doc .hljs-type, .doc .hljs-doctag,
.doc .hljs-title, .doc .hljs-title.function_, .doc .hljs-title.class_ { color: var(--code-fg); font-weight: 600; }
.doc .hljs-string, .doc .hljs-number, .doc .hljs-regexp, .doc .hljs-attr,
.doc .hljs-attribute, .doc .hljs-symbol, .doc .hljs-bullet, .doc .hljs-meta,
.doc .hljs-variable, .doc .hljs-template-variable, .doc .hljs-link, .doc .hljs-selector-attr,
.doc .hljs-selector-pseudo, .doc .hljs-selector-class, .doc .hljs-selector-id { color: var(--muted); }
.doc .hljs-emphasis { font-style: italic; }
.doc .hljs-strong { font-weight: 700; }

.doc table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; font-family: var(--font-doc-sans); font-size: .92em; }
.doc th, .doc td { border: 1px solid var(--border); padding: 8px 13px; white-space: nowrap; }
.doc th { font-weight: 600; background: var(--code-bg); }

.doc img { max-width: 100%; border-radius: 4px; }
.doc hr { border: none; border-top: 1px solid var(--border); margin: 2.2em 0; }

.doc kbd {
  font-family: var(--font-doc-mono); font-size: .82em;
  background: var(--code-bg); color: var(--code-fg);
  border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; padding: .12em .45em;
}

/* Mermaid: kasih ruang, center */
.doc pre.mermaid { background: none; border: 0; padding: 0; text-align: center; margin: 1.6em 0; }

/* Footer dokumen */
.doc-footer {
  max-width: 760px;
  margin: 0 auto clamp(20px, 5vw, 48px);
  padding: 22px 0 0;
  text-align: center;
}
.doc-footer a {
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--muted); text-decoration: none; font-family: var(--font-doc-sans); font-size: .82rem;
}
.doc-footer a:hover { color: var(--fg); }
.doc-footer .docmark { opacity: .7; }

/* ── Auto-scroll floating button ── */
#auto-scroll-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1.5px solid var(--border, rgba(128,128,128,.3));
  background: var(--bg, #fff);
  color: var(--muted, #888);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: .45;
  transition: opacity .15s, color .15s, border-color .15s;
  z-index: 200;
}
#auto-scroll-btn:hover { opacity: .85; color: var(--fg, #222); }
#auto-scroll-btn.active { opacity: .9; color: var(--link, #0066cc); border-color: var(--link, #0066cc); }

/* ── Halaman kumpulan dokumen (/dir/<slug>) ── */
.dir-head { margin-bottom: 1.4em; }
.dir-kicker {
  font-family: var(--font-doc-sans); font-size: .74rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--muted); margin: 0 0 .5em;
}
.dir-title { margin: 0; border: 0; padding: 0; font-size: 2.3em; }
.dir-count { font-family: var(--font-doc-sans); font-size: .86rem; color: var(--muted); margin: .5em 0 0; }
.dir-intro {
  margin: 0 0 1.6em; padding-bottom: 1.4em;
  border-bottom: 1px solid var(--border); color: var(--muted);
}
.dir-intro > :first-child { margin-top: 0; }
.dir-intro > :last-child { margin-bottom: 0; }

.dir-list { list-style: none; margin: 0; padding: 0; }
.dir-item { margin: 0; border-bottom: 1px solid color-mix(in oklab, var(--border) 65%, transparent); }
.dir-item:last-child { border-bottom: 0; }
.dir-link {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 16px 6px; text-decoration: none; color: var(--fg);
  transition: background .12s, padding-left .12s;
}
.dir-link:hover { background: color-mix(in oklab, var(--bg) 92%, var(--fg)); padding-left: 14px; }
.dir-item-title { font-size: 1.12em; font-weight: 600; letter-spacing: -.01em; }
.dir-lock { font-size: .78em; margin-left: .4em; opacity: .7; }
.dir-item-meta {
  flex: none; font-family: var(--font-doc-sans); font-size: .78rem; color: var(--muted);
}
.dir-empty { color: var(--muted); font-style: italic; padding: 16px 6px; list-style: none; }

/* ── Mobile: lembar kertas jadi full-width, heading lebih ringkas ── */
@media (max-width: 600px) {
  body { font-size: 16.5px; line-height: 1.68; }
  .doc {
    margin: 0;
    max-width: none;
    border-left: 0; border-right: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 28px 20px 48px;
  }
  .doc h1 { font-size: 1.72em; }
  .doc h2 { font-size: 1.4em; }
  .doc h3 { font-size: 1.18em; }
  .doc pre { padding: 14px 14px; border-radius: 6px; }
  .doc ul, .doc ol { padding-left: 1.25em; }
  .doc blockquote { padding: .2em .9em; }

  .dir-title { font-size: 1.85em; }
  /* judul + meta numpuk biar ga kepencet di layar sempit */
  .dir-link { flex-direction: column; align-items: flex-start; gap: 3px; padding: 14px 4px; }
  .dir-link:hover { padding-left: 4px; }
  .dir-item-meta { font-size: .74rem; }

  .doc-footer { margin-left: 16px; margin-right: 16px; }
}

/* ── Daftar Isi + anchor heading ── */
.doc :is(h2,h3,h4,h5,h6) { scroll-margin-top: 24px; }
.h-anchor {
  margin-left: .4em;
  font-size: .75em;
  color: var(--muted);
  text-decoration: none;
  opacity: 0;
  transition: opacity .15s;
}
.doc :is(h2,h3,h4,h5,h6):hover .h-anchor { opacity: .8; }
.h-anchor:hover { color: var(--fg); opacity: 1 !important; }
@media (hover: none) { .h-anchor { opacity: .35; } } /* touch: selalu keliatan tipis */

.doc-toc {
  margin: 1.6em 0 2em;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: color-mix(in oklab, var(--bg) 96%, var(--fg));
  font-family: var(--font-doc-sans);
  font-size: .82rem;
}
.doc-toc summary {
  cursor: pointer;
  padding: 10px 14px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  font-size: .72rem;
  color: var(--muted);
  user-select: none;
}
.doc-toc summary:hover { color: var(--fg); }
.doc-toc ol { list-style: none; margin: 0; padding: 2px 14px 12px; }
.doc-toc li { margin: 0; padding: 3px 0; line-height: 1.45; }
.doc-toc li.toc-sub { padding-left: 18px; }
.doc-toc a { color: var(--fg); text-decoration: none; border-bottom: 1px solid transparent; }
.doc-toc a:hover { border-bottom-color: var(--muted); }
