/* ============================================================
   Kodename JPG — gaya docs minimal (Astro)
   Layout 3 kolom ala dokumentasi: sidebar kiri, artikel, TOC kanan.
   Dark mode: data-theme="dark" di <html> (localStorage 'kodename-theme',
   fallback prefers-color-scheme — sama seperti tema lama).
   ============================================================ */

:root {
  --bg: #ffffff;
  --surface: #f6f8fa;
  --surface-2: #eef1f4;
  --ink: #1b1f24;
  --muted: #57606a;
  --border: #d8dee4;
  --accent: #2563eb;
  --accent-soft: #e8effe;
  --accent-ink: #ffffff;
  --code-bg: #0d1117;
  --code-ink: #e6edf3;
  --code-border: #30363d;
  --tip-bg: #e8f5ee;
  --tip-border: #16a34a;
  --warn-bg: #fef3e2;
  --warn-border: #d97706;
  --shadow: 0 1px 3px rgb(16 24 40 / 0.08), 0 4px 16px rgb(16 24 40 / 0.06);
  --radius: 14px;
  --topbar-h: 60px;
}

[data-theme="dark"] {
  --bg: #0e1116;
  --surface: #161b22;
  --surface-2: #1c2330;
  --ink: #e6edf3;
  --muted: #9aa7b4;
  --border: #2a3340;
  --accent: #5b8cff;
  --accent-soft: #1a2740;
  --tip-bg: #12241a;
  --tip-border: #2ea043;
  --warn-bg: #2b1d0c;
  --warn-border: #d29922;
  --shadow: 0 1px 3px rgb(0 0 0 / 0.4), 0 4px 16px rgb(0 0 0 / 0.35);
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 1.65;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, summary:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

img, svg { max-width: 100%; }
h1, h2, h3 { line-height: 1.25; scroll-margin-top: calc(var(--topbar-h) + 20px); }
h2[id], h3[id] { scroll-margin-top: calc(var(--topbar-h) + 20px); }

.wrap { max-width: 1280px; margin: 0 auto; padding: 0 24px; }

/* ---------- Progress bar baca ---------- */
.progress {
  position: fixed;
  top: 0; left: 0;
  height: 3px; width: 0;
  background: var(--accent);
  z-index: 90;
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 80;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  height: var(--topbar-h);
}
.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--ink);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: -0.02em;
  flex-shrink: 0;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-flex;
  width: 30px; height: 30px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-ink);
}
.brand-mark svg { width: 18px; height: 18px; }
.mainnav { margin-left: auto; }
.nav-links { display: flex; gap: 2px; }
.nav-links a {
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  padding: 7px 11px;
  border-radius: 8px;
}
.nav-links a:hover { color: var(--ink); background: var(--surface); text-decoration: none; }
.nav-links a.active { color: var(--accent); background: var(--accent-soft); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px; height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface); }
.icon-btn svg { width: 19px; height: 19px; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }

.lang-switch {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 700;
  flex-shrink: 0;
}
.lang-switch a { color: var(--muted); padding: 4px 2px; }
.lang-switch a:hover { color: var(--ink); }
.lang-switch .lang-active { color: var(--accent); }
.lang-switch .lang-sep { color: var(--border); }

.hamburger { display: none; }

/* ---------- Drawer (HP) ---------- */
.drawer-backdrop {
  position: fixed; inset: 0;
  background: rgb(0 0 0 / 0.45);
  z-index: 95;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
}
.drawer {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: min(320px, 86vw);
  background: var(--bg);
  border-right: 1px solid var(--border);
  z-index: 96;
  transform: translateX(-105%);
  transition: transform 0.25s ease;
  overflow-y: auto;
  padding: 16px 20px 32px;
}
body.drawer-open .drawer { transform: translateX(0); }
body.drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }
body.drawer-open { overflow: hidden; }
.drawer .drawer-nav { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.drawer .drawer-nav a {
  color: var(--ink);
  font-weight: 600;
  padding: 9px 10px;
  border-radius: 8px;
}
.drawer .drawer-nav a:hover { background: var(--surface); text-decoration: none; }
.drawer .drawer-nav a.active { color: var(--accent); background: var(--accent-soft); }
.drawer-close { margin-left: auto; }

/* ---------- Hero (beranda) ---------- */
.hero { padding: 56px 0 40px; max-width: 760px; }
.hero-kicker, .section-kicker, .page-kicker {
  display: inline-block;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 12px;
}
.hero h1 {
  font-family: "Libre Bodoni", Georgia, serif;
  font-size: clamp(30px, 4.6vw, 44px);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 16px;
}
.hero-lead { font-size: 19px; color: var(--muted); margin: 0 0 24px; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 32px; }
.btn {
  display: inline-block;
  padding: 11px 20px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 15px;
  border: 1px solid transparent;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost {
  border-color: var(--border);
  color: var(--ink);
  background: var(--bg);
}
.btn-ghost:hover { background: var(--surface); }
.hero-stats { display: flex; gap: 32px; flex-wrap: wrap; }
.stat b { display: block; font-size: 26px; line-height: 1.1; }
.stat span { color: var(--muted); font-size: 14px; }

/* ---------- Section beranda ---------- */
.section { padding: 24px 0 8px; }
.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.section-head h2, .page-head h1 {
  font-family: "Libre Bodoni", Georgia, serif;
  font-size: clamp(24px, 3vw, 30px);
  margin: 0;
}
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.card:hover { box-shadow: var(--shadow); border-color: var(--accent); }
.card-eyebrow { color: var(--muted); font-size: 13px; margin: 0; }
.card h3 { font-size: 18px; margin: 0; line-height: 1.35; }
.card h3 a { color: var(--ink); }
.card h3 a:hover { color: var(--accent); }
.card p { margin: 0; color: var(--muted); font-size: 15px; }
.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 6px;
}
.card-link { font-weight: 700; font-size: 14px; white-space: nowrap; }

.badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.badge.beginner { background: #e6f4ea; color: #137333; }
[data-theme="dark"] .badge.beginner { background: #12241a; color: #7ddba0; }
.badge.intermediate { background: #fef3e2; color: #9a6700; }
[data-theme="dark"] .badge.intermediate { background: #2b1d0c; color: #f5c168; }

.topic-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
}
.topic {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  color: var(--ink);
  position: relative;
  overflow: hidden;
}
.topic::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--series-accent, var(--accent));
}
.topic:hover { text-decoration: none; box-shadow: var(--shadow); border-color: var(--series-accent, var(--accent)); }
.topic h3 { margin: 0 0 6px; font-size: 18px; }
.topic h3 .topic-count { color: var(--muted); font-size: 14px; font-weight: 600; }
.topic p { margin: 0; color: var(--muted); font-size: 15px; }

.about-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-top: 1px solid var(--border);
  padding: 32px 0;
  margin-top: 32px;
}
.about-strip h2 {
  font-family: "Libre Bodoni", Georgia, serif;
  font-size: clamp(22px, 2.8vw, 28px);
  margin: 0 0 8px;
}
.about-strip p { color: var(--muted); margin: 0; max-width: 640px; }
.about-strip .btn { flex-shrink: 0; }

/* ---------- Halaman statis ---------- */
.page-head { padding: 44px 0 8px; max-width: 760px; }
.page-head p { color: var(--muted); font-size: 18px; margin: 12px 0 0; }
.page-main { padding-bottom: 56px; }
.prose { max-width: 760px; padding-top: 40px; }
.prose h1 {
  font-family: "Libre Bodoni", Georgia, serif;
  font-size: clamp(28px, 4vw, 36px);
  margin: 0 0 16px;
}
.prose .tutorial-meta { color: var(--muted); font-size: 14px; margin: 8px 0 0; }

/* ---------- Arsip ---------- */
.archive-year {
  font-family: "Libre Bodoni", Georgia, serif;
  font-size: 24px;
  margin: 32px 0 12px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.archive-rows { display: flex; flex-direction: column; }
.archive-row {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 16px;
  align-items: start;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
}
.archive-date { color: var(--muted); font-size: 14px; padding-top: 3px; white-space: nowrap; }
.archive-row h3 { margin: 0 0 4px; font-size: 17px; }
.archive-row h3 a { color: var(--ink); }
.archive-row h3 a:hover { color: var(--accent); }
.archive-row p { margin: 0; color: var(--muted); font-size: 15px; }

/* ---------- Layout docs (halaman tutorial) ---------- */
.docs-layout {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr) 224px;
  gap: 40px;
  align-items: start;
}
.docs-sidebar {
  position: sticky;
  top: calc(var(--topbar-h) + 24px);
  max-height: calc(100vh - var(--topbar-h) - 48px);
  overflow-y: auto;
  padding-right: 8px;
  scrollbar-width: thin;
}
.sidebar-group { margin-bottom: 20px; }
.sidebar-series {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 6px;
  padding: 0 10px;
}
.series-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--series-accent, var(--accent));
  flex-shrink: 0;
}
.sidebar-group ul { list-style: none; margin: 0; padding: 0; }
.sidebar-group a {
  display: block;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.4;
  padding: 6px 10px;
  border-left: 2px solid transparent;
  border-radius: 0 8px 8px 0;
}
.sidebar-group a:hover { color: var(--ink); background: var(--surface); text-decoration: none; }
.sidebar-group a.current {
  color: var(--accent);
  font-weight: 700;
  background: var(--accent-soft);
  border-left-color: var(--accent);
}

.docs-article { min-width: 0; padding: 40px 0 56px; }
.breadcrumb {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb .sep { color: var(--border); }
.breadcrumb .current { color: var(--ink); font-weight: 600; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 700;
  color: var(--series-accent, var(--accent));
  background: color-mix(in srgb, var(--series-accent, var(--accent)) 10%, transparent);
  border: 1px solid color-mix(in srgb, var(--series-accent, var(--accent)) 30%, transparent);
  padding: 4px 11px;
  border-radius: 999px;
  margin-bottom: 14px;
}
.chip .series-dot { width: 8px; height: 8px; }

.docs-article h1 {
  font-family: "Libre Bodoni", Georgia, serif;
  font-size: clamp(28px, 4vw, 38px);
  margin: 0 0 12px;
}
.article-meta {
  color: var(--muted);
  font-size: 14.5px;
  margin: 0 0 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}

/* ---------- Isi artikel ---------- */
.article-body { font-size: 17px; }
.article-body h2 {
  font-family: "Libre Bodoni", Georgia, serif;
  font-size: 26px;
  margin: 40px 0 12px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.article-body h2:first-child { border-top: none; margin-top: 0; }
.article-body h3 { font-size: 20px; margin: 28px 0 10px; }
.article-body p { margin: 0 0 16px; }
.article-body ul, .article-body ol { margin: 0 0 16px; padding-left: 24px; }
.article-body li { margin-bottom: 6px; }
.article-body li::marker { color: var(--accent); }
.article-body strong { font-weight: 700; }
.article-body a { text-underline-offset: 2px; }
.article-body hr { border: none; border-top: 1px solid var(--border); margin: 32px 0; }
.article-body img {
  display: block;
  margin: 0 auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}
.article-body p:has(> img) { margin: 24px 0 8px; }
.article-body p:has(> em:only-child) {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 24px;
}
.article-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 20px;
  font-size: 15px;
  display: block;
  overflow-x: auto;
}
.article-body th, .article-body td {
  border: 1px solid var(--border);
  padding: 9px 12px;
  text-align: left;
}
.article-body th { background: var(--surface); font-weight: 700; }

.article-body code {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 0.88em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
  overflow-wrap: anywhere;
}
.article-body pre {
  background: var(--code-bg);
  color: var(--code-ink);
  border: 1px solid var(--code-border);
  border-radius: 12px;
  padding: 16px 18px;
  margin: 0 0 20px;
  overflow-x: auto;
  font-size: 14.5px;
  line-height: 1.6;
}
.article-body pre code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
  overflow-wrap: normal;
}
.codeblock { position: relative; }
.codeblock pre { padding-top: 40px; }
.copy-btn {
  position: absolute;
  top: 8px; right: 8px;
  z-index: 2;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  color: #c9d1d9;
  background: #21262d;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 5px 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.copy-btn:hover { background: #30363d; color: #fff; }

.article-body blockquote {
  margin: 0 0 20px;
  padding: 14px 18px;
  border-left: 4px solid var(--accent);
  background: var(--accent-soft);
  border-radius: 0 12px 12px 0;
}
.article-body blockquote p { margin: 0; }
.article-body blockquote.callout-tip {
  border-left-color: var(--tip-border);
  background: var(--tip-bg);
}
.article-body blockquote.callout-warn {
  border-left-color: var(--warn-border);
  background: var(--warn-bg);
}

/* TOC mobile (details) — tampil saat TOC kanan hilang */
.toc-mobile { display: none; margin: 0 0 24px; }
.toc-mobile summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 15px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.toc-mobile summary::-webkit-details-marker { display: none; }
.toc-mobile summary::after { content: "▾"; color: var(--muted); }
.toc-mobile[open ] summary::after { content: "▴"; }
.toc-mobile nav { padding: 12px 4px 4px; }
.toc-mobile a { display: block; padding: 5px 12px; font-size: 14.5px; color: var(--muted); }
.toc-mobile a:hover { color: var(--accent); text-decoration: none; }

/* ---------- TOC kanan ---------- */
.docs-toc {
  position: sticky;
  top: calc(var(--topbar-h) + 24px);
  max-height: calc(100vh - var(--topbar-h) - 48px);
  overflow-y: auto;
  padding-top: 40px;
}
.docs-toc h2 {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 10px;
}
.docs-toc nav { border-left: 1px solid var(--border); }
.docs-toc a {
  display: block;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.45;
  padding: 5px 0 5px 16px;
  border-left: 2px solid transparent;
  margin-left: -1px;
}
.docs-toc a:hover { color: var(--ink); text-decoration: none; }
.docs-toc a.active { color: var(--accent); font-weight: 700; border-left-color: var(--accent); }

/* ---------- Navigasi Sebelumnya/Berikutnya ---------- */
.prev-next {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 40px 0 24px;
}
.prev-next a {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  color: var(--ink);
}
.prev-next a:hover { text-decoration: none; border-color: var(--accent); box-shadow: var(--shadow); }
.prev-next .pn-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 4px;
}
.prev-next .pn-title { display: block; font-weight: 700; font-size: 15.5px; line-height: 1.4; }
.prev-next .pn-next { text-align: right; }
.prev-next .pn-only { grid-column: 1 / -1; }

/* ---------- Support + komentar ---------- */
.support-box {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 20px 22px;
  margin: 0 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.support-box p { margin: 0; }
.comments { margin-top: 8px; }
.comments h2 {
  font-family: "Libre Bodoni", Georgia, serif;
  font-size: 24px;
  margin: 0 0 12px;
}

/* ---------- Pencarian ---------- */
.search-input {
  width: 100%;
  padding: 13px 16px;
  font-size: 17px;
  font-family: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin: 20px 0 8px;
}
.search-input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.search-results { margin-top: 16px; }
.search-empty { color: var(--muted); padding: 24px 0; }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 36px 0 28px;
  margin-top: 24px;
}
.footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.footer-name { font-weight: 800; font-size: 18px; margin: 0 0 4px; }
.footer-tag { color: var(--muted); margin: 0; font-size: 15px; max-width: 420px; }
.footer-nav { display: flex; gap: 4px; flex-wrap: wrap; align-items: start; }
.footer-nav a { color: var(--muted); font-size: 15px; font-weight: 600; padding: 6px 10px; border-radius: 8px; }
.footer-nav a:hover { color: var(--ink); background: var(--surface); text-decoration: none; }
.footer-bottom {
  color: var(--muted);
  font-size: 14px;
  padding-top: 24px;
}
.footer-bottom p { margin: 0; }
.footer-bottom a { color: var(--muted); }
.footer-bottom a:hover { color: var(--accent); }

/* ---------- Responsif ---------- */
@media (max-width: 1120px) {
  .docs-layout { grid-template-columns: 264px minmax(0, 1fr); }
  .docs-toc { display: none; }
  .toc-mobile { display: block; }
}
@media (max-width: 880px) {
  .wrap { padding: 0 16px; }
  .mainnav { display: none; }
  .hamburger { display: inline-flex; }
  .docs-layout { grid-template-columns: minmax(0, 1fr); }
  .docs-sidebar { display: none; }
  .docs-article { padding: 28px 0 40px; }
  .card-grid, .topic-grid { grid-template-columns: 1fr; }
  .hero { padding: 40px 0 28px; }
  .about-strip { flex-direction: column; align-items: flex-start; }
  .archive-row { grid-template-columns: 1fr; gap: 4px; }
  .archive-row .badge { justify-self: start; }
  .prev-next { grid-template-columns: 1fr; }
  .prev-next .pn-next { text-align: left; }
  .brand-name { font-size: 16px; }
  .lang-switch { font-size: 13px; margin-left: auto; }
  .theme-toggle { order: 5; }
}
@media (max-width: 400px) {
  .topbar-inner { gap: 8px; }
  .hero-stats { gap: 20px; }
}
