/* ============================================
   PPLDAO GitBook-Style Whitepaper Theme
   Matches main site: #050720 bg, #eac36f gold
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Righteous&family=Roboto:wght@300;400;500;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap');

/* --- CSS Reset & Variables --- */
:root {
  --bg-primary: #050720;
  --bg-sidebar: #0a0e1f;
  --bg-sidebar-hover: #111633;
  --bg-card: #0d1130;
  --bg-code: #0f1338;
  --accent-gold: #eac36f;
  --accent-gold-dim: rgba(234, 195, 111, 0.15);
  --accent-gold-hover: #f5d88a;
  --text-primary: #e0e0e0;
  --text-secondary: #9ca3af;
  --text-heading: #ffffff;
  --text-muted: #6b7280;
  --border-color: rgba(234, 195, 111, 0.12);
  --border-subtle: rgba(255, 255, 255, 0.06);
  --sidebar-width: 300px;
  --topbar-height: 60px;
  --transition: 0.25s ease;
}

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 80px;
}

body {
  font-family: 'Roboto', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.8;
  font-size: 16px;
  overflow-x: hidden;
}

/* --- Reading Progress Bar --- */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-gold), #f5d88a, var(--accent-gold));
  width: 0%;
  z-index: 10001;
  transition: width 0.1s linear;
}

/* --- Top Bar --- */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: rgba(5, 7, 32, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 1000;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-heading);
}

.topbar-logo img {
  height: 36px;
  width: auto;
}

.topbar-logo span {
  font-family: 'Righteous', cursive;
  font-size: 18px;
  color: var(--accent-gold);
  letter-spacing: 0.5px;
}

.topbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border-color);
}

.topbar-title {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 400;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lang-switcher {
  display: flex;
  align-items: center;
  background: var(--bg-sidebar);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}

.lang-btn {
  padding: 6px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition);
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
}

.lang-btn.active {
  background: var(--accent-gold);
  color: #050720;
  font-weight: 600;
}

.lang-btn:hover:not(.active) {
  color: var(--text-heading);
  background: var(--bg-sidebar-hover);
}

.back-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  transition: all var(--transition);
}

.back-link:hover {
  color: var(--accent-gold);
  border-color: var(--accent-gold);
}

.back-link svg {
  width: 14px;
  height: 14px;
}

/* --- Hamburger --- */
.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  flex-direction: column;
  gap: 5px;
}

.hamburger span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-primary);
  transition: all var(--transition);
  border-radius: 2px;
}

.hamburger.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.hamburger.active span:nth-child(2) {
  opacity: 0;
}

.hamburger.active span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  width: var(--sidebar-width);
  height: calc(100vh - var(--topbar-height));
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 0;
  z-index: 999;
  transition: transform var(--transition);
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.sidebar-search {
  padding: 0 16px 16px;
}

.sidebar-search input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--transition);
}

.sidebar-search input::placeholder {
  color: var(--text-muted);
}

.sidebar-search input:focus {
  border-color: var(--accent-gold);
}

.sidebar-nav {
  list-style: none;
}

.sidebar-chapter {
  margin-bottom: 2px;
}

.sidebar-chapter > a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  position: relative;
}

.sidebar-chapter > a:hover {
  color: var(--text-heading);
  background: var(--bg-sidebar-hover);
}

.sidebar-chapter > a.active {
  color: var(--accent-gold);
  border-left-color: var(--accent-gold);
  background: var(--accent-gold-dim);
}

.sidebar-chapter > a .chapter-num {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
  min-width: 20px;
  flex-shrink: 0;
}

.sidebar-chapter > a.active .chapter-num {
  color: var(--accent-gold);
}

.sidebar-sub {
  list-style: none;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
}

.sidebar-chapter.expanded .sidebar-sub {
  max-height: 2000px;
}

.sidebar-sub a {
  display: block;
  padding: 7px 20px 7px 48px;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 13px;
  transition: all var(--transition);
  border-left: 3px solid transparent;
}

.sidebar-sub a:hover {
  color: var(--text-secondary);
  background: var(--bg-sidebar-hover);
}

.sidebar-sub a.active {
  color: var(--accent-gold);
  border-left-color: var(--accent-gold);
}

.sidebar-chapter .toggle-icon {
  margin-left: auto;
  transition: transform 0.3s ease;
  opacity: 0.4;
  font-size: 10px;
}

.sidebar-chapter.expanded .toggle-icon {
  transform: rotate(90deg);
  opacity: 0.7;
}

/* --- Main Content --- */
.main-content {
  margin-left: var(--sidebar-width);
  padding: calc(var(--topbar-height) + 40px) 60px 80px;
  max-width: 900px;
  min-height: 100vh;
}

.main-content section {
  margin-bottom: 48px;
  padding-top: 4px;
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Righteous', 'Noto Sans SC', cursive;
  color: var(--text-heading);
  line-height: 1.3;
  margin-bottom: 16px;
}

h1 {
  font-size: 36px;
  margin-bottom: 24px;
  background: linear-gradient(135deg, var(--accent-gold), #f5d88a);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

h2 {
  font-size: 26px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
  margin-top: 48px;
  margin-bottom: 20px;
}

h2:first-child {
  margin-top: 0;
}

h3 {
  font-size: 20px;
  color: var(--accent-gold);
  margin-top: 32px;
}

h4 {
  font-size: 17px;
  margin-top: 24px;
}

h5 { font-size: 15px; }
h6 { font-size: 14px; color: var(--text-secondary); }

p {
  margin-bottom: 16px;
  color: var(--text-primary);
}

strong, b {
  color: var(--text-heading);
  font-weight: 600;
}

a {
  color: var(--accent-gold);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--accent-gold-hover);
}

/* --- Lists --- */
ul, ol {
  margin: 12px 0 16px 24px;
}

li {
  margin-bottom: 6px;
  color: var(--text-primary);
}

li::marker {
  color: var(--accent-gold);
}

/* --- Tables --- */
.table-wrapper {
  overflow-x: auto;
  margin: 20px 0;
  border-radius: 10px;
  border: 1px solid var(--border-color);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead {
  background: var(--bg-sidebar);
}

th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--accent-gold);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid var(--border-color);
}

td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

tbody tr:hover {
  background: var(--accent-gold-dim);
}

tbody tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

/* --- Code & Formulas --- */
code {
  background: var(--bg-code);
  color: var(--accent-gold);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 14px;
  font-family: 'Fira Code', 'Courier New', monospace;
  border: 1px solid var(--border-subtle);
}

pre {
  background: var(--bg-code);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 20px;
  overflow-x: auto;
  margin: 16px 0;
}

pre code {
  background: transparent;
  border: none;
  padding: 0;
}

.formula {
  background: var(--bg-code);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 16px 24px;
  margin: 16px 0;
  font-family: 'Fira Code', monospace;
  font-size: 15px;
  color: var(--accent-gold);
  text-align: center;
  overflow-x: auto;
}

/* --- Callouts / Info boxes --- */
.callout {
  padding: 16px 20px;
  border-radius: 10px;
  margin: 20px 0;
  border-left: 4px solid;
  font-size: 14px;
}

.callout-info {
  background: rgba(59, 130, 246, 0.08);
  border-left-color: #3b82f6;
}

.callout-warning {
  background: rgba(234, 195, 111, 0.08);
  border-left-color: var(--accent-gold);
}

.callout-note {
  background: rgba(139, 92, 246, 0.08);
  border-left-color: #8b5cf6;
}

/* --- Flow Diagrams (text-based) --- */
.flow-diagram {
  background: var(--bg-code);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 24px;
  margin: 20px 0;
  text-align: center;
  font-size: 15px;
  line-height: 2.2;
  color: var(--text-heading);
}

.flow-diagram .flow-arrow {
  color: var(--accent-gold);
  margin: 0 4px;
  font-weight: bold;
}

.flow-diagram .flow-step {
  display: inline-block;
  padding: 4px 14px;
  background: var(--accent-gold-dim);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  margin: 4px 2px;
  font-size: 13px;
}

/* --- Blockquotes --- */
blockquote {
  border-left: 3px solid var(--accent-gold);
  padding: 12px 20px;
  margin: 16px 0;
  background: var(--accent-gold-dim);
  border-radius: 0 8px 8px 0;
  color: var(--text-secondary);
  font-style: italic;
}

blockquote p {
  margin-bottom: 8px;
}

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

/* --- Horizontal Rule --- */
hr {
  border: none;
  height: 1px;
  background: var(--border-color);
  margin: 40px 0;
}

/* --- Page Title Section --- */
.page-hero {
  text-align: center;
  padding: 40px 0 48px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 48px;
}

.page-hero h1 {
  font-size: 42px;
  margin-bottom: 8px;
}

.page-hero .subtitle {
  font-size: 18px;
  color: var(--text-secondary);
  font-weight: 300;
  line-height: 1.6;
  max-width: 600px;
  margin: 0 auto;
}

.page-hero .version-badge {
  display: inline-block;
  padding: 4px 14px;
  background: var(--accent-gold-dim);
  border: 1px solid var(--accent-gold);
  border-radius: 20px;
  color: var(--accent-gold);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 16px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

/* --- Chapter headers --- */
.chapter-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.chapter-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: var(--accent-gold);
  color: #050720;
  border-radius: 10px;
  font-family: 'Righteous', cursive;
  font-size: 18px;
  flex-shrink: 0;
}

/* --- Scroll to top --- */
.scroll-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 44px;
  height: 44px;
  background: var(--accent-gold);
  color: #050720;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: translateY(20px);
  transition: all var(--transition);
  z-index: 100;
  box-shadow: 0 4px 20px rgba(234, 195, 111, 0.3);
}

.scroll-top.visible {
  opacity: 1;
  transform: translateY(0);
}

.scroll-top:hover {
  background: var(--accent-gold-hover);
  transform: translateY(-2px);
}

.scroll-top svg {
  width: 20px;
  height: 20px;
}

/* --- Sidebar overlay (mobile) --- */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: var(--topbar-height);
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 998;
}

/* --- Footer --- */
.content-footer {
  margin-top: 60px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  color: var(--text-muted);
}

.content-footer a {
  color: var(--accent-gold);
}

/* --- Responsive --- */
@media (max-width: 1024px) {
  .main-content {
    padding-left: 40px;
    padding-right: 40px;
  }
}

@media (max-width: 768px) {
  .hamburger {
    display: flex;
  }

  .sidebar {
    transform: translateX(-100%);
    width: 280px;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 30px rgba(0, 0, 0, 0.5);
  }

  .sidebar-overlay.active {
    display: block;
  }

  .main-content {
    margin-left: 0;
    padding: calc(var(--topbar-height) + 24px) 20px 60px;
  }

  .topbar-title {
    display: none;
  }

  .topbar-divider {
    display: none;
  }

  .back-link span {
    display: none;
  }

  h1, .page-hero h1 {
    font-size: 28px;
  }

  h2 { font-size: 22px; }
  h3 { font-size: 18px; }

  .page-hero .subtitle {
    font-size: 15px;
  }

  .content-footer {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }
}

/* --- Print --- */
@media print {
  .sidebar, .topbar, .progress-bar, .scroll-top, .hamburger, .sidebar-overlay {
    display: none !important;
  }

  .main-content {
    margin-left: 0;
    padding: 0;
    max-width: 100%;
  }

  body {
    background: #fff;
    color: #222;
  }

  h1, h2, h3, h4 {
    color: #111;
    -webkit-text-fill-color: #111;
  }

  a { color: #333; }

  table, th, td {
    border: 1px solid #ccc;
  }
}
