/* =========================================================
   wiki.css – Wikipedia-style article rendering for Kanka
   Klasa .wiki-article opakowuje cały artykuł.
   Klasa .wiki-entry renderuje surowy HTML z Kanki.
   Klasa .wiki-infobox to boczna tabela z faktami (float right).
   ========================================================= */

/* ---- Layout główny ---- */
.wiki-article {
    font-size: 0.95em;
    line-height: 1.65;
    color: var(--mud-palette-text-primary);
    overflow: hidden; /* clearfix dla float infobox */
}

.wiki-page-title {
    font-size: 2em;
    font-weight: 400;
    border-bottom: 1px solid var(--mud-palette-divider);
    padding-bottom: 4px;
    margin: 0 0 0.6em 0;
    line-height: 1.3;
}

/* ---- Infobox – float right (Wikipedia pattern) ---- */
.wiki-infobox {
    float: right;
    clear: right;
    margin: 0 0 1.2em 1.8em;
    border: 1px solid var(--mud-palette-divider);
    background-color: var(--mud-palette-background-grey);
    min-width: 240px;
    max-width: 300px;
    font-size: 0.875em;
    line-height: 1.5;
}

.wiki-infobox-title {
    background-color: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
    padding: 0.4em 0.7em;
    text-align: center;
    font-weight: 600;
    font-size: 1.05em;
}

.wiki-infobox-image {
    text-align: center;
    border-bottom: 1px solid var(--mud-palette-divider);
    padding: 0;
    overflow: hidden;
}

.wiki-infobox-image img {
    width: 100%;
    max-height: 280px;
    object-fit: cover;
    display: block;
}

.wiki-infobox table {
    width: 100%;
    border-collapse: collapse;
}

.wiki-infobox td {
    padding: 0.3em 0.6em;
    border-bottom: 1px solid var(--mud-palette-divider);
    vertical-align: top;
}

.wiki-infobox td:first-child {
    font-weight: 600;
    width: 40%;
    color: var(--mud-palette-text-secondary);
    white-space: nowrap;
}

.wiki-infobox td:last-child {
    word-break: break-word;
}

/* ---- Spis treści ---- */
.wiki-toc {
    display: inline-block;
    background-color: var(--mud-palette-background-grey);
    border: 1px solid var(--mud-palette-divider);
    padding: 0.6em 1em 0.6em 0.8em;
    margin: 0.2em 0 1em 0;
    min-width: 180px;
    font-size: 0.875em;
}

.wiki-toc-title {
    font-weight: 700;
    font-size: 0.95em;
    margin-bottom: 0.4em;
    text-align: center;
}

.wiki-toc ol {
    margin: 0;
    padding-left: 1.4em;
}

.wiki-toc li {
    margin: 0.15em 0;
}

.wiki-toc a {
    color: #3b6cd4;
    text-decoration: none;
}

.wiki-toc a:hover {
    text-decoration: underline;
}

/* ---- Treść artykułu (.wiki-entry) ---- */
.wiki-entry {
    overflow: hidden; /* żeby text nie wchodził pod infobox */
}

/* Nagłówki */
.wiki-entry h1 {
    font-size: 1.85em;
    font-weight: 400;
    border-bottom: 1px solid var(--mud-palette-divider);
    padding-bottom: 3px;
    margin: 0.8em 0 0.3em;
}

.wiki-entry h2 {
    font-size: 1.45em;
    font-weight: 400;
    border-bottom: 1px solid var(--mud-palette-divider);
    padding-bottom: 3px;
    margin: 1.2em 0 0.3em;
    overflow: hidden;
}

.wiki-entry h2::before {
    content: "";
    display: block;
}

.wiki-entry h3 {
    font-size: 1.15em;
    font-weight: 700;
    margin: 0.9em 0 0.25em;
}

.wiki-entry h4 {
    font-size: 1em;
    font-weight: 700;
    margin: 0.6em 0 0.2em;
}

.wiki-entry h5,
.wiki-entry h6 {
    font-size: 0.9em;
    font-weight: 700;
    margin: 0.5em 0 0.2em;
}

/* Akapity */
.wiki-entry p {
    margin: 0 0 0.75em;
}

/* Linki */
.wiki-entry a {
    color: #3b6cd4;
    text-decoration: none;
}

.wiki-entry a:hover {
    text-decoration: underline;
    color: #1a3d8f;
}

/* Kanka entity mentions */
.wiki-entry .mention,
.wiki-entry [class*="mention-"] {
    color: #3b6cd4;
    cursor: pointer;
    border-bottom: 1px dotted #3b6cd4;
    text-decoration: none;
}

.wiki-entry .mention-character { color: #7B341E; border-color: #7B341E; }
.wiki-entry .mention-location  { color: #276749; border-color: #276749; }
.wiki-entry .mention-family    { color: #6B21A8; border-color: #6B21A8; }
.wiki-entry .mention-race      { color: #9B1C1C; border-color: #9B1C1C; }
.wiki-entry .mention-item      { color: #92400E; border-color: #92400E; }
.wiki-entry .mention-event     { color: #1E3A8A; border-color: #1E3A8A; }
.wiki-entry .mention-quest     { color: #166534; border-color: #166534; }
.wiki-entry .mention-note      { color: #374151; border-color: #374151; }

/* Listy */
.wiki-entry ul,
.wiki-entry ol {
    margin: 0.3em 0 0.6em 1.8em;
    padding: 0;
}

.wiki-entry li {
    margin-bottom: 0.25em;
}

.wiki-entry ul > li {
    list-style-type: disc;
}

.wiki-entry ul > li > ul > li {
    list-style-type: circle;
}

.wiki-entry ol > li {
    list-style-type: decimal;
}

/* Tabele – domyślna "wikitable" */
.wiki-entry table {
    border-collapse: collapse;
    margin: 0.8em 0;
    font-size: 0.9em;
    width: auto;
    max-width: 100%;
}

.wiki-entry th {
    background-color: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
    border: 1px solid var(--mud-palette-divider);
    padding: 0.35em 0.75em;
    text-align: left;
    font-weight: 700;
}

.wiki-entry td {
    border: 1px solid var(--mud-palette-divider);
    padding: 0.3em 0.75em;
    vertical-align: top;
}

.wiki-entry tr:nth-child(even) td {
    background-color: rgba(0,0,0,0.03);
}

/* Tabele klasy Kanka */
.wiki-entry table.wikitable th {
    background-color: var(--mud-palette-background-grey);
    color: var(--mud-palette-text-primary);
}

.wiki-entry table.wikitable {
    min-width: 60%;
}

/* Cytaty */
.wiki-entry blockquote {
    border-left: 4px solid var(--mud-palette-primary);
    margin: 0.8em 0;
    padding: 0.4em 1em;
    color: var(--mud-palette-text-secondary);
    font-style: italic;
    background-color: var(--mud-palette-background-grey);
    border-radius: 0 4px 4px 0;
}

/* Kod */
.wiki-entry code {
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 0.88em;
    background-color: var(--mud-palette-background-grey);
    padding: 0.1em 0.3em;
    border-radius: 3px;
    border: 1px solid var(--mud-palette-divider);
}

.wiki-entry pre {
    background-color: var(--mud-palette-background-grey);
    border: 1px solid var(--mud-palette-divider);
    padding: 0.8em 1em;
    overflow-x: auto;
    border-radius: 4px;
    margin: 0.8em 0;
}

.wiki-entry pre code {
    background: none;
    border: none;
    padding: 0;
}

/* Linia pozioma */
.wiki-entry hr {
    border: none;
    border-top: 1px solid var(--mud-palette-divider);
    margin: 1.2em 0;
}

/* Obrazki */
.wiki-entry img {
    max-width: 100%;
    height: auto;
    border-radius: 2px;
}

/* Obrazek wyśrodkowany Kanka */
.wiki-entry figure {
    margin: 0.8em 0;
    text-align: center;
}

.wiki-entry figcaption {
    font-size: 0.85em;
    color: var(--mud-palette-text-secondary);
    font-style: italic;
    margin-top: 0.3em;
}

/* ---- Specjalne klasy Kanka/własne ---- */

/* Sekcja tylko dla MG */
.wiki-entry .kanka-gm,
.wiki-entry .gm-only,
.wiki-entry [data-private="true"] {
    position: relative;
    background-color: rgba(245, 158, 11, 0.08);
    border: 1px dashed #f59e0b;
    border-radius: 4px;
    padding: 0.6em 0.8em 0.6em 2.2em;
    margin: 0.8em 0;
}

.wiki-entry .kanka-gm::before,
.wiki-entry .gm-only::before {
    content: "🔒";
    position: absolute;
    left: 0.5em;
    top: 0.6em;
}

/* Sekcja "lore" – tło pergaminowe */
.wiki-entry .lore,
.wiki-entry .in-world {
    background-color: rgba(92, 64, 30, 0.06);
    border-left: 3px solid #8B6914;
    padding: 0.4em 0.8em;
    margin: 0.6em 0;
    font-style: italic;
}

/* Sekcja "mechanic" – zasady gry */
.wiki-entry .mechanic,
.wiki-entry .rules {
    background-color: rgba(59, 130, 246, 0.07);
    border-left: 3px solid #3b82f6;
    padding: 0.4em 0.8em;
    margin: 0.6em 0;
}

.wiki-entry .mechanic::before {
    content: "⚙ ";
    font-weight: 700;
    color: #3b82f6;
}

/* Ważna informacja */
.wiki-entry .important,
.wiki-entry .callout {
    background-color: rgba(239, 68, 68, 0.07);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 4px;
    padding: 0.5em 0.8em;
    margin: 0.8em 0;
}

/* Historia / flashback */
.wiki-entry .history,
.wiki-entry .past {
    opacity: 0.85;
    border-left: 3px solid var(--mud-palette-text-secondary);
    padding-left: 0.8em;
    margin: 0.6em 0;
}

/* Czyszczenie float po infoboxie */
.wiki-clearfix {
    clear: both;
}

/* Podpis / footnote */
.wiki-entry small,
.wiki-entry .footnote {
    font-size: 0.8em;
    color: var(--mud-palette-text-secondary);
}

/* =========================================================
   BESTIARIUSZ – creature-specific infobox
   ========================================================= */

.wiki-creature-infobox {
    border-color: #4a3728;
    background-color: #fdf8f0;
}

/* Dark-mode override */
@media (prefers-color-scheme: dark) {
    .wiki-creature-infobox {
        background-color: #1e1510;
        border-color: #6b4c30;
    }
}

.wiki-creature-title {
    background: linear-gradient(135deg, #4a3728 0%, #7c5232 100%);
    color: #f5e6cc;
    letter-spacing: 0.03em;
}

/* Nagłówki sekcji w tabeli infoboxu */
.wiki-creature-section td {
    background-color: #c9a46a;
    color: #2d1a00;
    font-weight: 700;
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.25em 0.6em;
    text-align: center;
}

@media (prefers-color-scheme: dark) {
    .wiki-creature-section td {
        background-color: #5c3a1e;
        color: #e8c99a;
    }
}

/* Puste pola – myślnik */
.wiki-creature-empty {
    color: #bbb;
    font-style: italic;
    font-size: 0.9em;
}

/* ---- Terminal theme touches ---- */
.wiki-entry .mention,
.wiki-entry [class*="mention-"] {
    text-shadow: 0 0 4px currentColor;
}

.wiki-infobox-title {
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* ---- Responsywność ---- */
@media (max-width: 640px) {
    .wiki-infobox {
        float: none;
        margin: 0 0 1em 0;
        max-width: 100%;
        min-width: unset;
    }

    .wiki-page-title {
        font-size: 1.5em;
    }

    .wiki-entry h2 {
        font-size: 1.25em;
    }
}
