/* ==========================================================================
   Fuwafuwa Framework Documentation - Modern Styles
   A clean, modern documentation theme with dark mode support
   ========================================================================== */

/* CSS Variables for theming */
:root {
  /* Light mode colors */
  --color-bg: #ffffff;
  --color-bg-secondary: #f8fafc;
  --color-bg-tertiary: #f1f5f9;
  --color-text: #1e293b;
  --color-text-secondary: #475569;
  --color-text-muted: #64748b;
  --color-border: #e2e8f0;
  --color-border-light: #f1f5f9;
  
  /* Brand colors */
  --color-primary: #3b82f6;
  --color-primary-light: #60a5fa;
  --color-primary-dark: #2563eb;
  --color-accent: #8b5cf6;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-error: #ef4444;
  
  /* Code colors */
  --color-code-bg: #f8fafc;
  --color-code-text: #334155;
  --color-code-border: #e2e8f0;
  
  /* TOC colors */
  --color-toc-text: #64748b;
  --color-toc-active: #3b82f6;
  --color-toc-marker: #3b82f6;
  
  /* Spacing */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  
  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Merriweather', Georgia, serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, Monaco, monospace;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
  --transition-slow: 350ms ease;
  
  /* Layout */
  --sidebar-width: 280px;
  --content-max-width: 900px;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #0f172a;
    --color-bg-secondary: #1e293b;
    --color-bg-tertiary: #334155;
    --color-text: #f1f5f9;
    --color-text-secondary: #cbd5e1;
    --color-text-muted: #94a3b8;
    --color-border: #334155;
    --color-border-light: #1e293b;
    
    --color-code-bg: #1e293b;
    --color-code-text: #e2e8f0;
    --color-code-border: #334155;
    
    --color-toc-text: #94a3b8;
    --color-toc-active: #60a5fa;
    --color-toc-marker: #60a5fa;
  }
}

/* Manual dark mode class */
.dark {
  --color-bg: #0f172a;
  --color-bg-secondary: #1e293b;
  --color-bg-tertiary: #334155;
  --color-text: #f1f5f9;
  --color-text-secondary: #cbd5e1;
  --color-text-muted: #94a3b8;
  --color-border: #334155;
  --color-border-light: #1e293b;
  
  --color-code-bg: #1e293b;
  --color-code-text: #e2e8f0;
  --color-code-border: #334155;
  
  --color-toc-text: #94a3b8;
  --color-toc-active: #60a5fa;
  --color-toc-marker: #60a5fa;
}

/* Base styles */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.7;
  color: var(--color-text);
  background-color: var(--color-bg);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Layout structure */
body {
  display: flex;
  padding-left: var(--sidebar-width);
}

@media (max-width: 1024px) {
  body {
    padding-left: 0;
    flex-direction: column;
  }
}

/* ==========================================================================
   Table of Contents Sidebar
   ========================================================================== */

.toc {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  padding: var(--space-xl);
  background: var(--color-bg-secondary);
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  z-index: 100;
  font-size: 0.875rem;
  line-height: 1.6;
}

.toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc > ul > li {
  margin-bottom: var(--space-md);
}

.toc ul ul {
  padding-left: var(--space-md);
  margin-top: var(--space-xs);
  border-left: 2px solid var(--color-border);
}

.toc li {
  position: relative;
  margin: var(--space-xs) 0;
}

.toc li a {
  display: block;
  padding: var(--space-xs) var(--space-sm);
  color: var(--color-toc-text);
  text-decoration: none;
  border-radius: 6px;
  transition: all var(--transition-fast);
}

.toc li a:hover {
  color: var(--color-toc-active);
  background: var(--color-bg-tertiary);
}

.toc .visible > a {
  color: var(--color-toc-active);
  font-weight: 600;
  background: var(--color-bg-tertiary);
  transform: translateX(4px);
}

/* TOC Marker (the cool position indicator) */
.toc-marker {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  overflow: visible;
  pointer-events: none;
}

.toc-marker path {
  transition: all 0.3s ease;
  stroke: var(--color-toc-marker);
  stroke-width: 2;
}

/* TOC Header */
.toc-header {
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--color-border);
}

.toc-brand {
  font-size: 1.25rem;
  text-decoration: none;
  display: block;
  margin-bottom: var(--space-xs);
}

.toc-subtitle {
  display: block;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

/* Home link at bottom of TOC */
.toc-home-link {
  margin-top: var(--space-xl);
  padding-top: var(--space-md);
  border-top: 1px solid var(--color-border);
}

.toc-home-link a {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  color: var(--color-text-secondary);
}

.toc-home-link a:hover {
  color: var(--color-primary);
}

/* Mobile TOC toggle */
.toc-toggle {
  display: none;
  position: fixed;
  top: var(--space-md);
  left: var(--space-md);
  z-index: 200;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  transition: all var(--transition-fast);
}

.toc-toggle:hover {
  background: var(--color-primary-dark);
}

@media (max-width: 1024px) {
  .toc-toggle {
    display: block;
  }
  
  .toc {
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
  }
  
  .toc.open {
    transform: translateX(0);
  }
}

/* ==========================================================================
   Main Content Area
   ========================================================================== */

main, article {
  flex: 1;
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-xl);
}

@media (max-width: 640px) {
  main, article {
    padding: var(--space-xl) var(--space-md);
  }
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  margin-top: var(--space-2xl);
  margin-bottom: var(--space-md);
  font-weight: 700;
  line-height: 1.3;
  color: var(--color-text);
  scroll-margin-top: var(--space-xl);
}

h1 {
  font-size: 2.5rem;
  margin-top: 0;
  padding-bottom: var(--space-md);
  border-bottom: 3px solid var(--color-primary);
}

h2 {
  font-size: 1.875rem;
  padding-bottom: var(--space-sm);
  border-bottom: 2px solid var(--color-border);
}

h3 {
  font-size: 1.5rem;
}

h4 {
  font-size: 1.25rem;
}

h5 {
  font-size: 1.125rem;
}

h6 {
  font-size: 1rem;
}

p {
  margin-top: 0;
  margin-bottom: var(--space-md);
}

/* Links */
a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-primary-dark);
  text-decoration: underline;
}

a:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Lists */
ul, ol {
  margin-top: 0;
  margin-bottom: var(--space-md);
  padding-left: var(--space-xl);
}

li {
  margin-bottom: var(--space-xs);
}

li > ul, li > ol {
  margin-top: var(--space-xs);
  margin-bottom: var(--space-xs);
}

/* Definition lists */
dt {
  font-weight: 600;
  margin-top: var(--space-md);
}

dd {
  margin-left: 0;
  margin-bottom: var(--space-sm);
  color: var(--color-text-secondary);
}

/* ==========================================================================
   Code Blocks & Inline Code
   ========================================================================== */

code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  padding: 0.2em 0.4em;
  background: var(--color-code-bg);
  color: var(--color-code-text);
  border-radius: 4px;
  border: 1px solid var(--color-code-border);
}

pre {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  line-height: 1.6;
  background: var(--color-code-bg);
  color: var(--color-code-text);
  padding: var(--space-lg);
  border-radius: 12px;
  border: 1px solid var(--color-code-border);
  overflow-x: auto;
  margin-bottom: var(--space-lg);
  box-shadow: var(--shadow-sm);
}

pre code {
  padding: 0;
  background: transparent;
  border: none;
  font-size: inherit;
  color: inherit;
}

/* Code block with language label */
pre[class*="language-"] {
  position: relative;
}

pre[class*="language-"]::before {
  content: attr(class);
  position: absolute;
  top: 0;
  right: var(--space-md);
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  background: var(--color-bg-tertiary);
  border-radius: 0 0 6px 6px;
}

/* Copy button for code blocks */
.code-block-wrapper {
  position: relative;
}

.code-copy-btn {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  padding: var(--space-xs) var(--space-sm);
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  cursor: pointer;
  opacity: 0;
  transition: all var(--transition-fast);
}

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

.code-copy-btn:hover {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
}

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

table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: var(--space-lg);
  font-size: 0.9375rem;
  box-shadow: var(--shadow-sm);
  border-radius: 8px;
  overflow: hidden;
}

th, td {
  padding: var(--space-sm) var(--space-md);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

th {
  background: var(--color-bg-secondary);
  font-weight: 600;
  color: var(--color-text);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

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

tr:hover td {
  background: var(--color-bg-secondary);
}

/* ==========================================================================
   Blockquotes
   ========================================================================== */

blockquote {
  margin: var(--space-lg) 0;
  padding: var(--space-md) var(--space-lg);
  border-left: 4px solid var(--color-primary);
  background: var(--color-bg-secondary);
  border-radius: 0 8px 8px 0;
  font-style: italic;
  color: var(--color-text-secondary);
}

blockquote p:last-child {
  margin-bottom: 0;
}

blockquote cite {
  display: block;
  margin-top: var(--space-sm);
  font-size: 0.875rem;
  font-style: normal;
  color: var(--color-text-muted);
}

/* ==========================================================================
   Callouts / Alerts
   ========================================================================== */

.callout {
  margin: var(--space-lg) 0;
  padding: var(--space-md) var(--space-lg);
  border-radius: 8px;
  border-left: 4px solid;
}

.callout-info {
  background: rgb(59 130 246 / 0.1);
  border-color: var(--color-primary);
}

.callout-success {
  background: rgb(16 185 129 / 0.1);
  border-color: var(--color-success);
}

.callout-warning {
  background: rgb(245 158 11 / 0.1);
  border-color: var(--color-warning);
}

.callout-error {
  background: rgb(239 68 68 / 0.1);
  border-color: var(--color-error);
}

.callout-title {
  font-weight: 600;
  margin-bottom: var(--space-xs);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

/* ==========================================================================
   Images
   ========================================================================== */

img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: var(--shadow-md);
}

figure {
  margin: var(--space-xl) 0;
}

figcaption {
  text-align: center;
  font-size: 0.875rem;
  color: var(--color-text-muted);
  margin-top: var(--space-sm);
}

/* ==========================================================================
   Prev/Next Navigation (Generated from JSON structure)
   ========================================================================== */

.prev-next-nav {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: var(--space-md);
  margin-top: var(--space-2xl);
  padding-top: var(--space-xl);
  border-top: 1px solid var(--color-border);
}

.prev-next-link {
  display: flex;
  flex-direction: column;
  flex: 1;
  max-width: 45%;
  padding: var(--space-md) var(--space-lg);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  text-decoration: none;
  color: var(--color-text);
  transition: all var(--transition-fast);
}

.prev-next-link:hover {
  background: var(--color-bg-tertiary);
  border-color: var(--color-primary);
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.prev-link {
  align-items: flex-start;
}

.next-link {
  align-items: flex-end;
  text-align: right;
  margin-left: auto;
}

.prev-next-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: var(--space-xs);
}

.prev-next-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  line-height: 1.4;
}

.prev-next-link:hover .prev-next-title {
  color: var(--color-primary);
}

/* Mobile responsive prev/next nav */
@media (max-width: 640px) {
  .prev-next-nav {
    flex-direction: column;
    gap: var(--space-sm);
  }
  
  .prev-next-link {
    max-width: 100%;
  }
  
  .next-link {
    align-items: flex-start;
    text-align: left;
    margin-left: 0;
  }
}

/* ==========================================================================
   Legacy Navigation Buttons (kept for backward compatibility)
   ========================================================================== */

.nav-buttons {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
  margin-top: var(--space-2xl);
  padding-top: var(--space-xl);
  border-top: 1px solid var(--color-border);
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-lg);
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text);
  font-size: 0.9375rem;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition-fast);
}

.nav-btn:hover {
  background: var(--color-primary);
  color: white;
  border-color: var(--color-primary);
  text-decoration: none;
}

.nav-btn-prev::before {
  content: "←";
}

.nav-btn-next::after {
  content: "→";
}

/* ==========================================================================
   Fuwafuwa Brand Styling
   ========================================================================== */

.ff {
  font-weight: 600;
  background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ==========================================================================
   Utility Classes
   ========================================================================== */

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-left { text-align: left; }

.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }

.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mt-4 { margin-top: var(--space-md); }
.mb-4 { margin-bottom: var(--space-md); }
.mt-8 { margin-top: var(--space-xl); }
.mb-8 { margin-bottom: var(--space-xl); }

/* Badge/Pill styles */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 9999px;
}

.badge-green {
  background: rgb(16 185 129 / 0.15);
  color: var(--color-success);
}

.badge-blue {
  background: rgb(59 130 246 / 0.15);
  color: var(--color-primary);
}

.badge-yellow {
  background: rgb(245 158 11 / 0.15);
  color: var(--color-warning);
}

.badge-red {
  background: rgb(239 68 68 / 0.15);
  color: var(--color-error);
}

/* ==========================================================================
   Search (for API docs)
   ========================================================================== */

.search-container {
  position: relative;
  margin-bottom: var(--space-xl);
}

.search-input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  padding-left: 2.5rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 0.9375rem;
  transition: all var(--transition-fast);
}

.search-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgb(59 130 246 / 0.1);
}

.search-icon {
  position: absolute;
  left: var(--space-sm);
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
}

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

@media print {
  body {
    padding-left: 0;
  }
  
  .toc {
    display: none;
  }
  
  .prev-next-nav,
  .nav-buttons {
    display: none;
  }
  
  pre {
    white-space: pre-wrap;
    word-wrap: break-word;
  }
  
  h1, h2, h3 {
    page-break-after: avoid;
  }
  
  img {
    max-width: 100% !important;
    page-break-inside: avoid;
  }
}

/* ==========================================================================
   Scrollbar styling
   ========================================================================== */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-muted);
}

/* ==========================================================================
   Selection
   ========================================================================== */

::selection {
  background: var(--color-primary);
  color: white;
}

::-moz-selection {
  background: var(--color-primary);
  color: white;
}
