/* ==========================================================================
   Susano docs + guides - page-level styles layered on susano.css.
   1. Markdown components shared by every rendered page (.cb-*)
   2. highlight.js token colours (Susano palette)
   3. Documentation shell (sidebar / content / TOC)
   4. Guides (cards, article, staff editor)
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Markdown components
   -------------------------------------------------------------------------- */
code.cb-inline { font-size: 0.82em; padding: 2px 6px; border-radius: 5px; background: rgba(255, 255, 255, 0.06); border: 1px solid var(--border); color: var(--accent-3); font-weight: 500; white-space: nowrap; }
pre.cb-code { position: relative; margin: var(--s-4) 0; border: 1px solid var(--border-strong); border-radius: 12px; background: #121218; overflow: hidden; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03); }
pre.cb-code code { display: block; padding: var(--s-4) var(--s-5); font-size: 0.8rem; line-height: 1.65; overflow-x: auto; white-space: pre; color: #e3e3e8; background: transparent; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
pre.cb-code[data-lang]::before { content: attr(data-lang); position: absolute; top: 9px; left: 14px; font-family: var(--mono); font-size: 0.6rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-muted); pointer-events: none; }
pre.cb-code[data-lang] code { padding-top: var(--s-7); }
.cb-copy { position: absolute; top: 8px; right: 8px; z-index: 1; width: 28px; height: 28px; border-radius: 7px; border: 1px solid var(--border); background: rgba(18, 18, 24, 0.9); color: var(--text-dim); display: inline-flex; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.2s, background 0.2s, color 0.2s, border-color 0.2s; }
.cb-copy svg { width: 13px; height: 13px; }
pre.cb-code:hover .cb-copy, .cb-copy:focus-visible { opacity: 1; }
.cb-copy:hover { background: rgba(255, 255, 255, 0.1); color: #fff; border-color: var(--border-strong); }
.cb-copy.copied { opacity: 1; background: var(--success-soft); color: var(--success); border-color: rgba(34, 211, 138, 0.35); }
@media (hover: none) { .cb-copy { opacity: 1; } }

.cb-hint { padding: var(--s-4) var(--s-5); margin: var(--s-4) 0; border-radius: 12px; border: 1px solid; font-size: var(--fs-sm); line-height: 1.75; }
.cb-hint > :first-child { margin-top: 0; }
.cb-hint > :last-child { margin-bottom: 0; }
.cb-hint p { margin: 0 0 var(--s-3); color: #d4d4da; }
.cb-hint p:last-child { margin-bottom: 0; }
.cb-hint h4 { margin: 0 0 var(--s-2); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; }
.cb-hint ul, .cb-hint ol { margin: var(--s-2) 0 var(--s-3) var(--s-5); }
.cb-hint pre.cb-code { margin: var(--s-3) 0; }
.cb-hint-info { background: var(--accent-soft); border-color: var(--border-accent); }
.cb-hint-info h4 { color: var(--accent); }
.cb-hint-success { background: var(--success-soft); border-color: rgba(34, 211, 138, 0.3); }
.cb-hint-success h4 { color: var(--success); }
.cb-hint-warning { background: var(--warning-soft); border-color: rgba(255, 176, 32, 0.3); }
.cb-hint-warning h4 { color: var(--warning); }
.cb-hint-danger { background: var(--danger-soft); border-color: rgba(255, 90, 90, 0.3); }
.cb-hint-danger h4 { color: var(--danger); }

.cb-table { overflow-x: auto; margin: var(--s-4) 0; border: 1px solid var(--border); border-radius: 12px; -webkit-overflow-scrolling: touch; }
.prose .cb-table table { margin: 0; }
.prose .cb-table th, .prose .cb-table td { border: 0; border-bottom: 1px solid var(--border); }
.prose .cb-table tr:last-child td { border-bottom: 0; }
.prose .cb-table tbody tr:hover td { background: rgba(255, 255, 255, 0.02); }
.ta-c { text-align: center !important; }
.ta-r { text-align: right !important; }
.prose ul ul, .prose ol ol, .prose ul ol, .prose ol ul { margin: 6px 0 0 var(--s-5); }
.prose li > p { margin: 0; }
.prose del { color: var(--text-muted); }
.prose hr { margin: var(--s-7) 0; }
.prose h4 { font-size: var(--fs-sm); color: #d9d9df; margin: var(--s-5) 0 var(--s-2); }
.prose .cb-task { margin-right: 6px; accent-color: var(--accent); vertical-align: -1px; }
.prose img { max-width: 100%; }

/* --------------------------------------------------------------------------
   2. highlight.js - Susano palette
   -------------------------------------------------------------------------- */
.hljs { color: #e3e3e8; }
.hljs-comment, .hljs-quote { color: #6f6f7c; font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-name { color: #ff8f62; }
.hljs-string, .hljs-addition, .hljs-regexp { color: #8ee3b5; }
.hljs-number, .hljs-symbol, .hljs-bullet { color: #ffb48a; }
.hljs-built_in, .hljs-title, .hljs-title.function_, .hljs-title.class_, .hljs-section { color: #7cc2ff; }
.hljs-attr, .hljs-property, .hljs-variable, .hljs-params { color: #d6d6de; }
.hljs-operator, .hljs-punctuation { color: #9a9aa4; }
.hljs-meta, .hljs-type { color: #c792ea; }
.hljs-deletion { color: var(--danger); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }

/* --------------------------------------------------------------------------
   3. Documentation shell
   -------------------------------------------------------------------------- */
.docs-page .site-footer { margin-top: 0; }
.docs-shell { --docs-side: 280px; --docs-toc: 220px; display: grid; grid-template-columns: var(--docs-side) minmax(0, 1fr) var(--docs-toc); gap: var(--s-8); width: 100%; max-width: 1440px; margin: 0 auto; padding: 0 var(--s-6); }

/* Sidebar */
.docs-sidebar { position: sticky; top: var(--header-h); align-self: start; max-height: calc(100vh - var(--header-h)); overflow-y: auto; padding: var(--s-6) var(--s-3) var(--s-9) 0; scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.12) transparent; scrollbar-gutter: stable; }
.docs-sidebar::-webkit-scrollbar { width: 6px; }
.docs-sidebar::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.1); border-radius: 3px; }
.docs-sidebar-top { display: flex; align-items: center; gap: var(--s-2); margin-bottom: var(--s-5); }
.docs-search { position: relative; flex: 1; min-width: 0; }
.docs-search svg { position: absolute; left: 12px; top: 50%; width: 14px; height: 14px; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }
.docs-search input { width: 100%; padding: 10px 52px 10px 36px; border-radius: 10px; background: rgba(255, 255, 255, 0.035); border: 1px solid var(--border-strong); color: #fff; font-size: var(--fs-sm); outline: none; transition: border-color 0.2s, box-shadow 0.2s; }
.docs-search input::placeholder { color: var(--text-muted); }
.docs-search input:focus { border-color: var(--accent); box-shadow: var(--ring); }
.docs-search input::-webkit-search-cancel-button { -webkit-appearance: none; }
.docs-search .kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.docs-close { display: none; width: 38px; height: 38px; flex-shrink: 0; border-radius: 10px; border: 1px solid var(--border); color: #fff; font-size: 1.4rem; line-height: 1; align-items: center; justify-content: center; }
.docs-nav { display: flex; flex-direction: column; }
.docs-section { margin-bottom: 2px; }
.docs-section-head { display: flex; align-items: center; gap: 2px; }
.docs-section-title { flex: 1; min-width: 0; display: block; padding: 7px 10px; border-radius: 8px; font-size: 0.66rem; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; color: #d9d9df; transition: color 0.15s, background 0.15s; }
.docs-section-title:hover { color: var(--accent); background: var(--panel-2); }
.docs-section-title.active { color: var(--accent); background: var(--accent-soft); }
.docs-toggle { width: 26px; height: 26px; flex-shrink: 0; border-radius: 7px; color: var(--text-muted); display: inline-flex; align-items: center; justify-content: center; transition: color 0.15s, background 0.15s; }
.docs-toggle:hover { color: #fff; background: var(--panel-2); }
.docs-toggle svg { width: 12px; height: 12px; transition: transform 0.25s var(--ease); }
.docs-section.collapsed .docs-toggle svg { transform: rotate(-90deg); }
.docs-section.collapsed .docs-list { display: none; }
.docs-list { display: flex; flex-direction: column; gap: 1px; margin: 2px 0 var(--s-3) 12px; padding-left: 10px; border-left: 1px solid var(--border); }
.docs-list a { display: block; padding: 5px 10px; border-radius: 7px; font-family: var(--mono); font-size: 0.74rem; color: var(--text-dim); letter-spacing: -0.01em; transition: color 0.15s, background 0.15s; }
.docs-list a:hover { color: #fff; background: var(--panel-2); }
.docs-list a.active { color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.docs-group-label { padding: var(--s-4) 10px var(--s-2); font-size: 0.58rem; font-weight: 800; letter-spacing: 0.24em; text-transform: uppercase; color: var(--text-muted); }
.docs-group-label a { color: inherit; }
.docs-group-label a:hover, .docs-group-label a.active { color: var(--accent); }
.docs-empty { padding: var(--s-4) 10px; font-size: var(--fs-sm); color: var(--text-muted); }
.docs-backdrop { display: none; }

/* Content column */
.docs-content { min-width: 0; padding: var(--s-6) 0 var(--s-11); transition: opacity 0.15s; }
.docs-content.is-loading { opacity: 0.55; pointer-events: none; }
.docs-topbar { display: flex; align-items: center; gap: var(--s-3); min-height: 36px; margin-bottom: var(--s-5); }
.docs-menu-btn { display: none; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--panel-2); color: #fff; font-size: var(--fs-xs); font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.docs-menu-btn svg { width: 16px; height: 16px; }
.docs-crumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.04em; color: var(--text-muted); }
.docs-crumbs a { color: var(--text-dim); }
.docs-crumbs a:hover { color: var(--accent); }
.docs-crumbs .sep { opacity: 0.4; }
.docs-crumbs .current { color: #fff; }
.docs-prose { max-width: 780px; }
.docs-prose h1 { font-size: clamp(1.9rem, 3.4vw, 2.5rem); letter-spacing: -0.03em; margin-bottom: var(--s-5); padding-bottom: var(--s-4); border-bottom: 1px solid var(--border); }
.docs-prose h2 { display: flex; align-items: center; gap: 10px; }
.docs-prose h2::before { content: ""; width: 3px; height: 16px; flex-shrink: 0; background: var(--accent-grad); border-radius: 2px; }
.docs-prose h1, .docs-prose h2, .docs-prose h3, .docs-prose h4 { scroll-margin-top: calc(var(--header-h) + 20px); }
.docs-prose p { color: #d4d4da; font-size: var(--fs-md); }
.docs-prose ul, .docs-prose ol { font-size: var(--fs-md); }

/* Prev / next */
.docs-pagenav { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); max-width: 780px; margin-top: var(--s-10); padding-top: var(--s-6); border-top: 1px solid var(--border); }
.docs-pagenav[hidden] { display: none; }
.docs-pagenav a { display: flex; flex-direction: column; gap: 4px; padding: var(--s-4) var(--s-5); border: 1px solid var(--border); border-radius: 14px; background: var(--panel); color: var(--text-dim); transition: border-color 0.2s, background 0.2s, transform 0.2s var(--ease); }
.docs-pagenav a:hover { border-color: var(--border-accent); background: var(--accent-soft); transform: translateY(-2px); }
.docs-pagenav .label { font-size: 0.6rem; font-weight: 800; letter-spacing: 0.18em; text-transform: uppercase; color: var(--accent); }
.docs-pagenav .title { font-size: var(--fs-sm); font-weight: 700; color: #fff; }
.docs-pagenav .prev { grid-column: 1; }
.docs-pagenav .next { grid-column: 2; text-align: right; align-items: flex-end; }

/* Table of contents */
.docs-toc { position: sticky; top: var(--header-h); align-self: start; max-height: calc(100vh - var(--header-h)); overflow-y: auto; padding: var(--s-6) 0 var(--s-9); scrollbar-width: thin; }
.docs-toc .toc-title { font-size: 0.6rem; font-weight: 800; letter-spacing: 0.2em; text-transform: uppercase; color: var(--text-muted); margin-bottom: var(--s-3); }
.docs-toc ul { list-style: none; border-left: 1px solid var(--border); }
.docs-toc a { display: block; padding: 5px 12px; margin-left: -1px; border-left: 2px solid transparent; font-size: var(--fs-xs); color: var(--text-dim); transition: color 0.15s, border-color 0.15s; }
.docs-toc a:hover { color: #fff; }
.docs-toc a.active { color: var(--accent); border-left-color: var(--accent); }
.docs-toc li.h3 a { padding-left: 24px; }

/* --------------------------------------------------------------------------
   4. Guides
   -------------------------------------------------------------------------- */
.guides-list { padding-bottom: var(--s-10); }
.guide-card { display: flex; flex-direction: column; overflow: hidden; }
.guide-card-media { display: block; aspect-ratio: 16 / 9; overflow: hidden; background: var(--panel-2); border-bottom: 1px solid var(--border); }
.guide-card-media img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s var(--ease); }
.guide-card:hover .guide-card-media img { transform: scale(1.04); }
.guide-card-body { display: flex; flex-direction: column; flex: 1; padding: var(--s-6); }
.guide-card-date { font-size: 0.64rem; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; color: var(--accent); margin-bottom: var(--s-3); }
.guide-card .card-title a { color: #fff; }
.guide-card .card-title a:hover { color: var(--accent); }
.guide-card .card-desc { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.guide-article { padding: var(--s-7) var(--s-6) var(--s-10); }
.guide-back { margin-bottom: var(--s-6); }
.guide-head { margin-bottom: var(--s-7); }
.guide-head .eyebrow { margin-bottom: var(--s-4); }
.guide-head h1 { font-size: clamp(2rem, 4.5vw, 3rem); margin-bottom: var(--s-4); }
.guide-head .lead { max-width: 640px; }
.guide-meta { display: flex; flex-wrap: wrap; gap: var(--s-3) var(--s-6); margin-top: var(--s-5); font-size: var(--fs-xs); font-weight: 600; letter-spacing: 0.04em; color: var(--text-muted); }
.guide-meta span { display: inline-flex; align-items: center; gap: 8px; }
.guide-meta svg { width: 14px; height: 14px; color: var(--accent); }
.guide-hero { margin: 0 0 var(--s-8); aspect-ratio: 16 / 9; overflow: hidden; border-radius: var(--radius-lg); border: 1px solid var(--border-strong); background: var(--panel-2); box-shadow: var(--shadow); }
.guide-hero img { width: 100%; height: 100%; object-fit: cover; }
.guide-prose { max-width: none; }
.guide-prose p { font-size: var(--fs-md); color: #d4d4da; }
.guide-prose ul, .guide-prose ol { font-size: var(--fs-md); }
.guide-prose img { margin: var(--s-6) 0; box-shadow: var(--shadow); }
.guide-footer { display: flex; align-items: center; justify-content: space-between; gap: var(--s-6); flex-wrap: wrap; margin-top: var(--s-10); }
.guide-footer h2 { margin-bottom: var(--s-2); }
.guide-footer .card-desc { max-width: 420px; }

/* Staff editor */
.guide-errors { margin: 6px 0 0 var(--s-5); display: flex; flex-direction: column; gap: 2px; }
.guide-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s-6); align-items: start; }
.guide-textarea { min-height: 420px; font-size: var(--fs-sm); line-height: 1.6; tab-size: 4; }
.guide-preview-card { position: sticky; top: var(--s-6); max-height: calc(100vh - var(--s-9)); display: flex; flex-direction: column; overflow: hidden; }
.guide-preview-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-4) var(--s-6); border-bottom: 1px solid var(--border); }
.guide-preview-body { padding: var(--s-6); overflow-y: auto; min-height: 320px; scrollbar-width: thin; }
.guide-preview-hero { margin-bottom: var(--s-5); border-radius: var(--radius); box-shadow: none; }
.guide-preview-title { font-size: var(--fs-xl); margin-bottom: var(--s-4); }
.guide-preview-body .prose p:first-child { margin-top: 0; }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1200px) {
  .docs-shell { grid-template-columns: var(--docs-side) minmax(0, 1fr); }
  .docs-toc { display: none; }
}
@media (max-width: 1100px) {
  .guide-editor { grid-template-columns: 1fr; }
  .guide-preview-card { position: static; max-height: none; }
}
@media (max-width: 960px) {
  .docs-shell { grid-template-columns: 1fr; gap: 0; padding: 0 var(--s-4); }
  /* The drawer sits below the sticky site header (which paints above <main>'s stacking context) */
  .docs-sidebar { position: fixed; top: var(--header-h); left: 0; bottom: 0; z-index: 700; width: min(330px, 88vw); max-height: none; padding: var(--s-5) var(--s-4) var(--s-8); background: var(--panel-solid); border-right: 1px solid var(--border); transform: translateX(-100%); transition: transform 0.3s var(--ease); box-shadow: 30px 0 60px rgba(0, 0, 0, 0.55); }
  .docs-sidebar.open { transform: none; }
  .docs-close { display: inline-flex; }
  .docs-backdrop { display: block; position: fixed; inset: var(--header-h) 0 0 0; z-index: 690; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
  .docs-backdrop[hidden] { display: none; }
  .docs-menu-btn { display: inline-flex; }
  .docs-content { padding: var(--s-5) 0 var(--s-10); }
  .docs-pagenav { grid-template-columns: 1fr; }
  .docs-pagenav .prev, .docs-pagenav .next { grid-column: auto; }
  pre.cb-code code { font-size: 0.76rem; }
}
@media (max-width: 768px) {
  .guide-article { padding: var(--s-5) var(--s-4) var(--s-9); }
  .guide-hero { border-radius: var(--radius); }
  .guide-footer .cluster { width: 100%; }
  .guide-footer .cluster .btn { flex: 1; }
}
