/* ============================================
CANDEV.ORG — Docs section stylesheet
Scope: .docs-* only. Loaded on Docs templates.
============================================ */

:root {
  --docs-nav-offset: 92px;
  --docs-code-bg:    #14161a;
  --docs-code-ink:   #e6e6e6;
  --docs-code-dim:   #8b949e;
  --docs-code-key:   #ff9d7a;
  --docs-code-str:   #9ecbff;
}

/* ---- Shell ---- */
.docs {
  padding: 40px 0 96px;
  background: var(--bg);
}

.docs__layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 56px;
  align-items: start;
}

/* ---- Breadcrumbs ---- */
.docs-crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink3);
  margin-bottom: 24px;
}

.docs-crumbs a {
  color: var(--ink3);
  transition: var(--transition);
}

.docs-crumbs a:hover { color: var(--accent); }
.docs-crumbs span[aria-current] { color: var(--ink2); }
.docs-crumbs i { font-style: normal; color: var(--ink4); }

/* ---- Sidebar ---- */
.docs-side {
  position: sticky;
  top: var(--docs-nav-offset);
  max-height: calc(100vh - var(--docs-nav-offset) - 24px);
  overflow-y: auto;
  padding-right: 8px;
}

.docs-side__title {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--ink3);
  margin-bottom: 14px;
}

.docs-toc { list-style: none; }

.docs-toc li { margin: 0; }

.docs-toc a {
  display: block;
  padding: 6px 12px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--ink2);
  border-left: 2px solid var(--border);
  transition: var(--transition);
}

.docs-toc a:hover {
  color: var(--ink);
  border-left-color: var(--border2);
  background: var(--bg2);
}

.docs-toc a.is-active {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 500;
}

.docs-side__group + .docs-side__group {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

/* ---- Version switcher ---- */
.docs-versions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.docs-versions a {
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink2);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: var(--transition);
}

.docs-versions a:hover {
  color: var(--ink);
  border-color: var(--border2);
}

.docs-versions a.is-active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

.docs-side__langs a {
  display: inline-block;
  margin: 0 6px 6px 0;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.docs-side__langs a:hover { border-color: var(--border2); color: var(--ink); }

.docs-side__langs a.is-active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

/* ---- Mobile TOC toggle ---- */
.docs-toc-toggle {
  display: none;
  width: 100%;
  padding: 12px 16px;
  margin-bottom: 20px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  color: var(--ink);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.docs-toc-toggle::after {
  content: '▾';
  float: right;
  color: var(--ink3);
}

.docs-toc-toggle[aria-expanded="true"]::after { content: '▴'; }

/* ---- Article header ---- */
.docs-head { margin-bottom: 44px; }

.docs-head h1 {
  font-size: clamp(30px, 4vw, 44px);
  margin-bottom: 16px;
}

.docs-head__lead {
  font-size: 17px;
  line-height: 1.7;
  color: var(--ink2);
  max-width: 68ch;
}

.docs-head__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.docs-badge {
  display: inline-block;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--green-dark);
  background: var(--green-light);
  border: 1px solid var(--green-border);
  border-radius: 999px;
}

.docs-badge--muted {
  color: var(--ink2);
  background: var(--bg2);
  border-color: var(--border);
}

/* ---- Article body ---- */
.docs-article { max-width: 82ch; }

.docs-section {
  padding-top: 28px;
  margin-bottom: 44px;
  scroll-margin-top: calc(var(--docs-nav-offset) + 12px);
}

.docs-section + .docs-section { border-top: 1px solid var(--border); }

.docs-section > h2 {
  font-size: clamp(22px, 2.6vw, 30px);
  margin-bottom: 18px;
}

.docs-section h3 {
  font-size: 19px;
  margin: 30px 0 12px;
}

.docs-section h4 {
  font-size: 15px;
  margin: 22px 0 10px;
  color: var(--ink);
}

.docs-section p { margin-bottom: 14px; }

/* reset.css strips list markers globally — restore them inside the article. */
.docs-section ul,
.docs-section ol {
  margin: 0 0 16px 22px;
  padding-left: 4px;
  color: var(--ink2);
}

.docs-section ul { list-style: disc outside; }
.docs-section ol { list-style: decimal outside; }
.docs-section li::marker { color: var(--ink4); }

.docs-section li { margin-bottom: 7px; line-height: 1.65; }

.docs-section a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Card links are blocks, not inline links — keep them unstyled. */
.docs-section a.docs-card,
.docs-section a.docs-card:hover {
  color: inherit;
  text-decoration: none;
}

.docs-section strong { color: var(--ink); font-weight: 600; }

.docs-section :not(pre) > code {
  padding: 2px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  color: #b4351a;
  background: var(--bg3);
  border-radius: 4px;
  word-break: break-word;
}

/* ---- Code blocks ---- */
.docs-code {
  position: relative;
  margin: 0 0 20px;
  background: var(--docs-code-bg);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.docs-code__label {
  display: block;
  padding: 8px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--docs-code-dim);
  background: rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.docs-code pre {
  margin: 0;
  padding: 16px 18px;
  overflow-x: auto;
}

.docs-code code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.7;
  color: var(--docs-code-ink);
  white-space: pre;
  tab-size: 4;
}

.docs-copy {
  position: absolute;
  top: 6px;
  right: 8px;
  padding: 4px 10px;
  font-family: var(--font-body);
  font-size: 11px;
  color: var(--docs-code-dim);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  cursor: pointer;
  opacity: 0;
  transition: var(--transition);
}

.docs-code:hover .docs-copy,
.docs-copy:focus-visible { opacity: 1; }

.docs-copy:hover { color: #fff; background: rgba(255, 255, 255, 0.14); }
.docs-copy.is-done { color: var(--green-border); }

/* ---- Callouts ---- */
.docs-note {
  padding: 14px 18px;
  margin: 0 0 20px;
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink2);
  background: var(--bg2);
  border-left: 3px solid var(--border2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.docs-note strong { color: var(--ink); }
.docs-note :last-child { margin-bottom: 0; }

.docs-note--tip {
  background: var(--green-light);
  border-left-color: var(--green-mid);
  color: var(--green-dark);
}

.docs-note--warn {
  background: #fff1ec;
  border-left-color: var(--accent);
  color: #7a1f0a;
}

/* ---- Tables ---- */
.docs-table-wrap {
  margin: 0 0 20px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.docs-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.docs-table th,
.docs-table td {
  padding: 10px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
}

.docs-table th {
  font-weight: 600;
  color: var(--ink);
  background: var(--bg2);
  white-space: nowrap;
}

.docs-table td { color: var(--ink2); }
.docs-table tr:last-child td { border-bottom: 0; }

.docs-table code {
  white-space: nowrap;
}

/* ---- Hub cards ---- */
.docs-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
  margin-bottom: 32px;
}

.docs-card {
  display: block;
  padding: 22px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: var(--transition);
}

.docs-card:hover {
  border-color: var(--border2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.05);
  transform: translateY(-2px);
}

.docs-card__kicker {
  display: block;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--ink3);
  margin-bottom: 10px;
}

.docs-card__title {
  font-family: var(--font-head);
  font-size: 19px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 8px;
}

.docs-card__desc {
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink2);
}

.docs-card--soon {
  opacity: 0.55;
  pointer-events: none;
}

/* ---- Prev/next footer ---- */
.docs-pager {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding-top: 28px;
  margin-top: 8px;
  border-top: 1px solid var(--border);
}

.docs-pager a {
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.docs-pager a:hover { border-color: var(--ink); }

/* ---- Back to top ---- */
.docs-top {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 42px;
  height: 42px;
  font-size: 16px;
  color: #fff;
  background: var(--ink);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
  z-index: 90;
}

.docs-top.is-visible { opacity: 1; visibility: visible; }
.docs-top:hover { background: var(--accent); }

/* ---- Responsive ---- */
@media (max-width: 1024px) {
  .docs__layout { grid-template-columns: 220px minmax(0, 1fr); gap: 36px; }
}

@media (max-width: 860px) {
  .docs { padding: 28px 0 72px; }
  .docs__layout { display: block; }
  .docs-toc-toggle { display: block; }

  .docs-side {
    position: static;
    max-height: none;
    overflow: visible;
    padding: 0 0 24px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
  }

  .docs-side[hidden] { display: none; }
  .docs-article { max-width: none; }
}

@media print {
  .docs-side,
  .docs-toc-toggle,
  .docs-copy,
  .docs-top,
  .docs-pager { display: none !important; }

  .docs-code { background: #f4f4f4; }
  .docs-code code { color: #111; }
}
