/* ==========================================================================
   APHELION PROTOCOL - GITBOOK-STYLE WHITEPAPER STYLESHEET
   ========================================================================== */

:root {
  --gb-bg-main: #0f1117;
  --gb-bg-sidebar: #131620;
  --gb-bg-header: rgba(19, 22, 32, 0.9);
  --gb-bg-card: #181c28;
  --gb-bg-hover: #202434;
  --gb-border: #232736;
  --gb-border-light: #2d3246;
  --gb-text: #e6e8ee;
  --gb-text-muted: #949cae;
  --gb-text-dim: #646c7e;
  --gb-accent: #2769F9;
  --gb-accent-green: #00ff9d;
  --gb-accent-glow: rgba(39, 105, 249, 0.15);
  --gb-font-body: 'Space Grotesk', sans-serif !important;
  --gb-font-display: 'Space Grotesk', sans-serif !important;
  --gb-font-code: 'Space Grotesk', sans-serif !important;
  --sidebar-width: 280px;
  --toc-width: 240px;
}

/* Light Theme Variables */
[data-theme="light"] {
  --gb-bg-main: #ffffff;
  --gb-bg-sidebar: #f8fafc;
  --gb-bg-header: rgba(255, 255, 255, 0.9);
  --gb-bg-card: #f1f5f9;
  --gb-bg-hover: #e2e8f0;
  --gb-border: #e2e8f0;
  --gb-border-light: #cbd5e1;
  --gb-text: #0f172a;
  --gb-text-muted: #475569;
  --gb-text-dim: #64748b;
  --gb-accent: #2769F9;
  --gb-accent-green: #10b981;
  --gb-accent-glow: rgba(39, 105, 249, 0.1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Space Grotesk', sans-serif !important;
}

a {
  color: inherit;
  text-decoration: none;
}

a:visited {
  color: inherit;
}

html, body, button, input, select, textarea, code, kbd, pre {
  font-size: 16px;
  scroll-behavior: smooth;
  background-color: var(--gb-bg-main);
  color: var(--gb-text);
  font-family: 'Space Grotesk', sans-serif !important;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--gb-bg-main);
}
::-webkit-scrollbar-thumb {
  background: var(--gb-border-light);
  border-radius: 3px;
}

/* HEADER BAR */
.gb-header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 60px;
  z-index: 100;
  background: var(--gb-bg-header);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--gb-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

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

.gb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--gb-text);
  font-family: var(--gb-font-display);
  font-weight: 700;
  font-size: 1.1rem;
}

.gb-brand img {
  height: 28px;
  width: auto;
}

.gb-badge {
  font-family: var(--gb-font-code);
  font-size: 0.7rem;
  padding: 3px 8px;
  border-radius: 4px;
  background: rgba(0, 242, 254, 0.1);
  color: var(--gb-accent);
  border: 1px solid rgba(0, 242, 254, 0.25);
}

.gb-search-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--gb-bg-card);
  border: 1px solid var(--gb-border);
  border-radius: 6px;
  color: var(--gb-text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  width: 240px;
  transition: all 0.2s ease;
}

.gb-search-btn:hover {
  border-color: var(--gb-accent);
  color: var(--gb-text);
}

.gb-search-btn kbd {
  font-family: var(--gb-font-code);
  font-size: 0.7rem;
  background: var(--gb-bg-main);
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--gb-border);
  margin-left: auto;
}

.gb-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.gb-icon-link {
  color: var(--gb-text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.2s ease;
}

.gb-icon-link:hover {
  color: var(--gb-accent);
}

.theme-toggle-btn {
  background: none;
  border: 1px solid var(--gb-border);
  color: var(--gb-text-muted);
  width: 34px;
  height: 34px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.theme-toggle-btn:hover {
  background: var(--gb-bg-hover);
  color: var(--gb-text);
}

/* LAYOUT CONTAINER */
.gb-layout {
  display: flex;
  margin-top: 60px;
  min-height: calc(100vh - 60px);
}

/* LEFT SIDEBAR NAVIGATION */
.gb-sidebar {
  width: var(--sidebar-width);
  background: var(--gb-bg-sidebar);
  border-right: 1px solid var(--gb-border);
  position: fixed;
  top: 60px;
  bottom: 0;
  left: 0;
  overflow-y: auto;
  padding: 24px 16px;
  z-index: 90;
  transition: transform 0.3s ease;
}

.nav-group {
  margin-bottom: 24px;
}

.nav-group-title {
  font-family: var(--gb-font-code);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gb-text-dim);
  margin-bottom: 10px;
  padding-left: 12px;
  font-weight: 700;
}

.nav-items {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  color: var(--gb-text-muted);
  text-decoration: none;
  font-size: 0.88rem;
  border-radius: 6px;
  transition: all 0.2s ease;
  line-height: 1.4;
}

.nav-item-link:hover {
  background: var(--gb-bg-hover);
  color: var(--gb-text);
}

.nav-item-link.active {
  background: var(--gb-bg-hover);
  color: var(--gb-accent);
  font-weight: 500;
  border-left: 3px solid var(--gb-accent);
}

/* MAIN CONTENT AREA */
.gb-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  margin-right: var(--toc-width);
  padding: 40px 56px 80px 56px;
  max-width: 900px;
}

/* BREADCRUMBS */
.gb-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--gb-text-dim);
  margin-bottom: 24px;
}

.gb-breadcrumbs a {
  color: var(--gb-text-muted);
  text-decoration: none;
}

.gb-breadcrumbs a:hover {
  color: var(--gb-accent);
}

/* TYPOGRAPHY IN CONTENT */
.doc-title {
  font-family: var(--gb-font-display);
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 12px;
  color: var(--gb-text);
}

.doc-subtitle {
  font-size: 1.15rem;
  color: var(--gb-text-muted);
  line-height: 1.6;
  margin-bottom: 36px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--gb-border);
}

.doc-section {
  margin-bottom: 48px;
  scroll-margin-top: 80px;
}

.doc-h2 {
  font-family: var(--gb-font-display);
  font-size: 1.75rem;
  font-weight: 600;
  margin-top: 36px;
  margin-bottom: 16px;
  color: var(--gb-text);
  scroll-margin-top: 80px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.doc-h2::before {
  content: '#';
  color: var(--gb-accent);
  opacity: 0.4;
  font-weight: 400;
}

.doc-h3 {
  font-family: var(--gb-font-display);
  font-size: 1.3rem;
  font-weight: 600;
  margin-top: 28px;
  margin-bottom: 14px;
  color: var(--gb-text);
  scroll-margin-top: 80px;
}

.doc-p {
  font-size: 1rem;
  line-height: 1.75;
  color: var(--gb-text-muted);
  margin-bottom: 20px;
}

.doc-ul {
  margin-bottom: 24px;
  padding-left: 24px;
  color: var(--gb-text-muted);
}

.doc-ul li {
  font-size: 0.98rem;
  line-height: 1.7;
  margin-bottom: 8px;
}

/* GITBOOK CALLOUT BOXES */
.gb-callout {
  padding: 20px 24px;
  border-radius: 8px;
  margin: 24px 0;
  display: flex;
  gap: 16px;
  background: var(--gb-bg-card);
  border: 1px solid var(--gb-border);
  border-left: 4px solid var(--gb-accent);
}

.gb-callout.info {
  border-left-color: var(--gb-accent);
  background: rgba(0, 242, 254, 0.05);
}

.gb-callout.success {
  border-left-color: var(--gb-accent-green);
  background: rgba(0, 255, 157, 0.05);
}

.gb-callout.warning {
  border-left-color: #f59e0b;
  background: rgba(245, 158, 11, 0.05);
}

.gb-callout-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.gb-callout-content {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--gb-text);
}

/* GITBOOK DIAGRAM / ARCHITECTURE BOX */
.gb-diagram-box {
  background: var(--gb-bg-card);
  border: 1px solid var(--gb-border);
  border-radius: 8px;
  padding: 32px;
  margin: 32px 0;
  overflow-x: auto;
}

.gb-diagram-flow {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 600px;
  margin: 0 auto;
}

.flow-step-node {
  width: 100%;
  padding: 16px 20px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--gb-border-light);
  border-radius: 6px;
  text-align: center;
  transition: all 0.3s ease;
}

.flow-step-node:hover {
  border-color: var(--gb-accent);
  box-shadow: 0 0 15px rgba(0, 242, 254, 0.15);
}

.flow-step-node .node-tag {
  font-family: var(--gb-font-code);
  font-size: 0.7rem;
  color: var(--gb-accent-green);
  letter-spacing: 0.1em;
  display: block;
  margin-bottom: 4px;
}

.flow-step-node .node-title {
  font-family: var(--gb-font-display);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--gb-text);
}

.flow-arrow {
  color: var(--gb-text-dim);
  font-size: 1.2rem;
}

/* TAX ALLOCATION CARDS IN DOCS */
.doc-alloc-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 28px 0;
}

.doc-alloc-card {
  padding: 20px;
  background: var(--gb-bg-card);
  border: 1px solid var(--gb-border);
  border-radius: 8px;
  text-align: center;
}

.doc-alloc-card .pct {
  font-family: var(--gb-font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--gb-accent);

}

.doc-alloc-card .lbl {
  font-size: 0.88rem;
  color: var(--gb-text-muted);
  margin-top: 6px;
}

/* RIGHT TABLE OF CONTENTS SIDEBAR */
.gb-toc {
  width: var(--toc-width);
  position: fixed;
  top: 60px;
  bottom: 0;
  right: 0;
  overflow-y: auto;
  padding: 40px 20px;
  border-left: 1px solid var(--gb-border);
}

.toc-title {
  font-family: var(--gb-font-code);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gb-text-dim);
  margin-bottom: 12px;
  font-weight: 700;
}

.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-left: 1px solid var(--gb-border);
  padding-left: 12px;
}

.toc-item a {
  color: var(--gb-text-muted);
  text-decoration: none;
  font-size: 0.82rem;
  line-height: 1.4;
  display: block;
  transition: color 0.2s ease;
}

.toc-item a:hover, .toc-item a.active {
  color: var(--gb-accent);
}

/* SEARCH MODAL */
.search-modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding-top: 100px;
}

.search-modal-backdrop.open {
  display: flex;
}

.search-modal {
  width: 100%;
  max-width: 600px;
  background: var(--gb-bg-sidebar);
  border: 1px solid var(--gb-border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.search-modal-input {
  width: 100%;
  padding: 16px 20px;
  background: none;
  border: none;
  border-bottom: 1px solid var(--gb-border);
  color: var(--gb-text);
  font-size: 1.1rem;
  outline: none;
}

.search-results-list {
  max-height: 360px;
  overflow-y: auto;
  padding: 12px;
  list-style: none;
}

.search-result-item {
  padding: 12px 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s ease;
}

.search-result-item:hover {
  background: var(--gb-bg-hover);
}

.search-result-item .item-title {
  font-weight: 600;
  color: var(--gb-text);
  font-size: 0.95rem;
}

.search-result-item .item-snippet {
  font-size: 0.82rem;
  color: var(--gb-text-muted);
  margin-top: 4px;
}

/* RESPONSIVE DESIGN */
@media (max-width: 1100px) {
  .gb-toc { display: none; }
  .gb-main { margin-right: 0; max-width: 100%; }
}

@media (max-width: 768px) {
  .gb-sidebar { transform: translateX(-100%); }
  .gb-sidebar.open { transform: translateX(0); }
  .gb-main { margin-left: 0; padding: 24px 20px; }
  .gb-search-btn { width: 140px; }
}
