/*
 * Copyright (c) 2024-2026 Luca Vitiello. All rights reserved.
 * SPDX-License-Identifier: LicenseRef-Proprietary
 */

/* ═══════════════════════════════════════════════════════════════════════
   Dousen Docs — Layout & typography
   Extends main.css
═══════════════════════════════════════════════════════════════════════ */

/* ── Docs layout ──────────────────────────────────────────────────────── */
.docs-layout {
  display: flex;
  min-height: 100vh;
  padding-top: 64px; /* nav height */
}

/* ── Sidebar ──────────────────────────────────────────────────────────── */
.docs-sidebar {
  width: 256px;
  flex-shrink: 0;
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  overflow-y: auto;
  border-right: 1px solid var(--border-1);
  padding: 2rem 0 4rem;
  background: var(--bg);
}

.docs-sidebar::-webkit-scrollbar { width: 4px; }
.docs-sidebar::-webkit-scrollbar-track { background: transparent; }
.docs-sidebar::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }

.sidebar-group {
  margin-bottom: 2rem;
  padding: 0 1.25rem;
}

.sidebar-group-label {
  font-family: var(--f-dis);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 0.5rem;
  padding-left: 0.5rem;
}

.sidebar-link {
  display: block;
  padding: 0.4rem 0.5rem;
  font-size: 0.875rem;
  font-weight: 400;
  color: var(--text-2);
  border-radius: 4px;
  transition: color 0.12s, background 0.12s;
  line-height: 1.4;
}

.sidebar-link:hover {
  color: var(--text-1);
  background: rgba(255,255,255,0.04);
}

.sidebar-link.active {
  color: var(--blue-hi);
  background: var(--blue-lo);
  font-weight: 500;
}

/* ── Docs content ─────────────────────────────────────────────────────── */
.docs-content {
  flex: 1;
  min-width: 0;
  padding: 3.5rem 3.5rem 6rem;
  max-width: 780px;
}

/* ── Typography ───────────────────────────────────────────────────────── */
.docs-content h1 {
  font-family: var(--f-dis);
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-1);
  line-height: 1.1;
  margin-bottom: 1rem;
}

.docs-content .doc-meta {
  font-size: 0.85rem;
  color: var(--text-3);
  margin-bottom: 2.5rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--border-1);
}

.docs-content h2 {
  font-family: var(--f-dis);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-1);
  letter-spacing: -0.01em;
  margin: 3rem 0 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-1);
  scroll-margin-top: 80px;
}

.docs-content h2:first-of-type { border-top: none; margin-top: 0; }

.docs-content h3 {
  font-family: var(--f-dis);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-1);
  margin: 2rem 0 0.75rem;
  scroll-margin-top: 80px;
}

.docs-content p {
  font-size: 0.95rem;
  color: var(--text-2);
  line-height: 1.8;
  margin-bottom: 1.25rem;
}

.docs-content a {
  color: var(--blue-hi);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border-3);
  transition: color 0.12s, text-decoration-color 0.12s;
}

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

.docs-content ul, .docs-content ol {
  padding-left: 1.5rem;
  margin-bottom: 1.25rem;
}

.docs-content li {
  font-size: 0.95rem;
  color: var(--text-2);
  line-height: 1.8;
  margin-bottom: 0.25rem;
}

.docs-content strong { color: var(--text-1); font-weight: 600; }

/* ── Code ─────────────────────────────────────────────────────────────── */
.docs-content code {
  font-family: var(--f-mon);
  font-size: 0.82rem;
  background: var(--surface-2);
  border: 1px solid var(--border-1);
  border-radius: 4px;
  padding: 0.15rem 0.45rem;
  color: var(--blue-hi);
}

.docs-content pre {
  background: var(--surface-1);
  border: 1px solid var(--border-1);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  position: relative;
}

.docs-content pre code {
  font-size: 0.83rem;
  background: none;
  border: none;
  padding: 0;
  color: var(--text-1);
  line-height: 1.7;
}

.pre-label {
  position: absolute;
  top: 0.6rem;
  right: 0.875rem;
  font-family: var(--f-dis);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
}

/* ── Callout boxes ────────────────────────────────────────────────────── */
.callout {
  border-left: 3px solid;
  border-radius: 0 6px 6px 0;
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  font-size: 0.9rem;
  line-height: 1.7;
}

.callout p { margin-bottom: 0; font-size: inherit; }

.callout-info  { border-color: var(--blue); background: var(--blue-lo); color: var(--text-2); }
.callout-warn  { border-color: var(--amber); background: rgba(240,184,48,0.08); color: var(--text-2); }
.callout-tip   { border-color: var(--green); background: rgba(32,201,110,0.08); color: var(--text-2); }

.callout strong { color: var(--text-1); }

/* ── Port / API table ─────────────────────────────────────────────────── */
.docs-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.875rem;
}

.docs-content th {
  text-align: left;
  font-family: var(--f-dis);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 0.6rem 0.875rem;
  border-bottom: 1px solid var(--border-2);
  background: var(--surface-1);
}

.docs-content td {
  padding: 0.65rem 0.875rem;
  border-bottom: 1px solid var(--border-1);
  color: var(--text-2);
  vertical-align: top;
}

.docs-content td:first-child { font-family: var(--f-mon); font-size: 0.8rem; color: var(--blue-hi); }

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

/* ── Step list ────────────────────────────────────────────────────────── */
.doc-steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
  margin: 1.5rem 0;
}

.doc-steps li {
  counter-increment: step;
  position: relative;
  padding: 1.25rem 0 1.25rem 44px;
  border-bottom: 1px solid var(--border-1);
  color: var(--text-2);
  font-size: 0.95rem;
  line-height: 1.7;
  margin-bottom: 0;
}

.doc-steps li:last-child { border-bottom: none; }

.doc-steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: 1.5rem;
  font-family: var(--f-dis);
  font-size: 0.65rem;
  font-weight: 800;
  color: var(--blue);
  min-width: 24px;
}

.doc-steps li p { margin-bottom: 0.5rem; }
.doc-steps li p:last-child { margin-bottom: 0; }

/* ── Doc cards (overview grid) ────────────────────────────────────────── */
.doc-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--border-1);
  border: 1px solid var(--border-1);
  border-radius: 10px;
  overflow: hidden;
  margin: 1.5rem 0 3rem;
}

.doc-card {
  background: var(--bg);
  padding: 1.5rem;
  transition: background 0.15s;
}

.doc-card:hover { background: var(--surface-1); }

.doc-card-icon {
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
}

.doc-card h3 {
  font-family: var(--f-dis);
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-1);
  margin: 0 0 0.4rem;
}

.doc-card p {
  font-size: 0.83rem;
  color: var(--text-2);
  line-height: 1.6;
  margin: 0;
}

.doc-card a.card-link {
  display: block;
  margin-top: 0.875rem;
  font-size: 0.82rem;
  color: var(--blue);
  text-decoration: none;
  font-weight: 600;
}

.doc-card a.card-link:hover { color: var(--blue-hi); }

/* ── Page nav (prev/next) ─────────────────────────────────────────────── */
.doc-page-nav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-1);
}

.doc-page-link {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border-1);
  border-radius: 8px;
  transition: border-color 0.12s, background 0.12s;
  flex: 1;
  max-width: 240px;
}

.doc-page-link:hover {
  border-color: var(--border-3);
  background: var(--surface-1);
}

.doc-page-link.next { text-align: right; margin-left: auto; }

.doc-page-label {
  font-family: var(--f-dis);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
}

.doc-page-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--blue-hi);
}

/* ── On-page TOC (right column, optional) ─────────────────────────────── */
.docs-toc {
  width: 200px;
  flex-shrink: 0;
  position: sticky;
  top: 64px;
  height: calc(100vh - 64px);
  overflow-y: auto;
  padding: 2.5rem 1.25rem 4rem;
  display: none;
}

@media (min-width: 1300px) {
  .docs-toc { display: block; }
}

.toc-label {
  font-family: var(--f-dis);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 0.75rem;
}

.toc-link {
  display: block;
  font-size: 0.8rem;
  color: var(--text-3);
  padding: 0.3rem 0;
  border-left: 2px solid transparent;
  padding-left: 0.75rem;
  transition: color 0.12s, border-color 0.12s;
  line-height: 1.4;
}

.toc-link:hover, .toc-link.active {
  color: var(--text-2);
  border-left-color: var(--blue);
}

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .docs-sidebar { display: none; }
  .docs-content { padding: 2rem 1.25rem 4rem; }
  .doc-cards { grid-template-columns: 1fr; }
  .doc-page-nav { flex-direction: column; }
  .doc-page-link { max-width: 100%; }
}
