/* Herzen 3D Reader Stylesheet v2.2 (Mobile optimized, centered loader) */
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;500;600;700;800&family=Playfair+Display:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

:root {
    /* Официальные цвета РГПУ им. А. И. Герцена по брендбуку в современном премиальном прочтении */
    --cobalt: #003087;        /* Pantone 287 C (Основной кобальт) */
    --cobalt-dark: #010714;   /* Космический кобальт (очень глубокий благородный синий) */
    --cobalt-light: #0055ff;  /* Яркий акцентный кобальт (для современного свечения) */
    --gold: #dfba73;          /* Pantone 8643 C в прочтении жидкого шампань-золота */
    --gold-light: #f7e7c4;    /* Светлое платиновое золото */
    --gold-dark: #b58c3d;     /* Богатое темное золото */
    --bg-dark: #020813;       /* Ультратемный фон сцены */
    
    /* Элементы Glassmorphism на базе Pantone 287 C */
    --card-bg: rgba(1, 10, 31, 0.75);
    --card-border: rgba(223, 186, 115, 0.25);
    --text-light: #f7e7c4;
    --text-muted: #8a9fc4;
    
    --font-header: 'Playfair Display', serif;
    --font-ui: 'Manrope', sans-serif;
}

html, body {
    margin: 0; 
    padding: 0; 
    height: 100%; 
    overflow: hidden; 
    font-family: var(--font-ui); 
    box-sizing: border-box;
    background-color: var(--bg-dark);
}

.scene {
    width: 100%; 
    height: 100vh;
    height: 100dvh; /* Динамическая высота для мобильных браузеров */
    background: radial-gradient(circle at center, #002261 0%, #000817 100%);
    display: flex; 
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

/* Декоративное кобальтово-золотое интерактивное свечение на заднем плане */
.ambient-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 85vw;
    height: 85vh;
    background: radial-gradient(circle, rgba(0, 85, 255, 0.15) 0%, rgba(223, 186, 115, 0.03) 40%, rgba(138, 43, 226, 0.05) 70%, transparent 100%);
    z-index: 0;
    pointer-events: none;
    filter: blur(60px);
}

/* Тончайшая золотая нить прогресса чтения */
.reading-progress-wrapper {
    position: absolute;
    top: 80px;
    left: 0;
    width: 100%;
    height: 3px;
    z-index: 101;
}

.reading-progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, var(--gold-dark) 0%, var(--gold) 50%, var(--gold-light) 100%);
    box-shadow: 0 1px 8px rgba(223, 186, 115, 0.5);
    transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
}

.scroll-wrapper {
    flex-grow: 1; 
    width: 100%; 
    overflow: hidden; 
    display: flex;
    perspective: 2000px;
    z-index: 1;
}

.scroll-wrapper::-webkit-scrollbar { 
    width: 10px; 
    height: 10px; 
}
.scroll-wrapper::-webkit-scrollbar-track { 
    background: rgba(1, 10, 31, 0.8); 
}
.scroll-wrapper::-webkit-scrollbar-thumb { 
    background: rgba(223, 186, 115, 0.3); 
    border-radius: 5px; 
    border: 2px solid rgba(1, 10, 31, 0.8); 
}
.scroll-wrapper::-webkit-scrollbar-thumb:hover { 
    background: rgba(223, 186, 115, 0.6); 
}

.book-perspective {
    margin: auto;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    transform-origin: center center;
    transition: width 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), height 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    padding: 20px 0;
}

/* Мягкая напольная тень книги для создания 3D-объема */
.book-shadow-floor {
    position: absolute;
    bottom: -15px;
    left: 5%;
    width: 90%;
    height: 30px;
    background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.6) 0%, rgba(0, 0, 0, 0.2) 50%, transparent 80%);
    filter: blur(10px);
    z-index: -1;
    pointer-events: none;
}

#book {
    width: 100%;
    height: 100%;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6), 0 0 100px rgba(0, 85, 255, 0.08);
    position: relative;
}

/* ====================================================================
   ПРЕМИАЛЬНЫЙ ЭКРАН ЗАГРУЗКИ (КРУГОВОЙ ЗОЛОТОЙ СПИННЕР)
   ==================================================================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #020813;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.8s;
}

.loading-overlay.fade-out {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.spinner-box {
    position: relative;
    width: 150px;
    height: 150px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 25px;
}

.circle-loader {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid rgba(223, 186, 115, 0.15);
    border-top: 3px solid var(--gold);
    border-right: 3px solid var(--gold-light);
    animation: spin 1.2s cubic-bezier(0.5, 0, 0.5, 1) infinite;
    box-shadow: 0 0 20px rgba(223, 186, 115, 0.2);
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.spinner-logo {
    width: 85px;
    height: 85px;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2;
    filter: drop-shadow(0 0 8px rgba(223, 186, 115, 0.4));
}

.percent-box {
    position: absolute;
    bottom: -30px;
    color: var(--gold);
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 1px;
    font-family: var(--font-ui);
}

.loading-title {
    color: var(--gold);
    font-family: var(--font-header);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 1.5px;
    margin-top: 25px;
    margin-left: auto !important;
    margin-right: auto !important;
    text-transform: uppercase;
    text-shadow: 0 2px 10px rgba(223, 186, 115, 0.3);
    text-align: center !important;
    width: 100% !important;
    max-width: 90%;
    padding: 0 15px;
    box-sizing: border-box;
    display: block !important;
}

.loading-subtitle {
    color: var(--text-muted);
    font-size: 13px;
    letter-spacing: 1.2px;
    margin-top: 10px;
    margin-left: auto !important;
    margin-right: auto !important;
    font-weight: 400;
    text-align: center !important;
    width: 100% !important;
    max-width: 90%;
    padding: 0 15px;
    box-sizing: border-box;
    line-height: 1.5;
    display: block !important;
}

/* ====================================================================
   ШАПКА (HEADER)
   ==================================================================== */
.book-header {
    height: 80px;
    width: 100%;
    background: rgba(1, 10, 31, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    box-sizing: border-box;
    z-index: 100;
    position: relative;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    gap: 15px;
}

.header-logo-left {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s ease, filter 0.3s ease;
}

.header-logo-left:hover {
    transform: scale(1.08);
    filter: drop-shadow(0 0 10px rgba(223, 186, 115, 0.6));
}

.header-decor-left,
.header-decor-right {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(223, 186, 115, 0.4), transparent);
    margin: 0 15px;
}

.header-title-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    flex: 1;
    min-width: 0;
    max-width: 100%;
}

.uni-name {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 2px;
    color: var(--gold);
    text-transform: uppercase;
    margin-bottom: 3px;
    opacity: 0.9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-header h1 {
    margin: 0;
    font-family: var(--font-header);
    font-size: 1.35rem;
    font-weight: 700;
    color: #ffffff;
    background: linear-gradient(135deg, #ffffff 30%, var(--gold-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 0.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
}

.header-logo-right-placeholder {
    width: 50px;
    flex-shrink: 0;
}

/* ====================================================================
   ПОДВАЛ / ПАНЕЛЬ УПРАВЛЕНИЯ (CONTROLS)
   ==================================================================== */
.book-controls {
    height: 70px;
    width: 100%;
    background: rgba(1, 10, 31, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    box-sizing: border-box;
    z-index: 100;
    box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.4);
}

.zoom-controls,
.nav-controls,
.extra-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ctrl-btn {
    background: rgba(223, 186, 115, 0.08);
    border: 1px solid rgba(223, 186, 115, 0.2);
    color: var(--text-light);
    height: 40px;
    padding: 0 14px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: var(--font-ui);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
    text-decoration: none;
    user-select: none;
    white-space: nowrap;
}

.ctrl-btn:hover {
    background: rgba(223, 186, 115, 0.2);
    border-color: var(--gold);
    color: #ffffff;
    box-shadow: 0 0 12px rgba(223, 186, 115, 0.25);
    transform: translateY(-1px);
}

.ctrl-btn:active {
    transform: translateY(1px);
}

.ctrl-btn.active {
    background: linear-gradient(135deg, rgba(223, 186, 115, 0.35) 0%, rgba(0, 85, 255, 0.25) 100%);
    border-color: var(--gold);
    color: #ffffff;
    box-shadow: 0 0 15px rgba(223, 186, 115, 0.3);
}

.ctrl-btn-icon {
    padding: 0 10px;
}

/* Счетчик страниц */
.page-counter {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(223, 186, 115, 0.25);
    border-radius: 8px;
    height: 40px;
    padding: 0 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--gold-light);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.4);
}

.page-counter input {
    background: transparent;
    border: none;
    color: #ffffff;
    font-family: var(--font-ui);
    font-size: 0.95rem;
    font-weight: 700;
    width: 38px;
    text-align: center;
    outline: none;
    -moz-appearance: textfield;
}

.page-counter input::-webkit-outer-spin-button,
.page-counter input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.page-counter .divider {
    color: var(--gold-dark);
    font-weight: 400;
}

/* ====================================================================
   СТРАНИЦЫ КНИГИ И ЗАЩИТА КОНТЕНТА
   ==================================================================== */
.page {
    background-color: #fdfaf2;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

.page-content {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #fdfaf2;
}

.anti-copy-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10;
    background: transparent;
    cursor: default;
}

.protected-img {
    pointer-events: none;
    -webkit-user-drag: none;
    user-select: none;
}

/* ====================================================================
   СВЕТЛАЯ ТЕМА (LIGHT THEME)
   ==================================================================== */
html[data-theme="light"] {
    --bg-dark: #dcd5c9;
    --card-bg: rgba(248, 244, 236, 0.94);
    --card-border: rgba(0, 48, 135, 0.18);
    --text-light: #0a1628;
    --text-muted: #2c3e6b;
}

html[data-theme="light"] .scene {
    background: radial-gradient(circle at 35% 45%, #c2d4eb 0%, #d8d0c4 100%);
}

html[data-theme="light"] .ambient-glow {
    background: radial-gradient(circle, rgba(0, 85, 210, 0.07) 0%, rgba(210, 175, 55, 0.03) 40%, transparent 100%);
    opacity: 0.8;
}

html[data-theme="light"] .loading-overlay {
    background: #d8d0c4;
}

html[data-theme="light"] .book-header,
html[data-theme="light"] .book-controls {
    background: rgba(240, 236, 228, 0.92);
    border-color: rgba(0, 48, 135, 0.14);
}

html[data-theme="light"] .ctrl-btn {
    background: rgba(0, 48, 135, 0.04);
    border-color: rgba(0, 48, 135, 0.14);
    color: #0a1628;
}

html[data-theme="light"] .ctrl-btn:hover {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.18) 0%, rgba(0, 48, 135, 0.12) 100%);
    border-color: rgba(212, 175, 55, 0.4);
    color: #000000;
}

html[data-theme="light"] .ctrl-btn.active {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.28) 0%, rgba(0, 48, 135, 0.18) 100%);
    border-color: rgba(212, 175, 55, 0.55);
    color: #0a1628;
}

html[data-theme="light"] .uni-name {
    color: var(--cobalt);
    opacity: 1;
}

html[data-theme="light"] .book-header h1 {
    background: none;
    -webkit-text-fill-color: var(--cobalt);
    color: var(--cobalt);
    text-shadow: none;
}

html[data-theme="light"] .page-counter {
    background: rgba(0, 48, 135, 0.06);
    border-color: rgba(0, 48, 135, 0.15);
}

html[data-theme="light"] .page-counter input,
html[data-theme="light"] .page-counter span {
    color: #0a1628;
}

/* ====================================================================
   АДАПТИВНОСТЬ ДЛЯ МОБИЛЬНЫХ УСТРОЙСТВ
   ==================================================================== */
/* ====================================================================
   АДАПТИВНОСТЬ ДЛЯ МОБИЛЬНЫХ УСТРОЙСТВ (В СТИЛЕ ПРОЕКТА «KNIGI»)
   ==================================================================== */
@media (max-width: 1024px) {
    /* Компактная центрированная шапка */
    .book-header {
        height: 56px;
        padding: 0 12px;
        display: flex;
        align-items: center;
        justify-content: center !important;
        text-align: center !important;
    }
    
    /* Полностью убираем логотип и декор в мобильной версии на смартфонах и планшетах */
    .header-logo-left,
    .header-decor-left,
    .header-decor-right,
    .header-logo-right-placeholder,
    .mobile-hide {
        display: none !important;
        visibility: hidden !important;
        width: 0 !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }
    
    .header-title-container {
        width: 100% !important;
        max-width: 100% !important;
        flex: 1 1 100% !important;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-align: center;
        margin: 0 auto !important;
        padding: 0 4px;
    }
    
    .uni-name {
        font-size: 0.65rem;
        letter-spacing: 0.8px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        width: 100%;
        max-width: 100%;
        text-align: center;
        margin-bottom: 2px;
    }
    
    .book-header h1 {
        font-size: 0.95rem;
        letter-spacing: 0.3px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        width: 100%;
        max-width: 100%;
        text-align: center;
    }
    
    /* Сдвиг линии прогресса под высоту мобильной шапки */
    .reading-progress-wrapper {
        top: 56px;
    }
    
    /* Корректировка панели управления */
    .book-controls {
        height: 60px;
        padding: 0 16px;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }
    
    /* Скрываем все лишние кнопки на мобильных: только Каталог, Назад, Вперед, Экран */
    #btn-drag-mode,
    #btn-zoom-in,
    #btn-zoom-out,
    #btn-first,
    #btn-last,
    #btn-theme,
    .page-counter {
        display: none !important;
    }
    
    /* Скрываем текст во всех кнопках управления, оставляя только крупные иконки */
    .ctrl-btn span {
        display: none !important;
    }
    
    .ctrl-btn {
        -webkit-appearance: none !important;
        -moz-appearance: none !important;
        appearance: none !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        height: 42px !important;
        min-width: 44px !important;
        padding: 0 12px !important;
        border-radius: 10px !important;
        gap: 0 !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        line-height: 1 !important;
    }
    
    /* Кнопки Назад и Вперед по центру с удобным интервалом для пальцев */
    .nav-controls {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 18px;
    }
    
    .nav-controls .ctrl-btn {
        min-width: 50px !important;
        height: 42px !important;
    }
    
    .zoom-controls,
    .extra-controls {
        display: flex;
        align-items: center;
    }
}

