/* styles.css - объединенная версия */

/* ---------- ПЕРЕМЕННЫЕ СВЕТЛОЙ ТЕМЫ ---------- */
:root {
    --bg-body: #fafaf9;
    --bg-card: #ffffff;
    --bg-header: #ffffff;
    --text-primary: #1e1e2a;
    --text-secondary: #5a5a66;
    --text-muted: #8f8c86;
    --border-light: #e4e2dd;
    --border-card: #ecebe8;
    --accent: #9b7b5c;
    --code-bg: #f5f4f2;
    --code-color: #2c5f2d;
    --blockquote-bg: #e8e5df;
    --shadow: rgba(0, 0, 0, 0.08);
}

/* ---------- ПЕРЕМЕННЫЕ ТЕМНОЙ ТЕМЫ ---------- */
body.dark {
    --bg-body: #1a1a1a;
    --bg-card: #2a2a2a;
    --bg-header: #1f1f1f;
    --text-primary: #e8e8e8;
    --text-secondary: #a0a0a0;
    --text-muted: #7a7a7a;
    --border-light: #3a3a3a;
    --border-card: #3a3a3a;
    --accent: #b8956e;
    --code-bg: #2d2d2d;
    --code-color: #8bc34a;
    --blockquote-bg: #3a3a3a;
    --shadow: rgba(0, 0, 0, 0.3);
}

/* ---------- БАЗА ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--bg-body);
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    scroll-behavior: smooth;
    transition: background 0.2s ease, color 0.2s ease;
}

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

/* ---------- ШАПКА ---------- */
.site-header {
    background: var(--bg-header);
    border-bottom: 1px solid var(--border-light);
    padding: 1rem 0;
    margin-bottom: 2rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0 30px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.site-title {
    font-size: 1.35rem;
    font-weight: 500;
    letter-spacing: -0.2px;
    color: var(--text-primary);
    text-decoration: none;
    position: relative;
    transition: color 0.2s;
}

.site-title::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent);
    transition: width 0.3s ease;
}

.site-title:hover {
    color: var(--accent);
}

.site-title:hover::after {
    width: 100%;
}

/* ---------- ПЕРЕКЛЮЧАТЕЛЬ ТЕМЫ ---------- */
.theme-toggle {
    background: var(--code-bg);
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    cursor: pointer;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    background: var(--border-card);
    transform: translateY(-2px);
}

/* ---------- СОЦИАЛЬНЫЕ ССЫЛКИ ---------- */
.social-links {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.social-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--code-bg);
    transition: all 0.2s ease;
}

.social-link:hover {
    background: var(--border-card);
    transform: translateY(-2px);
}

.social-link img {
    width: 16px;
    height: 16px;
    display: block;
}

/* ---------- СЕТКА СТАТЕЙ ---------- */
.posts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
    margin-bottom: 3.5rem;
}

.post-card {
    background: var(--bg-card);
    border-radius: 20px;
    overflow: hidden;
    border: 1px solid var(--border-card);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.post-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px var(--shadow);
}

.post-image-link {
    display: block;
    line-height: 0;
    overflow: hidden;
    position: relative;
}

.post-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
    background: var(--code-bg);
    transition: transform 0.3s ease;
}

.post-card:hover .post-image {
    transform: scale(1.02);
}

.post-image-link::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0);
    transition: background 0.3s ease;
    pointer-events: none;
}

.post-card-content {
    padding: 1.2rem 1.2rem 1.5rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.post-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    font-size: 0.75rem;
}

.post-date {
    color: var(--text-muted);
}

.post-category {
    background: var(--code-bg);
    padding: 0.2rem 0.65rem;
    border-radius: 30px;
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
}

.post-title {
    font-size: 1.25rem;
    font-weight: 500;
    line-height: 1.4;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

.post-title a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s;
}

.post-title a:hover {
    color: var(--accent);
    text-decoration: underline;
}

.post-excerpt {
    color: var(--text-secondary);
    margin-bottom: 1.2rem;
    font-size: 0.9rem;
    line-height: 1.5;
    flex-grow: 1;
}

.read-more {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: gap 0.2s, border-color 0.2s;
    align-self: flex-start;
    margin-top: auto;
}

.read-more:hover {
    border-bottom-color: var(--accent);
    gap: 0.5rem;
}

/* ---------- СТРАНИЦА СТАТЬИ ---------- */
.article-full {
    background: transparent;
    margin: 1.5rem auto 2.5rem;
    max-width: 1090px;
}

.article-title {
    font-size: 2rem;
    font-weight: 500;
    line-height: 1.3;
    margin-bottom: 2.5rem;
    color: var(--text-primary);
    letter-spacing: -0.2px;
}

.article-footnote {
    margin-top: 2rem;
    padding-top: 1.2rem;
    border-top: 1px solid var(--border-light);
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.more-posts {
    text-align: center;
    margin: 1.5rem 0 2rem;
}

.more-posts-link {
    background: transparent;
    border: 1px solid var(--border-light);
    padding: 0.7rem 1.5rem;
    border-radius: 40px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.more-posts-link:hover {
    background: var(--code-bg);
    border-color: var(--accent);
    color: var(--accent);
}

/* ---------- ПОДВАЛ ---------- */
.site-footer {
    border-top: 1px solid var(--border-light);
    margin-top: 3rem;
    padding: 2rem 1rem 2.5rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* ---------- АНИМАЦИИ ---------- */
.post-card {
    animation: fadeInUp 0.35s ease-out forwards;
    opacity: 0;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.post-card:nth-child(1) { animation-delay: 0.05s; }
.post-card:nth-child(2) { animation-delay: 0.1s; }
.post-card:nth-child(3) { animation-delay: 0.15s; }
.post-card:nth-child(4) { animation-delay: 0.2s; }
.post-card:nth-child(5) { animation-delay: 0.25s; }
.post-card:nth-child(6) { animation-delay: 0.3s; }

/* ---------- ДВЕ КОЛОНКИ ---------- */
.two-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    margin: 2rem 0 3rem;
}

.archive-column,
.sidebar-column {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 1.5rem;
    border: 1px solid var(--border-card);
}

.section-title {
    font-size: 1.2rem;
    font-weight: 500;
    margin-bottom: 1.2rem;
    color: var(--text-primary);
}

.archive-year {
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent);
    margin: 1rem 0 0.5rem;
}

.archive-year:first-of-type {
    margin-top: 0;
}

.archive-items {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
}

.archive-items li {
    margin: 0.5rem 0;
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.archive-items li a {
    text-decoration: none;
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: color 0.2s;
    flex: 1;
}

.archive-items li a:hover {
    color: var(--accent);
    text-decoration: underline;
}

.archive-date {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.coming-soon {
    font-size: 0.8rem;
    color: var(--accent);
    font-style: italic;
}

/* ---------- 404 ---------- */
.error-page {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
}

.error-container {
    max-width: 600px;
    text-align: center;
    background: var(--bg-card);
    border-radius: 32px;
    padding: 3rem 2rem;
    border: 1px solid var(--border-card);
}

.error-code {
    font-size: 8rem;
    font-weight: 700;
    line-height: 1;
    color: var(--border-light);
    letter-spacing: -0.05em;
    margin-bottom: 1rem;
}

.error-title {
    font-size: 1.8rem;
    font-weight: 500;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

.error-message {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.error-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-light);
}

.error-home-link,
.error-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1.2rem;
    background: var(--code-bg);
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 40px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.error-home-link:hover,
.error-back-link:hover {
    background: var(--border-card);
    transform: translateY(-2px);
}

.error-suggestions {
    text-align: left;
    background: var(--code-bg);
    padding: 1.2rem 1.5rem;
    border-radius: 20px;
}

.error-suggestions p {
    font-weight: 500;
    margin-bottom: 0.8rem;
    color: var(--text-primary);
}

.error-suggestions ul {
    margin: 0;
    padding-left: 1.2rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.error-suggestions li {
    margin: 0.5rem 0;
}

.error-suggestions a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
}

.error-suggestions a:hover {
    border-bottom-color: var(--accent);
}

/* ========== MARKDOWN-КОНТЕНТ ========== */
.article-content {
    font-size: 1.05rem;
    line-height: 1.7;
    color: var(--text-primary);
}

.article-content h1 { font-size: 2.2rem; font-weight: 600; margin: 1.5rem 0 1rem; }
.article-content h2 { font-size: 1.6rem; font-weight: 550; margin: 2rem 0 1rem; }
.article-content h3 { font-size: 1.3rem; font-weight: 540; margin: 1.5rem 0 0.8rem; }
.article-content h4 { font-size: 1.1rem; font-weight: 530; margin: 1.2rem 0 0.6rem; }
.article-content h1, .article-content h2, .article-content h3, .article-content h4 { color: var(--text-primary); }

.article-content p { margin-bottom: 1.2rem; }
.article-content strong { font-weight: 600; color: var(--text-primary); }
.article-content em { font-style: italic; color: var(--text-secondary); }

.article-content hr {
    margin: 2rem 0;
    border: none;
    height: 1px;
    background: var(--border-light);
}

.article-content ul, .article-content ol {
    margin: 1rem 0 1.4rem 1.8rem;
}

.article-content li { margin: 0.5rem 0; }

.article-content blockquote {
    border-left: 4px solid var(--accent);
    padding: 0.5rem 0 0.5rem 1.2rem;
    margin: 1rem 0;
    color: var(--text-secondary);
    background: var(--blockquote-bg);
    border-radius: 0 12px 12px 0;
}

.article-content blockquote p { margin-bottom: 0; }

.article-content code {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.85em;
    background: var(--code-bg);
    padding: 0.2rem 0.4rem;
    border-radius: 6px;
    color: var(--code-color);
}

.article-content pre {
    background: var(--code-bg);
    border-radius: 14px;
    padding: 1.2rem;
    margin: 1.5rem 0;
    overflow-x: auto;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.85rem;
    border: 1px solid var(--border-light);
}

.article-content pre code {
    background: none;
    padding: 0;
    color: var(--code-color);
}

.article-content img {
    max-width: 100%;
    height: auto;
    border-radius: 20px;
    margin: 1.5rem 0;
    display: block;
}

.article-content a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}

.article-content a:hover { border-bottom-color: var(--accent); }

.article-content table {
    width: 100%;
    margin: 1.5rem 0;
    border-collapse: collapse;
    overflow-x: auto;
    display: block;
}

.article-content th, .article-content td {
    padding: 0.75rem 1rem;
    border-right: 1px solid var(--border-light);
}

.article-content th {
    background: var(--code-bg);
    font-weight: 600;
    color: var(--text-primary);
}

.article-content td { border-bottom: 1px solid var(--border-light); }
.article-content tr:last-child td { border-bottom: none; }
.article-content th:last-child, .article-content td:last-child { border-right: none; }

/* ========== ДОПОЛНИТЕЛЬНЫЕ СТИЛИ ИЗ EXT.CSS ========== */
.code-block {
    background: var(--code-bg);
    border-radius: 14px;
    padding: 1.2rem;
    margin: 1.8rem 0;
    overflow-x: auto;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    border: 1px solid var(--border-light);
}

.code-block pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.code-block code {
    font-family: inherit;
    color: var(--code-color);
}

.image-text-row {
    display: flex;
    gap: 1.8rem;
    align-items: flex-start;
    margin: 2rem 0;
    flex-wrap: wrap;
}

.image-text-row .image-side {
    flex: 1.2;
    min-width: 180px;
}

.image-text-row .image-side img {
    width: 100%;
    border-radius: 20px;
    display: block;
    background: var(--code-bg);
    border: 1px solid var(--border-light);
}

.image-text-row .text-side {
    flex: 1.8;
}

.image-text-row .text-side p {
    margin-bottom: 0.8rem;
}

.image-text-row .text-side p:last-child {
    margin-bottom: 0;
}

.img-caption {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    margin-top: 0.4rem;
}

/* ---------- АДАПТИВНОСТЬ ---------- */
@media (max-width: 860px) {
    .container { padding: 0 20px; }
    .posts-grid { grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
    .post-image { height: 180px; }
    .article-full { max-width: 100%; }
    .two-columns { grid-template-columns: 1fr; gap: 1.5rem; margin-top: 1.5rem; }
    .image-text-row { flex-direction: column; gap: 1rem; }
    .image-text-row .image-side { max-width: 100%; }
}

@media (max-width: 560px) {
    .header-content { flex-direction: row; justify-content: space-between; padding: 0; gap: 0.5rem; }
    .site-title { font-size: 1rem; max-width: 55%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .site-title::after { bottom: -2px; }
    .social-links { gap: 0.5rem; }
    .social-link { width: 28px; height: 28px; }
    .social-link img { width: 14px; height: 14px; }
    .site-header { padding: 0.6rem 0; margin-bottom: 1rem; }
    .theme-toggle { width: 28px; height: 28px; font-size: 0.85rem; }

    .posts-grid { display: flex; flex-direction: column; gap: 1rem; }
    .posts-grid .post-card { flex-direction: row; align-items: flex-start; gap: 0.75rem; padding: 0.75rem; min-height: 100px; }
    .posts-grid .post-image { width: 80px; height: 80px; border-radius: 12px; margin: 0; flex-shrink: 0; object-fit: cover; }
    .posts-grid .post-card-content { padding: 0; flex: 1; min-width: 0; }
    .posts-grid .post-meta { margin-bottom: 0; gap: 0.5rem; }
    .posts-grid .post-date { font-size: 0.7rem; }
    .posts-grid .post-category { font-size: 0.65rem; padding: 0.15rem 0.5rem; }
    .posts-grid .post-title { font-size: 0.95rem; margin-bottom: 0.25rem; }
    .posts-grid .post-excerpt, .posts-grid .read-more { display: none; }
    .posts-grid .post-title a::after { content: " →"; font-size: 0.85rem; color: var(--accent); }

    .article-full { margin: 1rem auto 1.5rem; }
    .article-title { font-size: 1.6rem; }
    .article-content { font-size: 1rem; }
    .article-content h1 { font-size: 1.6rem; }
    .article-content h2 { font-size: 1.3rem; }
    .article-content h3 { font-size: 1.1rem; }
    .article-content pre { padding: 0.8rem; font-size: 0.8rem; }

    .section-title { font-size: 1rem; margin-bottom: 1rem; }
    .archive-column, .sidebar-column { padding: 1rem; }
    .archive-items li { flex-direction: column; gap: 0.25rem; }
    .archive-date { white-space: normal; font-size: 0.65rem; }

    .error-container { padding: 2rem 1.2rem; }
    .error-code { font-size: 6rem; }
    .error-title { font-size: 1.5rem; }
    .error-actions { flex-direction: column; gap: 0.8rem; }
}
