/* =========================================
   PF HISTORY — отдельная тема
   ========================================= */

:root {
    --bg-h: #f5efe6;
    --surface-h: #fbf6ee;
    --text-main-h: #2a2320;
    --text-muted-h: #6b5d52;
    --accent-h: #7f1d1d;
    --accent-h-hover: #991b1b;
    --border-h: #e3d5c3;
}

/* Применяем тему к body на страницах истории */
body.history-theme {
    background: var(--bg-h);
    color: var(--text-main-h);
}

body.history-theme .header {
    background: rgba(245, 239, 230, 0.9);
    border-bottom: 1px solid var(--border-h);
}

body.history-theme .nav a {
    color: var(--text-main-h);
}

body.history-theme .nav a::after {
    background: var(--accent-h);
}

body.history-theme .nav a:hover {
    color: var(--accent-h);
}

/* =========================================
   HERO РАЗДЕЛА
   ========================================= */
.history-hero {
    padding: 140px 8% 60px 8%;
    text-align: center;
    background: linear-gradient(135deg, #f5efe6 0%, #ecdfc9 100%);
    border-bottom: 1px solid var(--border-h);
}

.history-hero .era-tag {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--accent-h);
    padding: 8px 18px;
    border: 1px solid var(--accent-h);
    border-radius: 50px;
    margin-bottom: 25px;
}

.history-hero h1 {
    font-family: 'Playfair Display', serif;
    font-size: 3.8rem;
    color: var(--text-main-h);
    margin-bottom: 20px;
    line-height: 1.1;
}

.history-hero p {
    font-size: 1.15rem;
    color: var(--text-muted-h);
    max-width: 650px;
    margin: 0 auto;
    line-height: 1.7;
}

/* =========================================
   ЛЕНТА ЭПОХ (фильтр по векам)
   ========================================= */
.era-filter {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 40px 8% 0 8%;
}

.era-btn {
    padding: 10px 22px;
    border: 1px solid var(--border-h);
    background: var(--surface-h);
    color: var(--text-muted-h);
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: inherit;
    width: auto;
}

.era-btn:hover {
    border-color: var(--accent-h);
    color: var(--accent-h);
}

.era-btn.active {
    background: var(--accent-h);
    color: #f5efe6;
    border-color: var(--accent-h);
}

/* =========================================
   СЕТКА ИСТОРИЧЕСКИХ СТАТЕЙ
   ========================================= */
.history-grid-section {
    padding: 60px 8% 100px 8%;
}

.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 30px;
}

.history-card {
    background: var(--surface-h);
    border: 1px solid var(--border-h);
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.35s ease;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Стилизованная "буквица" с годом */
.history-card::before {
    content: attr(data-year);
    position: absolute;
    top: 15px;
    right: 20px;
    font-family: 'Playfair Display', serif;
    font-size: 3rem;
    font-weight: 700;
    color: rgba(127, 29, 29, 0.08);
    z-index: 2;
    pointer-events: none;
}

.history-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(127, 29, 29, 0.12);
    border-color: var(--accent-h);
}

.history-card-image {
    width: 100%;
    height: 220px;
    object-fit: cover;
    filter: sepia(20%) contrast(105%);
    border-bottom: 1px solid var(--border-h);
    transition: filter 0.35s ease;
}

.history-card:hover .history-card-image {
    filter: sepia(0%) contrast(110%);
}

.history-card-content {
    padding: 28px 26px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
}

.history-era-label {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: var(--accent-h);
    margin-bottom: 12px;
}

.history-card h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.4rem;
    color: var(--text-main-h);
    line-height: 1.3;
    margin-bottom: 12px;
}

.history-card p {
    font-size: 0.95rem;
    color: var(--text-muted-h);
    line-height: 1.65;
    flex-grow: 1;
}

.history-card-date {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted-h);
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border-h);
    font-style: italic;
}

/* =========================================
   "ДЕНЬ В ИСТОРИИ" — КОМПАКТНЫЙ БЛОК
   ========================================= */
.day-in-history {
    display: flex;
    align-items: center;
    gap: 20px;
    max-width: 900px;
    margin: 40px auto 0 auto;
    padding: 16px 24px;
    background: linear-gradient(90deg, #fbf6ee 0%, #f5efe6 100%);
    border: 1px solid var(--border-h);
    border-left: 4px solid var(--accent-h);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.25s ease;
    position: relative;
    overflow: hidden;
}

.day-in-history:hover {
    border-left-color: #991b1b;
    background: linear-gradient(90deg, #f5e6d3 0%, #f0e0c9 100%);
    box-shadow: 0 4px 16px rgba(127, 29, 29, 0.08);
    transform: translateX(3px);
}

/* Дата — компактный бордовый бейдж */
.day-date {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 52px;
    padding: 6px 8px;
    background: var(--accent-h);
    color: #f5efe6;
    border-radius: 8px;
    line-height: 1;
    font-family: 'Playfair Display', serif;
}

.day-date .day-num {
    font-size: 1.4rem;
    font-weight: 700;
}

.day-date .day-month {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 2px;
    opacity: 0.85;
}

/* Текст по центру */
.day-content {
    flex: 1;
    min-width: 0;
}

.day-label {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 1.8px;
    text-transform: uppercase;
    color: var(--accent-h);
    opacity: 0.7;
    margin-bottom: 3px;
}

.day-in-history h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.05rem;
    color: var(--text-main-h);
    margin: 0;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Стрелка справа */
.day-arrow {
    flex-shrink: 0;
    color: var(--accent-h);
    font-size: 1.2rem;
    transition: transform 0.25s ease;
    opacity: 0.6;
}

.day-in-history:hover .day-arrow {
    transform: translateX(4px);
    opacity: 1;
}

/* Мобильная версия */
@media (max-width: 768px) {
    .day-in-history {
        margin: 25px 5% 0 5%;
        padding: 12px 16px;
        gap: 14px;
        max-width: none;
    }

    .day-date {
        min-width: 44px;
        padding: 5px 6px;
    }

    .day-date .day-num {
        font-size: 1.15rem;
    }

    .day-date .day-month {
        font-size: 0.58rem;
    }

    .day-in-history h3 {
        font-size: 0.9rem;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .day-label {
        font-size: 0.6rem;
    }

    .day-arrow {
        font-size: 1rem;
    }
}

/* =========================================
   МОДАЛЬНОЕ ОКНО (бордовая тема)
   ========================================= */
body.history-theme .modal {
    background: rgba(42, 35, 32, 0.85);
}

body.history-theme .modal-content {
    background: var(--surface-h);
}

body.history-theme .close-btn {
    color: var(--text-muted-h);
}

body.history-theme .close-btn:hover {
    color: var(--accent-h);
}

body.history-theme .modal-content h2 {
    font-family: 'Playfair Display', serif;
    color: var(--text-main-h);
}

body.history-theme .modal-date {
    color: var(--accent-h);
}

body.history-theme .modal-body {
    color: var(--text-main-h);
    font-family: 'Playfair Display', Georgia, serif;
    font-size: 1.15rem;
    line-height: 1.85;
}

body.history-theme .modal-body h2,
body.history-theme .modal-body h3 {
    font-family: 'Playfair Display', serif;
    color: var(--accent-h);
}

body.history-theme .modal-body blockquote {
    border-left: 4px solid var(--accent-h);
    background: rgba(127, 29, 29, 0.05);
}

body.history-theme .reading-progress {
    background: linear-gradient(90deg, var(--accent-h), #b91c1c);
}

/* =========================================
   "ЧИТАТЬ ТАКЖЕ" в историческом стиле
   ========================================= */
body.history-theme .related-block {
    border-top-color: var(--border-h);
}

body.history-theme .related-title {
    color: var(--text-main-h);
}

body.history-theme .related-title::after {
    background: var(--accent-h);
}

body.history-theme .related-item {
    background: rgba(127, 29, 29, 0.04);
}

body.history-theme .related-item:hover {
    background: rgba(127, 29, 29, 0.08);
    border-left-color: var(--accent-h);
}

body.history-theme .related-category {
    color: var(--accent-h);
}

body.history-theme .related-item h4 {
    color: var(--text-main-h);
}

body.history-theme .related-item:hover h4 {
    color: var(--accent-h);
}

/* =========================================
   ФУТЕР
   ========================================= */
body.history-theme footer {
    background: #2a2320;
    color: #c8b8a8;
}

body.history-theme .footer-nav a {
    color: #a89683;
}

body.history-theme .footer-nav a:hover {
    color: #f5efe6;
}

/* =========================================
   МОБИЛЬНАЯ АДАПТАЦИЯ
   ========================================= */
@media (max-width: 768px) {
    .history-hero {
        padding: 100px 5% 40px 5%;
    }
    .history-hero h1 {
        font-size: 2.4rem;
    }
    .history-hero p {
        font-size: 1rem;
    }
    .era-filter {
        padding: 30px 5% 0 5%;
        justify-content: flex-start;
        overflow-x: auto;
        flex-wrap: nowrap;
        scrollbar-width: none;
    }
    .era-filter::-webkit-scrollbar {
        display: none;
    }
    .era-btn {
        flex-shrink: 0;
        white-space: nowrap;
    }
    .history-grid-section {
        padding: 40px 5% 60px 5%;
    }
    .history-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    .history-card-image {
        height: 180px;
    }
    .history-card h3 {
        font-size: 1.2rem;
    }
    .history-card::before {
        font-size: 2.2rem;
    }
    .day-in-history {
        margin: 25px 5% 0 5%;
        padding: 30px 22px;
    }
    .day-in-history h3 {
        font-size: 1.35rem;
        max-width: 100%;
    }
    .day-in-history p {
        max-width: 100%;
    }
    .day-in-history .day-date {
        font-size: 2.2rem;
    }
}
/* =========================================
   ФИЛЬТР ПО СТРАНАМ (появляется после века)
   ========================================= */
.country-filter-wrapper {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s ease, padding 0.3s ease;
    opacity: 0;
    padding: 0 8%;
}

.country-filter-wrapper.visible {
    max-height: 120px;
    opacity: 1;
    padding: 20px 8% 0 8%;
}

.country-filter {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 14px 0;
    border-top: 1px dashed var(--border-h);
}

.country-btn {
    padding: 8px 18px;
    border: 1px solid var(--border-h);
    background: transparent;
    color: var(--text-muted-h);
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    font-family: inherit;
    width: auto;
}

.country-btn:hover {
    border-color: var(--accent-h);
    color: var(--accent-h);
}

.country-btn.active {
    background: var(--accent-h);
    color: #f5efe6;
    border-color: var(--accent-h);
}

/* =========================================
   КНОПКА "ПОКАЗАТЬ ЕЩЁ"
   ========================================= */
.load-more-wrapper {
    text-align: center;
    margin-top: 45px;
}

.load-more-btn {
    display: inline-block;
    padding: 16px 42px;
    background: transparent;
    border: 2px solid var(--accent-h);
    color: var(--accent-h);
    border-radius: 50px;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s ease;
    width: auto;
}

.load-more-btn:hover {
    background: var(--accent-h);
    color: #f5efe6;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(127, 29, 29, 0.2);
}

.load-more-btn:active {
    transform: scale(0.97);
}

/* =========================================
   СПЕЦИАЛЬНЫЕ ПРОЕКТЫ (горизонтальный скролл)
   ========================================= */
.special-projects {
    padding: 80px 0 100px 0;
    border-top: 1px solid var(--border-h);
    margin-top: 60px;
    background: linear-gradient(180deg, transparent 0%, rgba(127, 29, 29, 0.03) 100%);
}

.special-projects-header {
    padding: 0 8%;
    margin-bottom: 35px;
}

.special-projects-header h2 {
    font-family: 'Playfair Display', serif;
    font-size: 2.2rem;
    color: var(--text-main-h);
    margin-bottom: 10px;
    position: relative;
    display: inline-block;
}

.special-projects-header h2::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -8px;
    width: 60px;
    height: 4px;
    background: var(--accent-h);
    border-radius: 2px;
}

.special-projects-header p {
    color: var(--text-muted-h);
    font-size: 1rem;
    margin-top: 20px;
}

/* Горизонтальная прокрутка */
.projects-scroll {
    display: flex;
    gap: 25px;
    overflow-x: auto;
    padding: 10px 8% 30px 8%;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-h) var(--border-h);
}

.projects-scroll::-webkit-scrollbar {
    height: 6px;
}

.projects-scroll::-webkit-scrollbar-track {
    background: var(--border-h);
    border-radius: 3px;
    margin: 0 8%;
}

.projects-scroll::-webkit-scrollbar-thumb {
    background: var(--accent-h);
    border-radius: 3px;
}

/* Карточка проекта */
.project-card {
    flex-shrink: 0;
    width: 320px;
    height: 220px;
    border-radius: 16px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    scroll-snap-align: start;
    transition: transform 0.35s ease, box-shadow 0.35s ease;
    background: #2a2320;
}

.project-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 20px 40px rgba(127, 29, 29, 0.25);
}

.project-card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.55;
    transition: opacity 0.35s ease, transform 0.5s ease;
}

.project-card:hover .project-card-image {
    opacity: 0.75;
    transform: scale(1.05);
}

.project-card-overlay {
    position: absolute;
    inset: 0;
    padding: 25px;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    background: linear-gradient(180deg, transparent 40%, rgba(42, 35, 32, 0.9) 100%);
    color: #f5efe6;
}

.project-card-label {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #e0b8b8;
    margin-bottom: 8px;
}

.project-card h3 {
    font-family: 'Playfair Display', serif;
    font-size: 1.5rem;
    line-height: 1.2;
    margin-bottom: 6px;
    color: #f5efe6;
}

.project-card .project-count {
    font-size: 0.85rem;
    color: #c8b8a8;
}

/* Мобильная адаптация */
@media (max-width: 768px) {
    .country-filter-wrapper.visible {
        padding: 15px 5% 0 5%;
        max-height: 200px;
    }

    .country-filter {
        justify-content: flex-start;
        overflow-x: auto;
        flex-wrap: nowrap;
        scrollbar-width: none;
        padding: 10px 0;
    }

    .country-filter::-webkit-scrollbar {
        display: none;
    }

    .country-btn {
        flex-shrink: 0;
        white-space: nowrap;
        font-size: 0.8rem;
        padding: 7px 14px;
    }

    .load-more-btn {
        padding: 14px 32px;
        font-size: 0.9rem;
        width: 90%;
    }

    .special-projects {
        padding: 50px 0 60px 0;
    }

    .special-projects-header {
        padding: 0 5%;
    }

    .special-projects-header h2 {
        font-size: 1.6rem;
    }

    .projects-scroll {
        padding: 10px 5% 25px 5%;
        gap: 15px;
    }

    .project-card {
        width: 260px;
        height: 180px;
    }

    .project-card h3 {
        font-size: 1.2rem;
    }
}