/* ============================================
   AlgoSierra — Documentation Styles
   ============================================ */

.doc-container {
  max-width: 860px;
  margin: 0 auto;
  animation: fadeUp 0.4s ease both;
}

/* ── Doc Header ───────────────────────────── */
.doc-header {
  margin-bottom: 40px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 20px;
  color: var(--text-dim);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  transition: color 0.2s ease;
  letter-spacing: 0.02em;
}

.back-link:hover { color: var(--gold); }

.doc-header h1 {
  font-family: var(--font-serif);
  font-size: 2.4rem;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
  letter-spacing: -0.015em;
  line-height: 1.15;
}

.meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.badge {
  padding: 4px 12px;
  border-radius: 3px;
  font-size: 0.62rem;
  font-family: var(--font-mono);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 5px;
}

.badge::before {
  content: '';
  width: 4px; height: 4px;
  border-radius: 50%;
}

.badge.success {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(39, 201, 138, 0.2);
}
.badge.success::before { background: var(--green); animation: pulse-dot 2s ease-in-out infinite; }

.badge.warning {
  background: var(--amber-dim);
  color: var(--amber);
  border: 1px solid rgba(240, 168, 57, 0.2);
}
.badge.warning::before { background: var(--amber); }

/* ── Doc Layout ───────────────────────────── */
.doc-layout {
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 32px;
  align-items: start;
}

.doc-main { min-width: 0; }

.doc-sidebar {
  position: sticky;
  top: 100px;
}

.sidebar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
}

.sidebar-card-title {
  font-family: var(--font-mono);
  font-size: 0.6rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin-bottom: 14px;
}

.sidebar-toc {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.toc-item {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  padding: 5px 8px;
  border-radius: 3px;
  transition: all 0.2s;
  cursor: pointer;
}

.toc-item:hover {
  color: var(--gold);
  background: var(--gold-trace);
}

/* ── Doc Sections ─────────────────────────── */
.doc-section {
  margin-bottom: 40px;
}

.doc-section h2 {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--gold-dim);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.doc-section h2::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.doc-section h3 {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  font-weight: 600;
  margin: 22px 0 12px;
  color: var(--text);
}

.doc-section p {
  color: var(--text-muted);
  line-height: 1.75;
  font-size: 0.9rem;
}

.doc-section ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.doc-section ul li {
  font-size: 0.875rem;
  color: var(--text-muted);
  padding-left: 18px;
  position: relative;
  line-height: 1.65;
}

.doc-section ul li::before {
  content: '—';
  position: absolute;
  left: 0;
  color: var(--text-dim);
  font-size: 0.68rem;
  top: 2px;
}

/* ── Stats Grid ───────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-top: 14px;
}

.stat-card {
  background: var(--surface);
  padding: 20px 16px;
  text-align: center;
  transition: background 0.2s;
  position: relative;
}

.stat-card:hover { background: var(--surface2); }

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 50%; transform: translateX(-50%);
  width: 30px; height: 2px;
  border-radius: 0 0 2px 2px;
  transition: opacity 0.2s;
  opacity: 0;
}

.stat-card:hover::before { opacity: 1; }
.stat-card.success-card::before { background: var(--green); }

.stat-label {
  display: block;
  color: var(--text-dim);
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-family: var(--font-mono);
  margin-bottom: 8px;
}

.stat-value {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
}

.stat-value.success { color: var(--green); }
.stat-value.warning { color: var(--amber); }
.stat-value.danger  { color: var(--red); }
.stat-value.gold    { color: var(--gold); }

.stat-sub {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--text-dim);
  margin-top: 4px;
}

/* ── Params Table ─────────────────────────── */
.params-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 14px;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.params-table th,
.params-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.params-table thead tr { background: var(--surface2); }

.params-table th {
  color: var(--gold-dim);
  font-weight: 500;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--font-mono);
}

.params-table td {
  background: var(--surface);
  color: var(--text-muted);
}

.params-table tbody tr:last-child td { border-bottom: none; }

.params-table td:first-child {
  color: var(--gold);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 0.82rem;
  width: 180px;
}

.params-table td:nth-child(2) {
  color: var(--blue);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  width: 100px;
}

.params-table tr:hover td { background: var(--surface2); }

/* ── Code Block ───────────────────────────── */
.code-block-wrap {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
}

.code-lang {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--gold-dim);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.code-dots {
  display: flex;
  gap: 5px;
}

.code-dots span {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--border2);
}

pre {
  background: #060a10;
  padding: 24px 20px;
  overflow-x: auto;
  margin: 0;
}

code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #8fa8c8;
  line-height: 1.7;
}

.code-comment  { color: var(--text-dim); font-style: italic; }
.code-keyword  { color: var(--gold); }
.code-function { color: #7ec8e3; }
.code-string   { color: #98c379; }
.code-number   { color: #e06c75; }
.code-type     { color: #c792ea; }

/* Line numbers */
.code-lines {
  display: flex;
}

.code-line-nums {
  flex-shrink: 0;
  padding: 0 12px 0 0;
  text-align: right;
  color: var(--text-dim);
  font-size: 0.75rem;
  line-height: 1.7;
  user-select: none;
  border-right: 1px solid var(--border);
  margin-right: 16px;
}

/* ── Logic Cards ──────────────────────────── */
.logic-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

.logic-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.logic-card-title {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.logic-card.long .logic-card-title { color: var(--green); }
.logic-card.short .logic-card-title { color: var(--red); }

.logic-card.long  { border-top: 2px solid var(--green); }
.logic-card.short { border-top: 2px solid var(--red); }

.logic-card ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.logic-card ul li {
  font-size: 0.84rem;
  color: var(--text-muted);
  padding-left: 14px;
  position: relative;
  line-height: 1.55;
}

.logic-card.long  ul li::before { content: '+'; position: absolute; left: 0; color: var(--green); font-size: 0.78rem; }
.logic-card.short ul li::before { content: '−'; position: absolute; left: 0; color: var(--red);   font-size: 0.78rem; }

/* ── Download Section ─────────────────────── */
.download-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.download-info h3 {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.download-info p {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.btn.download {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--gold);
  border: 1px solid var(--gold);
  color: #07090d;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  transition: all 0.22s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.btn.download:hover {
  background: var(--gold-bright);
  border-color: var(--gold-bright);
  color: #07090d;
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(200, 168, 75, 0.3);
}

.btn.download:disabled {
  background: var(--surface2);
  border-color: var(--border);
  color: var(--text-dim);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ── Responsive Doc ───────────────────────── */
@media (max-width: 900px) {
  .doc-layout {
    grid-template-columns: 1fr;
  }
  .doc-sidebar { display: none; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .logic-grid { grid-template-columns: 1fr; }
  .download-section { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 600px) {
  .doc-header h1 { font-size: 1.8rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  pre { padding: 16px 14px; font-size: 0.74rem; }
}
