/* ═══════════════════════════════════════════════════════════════
   BugCreators Docs — Shared Base Styles
   Import: <link rel="stylesheet" href="../../shared/docs-base.css">
   ═══════════════════════════════════════════════════════════════ */

/* ── THEME VARIABLES ── */
:root {
  --bg: #0a0a0f;
  --surface: #111118;
  --surface2: #16161f;
  --border: #1e1e2e;
  --accent: #00ff88;
  --accent2: #ff3e6c;
  --accent3: #ffe44d;
  --accent4: #4ecaff;
  --text: #e8e8f0;
  --muted: #5a5a7a;
  --glow: rgba(0, 255, 136, 0.18);
  --code-bg: #0d0d14;
  --code-border: #1a1a2a;
}

[data-theme="light"] {
  --bg: #f0ede8;
  --surface: #faf8f4;
  --surface2: #f4f0ea;
  --border: #ddd8ce;
  --accent: #007a42;
  --accent2: #cc2249;
  --accent3: #c8930a;
  --accent4: #0080aa;
  --text: #1a1a2e;
  --muted: #8a8aaa;
  --glow: rgba(0, 122, 66, 0.12);
  --code-bg: #f5f3ee;
  --code-border: #ddd8ce;
}

/* ── RESET & BASE ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0
}

html {
  scroll-behavior: smooth
}

body {
  width: 100%;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Space Mono', monospace;
  transition: background .4s, color .4s;
  line-height: 1.7;
  font-size: 14px
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 40px 40px;
  opacity: .4;
  pointer-events: none;
  z-index: 0
}

/* ── SIDEBAR ── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 220px;
  height: 100vh;
  background: var(--surface);
  border-right: 1px solid var(--border);
  z-index: 100;
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto
}

.sidebar-brand {
  padding: 0 20px 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px
}

.sidebar-brand a {
  color: var(--muted);
  text-decoration: none;
  font-size: 11px;
  letter-spacing: .1em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: color .2s
}

.sidebar-brand a:hover {
  color: var(--accent)
}

.sidebar-tree {
  flex: 1;
  overflow-y: auto;
  padding: 0 0 16px
}

.tree-category {
  margin-bottom: 4px
}

.tree-cat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 20px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  user-select: none
}

.tree-cat-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%
}

.tree-group {
  margin-bottom: 2px
}

.tree-group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 20px 7px 32px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  transition: all .2s;
  user-select: none;
  letter-spacing: .03em
}

.tree-group-header:hover {
  color: var(--accent);
  background: var(--surface2)
}

.tree-group-header .arrow {
  font-size: 8px;
  color: var(--muted);
  transition: transform .2s;
  min-width: 10px
}

.tree-group.open .arrow {
  transform: rotate(90deg)
}

.tree-group-header .coming {
  font-size: 8px;
  padding: 1px 6px;
  border-radius: 100px;
  background: var(--surface2);
  color: var(--muted);
  letter-spacing: .06em;
  margin-left: auto
}

.tree-items {
  list-style: none;
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s ease
}

.tree-group.open .tree-items {
  max-height: 300px
}

.tree-items li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 20px 6px 44px;
  color: var(--muted);
  text-decoration: none;
  font-size: 11px;
  letter-spacing: .03em;
  border-left: 2px solid transparent;
  transition: all .2s
}

.tree-items li a:hover {
  color: var(--text);
  background: var(--surface2);
  border-left-color: var(--border)
}

.tree-items li a.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(0, 255, 136, 0.05)
}

.tree-items .nav-num {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 10px;
  color: var(--muted);
  min-width: 16px
}

.tree-items li a.active .nav-num {
  color: var(--accent)
}

/* ── MAIN CONTENT ── */
.main {
  margin-left: 220px;
  padding: 40px 40px 80px;
  max-width: 900px;
  position: relative;
  z-index: 1;
  margin-right: auto;
  margin-left: calc(220px + max(0px, (100vw - 220px - 900px) / 2))
}

.main {
  padding-top: 70px
}

/* ── TOP BAR ── */
.topbar {
  position: fixed;
  top: 0;
  right: 0;
  left: 220px;
  height: 50px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 99;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 24px;
  gap: 8px
}

.ctrl-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  padding: 6px 12px;
  cursor: pointer;
  border-radius: 4px;
  transition: all .2s;
  letter-spacing: .05em
}

.ctrl-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 12px var(--glow)
}

/* ── TYPOGRAPHY ── */
h1 {
  font-family: 'Syne', sans-serif;
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 8px
}

h2 {
  font-family: 'Syne', sans-serif;
  font-size: clamp(1.3rem, 3vw, 1.8rem);
  font-weight: 700;
  margin: 48px 0 16px;
  color: var(--text);
  position: relative;
  padding-left: 16px
}

h2::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 3px;
  background: var(--accent);
  border-radius: 2px
}

h3 {
  font-family: 'Syne', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  margin: 32px 0 12px;
  color: var(--accent4)
}

p {
  margin-bottom: 16px;
  color: var(--text);
  opacity: .9
}

.green {
  color: var(--accent)
}

.red {
  color: var(--accent2)
}

.blue {
  color: var(--accent4)
}

.yellow {
  color: var(--accent3)
}

/* ── HERO ── */
.hero {
  text-align: center;
  padding: 40px 0 48px
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 6px 16px;
  border-radius: 100px;
  font-size: 11px;
  color: var(--accent);
  letter-spacing: .1em;
  text-transform: uppercase;
  margin-bottom: 24px;
  animation: fadeDown .6s ease both
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.5s infinite
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
    transform: scale(1)
  }

  50% {
    opacity: .5;
    transform: scale(1.4)
  }
}

@keyframes fadeDown {
  from {
    opacity: 0;
    transform: translateY(-16px)
  }

  to {
    opacity: 1;
    transform: translateY(0)
  }
}

.hero p {
  color: var(--muted);
  max-width: 500px;
  margin: 12px auto 0;
  font-size: 13px
}

.cursor {
  display: inline-block;
  width: 2px;
  height: 1.1em;
  background: var(--accent);
  margin-left: 3px;
  vertical-align: text-bottom;
  animation: blink .8s step-end infinite
}

@keyframes blink {

  0%,
  100% {
    opacity: 1
  }

  50% {
    opacity: 0
  }
}

/* ── COMPARE CARDS ── */
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin: 24px 0
}

.compare-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 28px 24px;
  position: relative;
  overflow: hidden;
  transition: all .3s
}

.compare-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px
}

.compare-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 24px var(--glow);
  transform: translateY(-2px)
}

.compare-card h3 {
  margin-top: 0;
  font-size: 1.3rem
}

.compare-card .subtitle {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 16px;
  font-style: italic
}

.compare-card .icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  display: block
}

.compare-card ul {
  list-style: none;
  padding: 0
}

.compare-card ul li {
  padding: 6px 0;
  font-size: 13px;
  color: var(--text);
  opacity: .85;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px
}

.compare-card ul li:last-child {
  border-bottom: none
}

.compare-card ul li::before {
  content: '>';
  color: var(--accent);
  font-weight: 700;
  font-size: 11px
}

/* ── FLOW DIAGRAM ── */
.flow-diagram {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 32px 0;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
  justify-content: center;
  flex-wrap: nowrap
}

.flow-box {
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 14px 20px;
  border-radius: 6px;
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .05em;
  white-space: nowrap;
  transition: all .3s;
  min-width: 100px;
  position: relative
}

.flow-box:hover {
  border-color: var(--accent);
  box-shadow: 0 0 16px var(--glow);
  transform: translateY(-3px)
}

.flow-box.highlight-green {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: 0 0 20px var(--glow)
}

.flow-box.highlight-blue {
  border-color: var(--accent4);
  color: var(--accent4);
  box-shadow: 0 0 20px rgba(78, 202, 255, 0.2)
}

.flow-box .flow-label {
  font-size: 9px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .1em;
  margin-top: 4px;
  font-weight: 400
}

.flow-arrow {
  display: flex;
  align-items: center;
  padding: 0 8px;
  color: var(--muted);
  font-size: 18px;
  user-select: none;
  flex-shrink: 0
}

.flow-arrow::after {
  content: '';
  display: inline-block;
  width: 24px;
  height: 2px;
  background: var(--border);
  position: relative
}

.flow-arrow span {
  color: var(--accent);
  font-size: 14px;
  margin-left: -2px
}

/* ── ACCORDION ── */
.accordion {
  margin: 24px 0
}

.accordion-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 8px;
  overflow: hidden;
  transition: border-color .3s
}

.accordion-item:hover {
  border-color: var(--accent)
}

.accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .05em;
  transition: background .2s;
  user-select: none
}

.accordion-header:hover {
  background: var(--surface2)
}

.accordion-header .tag {
  font-size: 10px;
  padding: 3px 10px;
  border-radius: 100px;
  border: 1px solid var(--border);
  color: var(--muted);
  letter-spacing: .08em;
  margin-left: auto;
  margin-right: 12px
}

.accordion-toggle {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--accent);
  transition: transform .3s;
  flex-shrink: 0
}

.accordion-item.open .accordion-toggle {
  transform: rotate(45deg)
}

.accordion-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height .4s ease
}

.accordion-item.open .accordion-body {
  max-height: 600px
}

.accordion-content {
  padding: 0 20px 20px;
  font-size: 13px;
  color: var(--text);
  opacity: .85;
  line-height: 1.8
}

.accordion-content code {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 12px;
  color: var(--accent)
}

/* ── CODE BLOCK ── */
.code-block {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 6px;
  padding: 16px 20px;
  margin: 16px 0;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.7;
  position: relative
}

.code-block .code-lang {
  position: absolute;
  top: 8px;
  right: 12px;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: .1em;
  text-transform: uppercase
}

.code-block pre {
  margin: 0;
  white-space: pre;
  font-family: 'Space Mono', monospace
}

.kw {
  color: var(--accent4)
}

.type {
  color: var(--accent)
}

.str {
  color: var(--accent3)
}

.cmt {
  color: var(--muted);
  font-style: italic
}

.attr {
  color: var(--accent2)
}

.num {
  color: var(--accent3)
}

.fn {
  color: var(--accent4)
}

/* ── NAV CARDS ── */
.nav-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 32px 0
}

.nav-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 24px;
  text-decoration: none;
  color: var(--text);
  transition: all .3s;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden
}

.nav-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform .3s;
  transform-origin: left
}

.nav-card:hover {
  border-color: var(--accent);
  box-shadow: 0 0 24px var(--glow);
  transform: translateY(-2px)
}

.nav-card:hover::before {
  transform: scaleX(1)
}

.nav-card .card-num {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 2rem;
  color: var(--accent);
  opacity: .3;
  line-height: 1
}

.nav-card .card-title {
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: 1rem
}

.nav-card .card-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6
}

/* ── PREV/NEXT NAV ── */
.page-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 64px;
  padding-top: 32px;
  border-top: 1px solid var(--border)
}

.page-nav a {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px 24px;
  text-decoration: none;
  color: var(--text);
  transition: all .3s;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px
}

.page-nav a:hover {
  border-color: var(--accent);
  box-shadow: 0 0 16px var(--glow)
}

.page-nav a .nav-dir {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .1em
}

.page-nav a .nav-title {
  font-weight: 700;
  font-size: 14px
}

.page-nav a.next {
  text-align: right
}

/* ── TIP & WARNING ── */
.tip {
  background: rgba(0, 255, 136, 0.05);
  border: 1px solid rgba(0, 255, 136, 0.2);
  border-radius: 6px;
  padding: 16px 20px;
  margin: 16px 0;
  font-size: 13px
}

.tip::before {
  content: 'TIP';
  font-size: 10px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: .1em;
  display: block;
  margin-bottom: 6px
}

.warning {
  background: rgba(255, 62, 108, 0.05);
  border: 1px solid rgba(255, 62, 108, 0.2);
  border-radius: 6px;
  padding: 16px 20px;
  margin: 16px 0;
  font-size: 13px
}

.warning::before {
  content: 'WARNING';
  font-size: 10px;
  font-weight: 700;
  color: var(--accent2);
  letter-spacing: .1em;
  display: block;
  margin-bottom: 6px
}

/* ── MOBILE NAV ── */
.mobile-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0
}

.mobile-nav-inner {
  display: flex
}

.mobile-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 4px 12px;
  font-size: 8px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  transition: color .2s;
  border: none;
  background: transparent;
  font-family: 'Space Mono', monospace;
  cursor: pointer
}

.mobile-tab .tab-icon {
  font-size: 16px
}

.mobile-tab:hover,
.mobile-tab.active {
  color: var(--accent)
}

/* ── SCROLL REVEAL ── */
.scroll-reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .5s ease, transform .5s ease
}

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

/* ── RESPONSIVE ── */
@media(max-width:768px) {
  .sidebar {
    display: none
  }

  .topbar {
    left: 0
  }

  .main {
    margin-left: 0;
    padding: 70px 20px 100px
  }

  .mobile-nav {
    display: block
  }

  .compare-grid,
  .nav-cards {
    grid-template-columns: 1fr
  }

  .flow-diagram {
    justify-content: flex-start
  }

  h1 {
    font-size: 1.8rem
  }
}