/* ==========================================================================
   Kamus Data Analyst : Tempat Belajar / ReWork Academy
   Reuse design tokens dari Handbook Data Analyst
   ========================================================================== */

:root {
  --primary: #592e6f;
  --primary-light: #7a4d95;
  --primary-pale: #f3ecf7;
  --dark: #281533;
  --paper: #faf8f9;
  --paper-alt: #f3eef4;
  --accent: #b8860b;
  --accent-pale: #fbf3e0;
  --text-main: #2a1f30;
  --text-muted: #6b5c74;
  --border: #e2d8e6;
  --border-strong: #c9b8d1;
  --white: #ffffff;
  --code-bg: #2a1a33;
  --code-text: #f1e8f5;
  --error-red: #a32d2d;
  --error-pale: #fbeeee;
  --badge-formula: #b8860b;
  --badge-syntax: #592e6f;
  --badge-context: #4a5568;
  --sidebar-width: 300px;
  --font-body: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-code: 'Fira Code', 'Courier New', monospace;
  --radius: 8px;
  --shadow-sm: 0 1px 3px rgba(40, 21, 51, 0.08);
  --shadow-md: 0 4px 16px rgba(40, 21, 51, 0.12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--text-main);
  font-size: 17px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ==========================================================================
   Hamburger (mobile only, plain square button, no colored bar)
   ========================================================================== */

.hamburger {
  display: none;
  position: fixed;
  top: 14px; left: 14px;
  width: 42px; height: 42px;
  background: var(--white);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  cursor: pointer;
  z-index: 100;
  box-shadow: var(--shadow-sm);
  padding: 0;
}
.hamburger span { display: block; width: 18px; height: 2px; background: var(--dark); margin: 4px auto; transition: transform 0.2s ease, opacity 0.2s ease; }
.hamburger.is-open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.hamburger.is-open span:nth-child(2) { opacity: 0; }
.hamburger.is-open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* ==========================================================================
   Sidebar brand + search + nav icons
   ========================================================================== */

.sidebar-brand {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}
.sidebar-brand:hover { background: var(--paper-alt); text-decoration: none; }
.sidebar-brand-title { font-weight: 700; font-size: 16px; color: var(--dark); }
.sidebar-brand-subtitle { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

.sidebar-search-wrap { padding: 14px 16px; border-bottom: 1px solid var(--border); margin-bottom: 6px; position: relative; }
.sidebar-search-wrap .search-input { width: 100%; padding: 10px 14px; font-size: 13.5px; }
.sidebar-search-wrap .search-count { font-size: 11.5px; margin-top: 6px; }

.search-results-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 60vh; overflow-y: auto; }
.search-result-item { border-radius: 8px; }
.search-result-item a { display: block; padding: 9px 10px; border-radius: 8px; text-decoration: none; }
.search-result-item a:hover { background: var(--primary-pale); text-decoration: none; }
.search-result-group { font-size: 10.5px; color: var(--accent); font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 2px; }
.search-result-title { font-size: 13.5px; font-weight: 700; color: var(--dark); margin-bottom: 2px; }
.search-result-snippet { font-size: 12px; color: var(--text-muted); line-height: 1.4; }

.nav-section.search-hidden { display: none; }

@keyframes searchHighlightPulse {
  0% { background: var(--accent-pale); border-left-color: var(--accent); }
  100% { background: var(--white); border-left-color: var(--primary); }
}
.term-card.search-highlight, .error-card.search-highlight { animation: searchHighlightPulse 2s ease; }

.shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-width);
  background: var(--white);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 0 0 40px;
  z-index: 90;
}

.sidebar-overlay { display: none; }

.nav-section { margin-bottom: 4px; }

.nav-section-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  text-align: left;
  padding: 11px 20px;
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 700;
  color: var(--dark);
  cursor: pointer;
}
.nav-section-toggle:hover { background: var(--paper-alt); }
.nav-icon { flex-shrink: 0; width: 16px; height: 16px; stroke: var(--primary); fill: none; stroke-width: 1.8; }
.sub-icon { flex-shrink: 0; width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; margin-right: 8px; vertical-align: -3px; }
.nav-section-toggle span.label { flex: 1; }
.nav-section-toggle .chevron {
  flex-shrink: 0; width: 9px; height: 9px;
  border-right: 2px solid var(--text-muted); border-bottom: 2px solid var(--text-muted);
  transform: rotate(-45deg); transition: transform 0.2s ease; margin-top: -3px;
}
.nav-section.is-open .nav-section-toggle .chevron { transform: rotate(45deg); margin-top: 0; }

.nav-section-list { list-style: none; margin: 0; padding: 0; max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
.nav-section.is-open .nav-section-list { max-height: 800px; }
.nav-section-list a { display: flex; align-items: center; padding: 9px 20px 9px 24px; font-size: 13.5px; color: var(--text-muted); border-left: 3px solid transparent; }
.nav-section-list a:hover { background: var(--primary-pale); color: var(--primary); text-decoration: none; }
.nav-section-list a.active { background: var(--primary-pale); color: var(--primary); border-left-color: var(--primary); font-weight: 600; }

/* ==========================================================================
   Main content (centered, not hugging sidebar)
   ========================================================================== */

.main { margin-left: var(--sidebar-width); flex: 1; min-width: 0; padding: 44px 40px; display: flex; justify-content: center; }
.content-inner { width: 100%; max-width: 820px; }

.content h1 { font-size: 30px; font-weight: 700; color: var(--dark); margin: 0 0 6px; line-height: 1.25; }
.content .chapter-label { font-size: 13.5px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 10px; }
.content .lead-text { font-size: 16px; color: var(--text-muted); margin-bottom: 28px; }
.content h2 { font-size: 22px; font-weight: 700; color: var(--primary); margin: 20px 0 16px; }
.content p { margin: 0 0 16px; }

/* ==========================================================================
   Search input (shared style, used in sidebar)
   ========================================================================== */

.search-input {
  width: 100%;
  padding: 13px 18px;
  font-size: 15px;
  font-family: var(--font-body);
  border: 1.5px solid var(--border-strong);
  border-radius: 10px;
  background: var(--white);
  color: var(--text-main);
  outline: none;
  transition: border-color 0.15s ease;
}
.search-input:focus { border-color: var(--primary); }
.search-count { font-size: 12.5px; color: var(--text-muted); margin-top: 8px; }

/* ==========================================================================
   Term card (Kamus entries)
   ========================================================================== */

.term-grid { display: flex; flex-direction: column; gap: 14px; margin-top: 10px; }

.term-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 18px 22px;
  overflow: hidden;
  word-wrap: break-word;
}

.term-card-title { font-size: 17px; font-weight: 700; color: var(--dark); margin: 0 0 8px; }

.term-block { margin-bottom: 10px; }
.term-block:last-child { margin-bottom: 0; }

.term-block-label {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 9px;
  border-radius: 20px;
  margin-bottom: 6px;
  color: var(--white);
}

.badge-definisi { background: var(--text-muted); }
.badge-rumus { background: var(--badge-formula); color: #412402; }
.badge-sintaks { background: var(--badge-syntax); }
.badge-kapan { background: var(--badge-context); }
.badge-contoh { background: var(--primary-light); }
.badge-kenapa { background: #3b6d11; }
.badge-cara { background: #2d6a8a; }
.badge-perbedaan { background: #85510b; }

.term-block p { margin: 0; font-size: 14.5px; color: var(--text-main); line-height: 1.65; overflow-wrap: break-word; word-break: break-word; }
.term-block code {
  font-family: var(--font-code);
  background: var(--primary-pale);
  color: var(--primary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.88em;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: break-word;
  display: inline-block;
  max-width: 100%;
}

/* ==========================================================================
   Error card variant
   ========================================================================== */

.error-card {
  background: var(--error-pale);
  border: 1px solid #eccaca;
  border-left: 4px solid var(--error-red);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 18px 22px;
  overflow: hidden;
  word-wrap: break-word;
}

.error-card-title {
  font-family: var(--font-code);
  font-size: 16px;
  font-weight: 700;
  color: var(--error-red);
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.error-card-title .warn-icon { flex-shrink: 0; width: 16px; height: 16px; }
.error-card .term-block p { color: var(--text-main); }
.badge-penyebab { background: #8a3a1f; }
.badge-cara-mengatasi { background: #3b6d11; }

/* ==========================================================================
   Stat cards (halaman index)
   ========================================================================== */

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin: 24px 0 32px; }
.stat-card { background: var(--white); border: 1px solid var(--border); border-radius: 12px; padding: 20px; text-align: center; }
.stat-number { font-size: 32px; font-weight: 700; color: var(--primary); line-height: 1.1; }
.stat-label { font-size: 12.5px; color: var(--text-muted); margin-top: 6px; }

.category-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; margin: 10px 0 30px; }
.category-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  text-decoration: none;
}
.category-card:hover { border-color: var(--primary); text-decoration: none; box-shadow: var(--shadow-sm); }
.category-icon { flex-shrink: 0; width: 32px; height: 32px; stroke: var(--primary); fill: none; stroke-width: 1.6; }
.category-card-title { font-size: 15px; font-weight: 700; color: var(--dark); margin: 0 0 2px; }
.category-card-count { font-size: 12.5px; color: var(--text-muted); }

/* highlight.js token colors */
.hljs-keyword, .hljs-built_in { color: #c99cf0; }
.hljs-string { color: #a8d98a; }
.hljs-number { color: #f0c674; }
.hljs-comment { color: #8b7a94; font-style: italic; }
.hljs-title.function_ { color: #7fc7e8; }
.hljs-variable, .hljs-attr { color: #e8c789; }
.content pre { background: var(--code-bg); color: var(--code-text); padding: 16px 18px; border-radius: var(--radius); margin: 14px 0; overflow-x: auto; font-family: var(--font-code); font-size: 13.5px; white-space: pre-wrap; word-break: break-word; }
.content pre code.hljs { background: none; padding: 0; }

/* ==========================================================================
   Mobile
   ========================================================================== */

@media (max-width: 880px) {
  body { font-size: 15.5px; }
  .hamburger { display: block; }
  .sidebar { top: 0; transform: translateX(-100%); transition: transform 0.25s ease; width: 86%; max-width: 320px; box-shadow: var(--shadow-md); padding-top: 66px; }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(40, 21, 51, 0.45); z-index: 80; }
  .sidebar-overlay.is-open { display: block; }
  .main { margin-left: 0; padding: 72px 16px 60px; justify-content: center; }
  .content-inner { max-width: 100%; }
  .content h1 { font-size: 23px; }
  .term-card, .error-card { padding: 14px 16px; }
  .term-block code { font-size: 0.82em; }
  .category-grid { grid-template-columns: 1fr; }
}

@media (min-width: 881px) {
  .sidebar-overlay { display: none !important; }
}

/* ===================== PASSWORD GATE ===================== */
html.hb-locked, html.hb-locked body{ overflow:hidden; height:100%; }
html.hb-locked .shell, html.hb-locked .mobile-topstrip{
  filter: blur(10px) saturate(0.9);
  pointer-events: none;
  user-select: none;
  transition: filter .2s ease;
}
#hb-auth-overlay{
  position:fixed; inset:0; z-index:9999;
  display:none;
  align-items:center; justify-content:center;
  background: rgba(40,21,51,0.6);
  backdrop-filter: blur(3px);
  padding: 20px;
}
html.hb-locked #hb-auth-overlay{ display:flex; }
#hb-auth-card{
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 34px 30px 28px;
  width: min(360px, 100%);
  box-shadow: 0 20px 60px rgba(40,21,51,0.35);
  text-align: center;
  font-family: var(--font-body);
  animation: hb-pop .18s ease;
}
@keyframes hb-pop{ from{ opacity:0; transform:translateY(6px) scale(.98); } to{ opacity:1; transform:translateY(0) scale(1); } }
#hb-auth-mark{
  width:44px; height:44px; border-radius:12px; margin:0 auto 16px;
  background:linear-gradient(135deg, var(--dark), var(--primary));
  display:flex; align-items:center; justify-content:center;
  color:#fff; font-family: var(--font-body); font-weight:700; font-size:18px;
  box-shadow: 0 4px 12px rgba(40,21,51,0.25);
}
#hb-auth-card h2{
  font-family: var(--font-body); font-weight:700; font-size:18px;
  color: var(--text-main); margin: 0 0 6px;
}
#hb-auth-card p{
  font-size: 13.5px; color: var(--text-muted); margin: 0 0 20px; line-height:1.5;
}
#hb-auth-form{ display:flex; flex-direction:column; gap:10px; }
#hb-auth-input{
  width:100%; padding:11px 14px; border-radius:9px;
  border:1.5px solid var(--border); background:var(--paper-alt);
  font-family: var(--font-body); font-size:14.5px; color:var(--text-main);
  outline:none; text-align:center; letter-spacing:.03em;
  transition: border-color .15s ease;
}
#hb-auth-input:focus{ border-color: var(--primary); }
#hb-auth-submit{
  width:100%; padding:11px 14px; border-radius:9px; border:none; cursor:pointer;
  background: var(--primary); color:#fff;
  font-family: var(--font-body); font-weight:700; font-size:14px;
  transition: background .15s ease, transform .1s ease;
}
#hb-auth-submit:hover{ background: var(--dark); }
#hb-auth-submit:active{ transform: scale(.98); }
#hb-auth-error{
  font-size:12.5px; color:#B91C1C; min-height:16px; margin-top:2px;
  font-family: var(--font-body); font-weight:600;
}
