@import url('https://cdn.jsdelivr.net/npm/easymde/dist/easymde.min.css');

/* --- Общие стили страницы --- */
.header {
    position: fixed; /* Фиксируем шапку */
    z-index: 1000; /* Устанавливаем высокий z-index */
}

.chronicles-page {
    padding-top: var(--header-height);
}

.chronicles-page .gallery {
    padding-top: 60px; /* Увеличим отступ сверху */
    padding-bottom: 60px;
}

.chronicles-page h2 {
    text-align: center;
    margin-bottom: 50px;
    font-size: 2.5rem;
}

/* --- Переходим на Grid для загрузки по рядам и стабильности --- */
.timeline-grid {
    display: grid;
    /* Создаем адаптивные колонки, которые заполняют пространство */
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    margin: 0 auto; /* Центрируем сетку */
    min-height: 50vh; /* Чтобы лоадер был виден при первой загрузке */
}

/* --- Стили для поиска и фильтров --- */
.chronicles-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 40px;
    align-items: center;
}
#chronicles-search {
    flex-grow: 1;
    padding: 12px 15px;
    background: var(--light-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-color);
    font-size: 1rem;
    min-width: 250px;
    transition: all 0.3s ease;
    font-family: 'Noto Sans JP', sans-serif;
}

#chronicles-search:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 15px var(--primary-color), inset 0 0 5px rgba(229, 57, 53, 0.5);
    background: var(--white-bg);
}

.filters-container {
    display: flex;
    gap: 10px;
    background-color: transparent;
    padding: 0;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.filter-btn {
    padding: 8px 15px;
    border: none;
    border-right: 1px solid var(--border-color);
    background: var(--white-bg);
    color: var(--secondary-text);
    border-radius: 0;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 700;
    font-family: 'Orbitron', sans-serif;
    text-transform: uppercase;
    font-size: 0.9rem;
}

.filters-container .filter-btn:last-child {
    border-right: none;
}

.filter-btn:hover {
    color: var(--text-color);
    background-color: #3c3c3c;
}

.filter-btn.active {
    background: var(--primary-color);
    color: #fff;
    box-shadow: 0 0 15px var(--primary-color);
}

/* --- Общие стили для элементов сетки --- */
.timeline-item {
    width: 100%;
    background: var(--white-bg);
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    /* Анимация появления */
    opacity: 0;
    transform: translateY(20px);
    animation: fadeIn 0.5s ease-out forwards;
}

.timeline-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 0 20px rgba(0, 191, 255, 0.5); /* Неоновая тень при наведении */
}

/* --- Стили для постов (теперь похожи на promo-card) --- */
.timeline-item--post {
    display: flex;
    flex-direction: column-reverse; /* Контент внизу */
    position: relative;
}

/* Стили для постов с фоновым изображением */
.timeline-item--post[style*="background-image"] {
    background-size: contain; /* Показываем изображение целиком */
    background-position: center top; /* Позиционируем сверху */
    background-repeat: no-repeat; /* Запрещаем повторение */
    min-height: 250px; /* Минимальная высота, чтобы было видно картинку */
}

.timeline-item__content {
    padding: 20px;
    position: relative;
    z-index: 2;
    background: linear-gradient(to top, rgba(0,0,0,0.9) 20%, rgba(0,0,0,0.7) 60%, transparent 100%);
    margin-top: auto;
    color: #fff;
}

/* Дополнительные стили для текстовых постов без заголовка */
.timeline-item__content--text-only {
    background: none; /* Убираем градиент */
    color: var(--text-color); /* Возвращаем основной цвет текста */
    font-size: 1rem;
    line-height: 1.6;
}

/* --- Стили для акционных постов --- */
/* Упрощаем, т.к. базовые стили уже подходят. Добавляем только рамку. */
.timeline-item.is-promo {
    background: linear-gradient(135deg, var(--primary-color) 0%, #a12a28 100%);
    color: #fff;
    border: none;
    box-shadow: 0 5px 25px rgba(229, 57, 53, 0.5);
    position: relative;
}
.timeline-item--post.is-promo {
    border: 2px solid var(--primary-color);
}


.timeline-item.is-promo:hover {
    box-shadow: 0 8px 30px rgba(229, 57, 53, 0.7);
}

/* --- Стили для неактуальных акций --- */
.timeline-item.is-promo.is-expired {
    background-image: none !important; /* Убираем фоновую картинку */
    filter: grayscale(80%); /* Делаем карточку серой */
    opacity: 0.7;
}

.timeline-item.is-promo.is-expired::after {
    content: 'АКЦИЯ ЗАВЕРШЕНА';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-10deg);
    background: rgba(0,0,0,0.7);
    color: #fff;
    padding: 10px 20px;
    border-radius: 5px;
    font-weight: 700;
    font-family: 'Orbitron', sans-serif;
}

.timeline-item__meta {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.timeline-item__title {
    font-size: 1.2rem;
    margin: 0;
    line-height: 1.4;
}

/* Добавляем отступы для списков внутри постов */
.timeline-item__excerpt ul,
.timeline-item__excerpt ol {
    padding-left: 20px;
}

/* --- Стили для фото-моментов (timeline-item--photo) --- */
.timeline-item--photo {
    position: relative;
    cursor: pointer;
    height: 250px; /* Задаем фиксированную высоту для единообразия */
}

.timeline-item--photo .timeline-item__image {
    width: 100%;
    height: 100%; /* Растягиваем изображение на всю высоту карточки */
    object-fit: cover; /* Масштабируем, чтобы покрыть всю область, обрезая лишнее */
    object-position: center; /* Центрируем изображение, чтобы избежать некрасивой обрезки */
    display: block;
}

.timeline-item__overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
    color: #fff;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.timeline-item--photo:hover .timeline-item__overlay {
    opacity: 1;
    transform: translateY(0);
}

/* --- Адаптивность --- */
/* Grid с auto-fill и minmax уже адаптивен, отдельные правила не нужны */

/* Анимация появления карточек */
@keyframes fadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Стили для загрузчика --- */
.chronicles-loader {
    display: none; /* Скрыт по умолчанию */
    text-align: center;
    padding: 40px 0;
}

.loader-dots {
    display: inline-block;
    position: relative;
    width: 80px;
    height: 13px;
}
.loader-dots div {
    position: absolute;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--primary-color);
    animation: loader-dots 1.2s cubic-bezier(0, 0.5, 0.5, 1) infinite;
}
.loader-dots div:nth-child(1) { left: 8px; animation-delay: -0.24s; }
.loader-dots div:nth-child(2) { left: 32px; animation-delay: -0.12s; }
.loader-dots div:nth-child(3) { left: 56px; animation-delay: 0; }
@keyframes loader-dots { 0%, 100% { top: 0; } 50% { top: -10px; } }

/* --- Стили для модального окна постов --- */
/* Эти стили были пропущены, из-за чего оверлей блокировал страницу */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none; /* Не реагировать на клики, когда невидимо */
    transition: opacity 0.3s ease;
}

.modal-overlay.is-visible {
    opacity: 1;
    pointer-events: auto; /* Реагировать на клики, когда видимо */
}
