/* ============================================
   Wiki Layout — Reading-optimized stylesheet
   Uses with: sidebar + main content area
   ============================================ */

/* --- Layout Skeleton --- */
.wiki-wrapper {
  display: flex;
  min-height: calc(100vh - 80px); /* subtract header */
}

/* --- Sidebar --- */
.wiki-sidebar {
  width: 260px;
  flex-shrink: 0;
  background: #f8f9fa;
  border-right: 1px solid #e5e7eb;
  position: sticky;
  top: 64px; /* header height */
  height: calc(100vh - 64px);
  overflow-y: auto;
  padding: 24px 0;
  font-size: 14px;
  z-index: 40;
}

/* Sidebar scrollbar */
.wiki-sidebar::-webkit-scrollbar {
  width: 4px;
}
.wiki-sidebar::-webkit-scrollbar-track {
  background: transparent;
}
.wiki-sidebar::-webkit-scrollbar-thumb {
  background: #d1d5db;
  border-radius: 2px;
}

/* Category group */
.wiki-sidebar-category {
  margin-bottom: 8px;
}

.wiki-sidebar-category-title {
  padding: 8px 20px 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
}

/* Category items */
.wiki-sidebar-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.wiki-sidebar-list li a {
  display: block;
  padding: 7px 20px 7px 28px;
  color: #4b5563;
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all 0.15s ease;
  font-size: 14px;
  line-height: 1.4;
}

.wiki-sidebar-list li a:hover {
  background: #eef2ff;
  color: #2563eb;
}

.wiki-sidebar-list li a.active {
  color: #2563eb;
  font-weight: 600;
  border-left-color: #2563eb;
  background: #eff6ff;
}

.wiki-sidebar-list li a.coming-soon {
  color: #d1d5db;
  cursor: default;
}
.wiki-sidebar-list li a.coming-soon:hover {
  background: transparent;
  color: #d1d5db;
}

/* --- Main Content --- */
.wiki-main {
  flex: 1;
  min-width: 0; /* prevent overflow */
  max-width: 860px;
  padding: 32px 40px 64px;
}

/* Breadcrumb */
.wiki-breadcrumb {
  font-size: 13px;
  color: #9ca3af;
  margin-bottom: 24px;
}
.wiki-breadcrumb a {
  color: #6b7280;
  text-decoration: none;
}
.wiki-breadcrumb a:hover {
  color: #2563eb;
}

/* Page title */
.wiki-title {
  font-size: 32px;
  font-weight: 800;
  color: #111827;
  line-height: 1.3;
  margin-bottom: 8px;
  padding-bottom: 16px;
  border-bottom: 2px solid #2563eb;
}

/* Page description */
.wiki-desc {
  font-size: 16px;
  color: #6b7280;
  margin-bottom: 32px;
  line-height: 1.6;
}

/* Section heading */
.wiki-h2 {
  font-size: 22px;
  font-weight: 700;
  color: #111827;
  margin-top: 40px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e5e7eb;
}

.wiki-h3 {
  font-size: 18px;
  font-weight: 600;
  color: #1f2937;
  margin-top: 28px;
  margin-bottom: 12px;
}

/* Body text */
.wiki-p {
  font-size: 15px;
  color: #374151;
  line-height: 1.75;
  margin-bottom: 16px;
}

/* --- Auto-style bare h2/h3 inside .wiki-main --- */
.wiki-main h2 {
  font-size: 22px;
  font-weight: 700;
  color: #111827;
  margin-top: 40px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e5e7eb;
}

.wiki-main h3 {
  font-size: 18px;
  font-weight: 600;
  color: #1f2937;
  margin-top: 28px;
  margin-bottom: 12px;
}

/* --- Data Tables --- */
.wiki-table-wrap {
  overflow-x: auto;
  margin: 20px 0 28px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.wiki-table {
  width: 100%;
  font-size: 13px;
  border-collapse: collapse;
  text-align: left;
}

.wiki-table thead {
  background: #f3f4f6;
}

.wiki-table th {
  padding: 10px 14px;
  font-weight: 600;
  color: #374151;
  border-bottom: 2px solid #d1d5db;
  white-space: nowrap;
}

.wiki-table td {
  padding: 9px 14px;
  color: #4b5563;
  border-bottom: 1px solid #f3f4f6;
}

.wiki-table tbody tr:hover {
  background: #f9fafb;
}

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

/* --- Info / Warning / Tip Boxes --- */
.wiki-box {
  padding: 16px 20px;
  border-radius: 8px;
  margin: 20px 0;
  font-size: 14px;
  line-height: 1.6;
  color: #374151;
}

.wiki-box-info {
  background: #eff6ff;
  border-left: 4px solid #2563eb;
}

.wiki-box-warn {
  background: #fffbeb;
  border-left: 4px solid #f59e0b;
}

.wiki-box-tip {
  background: #f0fdf4;
  border-left: 4px solid #22c55e;
}

.wiki-box-danger {
  background: #fef2f2;
  border-left: 4px solid #ef4444;
}

.wiki-box strong {
  display: block;
  margin-bottom: 4px;
}

/* --- Card grid (for index page) --- */
.wiki-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  margin: 24px 0;
}

.wiki-card {
  display: block;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 20px;
  text-decoration: none;
  transition: all 0.2s ease;
}

.wiki-card:hover {
  border-color: #93c5fd;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.08);
  transform: translateY(-2px);
}

.wiki-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #fff;
  margin-bottom: 12px;
}

.wiki-card h3 {
  font-size: 15px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 6px;
}

.wiki-card p {
  font-size: 13px;
  color: #6b7280;
  line-height: 1.5;
}

.wiki-card .wiki-card-count {
  font-size: 12px;
  color: #2563eb;
  font-weight: 600;
  margin-top: 10px;
}

/* --- Page Navigation (prev / next) --- */
.wiki-page-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid #e5e7eb;
}

.wiki-page-nav a {
  display: block;
  padding: 12px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  text-decoration: none;
  font-size: 14px;
  color: #374151;
  max-width: 45%;
  transition: border-color 0.15s;
}

.wiki-page-nav a:hover {
  border-color: #2563eb;
  color: #2563eb;
}

.wiki-page-nav .nav-label {
  font-size: 11px;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

.wiki-page-nav .nav-title {
  font-weight: 600;
  font-size: 14px;
}

.wiki-page-nav .nav-next {
  text-align: right;
  margin-left: auto;
}

/* --- Mobile sidebar toggle --- */
.wiki-sidebar-toggle {
  display: none;
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 50;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  border: none;
  font-size: 20px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.wiki-sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 39;
}

/* --- Responsive --- */
@media (max-width: 1023px) {
  .wiki-sidebar {
    position: fixed;
    left: -280px;
    top: 64px;
    z-index: 45;
    transition: left 0.25s ease;
    box-shadow: 2px 0 12px rgba(0,0,0,0.08);
  }

  .wiki-sidebar.open {
    left: 0;
  }

  .wiki-sidebar-overlay.open {
    display: block;
  }

  .wiki-sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .wiki-main {
    padding: 24px 20px 64px;
  }

  .wiki-title {
    font-size: 26px;
  }

  .wiki-page-nav {
    flex-direction: column;
  }

  .wiki-page-nav a {
    max-width: 100%;
  }

  .wiki-card-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Quick-Find (decision-driven navigation) --- */
.wiki-quickfind {
  margin: 28px 0;
}

.wiki-quickfind-title {
  font-size: 20px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 16px;
}

.wiki-quickfind-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

.wiki-quickfind-item {
  display: flex;
  align-items: baseline;
  padding: 12px 16px;
  border-bottom: 1px solid #f3f4f6;
  text-decoration: none;
  transition: background 0.15s;
}

.wiki-quickfind-item:hover {
  background: #eff6ff;
}

.wiki-quickfind-item:last-child {
  border-bottom: none;
}

.wiki-quickfind-q {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  margin-right: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}

.wiki-quickfind-q::before {
  content: "Q";
  display: inline-block;
  background: #2563eb;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  width: 20px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  border-radius: 4px;
  margin-right: 8px;
  vertical-align: middle;
}

.wiki-quickfind-arrow {
  color: #9ca3af;
  margin: 0 8px;
  flex-shrink: 0;
  font-size: 13px;
}

.wiki-quickfind-a {
  font-size: 13px;
  color: #2563eb;
  font-weight: 500;
}

/* --- Speed Reference (compact data tables) --- */
.wiki-speed-ref {
  margin: 32px 0;
}

.wiki-speed-ref-title {
  font-size: 20px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e5e7eb;
}

.wiki-speed-ref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}

.wiki-speed-ref-block h3 {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid #f3f4f6;
}

.wiki-speed-ref-block table {
  width: 100%;
  font-size: 12.5px;
  border-collapse: collapse;
}

.wiki-speed-ref-block th {
  padding: 6px 10px;
  font-weight: 600;
  color: #6b7280;
  text-align: left;
  background: #f9fafb;
  border-bottom: 1px solid #e5e7eb;
}

.wiki-speed-ref-block td {
  padding: 5px 10px;
  color: #4b5563;
  border-bottom: 1px solid #f9fafb;
}

.wiki-speed-ref-block tbody tr:hover {
  background: #f9fafb;
}

/* --- Topic Directory (compact, replaces card grid) --- */
.wiki-topic-section {
  margin: 28px 0;
}

.wiki-topic-section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #9ca3af;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid #2563eb;
}

.wiki-topic-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0;
}

.wiki-topic-list li a {
  display: block;
  padding: 10px 14px;
  border-bottom: 1px solid #f3f4f6;
  text-decoration: none;
  transition: all 0.15s;
  border-left: 3px solid transparent;
}

.wiki-topic-list li a:hover {
  background: #eff6ff;
  border-left-color: #2563eb;
}

.wiki-topic-list li a .topic-name {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
}

.wiki-topic-list li a .topic-brief {
  font-size: 12px;
  color: #9ca3af;
  margin-top: 2px;
}

/* --- Print --- */
@media print {
  .wiki-sidebar,
  .wiki-sidebar-toggle,
  .wiki-sidebar-overlay,
  .wiki-page-nav {
    display: none !important;
  }
  .wiki-main {
    max-width: 100%;
    padding: 0;
  }
}
