/* --- БАЗА --- */
body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: #ffffff;
    color: #2f3a33;
    line-height: 1.7;
    margin: 0;
    padding: 0;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 20px;
}

a {
    color: #2e7d32;
}

/* --- ШАПКА --- */
/* Заголовок и кнопка входа — обычные элементы внутри header, в одном
   flex-ряду. Шапка скроллится вместе со страницей как единое целое:
   заголовок и кнопка уходят за край экрана одновременно. */
header {
    padding: 28px 0;
    border-bottom: 3px solid #a5d6a7;
    background: linear-gradient(180deg, #f1f8f2 0%, #ffffff 100%);
}

.header-inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    min-height: 48px;
    text-align: left;
}

.site-title {
    color: #1b5e20;
    font-size: 2.5rem;
    line-height: 1;
    margin: 0;
}

.site-title-link {
    color: inherit;
    text-decoration: none;
}

.site-title-link:hover {
    opacity: 0.85;
}

.site-subtitle {
    color: #4caf50;
    font-size: 1.2rem;
    margin-top: 10px;
}

/* --- КНОПКА АДМИНА (ЧАСТЬ ШАПКИ, УХОДИТ СО СКРОЛЛОМ ВМЕСТЕ С ЗАГОЛОВКОМ) --- */
.admin-corner {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.admin-link {
    display: inline-block;
    padding: 8px 18px;
    border: 2px solid #2e7d32;
    border-radius: 6px;
    color: #2e7d32;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    background: #ffffff;
    transition: background 0.2s ease, color 0.2s ease;
}

.admin-link:hover {
    background: #2e7d32;
    color: #ffffff;
}

.admin-link.admin-link-primary {
    background: #2e7d32;
    color: #ffffff;
}

.admin-link.admin-link-primary:hover {
    background: #1b5e20;
}

@media (max-width: 600px) {
    .header-inner {
        justify-content: center;
        text-align: center;
    }

    .admin-corner {
        justify-content: center;
    }
}

/* --- СТИЛЬ СТАТЬИ --- */
.post-content h2 {
    color: #1b5e20;
    border-left: 5px solid #4caf50;
    padding-left: 15px;
    margin-top: 40px;
}

.post-content p {
    font-size: 1.1rem;
    margin-bottom: 20px;
    color: #3c463f;
    white-space: pre-line;
}

.post-content ul {
    background: #f4faf4;
    padding: 25px 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(46, 125, 50, 0.08);
    list-style: none;
}

.post-content li {
    position: relative;
    padding-left: 25px;
    margin-bottom: 12px;
    color: #3c463f;
}

.post-content li::before {
    content: "✅";
    position: absolute;
    left: 0;
    top: 0;
}

hr.divider {
    border: 0;
    height: 1px;
    background: #c8e6c9;
    margin: 50px 0;
}

/* --- КАТАЛОГ СТАТЕЙ И ПОИСК (ОТДЕЛЬНАЯ ПОЛОСА ПОД ШАПКОЙ) --- */
/* Липкая полоса: обычный блок в потоке страницы, пока не долистали до неё,
   а затем "прилипает" к верху окна и остаётся видна поверх контента —
   как только шапка с заголовком уходит за край. */
.toolbar {
    position: sticky;
    top: 0;
    z-index: 40;
    background: #f1f8f2;
    border-bottom: 1px solid #c8e6c9;
    padding: 20px 0;
    margin-bottom: 40px;
}

.toolbar-inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
}

.header-tools {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.catalog {
    position: relative;
}

.catalog-toggle {
    list-style: none;
    cursor: pointer;
    padding: 13px 24px;
    border-radius: 8px;
    border: 2px solid #2e7d32;
    color: #2e7d32;
    font-weight: 600;
    font-size: 1rem;
    background: #ffffff;
    user-select: none;
    white-space: nowrap;
    transition: background 0.2s ease, color 0.2s ease;
}

.catalog-toggle::-webkit-details-marker {
    display: none;
}

.catalog[open] .catalog-toggle,
.catalog-toggle:hover {
    background: #2e7d32;
    color: #ffffff;
}

.catalog-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: #ffffff;
    border: 2px solid #a5d6a7;
    border-radius: 10px;
    box-shadow: 0 12px 28px rgba(27, 94, 32, 0.15);
    padding: 8px;
    display: flex;
    flex-direction: column;
    min-width: 220px;
    max-height: 320px;
    overflow-y: auto;
    z-index: 20;
}

.catalog-group {
    display: flex;
    flex-direction: column;
}

.catalog-group + .catalog-group {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid #e5e7eb;
}

.catalog-group-title {
    padding: 6px 12px 2px;
    color: #6b7280;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.catalog-menu a {
    padding: 9px 12px;
    border-radius: 6px;
    color: #2f3a33;
    text-decoration: none;
    font-size: 0.9rem;
}

.catalog-menu a:hover {
    background: #f1f8f2;
    color: #2e7d32;
}

.catalog-empty {
    padding: 9px 12px;
    color: #6b7280;
    font-size: 0.9rem;
}

.search-form {
    display: flex;
    flex: 1;
    max-width: 480px;
    min-width: 220px;
}

.search-form input {
    flex: 1;
    border: 2px solid #a5d6a7;
    border-right: none;
    border-radius: 8px 0 0 8px;
    padding: 12px 16px;
    font-size: 1rem;
    background: #ffffff;
    color: #2f3a33;
}

.search-form input:focus {
    outline: none;
    border-color: #2e7d32;
}

.search-form button {
    border: 2px solid #2e7d32;
    border-left: none;
    background: #2e7d32;
    color: #ffffff;
    border-radius: 0 8px 8px 0;
    padding: 0 22px;
    font-size: 1.1rem;
    cursor: pointer;
}

/* --- ПЕРЕКЛЮЧАТЕЛЬ ЯЗЫКА --- */
.lang-switch {
    display: flex;
    justify-content: center;
    gap: 6px;
}

.lang-switch a {
    padding: 12px 14px;
    border: 2px solid #2e7d32;
    border-radius: 8px;
    color: #2e7d32;
    font-weight: 600;
    font-size: 0.9rem;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.2s ease, color 0.2s ease;
}

.lang-switch a:hover {
    background: #e8f5e9;
}

.lang-switch a.active {
    background: #2e7d32;
    color: #ffffff;
}

@media (max-width: 600px) {
    .header-tools {
        flex-direction: column;
        align-items: stretch;
    }

    .search-form {
        max-width: none;
    }

    .catalog-menu {
        left: 0;
        right: 0;
    }
}

/* --- ГЛАВНАЯ КНОПКА-БАННЕР (СТАТЬЯ) --- */
.hero-btn {
    display: block;
    width: 100%;
    height: 220px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border: 3px solid #2e7d32;
    border-radius: 10px;
    box-sizing: border-box;
    position: relative;
    overflow: hidden;
}

.hero-btn::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(27, 94, 32, 0.45);
    z-index: 1;
}

.btn-text {
    position: relative;
    z-index: 2;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    color: white;
    font-size: 2rem;
    font-weight: bold;
    text-decoration: none;
    text-transform: uppercase;
    letter-spacing: 2px;
    text-align: center;
    padding: 0 20px;
}

.hero-btn:hover {
    filter: brightness(1.1);
    cursor: pointer;
}

/* --- КНОПКИ-СТАТЬИ ВНИЗУ ГЛАВНОЙ СТРАНИЦЫ --- */
.article-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 25px;
    margin-top: 40px;
}

.article-btn {
    display: block;
    height: 200px;
    border-radius: 10px;
    border: 3px solid #2e7d32;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
    overflow: hidden;
    text-decoration: none;
    box-shadow: 0 2px 10px rgba(46, 125, 50, 0.15);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.article-btn::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(27, 94, 32, 0.45);
    z-index: 1;
    transition: background 0.2s ease;
}

.article-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(46, 125, 50, 0.25);
}

.article-btn:hover::after {
    background: rgba(27, 94, 32, 0.3);
}

.article-btn-text {
    position: relative;
    z-index: 2;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    color: #ffffff;
    font-size: 1.3rem;
    font-weight: bold;
    text-align: center;
    padding: 0 20px;
}

/* --- ТОП-5 ПОПУЛЯРНЫХ БЛОКОВ (БЕГУЩАЯ ЛЕНТА) --- */
.block-preview-marquee {
    overflow: hidden;
    margin: 20px 0 40px;
    -webkit-mask-image: linear-gradient(to right, transparent, black 4%, black 96%, transparent);
    mask-image: linear-gradient(to right, transparent, black 4%, black 96%, transparent);
}

.block-preview-track {
    display: flex;
    gap: 20px;
    width: max-content;
    animation: block-preview-scroll 32s linear infinite;
}

.block-preview-marquee:hover .block-preview-track {
    animation-play-state: paused;
}

@keyframes block-preview-scroll {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

@media (prefers-reduced-motion: reduce) {
    .block-preview-track {
        animation: none;
    }
}

.block-preview-card {
    display: block;
    flex: 0 0 260px;
    background: #f4faf4;
    border: 2px solid #a5d6a7;
    border-radius: 10px;
    padding: 16px 18px;
    text-decoration: none;
    color: #2f3a33;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.block-preview-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(46, 125, 50, 0.2);
}

.block-preview-type {
    display: inline-block;
    font-weight: 600;
    font-size: 0.8rem;
    padding: 4px 12px;
    border-radius: 999px;
    margin-bottom: 10px;
    background: color-mix(in srgb, var(--type-color, #2e7d32) 15%, white);
    color: var(--type-color, #2e7d32);
}

.block-type-text { --type-color: #3498db; }
.block-type-image { --type-color: #9b59b6; }
.block-type-video { --type-color: #e74c3c; }
.block-type-code { --type-color: #2e7d32; }
.block-type-link { --type-color: #f39c12; }
.block-type-model3d { --type-color: #16a085; }

.block-preview-thumb {
    width: 100%;
    height: 130px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 10px;
}

.block-preview-text {
    margin: 0 0 10px;
    color: #3c463f;
}

.block-preview-code {
    background: #1b5e20;
    color: #d9f2da;
    font-family: 'Consolas', monospace;
    font-size: 0.85rem;
    padding: 10px;
    border-radius: 6px;
    overflow: hidden;
    white-space: pre-wrap;
    margin: 0 0 10px;
}

.block-preview-article {
    font-size: 0.85rem;
    color: #4caf50;
    font-style: italic;
}

/* --- БЛОКИ ВНУТРИ СТАТЬИ --- */
.content-block {
    margin: 30px 0;
}

.block-figure {
    margin: 0;
}

.block-figure img,
.block-figure video {
    max-width: 100%;
    border: 3px solid #2e7d32;
    border-radius: 10px;
    display: block;
}

.block-figure figcaption {
    margin-top: 8px;
    color: #4caf50;
    font-style: italic;
    font-size: 0.95rem;
}

.code-lang {
    display: inline-block;
    background: #2e7d32;
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    padding: 3px 10px;
    border-radius: 6px 6px 0 0;
}

.code-block {
    background: #1b1f1c;
    color: #d9f2da;
    font-family: 'Consolas', monospace;
    font-size: 0.95rem;
    padding: 18px 20px;
    border-radius: 0 8px 8px 8px;
    overflow-x: auto;
    margin: 0;
}

.content-link {
    display: inline-block;
    padding: 10px 20px;
    border: 2px solid #2e7d32;
    border-radius: 6px;
    color: #2e7d32;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s ease, color 0.2s ease;
}

.content-link:hover {
    background: #2e7d32;
    color: #ffffff;
}

.model3d-viewer {
    width: 100%;
    height: 400px;
    border: 3px solid #2e7d32;
    border-radius: 10px;
    background: #f1f8f2;
    overflow: hidden;
}

.block-caption {
    margin-top: 8px;
    color: #4caf50;
    font-style: italic;
    font-size: 0.95rem;
}

/* --- СТАТУС СТАТЬИ (ЧЕРНОВИК / ОПУБЛИКОВАНО) --- */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.status-published {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}

.status-draft {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffe08a;
}

/* --- АДМИНКА: ПОЛЯ БЛОКОВ --- */
.block-fieldset {
    border-top: 1px dashed #c8e6c9;
    padding-top: 15px;
    margin-top: 15px;
}

/* --- ОБЩИЕ КНОПКИ И ФОРМЫ --- */
button,
.btn-action {
    display: inline-block;
    background: #2e7d32;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    padding: 12px 28px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s ease;
}

button:hover,
.btn-action:hover {
    background: #1b5e20;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: #1b5e20;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #c8e6c9;
    border-radius: 6px;
    font-size: 1rem;
    box-sizing: border-box;
    font-family: inherit;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #4caf50;
}

/* --- ТАБЛИЦА СТАТИСТИКИ --- */
.stats-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
    background: #ffffff;
}

.stats-table th,
.stats-table td {
    border: 1px solid #c8e6c9;
    padding: 10px 14px;
    text-align: left;
}

.stats-table th {
    background: #e8f5e9;
    color: #1b5e20;
}

.stats-cards {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin: 20px 0;
}

.stats-card {
    background: #f1f8f2;
    border: 2px solid #a5d6a7;
    border-radius: 10px;
    padding: 20px 30px;
    text-align: center;
}

.stats-card .stats-number {
    font-size: 2rem;
    font-weight: bold;
    color: #2e7d32;
}

/* --- FLASH MESSAGES --- */
.flash-message {
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
    text-align: center;
}
.flash-message.success { background: #d4edda; color: #155724; }
.flash-message.warning { background: #fff3cd; color: #856404; }

/* --- ПОДВАЛ --- */
.site-footer {
    margin-top: 60px;
    background: #f1f8f2;
    border-top: 3px solid #a5d6a7;
    padding: 24px 0;
}

.footer-inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.footer-brand {
    font-weight: 700;
    color: #1b5e20;
}

.footer-about-link {
    color: #2e7d32;
    font-weight: 600;
    text-decoration: none;
}

.footer-about-link:hover {
    text-decoration: underline;
}

.footer-email {
    color: #2e7d32;
    font-weight: 600;
    text-decoration: none;
}

.footer-email:hover {
    text-decoration: underline;
}

/* Адаптив для телефонов */
@media (max-width: 600px) {
    .site-title { font-size: 1.8rem; }
    .hero-btn { height: 180px; }
    .btn-text { font-size: 1.5rem; }
    .article-btn { height: 160px; }
}
