/* content.css - Стили для контента статей (работают без классов) */

/* Основные стили для контента статей */
.post-content {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--dark);
    display: flow-root; /* Важно для обтекания */
}

.post-content > *:first-child {
    margin-top: 0;
}

.post-content > *:last-child {
    margin-bottom: 0;
}

/* Заголовки */
.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6 {
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    color: var(--primary);
    margin: 40px 0 20px;
    line-height: 1.3;
}

.post-content h1 {
    font-size: 1.8rem;
    border-bottom: 2px solid var(--secondary);
    padding-bottom: 10px;
}

.post-content h2 {
    font-size: 1.6rem;
    border-left: 4px solid var(--primary-light);
    padding-left: 15px;
}

.post-content h3 {
    font-size: 1.4rem;
    color: var(--dark);
}

.post-content h4 {
    font-size: 1.2rem;
    color: var(--dark);
}

.post-content h5,
.post-content h6 {
    font-size: 1.1rem;
    color: var(--gray);
}

/* Параграфы */
.post-content p {
    margin: 20px 0;
    text-align: justify;
    line-height: 1.7;
}

/* Списки */
.post-content ul,
.post-content ol {
    margin: 20px 0;
    padding-left: 30px;
}

.post-content li {
    margin: 10px 0;
    position: relative;
}

.post-content ul li::before {
    content: "•";
    color: var(--primary);
    font-weight: bold;
    position: absolute;
    left: -20px;
}

.post-content ol {
    counter-reset: item;
}

.post-content ol li {
    counter-increment: item;
}

.post-content ol li::before {
    content: counter(item) ".";
    color: var(--primary);
    font-weight: bold;
    position: absolute;
    left: -25px;
}

/* Вложенные списки */
.post-content ul ul,
.post-content ol ol,
.post-content ul ol,
.post-content ol ul {
    margin: 10px 0;
    padding-left: 20px;
}

/* Ссылки */
.post-content a {
    color: var(--primary);
    text-decoration: none;
    border-bottom: 1px dotted var(--primary-light);
    transition: var(--transition);
}

.post-content a:hover {
    color: var(--primary-light);
    border-bottom: 1px solid var(--primary-light);
}

/* Цитаты */
.post-content blockquote {
    margin: 30px 0;
    padding: 25px 30px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-left: 4px solid var(--primary);
    border-radius: 0 var(--radius) var(--radius) 0;
    font-style: italic;
    position: relative;
}

.post-content blockquote::before {
    content: "\201C";
    font-family: Georgia, serif;
    font-size: 3rem;
    color: var(--primary-light);
    position: absolute;
    top: -10px;
    left: 10px;
    opacity: 0.3;
}

.post-content blockquote p {
    margin: 0;
    font-size: 1.1rem;
    line-height: 1.6;
}

.post-content blockquote cite {
    display: block;
    margin-top: 10px;
    font-size: 0.9rem;
    color: var(--gray);
    font-style: normal;
    font-weight: 500;
}

.post-content blockquote cite::before {
    content: "— ";
}

/* Таблицы */
.post-content table {
    width: 100%;
    margin: 30px 0;
    border-collapse: collapse;
    border: 1px solid #e2e8f0;
}

.post-content table caption {
    caption-side: bottom;
    margin-top: 10px;
    font-size: 0.9rem;
    color: var(--gray);
    text-align: center;
}

.post-content thead {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: white;
}

.post-content th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #e2e8f0;
}

.post-content td {
    padding: 15px;
    border-bottom: 1px solid #e2e8f0;
}

.post-content tbody tr {
    transition: var(--transition);
}

.post-content tbody tr:hover {
    background-color: #f8fafc;
}

.post-content tbody tr:last-child td {
    border-bottom: none;
}

/* Изображения - ОБНОВЛЕНО! */
.post-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
}

/* Изображения с обтеканием - ОБНОВЛЕНО! */
.post-content img[style*="float: left"],
.post-content img[style*="float:left"] {
    float: left;
    margin: 15px 30px 15px 0;
    max-width: 50%;
    display: inline-block; /* Важно! Не block */
}

.post-content img[style*="float: right"],
.post-content img[style*="float:right"] {
    float: right;
    margin: 15px 0 15px 30px;
    max-width: 50%;
    display: inline-block; /* Важно! Не block */
}

/* Figure с обтеканием - ОБНОВЛЕНО! */
.post-content figure {
    margin: 0 0 20px 0;
    text-align: left;
}

.post-content figure img {
    margin: 0;
    display: block;
}

.post-content figcaption {
    margin-top: 10px;
    font-size: 0.9rem;
    color: var(--gray);
    font-style: italic;
    text-align: center;
    padding: 0 10px;
}


/* Figure с обтеканием — фикс отступа */
.post-content figure.article-image-float {
    margin: 0 26px 20px 0;            /* справа появится нужные 30px */
}

.post-content figure.article-image-float.right {
    margin: 0 0 20px 26px;
}

/* Первый параграф после плавающего изображения прижимаем к верху */
.post-content .article-image-float + p {
    margin-top: 0;
}


/* Код и преформатированный текст */
.post-content code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    color: #dc2626;
}

.post-content pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 25px;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 25px 0;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.5;
}

.post-content pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
}

/* Горизонтальная линия */
.post-content hr {
    margin: 40px 0;
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, #e2e8f0 50%, transparent 100%);
}

/* Выделенный текст */
.post-content strong,
.post-content b {
    color: var(--dark);
    font-weight: 600;
}

.post-content em,
.post-content i {
    font-style: italic;
}

.post-content mark {
    background: linear-gradient(120deg, rgba(245, 158, 11, 0.3) 0%, rgba(245, 158, 11, 0.1) 100%);
    padding: 2px 4px;
    border-radius: 2px;
}

/* Подстрочный и надстрочный текст */
.post-content sub,
.post-content sup {
    font-size: 0.75em;
    line-height: 0;
    position: relative;
    vertical-align: baseline;
}

.post-content sup {
    top: -0.5em;
}

.post-content sub {
    bottom: -0.25em;
}

/* Аббревиатуры */
.post-content abbr[title] {
    border-bottom: 1px dotted var(--gray);
    cursor: help;
    text-decoration: none;
}

/* Специальные блоки через встроенные стили (поддержка Quill) */
.post-content div[style*="background-color"] {
    padding: 20px;
    border-radius: var(--radius);
    margin: 25px 0;
    border-left: 4px solid transparent;
}

.post-content div[style*="background-color"] p {
    margin: 0;
}

.post-content div[style*="background-color"] p:not(:last-child) {
    margin-bottom: 10px;
}

/* Информационные блоки */
.post-content div[style*="background-color: #f8f9fa"] {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
    border-left-color: var(--primary) !important;
}

.post-content div[style*="background-color: #fff3cd"] {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%) !important;
    border-left-color: #ffc107 !important;
}

.post-content div[style*="background-color: #f8d7da"] {
    background: linear-gradient(135deg, #f8d7da 0%, #f1b0b7 100%) !important;
    border-left-color: #dc3545 !important;
}

.post-content div[style*="background-color: #d1ecf1"] {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%) !important;
    border-left-color: #0dcaf0 !important;
}

.post-content div[style*="background-color: #d4edda"] {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%) !important;
    border-left-color: #198754 !important;
}

/* Выравнивание текста */
.post-content div[style*="text-align: center"],
.post-content p[style*="text-align: center"] {
    text-align: center;
}

.post-content div[style*="text-align: right"],
.post-content p[style*="text-align: right"] {
    text-align: right;
}

.post-content div[style*="text-align: justify"],
.post-content p[style*="text-align: justify"] {
    text-align: justify;
}

/* Отступы через встроенные стили */
.post-content div[style*="padding"],
.post-content p[style*="padding"] {
    margin: 25px 0 !important;
}

.post-content div[style*="margin"],
.post-content p[style*="margin"] {
    margin: 25px 0 !important;
}

/* Специальные символы и оформление */
.post-content ::selection {
    background: rgba(59, 130, 246, 0.3);
    color: inherit;
}

.post-content ::-moz-selection {
    background: rgba(59, 130, 246, 0.3);
    color: inherit;
}

/* ========================== */
/* ОБТЕКАНИЕ КАРТИНКИ ТЕКСТОМ - ОБНОВЛЕНО! */
/* ========================== */

/* Figure с обтеканием слева - УЛУЧШЕННЫЙ ВАРИАНТ */
.article-image-float {
    float: left;
    max-width: 300px;
    width: auto;
    margin: 0 30px 20px 0; /* ОТСТУП СПРАВА 30px! */
    padding: 0;
    position: relative;
    clear: left; /* Важно для правильного обтекания */
}

.article-image-float img {
    width: 100%;
    height: auto;
    border-radius: 12px;
    display: block;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.article-image-float figcaption {
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--gray);
    font-style: italic;
    text-align: center;
    line-height: 1.4;
    padding: 0 10px;
}

/* Для правого обтекания */
.article-image-float.right {
    float: right;
    margin: 0 0 20px 30px; /* Отступ слева при правом обтекании */
    clear: right; /* Важно для правильного обтекания */
}

/* Очистка обтекания для заголовков */
.post-content h2,
.post-content h3,
.post-content h4 {
    clear: both; /* Заголовки начинаются с новой строки */
    margin-top: 2em;
}

/* Очистка обтекания для других элементов */
.post-content blockquote,
.post-content table {
    clear: both;
    margin-top: 2em;
}

/* ==================== */
/* МОБИЛЬНАЯ АДАПТАЦИЯ  */
/* ==================== */
@media (max-width: 768px) {
    .post-content {
        font-size: 1rem;
        line-height: 1.7;
    }
    
    .post-content h1 {
        font-size: 1.6rem;
    }
    
    .post-content h2 {
        font-size: 1.4rem;
    }
    
    .post-content h3 {
        font-size: 1.2rem;
    }
    
    /* Отключаем обтекание на мобильных */
    .article-image-float,
    .article-image-float.right {
        float: none;
        max-width: 100%;
        margin: 0 auto 25px !important;
        text-align: center;
    }
    
    .article-image-float img {
        max-width: 300px;
        margin: 0 auto;
    }
    
    .post-content p {
        text-align: left; /* На мобильных выравнивание по левому краю */
    }
    
    .post-content table {
        display: block;
        overflow-x: auto;
    }
    
    .post-content pre {
        font-size: 0.85rem;
        padding: 20px;
    }
}

@media (max-width: 480px) {
    .post-content {
        font-size: 0.95rem;
        line-height: 1.6;
    }
    
    .post-content h1 {
        font-size: 1.4rem;
    }
    
    .post-content h2 {
        font-size: 1.3rem;
    }
    
    .post-content blockquote {
        padding: 20px;
    }
    
    .post-content ul,
    .post-content ol {
        padding-left: 20px;
    }
}
