/* ==========================================================================
   ОСНОВНОЙ КОНТЕНТ И МАКЕТ
   ========================================================================== */

/* Базовые фиксы без изменения основной структуры */
html, body {
    overflow-x: hidden;
    max-width: 100%;
}

/* Основной контейнер с центрированием */
.content-container {
    display: flex;
    gap: 1rem;
    padding-top: 2rem;
    padding-bottom: 2rem;
    align-items: flex-start;
    min-height: calc(100vh - 200px);
    max-width: 1200px; /* Фиксированная максимальная ширина */
    margin: 0 auto; /* Центрирование */
    width: 100%;
    box-sizing: border-box;
    padding-left: 1rem;
    padding-right: 1rem;
}

/* Основная область контента */
.site-main {
    flex: 1;
    max-width: 100%;
    width: 100%;
}

/* Обертка контента с сохранением отступов */
.content-wrapper {
    background-color: var(--color-bg-primary);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow-light);
    transition: all 0.3s ease;
    box-sizing: border-box;
    max-width: 100%;
    overflow: hidden;
}

/* Базовые стили для медиа */
img, video, iframe {
    max-width: 100%;
}

/* Улучшенная типографика */
.entry-content {
    font-size: 1.2rem;
    line-height: 1.8;
    color: var(--color-text-primary);
    max-width: 100%;
    overflow-wrap: break-word;
}

.entry-title {
    color: #d4af37;
}

/* Ограничение ширины контента */
.entry-content > * {
    max-width: var(--max-width-content, 100%);
    width: 100%;
}

/* Заголовки внутри контента */
.entry-content h2,
.entry-content h3,
.entry-content h4 {
    margin-top: 2.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e6dcbb;
}

/* Цитаты */
.entry-content blockquote {
    border-left: 4px solid var(--color-sky-base);
    padding-left: 1.5rem;
    margin: 2rem 0;
    font-style: italic;
    color: var(--color-text-secondary);
    font-size: 1.25rem;
    line-height: 1.6;
}

.entry-content blockquote p:last-child {
    margin-bottom: 0;
}

/* Код и примеры */
.entry-content code {
    background-color: var(--color-bg-secondary);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.entry-content pre {
    background-color: var(--color-bg-secondary);
    padding: 1.5rem;
    border-radius: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 1.5rem 0;
    font-family: 'Courier New', monospace;
    font-size: 0.9375rem;
    line-height: 1.5;
    max-width: 100%;
}

/* Изображения в контенте */
.entry-content figure {
    margin: 2rem 0;
    text-align: center;
}

.entry-content figcaption {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    margin-top: 0.5rem;
    font-style: italic;
}

/* Таблицы */
.entry-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    max-width: 100%;
}

.entry-content th,
.entry-content td {
    padding: 0.75rem;
    border: 1px solid var(--color-border);
    text-align: left;
}

.entry-content th {
    background-color: var(--color-sky-light);
    font-weight: 600;
    color: var(--color-sky-dark);
}

/* Выделение текста */
::selection {
    background-color: var(--color-sky-light);
    color: var(--color-text-primary);
}

::-moz-selection {
    background-color: var(--color-sky-light);
    color: var(--color-text-primary);
}

/* Первый абзац */
.entry-content > p:first-of-type {
    font-size: 1.2rem;
    line-height: 1.8;
    color: #1b4260;
    margin-bottom: 2rem;
}

/* Разделители */
.content-divider {
    height: 1px;
    background: linear-gradient(90deg, 
        transparent, 
        var(--color-sky-base), 
        transparent);
    margin: 3rem auto;
    width: 80%;
    max-width: var(--max-width-content);
}

/* Каппинг для заголовков */
.entry-content h2,
.entry-content h3 {
    font-variant: small-caps;
    letter-spacing: 0.5px;
}

/* Сноски */
.footnote {
    font-size: 0.875rem;
    color: var(--color-text-secondary);
    border-left: 3px solid var(--color-border);
    padding-left: 1rem;
    margin: 1.5rem 0;
    font-style: italic;
}

/* Навигация между постами */
.navigation.posts-navigation {
    display: flex;
    justify-content: space-between;
    margin: 3rem 0;
    padding-top: 2rem;
    border-top: 1px solid var(--color-border);
}


/* Навигация по страницам */
.page-links {
    margin: 2rem 0;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.page-links a {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    margin: 0 0.25rem;
    background-color: var(--color-sky-light);
    border-radius: 4px;
}

.page-links > span {
    font-weight: 600;
    color: var(--color-sky-dark);
}

/* Навигационные ссылки */
.nav-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
}

/* ==========================================================================
   АДАПТИВНОСТЬ КОНТЕНТА (СОХРАНЕНИЕ ОТСТУПОВ)
   ========================================================================== */

@media (max-width: 1200px) {
    .content-container {
        max-width: 100%;
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

@media (max-width: 992px) {
    .content-container {
        gap: 2rem;
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
    
    .content-wrapper {
        padding: 2rem;
    }
    
    .entry-content {
        font-size: 1.0625rem;
        line-height: 1.7;
    }
    
    .entry-content > p:first-of-type {
        font-size: 1.0rem;
    }
}

@media (max-width: 768px) {
    .content-container {
        flex-direction: column;
        gap: 1.5rem;
        padding-top: 1.5rem;
        padding-bottom: 1.5rem;
        padding-left: 1rem; /* Сохраняем отступы от краев */
        padding-right: 1rem;
    }
    
    .content-wrapper {
        padding: 1.5rem;
        border-radius: 8px;
    }
    
    .entry-content {
        font-size: 1.1rem;
        line-height: 1.6;
    }
    
    .entry-content h2,
    .entry-content h3,
    .entry-content h4 {
        margin-top: 1.5rem;
    }
    
    .entry-content blockquote {
        font-size: 1.1rem;
        padding-left: 1rem;
        margin: 1.5rem 0;
    }
    
    .navigation.posts-navigation {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav-previous,
    .nav-next {
        max-width: 100%;
    }
    
    /* Таблицы с горизонтальным скроллом на мобильных */
    .entry-content table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 480px) {
    .content-container {
        padding-left: 0rem; /* Небольшие отступы от краев */
        padding-right: 0rem;
    }
    
    .content-wrapper {
        padding: 1.25rem;
    }
    
    .entry-content {
        font-size: 1rem;
        line-height: 1.5;
    }
    
    .entry-content pre {
        padding: 1rem;
        font-size: 0.875rem;
        margin-left: -0.5rem;
        margin-right: -0.5rem;
        border-radius: 4px;
    }
}

/* Фикс для длинного контента */
.entry-content pre,
.entry-content code,
.entry-content table {
    max-width: 100%;
    overflow-x: auto;
}

/* Фикс для iOS */
@supports (-webkit-touch-callout: none) {
    .entry-content pre {
        -webkit-overflow-scrolling: touch;
    }
}


/* ==========================================================================
   ИЗОБРАЖЕНИЯ В ШАПКЕ КОНТЕНТА (ДОБАВЬТЕ В КОНЕЦ ФАЙЛА content.css)
   ========================================================================== */

/* Контейнер для изображения записи */
.entry-featured-image {
    margin: 2rem 0;
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: var(--shadow-medium);
    background-color: var(--color-bg-secondary);
    min-height: 200px;
    display: block;
}

/* Само изображение записи */
.entry-featured-image .page-featured-image {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    object-fit: cover;
}

/* Подпись к изображению */
.entry-featured-image figcaption.wp-caption-text {
    padding: 1rem;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 0.875rem;
    text-align: center;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0;
    line-height: 1.4;
}

/* Ховер-эффект */
.entry-featured-image:hover .page-featured-image {
    transform: scale(1.02);
}

/* ==========================================================================
   ИЗОБРАЖЕНИЯ В ШАПКЕ КОНТЕНТА (ИСПРАВЛЕННАЯ ВЕРСИЯ)
   ========================================================================== */

/* Контейнер для изображения записи */
.entry-featured-image {
    margin: 1.5rem 0;
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: var(--shadow-medium);
    background-color: var(--color-bg-secondary);
    display: block;
    width: 100%;
}

/* Само изображение записи - ИСПРАВЛЕНО */
.entry-featured-image .page-featured-image {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    object-fit: cover;
    vertical-align: middle;
}

/* Подпись к изображению */
.entry-featured-image figcaption.wp-caption-text {
    padding: 1rem;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 0.875rem;
    text-align: center;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0;
    line-height: 1.4;
    z-index: 2;
}

/* Ховер-эффект */
.entry-featured-image:hover .page-featured-image {
    transform: scale(1.02);
}

/* ==========================================================================
   ИЗОБРАЖЕНИЯ В ШАПКЕ КОНТЕНТА - ФИНАЛЬНЫЙ ФИКС
   ========================================================================== */

/* Контейнер для изображения записи - УБИРАЕМ ФИКСИРОВАННУЮ ВЫСОТУ */
.entry-featured-image {
    margin: 1.5rem 0;
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: var(--shadow-medium);
    background-color: var(--color-bg-secondary);
    display: block;
    width: 100%;
    /* УБИРАЕМ ВСЕ ФИКСИРОВАННЫЕ ВЫСОТЫ И ASPECT-RATIO */
    height: auto;
    min-height: 0 !important;
}

/* Само изображение записи */
.entry-featured-image .page-featured-image {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    object-fit: cover;
    vertical-align: middle;
    /* УБИРАЕМ ФИКСИРОВАННУЮ ВЫСОТУ */
    max-height: none;
}

/* Подпись к изображению */
.entry-featured-image figcaption.wp-caption-text {
    padding: 1rem;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 0.875rem;
    text-align: center;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    margin: 0;
    line-height: 1.4;
    z-index: 2;
}

/* Ховер-эффект */
.entry-featured-image:hover .page-featured-image {
    transform: scale(1.02);
}

/* ==========================================================================
   АДАПТИВНОСТЬ ДЛЯ МОБИЛЬНЫХ УСТРОЙСТВ - КОНТЕЙНЕР ПОДСТРАИВАЕТСЯ ПОД ИЗОБРАЖЕНИЕ
   ========================================================================== */

@media (max-width: 992px) {
    .entry-featured-image {
        margin: 1.25rem 0;
        border-radius: 10px;
    }
}

@media (max-width: 768px) {
    .entry-featured-image {
        margin: 1rem 0;
        border-radius: 8px;
        margin-left: 0;
        margin-right: 0;
        width: 100%;
        max-width: 100%;
        /* ГЛАВНОЕ: контейнер растягивается по содержимому */
        height: auto;
        /* Убираем все фиксированные размеры */
        min-height: 0;
        max-height: none;
        aspect-ratio: none;
    }
    
    .entry-featured-image .page-featured-image {
        /* Изображение определяет высоту контейнера */
        height: auto;
        max-height: none;
        position: static;
        object-fit: cover;
        object-position: center;
        max-width: 100%;
        /* Убираем ограничения по высоте */
        min-height: 0;
    }
    
    /* Контейнер для подписи на мобильных */
    .entry-featured-image figcaption.wp-caption-text {
        position: relative;
        background-color: var(--color-bg-secondary);
        color: var(--color-text-secondary);
        margin-top: 0.5rem;
        border-radius: 0 0 8px 8px;
        /* Подпись идет после изображения, не перекрывает */
        position: static;
        transform: none;
    }
}

@media (max-width: 480px) {
    .entry-featured-image {
        margin: 0.75rem 0;
        border-radius: 6px;
    }
    
    .entry-featured-image figcaption.wp-caption-text {
        font-size: 0.75rem;
        padding: 0.75rem;
        margin-top: 0;
    }
}

/* Фикс для iOS и Safari */
@supports (-webkit-touch-callout: none) {
    .entry-featured-image {
        /* Для Safari - нормальный flow */
        display: block;
        -webkit-transform: none;
        transform: none;
    }
}

/* Гарантия загрузки изображения */
.entry-featured-image .page-featured-image[src] {
    opacity: 1;
    animation: fadeInImage 0.5s ease;
}

.entry-featured-image .page-featured-image:not([src]) {
    opacity: 0;
    /* Минимальная высота только если нет изображения */
    min-height: 150px;
    background: linear-gradient(135deg, 
        var(--color-sky-light) 0%, 
        var(--color-bg-secondary) 100%);
}

@keyframes fadeInImage {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Резервный фон на случай ошибки загрузки - ТОЛЬКО ПОД ИЗОБРАЖЕНИЕМ */
.entry-featured-image::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, 
        var(--color-sky-light) 0%, 
        var(--color-bg-secondary) 100%);
    z-index: -1;
    opacity: 0;
    transition: opacity 0.3s;
}

.entry-featured-image:has(.page-featured-image:not([src]))::before,
.entry-featured-image:has(.page-featured-image[src=""])::before {
    opacity: 1;
}

/* Убираем фон у самого контейнера когда есть изображение */
.entry-featured-image:has(.page-featured-image[src]:not([src=""])) {
    background: transparent;
}

/* Фикс для растянутых изображений - ТОЛЬКО ОГРАНИЧЕНИЕ ПО ШИРИНЕ */
.entry-featured-image img {
    max-width: 100%;
    /* Убираем ограничения по высоте */
    max-height: none;
    margin: 0 auto;
    display: block;
}

/* Если все еще есть проблема - сбрасываем ВСЕ возможные стили */
@media (max-width: 768px) {
    .entry-featured-image {
        all: unset;
        display: block;
        margin: 1rem 0;
        border-radius: 8px;
        overflow: hidden;
        box-shadow: var(--shadow-medium);
        width: 100%;
        height: auto;
    }
    
    .entry-featured-image .page-featured-image {
        all: unset;
        display: block;
        width: 100%;
        height: auto;
        max-width: 100%;
    }
}


/* В самый конец content.css добавьте: */

.content-wrapper .pages-tree-simple {
    width: 100%;
    box-sizing: border-box;
}

.content-wrapper .tree-simple-list {
    width: 100%;
}

.content-wrapper .tree-item-inner {
    width: 100%;
    box-sizing: border-box;
}

/* Убедитесь, что контейнер правильно ограничен */
.content-wrapper {
    position: relative;
    overflow: visible;
}

/* Исправляем отображение иконок */
.menu-item-icon {
    max-width: 16px;
    max-height: 16px;
    object-fit: contain;
    vertical-align: middle;
}