/* ══════════════════════════════════════════════════════════
   Init87 — Documentation Stylesheet
   Pure black · Terminal aesthetic · Fluid layout
   ══════════════════════════════════════════════════════════ */

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

/* ── Tokens ─────────────────────────────────────────────── */
:root {
  /* surfaces */
  --bg:           #000000;
  --s0:           #050507;
  --s1:           #0a0a0f;
  --s2:           #111118;
  --s3:           #18181f;

  /* borders */
  --b0:           #161620;
  --b1:           #21212e;
  --b2:           #2e2e40;

  /* text */
  --t0:           #eeeef5;
  --t1:           #9898b0;
  --t2:           #4a4a62;

  /* accent */
  --ac:           #00d9c4;
  --ac-dim:       rgba(0, 217, 196, 0.08);
  --ac-glow:      rgba(0, 217, 196, 0.18);
  --ac2:          #7b6ef6;
  --ac2-dim:      rgba(123, 110, 246, 0.1);

  /* link */
  --lk:           #5ea0fb;
  --lk-h:         #93c5ff;

  /* sizes */
  --topbar-h:     52px;
  --sidebar-w:    268px;
  --content-max:  760px;
  --radius:       5px;
  --radius-lg:    10px;

  /* font */
  --mono:         'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;

  /* transitions */
  --t-fast:       120ms ease;
  --t-med:        200ms ease;
  --t-slow:       300ms cubic-bezier(.4,0,.2,1);
}

/* ── Base ───────────────────────────────────────────────── */
html {
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.75;
  background: var(--bg);
  color: var(--t1);
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

body { min-height: 100vh; }

/* Dot-grid texture on the page body */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    radial-gradient(circle, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 28px 28px;
}

.layout {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a { color: var(--lk); text-decoration: none; transition: color var(--t-fast); }
a:hover { color: var(--lk-h); }

/* ── Scrollbar ──────────────────────────────────────────── */
::-webkit-scrollbar        { width: 5px; height: 5px; }
::-webkit-scrollbar-track  { background: transparent; }
::-webkit-scrollbar-thumb  { background: var(--b1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--b2); }

/* ═══════════════════════════════════════════════════════════
   TOPBAR
   ═══════════════════════════════════════════════════════════ */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background: rgba(0, 0, 0, 0.85);
  border-bottom: 1px solid var(--b0);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  gap: 12px;
}

/* subtle topbar accent line */
.topbar::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--ac-glow) 30%,
    var(--ac2-dim) 70%,
    transparent 100%);
}

.topbar__left,
.topbar__right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.topbar__center {
  flex: 1;
  display: flex;
  justify-content: center;
  overflow: hidden;
}

/* ── Sidebar toggle button ── */
.sidebar-toggle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  width: 34px;
  height: 34px;
  padding: 8px 6px;
  background: transparent;
  border: 1px solid var(--b1);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
  flex-shrink: 0;
}
.sidebar-toggle:hover {
  border-color: var(--b2);
  background: var(--s2);
}

.toggle-bar {
  display: block;
  width: 100%;
  height: 1.5px;
  background: var(--t1);
  border-radius: 2px;
  transition: transform var(--t-med), opacity var(--t-med), width var(--t-med);
  transform-origin: center;
}

/* animate to X when closed */
[data-sidebar="closed"] .toggle-bar:nth-child(1) {
  transform: translateY(5.5px) rotate(45deg);
}
[data-sidebar="closed"] .toggle-bar:nth-child(2) {
  opacity: 0;
  width: 0;
}
[data-sidebar="closed"] .toggle-bar:nth-child(3) {
  transform: translateY(-5.5px) rotate(-45deg);
}

/* ── Brand ── */
.brand {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--t0);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.brand:hover { color: var(--ac); }

.brand__sigil {
  color: var(--ac);
  font-size: 14px;
}

/* ── Breadcrumb ── */
.topbar__crumb {
  font-size: 11px;
  color: var(--t2);
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.crumb-sep { margin-right: 6px; }
.crumb-current { color: var(--t1); }

/* ── Topbar right ── */
.topbar__date {
  font-size: 11px;
  color: var(--t2);
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.topbar__gh {
  display: flex;
  align-items: center;
  color: var(--t2);
  transition: color var(--t-fast);
}
.topbar__gh:hover { color: var(--ac); }

/* ═══════════════════════════════════════════════════════════
   BODY GRID
   ═══════════════════════════════════════════════════════════ */
.body-grid {
  flex: 1;
  display: flex;
  margin-top: var(--topbar-h);
}

/* ═══════════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════════ */
.sidebar {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  width: var(--sidebar-w);
  flex-shrink: 0;
  overflow: hidden;
  background: var(--s0);
  border-right: 1px solid var(--b0);
  transition: width var(--t-slow);
  z-index: 100;
}

[data-sidebar="closed"] .sidebar {
  width: 0;
  border-right-color: transparent;
}

.sidebar__inner {
  width: var(--sidebar-w);
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--b1) transparent;
}

/* ── Sidebar head ── */
.sidebar__head {
  padding: 20px 16px 14px;
  border-bottom: 1px solid var(--b0);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--s1) 0%, var(--s0) 100%);
}

.sidebar__site-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ac);
}
.sidebar__site-sub {
  display: block;
  font-size: 10px;
  color: var(--t2);
  letter-spacing: 0.06em;
  margin-top: 2px;
}

/* ── Sidebar nav ── */
.sidebar__nav {
  flex: 1;
  padding: 8px 0;
}

.sidebar__section {
  border-bottom: 1px solid var(--b0);
}

/* Section header button */
.sidebar__section-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 14px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--t2);
  transition: color var(--t-fast), background var(--t-fast);
  text-align: left;
}
.sidebar__section-btn:hover {
  color: var(--t0);
  background: var(--s2);
}

.chevron {
  flex-shrink: 0;
  transition: transform var(--t-med);
  color: var(--t2);
}
.sidebar__section.is-collapsed .chevron {
  transform: rotate(-90deg);
}

/* Links list — animated collapse */
.sidebar__links {
  list-style: none;
  padding: 2px 0 6px;
  overflow: hidden;
  max-height: 600px;
  transition: max-height var(--t-slow), opacity var(--t-med), padding var(--t-med);
  opacity: 1;
}
.sidebar__section.is-collapsed .sidebar__links {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
}

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 20px;
  font-size: 12px;
  color: var(--t1);
  border-left: 2px solid transparent;
  transition: color var(--t-fast), background var(--t-fast), border-color var(--t-fast);
  position: relative;
  margin: 1px 0;
}
.sidebar__link:hover {
  color: var(--t0);
  background: var(--s2);
  border-left-color: var(--b2);
}
.sidebar__link.is-active {
  color: var(--ac) !important;
  border-left-color: var(--ac) !important;
  background: var(--ac-dim) !important;
}

.link__dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--b2);
  flex-shrink: 0;
  transition: background var(--t-fast);
}
.sidebar__link:hover .link__dot { background: var(--t2); }
.sidebar__link.is-active .link__dot { background: var(--ac); }

.link__text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Sidebar footer links ── */
.sidebar__footer-links {
  padding: 14px 16px;
  border-top: 1px solid var(--b0);
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--s0) 0%, var(--s1) 100%);
}

.sidebar__ext-link {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: var(--t2);
  transition: color var(--t-fast);
}
.sidebar__ext-link:hover { color: var(--ac); }

/* ═══════════════════════════════════════════════════════════
   MAIN
   ═══════════════════════════════════════════════════════════ */
.main {
  flex: 1;
  min-width: 0;
  overflow-x: hidden;
  transition: flex var(--t-slow);
}

.content-wrap {
  max-width: calc(var(--content-max) + 112px);
  padding: 0 56px 80px;
  margin: 0 auto;
}

/* ═══════════════════════════════════════════════════════════
   PAGE HERO
   ═══════════════════════════════════════════════════════════ */
.page-hero {
  position: relative;
  margin: 0 -56px 40px;
  overflow: hidden;
}

.page-hero__inner {
  position: relative;
  padding: 48px 56px 36px;
  border-bottom: 1px solid var(--b0);
  background:
    linear-gradient(135deg, var(--ac-dim) 0%, transparent 50%),
    linear-gradient(225deg, var(--ac2-dim) 0%, transparent 60%),
    var(--s0);
}

/* ambient glow blob */
.page-hero__glow {
  position: absolute;
  top: -60px;
  left: -40px;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: var(--ac-glow);
  filter: blur(80px);
  pointer-events: none;
  opacity: 0.5;
}

.page-hero__part {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ac);
  margin-bottom: 10px;
}

.page-hero__title {
  font-size: clamp(20px, 4vw, 30px);
  font-weight: 700;
  color: var(--t0);
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-bottom: 12px;
  position: relative;
}

.page-hero__desc {
  font-size: 13px;
  color: var(--t1);
  line-height: 1.7;
  max-width: 600px;
  margin-bottom: 18px;
  position: relative;
}

.page-hero__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  position: relative;
}

.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  font-size: 10px;
  letter-spacing: 0.05em;
  border-radius: 3px;
  background: var(--s2);
  border: 1px solid var(--b1);
  color: var(--t2);
}
.meta-chip--tag {
  color: var(--ac);
  border-color: rgba(0, 217, 196, 0.2);
  background: var(--ac-dim);
}

/* ═══════════════════════════════════════════════════════════
   ARTICLE
   ═══════════════════════════════════════════════════════════ */
.article { max-width: var(--content-max); }

/* ── Headings ── */
.article h1, .article h2, .article h3,
.article h4, .article h5, .article h6 {
  color: var(--t0);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin: 40px 0 14px;
}

.article h1 { font-size: 22px; }

.article h2 {
  font-size: 16px;
  color: var(--t0);
  padding: 10px 14px;
  background: var(--s1);
  border: 1px solid var(--b0);
  border-left: 3px solid var(--ac);
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 18px;
}

.article h3 {
  font-size: 13.5px;
  color: var(--ac);
}

.article h4 { font-size: 13px; color: var(--t1); }
.article h5, .article h6 { font-size: 12px; color: var(--t2); }

/* ── Paragraphs ── */
.article p { margin: 14px 0; color: var(--t1); }

/* ── Lists ── */
.article ul, .article ol {
  padding-left: 20px;
  margin: 14px 0;
}
.article li { margin: 5px 0; color: var(--t1); }
.article ul li::marker { color: var(--ac); content: '▸  '; }
.article ol li::marker { color: var(--ac); font-weight: 700; }

/* ── Strong / Em ── */
.article strong { color: var(--t0); font-weight: 700; }
.article em     { color: var(--t1); font-style: italic; }

/* ── HR ── */
.article hr {
  border: none;
  border-top: 1px solid var(--b0);
  margin: 36px 0;
  position: relative;
}
.article hr::after {
  content: '◆';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg);
  padding: 0 10px;
  font-size: 8px;
  color: var(--b2);
}

/* ── Inline code ── */
.article code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ac);
  background: var(--s2);
  border: 1px solid var(--b1);
  border-radius: 3px;
  padding: 1px 6px;
}

/* ── Code blocks ── */
.article pre {
  background: var(--s1);
  border: 1px solid var(--b1);
  border-radius: var(--radius-lg);
  margin: 20px 0;
  overflow: hidden;
  position: relative;
}

/* fake window chrome bar */
.article pre::before {
  content: '● ● ●';
  display: block;
  padding: 8px 14px;
  font-size: 10px;
  letter-spacing: 4px;
  color: var(--b2);
  background: var(--s2);
  border-bottom: 1px solid var(--b1);
}

.article pre code {
  display: block;
  padding: 18px 20px;
  overflow-x: auto;
  background: none;
  border: none;
  color: var(--t1);
  font-size: 12.5px;
  line-height: 1.75;
  scrollbar-width: thin;
  scrollbar-color: var(--b1) transparent;
}

/* ── Blockquote ── */
.article blockquote {
  margin: 20px 0;
  padding: 14px 18px;
  border-left: 3px solid var(--ac2);
  background: var(--ac2-dim);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--t1);
}
.article blockquote p { margin: 0; }

/* ── Tables ── */
.article table {
  width: 100%;
  border-collapse: collapse;
  margin: 22px 0;
  font-size: 12.5px;
}
.article th {
  background: var(--s2);
  color: var(--t0);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 9px 14px;
  text-align: left;
  border: 1px solid var(--b1);
}
.article td {
  padding: 8px 14px;
  border: 1px solid var(--b0);
  color: var(--t1);
}
.article tr:nth-child(even) td { background: var(--s1); }
.article tr:hover td           { background: var(--s2); transition: background var(--t-fast); }

/* ── Body links ── */
.article a {
  color: var(--lk);
  border-bottom: 1px solid rgba(94, 160, 251, 0.25);
  transition: color var(--t-fast), border-color var(--t-fast);
}
.article a:hover {
  color: var(--lk-h);
  border-bottom-color: var(--lk-h);
}

/* ── Images ── */
.article img {
  max-width: 100%;
  border-radius: var(--radius-lg);
  border: 1px solid var(--b1);
  margin: 16px 0;
}

/* ═══════════════════════════════════════════════════════════
   PAGE NAV (prev / next)
   ═══════════════════════════════════════════════════════════ */
.page-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 52px;
  padding-top: 28px;
  border-top: 1px solid var(--b0);
  max-width: var(--content-max);
}
.page-nav__prev, .page-nav__next {
  display: flex;
}
.page-nav__next { justify-content: flex-end; text-align: right; }

.page-nav a {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  background: var(--s1);
  border: 1px solid var(--b0);
  border-radius: var(--radius-lg);
  color: var(--t1);
  transition: border-color var(--t-fast), background var(--t-fast);
  width: 100%;
}
.page-nav a:hover {
  border-color: var(--ac);
  background: var(--ac-dim);
  color: var(--t0);
}
.page-nav__label {
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--t2);
}
.page-nav__title {
  font-size: 12px;
  color: var(--t0);
  font-weight: 500;
}

/* ═══════════════════════════════════════════════════════════
   ROUGE SYNTAX — dark terminal
   ═══════════════════════════════════════════════════════════ */
.highlight { background: transparent !important; }

.highlight .c,  .highlight .cm,
.highlight .c1, .highlight .cs  { color: #3d4055; font-style: italic; }

.highlight .k,  .highlight .kd,
.highlight .kn, .highlight .kr,
.highlight .kp, .highlight .kt  { color: #c792ea; font-weight: 600; }

.highlight .s,  .highlight .s1,
.highlight .s2, .highlight .sb,
.highlight .sc, .highlight .sd  { color: #c3e88d; }

.highlight .n,  .highlight .na  { color: #82aaff; }
.highlight .nb                  { color: #89ddff; }
.highlight .nf, .highlight .fm  { color: var(--ac); }
.highlight .nc                  { color: #ffcb6b; }
.highlight .o,  .highlight .ow  { color: #89ddff; }
.highlight .mi, .highlight .mf,
.highlight .mh                  { color: #f78c6c; }
.highlight .p                   { color: #b8bcc8; }
.highlight .err                 { color: #ff5572; background: none; border: none; }
.highlight .nt                  { color: #f07178; }
.highlight .ni                  { color: var(--ac); }
.highlight .ne                  { color: #f78c6c; font-weight: bold; }

/* ═══════════════════════════════════════════════════════════
   FOOTER
   ═══════════════════════════════════════════════════════════ */
.footer {
  border-top: 1px solid var(--b0);
  background: var(--s0);
  position: relative;
  overflow: hidden;
}

/* footer gradient background */
.footer::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--ac-glow) 40%,
    var(--ac2-dim) 60%,
    transparent 100%);
}

.footer::after {
  content: '';
  position: absolute;
  bottom: 0; right: 0;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: var(--ac2-dim);
  filter: blur(80px);
  pointer-events: none;
}

.footer__inner {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 40px;
  max-width: 1200px;
  margin: 0 auto;
  padding: 40px 56px;
}

.footer__brand {}

.footer__sigil {
  font-size: 16px;
  font-weight: 700;
  color: var(--ac);
}
.footer__name {
  font-size: 14px;
  font-weight: 700;
  color: var(--t0);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-left: 6px;
}
.footer__tagline {
  font-size: 11px;
  color: var(--t2);
  margin-top: 8px;
  max-width: 340px;
  line-height: 1.6;
}

.footer__cols {
  display: flex;
  gap: 48px;
}

.footer__col {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 100px;
}

.footer__col-head {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--t2);
  margin-bottom: 6px;
}

.footer__link {
  font-size: 12px;
  color: var(--t2);
  transition: color var(--t-fast);
  display: block;
}
.footer__link:hover { color: var(--ac); }
.footer__link--static { cursor: default; }
.footer__link--static:hover { color: var(--t2); }

/* bottom bar */
.footer__bar {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 56px;
  border-top: 1px solid var(--b0);
  background: var(--bg);
}

.footer__copy {
  font-size: 10px;
  color: var(--t2);
  letter-spacing: 0.04em;
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  :root { --sidebar-w: 240px; }

  .content-wrap  { padding: 0 28px 60px; }
  .page-hero     { margin: 0 -28px 32px; }
  .page-hero__inner { padding: 36px 28px 28px; }
  .footer__inner { grid-template-columns: 1fr; gap: 24px; padding: 32px 28px; }
  .footer__cols  { gap: 28px; flex-wrap: wrap; }
  .footer__bar   { padding: 12px 28px; flex-direction: column; gap: 4px; text-align: center; }
}

@media (max-width: 640px) {
  :root { --sidebar-w: 100vw; }

  /* on mobile sidebar slides over content as an overlay */
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    height: auto;
    box-shadow: 4px 0 24px rgba(0,0,0,0.6);
  }

  [data-sidebar="open"] .sidebar  { width: 100vw; }
  [data-sidebar="closed"] .sidebar { width: 0; }

  .content-wrap  { padding: 0 16px 60px; }
  .page-hero     { margin: 0 -16px 24px; }
  .page-hero__inner { padding: 28px 16px 20px; }
  .footer__inner { padding: 24px 16px; }
  .footer__bar   { padding: 12px 16px; }
  .page-nav      { grid-template-columns: 1fr; }
}

