/* Сброс и базовые стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Фоновая структура */
body {
    background-color: #050505;
    color: #aaa;
    line-height: 1.6;
    background-image: 
        linear-gradient(rgba(5, 5, 5, 0.95), rgba(5, 5, 5, 0.95)),
        url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><rect width="100" height="100" fill="%23050505"/><path d="M0,0 L100,100" stroke="%23111111" stroke-width="0.3"/><path d="M100,0 L0,100" stroke="%23111111" stroke-width="0.3"/></svg>');
    min-height: 100vh;
    text-shadow: 0 1px 2px rgba(0,0,0,0.7);
}

.content-wrapper {
    max-width: 850px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Логотип вверху страницы */
.header-logo {
    background-color: rgba(8, 8, 8, 0.98);
    border-bottom: 2px solid #3a1f0a;
    padding: 20px 0;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.8);
}

.site-title {
    color: #8b4513;
    font-size: 2.8rem;
    margin-bottom: 5px;
    text-shadow: 0 0 15px rgba(139, 69, 19, 0.3);
    letter-spacing: 1px;
    font-weight: 300;
}

.site-subtitle {
    color: #888;
    font-size: 1.1rem;
    font-style: italic;
}

/* Структурированная навигация внутри полотна текста */
.structured-navigation {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

@media (max-width: 650px) {
    .structured-navigation {
        grid-template-columns: 1fr;
    }
}

.nav-group {
    background-color: rgba(20, 15, 10, 0.8);
    padding: 20px;
    border-radius: 3px;
    border: 1px solid #2a1a0a;
    border-left: 4px solid #5a2c0e;
    transition: transform 0.3s, box-shadow 0.3s;
}

.nav-group:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
}

.nav-group-title {
    color: #a0522d;
    margin-bottom: 15px;
    font-size: 1.3rem;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(139, 69, 19, 0.3);
    text-align: center;
}

.nav-group-list {
    list-style: none;
    padding: 0;
}

.nav-group-list li {
    margin-bottom: 8px;
    position: relative;
    padding-left: 0;
}

.nav-group-list li:before {
    display: none;
}

.nav-group-list a {
    color: #b08968;
    text-decoration: none;
    display: block;
    padding: 8px 12px;
    border-radius: 3px;
    background-color: rgba(59, 29, 9, 0.2);
    border: 1px solid transparent;
    transition: all 0.3s;
}

.nav-group-list a:hover {
    color: #d4a276;
    background-color: rgba(139, 69, 19, 0.15);
    border: 1px solid rgba(139, 69, 19, 0.4);
    transform: translateX(5px);
}

/* Основной контент */
main {
    padding: 40px 0;
}

.page-container {
    background-color: rgba(12, 12, 12, 0.9);
    border-radius: 3px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.9);
    overflow: visible;
    border: 1px solid #222;
}

/* Простой список якорных ссылок на основном полотне */
.text-anchor-list {
    background-color: rgba(20, 15, 10, 0.8);
    padding: 20px;
    border-radius: 3px;
    margin: 25px 0;
    border-left: 4px solid #5a2c0e;
    border-top: 1px solid #2a1a0a;
    border-bottom: 1px solid #2a1a0a;
}

.text-anchor-list h3 {
    color: #a0522d;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.text-anchor-list ul {
    list-style-type: none;
    padding-left: 0;
}

.text-anchor-list li {
    margin-bottom: 8px;
    padding-left: 15px;
    position: relative;
}

.text-anchor-list li:before {
    content: "»";
    color: #8b4513;
    position: absolute;
    left: 0;
    font-weight: bold;
}

.text-anchor-list a {
    color: #b08968;
    text-decoration: none;
    transition: all 0.3s;
}

.text-anchor-list a:hover {
    color: #d4a276;
    text-decoration: none;
    text-shadow: 0 0 5px rgba(180, 120, 70, 0.5);
}

/* Секции */
.section {
    padding: 30px;
    border-bottom: 1px solid #1a1a1a;
    position: relative;
}

.section:last-of-type {
    border-bottom: none;
}

.section h2 {
    color: #8b4513;
    font-size: 1.8rem;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #3a1f0a;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.section h2.anchor-target {
    padding-top: 60px;
    margin-top: -40px;
}

.section p {
    margin-bottom: 15px;
    text-align: justify;
    color: #bbb;
}

/* Стили для span с tooltip */
.word-tooltip {
    position: relative;
    color: #b08968;
    cursor: help;
    border-bottom: 1px dotted #5a2c0e;
    font-weight: bold;
    display: inline-block;
}

.tooltip-text {
    visibility: hidden;
    width: 300px;
    background-color: rgba(15, 10, 5, 0.98);
    color: #ccc;
    text-align: left;
    border-radius: 3px;
    padding: 15px;
    position: absolute;
    z-index: 1001;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    opacity: 0;
    transition: opacity 0.3s, visibility 0.3s;
    border: 1px solid #3a1f0a;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.9);
    font-weight: normal;
    font-size: 0.9rem;
    line-height: 1.5;
    pointer-events: none;
}

.tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: #3a1f0a transparent transparent transparent;
}

.word-tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* Стили для якорных ссылок в тексте */
.text-anchor {
    color: #b08968;
    text-decoration: none;
    border-bottom: 1px dashed #5a2c0e;
    transition: all 0.3s;
}

.text-anchor:hover {
    color: #d4a276;
    border-bottom: 1px solid #8b4513;
    text-shadow: 0 0 5px rgba(180, 120, 70, 0.3);
}

/* Футер */
footer {
    background-color: rgba(8, 8, 8, 0.98);
    padding: 25px 0;
    text-align: center;
    border-top: 2px solid #3a1f0a;
    margin-top: 50px;
    color: #666;
}

footer p {
    color: #666;
    margin-bottom: 10px;
}

/* Дополнительные стили для мрачности */
.section strong {
    color: #8b7355;
    font-weight: 600;
}

.section h3 {
    color: #a0522d;
    border-left: 3px solid #5a2c0e;
    padding-left: 10px;
    margin-top: 25px;
    margin-bottom: 15px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

/* Стили для списков в контенте */
.section ul:not(.text-anchor-list ul):not(.nav-group-list) {
    margin-left: 25px;
    margin-bottom: 15px;
}

.section ul:not(.text-anchor-list ul):not(.nav-group-list) li {
    margin-bottom: 8px;
    color: #bbb;
    position: relative;
    padding-left: 5px;
}

.section ul:not(.text-anchor-list ul):not(.nav-group-list) li:before {
    content: "•";
    color: #8b4513;
    position: absolute;
    left: -15px;
}

/* Адаптивность */
@media (max-width: 900px) {
    .content-wrapper {
        max-width: 95%;
        padding: 0 15px;
    }
    
    .site-title {
        font-size: 2.2rem;
    }
    
    .section, .nav-group {
        padding: 20px;
    }
    
    /* Адаптивные стили для tooltip на мобильных */
    .tooltip-text {
        width: 280px;
        max-width: 90vw;
        left: 50%;
        transform: translateX(-50%);
    }
}

@media (max-width: 600px) {
    .content-wrapper {
        max-width: 100%;
        padding: 0 10px;
    }
    
    .site-title {
        font-size: 1.8rem;
    }
    
    .section h2 {
        font-size: 1.5rem;
    }
    
    /* Улучшенные стили для tooltip на маленьких экранах */
    .tooltip-text {
        width: 250px;
        font-size: 0.85rem;
        padding: 12px;
    }
    
    .structured-navigation {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 400px) {
    .tooltip-text {
        width: 220px;
        left: 0;
        transform: translateX(0);
    }
    
    .tooltip-text::after {
        left: 20px;
    }
}

/* Гарантия, что tooltip всегда будет виден */
.section p, .section h3, .section li {
    overflow: visible !important;
}

/* Дополнительные тени для мрачности */
.nav-group, .text-anchor-list, .section {
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}

/* Эффект старинного пергамента для текстовых блоков */
.section, .text-anchor-list, .nav-group {
    background-image: 
        linear-gradient(rgba(20, 15, 10, 0.1), rgba(20, 15, 10, 0.1)),
        url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" opacity="0.03"><filter id="noise"><feTurbulence type="fractalNoise" baseFrequency="0.9" numOctaves="3" stitchTiles="stitch"/></filter><rect width="100" height="100" filter="url(%23noise)"/></svg>');
}

/* Кнопка возврата на главную страницу */
.back-to-home {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1000;
}

.back-to-home-btn {
    background-color: rgba(20, 15, 10, 0.9);
    color: #b08968;
    border: 1px solid #5a2c0e;
    padding: 10px 15px;
    border-radius: 3px;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.back-to-home-btn:hover {
    background-color: rgba(139, 69, 19, 0.2);
    color: #d4a276;
    border-color: #8b4513;
    transform: translateX(-3px);
}

/* SVG иконка дома вместо FontAwesome */
.home-icon {
    width: 16px;
    height: 16px;
    fill: #b08968;
    transition: fill 0.3s;
}

.back-to-home-btn:hover .home-icon {
    fill: #d4a276;
}

/* Адаптивность для кнопки */
@media (max-width: 900px) {
    .back-to-home {
        top: 15px;
        left: 15px;
    }
    
    .back-to-home-btn {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
}

@media (max-width: 600px) {
    .back-to-home {
        top: 10px;
        left: 10px;
    }
    
    .back-to-home-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
    }
    
    .back-to-home-btn span {
        display: none; /* На маленьких экранах показываем только иконку */
    }
}

/* Стили для таблицы */
.content-table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-size: 0.95rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid #3a1f0a;
}

.content-table thead tr {
    background-color: rgba(139, 69, 19, 0.3);
    text-align: left;
    border-bottom: 2px solid #5a2c0e;
}

.content-table th {
    color: #d4a276;
    padding: 15px 20px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

.content-table tbody tr {
    border-bottom: 1px solid #2a1a0a;
    transition: background-color 0.3s;
}

.content-table tbody tr:nth-of-type(even) {
    background-color: rgba(20, 15, 10, 0.4);
}

.content-table tbody tr:nth-of-type(odd) {
    background-color: rgba(30, 25, 20, 0.4);
}

.content-table tbody tr:hover {
    background-color: rgba(139, 69, 19, 0.15);
}

.content-table td {
    padding: 15px 20px;
    vertical-align: top;
    color: #bbb;
    line-height: 1.5;
}

.content-table td:first-child {
    color: #b08968;
    font-weight: 600;
    width: 30%;
    border-right: 1px solid #2a1a0a;
    background-color: rgba(15, 10, 5, 0.2);
}

.content-table td:last-child {
    width: 70%;
}

/* Адаптивность для таблицы */
@media (max-width: 700px) {
    .content-table {
        display: block;
        overflow-x: auto;
    }
    
    .content-table th,
    .content-table td {
        padding: 12px 15px;
        font-size: 0.9rem;
    }
    
    .content-table td:first-child {
        width: 35%;
    }
    
    .content-table td:last-child {
        width: 65%;
    }
}

@media (max-width: 500px) {
    .content-table {
        font-size: 0.85rem;
    }
    
    .content-table th,
    .content-table td {
        padding: 10px 12px;
    }
}

/* Заголовок для таблицы */
.table-title {
    color: #a0522d;
    margin: 30px 0 15px 0;
    font-size: 1.4rem;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(139, 69, 19, 0.4);
}

/* Контейнер для таблицы с дополнительными стилями */
.table-container {
    margin: 25px 0;
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid #3a1f0a;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.6);
}

.table-container .content-table {
    margin: 0;
    box-shadow: none;
    border: none;
}

/* Стили для изображений */
.content-image {
    width: 100%;
    max-width: 800px;
    height: auto;
    border-radius: 5px;
    border: 1px solid #3a1f0a;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.7);
    margin: 20px 0;
    display: block;
    transition: transform 0.3s, box-shadow 0.3s;
}

.content-image:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.8);
}

/* Контейнер для изображений */
.image-container {
    margin: 25px 0;
    text-align: center;
    position: relative;
}

/* Подпись к изображению */
.image-caption {
    color: #b08968;
    font-size: 0.9rem;
    font-style: italic;
    margin-top: 10px;
    padding: 8px 15px;
    background-color: rgba(20, 15, 10, 0.6);
    border-radius: 3px;
    border-left: 3px solid #5a2c0e;
    display: inline-block;
    max-width: 80%;
}

/* Галерея изображений (несколько картинок в ряд) */
.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin: 25px 0;
}

.gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 5px;
    border: 1px solid #3a1f0a;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s, box-shadow 0.3s;
}

.gallery-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.7);
}

.gallery-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
    transition: transform 0.5s;
}

.gallery-item:hover .gallery-image {
    transform: scale(1.05);
}

.gallery-caption {
    padding: 10px;
    background-color: rgba(15, 10, 5, 0.9);
    color: #bbb;
    font-size: 0.85rem;
    text-align: center;
}

/* Изображения с обтеканием текстом */
.image-left {
    float: left;
    max-width: 300px;
    margin: 10px 20px 10px 0;
}

.image-right {
    float: right;
    max-width: 300px;
    margin: 10px 0 10px 20px;
}

/* Очистка float */
.clearfix::after {
    content: "";
    display: table;
    clear: both;
}

/* Фрейм для изображений с рамкой и фоном */
.image-frame {
    border: 2px solid #5a2c0e;
    padding: 10px;
    background-color: rgba(25, 20, 15, 0.7);
    border-radius: 8px;
    margin: 20px 0;
    display: inline-block;
    max-width: 100%;
}

.image-frame img {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Адаптивность для изображений */
@media (max-width: 700px) {
    .content-image {
        max-width: 100%;
    }
    
    .image-left,
    .image-right {
        float: none;
        max-width: 100%;
        margin: 15px 0;
    }
    
    .image-gallery {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 15px;
    }
    
    .gallery-image {
        height: 180px;
    }
}

@media (max-width: 500px) {
    .image-gallery {
        grid-template-columns: 1fr;
    }
    
    .gallery-image {
        height: 200px;
    }
    
    .image-caption {
        font-size: 0.85rem;
        max-width: 90%;
    }
}

/* Эффект старинной бумаги для изображений */
.vintage-effect {
    position: relative;
    overflow: hidden;
}

.vintage-effect::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        rgba(139, 69, 19, 0.1),
        rgba(139, 69, 19, 0.05),
        rgba(139, 69, 19, 0.1)
    );
    pointer-events: none;
    z-index: 1;
    border-radius: 5px;
}

/* Затемнение изображений для лучшей читаемости текста на них */
.darken-image {
    filter: brightness(0.8) contrast(1.1);
}

.darken-image:hover {
    filter: brightness(0.85) contrast(1.1);
}