/* ==========================================================================
   1. ОБЩИЕ НАСТРОЙКИ И СЕТКА
   ========================================================================== */
* { box-sizing: border-box; margin: 0; padding: 0; }

body { 
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; 
    background-color: #f4f7f6; 
    color: #333; 
    line-height: 1.6; 
}

.container { 
    width: 90%; 
    max-width: 1200px; 
    margin: 0 auto; 
    padding: 0 20px; 
}

main { 
    padding: 40px 0; 
    min-height: 75vh; 
}

/* ==========================================================================
   2. ШАПКА И НАВИГАЦИЯ
   ========================================================================== */
.main-header { 
    background: #1e4520; 
    color: #fff; 
    padding: 20px 0; 
    box-shadow: 0 20px 40px rgba(0,0,0,0.05); 
}

.main-header .container { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
}

.main-nav ul { 
    display: flex; 
    list-style: none; 
}

.main-nav li { 
    margin-left: 20px; 
}

.main-nav a { 
    color: #cbd5e1; 
    text-decoration: none; 
    font-weight: 500; 
    transition: color 0.3s; 
}

.main-nav a:hover { 
    color: #fff; 
}

/* Логотип */
.logo a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    text-decoration: none;
    font-size: 1.4rem;
    font-weight: bold;
}

.logo-img {
    width: 35px;
    height: 35px;
    object-fit: cover;
    border-radius: 4px;
    background: #fff;
}

/* ==========================================================================
   3. ГЛАВНАЯ СТРАНИЦА И КАРТОЧКИ
   ========================================================================== */
.hero { 
    background: #fff; 
    padding: 40px; 
    border-radius: 8px; 
    margin-bottom: 40px; 
    box-shadow: 0 4px 6px rgba(0,0,0,0.02); 
	
	/* Добавьте эти строки для фона: */
    background-image: url('../images/site_head.webp'); /* Путь к вашей картинке */
    background-size: cover;          /* Растягивает картинку на весь блок */
    background-position: center;     /* Центрирует картинку */
    background-repeat: no-repeat;    /* Отключает повторение */
}

.hero h1 { 
    margin-bottom: 10px; 
    color: #1e293b; 
}

/* Базовая сетка: 2 колонки */
.grid { 
    display: grid; 
    grid-template-columns: repeat(2, 1fr); 
    gap: 20px; 
    margin-top: 20px; 
}

/* Обычная вертикальная карточка-ссылка */
a.card { 
    text-decoration: none;
    color: inherit;
    background: #ffffff; 
    padding: 24px; 
    border-radius: 12px; 
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04); 
    display: flex; 
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

a.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

/* Горизонтальная карточка с картинкой слева */
a.card-horizontal {
    text-decoration: none;
    color: inherit;
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: row;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    grid-column: span 1;
	align-items: stretch; /* Растягивает элементы по высоте */
}

a.card-horizontal:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

/* Блок картинки слева */
.card-image {
    width: 220px;
    min-width: 220px;
    overflow: hidden;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

a.card-horizontal:hover .card-image img {
    transform: scale(1.05);
}

/* Правая часть горизонтальной карточки с текстом */
.card-content-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    flex: 1;
	min-width: 0; /* <--- ЭТОТ СТРАХОВОЧНЫЙ ПАРАМЕТР РЕШАЕТ ПРОБЛЕМУ СЪЕЗАНИЯ */
    padding: 20px;
}

/* Большая главная карточка сверху на всю ширину */
a.card.featured,
a.card-horizontal.featured {
    grid-column: 1 / -1;
    background: linear-gradient(135deg, #1b4d3e 0%, #0f2e24 100%);
    color: #ffffff;
}

/* Зеленый бейдж */
.badge { 
    display: inline-block; 
    background: #22c55e; 
    color: #fff; 
    font-size: 11px; 
    font-weight: 700; 
    padding: 4px 8px; 
    border-radius: 6px; 
    margin-bottom: 12px; 
    text-transform: uppercase; 
    letter-spacing: 0.5px; 
}

/* Заголовки и текст */
.card h3, 
.card-content-wrapper h3 { 
    margin-bottom: 10px; 
    color: #1e293b; 
    font-size: 1.15rem;
    line-height: 1.4;
}

a.card.featured h3,
a.card-horizontal.featured h3 {
    color: #ffffff;
    font-size: 1.15rem;
}

.card .excerpt,
.card-content-wrapper .excerpt { 
    color: #475569; 
    margin-bottom: 20px; 
    font-size: 0.95rem;
    line-height: 1.5;
}

a.card.featured .excerpt,
a.card-horizontal.featured .excerpt {
    color: #cbd5e1;
}

/* Подвал карточки: дата аккуратно прижата вправо */
.card-meta {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding-top: 14px;
    border-top: 1px solid #eaeaea;
    font-size: 0.85rem;
}

a.card.featured .card-meta,
a.card-horizontal.featured .card-meta {
    border-top-color: rgba(255, 255, 255, 0.15);
}

.card .date,
.card-content-wrapper .date { 
    color: #64748b; 
    margin: 0; 
}

a.card.featured .date,
a.card-horizontal.featured .date {
    color: #94a3b8;
}

/* ==========================================================================
   4. СТРАНИЦА СТАТЬИ И САЙДБАР
   ========================================================================== */
.article-container {
    display: flex;
    gap: 40px;
    margin-top: 20px;
}

.sidebar {
    width: 250px;
    min-width: 250px;
    position: sticky;
    top: 20px;
    height: fit-content;
    max-height: none;
    overflow-y: visible;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar-box {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
	margin-bottom: 5px; /* Добавили явный надежный разрыв для ПК */
}

.sidebar-box h4 {
    margin-bottom: 15px;
    color: #1e293b;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 5px;
    font-size: 1rem;
}

#toc-nav ul, .all-articles-nav ul { 
    list-style: none; 
    padding-left: 0;
}

#toc-nav li, .all-articles-nav li { 
    margin-bottom: 10px; 
}

#toc-nav a, .all-articles-nav a {
    color: #475569;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s;
    display: inline-block;
}

#toc-nav a:hover, .all-articles-nav a:hover {
    color: #3498db;
    transform: translateX(3px);
}

.article-content,
.post-body {
    flex: 1;
    min-width: 0;
}

.post-body h2 { 
    color: #1a3a1c; 
    margin-top: 40px; 
    margin-bottom: 10px; 
    font-size: 1.7rem; 
    font-weight: 700; 
    border-bottom: 2px solid #e2e8f0; 
    padding-bottom: 5px; 
}

.post-body p { 
    margin-bottom: 22px; 
    color: #334155; 
    font-size: 1.1rem; 
    line-height: 1.3; 
}

/* Красивые стили для ссылок внутри текста */
.post-body p a {
    color: #1e4520; /* Цвет ссылки под общую тему сайта */
    text-decoration: none; /* Убираем стандартное подчеркивание */
    border-bottom: 1px dotted #1e4520; /* Делаем красивое точечное подчеркивание */
    transition: all 0.2s ease;
}

.post-body p a:hover {
    color: #22c55e; /* Цвет при наведении */
    border-bottom-style: solid; /* При наведении подчеркивание становится сплошным */
}

/* Убираем любое подчеркивание/линии с жирного текста внутри ссылок */
.post-body p a strong {
    text-decoration: none !important;
    border-bottom: none !important;
}

/* ==========================================================================
   СПОЙЛЕР "ПОТОК СОЗНАНИЯ" (СВЕРНУТЫЙ ВИД)
   ========================================================================== */

/* Убираем стандартную стрелочку details/summary */
.stream-spoiler summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
}
.stream-spoiler summary::-webkit-details-marker {
    display: none;
}

/* Верхняя строка: Заголовок и знак "+" */
.stream-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 8px;
    margin-bottom: 12px;
}

.stream-title {
    font-size: 1rem;
    font-weight: 700;
    color: #1e293b;
}

.stream-icon {
    font-size: 1.3rem;
    font-weight: 700;
    color: #1e293b;
    line-height: 1;
    transition: transform 0.2s ease;
}

/* При раскрытии спойлера меняем плюс на минус */
.stream-spoiler[open] .stream-icon {
    transform: rotate(45deg); /* Поворот превращает '+' в '✕' */
}

/* Текущая активная статья со стильной синей полоской слева */
.stream-current {
    display: block;
    color: #2980b9; /* Цвет подсветки выделенного текста */
    font-size: 0.95rem;
    font-weight: 700;
    line-height: 1.4;
    border-left: 3px solid #0284c7;
    padding-left: 10px;
    margin: 10px 0 14px 0;
}

/* Список статей при раскрытии */
.stream-list {
    list-style: none;
    padding-left: 0;
    margin: 12px 0 16px 0;
}

.stream-list li {
    margin-bottom: 12px;
}

.stream-list a {
    color: #475569;
    text-decoration: none;
    font-size: 0.9rem;
    line-height: 1.45;
    display: inline-block;
    transition: color 0.2s ease, transform 0.2s ease;
}

.stream-list a:hover {
    color: #0284c7;
    transform: translateX(3px);
}

/* Кнопка "Все статьи =>" по правому краю внизу */
.stream-all-link {
    display: block;
    text-align: right;
    font-size: 0.85rem;
    font-weight: 700;
    color: #0f172a;
    text-decoration: none;
    margin-top: 10px;
    transition: color 0.2s ease;
}

.stream-all-link:hover {
    color: #2563eb;
}

/* ==========================================================================
   5. ОФОРМЛЕНИЕ КОДА И ТЕРМИНАЛА
   ========================================================================== */
pre {
    background-color: #f6f8fa;
    border: 1px solid #e1e4e6;
    border-radius: 6px;
    padding: 6px 12px;
    margin: 15px 0;
    width: 90%;
    max-width: 90%;
    box-sizing: border-box;
    white-space: pre;
    overflow-x: auto;
    word-break: normal;
}

.article-content code,
.post-body code {
    font-family: "Consolas", "Courier New", Courier, monospace;
    background-color: #f1f8f5;
    color: #2e6930;
    font-style: italic;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.95em;
    word-break: normal !important;
    overflow-wrap: break-word !important;
}

pre code {
    font-family: "Consolas", "Courier New", Courier, monospace;
    font-size: 1em !important;
    font-weight: normal !important;
    color: #527fac !important;
    background: none !important;
    font-style: normal !important;
    padding: 0 !important;
    word-break: normal !important;
    overflow-wrap: normal !important;
}

.break-path {
    white-space: normal !important;
    word-break: break-all !important;
    overflow-wrap: break-word !important;
    display: inline !important;
}

/* Терминал */
.terminal-container {
    background-color: #1e1e1e;
    border-radius: 6px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    margin-bottom: 40px;
    font-family: "Consolas", "Courier New", Courier, monospace;
    overflow: hidden;
    border: 1px solid #333;
}

.terminal-header {
    background-color: #2d2d2d;
    padding: 10px;
    display: flex;
    align-items: center;
    position: relative;
}

.terminal-btn {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 8px;
    display: inline-block;
}

.terminal-btn.close { background-color: #ff5f56; }
.terminal-btn.minimize { background-color: #ffbd2e; }
.terminal-btn.expand { background-color: #27c93f; }

.terminal-title {
    color: #999;
    font-size: 0.85rem;
    position: absolute;
    width: 100%;
    text-align: center;
    left: 0;
    pointer-events: none;
}

.terminal-body {
    padding: 15px;
    color: #f1f1f1;
    font-size: 0.95rem;
    line-height: 1.5;
}

.terminal-prompt { color: #4af626; margin-right: 10px; }
.terminal-command { color: #fff; }
.terminal-output {
    color: #cbd5e1;
    margin: 8px 0 12px 0;
    padding-left: 5px;
    border-left: 2px solid #527fac;
    font-style: italic;
}

.terminal-cursor {
    display: inline-block;
    width: 8px;
    height: 15px;
    background-color: #fff;
    margin-left: 4px;
    animation: blink 1s step-end infinite;
    vertical-align: middle;
}

@keyframes blink {
    from, to { background-color: transparent }
    50% { background-color: #fff; }
}

/* ==========================================================================
   6. СТРАНИЦА 404
   ========================================================================== */
.error-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    padding: 20px;
}

.error-card {
    background: #fff;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02);
    text-align: center;
    max-width: 500px;
    width: 100%;
}

.error-code {
    font-size: 5rem;
    font-weight: 800;
    color: #1e4520;
    line-height: 1;
    margin-bottom: 10px;
}

.error-card h2 { color: #1e293b; font-size: 1.4rem; margin-bottom: 15px; }
.error-text { color: #64748b; font-size: 1rem; line-height: 1.5; margin-bottom: 25px; }

.error-waiter {
    background: #f4f7f6;
    padding: 15px;
    border-radius: 6px;
    color: #475569;
    font-style: italic;
    font-size: 0.95rem;
    margin-bottom: 30px;
    border-left: 4px solid #1e4520;
}

.btn-home { display: inline-block; width: auto; padding: 12px 25px; }

/* ==========================================================================
   7. ТАБЛИЦА СПИСКОВ (ХАРАКТЕРИСТИКИ)
   ========================================================================== */
.specs-list {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 10px 20px;
    margin: 20px 0;
    line-height: 1.5;
}

.specs-list dt { font-weight: bold; color: #333; }
.specs-list dd { margin: 0; color: #555; }
.specs-list ul { margin: 5px 0 0 0; padding-left: 20px; }

/* ==========================================================================
   8. ФУТЕР
   ========================================================================== */
.main-footer { 
    background: #1e4520; 
    color: #94a3b8; 
    text-align: center; 
    padding: 20px 0; 
    margin-top: 40px; 
    font-size: 0.9rem; 
}

/* Стили для кнопки "Наверх" */
.back-to-top-btn {
    position: fixed !important;
    bottom: 20px !important;
    right: 20px !important;
    background-color: #1a1a1a !important;
    color: #00ff00 !important;
    border: 1px solid #00ff00 !important;
    padding: 5px 8px !important; /* Еще более компактный размер */
    font-family: monospace !important;
    font-size: 11px !important; /* Аккуратный мелкий шрифт */
    cursor: pointer !important;
    border-radius: 4px !important;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, background-color 0.2s ease;
    z-index: 1000 !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3) !important;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    pointer-events: auto !important;
}

.back-to-top-btn.show {
    opacity: 1 !important;
    visibility: visible !important;
}

.back-to-top-btn:hover {
    background-color: #00ff00 !important;
    color: #000000 !important;
}

/* ==========================================================================
   9. АДАПТИВНОСТЬ И МОБИЛЬНЫЕ УСТРОЙСТВА (ЕДИНЫЙ БЛОК)
   ========================================================================== */
   
/* Новая точка перехода для диапазона 769px - 1000px */
@media (min-width: 769px) and (max-width: 1000px) {
    /* Сетка в одну колонку */
    .grid {
        grid-template-columns: 1fr !important;
    }

    /* Сохраняем горизонтальную ориентацию карточек (картинка слева) */
    a.card-horizontal {
        flex-direction: row !important;
    }

    .card-image {
        width: 220px !important;
        min-width: 220px !important;
    }
}
   
@media (max-width: 768px) {
    .main-header .container {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .main-nav ul { padding: 0; }
    .main-nav li { margin: 0 10px; }

    .article-container {
        flex-direction: column;
        gap: 20px;
    }

    .sidebar {
        width: 100%;
        min-width: 100%;
        position: static; 
        max-height: none;  
        overflow-y: visible; 
    }

    .article-content { padding: 0 !important; }
    .post-title { font-size: 1.6rem; }

    .post-body h2 {
        font-size: 1.3rem;
        margin-top: 30px;
    }
    
    .post-body p {
        font-size: 1rem;
        line-height: 1.4;
    }

    pre code { font-weight: 600 !important; }

   .back-to-top-btn {
        bottom: 25px !important;
        right: 15px !important;
        padding: 8px 12px;
        font-size: 12px;
    }

    /* На мобилках сетка всегда в одну колонку */
    .grid {
        grid-template-columns: 1fr !important;
    }

    /* На мобилках горизонтальные карточки с картинкой уходят вертикально */
    a.card-horizontal {
        flex-direction: column;
    }
    
    .card-image {
        width: 100%;
        height: 160px;
        min-width: 100%;
    }
}

@media (max-width: 600px) {
    .specs-list { display: block; }
    .specs-list dt { margin-top: 12px; }
    .specs-list dt:first-child { margin-top: 0; }
    .specs-list dd { margin-top: 2px; margin-bottom: 8px; }
}

/* ==========================================================================
   10. МОБИЛЬНОЕ ВЫПАДАЮЩЕЕ МЕНЮ НАВИГАЦИИ (ЭКРАНЫ < 1000px)
   ========================================================================== */

.mobile-nav-toggle,
.mobile-menu-modal {
    display: none;
}

@media (max-width: 1000px) {
    .article-container {
        flex-direction: column !important;
        gap: 20px !important;
    }

    /* Исходный сайдбар жестко зафиксирован в потоке статьи и никуда не сдвигается */
    .sidebar {
        width: 100% !important;
        position: static !important;
        margin-bottom: 20px !important;
    }

    /* Плавающая кнопка (появляется при скролле > 1000px) */
    .mobile-nav-toggle.floating-toggle-show {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: #1e4520 !important;
        color: #fff;
        font-size: 18px;
        cursor: pointer;
        user-select: none;
        position: fixed !important;
        top: 15px !important;
        right: 15px !important;
        z-index: 9999 !important;
        border-radius: 8px !important;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25) !important;
    }

    /* Состояние кнопки когда меню открыто */
    .mobile-nav-toggle.floating-toggle-show.open {
        background: #1e293b !important;
        border-radius: 50% !important;
    }

    /* Абсолютно независимое всплывающее модальное окно */
    .mobile-menu-modal {
        display: none;
        position: fixed !important;
        top: 65px !important;
        right: 15px !important;
        z-index: 9998 !important;
        width: 75vw !important;
        max-width: 340px !important;
        min-width: 260px !important;
        max-height: 75vh !important;
        overflow-y: auto !important;
        background: transparent !important;
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
    }

    .mobile-menu-modal.active {
        display: block !important;
    }

    .mobile-menu-modal .sidebar-box {
		background: #ffffff !important;
		border-radius: 12px !important;
		padding: 16px 20px !important;
		margin-bottom: 5px !important; /* Тот самый физический разрыв между карточками */
		box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08) !important;
		border: 1px solid #e2e8f0 !important;
    }
	
	.mobile-menu-modal .sidebar-box:last-child {
    margin-bottom: 0 !important;
	}
	
}
