/* wiki.css — Styles for the wiki two-column layout.
   Scoped to .wiki-layout to prevent bleed into other pages.
   Inherits all CSS custom properties from variables.css. */

/* ── Layout ──────────────────────────────────────────────────────────────── */
.wiki-layout {
  display: flex;
  align-items: flex-start;
  gap: 0;
  padding-top: 0;
  min-height: 60vh;
}

.wiki-sidebar {
  width: 260px;
  min-width: 260px;
  border-right: 1px solid var(--border, #e5e7eb);
  padding: 24px 0;
  position: sticky;
  top: 64px; /* height of sticky navbar */
  max-height: calc(100vh - 64px);
  overflow-y: auto;
}

.wiki-content {
  flex: 1;
  min-width: 0;
  padding: 32px 40px;
}

/* ── Sidebar heading (icon + "Contents" label) ───────────────────────────── */
.wiki-sidebar__heading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px 10px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted, #6b7280);
}

.wiki-sidebar__heading .bi {
  font-size: 1rem;
  color: var(--wcm-red, #b31b1b);
  flex-shrink: 0;
}

/* ── Multi-book divider label in sidebar ─────────────────────────────────── */
.wiki-sidebar__book-label {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px 4px;
  margin-top: 6px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted, #6b7280);
  border-top: 1px solid #e5e7eb;
}

.wiki-sidebar__book-label:first-of-type {
  border-top: none;
  margin-top: 0;
}

.wiki-sidebar__book-label--active {
  color: var(--wcm-red, #b31b1b);
}

.wiki-sidebar__book-label .bi {
  font-size: 0.85rem;
  flex-shrink: 0;
}

/* Slight indent for trees under a book label */
.wiki-tree--sub {
  padding-bottom: 4px;
}

/* ── Sidebar tree ────────────────────────────────────────────────────────── */
.wiki-tree {
  padding: 0 12px;
}

/*
 * Block-level layout for tree items.
 * The JS-inserted toggle button uses position:absolute so it floats at the
 * right of the label row without affecting document flow — the children <ul>
 * always flows naturally below as a block element.
 */
.wiki-tree__section {
  position: relative; /* anchor for the absolutely-positioned toggle button */
  margin-bottom: 4px;
}

.wiki-tree__section-label {
  display: flex;      /* flex inside the <a> keeps lock-icon at far right */
  align-items: center;
  gap: 6px;
  padding: 6px 32px 6px 10px; /* right padding leaves room for toggle button */
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-primary, #1f2937);
  text-decoration: none;
  border-radius: 4px;
  transition: background var(--transition, 0.15s ease);
}

/* Collapse toggle button (chevron) — absolute so the children <ul> is never
   pushed inline alongside the section label. */
.wiki-tree__toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  right: 4px;
  top: 4px;
  width: 22px;
  height: 22px;
  padding: 0;
  background: none;
  border: none;
  border-radius: 4px;
  color: var(--text-muted, #6b7280);
  cursor: pointer;
  font-size: 0.7rem;
  transition: background var(--transition, 0.15s ease), color var(--transition, 0.15s ease);
}

.wiki-tree__toggle:hover {
  background: var(--bg-light, #f3f4f6);
  color: var(--wcm-orange, #cf4520);
}

.wiki-tree__section-label:hover {
  background: var(--bg-light, #f3f4f6);
  color: var(--wcm-orange, #cf4520);
  text-decoration: none;
}

.wiki-tree__section-label.active {
  color: var(--wcm-orange, #cf4520);
}

/* Children list — block by default; flows below the label naturally. */
.wiki-tree__children {
  padding-left: 16px;
  margin-top: 2px;
}

/* Each nested <li> is also a positioned block for its own toggle button. */
.wiki-tree__children > li {
  position: relative;
}

/* The toggle button inside nested <li> elements sits at the top-right of
   the page link row. It is absolutely positioned by the same .wiki-tree__toggle
   rule above — just fine-tuned for the smaller page link padding. */
.wiki-tree__children > li > .wiki-tree__toggle {
  top: 2px;
}

.wiki-tree__children--collapsed {
  display: none;
}

.wiki-tree__page {
  display: flex;      /* flex inside the <a> keeps lock-icon at far right */
  align-items: center;
  gap: 6px;
  padding: 4px 30px 4px 10px; /* right padding leaves room for toggle button */
  font-size: 0.8rem;
  color: var(--text-muted, #6b7280);
  text-decoration: none;
  border-radius: 4px;
  transition: background var(--transition, 0.15s ease), color var(--transition, 0.15s ease);
  margin-bottom: 1px;
}

.wiki-tree__page:hover {
  background: var(--bg-light, #f3f4f6);
  color: var(--wcm-orange, #cf4520);
  text-decoration: none;
}

.wiki-tree__page.active {
  background: var(--wcm-orange, #cf4520);
  color: #fff;
  font-weight: 500;
}

.wiki-tree__page.active:hover {
  background: var(--wcm-red, #b31b1b);
  color: #fff;
}

.wiki-tree__page--deep {
  padding-left: 20px;
  font-size: 0.75rem;
}

.wiki-tree__lock {
  font-size: 0.65rem;
  color: var(--wcm-red, #b31b1b);
  margin-left: auto; /* pushes icon to far right inside flex <a> */
}

.wiki-sidebar__edit {
  padding: 0 12px;
  border-top: 1px solid var(--border, #e5e7eb);
}

/* ── Article header ──────────────────────────────────────────────────────── */
.wiki-article__header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border, #e5e7eb);
}

.wiki-article__title {
  font-family: var(--font-brand, '1898 Sans', Georgia, serif);
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--text-primary, #1f2937);
  margin-bottom: 8px;
}

.wiki-article__meta {
  font-size: 0.8rem;
  color: var(--text-muted, #9ca3af);
}

.wiki-article__meta a {
  color: var(--wcm-orange, #cf4520);
  text-decoration: none;
}

.wiki-article__meta a:hover {
  text-decoration: underline;
}

/* ── Breadcrumb ──────────────────────────────────────────────────────────── */
.wiki-breadcrumb {
  margin-bottom: 16px;
  font-size: 0.8rem;
}

.wiki-breadcrumb .breadcrumb-item a {
  color: var(--wcm-orange, #cf4520);
  text-decoration: none;
}

.wiki-breadcrumb .breadcrumb-item a:hover {
  text-decoration: underline;
}

/* ── Body content ────────────────────────────────────────────────────────── */
.wiki-article__body {
  font-size: 0.95rem;
  line-height: 1.75;
  color: var(--text-primary, #374151);
}

.wiki-article__body h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
  color: var(--text-primary, #1f2937);
}

.wiki-article__body h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary, #1f2937);
}

.wiki-article__body h4 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-top: 1.25rem;
  margin-bottom: 0.4rem;
}

.wiki-article__body a {
  color: var(--wcm-orange, #cf4520);
}

.wiki-article__body a:hover {
  color: var(--wcm-red, #b31b1b);
}

.wiki-article__body code {
  font-family: var(--font-mono, 'JetBrains Mono', monospace);
  font-size: 0.85em;
  background: #f3f4f6;
  padding: 2px 5px;
  border-radius: 3px;
  color: var(--text-primary, #1f2937);
}

.wiki-article__body pre {
  background: #f8f9fa;
  border-left: 3px solid var(--wcm-red, #b31b1b);
  border-radius: 0 4px 4px 0;
  padding: 14px 18px;
  overflow-x: auto;
  margin: 1rem 0;
}

.wiki-article__body pre code {
  background: none;
  padding: 0;
  font-size: 0.875rem;
  color: #1f2937;
}

.wiki-article__body blockquote {
  border-left: 3px solid var(--wcm-orange, #cf4520);
  padding: 8px 16px;
  margin: 1rem 0;
  color: var(--text-muted, #6b7280);
  background: #fffbf9;
  border-radius: 0 4px 4px 0;
}

.wiki-article__body table {
  width: 100%;
  max-width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.875rem;
}

/*
 * Some pasted wiki content carries inline fixed widths (e.g. width: 996px),
 * which can force article overflow at narrower viewports.
 */
.wiki-article__body table[style] {
  width: 100% !important;
  max-width: 100% !important;
}

.wiki-article__body th {
  background: var(--wcm-red, #b31b1b);
  color: #fff;
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.wiki-article__body td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  overflow-wrap: anywhere;
}

.wiki-article__body tr:nth-child(even) td {
  background: #f9fafb;
}

.wiki-article__body img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 1rem 0;
}

.wiki-article__body hr {
  border: none;
  border-top: 1px solid var(--border, #e5e7eb);
  margin: 2rem 0;
}

.wiki-article__body ul,
.wiki-article__body ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

.wiki-article__body li {
  margin-bottom: 0.25rem;
}

/* ── Prev / Next ─────────────────────────────────────────────────────────── */
.wiki-article__prevnext {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid var(--border, #e5e7eb);
}

.wiki-prevnext {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.wiki-prevnext__prev,
.wiki-prevnext__next {
  font-size: 0.875rem;
  color: var(--wcm-orange, #cf4520);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.wiki-prevnext__prev:hover,
.wiki-prevnext__next:hover {
  color: var(--wcm-red, #b31b1b);
  text-decoration: none;
}

.wiki-prevnext__next {
  margin-left: auto;
}

/* ── Section index (auto-generated child-page cards) ─────────────────────── */
.wiki-section-index__intro {
  font-size: 0.875rem;
  color: var(--text-muted, #6b7280);
  margin-bottom: 1.25rem;
}

.wiki-section-index__grid {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.wiki-section-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 1.1rem;
  border: 1px solid var(--border, #e5e7eb);
  border-radius: 8px;
  text-decoration: none !important;
  color: inherit;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
}

.wiki-section-card:hover {
  border-color: var(--wcm-red, #b31b1b);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.07);
  transform: translateX(3px);
  color: inherit;
}

.wiki-section-card__icon {
  font-size: 1.4rem;
  color: var(--wcm-red, #b31b1b);
  flex-shrink: 0;
  line-height: 1;
}

.wiki-section-card__body {
  flex: 1;
  min-width: 0;
}

.wiki-section-card__title {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 0.15rem;
  color: var(--text-primary, #1f2937);
}

.wiki-section-card__excerpt {
  font-size: 0.82rem;
  color: var(--text-muted, #6b7280);
  margin: 0 0 0.3rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wiki-section-card__badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.72rem;
  padding: 0.15rem 0.55rem;
  background: var(--bg-muted, #f3f4f6);
  border-radius: 999px;
  color: var(--text-muted, #6b7280);
}

.wiki-section-card__arrow {
  font-size: 0.9rem;
  color: var(--text-muted, #d1d5db);
  flex-shrink: 0;
  transition: color 0.15s ease, transform 0.12s ease;
}

.wiki-section-card:hover .wiki-section-card__arrow {
  color: var(--wcm-red, #b31b1b);
  transform: translateX(2px);
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 991px) {
  .wiki-layout {
    flex-direction: column;
  }

  .wiki-sidebar {
    width: 100%;
    min-width: unset;
    border-right: none;
    border-bottom: 1px solid var(--border, #e5e7eb);
    position: static;
    max-height: none;
    overflow-y: visible;
    padding: 16px 0;
  }

  .wiki-content {
    padding: 24px 16px;
  }
}

@media (max-width: 575px) {
  .wiki-article__title {
    font-size: 1.4rem;
  }

  .wiki-prevnext {
    flex-direction: column;
    align-items: flex-start;
  }

  .wiki-prevnext__next {
    margin-left: 0;
  }
}

/* ── Access-denied page ──────────────────────────────────────────────────── */
.wiki-access-denied {
  max-width: 520px;
  padding: 48px 32px;
}

.wiki-access-denied__icon {
  font-size: 4.5rem;
  color: var(--wcm-red, #b31b1b);
  line-height: 1;
  margin-bottom: 24px;
}

.wiki-access-denied__title {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary, #1a1a1a);
  margin-bottom: 16px;
  font-family: var(--font-brand);
}

.wiki-access-denied__message {
  font-size: 1.05rem;
  color: var(--text-muted, #6c757d);
  margin-bottom: 12px;
  line-height: 1.65;
}

.wiki-access-denied__contact {
  font-size: 0.95rem;
  color: var(--text-muted, #6c757d);
  margin-bottom: 32px;
}

.wiki-access-denied__contact a {
  color: var(--wcm-orange, #cf4520);
  text-decoration: none;
}

.wiki-access-denied__contact a:hover {
  text-decoration: underline;
}

.wiki-access-denied__actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 8px;
}
