/* ============================================
   GRIDLOCK — Docs Page Styles
   GitBook-style layout with hackerman theme
   ============================================ */

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

:root {
  --bg: #050505;
  --bg-alt: #0a0a0a;
  --bg-card: #0c0c0c;
  --bg-card-hover: #111111;
  --border: #1a1a1a;
  --border-light: #252525;

  --green: #00FF41;
  --green-mid: #00CC33;
  --green-dim: #008F11;
  --green-dark: #003B00;
  --green-glow: rgba(0, 255, 65, 0.15);
  --green-glow-strong: rgba(0, 255, 65, 0.3);

  --cyan: #00E5FF;
  --red: #FF1744;
  --yellow: #FFD600;

  --text: #C0C0C0;
  --text-bright: #E0E0E0;
  --text-dim: #666;
  --text-dark: #444;

  --font-mono: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
  --font-display: 'Space Mono', 'JetBrains Mono', monospace;
  --font-retro: 'VT323', 'Courier New', monospace;

  --nav-height: 60px;
  --sidebar-width: 260px;
  --toc-width: 200px;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: var(--font-mono);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  overflow-x: hidden;
  position: relative;
}

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

/* --- Matrix Rain Canvas --- */
#matrix-rain {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 0.03;
  pointer-events: none;
}

/* --- Scanlines --- */
.scanlines {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.03) 2px,
    rgba(0, 0, 0, 0.03) 4px
  );
}

/* ============================================
   NAVIGATION
   ============================================ */

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: rgba(5, 5, 5, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  height: var(--nav-height);
}

.nav-inner {
  max-width: 100%;
  margin: 0 auto;
  padding: 0 24px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 0;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.logo-bracket {
  color: var(--green);
}

.logo-text {
  color: var(--text-bright);
  padding: 0 4px;
}

.nav-links {
  display: flex;
  gap: 28px;
}

.nav-links a {
  font-size: 13px;
  color: var(--text-dim);
  transition: color 0.2s;
  letter-spacing: 0.02em;
}

.nav-links a:hover {
  color: var(--green);
}

.nav-links a.nav-link-active {
  color: var(--green);
}

.nav-cta {
  font-size: 13px;
  font-weight: 500;
  padding: 8px 20px;
  border: 1px solid var(--green-dim);
  color: var(--green);
  border-radius: 2px;
  transition: all 0.2s;
  font-family: var(--font-mono);
}

.nav-cta:hover {
  background: var(--green);
  color: var(--bg);
  box-shadow: 0 0 20px var(--green-glow);
}

/* Hamburger toggle (mobile only) */
.docs-menu-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
}

.hamburger-line {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-dim);
  transition: transform 0.2s, opacity 0.2s;
}

/* ============================================
   DOCS LAYOUT — THREE COLUMN GRID
   ============================================ */

.docs-layout {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr) var(--toc-width);
  min-height: calc(100vh - var(--nav-height));
  padding-top: var(--nav-height);
}

/* ============================================
   LEFT SIDEBAR
   ============================================ */

.docs-sidebar {
  position: sticky;
  top: var(--nav-height);
  height: calc(100vh - var(--nav-height));
  overflow-y: auto;
  background: var(--bg-alt);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  scrollbar-width: thin;
  scrollbar-color: var(--border-light) transparent;
}

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

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

.docs-sidebar::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 2px;
}

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

.sidebar-search-input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--green);
  font-family: var(--font-mono);
  font-size: 12px;
  outline: none;
  transition: border-color 0.2s;
}

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

.sidebar-search-input:focus {
  border-color: var(--green-dark);
}

/* Sidebar Groups */
.sidebar-group {
  margin-bottom: 4px;
}

.sidebar-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  background: none;
  border: none;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.2s;
  text-align: left;
}

.sidebar-group-title:hover {
  color: var(--text);
}

.sidebar-group-title .chevron {
  color: var(--green-dim);
  font-size: 10px;
  transition: transform 0.2s;
  display: inline-block;
  font-family: var(--font-mono);
}

.sidebar-group:not(.collapsed) .chevron {
  transform: rotate(90deg);
}

.sidebar-group.collapsed .sidebar-group-items {
  display: none;
}

.sidebar-group-items {
  list-style: none;
  padding: 0;
  margin: 0 0 8px;
}

.sidebar-link {
  display: block;
  padding: 6px 16px 6px 36px;
  font-size: 13px;
  color: var(--text);
  border-left: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
  margin-left: 16px;
}

.sidebar-link:hover {
  color: var(--text);
  background: rgba(0, 255, 65, 0.03);
}

.sidebar-link.active {
  color: var(--green);
  border-left-color: var(--green);
  background: rgba(0, 255, 65, 0.05);
}

/* ============================================
   MAIN CONTENT AREA
   ============================================ */

.docs-content {
  padding: 32px 48px 80px;
  min-width: 0;
  overflow-wrap: break-word;
}

/* Only active section visible */
.doc-section {
  display: none;
  max-width: 760px;
}

.doc-section.active {
  display: block;
}

/* --- Breadcrumb --- */
.docs-breadcrumb {
  font-size: 12px;
  color: var(--text-dark);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
}

.breadcrumb-sep {
  color: var(--green-dark);
}

.breadcrumb-page {
  color: var(--text-dim);
}

/* --- Content Typography --- */
.docs-content h1 {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  color: var(--text-bright);
  margin-bottom: 8px;
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.doc-lead {
  font-size: 15px;
  color: var(--text-dim);
  line-height: 1.8;
  margin-bottom: 40px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

.docs-content h2 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-bright);
  margin-top: 48px;
  margin-bottom: 16px;
  letter-spacing: 0.01em;
  line-height: 1.3;
}

.docs-content h2:first-of-type {
  margin-top: 0;
}

.docs-content h3 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--text-bright);
  margin-top: 32px;
  margin-bottom: 12px;
  letter-spacing: 0.02em;
}

.docs-content p {
  font-size: 14px;
  color: var(--text);
  line-height: 1.8;
  margin-bottom: 16px;
}

.docs-content strong {
  color: var(--text-bright);
  font-weight: 600;
}

.docs-content em {
  color: var(--green-dim);
  font-style: normal;
}

/* Inline code */
.docs-content code {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 2px 6px;
  color: var(--green-dim);
}

/* Links in content */
.docs-content a:not(.doc-nav-prev):not(.doc-nav-next) {
  color: var(--green);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.docs-content a:not(.doc-nav-prev):not(.doc-nav-next):hover {
  border-bottom-color: var(--green);
}

/* Lists */
.docs-content ul,
.docs-content ol {
  padding-left: 24px;
  margin-bottom: 16px;
}

.docs-content li {
  font-size: 14px;
  color: var(--text);
  line-height: 1.8;
  margin-bottom: 6px;
}

.docs-content li::marker {
  color: var(--green-dim);
}

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

/* ============================================
   CONTENT COMPONENTS
   ============================================ */

/* --- Terminal Code Block --- */
.doc-terminal {
  margin: 24px 0;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 4px;
  overflow: hidden;
}

.doc-terminal .terminal-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: var(--border);
  border-bottom: 1px solid var(--border-light);
}

.terminal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.terminal-dot.red { background: #FF5F57; }
.terminal-dot.yellow { background: #FFBD2E; }
.terminal-dot.green { background: #28CA41; }

.doc-terminal .terminal-title {
  font-size: 11px;
  color: var(--text-dim);
  margin-left: 8px;
}

.doc-terminal .terminal-body {
  padding: 16px 20px;
  font-size: 13px;
  line-height: 1.8;
  overflow-x: auto;
}

.doc-terminal .terminal-body code {
  display: block;
  background: none;
  border: none;
  padding: 0;
  color: var(--green-dim);
  font-size: 13px;
  white-space: pre;
  line-height: 1.8;
}

.doc-terminal .prompt {
  color: var(--green);
  font-weight: 700;
}

.doc-terminal .cmd {
  color: var(--text-bright);
}

.doc-terminal .output {
  color: var(--green-dim);
  font-size: 12px;
}

/* --- Callout Box --- */
.doc-callout {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--green);
  border-radius: 2px;
  padding: 16px 20px;
  margin: 24px 0;
}

.doc-callout.warning {
  border-left-color: var(--yellow);
}

.doc-callout.danger {
  border-left-color: var(--red);
}

.callout-tag {
  font-size: 11px;
  color: var(--green);
  letter-spacing: 0.12em;
  font-weight: 600;
  display: block;
  margin-bottom: 8px;
}

.doc-callout.warning .callout-tag {
  color: var(--yellow);
}

.doc-callout.danger .callout-tag {
  color: var(--red);
}

.doc-callout p {
  margin-bottom: 0;
  font-size: 13px;
  color: var(--text-dim);
}

/* --- Tables --- */
.doc-table {
  width: 100%;
  border-collapse: collapse;
  margin: 24px 0;
  font-size: 13px;
}

.doc-table th {
  text-align: left;
  padding: 10px 16px;
  background: rgba(0, 255, 65, 0.05);
  border-bottom: 1px solid var(--green-dark);
  color: var(--green);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-size: 11px;
}

.doc-table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.doc-table tr:hover td {
  background: rgba(0, 255, 65, 0.02);
}

.doc-table code {
  font-size: 12px;
}

/* --- Stat Highlight --- */
.doc-stat {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  margin: 8px 0;
}

.doc-stat-value {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--green);
  text-shadow: 0 0 20px var(--green-glow);
}

.doc-stat-label {
  font-size: 13px;
  color: var(--text-dark);
}

/* ============================================
   PREVIOUS / NEXT NAVIGATION
   ============================================ */

.doc-nav-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 64px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
  gap: 16px;
}

.doc-nav-prev,
.doc-nav-next {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 2px;
  transition: border-color 0.2s;
  cursor: pointer;
}

.doc-nav-prev:hover,
.doc-nav-next:hover {
  border-color: var(--green-dark);
}

.doc-nav-next {
  text-align: right;
  margin-left: auto;
}

.doc-nav-label {
  font-size: 11px;
  color: var(--text-dark);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.doc-nav-title {
  font-size: 14px;
  color: var(--green);
  font-weight: 500;
}

/* ============================================
   RIGHT TABLE OF CONTENTS
   ============================================ */

.docs-toc {
  position: sticky;
  top: var(--nav-height);
  height: calc(100vh - var(--nav-height));
  overflow-y: auto;
  padding: 32px 16px 32px 0;
  scrollbar-width: none;
}

.docs-toc::-webkit-scrollbar {
  display: none;
}

.toc-inner {
  padding-left: 16px;
  border-left: 1px solid var(--border);
}

.toc-title {
  font-size: 11px;
  color: var(--text-dark);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 16px;
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc-list li {
  margin-bottom: 0;
}

.toc-list a {
  display: block;
  padding: 4px 0 4px 0;
  font-size: 12px;
  color: var(--text-dark);
  transition: color 0.2s;
  line-height: 1.5;
}

.toc-list a:hover {
  color: var(--text);
}

.toc-list a.toc-active {
  color: var(--green);
}

.toc-list a.toc-h3 {
  padding-left: 12px;
  font-size: 11px;
}

/* ============================================
   FOOTER
   ============================================ */

.footer {
  position: relative;
  z-index: 2;
  padding: 32px 24px 20px;
  border-top: 1px solid var(--border);
}

.footer-inner {
  max-width: 100%;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.footer-tagline {
  font-size: 13px;
  color: var(--text-dark);
  margin-top: 8px;
}

.footer-links {
  display: flex;
  gap: 24px;
}

.footer-links a {
  font-size: 13px;
  color: var(--text-dim);
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--green);
}

.footer-bottom {
  max-width: 100%;
  margin: 24px auto 0;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-bottom p {
  font-size: 12px;
  color: var(--text-dark);
  letter-spacing: 0.05em;
}

/* ============================================
   SIDEBAR OVERLAY (mobile)
   ============================================ */

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 199;
}

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

/* ============================================
   RESPONSIVE
   ============================================ */

/* Hide TOC on smaller screens */
@media (max-width: 1100px) {
  .docs-layout {
    grid-template-columns: var(--sidebar-width) 1fr;
  }

  .docs-toc {
    display: none;
  }
}

/* Mobile: sidebar becomes drawer */
@media (max-width: 768px) {
  .docs-layout {
    grid-template-columns: 1fr;
    z-index: auto; /* Remove stacking context so sidebar can escape */
  }

  .docs-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    z-index: 200;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.33, 1, 0.68, 1);
    padding-top: var(--nav-height);
    background: #0d0d0d;
  }

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

  .docs-content {
    padding: 24px 20px 60px;
  }

  .docs-toc {
    display: none;
  }

  .docs-menu-toggle {
    display: flex;
  }

  .nav-links {
    display: none;
  }

  .doc-nav-footer {
    flex-direction: column;
  }

  .doc-nav-next {
    margin-left: 0;
    text-align: left;
  }

  .docs-content h1 {
    font-size: 26px;
  }

  .docs-content h2 {
    font-size: 19px;
  }
}

@media (min-width: 769px) {
  .docs-menu-toggle {
    display: none;
  }
}
