/* ==========================================================================
   Hyperliquid Wiki & Knowledge Base - Design System
   Modern dark documentation theme inspired by Stripe Docs, GitBook, and Ethereum.org
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --bg-primary: #0b1114;
  --bg-secondary: #0f191d;
  --bg-tertiary: #142228;
  --bg-card: #121e23;
  --bg-card-hover: #17272e;
  --bg-code: #080d0f;
  
  --border-subtle: #1a2a30;
  --border-medium: #243a43;
  --border-active: #50d2c1;
  
  --text-primary: #f6fefd;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-dim: #475569;
  
  --accent-primary: #50d2c1;
  --accent-secondary: #1fa67d;
  --accent-glow: rgba(80, 210, 193, 0.15);
  --accent-blue: #38bdf8;
  --accent-amber: #fbbf24;
  --accent-purple: #c084fc;
  
  --sidebar-width: 280px;
  --toc-width: 240px;
  --header-height: 64px;
  --content-max-width: 860px;
  
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  color-scheme: dark;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ─── Scrollbars ─── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ─── Top Header Bar ─── */
.top-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-height);
  background: rgba(11, 17, 20, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-logo {
  width: 36px;
  height: 36px;
  background: rgba(80, 210, 193, 0.08);
  border: 1px solid rgba(80, 210, 193, 0.35);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.brand-wrapper:hover .brand-logo {
  background: rgba(80, 210, 193, 0.18);
  border-color: #50d2c1;
  box-shadow: 0 0 14px rgba(80, 210, 193, 0.3);
}

.brand-logo svg {
  display: block;
}

.brand-text-group {
  display: flex;
  flex-direction: column;
}

.brand-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
  line-height: 1.2;
}

.brand-subtext {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

/* Header Search & Nav */
.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.search-container {
  position: relative;
  width: 280px;
}

.search-input {
  width: 100%;
  height: 36px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 0 12px 0 36px;
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  transition: all 0.2s ease;
}

.search-input:focus {
  border-color: var(--accent-primary);
  background: var(--bg-tertiary);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 14px;
}

.mobile-menu-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--border-medium);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* ─── Layout Structure ─── */
.wiki-layout {
  display: flex;
  flex: 1;
  width: 100%;
  max-width: 1540px;
  margin: 0 auto;
}

/* ─── Left Sidebar Navigation ─── */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  height: calc(100vh - var(--header-height));
  position: sticky;
  top: var(--header-height);
  overflow-y: auto;
  padding: 24px 16px 40px;
}

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

.nav-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 10px;
  padding-left: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  font-weight: 400;
}

.nav-link:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  text-decoration: none;
}

.nav-link.active {
  background: var(--accent-glow);
  color: var(--accent-primary);
  font-weight: 600;
  border-left: 3px solid var(--accent-primary);
}

.nav-pill {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--bg-tertiary);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ─── Main Content Area ─── */
.main-wrapper {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: center;
  padding: 40px 32px 80px;
}

.content-article {
  width: 100%;
  max-width: var(--content-max-width);
}

/* ─── Breadcrumbs ─── */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

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

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

.breadcrumbs span.separator {
  color: var(--border-medium);
}

.breadcrumbs span.current {
  color: var(--text-secondary);
}

/* ─── Typography & Article Elements ─── */
.article-header {
  margin-bottom: 32px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 24px;
}

.article-title {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -0.8px;
  color: var(--text-primary);
  line-height: 1.25;
  margin-bottom: 12px;
}

.article-lead {
  font-size: 17px;
  color: var(--text-secondary);
  line-height: 1.6;
  font-weight: 400;
}

.article-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

.meta-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* Headings */
h2 {
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.4px;
  color: var(--text-primary);
  margin: 38px 0 16px;
  padding-top: 16px;
  border-top: 1px solid rgba(26, 42, 48, 0.6);
  display: flex;
  align-items: center;
  gap: 8px;
}

h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 26px 0 12px;
}

p {
  font-size: 15px;
  color: #cbd5e1;
  margin-bottom: 18px;
  line-height: 1.75;
}

strong {
  color: var(--text-primary);
  font-weight: 600;
}

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

a:hover {
  text-decoration: underline;
}

ul, ol {
  margin: 16px 0 24px 20px;
  color: #cbd5e1;
}

li {
  margin-bottom: 8px;
  font-size: 15px;
  line-height: 1.7;
}

/* ─── Callout Boxes ─── */
.callout {
  padding: 16px 20px;
  border-radius: var(--radius-md);
  margin: 24px 0;
  font-size: 14px;
  line-height: 1.65;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.callout-icon {
  font-size: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}

.callout.info {
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.25);
  color: #bae6fd;
}

.callout.tip {
  background: rgba(80, 210, 193, 0.08);
  border: 1px solid rgba(80, 210, 193, 0.25);
  color: #c7f9f1;
}

.callout.warning {
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.25);
  color: #fef08a;
}

/* ─── Tables ─── */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  margin: 24px 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-card);
}

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

th {
  background: var(--bg-secondary);
  padding: 12px 16px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-medium);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.6px;
}

td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: #cbd5e1;
}

tr:last-child td {
  border-bottom: none;
}

/* ─── Code Blocks ─── */
pre {
  background: var(--bg-code);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  overflow-x: auto;
  margin: 20px 0;
  position: relative;
}

code {
  font-family: var(--font-mono);
  font-size: 13.5px;
}

:not(pre) > code {
  background: var(--bg-tertiary);
  color: var(--accent-primary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  border: 1px solid var(--border-subtle);
}

.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-medium);
  color: var(--text-muted);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
}

.copy-btn:hover {
  color: var(--text-primary);
  border-color: var(--accent-primary);
}

/* ─── Architecture Diagram Card ─── */
.diagram-card {
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin: 28px 0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.diagram-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ─── Cards Grid ─── */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin: 24px 0;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 24px 0;
}

.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-decoration: none;
}

.feature-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-medium);
  transform: translateY(-2px);
  text-decoration: none;
}

.feature-icon {
  font-size: 24px;
  margin-bottom: 4px;
}

.feature-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.feature-desc {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin-bottom: 0;
}

/* ─── Page Navigation Buttons (Prev / Next) ─── */
.page-nav-wrapper {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border-subtle);
}

.page-nav-link {
  display: flex;
  flex-direction: column;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: all 0.2s;
  flex: 1;
}

.page-nav-link:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-primary);
  text-decoration: none;
}

.page-nav-direction {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.5px;
}

.page-nav-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 4px;
}

/* ─── Right On-Page Table of Contents ─── */
.right-toc {
  width: var(--toc-width);
  flex-shrink: 0;
  padding: 40px 0 40px 24px;
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
}

.toc-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.6px;
  margin-bottom: 12px;
}

.toc-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  border-left: 1px solid var(--border-subtle);
}

.toc-item {
  padding-left: 12px;
}

.toc-item a {
  color: var(--text-muted);
  text-decoration: none;
  display: block;
  transition: color 0.15s;
  line-height: 1.4;
}

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

.toc-item.active {
  border-left: 2px solid var(--accent-primary);
  margin-left: -1px;
}

/* ─── Dedicated Legal Callout Card ─── */
.legal-banner-card {
  background: rgba(26, 42, 48, 0.6);
  border: 1px solid var(--border-medium);
  border-left: 4px solid var(--accent-amber);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 28px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.legal-banner-icon {
  font-size: 22px;
  line-height: 1;
  flex-shrink: 0;
  margin-top: 2px;
}

.legal-banner-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.legal-banner-text strong {
  color: #fff;
}

/* ─── Footer Disclaimer & Legal Navigation ─── */
.wiki-footer {
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
  padding: 36px 24px;
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin-top: auto;
}

.footer-legal-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.footer-legal-links a {
  color: var(--accent-primary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: color 0.15s;
}

.footer-legal-links a:hover {
  color: #fff;
  text-decoration: underline;
}

.footer-divider {
  color: var(--border-medium);
}

.wiki-footer p {
  max-width: 900px;
  margin: 0 auto 8px;
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ─── Responsive Media Queries ─── */
@media (max-width: 1200px) {
  .right-toc {
    display: none;
  }
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    left: -280px;
    top: var(--header-height);
    bottom: 0;
    z-index: 99;
    transition: left 0.3s ease;
  }
  .sidebar.open {
    left: 0;
  }
  .mobile-menu-btn {
    display: block;
  }
  .grid-2, .grid-3 {
    grid-template-columns: 1fr;
  }
  .main-wrapper {
    padding: 24px 16px 60px;
  }
  .search-container {
    width: 180px;
  }
}
