/* === Переменные и базовые настройки ================================== */
:root {
    --primary-color: #f8f9fa;
    --secondary-color: #e9ecef;
    --accent-color: #dee2e6;
    --dark-color: #adb5bd;
    --text-primary: #212529;
    --text-secondary: #495057;
    --spacing-unit: 8px;
    --border-radius: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Crimson Text', Georgia, serif;
    line-height: 1.6;
    color: var(--text-primary);
    background-color: var(--primary-color);
}

h1, h2, h3, h4, h5, h6,
.nav-title, .button, .label {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* === Сетка ============================================================= */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 calc(var(--spacing-unit) * 3);
}

.grid {
    display: grid;
    gap: calc(var(--spacing-unit) * 4);
}

.grid-2 {
    grid-template-columns: 1fr 1fr;
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* === Типографика ======================================================= */
h1 {
    font-size: clamp(2.5rem, 5vw, 4rem);
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: calc(var(--spacing-unit) * 3);
    letter-spacing: -0.02em;
}

h2 {
    font-size: clamp(2rem, 4vw, 3rem);
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: calc(var(--spacing-unit) * 2);
    color: var(--text-primary);
}

h3 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: calc(var(--spacing-unit) * 2);
}

p {
    font-size: 1.125rem;
    margin-bottom: calc(var(--spacing-unit) * 2);
    color: var(--text-secondary);
}

/* === Шапка ============================================================= */
.header {
    position: fixed;
    top: 0;
    width: 100%;
    background-color: rgba(248, 249, 250, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--accent-color);
    z-index: 1000;
    transition: all 0.3s ease;
}

.nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: calc(var(--spacing-unit) * 2) 0;
}

.nav-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.01em;
}

.nav-list {
    display: flex;
    list-style: none;
    gap: calc(var(--spacing-unit) * 4);
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    padding: calc(var(--spacing-unit)) calc(var(--spacing-unit) * 2);
    border-radius: var(--border-radius);
    font-family: 'Inter', sans-serif;
}

.nav-link:hover {
    color: var(--text-primary);
    background-color: var(--secondary-color);
    transform: translateY(-1px);
}

/* === Главный блок ====================================================== */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding-top: calc(var(--spacing-unit) * 10);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
}

.hero-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: calc(var(--spacing-unit) * 8);
    align-items: center;
}

.hero-text h1 {
    color: var(--text-primary);
}

.hero-text p {
    font-size: 1.25rem;
    max-width: 500px;
    margin-bottom: calc(var(--spacing-unit) * 4);
}

.hero-image {
    text-align: center;
}

.hero-image img {
    max-width: 100%;
    height: auto;
    border-radius: var(--border-radius);
    box-shadow: 0 20px 40px rgba(173, 181, 189, 0.2);
    transition: transform 0.3s ease;
}

.hero-image img:hover {
    transform: scale(1.02);
}

/* === Кнопки ============================================================ */
.button {
    display: inline-block;
    padding: calc(var(--spacing-unit) * 2) calc(var(--spacing-unit) * 4);
    border-radius: var(--border-radius);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
    border: 2px solid;
    cursor: pointer;
    font-size: 1rem;
    font-family: 'Inter', sans-serif;
}

.button-primary {
    background-color: var(--text-primary);
    color: var(--primary-color);
    border-color: var(--text-primary);
}

.button-primary:hover {
    background-color: var(--text-secondary);
    border-color: var(--text-secondary);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(33, 37, 41, 0.2);
}

.button-secondary {
    background-color: transparent;
    color: var(--text-primary);
    border-color: var(--accent-color);
}

.button-secondary:hover {
    background-color: var(--secondary-color);
    transform: translateY(-2px);
}

.button-group {
    display: flex;
    gap: calc(var(--spacing-unit) * 2);
    flex-wrap: wrap;
}

/* === Секции ============================================================ */
.section {
    padding: calc(var(--spacing-unit) * 12) 0;
}

.section:nth-child(even) {
    background-color: var(--secondary-color);
}

.section-header {
    text-align: center;
    margin-bottom: calc(var(--spacing-unit) * 8);
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

/* === Карточки ========================================================== */
.card {
    background: white;
    border-radius: var(--border-radius);
    padding: calc(var(--spacing-unit) * 4);
    box-shadow: 0 4px 20px rgba(173, 181, 189, 0.1);
    transition: all 0.3s ease;
    height: 100%;
    border: 1px solid var(--accent-color);
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(173, 181, 189, 0.15);
}

.card-icon {
    width: 64px;
    height: 64px;
    background-color: var(--secondary-color);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: calc(var(--spacing-unit) * 3);
    font-size: 1.5rem;
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.card:hover .card-icon {
    background-color: var(--accent-color);
    transform: scale(1.1);
}

/* === Статистика ======================================================== */
.stats {
    text-align: center;
}

.stat-number {
    font-size: 3rem;
    font-weight: 700;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    display: block;
}

.stat-label {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
    font-family: 'Inter', sans-serif;
}

/* === Подвал ============================================================ */
.footer {
    background-color: var(--text-primary);
    color: var(--primary-color);
    padding: calc(var(--spacing-unit) * 8) 0 calc(var(--spacing-unit) * 4) 0;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: calc(var(--spacing-unit) * 4);
    margin-bottom: calc(var(--spacing-unit) * 4);
}

.footer h4 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: calc(var(--spacing-unit) * 2);
    color: var(--primary-color);
}

.footer p, .footer a {
    color: var(--dark-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer a:hover {
    color: var(--primary-color);
}

.footer-bottom {
    text-align: center;
    padding-top: calc(var(--spacing-unit) * 4);
    border-top: 1px solid var(--text-secondary);
    color: var(--dark-color);
}

/* === Мобильная навигация ============================================== */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-primary);
}

/* === Адаптивность ===================================================== */
@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 {
        grid-template-columns: 1fr;
    }
    
    .hero-content {
        grid-template-columns: 1fr;
        text-align: center;
    }
    
    .nav-list {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background-color: var(--primary-color);
        flex-direction: column;
        padding: calc(var(--spacing-unit) * 2);
        border-top: 1px solid var(--accent-color);
    }
    
    .nav-list.active {
        display: flex;
    }
    
    .nav-toggle {
        display: block;
    }
    
    .button-group {
        justify-content: center;
    }
}

/* === Плавная прокрутка ================================================ */
html {
    scroll-behavior: smooth;
}

/* === Кастомный скроллбар ============================================== */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--secondary-color);
}

::-webkit-scrollbar-thumb {
    background: var(--dark-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* === Хлебные крошки ================================================== */
.breadcrumbs {
    max-width: 1200px;
    margin: 1.5rem auto 0;
    padding: 0 1rem;
    font-size: 0.875rem;
    color: #777;
}

.breadcrumbs a {
    color: var(--text-primary);
    text-decoration: none;
}

.breadcrumbs a:hover {
    color: var(--text-secondary);
    text-decoration: underline;
}

.breadcrumbs span {
    color: #555;
}

/* === Стили для записей блога ========================================== */
.post-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
    max-width: 1200px;
    margin: 2.5rem auto;
    padding: 0 1rem;
}

.post-item {
    background: #fff;
    border: 1px solid var(--accent-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(173, 181, 189, 0.1);
    display: flex;
    flex-direction: column;
    transition: transform 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.post-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(173, 181, 189, 0.15);
}

.post-featured-image img {
    width: 100%;
    height: auto;
    display: block;
}

.post-item h3 {
    font-size: 1.25rem;
    margin: 1rem;
    line-height: 1.4;
}

.post-item h3 a {
    color: var(--text-primary);
    text-decoration: none;
}

.post-item h3 a:hover {
    color: var(--text-secondary);
}

.post-item p {
    margin: 0 1rem 1.25rem;
    color: var(--text-secondary);
    flex: 1 0 auto;
}

.post-item > a:last-of-type {
    align-self: flex-start;
    margin: 0 1rem 1.25rem;
    background: var(--text-primary);
    color: #fff;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    font-size: 0.875rem;
    transition: background 0.2s ease-in-out;
}

.post-item > a:last-of-type:hover {
    background: var(--text-secondary);
}

/* === Пагинация ======================================================== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 3rem;
    font-weight: 600;
}

.page-numbers {
    display: inline-block;
    padding: 0.5rem 0.9rem;
    border: 1px solid var(--accent-color);
    border-radius: var(--border-radius);
    text-decoration: none;
    color: var(--text-primary);
    transition: background 0.2s ease;
}

.page-numbers.current,
.page-numbers:hover {
    background: var(--text-primary);
    color: #fff;
    border-color: var(--text-primary);
}

.next.page-numbers,
.prev.page-numbers {
    border-color: transparent;
    color: var(--text-primary);
}

.next.page-numbers:hover,
.prev.page-numbers:hover {
    color: var(--text-secondary);
    background: transparent;
}

/* === Страница записи/страницы ========================================= */
.page-content {
    max-width: 800px;
    margin: 6rem auto 3rem;
    padding: 0 1rem 2rem;
    background: #fff;
    border: 1px solid var(--accent-color);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 20px rgba(173, 181, 189, 0.1);
    overflow: hidden;
}

.page-content .post-featured-image img {
    width: 100%;
    height: auto;
    display: block;
}

.page-content h1 {
    font-size: 1.75rem;
    margin: 1.5rem 0 1rem;
    line-height: 1.3;
    color: var(--text-primary);
    text-align: center;
}

.page-content .content {
    padding: 1rem;
}

.page-content .content p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

/* === Главная страница (Homepage) ====================================== */
.homepage {
    padding-top: calc(var(--spacing-unit) * 10);
}

/* === Hero Section для главной страницы ================================ */
.hero-section {
    padding: calc(var(--spacing-unit) * 8) 0;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
}

.hero-section .hero-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: calc(var(--spacing-unit) * 8);
    align-items: center;
}

.hero-section .hero-image {
    text-align: center;
}

.hero-section .hero-image img {
    max-width: 100%;
    height: auto;
    border-radius: var(--border-radius);
    box-shadow: 0 20px 40px rgba(173, 181, 189, 0.2);
    transition: transform 0.3s ease;
}

.hero-section .hero-image img:hover {
    transform: scale(1.02);
}

.hero-section .hero-text h1 {
    color: var(--text-primary);
    margin-bottom: calc(var(--spacing-unit) * 3);
}

.hero-section .hero-text p {
    font-size: 1.25rem;
    margin-bottom: calc(var(--spacing-unit) * 4);
    color: var(--text-secondary);
}

/* === Random Posts Section ============================================= */
.random-posts {
    padding: calc(var(--spacing-unit) * 8) 0;
    background-color: var(--primary-color);
}

.posts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: calc(var(--spacing-unit) * 4);
    margin-bottom: calc(var(--spacing-unit) * 6);
}

.post-card {
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(173, 181, 189, 0.1);
    transition: all 0.3s ease;
    border: 1px solid var(--accent-color);
}

.post-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(173, 181, 189, 0.15);
}

.post-card .post-thumbnail {
    overflow: hidden;
}

.post-card .post-thumbnail img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.post-card .post-thumbnail img:hover {
    transform: scale(1.05);
}

.post-card .post-content {
    padding: calc(var(--spacing-unit) * 3);
}

.post-card .post-content h3 {
    margin-bottom: 0;
    font-size: 1.25rem;
    line-height: 1.4;
}

.post-card .post-content h3 a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.post-card .post-content h3 a:hover {
    color: var(--text-secondary);
}

.blog-link {
    text-align: center;
}

/* === Адаптивность для главной страницы =============================== */
@media (max-width: 768px) {
    .hero-section .hero-content {
        grid-template-columns: 1fr;
        text-align: center;
        gap: calc(var(--spacing-unit) * 4);
    }
    
    .posts-grid {
        grid-template-columns: 1fr;
        gap: calc(var(--spacing-unit) * 3);
    }
}

/* === Страница 404 ===================================================== */
.error-404 {
    text-align: center;
    padding: 3rem 1rem;
}

.error-404 h1 {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.error-404 p {
    font-size: 1.25rem;
    margin-bottom: 2rem;
}