/* client/css/wiki.css — Wiki Grimvane (/wiki). Działa na bazie portal.css: pergamin, drewno, złote ramki.
   Układ: lewe menu portalu + jedna szeroka kolumna pergaminowa (hero z wyszukiwarką, kategorie, artykuł). */
.hidden { display: none !important; }
.wiki-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 4px; z-index: 100; background: #f4e9ca; color: #342a1e; padding: 8px 12px; border: 2px solid #997342; }
.skip-link:focus { left: 8px; }

body[data-page="wiki"] .portal-layout { grid-template-columns: 212px minmax(0, 1fr); }
@media (max-width: 780px) { body[data-page="wiki"] .portal-layout { grid-template-columns: 1fr; } }

body[data-page="wiki"] .site-frame { overflow: clip; } /* clip zamiast hidden — pozwala działać sticky na pasku bocznym */
.wiki-main { padding-bottom: 28px; }
.wiki-hero { padding: 6px 22px 12px; text-align: center; border-bottom: 2px solid #ab9064; background: linear-gradient(#e9dbb8, #dccba0); }
.wiki-hero-title { font: 700 clamp(30px, 4vw, 44px) 'IM Fell English SC', Georgia, serif; color: #54402b; text-shadow: 0 1px #ffedbb; margin: 2px 0 0; }
.wiki-hero-lead { font: italic 15px Georgia, serif; color: #766046; margin: 4px 0 14px; }
.wiki-searchbar { position: relative; max-width: 720px; margin: 0 auto 12px; }
.wiki-search-input { width: 100%; padding: 15px 44px 15px 16px; border: 3px inset #a08b69; background: #faf0d5; color: #372d21; font: 17px Georgia, serif; }
.wiki-search-input::placeholder { color: #8e7a5a; font-style: italic; }
.wiki-search-input:focus { outline: 3px solid #d19a44; outline-offset: 2px; }
.wiki-search-clear { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border: 0; background: transparent; color: #70512a; font-size: 16px; }
.wiki-page-tabs { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; }
.wiki-page-tab { padding: 9px 20px; border: 1px solid #907b55; background: #ccbb90; color: #614a2e; font: 700 12px Verdana, sans-serif; min-height: 40px; }
.wiki-page-tab.active { background: #46694f; color: #fff4ce; border-color: #3b533c; }
.wiki-page-tab:hover:not(.active) { background: #d8c9a2; }

.wiki-page-loading, .wiki-page-error { padding: 40px 20px; text-align: center; font: italic 15px Georgia, serif; color: #70512a; }
.wiki-page-error { color: #8a2a1a; }

/* Po wejściu w kategorię/artykuł hero się zwija — treść zaczyna się wyżej. */
.wiki-main-compact .wiki-hero { padding: 4px 22px 10px; }
.wiki-main-compact .intro-label, .wiki-main-compact .wiki-hero-lead { display: none; }
.wiki-main-compact .wiki-hero-title { font-size: clamp(22px, 2.6vw, 30px); margin: 6px 0 8px; }
.wiki-main-compact .wiki-search-input { padding: 10px 40px 10px 14px; font-size: 15px; }
.wiki-main-compact .wiki-searchbar { margin-bottom: 8px; }
.wiki-main-compact .wiki-page-tab { min-height: 34px; padding: 6px 16px; }

/* ── Układ artykułów: sidebar + treść ── */
.wiki-page-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 0 26px; padding: 20px 22px 0; align-items: start; }
.wiki-nav-toggle { display: none; }
.wiki-page-sidebar { position: sticky; top: 8px; max-height: calc(100vh - 16px); overflow-y: auto; border: 3px ridge #9d7e4c; background: #ead9b2; scrollbar-width: thin; }
.wiki-category-nav { list-style: none; margin: 0; padding: 4px; }
.wiki-category-nav li { margin: 0; }
.wiki-category-link { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px; text-align: left; border: 0; border-bottom: 1px dotted #c1ad83; background: transparent; color: #4d3821; padding: 10px 9px; font: 700 13px Georgia, serif; min-height: 40px; }
.wiki-category-link:hover { background: #cfb88d5c; }
.wiki-category-link.active { background: #46694f; color: #fff4ce; }
.wiki-category-count { font: 11px Verdana, sans-serif; color: #7b6338; background: #d6c394; border-radius: 9px; padding: 1px 7px; }
.wiki-category-link.active .wiki-category-count { background: #2f4c39; color: #e8d9a8; }
.wiki-page-list { border-top: 2px solid #9e8b64; }
.wiki-article-list { list-style: none; margin: 0; padding: 0; }
.wiki-article-item { margin: 0; }
.wiki-article-link { display: block; padding: 9px 11px; border-bottom: 1px dotted #c1ad83; color: #42362b; text-decoration: none; }
.wiki-article-link:hover { background: #cfb88d5c; text-decoration: none; }
.wiki-article-link.active { background: #d1b884; box-shadow: inset 3px 0 #70492b; }
.wiki-article-link-title { display: block; font: 700 14px Georgia, serif; color: #4d3821; }
.wiki-article-link-cat { display: inline-block; font: 700 9px Verdana, sans-serif; letter-spacing: .06em; text-transform: uppercase; color: #8b6031; margin-top: 2px; }
.wiki-article-link-summary { display: block; font: 12px/1.4 Georgia, serif; color: #70604b; margin-top: 2px; }
.wiki-article-list-compact .wiki-article-link-summary { display: none; }
.wiki-article-list-compact .wiki-article-link { padding: 8px 11px 8px 18px; }

/* ── Strona główna: kafle kategorii ── */
.wiki-category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.wiki-category-card { display: flex; flex-direction: column; gap: 4px; padding: 14px 15px; border: 3px ridge #9d7e4c; background: #f1e3c0; box-shadow: inset 0 0 0 3px #dfc69c; color: #42362b; text-decoration: none; min-height: 118px; }
.wiki-category-card:hover { background: #f6ebcd; border-color: #c59a52; text-decoration: none; }
.wiki-category-card-title { font: 700 21px 'IM Fell English SC', Georgia, serif; color: #49351d; line-height: 1.1; }
.wiki-category-card-count { font: 700 10px Verdana, sans-serif; letter-spacing: .06em; text-transform: uppercase; color: #8b6031; }
.wiki-category-card-desc { font: 13px/1.45 Georgia, serif; color: #574937; }
.wiki-category-card-preview { font: italic 11px/1.4 Georgia, serif; color: #80684a; margin-top: auto; }

/* ── Artykuł ── */
.wiki-page-detail { min-width: 0; color: #3b3024; font: 15px/1.7 Georgia, serif; max-width: 860px; }
.wiki-breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 4px 0; margin: 0 0 10px; padding: 0; font: 12px Verdana, sans-serif; color: #7b6338; }
.wiki-breadcrumbs li + li::before { content: '›'; margin: 0 7px; color: #a58d5e; }
.wiki-breadcrumbs a { color: #65471f; text-decoration: underline; }
.wiki-article-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.wiki-article-title { font: 700 clamp(28px, 3.4vw, 38px)/1.1 'IM Fell English SC', Georgia, serif; color: #473320; margin: 0 0 4px; outline: none; }
.wiki-article-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.wiki-tool-btn { border: 2px outset #947549; background: #31291d; color: #eee0b9; font: 700 11px Verdana, sans-serif; padding: 8px 12px; min-height: 36px; }
.wiki-tool-btn:hover { filter: brightness(1.15); }
.wiki-article-summary { font: italic 17px/1.55 Georgia, serif; color: #6a5438; margin: 4px 0 16px; padding-bottom: 14px; border-bottom: 2px solid #bca378; }
.wiki-article-meta { font: 11px Verdana, sans-serif; color: #826f50; margin-top: 18px; }

.wiki-toc { border: 2px solid #b79e6b; background: #ecdcb7; margin: 0 0 22px; }
.wiki-toc summary { cursor: pointer; padding: 9px 12px; font: 700 13px Georgia, serif; color: #54402b; list-style: none; }
.wiki-toc summary::-webkit-details-marker { display: none; }
.wiki-toc summary::before { content: '▾ '; }
.wiki-toc details:not([open]) summary::before { content: '▸ '; }
.wiki-toc ol { margin: 0; padding: 0 12px 10px 34px; columns: 2; column-gap: 24px; font: 13px/1.6 Verdana, sans-serif; }
.wiki-toc li { break-inside: avoid; }
.wiki-toc a { color: #65471f; }

.wiki-section { margin: 0 0 8px; padding-top: 6px; scroll-margin-top: 10px; }
.wiki-section-flash { animation: wikiFlash 1.6s ease-out; }
@keyframes wikiFlash { from { background: #f3d98a; } to { background: transparent; } }
.wiki-section-heading { font: 700 24px/1.2 'IM Fell English SC', Georgia, serif; color: #50402c; margin: 22px 0 8px; padding-bottom: 5px; border-bottom: 2px solid #9e8b64; }
.wiki-anchor { margin-left: 8px; font: 700 15px Verdana, sans-serif; color: #b79e6b; text-decoration: none; opacity: 0; }
.wiki-section-heading:hover .wiki-anchor, .wiki-anchor:focus { opacity: 1; }
.wiki-section-body, .wiki-callout-body { margin: 0 0 12px; }
.wiki-xref { color: #1f5a4a; text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 2px; }
.wiki-list { margin: 0 0 14px; padding-left: 24px; }
.wiki-list li { margin-bottom: 4px; }

/* Bloki: wartości i limity, tabele, przykłady, uwagi */
.wiki-values { border: 3px double #ad8852; background: #f1e3c0; margin: 6px 0 16px; }
.wiki-values-title { background: #2b4e40; color: #fff0c2; font: 700 12px Verdana, sans-serif; letter-spacing: .06em; text-transform: uppercase; padding: 7px 12px; }
.wiki-values dl { margin: 0; }
.wiki-values-row { display: grid; grid-template-columns: minmax(130px, 38%) minmax(0, 1fr); gap: 4px 14px; padding: 8px 12px; border-bottom: 1px dotted #c1ad83; font: 14px/1.5 Georgia, serif; }
.wiki-values-row:last-child { border-bottom: 0; }
.wiki-values dt { color: #5b4223; font-weight: 700; }
.wiki-values dd { margin: 0; }
.wiki-values-value { font: 700 15px Verdana, sans-serif; color: #2b4e40; overflow-wrap: anywhere; }
.wiki-values-unit { font-weight: 400; color: #6a5438; }
.wiki-values-note { display: block; font: 13px/1.45 Georgia, serif; color: #6a5a45; margin-top: 2px; }

.wiki-table-wrap { overflow-x: auto; margin: 6px 0 16px; border: 2px solid #b79e6b; background: #f4e8c8; }
.wiki-table-wrap:focus-visible { outline: 3px solid #d19a44; }
.wiki-table { border-collapse: collapse; width: 100%; font: 13px/1.45 Verdana, sans-serif; }
.wiki-table caption { caption-side: top; text-align: left; font: 700 13px Georgia, serif; color: #54402b; padding: 8px 10px; background: #e2d0a7; }
.wiki-table th, .wiki-table td { padding: 7px 10px; border-bottom: 1px solid #cdb98c; text-align: left; vertical-align: top; }
.wiki-table thead th { background: #46694f; color: #fff4ce; font-size: 12px; white-space: nowrap; }
.wiki-table tbody th { font-weight: 700; color: #4d3821; background: #eadbb5; }
.wiki-table tbody tr:nth-child(even) td { background: #efe2c0; }

.wiki-example, .wiki-callout { margin: 6px 0 16px; padding: 10px 14px; border-left: 5px solid #8b6031; background: #ebdbb9; }
.wiki-example { border-left-color: #46694f; background: #e3e8cf; }
.wiki-callout-warning { border-left-color: #a13a22; background: #f0d8c4; }
.wiki-callout-title { font: 700 11px Verdana, sans-serif; letter-spacing: .08em; text-transform: uppercase; color: #5b4223; margin-bottom: 4px; }
.wiki-callout-body:last-child { margin-bottom: 0; }

.wiki-related { margin-top: 28px; padding-top: 14px; border-top: 3px double #97794b; }
.wiki-related-title { font: 700 20px 'IM Fell English SC', Georgia, serif; color: #50402c; margin: 0 0 10px; }
.wiki-related-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.wiki-related-link { display: block; height: 100%; padding: 9px 11px; border: 2px ridge #9d7e4c; background: #f1e3c0; color: #42362b; text-decoration: none; }
.wiki-related-link:hover { background: #f6ebcd; text-decoration: none; }
.wiki-related-name { display: block; font: 700 14px Georgia, serif; color: #49351d; }
.wiki-related-sum { display: block; font: 12px/1.4 Georgia, serif; color: #70604b; margin-top: 2px; }
.wiki-passive-tree-link { margin-top: 18px; border: 2px outset #a3733e; background: linear-gradient(#d5a861, #a3682d); color: #23180f; font: 700 12px Verdana, sans-serif; padding: 10px 14px; }
.wiki-empty { font: italic 14px Georgia, serif; color: #80684a; }
.wiki-search-head { margin-bottom: 8px; }
.wiki-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #2b4e40; color: #fff0c2; padding: 10px 18px; border: 2px ridge #9b7c4c; font: 700 13px Verdana, sans-serif; z-index: 60; }

.wiki-page a:focus-visible, .wiki-main a:focus-visible, .wiki-main button:focus-visible { outline: 3px solid #d19a44; outline-offset: 2px; }

/* ── Drzewko pasywne (wizualizator zachowany; ciemny panel w ramce pergaminu) ── */
.wiki-page-passive-layout { padding: 18px 22px 0; }
.wiki-page-passive-filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

.wiki-page-passive-filters label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #a89878;
}

.wiki-page-passive-filters select {
  padding: 6px 8px;
  font-family: inherit;
  font-size: 13px;
  border: 1px solid #5a4020;
  background: rgba(12, 10, 8, 0.85);
  color: #eee;
}

.wiki-page-passive-meta {
  font-size: 12px;
  color: #a89878;
  margin-bottom: 8px;
}

.wiki-page-passive-detail-only {
  grid-column: span 2;
}

.wiki-page-passive-layout {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.wiki-page-passive-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.wiki-page-passive-toolbar .wiki-page-passive-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  flex: 1;
  margin-bottom: 0;
}

.wiki-page-passive-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 300px);
  gap: 16px;
  align-items: stretch;
}

@media (max-width: 900px) {
  .wiki-page-passive-main {
    grid-template-columns: 1fr;
  }
  .wiki-page-passive-detail-only {
    grid-column: span 1;
  }
}

.wiki-passive-viewport {
  position: relative;
  min-height: min(62vh, 520px);
  border: 1px solid #5a4020;
  background: radial-gradient(ellipse at center, rgba(28, 22, 14, 0.95) 0%, rgba(8, 6, 4, 0.98) 100%);
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}

.wiki-passive-detail-panel {
  background: rgba(12, 10, 8, 0.55);
  border: 1px solid #5a4020;
  padding: 12px;
  max-height: min(62vh, 520px);
  overflow: auto;
}

.wiki-passive-zoom {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wiki-passive-zoom-btn {
  width: 30px;
  height: 30px;
  border: 1px solid #5a4020;
  background: rgba(12, 10, 8, 0.9);
  color: #e8c872;
  font-family: inherit;
  font-size: 15px;
  cursor: pointer;
}

.wiki-passive-hover-tip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  max-width: 240px;
  padding: 6px 10px;
  border: 1px solid #5a4020;
  background: rgba(12, 10, 8, 0.94);
}

.wiki-passive-tip-kind {
  font-size: 10px;
  text-transform: uppercase;
  color: #a89878;
}

.wiki-passive-tip-name {
  font-size: 13px;
  font-weight: 700;
  color: #e8c872;
}

.wiki-passive-hint {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 4;
  margin: 0;
  font-size: 11px;
  color: #a89878;
  pointer-events: none;
}

.wiki-passive-viewport .passive-tree-vignette {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 2;
  background: radial-gradient(ellipse at center, transparent 38%, rgba(0, 0, 0, 0.62) 100%);
}

.wiki-passive-viewport .passive-tree-svg-surface {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
  z-index: 1;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}
.wiki-passive-viewport .passive-tree-svg-surface.pt-panning,
.wiki-passive-viewport .passive-tree-svg-surface.pt-panning * {
  cursor: grabbing !important;
}

.wiki-passive-viewport .pt-guide-ring {
  fill: none;
  stroke: rgba(140, 105, 55, 0.16);
  stroke-width: 1.5;
}

.wiki-passive-viewport .pt-edge {
  stroke: #4a4034;
  stroke-width: 3;
  fill: none;
  opacity: 0.92;
}

.wiki-passive-viewport .pt-node { cursor: pointer; }
.wiki-passive-viewport .pt-node:hover .pt-outer { stroke: var(--pt-fam-hover, #e8c060); }
.wiki-passive-viewport .pt-node.selected .pt-outer {
  stroke: #ffe080;
  stroke-width: 3;
}

/* Paleta węzła (--pt-fam-*) ustawiana przez PassiveTreeStyle — rodzina statystyki. */
.wiki-passive-viewport .pt-node .pt-outer {
  fill: var(--pt-fam-fill, #2a241c);
  stroke: var(--pt-fam-stroke, #6a5a48);
  stroke-width: 2;
}

.wiki-passive-viewport .pt-node .pt-inner {
  fill: var(--pt-fam-inner, #4a3c30);
  stroke: var(--pt-fam-inner-stroke, #8a7860);
  stroke-width: 1.5;
}

.wiki-passive-viewport .pt-node .pt-icon-fill {
  fill: var(--pt-fam-icon, #b0a084);
  stroke: none;
}

.wiki-passive-viewport .pt-node .pt-icon-stroke {
  stroke: var(--pt-fam-icon, #b0a084);
  fill: none;
}

.wiki-passive-viewport .pt-node.taken .pt-icon-fill {
  fill: var(--pt-fam-taken-icon, #fff0c0);
}

.wiki-passive-viewport .pt-node.taken .pt-icon-stroke {
  stroke: var(--pt-fam-taken-icon, #fff0c0);
}

.wiki-passive-viewport .pt-node.pt-start .pt-outer {
  fill: #5a3010;
  stroke: #ffd060;
  stroke-width: 3.5;
}

.wiki-passive-viewport .pt-node.pt-keystone .pt-outer {
  fill: var(--pt-fam-fill, #1a1824);
  stroke: var(--pt-fam-stroke, #a89050);
  stroke-width: 3.5;
}

.wiki-passive-viewport .pt-node.pt-keystone .pt-inner {
  fill: var(--pt-fam-inner, #2a2430);
  stroke: var(--pt-fam-inner-stroke, #c4a86a);
}

.wiki-passive-viewport .pt-node text {
  fill: #e8dcc0;
  font-family: Cinzel, Georgia, serif;
  font-size: 13px;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}

.wiki-passive-viewport .pt-search-active .pt-edge,
.wiki-passive-viewport .pt-search-active .pt-node.pt-search-dim {
  opacity: 0.12;
}

.wiki-passive-viewport .pt-search-active .pt-node.pt-search-hit {
  opacity: 1;
}

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

.wiki-page-passive-filters { flex-direction: row; flex-wrap: wrap; gap: 10px; margin-bottom: 0; }
.wiki-page-passive-filters label { color: #5b4223; font: 700 11px Verdana, sans-serif; }
.wiki-page-passive-filters select { min-height: 38px; border: 2px inset #a08b69; background: #faf0d5; color: #372d21; }
.wiki-page-passive-meta { color: #6a5438; }
.wiki-passive-viewport { border: 4px ridge #977b4b; }
.wiki-passive-detail-panel { background: #172924; color: #e4d7b0; border: 3px ridge #977b4b; font: 13px/1.55 Verdana, sans-serif; }
.wiki-passive-detail-panel .wiki-empty { color: #bfb099; }
.wiki-passive-detail-kind { font: 700 10px Verdana, sans-serif; letter-spacing: .08em; text-transform: uppercase; color: #d4a15c; }
.wiki-passive-detail-title { font: 700 20px 'IM Fell English SC', Georgia, serif; color: #f0c868; margin: 2px 0 8px; }
.wiki-passive-body, .wiki-passive-concept, .wiki-passive-effects, .wiki-passive-cost, .wiki-passive-points, .wiki-passive-exclusive { margin: 6px 0; }
.wiki-passive-tree-meta, .wiki-page-passive-meta { font: 12px Verdana, sans-serif; }

/* ── Telefon ── */
@media (max-width: 900px) {
  .wiki-page-layout { grid-template-columns: 1fr; padding: 14px 12px 0; gap: 12px; }
  .wiki-nav-toggle { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; min-height: 46px; padding: 10px 14px; border: 3px ridge #9d7e4c; background: #46694f; color: #fff4ce; font: 700 14px Georgia, serif; }
  .wiki-nav-toggle-cur { font: 400 12px Verdana, sans-serif; color: #e8d9a8; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .wiki-nav-toggle::after { content: '▾'; }
  .wiki-page-sidebar { display: none; position: static; max-height: 62vh; }
  .wiki-page-sidebar.open { display: block; }
  .wiki-page-detail { font-size: 16px; line-height: 1.7; }
  .wiki-toc ol { columns: 1; }
  .wiki-values-row { grid-template-columns: 1fr; gap: 0; }
  .wiki-hero { padding: 4px 12px 8px; }
  .wiki-category-grid { grid-template-columns: 1fr 1fr; }
  .wiki-page-passive-layout { padding: 12px; }
  .wiki-anchor { opacity: 1; }
  .wiki-article-head { flex-direction: column; }
}
@media (max-width: 520px) {
  .wiki-category-grid { grid-template-columns: 1fr; }
  .wiki-category-card { min-height: 0; }
  .wiki-search-input { font-size: 16px; }
  .wiki-section-heading { font-size: 21px; }
  .wiki-table { font-size: 12px; }
  .wiki-page-tab { flex: 1; padding: 9px 8px; }
}
@media (prefers-reduced-motion: reduce) { .wiki-section-flash { animation: none; } }
