/* =========================================================
   Oscilla Docs — Stylesheet
   ========================================================= */

/* ---------------------------------------------------------
   CSS Custom Properties
   --------------------------------------------------------- */

:root {
  --bg-main: #0d1117;
  --bg-panel: #161b22;
  --bg-code: #0f172a;
  --bg-hover: #1c2128;

  --text-main: #e6edf3;
  --text-muted: #9da7b3;
  --text-faint: #7d8590;

  --border-subtle: #30363d;

  --link: #58a6ff;
  --link-hover: #79c0ff;

  --accent: #1f6feb;
  --accent-glow: rgba(31, 111, 235, 0.15);

  --header-height: 3.25rem;
  --sidebar-width: 240px;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

/* ---------------------------------------------------------
   Reset & Base
   --------------------------------------------------------- */

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

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

body, html {
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* ---------------------------------------------------------
   Header (fixed)
   --------------------------------------------------------- */

.docs-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;

  display: flex;
  align-items: center;
  gap: 0.75rem;
  height: var(--header-height);
  padding: 0 1rem;

  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-subtle);
}

.docs-header-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
  text-decoration: none;
}

.docs-header-title:hover {
  color: var(--link);
}


.docs-logo {
  height: 32px;
  width: auto;
  display: block;
}

.docs-menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;

  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-main);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.docs-menu-toggle:hover {
  background: var(--bg-hover);
  border-color: var(--text-faint);
}

.docs-menu-toggle svg {
  display: block;
}

/* ---------------------------------------------------------
   Layout Grid
   --------------------------------------------------------- */

.docs-container {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
  min-height: 100vh;
  padding-top: var(--header-height);
}

/* ---------------------------------------------------------
   Sidebar
   --------------------------------------------------------- */

.sidebar {
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  overflow-y: auto;
  overscroll-behavior: contain;

  padding: 1rem 0.75rem;
  background: var(--bg-panel);
  border-right: 1px solid var(--border-subtle);

  font-size: 0.875rem;
  line-height: 1.4;
}

/* Custom scrollbar for sidebar */
.sidebar::-webkit-scrollbar {
  width: 6px;
}

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

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

.sidebar::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
}

/* Sidebar headings */
.sidebar h2,
.sidebar h3 {
  color: var(--text-main);
  margin: 0;
}

.sidebar h2 {
  margin: 1.25rem 0 0.5rem;
  padding-bottom: 0.25rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar h2:first-child,
.sidebar h3:first-child {
  margin-top: 0;
}

.sidebar h3 {
  margin: 1rem 0 0.35rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}

/* Sidebar lists */
.sidebar ul {
  list-style: none;
  margin: 0 0 0.5rem;
  padding: 0;
}

.sidebar li {
  margin: 0;
  padding: 0;
}

.sidebar a {
  display: block;
  padding: 0.1rem 1.95rem;
  margin: 0 -0.5rem;
  border-radius: 4px;

  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition-fast), background var(--transition-fast);
}

.sidebar a:hover {
  color: var(--text-main);
  background: var(--bg-hover);
}

.sidebar a.active,
.sidebar a[aria-current="page"] {
  color: var(--link);
  background: var(--accent-glow);
  font-weight: 500;
}

/* ---------------------------------------------------------
   Main Content
   --------------------------------------------------------- */

.docs-content {
  min-width: 0;
  max-width: 52rem;
  padding: 1.5rem 2rem 3rem;

  font-size: 0.95rem;
  line-height: 1.65;
}

/* Headings */
.docs-content h1,
.docs-content h2,
.docs-content h3,
.docs-content h4 {
  color: var(--text-main);
  font-weight: 600;
  line-height: 1.3;
}

.docs-content h1 {
  margin: 0 0 1rem;
  font-size: 1.75rem;
}

.docs-content h2 {
  margin: 2rem 0 0.75rem;
  padding-bottom: 0.35rem;
  font-size: 1.35rem;
  border-bottom: 1px solid var(--border-subtle);
}

.docs-content h3 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1.1rem;
}

.docs-content h4 {
  margin: 1.25rem 0 0.4rem;
  font-size: 1rem;
}

/* Paragraphs */
.docs-content p {
  margin: 0 0 1rem;
}

/* Lists */
.docs-content ul,
.docs-content ol {
  margin: 0 0 1rem;
  padding-left: 1.5rem;
}

.docs-content li {
  margin: 0.3rem 0;
}

.docs-content li > ul,
.docs-content li > ol {
  margin: 0.3rem 0 0.3rem;
}

/* Links */
.docs-content a {
  color: var(--link);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.docs-content a:hover {
  color: var(--link-hover);
  text-decoration: underline;
}

/* Inline code */
.docs-content code {
  padding: 0.15em 0.4em;
  font-size: 0.875em;
  font-family: "SF Mono", "Fira Code", "JetBrains Mono", Consolas, monospace;
  background: var(--bg-code);
  border-radius: 4px;
  color: #f0f6fc;
}

/* Code blocks */
.docs-content pre {
  margin: 0 0 1.25rem;
  padding: 1rem;
  overflow-x: auto;

  background: var(--bg-code);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;

  font-size: 0.85rem;
  line-height: 1.5;
}

.docs-content pre code {
  padding: 0;
  background: transparent;
  border-radius: 0;
}

/* Blockquotes */
.docs-content blockquote {
  margin: 0 0 1rem;
  padding: 0.5rem 1rem;
  border-left: 3px solid var(--accent);
  background: var(--accent-glow);
  border-radius: 0 6px 6px 0;
}

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

/* Tables */
.docs-content table {
  width: 100%;
  margin: 0 0 1.25rem;
  border-collapse: collapse;
  font-size: 0.9rem;
}

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

.docs-content th {
  background: var(--bg-panel);
  font-weight: 600;
}

.docs-content tr:nth-child(even) {
  background: rgba(255, 255, 255, 0.02);
}

/* Images */
.docs-content img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}

.doc-image {
  margin: 1rem 0;
}

.doc-image img {
  max-width: 50%;
  cursor: zoom-in;
  transition: transform var(--transition-normal);
}

.doc-image img:active {
  transform: scale(1.5);
  cursor: zoom-out;
}

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

/* ---------------------------------------------------------
   Page Navigation (prev / next)
   --------------------------------------------------------- */

.docs-nav {
  display: flex;
  gap: 1rem;
  /* margin-bottom: 1.5rem; */
  padding-bottom: 0rem;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.875rem;
}

.docs-nav a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.docs-nav a:hover {
  color: var(--link);
}

/* ---------------------------------------------------------
   Hint Text
   --------------------------------------------------------- */

.docs-hint {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  color: var(--text-faint);
}

/* ---------------------------------------------------------
   Mobile Overlay
   --------------------------------------------------------- */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity var(--transition-normal);
  pointer-events: none;
}

/* ---------------------------------------------------------
   Responsive: Tablet & Mobile (≤900px)
   --------------------------------------------------------- */

@media (max-width: 900px) {
  :root {
    --sidebar-width: 280px;
  }

  /* Show hamburger */
  .docs-menu-toggle {
    display: flex;
  }

  /* Single column layout */
  .docs-container {
    grid-template-columns: 1fr;
  }

  /* Sidebar becomes slide-out drawer */
  .sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    z-index: 95;

    width: var(--sidebar-width);
    max-width: 85vw;
    height: calc(100vh - var(--header-height));

    transform: translateX(-100%);
    transition: transform var(--transition-normal);
    border-radius: 0;
    box-shadow: none;
  }

  /* Sidebar open state */
  body.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
  }

  /* Show overlay when sidebar is open */
  body.sidebar-open .sidebar-overlay {
    display: block;
    opacity: 1;
    pointer-events: auto;
  }

  /* Prevent body scroll when sidebar is open */
  body.sidebar-open {
    overflow: hidden;
  }

  /* Content adjustments */
  .docs-content {
    padding: 1rem 1rem 2rem;
  }

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

  .docs-content h2 {
    font-size: 1.2rem;
  }

  .doc-image img {
    max-width: 100%;
  }
}

/* ---------------------------------------------------------
   Responsive: Small Mobile (≤480px)
   --------------------------------------------------------- */

@media (max-width: 480px) {
  .docs-content {
    padding: 0.75rem 0.75rem 2rem;
    font-size: 0.9rem;
  }

  .docs-content pre {
    padding: 0.75rem;
    font-size: 0.8rem;
    border-radius: 6px;
  }

  .docs-nav {
    flex-direction: column;
    gap: 0.5rem;
  }
}

/* ---------------------------------------------------------
   Cheatsheet Styles (in-browser)
   --------------------------------------------------------- */

.cheatsheet-content {
  max-width: none;
}

.cheatsheet-content h1 {
  margin-bottom: 0.25rem;
}

.cheatsheet-content h3 {
  margin-top: 0;
  color: var(--text-muted);
  font-weight: 400;
}

.cheatsheet-intro {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.print-btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-main);
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.print-btn:hover {
  background: var(--bg-hover);
  border-color: var(--text-faint);
}

/* Tighter spacing for cheatsheet code blocks */
.cheatsheet-content pre {
  margin: 0.4rem 0 0.8rem;
  padding: 0.6rem 0.8rem;
  font-size: 0.8rem;
  line-height: 1.45;
}

.cheatsheet-content h2 {
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
}

.cheatsheet-content p strong {
  color: var(--link);
}

.cheatsheet-footer {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  color: var(--text-faint);
  text-align: center;
}

/* ---------------------------------------------------------
   Print Styles
   --------------------------------------------------------- */

@media print {
  /* Hide navigation chrome */
  .docs-header,
  .docs-menu-toggle,
  .sidebar,
  .sidebar-overlay,
  .docs-nav,
  .docs-hint,
  .print-btn,
  .cheatsheet-intro {
    display: none !important;
  }

  /* Reset layout */
  .docs-container {
    display: block;
    padding: 0;
  }

  .docs-content {
    max-width: none;
    padding: 0;
    margin: 0;
  }

  /* Light theme for print */
  body {
    background: white;
    color: black;
    font-size: 9pt;
    line-height: 1.3;
  }

  /* ---------------------------------------------------------
     Cheatsheet Print Layout — Multi-column
     --------------------------------------------------------- */

  .cheatsheet-content {
    column-count: 3;
    column-gap: 1.5em;
    column-rule: 1px solid #ddd;
  }

  .cheatsheet-content h1 {
    column-span: all;
    font-size: 14pt;
    margin: 0 0 0.25rem;
    text-align: center;
  }

  .cheatsheet-content > h3:first-of-type {
    column-span: all;
    text-align: center;
    margin: 0 0 0.5rem;
    font-size: 9pt;
    color: #666;
  }

  .cheatsheet-content h2 {
    font-size: 9pt;
    margin: 0.6rem 0 0.2rem;
    padding-bottom: 0.15rem;
    border-bottom: 1px solid #ccc;
    break-after: avoid;
    color: #0066cc;
  }

  .cheatsheet-content h3 {
    font-size: 8pt;
    margin: 0.4rem 0 0.15rem;
    color: #333;
  }

  .cheatsheet-content p {
    margin: 0.15rem 0;
    font-size: 8pt;
  }

  .cheatsheet-content p strong {
    color: #0066cc;
  }

  .cheatsheet-content pre {
    margin: 0.2rem 0 0.4rem;
    padding: 0.3rem 0.4rem;
    font-size: 6.5pt;
    line-height: 1.35;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 3px;
    break-inside: avoid;
    white-space: pre-wrap;
    word-break: break-word;
  }

  .cheatsheet-content code {
    font-size: 6.5pt;
    background: #f0f0f0;
    padding: 0.1em 0.25em;
    border-radius: 2px;
  }

  .cheatsheet-footer {
    column-span: all;
    margin-top: 0.5rem;
    padding-top: 0.25rem;
    font-size: 7pt;
    color: #666;
    border-top: 1px solid #ddd;
    text-align: center;
  }

  /* Page setup */
  @page {
    size: A4 landscape;
    margin: 0.75cm;
  }

  /* Prevent awkward breaks */
  .cheatsheet-content h2,
  .cheatsheet-content p strong {
    break-after: avoid;
  }

  .cheatsheet-content pre {
    break-inside: avoid;
  }
}
