/* ОБЩИЕ СТИЛИ  */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #f9f5eb;

    /* body flex, чтобы подвал всегда был внизу */
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ШАПКА САЙТА */
.site-header {
    background: #f8f1e3;
    border-bottom: 4px solid #d97706;
    position: relative;
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    padding: 15px 55px;
    gap: 40px;
    justify-content: flex-start;
}

/* Логотип */
.logo img {
    max-height: 85px;
    width: auto;
}

/* Иконка слева от названия категории */
.category-icon {
    height: 65px;
    width: 50px;
    object-fit: contain;
    margin-right: 12px;
    border: none !important;
    outline: none !important;
    flex-shrink: 0;
}

/* КАРТОЧКИ КАТЕГОРИЙ  */
.category-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    flex: 1;
    justify-content: center;
}

.category-card {
    background: #d97706;
    color: white;
    padding: 14px 20px;
    border-radius: 10px;
    text-align: center;
    align-items: center;
    justify-content: center;
    min-width: 160px;
    max-width: 200px;
    height: 68px;
    font-weight: 600;
    font-size: 15.5px;
    transition: all 0.3s ease;
    cursor: pointer;
    box-shadow: 0 5px 12px rgba(0,0,0,0.1);
    position: relative;
    display: flex;
    border: none !important;
    outline: none !important;
    overflow: visible;
    z-index: 1;
}

.category-card:hover {
    background: #b45309;
    transform: translateY(-4px);
    z-index: 10;
}

/* ВЫПАДАЮЩИЙ СПИСОК КНИГ */
.category-card ul {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    color: #222;
    padding: 12px 0;
    margin-top: 8px;
    border-radius: 10px;
    box-shadow: 0 12px 25px rgba(0,0,0,0.18);
    min-width: 240px;
    list-style: none;
    z-index: 12000;
    text-align: left;
}

.category-card:hover ul {
    display: block;
}

.category-card ul li {
    padding: 10px 22px;
    border-bottom: 1px solid #eee;
}

.category-card ul li:last-child {
    border-bottom: none;
}

.category-card ul li:hover {
    background: #f8f4eb;
}

/*  ОСНОВНОЙ КОНТЕНТ  */
.main-content {
    max-width: 1400px;
    margin: 40px auto;
    padding: 0 20px;
    display: flex;
    gap: 30px;
    flex: 1;
}

/* Левая колонка с тегами */
.sidebar {
    width: 260px;
    background: white;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    height: fit-content;
    margin-left: -20px;
}

.sidebar h3 {
    margin-bottom: 15px;
    color: #d97706;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    background: #f4e9d0;
    color: #444;
    padding: 6px 14px;
    border-radius: 30px;
    font-size: 14px;
    text-decoration: none;
    transition: 0.2s;
}

.tag:hover {
    background: #d97706;
    color: white;
}

/* Центральная часть */
.content {
    flex: 1;
}

/* ПОДВАЛ  */
.site-footer {
    background: #333;
    color: #ddd;
    text-align: center;
    padding: 35px 20px 25px;
    width: 100%;
    margin-top: auto;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
}

.site-footer a {
    color: #f8c66d;
    text-decoration: none;
    margin: 0 8px;
}

.site-footer a:hover {
    color: #fff;
    text-decoration: underline;
}

.site-footer p {
    margin: 8px 0;
    font-size: 15px;
}

/* МОБИЛЬНОЕ МЕНЮ */
.menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 30px;
    height: 25px;
    background: transparent;
    border: none;
    cursor: pointer;
}

.menu-toggle span {
    width: 100%;
    height: 4px;
    background: #d97706;
    transition: 0.3s;
}

/* Анимация гамбургера - крестик */
.menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(6px, 5px);
}

.menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* Мобильное меню открывается под шапкой */
.category-grid.active {
    display: flex !important;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: #f8f1e3;
    padding: 20px;
    z-index: 1000;
    box-shadow: 0 10px 15px rgba(0,0,0,0.15);
}

/* АДАПТИВНОСТЬ  */
@media (max-width: 992px) {
    .menu-toggle {
        display: flex;
    }

    .header-container {
        padding: 15px 10px !important;
        gap: 15px;
        justify-content: space-between;
    }

    .category-grid {
        display: none;
        gap: 8px;
        padding: 15px 8px 25px;
        width: 100% !important;
    }

    .category-card {
        min-width: 48% !important;
        max-width: none;
        padding: 14px 16px;
        font-size: 14px;
        height: auto;
        margin: 6px 0;
    }

    .main-content {
        padding: 20px 10px !important;
        margin: 20px 0;
    }

    .sidebar {
        width: 100% !important;
        margin-left: 0 !important;
        display: none !important;
    }

    body {
        overflow-x: hidden;
    }

    /* Мобильный фильтр по тегам */
    .mobile-tags {
        margin-top: 25px;
        padding-top: 20px;
        border-top: 1px solid #e5d5b8;
    }

    .mobile-tags h3 {
        color: #d97706;
        margin-bottom: 12px;
        font-size: 16px;
    }
}

/* Скрываем мобильный фильтр по тегам на компьютере */
.mobile-tags {
    display: none;
}
@media (max-width: 992px) {
    .mobile-tags {
        display: block;
    }
}

/*  СТРАНИЦА КНИГИ  */
.book-page {
    max-width: 1200px;
    margin: 40px auto;
    padding: 0 20px;
}

.book-container {
    display: flex;
    gap: 50px;
    background: #fff;
    padding: 50px 45px;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.09);
    flex-wrap: wrap;
    justify-content: center;
}

/* Обложка слева */
.book-cover {
    flex: 0 0 300px;
    text-align: center;
}

/* Левая колонка (обложка + теги) */
.book-left-column {
    flex: 0 0 320px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.book-cover img {
    width: 100%;
    max-width: 300px;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

/* Блок фильтра по тегам под обложкой */
.book-tags-sidebar {
    background: #f9f5eb;
    padding: 25px;
    border-radius: 12px;
}

.book-tags-sidebar h3 {
    color: #d97706;
    margin-bottom: 18px;
    font-size: 1.25rem;
}

.book-tags-sidebar .tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Теги конкретной книги (под заголовком) */
.book-tags {
    margin: 18px 0 30px;
}

.book-tags .tag {
    display: inline-block;
    background: #d97706;
    color: white;
    padding: 6px 16px;
    border-radius: 30px;
    font-size: 14px;
    margin-right: 8px;
    margin-bottom: 8px;
    text-decoration: none;
}

.book-tags .tag:hover {
    background: #b35c00;
}

/* Правая колонка с информацией */
.book-info {
    flex: 1;
    min-width: 320px;
    max-width: 700px;
}

.book-info h1 {
    font-size: 2.4rem;
    color: #d97706;
    margin-bottom: 16px;
    line-height: 1.15;
}

/* Теги */
.book-tags {
    margin: 20px 0 30px;
}

.book-tags .tag {
    display: inline-block;
    background: #f4e9d0;
    color: #444;
    padding: 7px 17px;
    border-radius: 30px;
    font-size: 14.5px;
    margin-right: 9px;
    margin-bottom: 8px;
    text-decoration: none;
}

.book-tags .tag:hover {
    background: #d97706;
    color: white;
}

/* Библиографическое описание */
.bib-description {
    background: #f9f5eb;
    padding: 24px 28px;
    border-radius: 12px;
    margin: 30px 0;
    font-style: italic;
    line-height: 1.75;
    color: #444;
}

/* Ссылка на ирбис */
.irbis-link {
    display: inline-block;
    background: #d97706;
    color: white;
    padding: 14px 28px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    margin: 10px 0 35px;
    transition: all 0.2s;
}

.irbis-link:hover {
    background: #b35c00;
    transform: translateY(-2px);
}

/* Заголовки разделов */
.book-info h2 {
    color: #d97706;
    margin-top: 40px;
    margin-bottom: 14px;
    font-size: 1.55rem;
    border-bottom: 3px solid #f4e9d0;
    padding-bottom: 8px;
}

/* Адаптивность */
@media (max-width: 868px) {
    .book-container {
        padding: 35px 25px;
        gap: 30px;
    }

    .book-cover {
        flex: 0 0 240px;
    }

    .book-info h1 {
        font-size: 2rem;
    }

    .book-left-column {
        flex: none;
        align-items: center;
    }
}

@media (max-width: 600px) {
    .book-cover {
        flex: none;
        max-width: 220px;
        margin: 0 auto 30px;
    }
}

/* БЛОК ПОДЕЛИТЬСЯ  */
.share-block {
    margin-top: 50px;
    padding-top: 30px;
    border-top: 2px solid #f4e9d0;
}

.share-block h3 {
    color: #d97706;
    margin-bottom: 18px;
    font-size: 1.4rem;
}

.share-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.share-btn {
    padding: 12px 22px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.share-btn:hover {
    transform: translateY(-2px);
}

.vk { background: #4a76a8; color: white; }
.telegram { background: #229ed9; color: white; }
.whatsapp { background: #25d366; color: white; }
.copy {
    background: #666;
    color: white;
    border: none;
    cursor: pointer;
}

.copy:hover {
    background: #555;
}


/*  КОММЕНТАРИИ  */

.comments-section {
    margin-top: 14px;
    padding-top: 0px;
    border-top: 2px solid #f4e9d0;
}

.comments-section h2 {
    color: #d97706;
    margin-bottom: 20px;
}

.comment-form .form-group {
    margin-bottom: 16px;
}

.comment-form label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}

.comment-form input,
.comment-form textarea {
    width: 100%;
    padding: 11px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 15px;
}

.comment-form textarea {
    min-height: 110px;
    resize: vertical;
}

.submit-comment-btn {
    background: #d97706;
    color: white;
    border: none;
    padding: 13px 26px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.submit-comment-btn:hover {
    background: #b35c00;
}

.comment {
    background: #f9f5eb;
    padding: 16px 20px;
    border-radius: 10px;
    margin-bottom: 14px;
}

.comment strong {
    color: #d97706;
}

.comment small {
    color: #777;
    margin-left: 8px;
}

.comment p {
    margin-top: 8px;
    line-height: 1.6;
}

/* СВОРАЧИВАЕМЫЕ БЛОКИ  */
.collapsible {
    border: 1px solid #e8d9c2;
    border-radius: 10px;
    margin-bottom: 15px;
    background: #fff;
    overflow: hidden;
}

.collapsible summary {
    background: #f9f5eb;
    padding: 16px 22px;
    font-size: 1.15rem;
    font-weight: 600;
    color: #d97706;
    cursor: pointer;
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.collapsible summary::-webkit-details-marker {
    display: none;
}

.collapsible summary::after {
    content: '▼';
    font-size: 0.9rem;
    transition: transform 0.3s ease;
}

.collapsible[open] summary::after {
    transform: rotate(180deg);
}

.collapsible-content {
    padding: 20px 22px;
    line-height: 1.7;
}

/* МОДАЛЬНОЕ ОКНО */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.modal-window {
    background: white;
    padding: 35px 40px;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    max-width: 420px;
    width: 90%;
    text-align: center;
}

.modal-text {
    font-size: 18px;
    color: #333;
    margin-bottom: 30px;
    line-height: 1.5;
}

.modal-btn {
    background: #d97706;
    color: white;
    border: none;
    padding: 14px 40px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.modal-btn:hover {
    background: #b35c00;
}

/* СТИЛИ ДЛЯ СТРАНИЦЫ ТЕГОВ И РАЗДЕЛА ОБУЧЕНИЯ */
.books-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 25px;
    margin-top: 25px;
}

.book-card-item {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 15px;
    width: calc(25% - 20px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
    text-align: center;
    position: relative;
    transition: transform 0.2s ease;
}

.book-card-item:hover {
    transform: translateY(-4px);
}

.book-card-item a {
    text-decoration: none;
    color: #333;
}

.tag-book-cover {
    width: 100%;
    max-height: 220px;
    object-fit: contain;
    margin-bottom: 12px;
    border-radius: 4px;
}

.book-card-item h4 {
    font-size: 1rem;
    margin-bottom: 10px;
    font-weight: 600;
}

.views-badge {
    display: inline-block;
    font-size: 0.85rem;
    color: #718096;
    background: #edf2f7;
    padding: 2px 8px;
    border-radius: 12px;
}

.sort-links a {
    display: inline-block;
    color: #4a5568;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 4px;
    background: #fff;
    border: 1px solid #cbd5e0;
}

.sort-links a.active-sort {
    background: #d97706;
    color: #fff;
    border-color: #d97706;
}

/* Адаптивность под планшеты и мобилки для сетки тегов */
@media (max-width: 1024px) {
    .book-card-item { width: calc(33.33% - 20px); }
}
@media (max-width: 768px) {
    .book-card-item { width: calc(50% - 20px); }
}
@media (max-width: 480px) {
    .book-card-item { width: 100%; }
}