/* =====================================================
   TURISMO-BOOK.CSS — Estilos do Lector de Libro Interactivo (Escolma)
   ===================================================== */

/* Layout Principal */
.book-reader-layout {
    display: flex;
    background: var(--reader-bg, #f8fafc);
    color: var(--reader-text, #1e293b);
    position: relative;
    transition: background-color 0.3s ease, color 0.3s ease;
    min-height: 70vh;
    margin-top: 160px; /* Compensa el header fijo de la web en escritorio */
}

/* Temas de Lectura */
body.theme-light {
    --reader-bg: #f8fafc;
    --reader-text: #1e293b;
    --card-bg: #ffffff;
    --border-color: #e2e8f0;
    --sidebar-bg: #ffffff;
    --active-item-bg: #f1f5f9;
    --active-item-text: #0f172a;
    --toolbar-bg: #ffffff;
}

body.theme-sepia {
    --reader-bg: #f4ecd8;
    --reader-text: #433422;
    --card-bg: #faf4e8;
    --border-color: #e6d8b8;
    --sidebar-bg: #eadfb4;
    --active-item-bg: #dfd29e;
    --active-item-text: #2c1e11;
    --toolbar-bg: #eadfb4;
}

body.theme-dark {
    --reader-bg: #0f172a;
    --reader-text: #cbd5e1;
    --card-bg: #1e293b;
    --border-color: #334155;
    --sidebar-bg: #0b0f19;
    --active-item-bg: #1e293b;
    --active-item-text: #ffffff;
    --toolbar-bg: #0b0f19;
}

/* Sidebar / Índice */
.book-sidebar {
    width: 320px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 160px); /* Ocupa la altura restante visible */
    position: sticky;
    top: 160px; /* Queda fija justo bajo el header en escritorio */
    z-index: 100;
    transition: transform 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h3 {
    font-size: 1.15rem;
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    margin: 0;
    color: var(--reader-text);
}

.close-sidebar-btn {
    display: none;
    background: none;
    border: none;
    font-size: 1.4rem;
    color: var(--reader-text);
    cursor: pointer;
}

.sidebar-scrollport {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0.5rem;
}

/* Nivel de navegación do índice */
.book-index-nav {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.index-group {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.group-title {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--reader-text);
    opacity: 0.6;
    padding: 0.5rem 1rem 0.2rem;
    margin: 0;
}

.index-group ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.index-item {
    display: flex;
    align-items: center;
    padding: 0.6rem 1rem;
    font-size: 0.92rem;
    color: var(--reader-text);
    text-decoration: none;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    transition: background-color 0.2s, color 0.2s;
    line-height: 1.3;
}

.index-item:hover {
    background: var(--active-item-bg);
    opacity: 0.9;
}

.index-item.active {
    background: var(--active-item-bg);
    color: var(--active-item-text);
    font-weight: 600;
}

.chapter-num {
    font-family: 'Montserrat', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    opacity: 0.6;
    margin-right: 0.6rem;
    min-width: 20px;
    display: inline-block;
}

/* Área de lectura */
.book-reading-viewport {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Toolbar (Estática, hace scroll con el texto de lectura de forma natural) */
.reading-toolbar {
    background: var(--toolbar-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 50;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    margin-bottom: 1rem; /* Separación limpia con respecto al inicio del texto */
}

.toolbar-left, .toolbar-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.toggle-sidebar-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--reader-text);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    display: none; /* Oculto en escritorio (la barra lateral ya es visible) */
    align-items: center;
    gap: 0.4rem;
    transition: background-color 0.2s, border-color 0.2s;
}

.toggle-sidebar-btn:hover {
    background: var(--active-item-bg);
}

.current-category-badge {
    font-size: 0.8rem;
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--active-item-bg);
    color: var(--active-item-text);
    padding: 0.35rem 0.8rem;
    border-radius: 20px;
    opacity: 0.9;
}

.control-group {
    display: flex;
    align-items: center;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 2px;
}

.tool-btn {
    background: none;
    border: none;
    color: var(--reader-text);
    padding: 0.35rem 0.75rem;
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.tool-btn:hover {
    background: var(--active-item-bg);
}

.theme-selectors {
    gap: 6px;
    padding: 4px 8px;
}

.theme-btn {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
}

.theme-btn:hover {
    transform: scale(1.1);
}

.theme-btn.active {
    border-color: var(--reader-text);
    transform: scale(1.1);
}

.theme-light-btn {
    background: #f8fafc;
    box-shadow: inset 0 0 0 1px #cbd5e1;
}

.theme-sepia-btn {
    background: #f4ecd8;
    box-shadow: inset 0 0 0 1px #e6d8b8;
}

.theme-dark-btn {
    background: #0f172a;
    box-shadow: inset 0 0 0 1px #334155;
}

/* Páxina do Libro */
.book-page {
    flex: 1;
    max-width: 820px;
    width: 100%;
    margin: 0 auto;
    padding: 3rem 2rem 5rem;
    box-sizing: border-box;
}

.book-page-content {
    opacity: 1;
    transition: opacity 0.15s ease;
}

/* Tipografía de Lectura */
.book-title {
    font-family: 'Montserrat', sans-serif;
    font-weight: 800;
    font-size: 2.2rem;
    line-height: 1.25;
    margin-bottom: 2rem;
    color: var(--reader-text);
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 1.5rem;
}

.chapter-indicator {
    display: block;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.book-subtitle {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 1.35rem;
    margin-top: 2.5rem;
    margin-bottom: 1rem;
    color: var(--reader-text);
}

.book-paragraph {
    font-family: 'Merriweather', Georgia, serif;
    line-height: 1.8;
    margin-bottom: 1.5rem;
    text-align: justify;
}

/* Axustes de tamaño de letra */
.font-small .book-paragraph {
    font-size: 1rem;
}
.font-medium .book-paragraph {
    font-size: 1.12rem;
}
.font-large .book-paragraph {
    font-size: 1.28rem;
}

/* Ilustracións intercaladas */
.book-illustration {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.75rem;
    margin: 2rem auto;
    max-width: 520px;
    width: 100%;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.02);
    box-sizing: border-box;
}

.book-illustration img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    display: block;
    margin: 0 auto;
    cursor: zoom-in;
    transition: transform 0.2s ease;
}

.book-illustration img:hover {
    transform: scale(1.01);
}

.book-illustration .image-caption {
    font-size: 0.82rem;
    color: var(--reader-text);
    opacity: 0.75;
    margin-top: 0.75rem;
    line-height: 1.4;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
}

/* Navegación inferior */
.chapter-navigation {
    display: flex;
    justify-content: space-between;
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.nav-chapter-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--reader-text);
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-chapter-btn:hover {
    background: var(--active-item-bg);
    border-color: var(--reader-text);
}

/* Botón flotante móbil */
.mobile-index-trigger {
    display: none;
    position: fixed;
    bottom: 25px;
    right: 25px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50px;
    padding: 0.8rem 1.5rem;
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    cursor: pointer;
    align-items: center;
    gap: 0.5rem;
}

/* Loading state */
.book-page-loading {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 5rem 0;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* =====================================================
   MEDIAS QUERIES / RESPONSIVE
   ===================================================== */
@media (max-width: 992px) {
    .book-reader-layout {
        margin-top: 120px; /* Header móvil más bajo (80px + 40px) */
    }
    
    .reading-toolbar {
        padding: 0.8rem 1rem;
        margin-bottom: 0.5rem;
    }
    
    .book-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 10px 30px rgba(0,0,0,0.15);
        z-index: 2000;
    }
    
    .book-sidebar.open {
        transform: translateX(0);
    }
    
    .close-sidebar-btn {
        display: block;
    }
    
    .mobile-index-trigger {
        display: flex;
    }
    
    .toggle-sidebar-btn {
        display: flex; /* Se muestra en móvil para abrir el índice */
    }
}

@media (max-width: 600px) {
    .current-category-badge {
        display: none;
    }
    .book-page {
        padding: 1.5rem 1rem 4rem;
    }
    .book-title {
        font-size: 1.6rem;
        margin-bottom: 1.5rem;
        padding-bottom: 1rem;
    }
    .book-paragraph {
        text-align: left;
    }
    .chapter-navigation {
        flex-direction: column;
        gap: 1rem;
    }
    .nav-chapter-btn {
        width: 100%;
        text-align: center;
    }
}
