/* ==========================================================================
   Handbook Data Analyst — Tempat Belajar / ReWork Academy
   Design tokens: primary #592e6f, dark #281533, paper background, accent amber
   Typography: Open Sans (body/heading), Fira Code (code)
   ========================================================================== */

: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;
  --success-bg: #eaf3de;
  --success-text: #3b6d11;
  --sidebar-width: 300px;
  --topbar-height: 60px;
  --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;
}

img { max-width: 100%; }

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

/* ==========================================================================
   Mobile top strip (hamburger only, no brand duplication here)
   ========================================================================== */

.mobile-topstrip {
  display: none;
  position: fixed;
  top: 14px;
  left: 14px;
  width: 44px;
  height: 44px;
  background: var(--dark);
  border-radius: 10px;
  align-items: center;
  justify-content: center;
  z-index: 100;
  box-shadow: 0 4px 14px rgba(40, 21, 51, 0.25);
  transition: width 0.25s ease, height 0.25s ease, border-radius 0.25s ease, top 0.25s ease, left 0.25s ease, background 0.25s ease, box-shadow 0.25s ease, padding 0.25s ease;
}

.mobile-topstrip.is-open {
  top: 0;
  left: 0;
  width: 86%;
  max-width: 320px;
  height: 56px;
  border-radius: 0;
  box-shadow: none;
  justify-content: flex-start;
  padding-left: 6px;
  background: var(--dark);
}

.hamburger {
  display: none;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  margin: 0;
  width: 44px;
  height: 44px;
  flex-shrink: 0;
  position: relative;
  border-radius: 8px;
}

.hamburger span {
  position: absolute;
  left: 12px;
  width: 20px;
  height: 2px;
  background: var(--white);
  border-radius: 2px;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), top 0.25s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
  transform-origin: center;
}

.hamburger span:nth-child(1) { top: 14px; }
.hamburger span:nth-child(2) { top: 21px; }
.hamburger span:nth-child(3) { top: 28px; }

.hamburger.is-open span:nth-child(1) {
  top: 21px;
  transform: rotate(45deg);
}

.hamburger.is-open span:nth-child(2) {
  opacity: 0;
  transform: scale(0);
}

.hamburger.is-open span:nth-child(3) {
  top: 21px;
  transform: rotate(-45deg);
}

/* ==========================================================================
   Sidebar brand (top of sidebar, clickable, links to Pembuka)
   ========================================================================== */

.sidebar-brand {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
  text-decoration: none;
  transition: background 0.2s ease;
  cursor: pointer;
}

.sidebar-brand:hover { background: var(--primary-pale); text-decoration: none; }
.sidebar-brand:hover .sidebar-brand-title { color: var(--primary); }
.sidebar-brand-title { font-weight: 700; font-size: 16px; color: var(--dark); transition: color 0.2s ease; }
.sidebar-brand-subtitle { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

/* ==========================================================================
   Layout shell
   ========================================================================== */

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

/* ==========================================================================
   Sidebar (desktop: fixed/locked, doesn't scroll with content)
   ========================================================================== */

.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;
  justify-content: space-between;
  gap: 8px;
  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;
  letter-spacing: 0.2px;
}

.nav-section-toggle:hover { background: var(--paper-alt); }

.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.25s ease;
}

.nav-section.is-open .nav-section-list { max-height: 1200px; }

.nav-section-list a {
  display: block;
  padding: 9px 20px 9px 34px;
  font-size: 14px;
  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
   ========================================================================== */

.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  padding: 48px 32px 100px;
  display: flex;
  justify-content: center;
}

.content {
  width: 100%;
  max-width: 760px;
}

.content h1 {
  font-size: 32px;
  font-weight: 700;
  color: var(--dark);
  margin: 0 0 16px;
  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 h2 {
  font-size: 23px;
  font-weight: 700;
  color: var(--primary);
  margin: 44px 0 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--border);
}

.content h2:first-of-type { margin-top: 30px; }

.content h3 {
  font-size: 18.5px;
  font-weight: 700;
  color: var(--dark);
  margin: 30px 0 12px;
}

.content p { margin: 0 0 18px; }

.content strong { color: var(--dark); font-weight: 700; }

.content ul, .content ol { margin: 0 0 18px; padding-left: 24px; }
.content li { margin-bottom: 8px; }

.content blockquote {
  margin: 20px 0;
  padding: 14px 20px;
  background: var(--accent-pale);
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
}

.content blockquote p:last-child { margin-bottom: 0; }

/* Code blocks — no horizontal-scroll navigation, wraps instead */
.content pre {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 18px 20px;
  border-radius: var(--radius);
  margin: 20px 0;
  overflow-x: auto;
  font-family: var(--font-code);
  font-size: 14px;
  line-height: 1.6;
}

.content pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
  white-space: pre-wrap;
  word-break: break-word;
}

.content code {
  font-family: var(--font-code);
  background: var(--primary-pale);
  color: var(--primary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
  word-break: break-word;
}

.content pre code.hljs { background: none; padding: 0; }

/* highlight.js token colors tuned to site palette */
.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_, .hljs-title.class_ { color: #7fc7e8; }
.hljs-variable, .hljs-attr { color: #e8c789; }
.hljs-literal { color: #f0c674; }
.hljs-operator, .hljs-punctuation { color: var(--code-text); }

.content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 40px 0;
}

/* ==========================================================================
   Responsive tables — desktop grid, mobile stacked cards
   ========================================================================== */

.table-wrap { margin: 20px 0; }

.content table {
  width: 100%;
  border-collapse: collapse;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.content th {
  background: var(--primary);
  color: var(--white);
  text-align: left;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 700;
}

.content td {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 14.5px;
  vertical-align: top;
}

.content tr:nth-child(even) td { background: var(--paper-alt); }

/* ==========================================================================
   Callout box (Apa yang Akan Kamu Pahami, etc.)
   ========================================================================== */

.callout {
  background: var(--primary-pale);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 18px 22px;
  margin: 24px 0 32px;
}

.callout p:last-child { margin-bottom: 0; }
.callout p:first-child { margin-top: 0; }
.callout ul { margin: 8px 0 0 0; padding-left: 20px; }
.callout ul li { margin-bottom: 8px; line-height: 1.65; }
.callout ul li:last-child { margin-bottom: 0; }

.callout-label {
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--primary);
  margin-bottom: 10px;
}

/* Objectives Callout Box */
.callout-objectives {
  background: var(--primary-pale);
  border: 1px solid var(--border-strong);
  border-left: 4px solid var(--primary);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 20px 24px;
  margin: 24px 0 32px;
}

/* Summary Callout Box */
.callout-summary {
  background: #fdfaf4;
  border: 1px solid #e4c680;
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 20px 24px;
  margin: 36px 0 24px;
}

.callout-summary .callout-label {
  color: #85510b;
}

/* Amber "perhatian" callout variant */
.callout-warn {
  background: var(--accent-pale);
  border: 1px solid #e4c680;
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 16px 20px;
  margin: 20px 0;
}
.callout-warn p:last-child { margin-bottom: 0; }
.callout-warn p:first-child { margin-top: 0; }
.callout-warn .callout-label { color: #85510b; }

/* ==========================================================================
   Card grid (definitions, metrics, comparisons)
   ========================================================================== */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin: 22px 0 28px;
}

.card-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.card-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }

.mini-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-top: 3px solid var(--primary);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.mini-card h4 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 700;
  color: var(--dark);
}

.mini-card .mini-card-formula {
  font-family: var(--font-code);
  font-size: 12.5px;
  color: var(--primary);
  background: var(--primary-pale);
  padding: 3px 8px;
  border-radius: 4px;
  display: inline-block;
  margin-bottom: 8px;
}

.mini-card p {
  margin: 0;
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* Two-column data-vs-insight style comparison */
.split-compare {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 20px 0 28px;
}

.split-compare > div {
  border-radius: var(--radius);
  padding: 16px 18px;
  border: 1px solid var(--border);
}

.split-compare .split-bad { background: #faf3f0; border-top: 3px solid var(--text-muted); }
.split-compare .split-good { background: var(--primary-pale); border-top: 3px solid var(--primary); }
.split-compare h4 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.4px; }
.split-compare p { margin: 0; font-size: 14px; line-height: 1.6; }

/* ==========================================================================
   SVG diagram container
   ========================================================================== */

.diagram-wrap {
  margin: 26px 0;
  padding: 20px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow-x: auto;
}

.diagram-wrap svg { display: block; width: 100%; height: auto; }
.diagram-caption {
  text-align: center;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 10px;
}

/* Responsive 2-Panel Grid Diagram (Opsi B) */
.diagram-grid {
  display: flex;
  gap: 16px;
  margin: 26px 0 10px;
}

.diagram-grid .diagram-card {
  flex: 1;
  min-width: 0;
  padding: 18px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.diagram-grid .diagram-card svg {
  display: block;
  width: 100%;
  height: auto;
}

/* Spektrum Peran Data Grid */
.spectrum-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 10px 0 16px;
}

.spectrum-card {
  border-radius: 8px;
  padding: 16px 14px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}

.spectrum-card-de {
  background: #f3eef4;
  border: 1px solid #c9b8d1;
}

.spectrum-card-da {
  background: #592e6f;
  border: 1px solid #281533;
  color: #ffffff;
}

.spectrum-card-ds {
  background: #f3ecf7;
  border: 1px solid #592e6f;
}

.spectrum-card .spectrum-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
}
.spectrum-card-de .spectrum-title,
.spectrum-card-ds .spectrum-title { color: #281533; }
.spectrum-card-da .spectrum-title { color: #ffffff; }

.spectrum-card .spectrum-subtitle {
  font-size: 12px;
  margin-bottom: 14px;
}
.spectrum-card-de .spectrum-subtitle,
.spectrum-card-ds .spectrum-subtitle { color: #592e6f; }
.spectrum-card-da .spectrum-subtitle { color: #e6d9ec; }

.spectrum-card .spectrum-badge {
  font-size: 11.5px;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 4px;
  width: 100%;
  margin-bottom: 16px;
}
.spectrum-card-de .spectrum-badge,
.spectrum-card-ds .spectrum-badge { background: #e6d9ec; color: #281533; }
.spectrum-card-da .spectrum-badge { background: #b8860b; color: #ffffff; }

.spectrum-card .spectrum-footer {
  font-size: 11.5px;
  padding-top: 10px;
  border-top: 1px dashed #c9b8d1;
  width: 100%;
}
.spectrum-card-de .spectrum-footer,
.spectrum-card-ds .spectrum-footer { color: #6b5c74; }
.spectrum-card-da .spectrum-footer { color: #e6d9ec; border-top-color: rgba(255, 255, 255, 0.25); }

@media (max-width: 880px) {
  .diagram-grid {
    flex-direction: column;
    gap: 12px;
  }
  .spectrum-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}

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

@media (max-width: 880px) {
  body { font-size: 15.5px; }

  .mobile-topstrip { display: flex; }
  .hamburger { display: block; }

  .shell { padding-top: 0; }

  .sidebar {
    top: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: 86%;
    max-width: 320px;
    box-shadow: var(--shadow-md);
    padding-top: 56px;
  }

  .sidebar.is-open { transform: translateX(0); }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0 0 0 0;
    background: rgba(40, 21, 51, 0.45);
    z-index: 80;
  }

  .sidebar-overlay.is-open { display: block; }

  .main {
    margin-left: 0;
    padding: 68px 18px 60px;
    display: block;
  }

  .card-grid, .card-grid.cols-2, .card-grid.cols-3 { grid-template-columns: 1fr; }
  .split-compare { grid-template-columns: 1fr; }
  .diagram-wrap { padding: 14px; overflow-x: auto; }

  .content h1 { font-size: 24px; }
  .content h2 { font-size: 19px; margin-top: 34px; }
  .content h3 { font-size: 16.5px; }
  .content pre { font-size: 12.5px; padding: 14px 16px; }
  .content code { font-size: 0.85em; }

  /* Responsive table -> stacked cards on mobile, no overlap */
  .content table, .content thead, .content tbody, .content th, .content td, .content tr {
    display: block;
  }

  .content thead { display: none; }

  .content tr {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 14px;
    padding: 4px 0;
    background: var(--white);
  }

  .content tr:nth-child(even) td { background: var(--white); }

  .content td {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    font-size: 14px;
  }

  .content td:first-child { border-top: none; }

  .content td::before {
    content: attr(data-label);
    font-weight: 700;
    color: var(--accent);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 3px;
  }
}

@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;
}
