/* =========================================
   WIKI (SKYLAND STYLE v2)
   ========================================= */

.wiki-section {
    padding-top: 48px;
    /* Отступ от хедера, чтобы текст не залезал под него */
    padding-bottom: 50px;
    background-color: transparent;
    min-height: 100vh;
}

.wiki-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 40px;
    display: grid;
    grid-template-columns: 260px 1fr 260px;
    gap: 48px;
}

/* =========================================
   ЛЕВАЯ КОЛОНКА (САЙДБАР)
   ========================================= */
.wiki-sidebar {
    position: sticky;
    top: 70px;
    align-self: start;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    padding-right: 32px;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

/* Лого "WIKI" удалено, так как на референсе его нет */
.wiki-logo {
    display: none;
}

/* Навигация */
.wiki-group {
    margin-bottom: 30px;
}

.wiki-group-title {
    font-family: 'Unbounded', sans-serif !important;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 0.05em;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    padding: 6px 8px;
    margin-left: -8px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.wiki-group-title:hover {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-main);
}

.wiki-group-title .chevron-icon {
    transition: transform 0.2s ease;
    color: rgba(255, 255, 255, 0.3);
}

.wiki-group-title:hover .chevron-icon {
    color: var(--text-main);
}

.wiki-group.collapsed .wiki-group-list {
    display: none;
}

.wiki-group.collapsed .wiki-group-title .chevron-icon {
    transform: rotate(-90deg);
}

.wiki-group-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.wiki-group-list li {
    margin-bottom: 0;
}

.wiki-link {
    display: block;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-weight: 600;
    box-sizing: border-box;
    width: 100%;
}

.wiki-link:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.03);
}

.wiki-link.active {
    color: #3b82f6 !important;
    background: rgba(59, 130, 246, 0.12) !important;
    font-weight: 700;
}

/* =========================================
   ЦЕНТРАЛЬНАЯ КОЛОНКА (КОНТЕНТ)
   ========================================= */
.wiki-main {
    min-width: 0;
    max-width: 760px;
    width: 100%;
}

.wiki-header {
    margin-bottom: 0px;
}

.wiki-title {
    font-size: 3rem;
    font-weight: 800;
    margin: 0 0 15px 0;
    color: var(--text-main);
    line-height: 1.1;
}

.wiki-desc {
    font-size: 1.1rem;
    color: var(--text-muted);
    line-height: 1.6;
}

/* Стиль Markdown контента */
.skyland-wiki-content {
    color: var(--text-main);
    font-size: 1.05rem;
    line-height: 1.7;
}

.skyland-wiki-content>*:first-child {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* =========================================
   MARKDOWN FORMATTING (OBSIDIAN/GITHUB STYLE)
   ========================================= */
.skyland-wiki-content h1 {
    font-size: 2.2rem;
    font-weight: 800;
    margin-top: 0 !important;
    margin-bottom: 24px;
    color: var(--text-main);
    line-height: 1.25;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.skyland-wiki-content h2 {
    font-size: 1.6rem;
    font-weight: 700;
    margin-top: 36px;
    margin-bottom: 16px;
    color: var(--text-main);
    line-height: 1.3;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.skyland-wiki-content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-top: 28px;
    margin-bottom: 12px;
    color: var(--text-main);
    line-height: 1.4;
}

.skyland-wiki-content h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-top: 24px;
    margin-bottom: 8px;
    color: var(--text-main);
}

.skyland-wiki-content p,
.skyland-wiki-content ul,
.skyland-wiki-content ol,
.skyland-wiki-content li {
    color: rgba(255, 255, 255, 0.78);
    font-family: 'Onest', sans-serif;
    font-size: 0.95rem;
}

.skyland-wiki-content p {
    margin-bottom: 16px;
    line-height: 1.62;
}

.skyland-wiki-content strong,
.skyland-wiki-content b {
    color: #ffffff !important;
    font-weight: 700;
}

/* Списки */
.skyland-wiki-content ul,
.skyland-wiki-content ol {
    margin-top: 0;
    margin-bottom: 16px;
    padding-left: 24px;
}

.skyland-wiki-content ul {
    list-style-type: disc;
}

.skyland-wiki-content ol {
    list-style-type: decimal;
}

.skyland-wiki-content li {
    margin-top: 4px;
    margin-bottom: 4px;
    line-height: 1.6;
}

.skyland-wiki-content li > ul,
.skyland-wiki-content li > ol {
    margin-top: 4px;
    margin-bottom: 0;
}

/* Ссылки */
.skyland-wiki-content a {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
}

.skyland-wiki-content a:hover {
    color: #60a5fa;
    text-decoration: underline;
}

/* Цитаты (Blockquotes) */
.skyland-wiki-content blockquote {
    margin: 0 0 16px 0;
    padding: 10px 16px;
    color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.02);
    border-left: 4px solid #3b82f6;
    border-radius: 0 6px 6px 0;
}

.skyland-wiki-content blockquote p {
    margin-bottom: 0;
}

/* Горизонтальная линия (HR) */
.skyland-wiki-content hr {
    height: 1px;
    padding: 0;
    margin: 24px 0;
    background-color: rgba(255, 255, 255, 0.1);
    border: 0;
}

/* Код (Code & Pre) */
.skyland-wiki-content code {
    font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace;
    font-size: 0.85em;
    padding: 3px 6px;
    background-color: rgba(255, 255, 255, 0.08);
    border-radius: 5px;
    color: #ff79c6; /* Неоновый розовый/фиолетовый акцент для кодовых слов */
}

.skyland-wiki-content pre {
    margin-top: 0;
    margin-bottom: 16px;
    padding: 16px;
    overflow: auto;
    font-size: 0.85em;
    line-height: 1.45;
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.skyland-wiki-content pre code {
    padding: 0;
    font-size: 100%;
    color: #e6edf3;
    background-color: transparent;
    border-radius: 0;
    display: block;
    word-break: normal;
}

/* Таблицы (Tables) */
.skyland-wiki-content table {
    width: 100%;
    margin-bottom: 20px;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.skyland-wiki-content th,
.skyland-wiki-content td {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    text-align: left;
}

.skyland-wiki-content th {
    font-family: 'Unbounded', sans-serif !important;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-main);
    background-color: rgba(255, 255, 255, 0.03);
    border-bottom: 2px solid rgba(255, 255, 255, 0.12);
}

.skyland-wiki-content tr:nth-child(even) {
    background-color: rgba(255, 255, 255, 0.01);
}

/* =========================================
   ПРАВАЯ КОЛОНКА (ОГЛАВЛЕНИЕ)
   ========================================= */
.wiki-toc {
    display: block;
    border-left: 1px solid rgba(255, 255, 255, 0.05);
    padding-left: 32px;
}

.wiki-toc-sticky {
    position: sticky;
    top: 70px;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.toc-title {
    font-family: 'Unbounded', sans-serif !important;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.4);
    letter-spacing: 0.05em;
    margin: 0 0 16px 0;
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toc-list li.toc-item-level-2 {
    font-size: 0.85rem;
}

.toc-list li.toc-item-level-3 {
    font-size: 0.8rem;
    padding-left: 12px;
}

.toc-list li a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.15s ease;
    display: block;
    line-height: 1.4;
}

.toc-list li a:hover {
    color: var(--text-main);
}

.toc-list li.active a {
    color: #3b82f6;
    font-weight: 700;
}

/* Discord widget card */
.wiki-toc-discord-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 16px;
    text-align: left;
}

.discord-card-logo {
    display: flex;
    align-items: center;
    justify-content: flex-start;
}

.discord-card-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.discord-card-title {
    font-family: 'Unbounded', sans-serif !important;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-main);
}

.discord-card-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.4;
}

.discord-card-btn {
    background: #5865f2;
    color: white;
    text-decoration: none;
    font-family: 'Onest', sans-serif;
    font-size: 0.85rem;
    font-weight: 700;
    text-align: center;
    padding: 10px 16px;
    border-radius: 8px;
    transition: opacity 0.15s ease;
}

.discord-card-btn:hover {
    opacity: 0.85;
}

.discord-card-btn:active {
    opacity: 0.7;
}

/* =========================================
   АДАПТАЦИЯ ВИКИ
   ========================================= */
@media (max-width: 1200px) {
    .wiki-container {
        grid-template-columns: 240px 1fr;
        gap: 40px;
    }

    .wiki-toc {
        display: none;
    }
}

/* =========================================
   МОБИЛЬНАЯ АДАПТАЦИЯ (PLASMO STYLE)
   ========================================= */

/* По умолчанию скрываем мобильные элементы */
.wiki-mobile-controls,
.wiki-mobile-overlay {
    display: none;
}

@media (max-width: 850px) {
    .wiki-container {
        grid-template-columns: 1fr;
        padding: 0 20px;
        gap: 30px;
    }

    /* Скрываем обычный сайдбар на мобильных */
    .wiki-sidebar.desktop-only {
        display: none;
    }

    /* Показываем кнопку открытия */
    .wiki-mobile-controls {
        display: block;
        margin-bottom: 25px;
    }

    /* Синяя кнопка "Содержимое Вики" */
    .btn-wiki-content-toggle {
        width: 100%;
        background: #3b82f6;
        color: white;
        border: none;
        padding: 14px;
        border-radius: 12px;
        font-weight: 700;
        font-size: 1rem;
        cursor: pointer;
        transition: opacity 0.2s;
    }

    .btn-wiki-content-toggle:hover {
        opacity: 0.85;
    }

    .btn-wiki-content-toggle:active {
        opacity: 0.7;
    }

    /* --- OVERLAY МЕНЮ (Выезжает справа или на весь экран) --- */
    .wiki-mobile-overlay {
        display: block;
        /* Но скрыто через transform/visibility */
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: #0A0A0A;
        /* Темный фон как на скрине */
        z-index: 9999;
        overflow-y: auto;
        padding: 20px;
        box-sizing: border-box;

        /* Анимация появления */
        opacity: 0;
        visibility: hidden;
        transform: translateX(100%);
        /* Уехало вправо */
        transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .wiki-mobile-overlay.active {
        opacity: 1;
        visibility: visible;
        transform: translateX(0);
    }

    /* Шапка оверлея */
    .wiki-mobile-header {
        margin-bottom: 30px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        padding-bottom: 15px;
    }

    .btn-close-wiki {
        background: transparent;
        border: none;
        color: white;
        font-size: 1.2rem;
        font-weight: 700;
        display: flex;
        align-items: center;
        gap: 15px;
        cursor: pointer;
        padding: 0;
    }

    /* Список ссылок в мобильном меню */
    .wiki-link-mobile {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 16px 10px;
        color: var(--text-muted);
        text-decoration: none;
        font-size: 1rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
        font-weight: 500;
    }

    .wiki-link-mobile:active {
        background: rgba(255, 255, 255, 0.05);
    }

    .wiki-link-mobile.active {
        color: #3b82f6;
        font-weight: 700;
    }

    .wiki-link-mobile .arrow-right {
        opacity: 0.3;
    }

    .wiki-link-mobile.active .arrow-right {
        opacity: 1;
        color: #3b82f6;
    }
}

/* Custom Scrollbars matching user design */
.wiki-sidebar::-webkit-scrollbar {
    width: 4px;
    display: block !important;
}

.wiki-sidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.01);
    border-radius: 10px;
}

.wiki-sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    transition: background 0.2s ease;
}

.wiki-sidebar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* --- Crafting Recipe Grid Component --- */
.crafting-recipe-wrapper {
    display: inline-flex;
    align-items: center;
    gap: 20px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 24px;
    margin: 16px 0;
    box-sizing: border-box;
}

.crafting-grid-3x3 {
    display: grid;
    grid-template-columns: repeat(3, 64px);
    grid-template-rows: repeat(3, 64px);
    gap: 4px;
    background: rgba(10, 10, 10, 0.6);
    border: 1px solid var(--border-highlight);
    border-radius: 8px;
    padding: 6px;
    box-sizing: border-box;
}

.crafting-slot {
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    text-align: center;
    box-sizing: border-box;
    padding: 4px;
    line-height: 1.25;
    position: relative;
    cursor: default;
}

.crafting-slot.active-item {
    background: rgba(255, 255, 255, 0.04);
    border-color: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s ease;
}

.crafting-slot.active-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    transform: scale(1.05);
}

.crafting-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
}

.crafting-arrow svg {
    width: 24px;
    height: 24px;
}

.crafting-result-slot {
    background: rgba(59, 130, 246, 0.03);
    border: 1.5px solid rgba(59, 130, 246, 0.2);
    border-radius: 8px;
    width: 76px;
    height: 76px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #3b82f6;
    font-size: 0.78rem;
    font-weight: 700;
    text-align: center;
    box-sizing: border-box;
    padding: 6px;
    line-height: 1.25;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}

.crafting-result-slot:hover {
    background: rgba(59, 130, 246, 0.06);
    border-color: rgba(59, 130, 246, 0.4);
    transform: scale(1.05);
}

/* Minecraft-like Tooltip System */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: #0A0A0A;
    border: 1px solid var(--border-highlight);
    border-radius: 4px;
    color: #F2EBDD;
    padding: 6px 10px;
    font-family: 'Onest', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: 99999;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-tooltip]::before {
    content: '';
    position: absolute;
    bottom: 112%;
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    border-width: 5px;
    border-style: solid;
    border-color: #0A0A0A transparent transparent transparent;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    z-index: 99999;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-tooltip]:hover::after,
[data-tooltip]:hover::before {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Minecraft Sprite Icons styling */
.mc-item-icon {
    width: 36px;
    height: 36px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    object-fit: contain;
}

.crafting-result-slot .mc-item-icon {
    width: 44px;
    height: 44px;
}

@media (max-width: 600px) {
    .crafting-recipe-wrapper {
        flex-direction: column !important;
        width: 100% !important;
        align-items: center !important;
        padding: 16px !important;
    }

    .crafting-arrow {
        transform: rotate(90deg);
    }
}

/* --- Portal Schematic Grid System --- */
.portal-schematic-wrapper {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    margin: 16px 0;
    box-sizing: border-box;
}

.portal-schematic-grid {
    display: grid;
    grid-template-columns: repeat(4, 52px);
    grid-template-rows: repeat(5, 52px);
    gap: 2px;
    background: rgba(10, 10, 10, 0.4);
    border: 1px solid var(--border-highlight);
    border-radius: 8px;
    padding: 4px;
    box-sizing: border-box;
}

.portal-block-slot {
    width: 52px;
    height: 52px;
    background: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    position: relative;
}

.portal-block-slot img {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    object-fit: cover;
    border-radius: 3px;
}

.portal-schematic-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-top: 12px;
    font-family: 'Unbounded', sans-serif;
}

/* --- Portal Switcher Tabs System --- */
.portal-switcher-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    margin: 20px 0;
}

.portal-tabs {
    display: flex;
    gap: 8px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 4px;
    margin-bottom: 16px;
}

.portal-tab-btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-family: 'Onest', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    text-align: center;
}

.portal-tab-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.03);
}

/* Hide all view elements by default */
.portal-schematic-wrapper.view-main,
.portal-schematic-wrapper.view-farms,
.portal-schematic-wrapper.view-arts {
    display: none !important;
}

/* Show correct view based on checked radio button */
#portal-tab-main:checked ~ .view-main {
    display: inline-flex !important;
}
#portal-tab-farms:checked ~ .view-farms {
    display: inline-flex !important;
}
#portal-tab-arts:checked ~ .view-arts {
    display: inline-flex !important;
}

/* Highlight active tab button based on checked radio */
#portal-tab-main:checked ~ .portal-tabs .btn-main,
#portal-tab-farms:checked ~ .portal-tabs .btn-farms,
#portal-tab-arts:checked ~ .portal-tabs .btn-arts {
    background: rgba(59, 130, 246, 0.1) !important;
    color: #3b82f6 !important;
}

/* Wiki Footer with FAQ and Telegram */
.wiki-footer {
    margin-top: 48px;
    padding-bottom: 24px;
}

.wiki-footer-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin-bottom: 24px;
}

.wiki-footer-content {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.6;
    font-family: 'Onest', sans-serif;
}

.wiki-footer-content a {
    color: #3b82f6;
    text-decoration: none;
    font-weight: 600;
    transition: opacity 0.2s ease;
}

.wiki-footer-content a:hover {
    opacity: 0.85;
}

.wiki-footer-content a:active {
    opacity: 0.7;
}