/**
 * @name Altuit-TOC
 * @background #111927
 * @text #FFFFFF
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600&display=swap');

/* ============================================
   CSS Variables - Dark/Light Theme Support
   ============================================ */
:root {
  --accent: #FF6B1A;
  --accent-hover: #FF8A4C;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(0,0,0,.35);
  --content-w: 920px;
  --sidebar-w: 280px;
}

/* Dark theme - for browser export and in-app preview */
[data-theme="dark"],
.theme-altuit-toc {
  --bg: #111927;
  --elev-1: #1A2332;
  --elev-2: #1A2332;
  --text: #FFFFFF;
  --muted: #B0B0B0;
  --border: #09324B;
  --link: #FF6B1A;
  --chip: #1A2332;
  --code-bg: #1A2332;
}

[data-theme="light"] {
  --bg: #f8f9fb;
  --elev-1: #ffffff;
  --elev-2: #f2f3f6;
  --text: #181a1f;
  --muted: #5b6270;
  --border: #e3e6ef;
  --link: #d45a10;
  --chip: #f3f5fb;
  --code-bg: #f3f5fb;
}

/* ============================================
   Base Typography
   ============================================ */
html {
  height: 100%;
  scroll-padding-top: 80px;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-weight: 300;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background: var(--bg);
  color: var(--text);
}

* { box-sizing: border-box }
a { color: var(--link); text-decoration: none }
a:hover { color: var(--accent-hover); text-decoration: underline }
strong, b { font-weight: 600; }
em, i { font-style: italic; }

/* ============================================
   Custom Scrollbar
   ============================================ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--elev-1);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}
/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border) var(--elev-1);
}

/* ============================================
   Headings - Orange Accent (scoped for in-app preview)
   ============================================ */
.theme-altuit-toc h1, .theme-altuit-toc h2, .theme-altuit-toc h3,
.theme-altuit-toc h4, .theme-altuit-toc h5, .theme-altuit-toc h6,
h1, h2, h3, h4, h5, h6 {
  font-weight: 500;
  margin-top: 1.2em;
  margin-bottom: 0.5em;
  line-height: 1.1;
  color: var(--accent);
}
.theme-altuit-toc h1, h1 { font-size: 2.5em; border-bottom: 2px solid var(--border); padding-bottom: 0.3em; }
.theme-altuit-toc h2, h2 { font-size: 2em; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
.theme-altuit-toc h3, h3 { font-size: 1.5em; }
.theme-altuit-toc h4, h4 { font-size: 1.25em; color: var(--text); }
.theme-altuit-toc h5, h5 { font-size: 1.1em; color: var(--text); font-weight: 400; }
.theme-altuit-toc h6, h6 { font-size: 1em; color: var(--muted); font-weight: 400; }

/* ============================================
   Header
   ============================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--elev-2);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: calc(var(--content-w) + var(--sidebar-w) + 64px);
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
}
.brand {
  font-size: 18px;
  display: flex;
  align-items: center;
  font-weight: 600;
  color: var(--text);
}
.spacer { flex: 1 }

/* ============================================
   Buttons
   ============================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  font-size: 14px;
  line-height: 1.5;
  font-family: inherit;
}
.btn:hover {
  background: rgba(127,127,127,.12);
  text-decoration: none;
}

/* ============================================
   Layout - Sidebar + Content
   ============================================ */
.layout {
  max-width: calc(var(--content-w) + var(--sidebar-w) + 64px);
  margin: 24px auto;
  padding: 0 16px;
  display: grid;
  gap: 24px;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
}

/* ============================================
   TOC Sidebar
   ============================================ */
nav.toc {
  position: sticky;
  top: 84px;
  align-self: start;
  padding: 16px;
  background: var(--elev-1);
  border: 1px solid var(--border);
  border-radius: 16px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}
.toc h3 {
  margin: 0 0 8px 0;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  border: none;
}
.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.toc > ul > li {
  margin: 4px 0;
}
.toc a {
  color: var(--text);
  text-decoration: none;
  font-size: 14px;
}
.toc a:hover {
  text-decoration: underline;
  color: var(--link);
}

/* TOC Header with Controls */
.toc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.toc-header h3 { margin: 0; }
.toc-controls {
  display: flex;
  gap: 4px;
}
.toc-controls button {
  background: none;
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  padding: 4px 10px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 4px;
  line-height: 1;
  font-family: inherit;
}
.toc-controls button:hover {
  background: var(--border);
  color: var(--text);
}

/* Collapsible TOC Sections */
.toc-section {
  margin: 4px 0;
}
.toc-section-header {
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 4px 0;
}
.toc-section-header:hover {
  color: var(--link);
}
.toc-toggle {
  width: 16px;
  height: 16px;
  margin-right: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--muted);
  transition: transform 0.2s;
}
.toc-section.collapsed .toc-toggle {
  transform: rotate(-90deg);
}
.toc-section-header a {
  flex: 1;
}
.toc-children {
  margin-left: 20px;
  padding: 4px 0 4px 12px;
  border-left: 1px solid var(--border);
  overflow: hidden;
}
.toc-section.collapsed .toc-children {
  display: none;
}
.toc-children li {
  margin: 4px 0;
}
.toc-children a {
  font-size: 13px;
  color: var(--muted);
}
.toc-children a:hover {
  color: var(--link);
}

/* H1 level styling - slightly bolder */
.toc-h1 > .toc-section-header a {
  font-weight: 600;
  font-size: 14px;
}
/* H2 level styling */
.toc-h2 > .toc-section-header a {
  font-weight: 400;
  font-size: 13px;
}

/* ============================================
   Content Card
   ============================================ */
.card {
  background: var(--elev-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

/* Document Content Styling - for browser export (.doc) and in-app preview (.theme-altuit-toc) */
.doc p, .theme-altuit-toc p { margin: 1em 0; font-weight: 300; }
.doc ul, .theme-altuit-toc ul {
  margin: 1em 0;
  padding-left: 2em;
  list-style: disc outside;
}
.doc ol, .theme-altuit-toc ol {
  margin: 1em 0;
  padding-left: 2em;
  list-style: decimal outside;
}
.doc li, .theme-altuit-toc li {
  margin: 0.5em 0;
  display: list-item;
}
.doc img, .theme-altuit-toc img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}
.doc blockquote, .theme-altuit-toc blockquote {
  border-left: 4px solid var(--accent);
  padding-left: 1em;
  color: var(--muted);
  margin: 1em 0;
  font-style: italic;
}
.doc code, .theme-altuit-toc code {
  background: var(--code-bg);
  padding: 0.2em 0.4em;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}
.doc pre, .theme-altuit-toc pre {
  background: var(--code-bg);
  padding: 1em;
  border-radius: 8px;
  overflow-x: auto;
  border: 1px solid var(--border);
}
.doc pre code, .theme-altuit-toc pre code {
  background: none;
  padding: 0;
}
.doc hr, .theme-altuit-toc hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}
.doc mark, .theme-altuit-toc mark {
  background: transparent;
  color: #BFFF00;
}
/* Light theme: red highlight, black headings */
[data-theme="light"] mark,
[data-theme="light"] .doc mark,
[data-theme="light"] .theme-altuit-toc mark {
  color: #CC0000;
}
[data-theme="light"] h1,
[data-theme="light"] h2,
[data-theme="light"] h3,
[data-theme="light"] .theme-altuit-toc h1,
[data-theme="light"] .theme-altuit-toc h2,
[data-theme="light"] .theme-altuit-toc h3 {
  color: #000000;
}

/* Tables */
.doc table, .theme-altuit-toc table {
  border-collapse: collapse;
  width: 100%;
  margin: 1em 0;
  font-size: 0.9em;
  font-weight: 300;
}
.doc th, .doc td, .theme-altuit-toc th, .theme-altuit-toc td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
  color: var(--text);
  font-weight: 300;
}
.doc th, .theme-altuit-toc th {
  background: var(--elev-2);
  font-weight: 400;
}
.doc th img, .doc td img,
.theme-altuit-toc th img, .theme-altuit-toc td img {
  max-width: none;
  width: auto;
  height: auto;
  display: block;
  margin: 12px auto 0 auto;
}

/* YouTube embeds - responsive 16:9 */
.youtube-embed {
  position: relative;
  padding-bottom: 56.25%;
  height: 0;
  margin: 1em 0;
  overflow: hidden;
}
.youtube-embed iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* ============================================
   Responsive - Mobile
   ============================================ */
@media (max-width: 1024px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }
  nav.toc {
    position: relative;
    top: 0;
    margin-bottom: 16px;
  }
}
@media (max-width: 768px) {
  .brand {
    font-size: 16px;
  }
}
