/* ==========================================================================
   Handbook Virtual Assistant : Tempat Belajar
   Design tokens
   ========================================================================== */

:root {
  --color-primary: #196189;
  --color-primary-dark: #124a68;
  --color-deep: #042e3d;

  --color-bg: #f7f9fa;
  --color-surface: #ffffff;
  --color-sidebar-bg: #042e3d;
  --color-sidebar-bg-raised: #0a3c4e;

  --color-text: #1f2a2e;
  --color-text-muted: #5b6b70;
  --color-text-on-dark: #eaf2f5;
  --color-text-on-dark-muted: #9fb8c2;

  --color-border: #dbe3e6;
  --color-border-dark: #164a63;

  --color-accent-case: #b8722f;
  --color-accent-case-bg: #fbf1e6;
  --color-accent-note: #2f7a5c;
  --color-accent-note-bg: #eaf5f0;
  --color-accent-warn: #a03e3e;
  --color-accent-warn-bg: #faeceb;

  --font-body: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --sidebar-width: 300px;
  --content-max-width: 780px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(4, 46, 61, 0.06);
  --shadow-md: 0 4px 16px rgba(4, 46, 61, 0.10);
}

* { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  overflow-x: hidden;
  max-width: 100vw;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.65;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  max-width: 100vw;
  position: relative;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; height: auto; }

a:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  border-radius: 4px;
}

.app-shell {
  display: flex;
  min-height: 100vh;
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--color-sidebar-bg);
  color: var(--color-text-on-dark);
  overflow-y: auto;
  z-index: 40;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--color-border-dark);
}

.sidebar-brand { padding: 22px 20px 16px; border-bottom: 1px solid var(--color-border-dark); }
.sidebar-brand .brand-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text-on-dark-muted);
  display: block;
  margin-bottom: 4px;
}
.sidebar-brand .brand-title { font-size: 17px; font-weight: 600; color: var(--color-text-on-dark); line-height: 1.3; }

.sidebar-nav { padding: 12px 10px 32px; flex: 1; }

.nav-group { margin-bottom: 4px; border-radius: var(--radius-sm); overflow: hidden; }
.nav-group > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 11px 12px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--color-text-on-dark);
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary:hover { background: var(--color-sidebar-bg-raised); }
.nav-group > summary .chevron {
  flex-shrink: 0; width: 16px; height: 16px;
  transition: transform 0.18s ease;
  color: var(--color-text-on-dark-muted);
}
.nav-group[open] > summary .chevron { transform: rotate(90deg); }
.nav-group[open] > summary { background: var(--color-sidebar-bg-raised); }

.nav-group-label { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.nav-group-label .group-num { font-family: var(--font-mono); font-size: 11px; color: var(--color-primary); flex-shrink: 0; }
.nav-group-label .group-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav-list { list-style: none; margin: 2px 0 8px; padding: 0 4px 0 14px; display: flex; flex-direction: column; gap: 1px; }
.nav-list a {
  display: block;
  padding: 8px 12px;
  font-size: 13.5px;
  color: var(--color-text-on-dark-muted);
  border-radius: var(--radius-sm);
  border-left: 2px solid transparent;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-list a:hover { background: var(--color-sidebar-bg-raised); color: var(--color-text-on-dark); text-decoration: none; }
.nav-list a.active { background: var(--color-primary); color: #ffffff; border-left-color: #ffffff; font-weight: 500; }

.hamburger {
  display: none;
}
.sidebar-overlay { display: none; }

.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  max-width: 100%;
  display: flex;
  justify-content: center;
  padding: 56px 32px 96px;
  box-sizing: border-box;
}
.content {
  width: 100%;
  max-width: var(--content-max-width);
  min-width: 0;
  box-sizing: border-box;
}

.content .part-eyebrow {
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-primary);
  margin: 0 0 8px;
}
.content h1 { font-size: 32px; font-weight: 700; line-height: 1.25; color: var(--color-deep); margin: 0 0 28px; word-break: break-word; }
.content h2 {
  font-size: 23px; font-weight: 700; color: var(--color-deep);
  margin: 48px 0 16px; padding-top: 8px; border-top: 1px solid var(--color-border);
  word-break: break-word;
}
.content h2:first-of-type { border-top: none; padding-top: 0; }
.content h3 { font-size: 18px; font-weight: 600; color: var(--color-primary-dark); margin: 30px 0 12px; word-break: break-word; }
.content p { margin: 0 0 16px; word-break: break-word; overflow-wrap: break-word; }
.content ul, .content ol { margin: 0 0 16px; padding-left: 22px; }
.content li { margin-bottom: 6px; word-break: break-word; overflow-wrap: break-word; }

.class-table, .table-wrap {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  margin: 16px 0 24px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
}
.class-table table, .table-wrap table {
  margin: 0;
  border: none;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.content table {
  width: 100%;
  max-width: 100%;
  table-layout: auto;
  border-collapse: collapse;
  margin: 8px 0 24px;
  font-size: 14px;
  box-sizing: border-box;
}
.content th, .content td {
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--color-border);
  vertical-align: top;
  word-break: break-word;
  overflow-wrap: anywhere;
  hyphens: auto;
  box-sizing: border-box;
}
.content th { background: var(--color-bg); font-weight: 600; color: var(--color-deep); }

.table-card-list { display: none; }

.content code {
  font-family: var(--font-mono); font-size: 0.88em; background: var(--color-bg);
  padding: 2px 6px; border-radius: 4px; border: 1px solid var(--color-border);
  word-break: break-all;
}
.content pre {
  background: var(--color-deep); color: var(--color-text-on-dark);
  padding: 18px 20px; border-radius: var(--radius-md); overflow-x: auto;
  font-family: var(--font-mono); font-size: 13.5px; line-height: 1.6; margin: 0 0 24px;
  max-width: 100%; box-sizing: border-box;
}
.content pre code { background: none; border: none; padding: 0; color: inherit; word-break: normal; }

.content blockquote {
  margin: 0 0 20px; padding: 14px 18px; border-left: 3px solid var(--color-primary);
  background: var(--color-bg); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--color-text);
  max-width: 100%; box-sizing: border-box;
}
.content blockquote p:last-child { margin-bottom: 0; }
.content svg { display: block; margin: 8px 0 28px; max-width: 100%; height: auto; }

.objectives-box {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-primary); border-radius: var(--radius-md);
  padding: 20px 24px; margin: 0 0 32px;
  max-width: 100%; box-sizing: border-box;
}
.objectives-box .box-label {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--color-primary); margin-bottom: 10px; display: block;
}
.objectives-box ul { margin-bottom: 0; }

.callout { border-radius: var(--radius-md); padding: 18px 22px; margin: 0 0 28px; border: 1px solid transparent; max-width: 100%; box-sizing: border-box; }
.callout-label {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.06em;
  text-transform: uppercase; font-weight: 600; display: block; margin-bottom: 8px;
}
.callout p:last-child { margin-bottom: 0; }
.callout-case { background: var(--color-accent-case-bg); border-color: rgba(184, 114, 47, 0.25); }
.callout-case .callout-label { color: var(--color-accent-case); }
.callout-note { background: var(--color-accent-note-bg); border-color: rgba(47, 122, 92, 0.25); }
.callout-note .callout-label { color: var(--color-accent-note); }
.callout-warn { background: var(--color-accent-warn-bg); border-color: rgba(160, 62, 62, 0.25); }
.callout-warn .callout-label { color: var(--color-accent-warn); }

.summary-box { background: var(--color-deep); color: var(--color-text-on-dark); border-radius: var(--radius-md); padding: 24px 26px; margin: 40px 0 8px; max-width: 100%; box-sizing: border-box; }
.summary-box .box-label {
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.06em;
  text-transform: uppercase; color: #7fb8d4; margin-bottom: 10px; display: block;
}
.summary-box p { color: var(--color-text-on-dark); margin-bottom: 12px; }
.summary-box p:last-child { margin-bottom: 0; }

.mobile-header { display: none; }

.content .diagram-wrap {
  background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--radius-md); padding: 20px; margin: 0 0 28px;
  max-width: 100%; box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.diagram-wrap svg { display: block; margin: 0 auto; max-width: 100%; height: auto; }
.diagram-wrap text { font-family: var(--font-body); fill: var(--color-text); }
.diagram-wrap .th { font-weight: 600; font-size: 13px; }
.diagram-wrap .ts { font-size: 11.5px; fill: var(--color-text-muted); }
.diagram-wrap .arr { stroke: var(--color-text-muted); fill: none; }
.diagram-wrap .node rect, .diagram-wrap rect.shape { stroke: var(--color-border); }
.diagram-wrap .c-blue rect, .diagram-wrap rect.c-blue { fill: #e3edf3; stroke: var(--color-primary); }
.diagram-wrap .c-teal rect, .diagram-wrap rect.c-teal { fill: #e1f0ec; stroke: var(--color-accent-note); }
.diagram-wrap .c-purple rect, .diagram-wrap rect.c-purple { fill: #ebe4f2; stroke: #6c4ea0; }
.diagram-wrap .c-coral rect, .diagram-wrap rect.c-coral { fill: #fbe9e4; stroke: #c1583a; }
.diagram-wrap .c-gray rect, .diagram-wrap rect.c-gray { fill: #eef1f2; stroke: var(--color-text-muted); }
.diagram-wrap .c-amber rect, .diagram-wrap rect.c-amber { fill: var(--color-accent-case-bg); stroke: var(--color-accent-case); }
.diagram-wrap .c-red rect, .diagram-wrap rect.c-red { fill: var(--color-accent-warn-bg); stroke: var(--color-accent-warn); }
.diagram-wrap .diagram-caption { font-size: 12.5px; color: var(--color-text-muted); margin-top: 10px; text-align: center; }

.glossary-term {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 18px 22px;
  margin: 0 0 16px;
  max-width: 100%; box-sizing: border-box;
}
.glossary-term .term-title {
  display: block;
  font-weight: 700;
  font-size: 16px;
  color: var(--color-deep);
  margin-bottom: 8px;
}
.glossary-term .term-desc {
  margin: 0 0 12px;
  color: var(--color-text);
}
.glossary-term .term-example {
  margin: 0;
  padding-top: 10px;
  border-top: 1px dashed var(--color-border);
  font-size: 14px;
  color: var(--color-text-muted);
}
.glossary-term .term-example .example-label {
  font-weight: 600;
  color: var(--color-primary);
}

@media (max-width: 900px) {
  html, body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
    position: relative;
    width: 100% !important;
  }

  body {
    font-size: 14.5px;
    line-height: 1.6;
  }

  .app-shell {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    width: min(84vw, 320px);
    box-shadow: var(--shadow-md);
    padding-top: 64px;
  }
  .sidebar.open { transform: translateX(0); }

  .mobile-header { display: none !important; }

  .main {
    margin-left: 0 !important;
    padding: 72px 16px 64px !important;
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }

  .content {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: hidden !important;
    box-sizing: border-box !important;
  }

  .sidebar-brand { padding-top: 4px; }

  /* Floating square hamburger / close button fixed to top-left */
  .hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 14px;
    left: 14px;
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    background: var(--color-sidebar-bg);
    color: var(--color-text-on-dark);
    border: 1px solid var(--color-border-dark);
    cursor: pointer;
    z-index: 60;
    box-shadow: var(--shadow-md);
  }
  .hamburger .icon-close { display: none; }
  .hamburger.open .icon-burger { display: none; }
  .hamburger.open .icon-close { display: block; }

  .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(4, 46, 61, 0.5); z-index: 39; }
  .sidebar-overlay.open { display: block; }

  /* Font size & typography scaling for mobile */
  .content .part-eyebrow { font-size: 11.5px; margin-bottom: 6px; }
  .content h1 { font-size: 22px; line-height: 1.3; margin: 0 0 20px; word-break: break-word; }
  .content h2 { font-size: 18px; margin: 34px 0 12px; word-break: break-word; }
  .content h3 { font-size: 15.5px; margin: 22px 0 10px; word-break: break-word; }
  .content p { font-size: 14.5px; margin: 0 0 14px; word-break: break-word; overflow-wrap: break-word; }
  .content ul, .content ol { font-size: 14.5px; padding-left: 18px; margin: 0 0 14px; }
  .content li { margin-bottom: 5px; word-break: break-word; overflow-wrap: break-word; }
  .content blockquote { padding: 12px 14px; font-size: 14px; margin-bottom: 16px; word-break: break-word; }
  .content pre { font-size: 12.5px; padding: 14px 16px; margin-bottom: 18px; white-space: pre-wrap; word-break: break-all; overflow-x: auto; }

  .objectives-box { padding: 16px 18px; margin-bottom: 24px; font-size: 14px; }
  .callout { padding: 14px 16px; margin-bottom: 20px; font-size: 14px; }
  .summary-box { padding: 18px 20px; margin: 28px 0 8px; font-size: 14px; }

  .glossary-term { padding: 14px 16px; margin-bottom: 12px; }
  .glossary-term .term-title { font-size: 15px; }
  .glossary-term .term-desc { font-size: 13.5px; }
  .glossary-term .term-example { font-size: 12.5px; }

  /* Hide raw table & show Stacked Cards on Mobile */
  .class-table:not(.keep-table) table, .table-wrap:not(.keep-table) table {
    display: none !important;
  }

  .keep-table {
    overflow-x: auto !important;
  }

  .class-table, .table-wrap {
    width: 100% !important;
    max-width: 100% !important;
    margin: 14px 0 22px;
    border: none;
    background: transparent;
    overflow: visible;
  }

  .table-card-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .table-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    box-shadow: var(--shadow-sm);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
  }

  .table-card-header {
    font-weight: 700;
    font-size: 15px;
    color: var(--color-deep);
    padding-bottom: 8px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--color-border);
    word-break: break-word;
  }

  .table-card-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .table-card-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 13.5px;
  }

  .table-card-label {
    font-weight: 600;
    font-size: 11.5px;
    color: var(--color-primary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  .table-card-val {
    color: var(--color-text);
    line-height: 1.5;
    word-break: break-word;
    overflow-wrap: break-word;
  }

  .diagram-wrap {
    padding: 14px 12px;
    max-width: 100% !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
  }

  .diagram-wrap svg {
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    margin: 0 auto;
  }
}

/* ===================== PASSWORD GATE ===================== */
html.hb-locked, html.hb-locked body{ overflow:hidden; height:100%; }
html.hb-locked .app-shell, html.hb-locked .hamburger{
  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(4,46,61,0.6);
  backdrop-filter: blur(3px);
  padding: 20px;
}
html.hb-locked #hb-auth-overlay{ display:flex; }
#hb-auth-card{
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 34px 30px 28px;
  width: min(360px, 100%);
  box-shadow: 0 20px 60px rgba(4,46,61,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:var(--radius-md); margin:0 auto 16px;
  background:linear-gradient(135deg, var(--color-deep), var(--color-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(4,46,61,0.25);
}
#hb-auth-card h2{
  font-family: var(--font-body); font-weight:700; font-size:18px;
  color: var(--color-text); margin: 0 0 6px;
}
#hb-auth-card p{
  font-size: 13.5px; color: var(--color-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:var(--radius-sm);
  border:1.5px solid var(--color-border); background:var(--color-bg);
  font-family: var(--font-body); font-size:14.5px; color:var(--color-text);
  outline:none; text-align:center; letter-spacing:.03em;
  transition: border-color .15s ease;
}
#hb-auth-input:focus{ border-color: var(--color-primary); }
#hb-auth-submit{
  width:100%; padding:11px 14px; border-radius:var(--radius-sm); border:none; cursor:pointer;
  background: var(--color-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(--color-primary-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;
}
