/* wiki.css — Sloppia Wiki MediaWiki-style styling */

:root {
  --wiki-bg: #f8f9fa;
  --wiki-content-bg: #ffffff;
  --wiki-sidebar-bg: #ffffff;
  --wiki-border: #a2a9b1;
  --wiki-link: #0645ad;
  --wiki-link-visited: #0b0080;
  --wiki-link-new: #cc2200;
  --wiki-h1-border: #a2a9b1;
  --wiki-portlet-bg: #f8f9fa;
  --wiki-tab-border: #a2a9b1;
  --wiki-tab-active-bg: #ffffff;
  --wiki-tab-inactive-bg: #f0f0f0;
  --wiki-table-border: #a2a9b1;
  --wiki-th-bg: #eaecf0;
  --wiki-infobox-bg: #f8f9fa;
  --wiki-infobox-border: #a2a9b1;
  --wiki-notice-bg: #fff3cd;
  --wiki-notice-border: #ffc107;
  --wiki-catlinks-bg: #f8f9fa;
}

@media (prefers-color-scheme: dark) {
  :root {
    --wiki-bg: #1a1a2e;
    --wiki-content-bg: #16152a;
    --wiki-sidebar-bg: #1a1a2e;
    --wiki-border: #444;
    --wiki-link: #7eb6ff;
    --wiki-link-visited: #c59aff;
    --wiki-link-new: #ff6b6b;
    --wiki-h1-border: #444;
    --wiki-portlet-bg: #1a1a2e;
    --wiki-tab-border: #444;
    --wiki-tab-active-bg: #16152a;
    --wiki-tab-inactive-bg: #1a1a2e;
    --wiki-table-border: #444;
    --wiki-th-bg: #2a2a4a;
    --wiki-infobox-bg: #1a1a2e;
    --wiki-infobox-border: #444;
    --wiki-notice-bg: #3a3a2a;
    --wiki-notice-border: #ffaa00;
    --wiki-catlinks-bg: #1a1a2e;
  }
}

.wiki-page {
  background: var(--wiki-bg);
  min-height: 100vh;
}

.wiki-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 24px;
  padding: 24px 32px;
  max-width: 1400px;
  margin: 0 auto;
}

.wiki-sidebar {
  flex-shrink: 0;
  background: var(--wiki-sidebar-bg);
  border: 1px solid var(--wiki-border);
  border-radius: 8px;
  padding: 16px;
  height: fit-content;
  position: sticky;
  top: 120px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
}

.wiki-search {
  margin-bottom: 20px;
}

.wiki-search label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #666;
  margin-bottom: 6px;
}

.wiki-search input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--wiki-border);
  border-radius: 4px;
  font-size: 13px;
  background: var(--wiki-content-bg);
  color: inherit;
  box-sizing: border-box;
}

.wiki-search input:focus {
  outline: none;
  border-color: var(--wiki-link);
  box-shadow: 0 0 0 2px rgba(6, 69, 173, 0.2);
}

.wiki-search-results {
  margin-top: 6px;
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--wiki-border);
  border-radius: 4px;
  background: var(--wiki-content-bg);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.wiki-search-result {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid var(--wiki-border);
  font-size: 13px;
  transition: background 0.1s;
}

.wiki-search-result:last-child {
  border-bottom: none;
}

.wiki-search-result:hover,
.wiki-search-result.selected {
  background: rgba(6, 69, 173, 0.1);
}

.wiki-search-result .snippet {
  font-size: 11px;
  color: #666;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wiki-nav,
.wiki-tools,
.wiki-languages {
  margin-bottom: 20px;
}

.wiki-nav h3,
.wiki-tools h3,
.wiki-languages h3 {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #666;
  margin: 0 0 8px 0;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--wiki-border);
}

.wiki-nav ul,
.wiki-tools ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.wiki-nav li,
.wiki-tools li {
  margin-bottom: 4px;
}

.wiki-nav a,
.wiki-tools a {
  display: block;
  padding: 6px 10px;
  color: var(--wiki-link);
  text-decoration: none;
  font-size: 13px;
  border-radius: 4px;
  transition: background 0.1s;
}

.wiki-nav a:hover,
.wiki-tools a:hover {
  background: rgba(6, 69, 173, 0.1);
  text-decoration: none;
}

.wiki-languages ul {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 13px;
  color: #333;
}

.wiki-languages li {
  padding: 4px 0;
}

.wiki-content {
  background: var(--wiki-content-bg);
  border: 1px solid var(--wiki-border);
  border-radius: 8px;
  padding: 0;
  min-height: 500px;
}

#wiki-header {
  border-bottom: 1px solid var(--wiki-border);
  padding-bottom: 8px;
  margin-bottom: 0;
}

#wiki-title {
  font-size: 28px;
  font-weight: 400;
  margin: 0 0 8px 0;
  padding: 16px 24px 0 24px;
  color: #16152a;
}

@media (prefers-color-scheme: dark) {
  #wiki-title {
    color: #e8e8f0;
  }
}

.wiki-tabs {
  display: flex;
  border-bottom: 1px solid var(--wiki-tab-border);
  margin: 0 24px;
  padding-left: 0;
}

.wiki-tabs a {
  display: block;
  padding: 8px 16px;
  text-decoration: none;
  color: var(--wiki-link);
  font-size: 13px;
  font-weight: 700;
  border: 1px solid transparent;
  border-bottom: none;
  margin-bottom: -1px;
  background: var(--wiki-tab-inactive-bg);
  border-radius: 4px 4px 0 0;
  transition: all 0.1s;
}

.wiki-tabs a:hover {
  background: var(--wiki-tab-active-bg);
  text-decoration: none;
}

.wiki-tabs a.active {
  background: var(--wiki-tab-active-bg);
  border-color: var(--wiki-tab-border);
  border-bottom-color: var(--wiki-tab-active-bg);
  color: #16152a;
}

@media (prefers-color-scheme: dark) {
  .wiki-tabs a.active {
    color: #e8e8f0;
  }
}

.wiki-body {
  padding: 24px;
  line-height: 1.6;
  font-size: 14px;
}

.wiki-body p {
  margin: 0 0 1em 0;
}

.wiki-body h2 {
  font-size: 20px;
  font-weight: 400;
  border-bottom: 1px solid var(--wiki-h1-border);
  padding-bottom: 6px;
  margin: 1.5em 0 0.8em 0;
  color: #16152a;
}

@media (prefers-color-scheme: dark) {
  .wiki-body h2 {
    color: #e8e8f0;
  }
}

.wiki-body h3 {
  font-size: 16px;
  font-weight: 700;
  margin: 1.2em 0 0.6em 0;
  color: #16152a;
}

@media (prefers-color-scheme: dark) {
  .wiki-body h3 {
    color: #e8e8f0;
  }
}

.wiki-body ul,
.wiki-body ol {
  margin: 0.5em 0 1em 1.5em;
}

.wiki-body li {
  margin: 0.25em 0;
}

.wiki-body a {
  color: var(--wiki-link);
  text-decoration: none;
}

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

.wiki-body a:visited {
  color: var(--wiki-link-visited);
}

.wiki-body a.new {
  color: var(--wiki-link-new);
}

.wiki-body code {
  background: rgba(0,0,0,0.05);
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 0.9em;
  font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
}

.wiki-body .infobox {
  float: right;
  width: 280px;
  border: 1px solid var(--wiki-border);
  border-radius: 4px;
  background: var(--wiki-portlet-bg);
  margin: 0 0 1em 1em;
  font-size: 13px;
  max-width: calc(100% - 20px);
}

.wiki-body .infobox caption {
  background: var(--wiki-th-bg);
  font-weight: 700;
  font-size: 14px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--wiki-border);
}

.wiki-body .infobox th {
  text-align: left;
  padding: 6px 10px;
  font-weight: 700;
  width: 100px;
  vertical-align: top;
}

.wiki-body .infobox td {
  padding: 6px 10px;
}

.wiki-body .infobox tr {
  border-bottom: 1px solid var(--wiki-border);
}

.wiki-body .infobox .infobox-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 18px;
  height: 18px;
  background: var(--wiki-bg);
  border: 1px solid var(--wiki-border);
  border-radius: 50%;
  font-size: 12px;
  text-align: center;
  line-height: 18px;
  cursor: pointer;
  z-index: 10;
  user-select: none;
}

.wiki-body .infobox .infobox-close:hover {
  background: var(--wiki-border);
}

@media (prefers-color-scheme: dark) {
  .wiki-body code {
    background: rgba(255,255,255,0.1);
  }
}

@media (max-width: 900px) {
  .wiki-body .infobox {
    float: none;
    width: 100%;
    margin: 1em 0;
  }
}

.wiki-body pre {
  background: #f5f5f5;
  border: 1px solid var(--wiki-border);
  border-radius: 4px;
  padding: 12px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.5;
}

@media (prefers-color-scheme: dark) {
  .wiki-body pre {
    background: #1a1a2e;
  }
}

.wiki-body pre code {
  background: none;
  padding: 0;
}

.wiki-body blockquote {
  border-left: 4px solid var(--wiki-border);
  padding-left: 16px;
  margin: 1em 0;
  color: #555;
  font-style: italic;
}

@media (prefers-color-scheme: dark) {
  .wiki-body blockquote {
    color: #aaa;
  }
}

.wiki-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 1em 0;
}

.wiki-body th,
.wiki-body td {
  border: 1px solid var(--wiki-table-border);
  padding: 8px 12px;
  text-align: left;
}

.wiki-body th {
  background: var(--wiki-th-bg);
  font-weight: 700;
}

.wiki-body tr:nth-child(even) td {
  background: rgba(0,0,0,0.02);
}

@media (prefers-color-scheme: dark) {
  .wiki-body tr:nth-child(even) td {
    background: rgba(255,255,255,0.03);
  }
}

.wiki-portlet {
  background: var(--wiki-portlet-bg);
  border: 1px solid var(--wiki-border);
  border-radius: 4px;
  padding: 16px;
  margin: 16px 0;
}

.wiki-portlet h2 {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 12px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #666;
}

.wiki-portlet ul {
  list-style: disc;
  margin: 0 0 0 1.5em;
}

.wiki-portlet li {
  margin: 0.4em 0;
}

.wiki-footer {
  border-top: 1px solid var(--wiki-border);
  padding: 16px 24px;
  font-size: 12px;
  color: #666;
}

.wiki-footer p {
  margin: 0.5em 0;
}

.wiki-footer code {
  background: rgba(0,0,0,0.05);
  padding: 1px 4px;
  border-radius: 3px;
}

.wiki-infobox {
  float: right;
  width: 280px;
  border: 1px solid var(--wiki-infobox-border);
  border-radius: 4px;
  background: var(--wiki-infobox-bg);
  margin: 0 0 1em 1em;
  font-size: 13px;
}

.wiki-infobox caption {
  background: var(--wiki-th-bg);
  font-weight: 700;
  font-size: 14px;
  padding: 8px;
  border-bottom: 1px solid var(--wiki-infobox-border);
}

.wiki-infobox tr {
  border-bottom: 1px solid var(--wiki-infobox-border);
}

.wiki-infobox th {
  text-align: left;
  padding: 6px 10px;
  font-weight: 700;
  width: 100px;
  vertical-align: top;
}

.wiki-infobox td {
  padding: 6px 10px;
}

.wiki-notice {
  border: 1px solid var(--wiki-notice-border);
  background: var(--wiki-notice-bg);
  border-radius: 4px;
  padding: 12px 16px;
  margin: 1em 0;
  font-size: 13px;
}

.wiki-catlinks {
  border-top: 1px solid var(--wiki-border);
  padding-top: 16px;
  margin-top: 24px;
  background: var(--wiki-catlinks-bg);
  padding: 16px 24px;
}

.wiki-catlinks div {
  margin: 0.5em 0;
}

.wiki-catlinks a {
  margin-right: 0.5em;
}

.wiki-editsection {
  float: right;
  font-size: 11px;
  font-weight: 400;
  margin-left: 8px;
}

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

.toc {
  border: 1px solid var(--wiki-border);
  background: var(--wiki-portlet-bg);
  border-radius: 4px;
  padding: 12px 16px;
  margin: 1em 0;
  display: inline-block;
}

.toc h2 {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 8px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #666;
  border: none;
}

.toc ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc li {
  margin: 4px 0;
}

.toc a {
  color: var(--wiki-link);
  text-decoration: none;
  font-size: 13px;
}

.toc a:hover {
  text-decoration: underline;
}

.thumb {
  border: 1px solid var(--wiki-border);
  background: var(--wiki-portlet-bg);
  padding: 6px;
  margin: 1em 0;
  display: inline-block;
}

.thumb img {
  display: block;
}

.thumbcaption {
  text-align: center;
  font-size: 12px;
  margin-top: 6px;
  color: #555;
}

.reflist {
  font-size: 12px;
  column-count: 2;
  column-gap: 40px;
}

.reflist ol {
  margin-left: 1.5em;
}

.reference {
  text-decoration: none;
  color: var(--wiki-link);
}

.edit-history {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--wiki-border);
}

.edit-history h2 {
  font-size: 18px;
  font-weight: 400;
  border-bottom: 1px solid var(--wiki-h1-border);
  padding-bottom: 6px;
  margin-bottom: 16px;
}

.history-entry {
  padding: 12px 0;
  border-bottom: 1px solid var(--wiki-border);
  font-size: 13px;
}

.history-entry:last-child {
  border-bottom: none;
}

.history-meta {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.history-time {
  color: #666;
  font-family: monospace;
}

.history-user {
  font-weight: 700;
  color: var(--wiki-link);
}

.history-size {
  color: #666;
  font-family: monospace;
}

.history-comment {
  color: #333;
  font-style: italic;
}

@media (prefers-color-scheme: dark) {
  .history-comment {
    color: #ccc;
  }
}

.history-diff,
.history-oldid {
  font-size: 12px;
  color: var(--wiki-link);
  margin-left: 8px;
}

/* Article content specific */
.article-lead {
  font-size: 15px;
  line-height: 1.7;
  margin-bottom: 1.5em;
}

.article-lead b {
  font-weight: 700;
}

.see-also {
  margin-top: 24px;
}

.see-also h2 {
  font-size: 18px;
  border-bottom: 1px solid var(--wiki-h1-border);
  padding-bottom: 6px;
}

.see-also ul {
  list-style: none;
  padding: 0;
  columns: 2;
  column-gap: 40px;
}

.see-also li {
  margin: 4px 0;
  padding-left: 16px;
  position: relative;
}

.see-also li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: #666;
}

.mw-parser-output {
  /* MediaWiki compatibility */
}

.mw-parser-output > p:first-child {
  margin-top: 0;
}

.redirectMsg {
  font-size: 14px;
  font-weight: 700;
  color: #333;
}

@media (max-width: 900px) {
  .wiki-layout {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .wiki-sidebar {
    position: static;
    max-height: none;
    order: 2;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
  }

  .wiki-content {
    order: 1;
  }

  .wiki-infobox {
    float: none;
    width: 100%;
    margin: 1em 0;
  }

  .see-also ul {
    columns: 1;
  }

  .reflist {
    column-count: 1;
  }
}

@media (max-width: 600px) {
  .wiki-tabs a {
    padding: 8px 10px;
    font-size: 12px;
  }

  #wiki-title {
    font-size: 22px;
    padding: 12px 16px 0 16px;
  }

  .wiki-body {
    padding: 16px;
  }

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

/* Special pages */
.special-page {
  padding: 24px;
}

.special-page h2 {
  font-size: 20px;
  font-weight: 400;
  border-bottom: 1px solid var(--wiki-h1-border);
  padding-bottom: 6px;
  margin: 1.5em 0 0.8em 0;
}

.special-page ul {
  list-style: disc;
  margin-left: 1.5em;
}

.special-page li {
  margin: 0.5em 0;
}

.random-article-btn {
  display: inline-block;
  background: var(--wiki-link);
  color: white;
  padding: 10px 20px;
  border-radius: 4px;
  text-decoration: none;
  font-weight: 700;
  margin: 16px 0;
  transition: background 0.1s;
}

.random-article-btn:hover {
  background: #053891;
  color: white;
  text-decoration: none;
}

/* Diff view */
.diff {
  overflow-x: auto;
}

.diff table {
  width: 100%;
  border-collapse: collapse;
}

.diff th {
  background: var(--wiki-th-bg);
  padding: 8px;
  text-align: left;
  border: 1px solid var(--wiki-border);
}

.diff .diff-added {
  background: #d4fcbc;
}

.diff .diff-removed {
  background: #ffb3b3;
}

.diff .diff-changed {
  background: #fff3cd;
}

.diff .diff-context {
  background: transparent;
}

@media (prefers-color-scheme: dark) {
  .diff .diff-added {
    background: #1a3a1a;
  }

  .diff .diff-removed {
    background: #3a1a1a;
  }

  .diff .diff-changed {
    background: #3a3a1a;
  }
}

/* Search suggestions */
.wiki-search-results {
  position: absolute;
  z-index: 100;
  width: 100%;
  box-sizing: border-box;
}

.wiki-search-result {
  display: flex;
  flex-direction: column;
}

/* Breadcrumbs */
.wiki-breadcrumbs {
  font-size: 13px;
  margin-bottom: 16px;
  padding: 8px 12px;
  background: var(--wiki-portlet-bg);
  border: 1px solid var(--wiki-border);
  border-radius: 4px;
  line-height: 1.5;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.wiki-breadcrumbs a {
  color: var(--wiki-link);
  text-decoration: none;
}

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

.wiki-breadcrumbs .sep {
  color: #666;
  margin: 0 4px;
}

.wiki-breadcrumbs .current {
  color: #333;
  font-weight: 700;
}

/* Breadcrumb collapse for mobile */
@media (max-width: 600px) {
  .wiki-breadcrumbs {
    justify-content: space-between;
  }

  .wiki-breadcrumbs .current {
    font-weight: 600;
  }
}

@media (prefers-color-scheme: dark) {
  .wiki-breadcrumbs .current {
    color: #e8e8f0;
  }
}

/* Related articles portlet */
.related-portlet {
  margin-top: 24px;
}

.related-portlet h2 {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 12px 0;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #666;
}

.related-portlet ul {
  list-style: disc;
  margin: 0 0 0 1.5em;
  padding: 0;
}

.related-portlet li {
  margin: 0.4em 0;
}

.related-portlet a {
  color: var(--wiki-link);
  text-decoration: none;
}

.related-portlet a:hover {
  text-decoration: underline;
}

/* TOC improvements */
.toc ol {
  list-style: none;
  padding: 0;
  margin: 0;
}

.toc ol ol {
  padding-left: 1.5em;
}

.toc li {
  margin: 3px 0;
}

.toc a {
  color: var(--wiki-link);
  text-decoration: none;
  font-size: 13px;
}

.toc a:hover {
  text-decoration: underline;
}

/* Sticky TOC - stays visible while scrolling */
.toc {
  position: sticky;
  top: 120px;
  max-height: calc(100vh - 140px);
  overflow-y: auto;
}

@media (max-width: 900px) {
  .toc {
    position: static;
    max-height: none;
  }
}

/* Print styles for TOC */
@media print {
  .toc {
    page-break-inside: avoid;
    position: static;
  }
}

/* Collapsible TOC */
.toc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}

.toc-toggle {
  background: none;
  border: none;
  color: var(--wiki-link);
  cursor: pointer;
  font-size: 12px;
  padding: 0;
}

.toc-toggle:hover {
  text-decoration: underline;
}

.toc-content {
  transition: max-height 0.3s ease-out, opacity 0.2s ease;
  overflow: hidden;
}

.toc-content.collapsed {
  max-height: 0;
  opacity: 0;
}

/* Breadcrumbs on mobile */
@media (max-width: 600px) {
  .wiki-breadcrumbs {
    font-size: 12px;
    padding: 6px 10px;
  }

  .wiki-breadcrumbs .sep {
    margin: 0 2px;
  }
}

/* Print styles */
@media print {
  .wiki-sidebar,
  .wiki-tabs,
  .controls,
  .marquee,
  .nav,
  footer {
    display: none !important;
  }

  .wiki-layout {
    display: block;
    padding: 0;
  }

  .wiki-content {
    border: none;
    box-shadow: none;
  }

  .wiki-body a {
    text-decoration: underline;
  }
}