/* ============================================================
   pi.dev-inspired dark theme — Inference & Deployment Guide
   ============================================================ */

/* --- Custom Properties --- */
:root {
  --bg-base:        #080808;
  --bg-surface:     #111111;
  --bg-elevated:    #1a1a1a;
  --bg-code:        #0f0f0f;
  --bg-highlight:   #1f1a12;

  --border:         #2a2a2a;
  --border-subtle:  #1e1e1e;

  --text-primary:   #e8e8e8;
  --text-secondary: #999999;
  --text-muted:     #555555;

  --accent:         #f97316;
  --accent-dim:     #c2570e;
  --accent-glow:    rgba(249, 115, 22, 0.15);
  --accent-subtle:  rgba(249, 115, 22, 0.08);

  --green:          #22c55e;
  --blue:           #3b82f6;
  --purple:         #a855f7;
  --yellow:         #eab308;

  --sidebar-width:  260px;
  --font-sans:      'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:      'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'SF Mono', Consolas, monospace;

  --radius-sm:      4px;
  --radius:         6px;
  --radius-lg:      10px;

  --transition:     150ms ease;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* --- Layout --- */
.layout {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  flex-shrink: 0;
}

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

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

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

.sidebar-header {
  padding: 1.25rem 1.125rem;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text-primary);
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  transition: color var(--transition);
}

.logo:hover {
  color: var(--accent);
}

.logo-icon {
  font-size: 1.1rem;
  line-height: 1;
}

.logo-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  flex: 1;
  padding: 0.625rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.nav-item {
  display: block;
  padding: 0.4375rem 0.75rem;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--text-secondary);
  font-size: 0.8125rem;
  font-weight: 400;
  line-height: 1.4;
  transition: color var(--transition), background-color var(--transition);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.nav-item.active {
  color: var(--accent);
  background-color: var(--accent-subtle);
  font-weight: 500;
}

.sidebar-footer {
  padding: 0.875rem 1.125rem;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.github-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  transition: color var(--transition);
}

.github-link:hover {
  color: var(--text-secondary);
}

/* --- Mobile sidebar toggle --- */
.sidebar-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 200;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 2.25rem;
  height: 2.25rem;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0.375rem;
  transition: background-color var(--transition), border-color var(--transition);
}

.sidebar-toggle:hover {
  background: var(--bg-surface);
  border-color: var(--accent);
}

.sidebar-toggle span {
  display: block;
  width: 16px;
  height: 1.5px;
  background: var(--text-secondary);
  border-radius: 1px;
  transition: transform var(--transition), opacity var(--transition);
}

.sidebar-toggle.active span:nth-child(1) {
  transform: translateY(5.5px) rotate(45deg);
}

.sidebar-toggle.active span:nth-child(2) {
  opacity: 0;
}

.sidebar-toggle.active span:nth-child(3) {
  transform: translateY(-5.5px) rotate(-45deg);
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 90;
  backdrop-filter: blur(2px);
}

/* --- Main content area --- */
.main-content {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.content {
  flex: 1;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  padding: 3rem 2.5rem 4rem;
}

/* --- Footer --- */
.content-footer {
  border-top: 1px solid var(--border-subtle);
  padding: 1.25rem 2.5rem;
}

.footer-inner {
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.625rem;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.footer-inner a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition);
}

.footer-inner a:hover {
  color: var(--accent);
}

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

/* ============================================================
   Typography
   ============================================================ */

.content h1 {
  font-size: 1.875rem;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  margin-bottom: 1rem;
  margin-top: 0;
}

.content h2 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-top: 2.5rem;
  margin-bottom: 0.875rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.content h3 {
  font-size: 1.0625rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--accent);
  margin-top: 2rem;
  margin-bottom: 0.625rem;
}

.content h4 {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.content h5,
.content h6 {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 1.25rem;
  margin-bottom: 0.375rem;
}

.content p {
  margin-bottom: 1.125rem;
  color: var(--text-primary);
}

.content p:last-child {
  margin-bottom: 0;
}

.content a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color var(--transition), color var(--transition);
}

.content a:hover {
  color: var(--accent-dim);
  border-bottom-color: var(--accent-dim);
}

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

.content em {
  color: var(--text-secondary);
  font-style: italic;
}

/* --- Blockquote --- */
.content blockquote {
  margin: 1.5rem 0;
  padding: 0.875rem 1.125rem;
  background: var(--accent-subtle);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.content blockquote p {
  color: var(--text-secondary);
  font-size: 0.9375rem;
  margin: 0;
}

.content blockquote strong {
  color: var(--accent);
}

/* --- Horizontal rule --- */
.content hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin: 2.5rem 0;
}

/* --- Lists --- */
.content ul,
.content ol {
  padding-left: 1.625rem;
  margin-bottom: 1.125rem;
}

.content li {
  margin-bottom: 0.3125rem;
  color: var(--text-primary);
}

.content li::marker {
  color: var(--accent);
}

.content li > ul,
.content li > ol {
  margin-top: 0.3125rem;
  margin-bottom: 0.3125rem;
}

/* ============================================================
   Code Blocks
   ============================================================ */

.content code {
  font-family: var(--font-mono);
  font-size: 0.8125rem;
  background: var(--bg-elevated);
  color: var(--accent);
  padding: 0.125rem 0.3125rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.content pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.375rem;
  overflow-x: auto;
  margin: 1.375rem 0;
  font-size: 0.8125rem;
  line-height: 1.65;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.content pre::-webkit-scrollbar {
  height: 4px;
}

.content pre::-webkit-scrollbar-track {
  background: transparent;
}

.content pre::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

.content pre code {
  background: transparent;
  color: var(--text-primary);
  padding: 0;
  border: none;
  border-radius: 0;
  font-size: inherit;
  white-space: pre;
}

/* ASCII diagrams: preserve exact spacing, prevent wrapping */
.content pre code {
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
}

/* --- Rouge syntax highlighting (dark theme) --- */
.highlight { background: var(--bg-code); }

.highlight .c,
.highlight .cd,
.highlight .cm,
.highlight .c1,
.highlight .cs  { color: #6b7280; font-style: italic; }  /* Comments */
.highlight .err { color: #f87171; }                        /* Error */
.highlight .k,
.highlight .kc,
.highlight .kd,
.highlight .kn,
.highlight .kp,
.highlight .kr,
.highlight .kt  { color: #a78bfa; font-weight: 500; }      /* Keywords */
.highlight .o   { color: #94a3b8; }                        /* Operators */
.highlight .p   { color: #94a3b8; }                        /* Punctuation */
.highlight .na  { color: #34d399; }                        /* Attr name */
.highlight .nb  { color: #60a5fa; }                        /* Builtin */
.highlight .nc  { color: #34d399; font-weight: 500; }      /* Class */
.highlight .no  { color: #f97316; }                        /* Constant */
.highlight .nd  { color: #f97316; }                        /* Decorator */
.highlight .ni  { color: #e5e7eb; }                        /* Entity */
.highlight .ne  { color: #f87171; }                        /* Exception */
.highlight .nf  { color: #60a5fa; font-weight: 500; }      /* Function */
.highlight .nl  { color: #e5e7eb; }                        /* Label */
.highlight .nn  { color: #34d399; }                        /* Namespace */
.highlight .nt  { color: #60a5fa; }                        /* Tag */
.highlight .nv  { color: #e5e7eb; }                        /* Variable */
.highlight .ow  { color: #a78bfa; }                        /* Word operator */
.highlight .w   { color: #e5e7eb; }                        /* Whitespace */
.highlight .l,
.highlight .ld,
.highlight .m,
.highlight .mb,
.highlight .mf,
.highlight .mh,
.highlight .mi,
.highlight .mo  { color: #fb923c; }                        /* Numbers/Literals */
.highlight .s,
.highlight .sb,
.highlight .sc,
.highlight .sd,
.highlight .s2,
.highlight .se,
.highlight .sh,
.highlight .si,
.highlight .sx,
.highlight .sr,
.highlight .s1,
.highlight .ss  { color: #86efac; }                        /* Strings */
.highlight .bp  { color: #60a5fa; }                        /* Builtin pseudo */
.highlight .vc,
.highlight .vg,
.highlight .vi  { color: #e5e7eb; }                        /* Variables */
.highlight .il  { color: #fb923c; }                        /* Integer literal */

/* ============================================================
   Tables
   ============================================================ */

.content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.875rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: block;
  overflow-x: auto;
}

.content thead {
  background: var(--bg-elevated);
}

.content th {
  padding: 0.6875rem 1rem;
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.content td {
  padding: 0.5625rem 1rem;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: top;
}

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

.content tbody tr:hover {
  background: var(--bg-elevated);
}

/* ============================================================
   Special elements
   ============================================================ */

/* First paragraph after H1 gets the subtitle treatment */
.content h1 + p > em:only-child,
.content h1 + blockquote {
  color: var(--text-secondary);
}

/* Back link styling */
.content > p:first-child > a[href*="README"] {
  display: inline-flex;
  align-items: center;
  gap: 0.3125rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  border-bottom: none;
  margin-bottom: 0.5rem;
  padding: 0.25rem 0;
  transition: color var(--transition);
}

.content > p:first-child > a[href*="README"]:hover {
  color: var(--accent);
  border-bottom: none;
}

/* Emoji in headings */
.content h1 .emoji,
.content h2 .emoji,
.content h3 .emoji {
  font-style: normal;
}

/* ============================================================
   Responsive — Mobile
   ============================================================ */

@media (max-width: 768px) {
  .sidebar-toggle {
    display: flex;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 250ms ease;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  }

  .sidebar-overlay {
    display: block;
    opacity: 0;
    pointer-events: none;
    transition: opacity 250ms ease;
  }

  .sidebar-overlay.visible {
    opacity: 1;
    pointer-events: auto;
  }

  .main-content {
    margin-left: 0;
  }

  .content {
    padding: 4.5rem 1.25rem 3rem;
  }

  .content-footer {
    padding: 1rem 1.25rem;
  }

  .content h1 {
    font-size: 1.5rem;
  }

  .content h2 {
    font-size: 1.125rem;
  }

  .content pre {
    font-size: 0.75rem;
    padding: 1rem;
  }
}

@media (max-width: 480px) {
  .content {
    padding: 4.5rem 1rem 2.5rem;
  }

  .content table {
    font-size: 0.8125rem;
  }

  .content th,
  .content td {
    padding: 0.5rem 0.625rem;
  }
}

/* ============================================================
   Print
   ============================================================ */

@media print {
  .sidebar,
  .sidebar-toggle,
  .sidebar-overlay,
  .content-footer {
    display: none;
  }

  .main-content {
    margin-left: 0;
  }

  .content {
    max-width: 100%;
    padding: 1rem;
  }

  .content pre {
    white-space: pre-wrap;
    word-break: break-all;
    border: 1px solid #ccc;
  }

  body {
    background: white;
    color: black;
  }
}
