/* ============================================
   ARCANE INKWELL - DOCUMENTATION STYLES
   ============================================ */

/* ============================================
   GOOGLE FONTS
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* ============================================
   CSS RESET
   ============================================ */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* ============================================
   ROOT VARIABLES
   ============================================ */
:root {
  --font-sans: var(--arcane-font-sans, 'Inter', -apple-system, BlinkMacSystemFont, sans-serif);
  --font-mono: var(--arcane-font-mono, 'Fira Code', 'Consolas', monospace);
  --kb-sidebar-width: 280px;
  --kb-toc-width: 220px;
}

/* ============================================
   BASE STYLES
   ============================================ */
html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  scroll-behavior: smooth;
  background-color: var(--background);
  color: var(--foreground);
}

body {
  min-height: 100vh;
  background-color: var(--background);
  color: var(--foreground);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   SIDEBAR HEADER STYLES
   ============================================ */
.sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sidebar-brand-title {
  font-weight: 700;
  font-size: 1.125rem;
  color: var(--foreground);
}

.sidebar-brand-subtitle {
  font-size: 0.875rem;
  color: var(--muted-foreground);
  margin-top: 0.25rem;
}

.sidebar-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* ============================================
   SIDEBAR SEARCH
   ============================================ */
.sidebar-search {
  position: relative;
  flex: 1;
}

.sidebar-search input {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2rem;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 6px);
  font-size: 0.875rem;
  color: var(--foreground);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.sidebar-search input::placeholder {
  color: var(--muted-foreground);
}

.sidebar-search input:focus {
  border-color: var(--ring);
  box-shadow: 0 0 0 2px var(--ring);
}

.sidebar-search .search-icon {
  position: absolute;
  left: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-foreground);
  pointer-events: none;
}

.search-results {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 0.25rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 6px);
  box-shadow: var(--shadow-lg, 0 10px 15px -3px rgba(0, 0, 0, 0.1));
  max-height: 300px;
  overflow-y: auto;
  z-index: 100;
}

/* ============================================
   SIDEBAR THEME TOGGLE
   ============================================ */
.sidebar-theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 6px);
  color: var(--muted-foreground);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.sidebar-theme-toggle:hover {
  background: var(--muted);
  color: var(--foreground);
}

.theme-icon-dark {
  display: none;
}

.dark .theme-icon-light {
  display: none;
}

.dark .theme-icon-dark {
  display: block;
}

/* ============================================
   SIDEBAR NAVIGATION
   Note: Core sidebar styles (sections, tree, links, chevrons)
   are now provided by arcane_inkwell's KBStyles.
   Add any custom overrides here.
   ============================================ */

/* ============================================
   PROSE CONTENT STYLES
   ============================================ */
.prose {
  max-width: 65ch;
  color: var(--foreground);
}

.prose h1, .prose h2, .prose h3,
.prose h4, .prose h5, .prose h6 {
  color: var(--foreground);
  font-weight: 600;
  line-height: 1.25;
  margin-top: 2rem;
  margin-bottom: 1rem;
}

.prose h1 { font-size: 2.25rem; margin-top: 0; }
.prose h2 {
  font-size: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}
.prose h3 { font-size: 1.25rem; }
.prose h4 { font-size: 1rem; }

.prose p {
  color: var(--muted-foreground);
  margin-bottom: 1rem;
}

.prose li {
  color: var(--muted-foreground);
  margin-bottom: 0.25rem;
}

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

.prose a:hover {
  text-decoration: underline;
  opacity: 0.8;
}

.prose strong, .prose b {
  color: var(--foreground);
  font-weight: 600;
}

.prose em {
  font-style: italic;
}

.prose ul, .prose ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.prose li::marker {
  color: var(--muted-foreground);
}

.prose blockquote {
  border-left: 4px solid var(--border);
  padding-left: 1rem;
  margin: 1rem 0;
  font-style: italic;
  color: var(--muted-foreground);
}

/* ============================================
   CODE BLOCKS
   ============================================ */
.prose pre {
  background-color: oklch(0.97 0 0);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 20px;
  overflow-x: auto;
  margin: 1.5rem 0;
  position: relative;
}

.dark .prose pre {
  background-color: oklch(0.145 0 0);
}

.prose code {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.7;
  color: #c9d1d9;
}

:not(.dark) .prose code {
  color: #24292f;
}

/* Syntax highlighting - Dark mode */
.dark .prose pre code { color: #c9d1d9; }
.dark .prose .hljs-keyword,
.dark .prose .hljs-selector-tag,
.dark .prose .hljs-literal,
.dark .prose .hljs-section,
.dark .prose .hljs-link { color: #ff7b72; }
.dark .prose .hljs-string,
.dark .prose .hljs-attr { color: #a5d6ff; }
.dark .prose .hljs-number,
.dark .prose .hljs-type { color: #79c0ff; }
.dark .prose .hljs-function,
.dark .prose .hljs-title { color: #d2a8ff; }
.dark .prose .hljs-comment { color: #8b949e; font-style: italic; }
.dark .prose .hljs-variable,
.dark .prose .hljs-params { color: #ffa657; }
.dark .prose .hljs-class,
.dark .prose .hljs-built_in { color: #7ee787; }

/* Syntax highlighting - Light mode */
.prose pre code { color: #24292f; }
.prose .hljs-keyword,
.prose .hljs-selector-tag,
.prose .hljs-literal,
.prose .hljs-section,
.prose .hljs-link { color: #cf222e; }
.prose .hljs-string,
.prose .hljs-attr { color: #0a3069; }
.prose .hljs-number,
.prose .hljs-type { color: #0550ae; }
.prose .hljs-function,
.prose .hljs-title { color: #8250df; }
.prose .hljs-comment { color: #6e7781; font-style: italic; }
.prose .hljs-variable,
.prose .hljs-params { color: #953800; }
.prose .hljs-class,
.prose .hljs-built_in { color: #116329; }

/* Inline code */
.prose :not(pre) > code {
  background-color: rgba(175, 184, 193, 0.3);
  color: #1f2328;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.875em;
  font-weight: 500;
}

.dark .prose :not(pre) > code {
  background-color: rgba(110, 118, 129, 0.4);
  color: #e6edf3;
}

/* ============================================
   CODE COPY BUTTON
   ============================================ */
.code-block-wrapper {
  position: relative !important;
  margin: 1.5rem 0;
}

.code-block-wrapper pre {
  margin: 0;
  padding-right: 50px;
}

.copy-code-btn {
  position: absolute !important;
  top: 12px !important;
  right: 12px !important;
  padding: 6px;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--muted-foreground);
  cursor: pointer;
  opacity: 0;
  transition: all 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.code-block-wrapper:hover .copy-code-btn {
  opacity: 0.7;
}

.copy-code-btn:hover {
  opacity: 1 !important;
  background: rgba(0, 0, 0, 0.05);
  color: var(--foreground);
}

.dark .copy-code-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.copy-code-btn.copied {
  color: var(--success, #22c55e);
  opacity: 1 !important;
}

.copy-code-btn svg {
  width: 14px;
  height: 14px;
}

/* ============================================
   TABLES
   ============================================ */
.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}

.prose th, .prose td {
  border: 1px solid var(--border);
  padding: 0.75rem;
  text-align: left;
}

.prose th {
  background-color: var(--muted);
  color: var(--foreground);
  font-weight: 600;
}

.prose td {
  color: var(--muted-foreground);
}

/* ============================================
   HORIZONTAL RULE
   ============================================ */
.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* ============================================
   IMAGES
   ============================================ */
.prose img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md, 6px);
}

/* ============================================
   HEADING ANCHORS
   ============================================ */
.prose h1 a, .prose h2 a, .prose h3 a,
.prose h4 a, .prose h5 a, .prose h6 a {
  color: inherit;
  text-decoration: none;
}

.anchor-link {
  opacity: 0;
  margin-left: 0.5rem;
  color: var(--muted-foreground);
  transition: opacity 0.15s;
}

.prose h1:hover .anchor-link,
.prose h2:hover .anchor-link,
.prose h3:hover .anchor-link {
  opacity: 1;
}

/* ============================================
   TOC STYLES
   ============================================ */
.toc-content a {
  display: block;
  padding: 0.25rem 0;
  font-size: 0.875rem;
  color: var(--muted-foreground);
  text-decoration: none;
  transition: color 0.15s;
}

.toc-content a:hover {
  color: var(--foreground);
}

.toc-content a.toc-active {
  color: var(--primary);
  font-weight: 500;
}

/* ============================================
   CALLOUTS / ADMONITIONS
   ============================================ */
.kb-callout {
  position: relative;
  padding: 1rem 1rem 1rem 1.25rem;
  margin: 1.5rem 0;
  border-radius: var(--radius-lg, 12px);
  border: 1px solid var(--border);
  border-left-width: 4px;
  background: var(--card);
}

.kb-callout-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.875rem;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
}

.kb-callout-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kb-callout-icon svg {
  width: 18px;
  height: 18px;
}

.kb-callout-content {
  font-size: 0.9375rem;
  line-height: 1.6;
  color: var(--muted-foreground);
}

.kb-callout-content br {
  display: block;
  content: '';
  margin-top: 0.5rem;
}

/* Note - Blue */
.kb-callout-note {
  border-left-color: #3b82f6;
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.08) 0%, rgba(59, 130, 246, 0.02) 100%);
}

.kb-callout-note .kb-callout-title {
  color: #3b82f6;
}

.dark .kb-callout-note {
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.12) 0%, rgba(59, 130, 246, 0.04) 100%);
}

/* Tip - Green */
.kb-callout-tip {
  border-left-color: #22c55e;
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.08) 0%, rgba(34, 197, 94, 0.02) 100%);
}

.kb-callout-tip .kb-callout-title {
  color: #22c55e;
}

.dark .kb-callout-tip {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.12) 0%, rgba(34, 197, 94, 0.04) 100%);
}

/* Important - Purple */
.kb-callout-important {
  border-left-color: #a855f7;
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.08) 0%, rgba(168, 85, 247, 0.02) 100%);
}

.kb-callout-important .kb-callout-title {
  color: #a855f7;
}

.dark .kb-callout-important {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.12) 0%, rgba(168, 85, 247, 0.04) 100%);
}

/* Warning - Amber */
.kb-callout-warning {
  border-left-color: #f59e0b;
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, rgba(245, 158, 11, 0.02) 100%);
}

.kb-callout-warning .kb-callout-title {
  color: #f59e0b;
}

.dark .kb-callout-warning {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.12) 0%, rgba(245, 158, 11, 0.04) 100%);
}

/* Caution - Red */
.kb-callout-caution {
  border-left-color: #ef4444;
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.08) 0%, rgba(239, 68, 68, 0.02) 100%);
}

.kb-callout-caution .kb-callout-title {
  color: #ef4444;
}

.dark .kb-callout-caution {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.12) 0%, rgba(239, 68, 68, 0.04) 100%);
}

/* ============================================
   MOBILE SIDEBAR
   ============================================ */
.kb-hamburger {
  display: none;
  padding: 0.5rem;
  background: transparent;
  border: none;
  color: var(--foreground);
  cursor: pointer;
}

.kb-sidebar {
  transition: transform 0.3s ease;
}

@media (max-width: 768px) {
  .kb-hamburger {
    display: block;
  }

  .kb-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    transform: translateX(-100%);
    z-index: 1000;
  }

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

/* ============================================
   BACK TO TOP
   ============================================ */
.kb-back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--muted-foreground);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s, background 0.15s;
  z-index: 100;
}

.kb-back-to-top.visible {
  opacity: 1;
  visibility: visible;
}

.kb-back-to-top:hover {
  background: var(--muted);
  color: var(--foreground);
}

/* ============================================
   SELECTION
   ============================================ */
::selection {
  background-color: var(--accent);
  color: var(--accent-foreground);
}

/* ============================================
   FOCUS STATES
   ============================================ */
button:focus-visible {
  outline: 2px solid var(--ring);
  outline-offset: 2px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
  .toc-content {
    display: none;
  }
}

@media (max-width: 768px) {
  .prose {
    font-size: 15px;
  }
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes arcane-spin {
  to { transform: rotate(360deg); }
}

@keyframes arcane-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes arcane-dropdown-fade {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
