/* ==========================================================================
   Wiki — page index, article, and revision history / diff.
   Every value resolves to a design token from tokens.css.
   ========================================================================== */

/* ---- Toolbar (shared header row for index / article / history) ----------- */
.wiki-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.wiki-toolbar__count {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.wiki-search {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.wiki-search__input {
  min-width: 200px;
}

/* ---- Sidebar page nav (occupies the column the forum sidebar vacates) ---- */
.wiki-nav {
  flex: 0 0 200px;
  align-self: flex-start;
  position: sticky;
  top: var(--space-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow: hidden;
}

@media (max-width: 768px) {
  .wiki-nav {
    flex-basis: auto;
    width: 100%;
    position: static;
  }
}

.wiki-nav__title {
  padding: var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
}

.wiki-nav__list {
  list-style: none;
  margin: 0;
  padding: var(--space-1) 0;
  max-height: 60vh;
  overflow-y: auto;
}

.wiki-nav__link {
  display: block;
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-sm);
  color: var(--link);
}

.wiki-nav__link:hover {
  background: var(--surface-3);
  color: var(--link-hover);
}

.wiki-nav__link--active {
  background: var(--surface-accent);
  color: var(--text-strong);
  font-weight: var(--weight-semibold);
}

.wiki-nav__empty {
  padding: var(--space-2);
  font-size: var(--text-sm);
}

.wiki-nav__back {
  display: block;
  padding: var(--space-2);
  border-top: 1px solid var(--border-subtle);
  font-size: var(--text-sm);
  color: var(--link);
}

.wiki-nav__back:hover {
  background: var(--surface-3);
  color: var(--link-hover);
}

/* ---- Table of contents --------------------------------------------------- */
.wiki-toc {
  margin: 0 0 var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.wiki-toc__title {
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-strong);
}

.wiki-toc__list {
  list-style: none;
  margin: var(--space-2) 0 0;
  padding: 0;
}

.wiki-toc__item {
  padding: 1px 0;
  font-size: var(--text-sm);
}

.wiki-toc__item--l1 { padding-left: var(--space-3); }
.wiki-toc__item--l2 { padding-left: var(--space-5); }

.wiki-toc__link {
  color: var(--link);
}

.wiki-toc__link:hover {
  color: var(--link-hover);
}

/* ---- Inline [[wiki links]] ----------------------------------------------- */
.wiki-link {
  color: var(--link);
}

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

.wiki-link--missing {
  color: var(--danger-fg);
  border-bottom: 1px dotted var(--danger-border);
}

/* ---- Page index ---------------------------------------------------------- */
.wiki-page-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--border-subtle);
}

.wiki-page-list__item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
  transition: background-color 0.1s ease-in-out;
}

.wiki-page-list__item:hover {
  background: var(--surface-2);
}

.wiki-page-list__link {
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  color: var(--link);
}

.wiki-page-list__link:hover {
  color: var(--link-hover);
}

.wiki-page-list__meta {
  flex: none;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* ---- Article ------------------------------------------------------------- */
.wiki-page-meta {
  margin: 0 0 var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.wiki-page-body {
  padding: var(--space-2) 0 var(--space-4);
  line-height: 1.7;
}

.wiki-page-body > :first-child {
  margin-top: 0;
}

/* ---- Revision history ---------------------------------------------------- */
.wiki-history {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--border-subtle);
}

.wiki-history__item {
  padding: var(--space-3) var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}

.wiki-history__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.wiki-history__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
}

.wiki-history__event {
  font-weight: var(--weight-semibold);
  color: var(--text-strong);
}

.wiki-history__by::before {
  content: "·";
  margin-right: var(--space-2);
  color: var(--text-muted);
}

.wiki-history__time {
  color: var(--text-muted);
}

.wiki-history__badge {
  display: inline-block;
  padding: 0 var(--space-2);
  border-radius: var(--radius-sm);
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.wiki-history__badge--current {
  background: var(--success-bg);
  color: var(--success-fg);
  border: 1px solid var(--success-border);
}

.wiki-history__restore {
  display: inline;
  margin: 0;
}

.wiki-history__diff {
  margin-top: var(--space-2);
}

.wiki-history__summary {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
  list-style: none;
}

.wiki-history__summary::-webkit-details-marker {
  display: none;
}

.wiki-history__summary::before {
  content: "▸";
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.wiki-history__diff[open] .wiki-history__summary::before {
  content: "▾";
}

.wiki-history__summary:hover {
  color: var(--link-hover);
}

.wiki-history__diff .wiki-diff {
  margin-top: var(--space-2);
}

/* ---- Diff ---------------------------------------------------------------- */
.wiki-diff__stat {
  font-weight: var(--weight-semibold);
  font-family: var(--font-code);
  font-size: var(--text-xs);
}

.wiki-diff__stat--add { color: var(--success-fg); }
.wiki-diff__stat--del { color: var(--danger-fg); }

.wiki-diff {
  margin: 0;
  padding: 0;
  border: 1px solid var(--border-code);
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  font-family: var(--font-code);
  font-size: var(--text-sm);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}

.wiki-diff__line {
  display: block;
  padding: 0 var(--space-2);
  border-left: 3px solid transparent;
}

.wiki-diff__line--added {
  background: var(--success-bg);
  color: var(--success-fg);
  border-left-color: var(--success-border);
}

.wiki-diff__line--removed {
  background: var(--danger-bg);
  color: var(--danger-fg);
  border-left-color: var(--danger-border);
}

.wiki-diff__line--unchanged {
  color: var(--text-muted);
}

.wiki-diff__empty {
  margin: 0;
  padding: var(--space-2);
  font-size: var(--text-sm);
}
