/* =========================================
   1. CONFIGURACIÓN BASE Y VARIABLES
   ========================================= */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Inter:wght@300;400;500;600&family=Merriweather:ital,wght@0,300;0,400;1,400&display=swap');

:root {
    /* Paleta de Colores Original */
    --primary-dark: #1a120b;
    --primary-darker: #0f0a05;
    --secondary-dark: #2c1a0f;
    
    /* Estilo Wiki Old School */
    --wiki-bg-page: #121212;
    --wiki-bg-content: #1e1e1e;
    --wiki-bg-header: #251d16;
    
    --wiki-border-outer: #4a3b2a;
    --wiki-border-inner: #3d2e1e;
    
    --wiki-text-main: #e0e0e0;
    --wiki-text-muted: #a0a0a0;
    --wiki-link: #ffba3b;
    --wiki-link-hover: #ffd700;
    
    /* Rarezas */
    --rarity-common: #ffffff;
    --rarity-uncommon: #1eff00;
    --rarity-rare: #0070dd;
    --rarity-epic: #a335ee;
    --rarity-legendary: #ff8000;
    --rarity-artifact: #e6cc80;

    /* Dimensiones */
    --sidebar-width: 280px;
}

/* Reset y Scrollbars */
* {
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: var(--wiki-border-outer) var(--primary-darker);
}

/* Scrollbar Chrome/Edge/Safari */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--primary-darker); }
::-webkit-scrollbar-thumb { background: var(--wiki-border-outer); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--wiki-link); }

body {
    margin: 0;
    padding: 0;
    background-color: var(--wiki-bg-page);
    color: var(--wiki-text-main);
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    line-height: 1.6;
    
    /* CLAVE: Bloqueamos scroll global para gestionar paneles independientemente */
    height: 100vh;
    height: 100dvh; /* Altura real móvil */
    overflow: hidden; 
}

/* Títulos */
h1, h2, h3, h4 {
    font-family: 'Cinzel', serif;
    color: var(--wiki-link);
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
}
h1 { font-size: 2.4rem; border-bottom: 1px solid var(--wiki-border-outer); padding-bottom: 0.2em; margin-top: 0; }
h2 { font-size: 1.8rem; border-bottom: 1px solid var(--wiki-border-inner); padding-bottom: 0.1em; }
h3 { font-size: 1.4rem; }
a { color: var(--wiki-link); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--wiki-link-hover); text-decoration: underline; }

/* =========================================
   2. ESTRUCTURA SHELL (LAYOUT PRINCIPAL)
   ========================================= */

/* Contenedor Grid Principal */
.wiki-shell-container {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
    height: 100%;
    width: 100%;
    overflow: hidden; 
}

/* --- SIDEBAR (Menú Lateral) --- */
.wiki-sidebar {
    background: var(--primary-darker);
    border-right: 2px solid var(--wiki-border-outer);
    display: flex;
    flex-direction: column;
    height: 100%;
    z-index: 20;
    overflow-y: auto; /* Scroll propio del menú */
}

.wiki-sidebar-header {
    padding: 1.5rem 1rem;
    text-align: center;
    border-bottom: 1px solid var(--wiki-border-inner);
    background: linear-gradient(to bottom, var(--secondary-dark), var(--primary-darker));
    flex-shrink: 0;
}

.wiki-logo-text {
    font-family: 'Cinzel', serif;
    font-size: 1.6rem;
    color: var(--wiki-link-hover);
}

.wiki-nav-content {
    flex: 1;
    padding: 1rem 0;
}

/* Links del menú */
.wiki-nav-group { margin-bottom: 1.5rem; }
.wiki-nav-title {
    padding: 0.5rem 1.5rem;
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    color: var(--wiki-text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--wiki-border-inner);
    margin-bottom: 0.5rem;
    background: rgba(255,255,255,0.02);
}

.wiki-start-button {
    display: block;
    padding: 0.4rem 1.5rem 0.4rem 2rem;
    color: var(--wiki-text-main);
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.4s ease-in-out;
}
.wiki-start-button:hover {
    background: #fff !important;
    color: #000 !important;
    text-decoration: none;
    font-weight: 800;
    font-size: 1.2rem;
    /*separacion de letras*/
    letter-spacing: 5px;
    transition: all 0.2s ease-in-out;
}

.wiki-nav-link {
    display: block;
    padding: 0.4rem 1.5rem 0.4rem 2rem;
    color: var(--wiki-text-main);
    font-size: 0.95rem;
    border-left: 3px solid transparent;
    cursor: pointer;
}
.wiki-nav-link:hover {
    background: rgba(255, 186, 59, 0.05);
    color: var(--wiki-link-hover);
}
.wiki-nav-link.active {
    border-left-color: var(--wiki-link);
    background: rgba(255, 186, 59, 0.1);
    color: var(--wiki-link-hover);
    font-weight: 500;
}

/* --- MAIN AREA (Contenedor del Iframe) --- */
.wiki-main-area {
    position: relative;
    height: 100%;
    width: 100%;
    background: var(--wiki-bg-page);
    
    /* SOLUCIÓN AL PROBLEMA DE SCROLL MÓVIL */
    /* Si el iframe se expande (comportamiento iOS), este div permite el scroll */
    overflow-y: auto; 
    
}

body {
    overflow-y: auto;
}

#wiki-frame {
    width: 100%;
    height: 100%; /* En PC ocupa el 100% */
    min-height: 100%; /* En móvil asegura llenar */
    border: none;
    display: block;
}

/* =========================================
   3. ESTILOS DEL CONTENIDO (Dentro del Iframe)
   ========================================= */

.wiki-article {
    max-width: 100%;
    margin: 0 auto;
    padding: 2rem 3rem;
    background-color: var(--wiki-bg-page);
    min-height: 100vh; /* Asegura que cubra la pantalla */
    /* box-shadow: 0 0 50px rgba(0, 0, 0, 0.8); */
    /* border: 2px solid var(--wiki-border-outer); */
}

/* Infobox Flotante */
.infobox {
    float: right;
    clear: right;
    width: 300px;
    margin: 0 0 1rem 1.5rem;
    background: var(--primary-dark);
    border: 1px solid var(--wiki-border-outer);
    padding: 5px;
    font-size: 0.9rem;
    box-shadow: 4px 4px 10px rgba(0,0,0,0.4);
}
.infobox-header {
    background: var(--secondary-dark);
    color: var(--wiki-link);
    text-align: center;
    padding: 8px;
    font-family: 'Cinzel', serif;
    font-weight: bold;
    border-bottom: 2px solid var(--wiki-border-outer);
}
.infobox-image {
    width: 100%;
    background: #000;
    border: 1px solid var(--wiki-border-inner);
}
.infobox-image img { width: 100%; height: auto; display: block; }
.infobox-data { width: 100%; border-collapse: collapse; }
.infobox-data th { text-align: left; padding: 4px 8px; color: var(--wiki-text-muted); vertical-align: top; }
.infobox-data td { text-align: left; padding: 4px 8px; color: var(--wiki-text-main); }

/* Tablas */
.wikitable {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0 2rem 0;
    background: var(--primary-darker);
    border: 1px solid var(--wiki-border-outer);
    font-size: 0.95rem;
}
.wikitable th {
    background: var(--secondary-dark);
    color: var(--wiki-link);
    font-family: 'Cinzel', serif;
    padding: 10px 12px;
    text-align: left;
    border: 1px solid var(--wiki-border-outer);
}
.wikitable td {
    padding: 8px 12px;
    border: 1px solid var(--wiki-border-inner);
}
.wikitable tr:nth-child(even) { background-color: rgba(255, 255, 255, 0.02); }

/* Citas de Lore */
.lore-quote {
    font-family: 'Merriweather', serif;
    font-style: italic;
    color: var(--wiki-text-muted);
    border-left: 3px solid var(--wiki-link);
    padding: 1rem 1rem 1rem 1.5rem;
    margin: 1.5rem 0;
    background: rgba(0,0,0,0.2);
}

/* Tabla de Contenidos */
.toc-container {
    display: inline-block;
    background: var(--primary-dark);
    border: 1px solid var(--wiki-border-inner);
    padding: 1rem;
    margin: 1rem 0;
}
.toc-title { text-align: center; font-family: 'Cinzel', serif; border-bottom: 1px solid var(--wiki-border-inner); margin-bottom: 0.5rem; }
.toc-list ul { list-style: none; padding-left: 1rem; }

details summary { cursor: pointer; }
details summary::-webkit-details-marker { display: none; }
details summary::marker { display: none; }

details summary {
    color: var(--wiki-link);
}

details ul {
    margin: 0.2rem 0 0.5rem 1.5rem;
    padding-left: 0.5rem;
    border-left: 2px solid var(--wiki-link);
}

.wiki-breadcrumbs {
    font-size: 0.85rem;
    color: var(--wiki-text-muted);
    margin-bottom: 1rem;
    text-transform: uppercase;
}

.text-rare { color: var(--rarity-rare); }
.text-epic { color: var(--rarity-epic); }
.text-legendary { color: var(--rarity-legendary); }


.wiki-footer {
    position: fixed;
    bottom: 0;
    width: 100%;
    height: 3.2rem;
    border-top: 1px solid var(--wiki-border-inner);
    background-color: var(--primary-dark);
}

.wiki-footer-container {
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.wiki-footer-copyright {
    color: var(--wiki-text-muted);
    margin-left: 15rem;
}

.wiki-footer-developer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.wiki-footer-social-links {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.wiki-footer-social-link {
    border: 2px solid var(--wiki-border-inner);
}

@media (max-width: 480px) {

    .wiki-footer {
        display: block;
        height: auto;
        position: static;
    }
    
    .wiki-footer-container {
        flex-direction: column;
        align-items: center;
        gap: 1rem;
        padding: 1rem;
        text-align: center;
        margin-left: 0;
        margin-right: 0;
        margin: 0 auto;
        width: 100%;
        max-width: 480px;
        box-sizing: border-box;
    }

    .wiki-footer-copyright {
        margin-left: 0;
    }
}

@media (max-width: 1300px) {
    
    .wiki-footer {
        display: none;
    }
}


/* =========================================
   4. RESPONSIVE DESIGN (MÓVIL)
   ========================================= */
@media (max-width: 768px) {
    .wiki-shell-container {
        grid-template-columns: 1fr; /* Layout de 1 columna */
    }

    /* El Sidebar se convierte en menú deslizante */
    .wiki-sidebar {
        position: fixed; /* Fijo sobre todo */
        top: 0;
        left: 0;
        width: 85%;
        height: 100%;
        transform: translateX(-100%); /* Oculto a la izquierda */
        transition: transform 0.3s ease-in-out;
        box-shadow: 5px 0 20px rgba(0,0,0,0.8);
    }
    
    /* Clase para mostrar el menú */
    .wiki-sidebar.active {
        transform: translateX(0);
    }

    /* Ajustes del contenido para móvil */
    .wiki-article {
        padding: 4rem 1rem 2rem 1rem; /* Padding superior para evitar solapamiento del botón */
        width: 100%;
        /* Permitir scroll natural */
        overflow-x: hidden; 
    }
    
    .wiki-breadcrumbs { margin-left: 0; margin-top: 0; }
    
    .infobox {
        float: none; /* Quitar flotación en móvil */
        width: 100%;
        margin: 1rem 0;
    }
    
    h1 { font-size: 1.8rem; }
}