/* ==========================================================================
   1. ГЛОБАЛЬНЫЕ НАСТРОЙКИ СТРАНИЦЫ И ФИЛЬТРА ДАТ
   ========================================================================== */
:root {
    --color-page-bg: #e2e2e2;
    --color-purple-brick: #3A2C96;
    --color-purple-hover: #2e2378;
    --color-bg-card: #ffffff;
    --color-text-white: #ffffff;
    --color-text-dark: #374151;
    --color-text-black: #000000;
    --transition-magic: 0.5s cubic-bezier(0.25, 1, 0.5, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: var(--color-page-bg);
    color: var(--color-text-dark);
    min-height: 100vh;
    padding-top: 40px;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

.news-page-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.65);
    z-index: 40;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-magic), visibility var(--transition-magic);
}

.news-page-overlay.active {
    opacity: 1;
    visibility: visible;
}

.news-page-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 45px 60px 45px;
}

.news-page-title {
    text-align: center;
    color: var(--color-purple-brick);
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 25px;
}

/* ==========================================================================
   2. СТИЛИ БЛОКА ФИЛЬТРАЦИИ ПО ДАТАМ (ДЛЯ БАБУШЕК)
   ========================================================================== */
.news-filter-panel {
    background-color: var(--color-bg-card);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 40px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    justify-content: center;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.filter-group label {
    font-weight: bold;
    color: var(--color-purple-brick);
    font-size: 16px;
}

/* Крупные селекторы, чтобы бабушкам было легко попадать пальцем */
.filter-select {
    padding: 8px 16px;
    font-size: 16px;
    font-weight: 500;
    border: 2px solid var(--color-purple-brick);
    border-radius: 8px;
    background-color: #ffffff;
    color: var(--color-text-dark);
    cursor: pointer;
    outline: none;
}

.news-bricks-grid {
    display: flex;
    flex-direction: column;
    gap: 40px;
    width: 100%;
}
/* ==========================================================================
   3. УМЕНЬШЕННЫЕ КИРПИЧИ (140px) И РЕЗИНОВЫЕ БЕЛЫЕ КАРТОЧКИ (AUTO)
   ========================================================================== */
.news-brick-item {
    position: relative;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform var(--transition-magic), opacity 0.4s ease, visibility 0.4s ease;
    z-index: 10;
}

/* Скрытие карточек, которые не подошли под выбранную дату */
.news-brick-item.hidden-by-date {
    display: none !important;
}

.news-back-btn {
    display: inline-block;
    color: var(--color-text-white);
    background-color: var(--color-purple-brick);
    border: none;
    font-weight: bold;
    font-size: 15px;
    padding: 10px 20px;
    border-radius: 8px;
    margin-bottom: 15px;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: opacity 0.4s ease, transform 0.4s ease, background-color 0.2s;
    align-self: flex-start;
}

.news-back-btn:hover {
    background-color: var(--color-purple-hover);
}

.news-header-nav-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 25px;
}

.news-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
}

.breadcrumb-link {
    color: var(--color-purple-brick);
    text-decoration: none;
    font-weight: 600;
}

.breadcrumb-link:hover {
    text-decoration: underline;
}

.breadcrumb-separator {
    color: #6b7280;
}

.breadcrumb-current {
    color: #4b5563;
    font-weight: 500;
}

.news-global-back-link {
    display: inline-block;
    color: var(--color-purple-brick);
    text-decoration: none;
    font-weight: bold;
    font-size: 15px;
    padding: 9px 16px;
    border: 2px solid var(--color-purple-brick);
    border-radius: 8px;
    background-color: transparent;
    transition: background-color 0.2s, color 0.2s;
}

.news-global-back-link:hover {
    background-color: var(--color-purple-brick);
    color: var(--color-text-white);
}

.news-empty-notice {
    display: none;
    background-color: var(--color-bg-card);
    border-radius: 10px;
    padding: 30px;
    text-align: center;
    font-size: 16px;
    font-weight: 500;
    color: var(--color-text-dark);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
    margin-top: 20px;
}

/* НОВАЯ КОМПАКТНАЯ ВЫСОТА: Закрытый кирпич теперь ровно 140px */
.news-brick-content-card {
    display: flex;
    width: 100%;
    height: 140px; 
    background-color: var(--color-purple-brick);
    border-radius: 10px; 
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
    cursor: pointer; 
    transition: background-color var(--transition-magic), 
                box-shadow var(--transition-magic), 
                height var(--transition-magic);
}

.news-brick-text-layers {
    width: 100%;
    height: 100%;
    padding: 20px 35px;
    position: relative;
}

.text-layer-preview {
    color: var(--color-text-white);
    opacity: 1;
    visibility: visible;
    transition: opacity 0.25s, visibility 0.25s;
}

.text-layer-preview h3 {
    font-size: 19px;
    margin-bottom: 8px;
    font-weight: bold;
}

/* Ограничиваем превью в две строки, чтобы текст не вылезал из компактного 140px кирпича */
.text-layer-preview p {
    font-size: 14px;
    line-height: 1.4;
    max-height: calc(14px * 1.4 * 2); /* Автоматически рассчитываем высоту ровно под 2 строки текста */
    overflow: hidden; /* Всё, что не поместилось в 2 строки — аккуратно прячем */
    position: relative;
}


.text-layer-full {
    position: absolute;
    top: 24px;
    left: 35px;
    right: 35px;
    color: var(--color-text-black);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s, visibility 0.25s;
}

.text-layer-full h3 {
    font-size: 22px;
    margin-bottom: 15px;
    font-weight: bold;
}

.text-layer-full p {
    font-size: 16px;
    line-height: 1.6;
}

/* МАГИЯ ВЫДЕЛЕНИЯ: Безопасное выделение без вестибулярных искажений */
.news-brick-item.focused-magic {
    z-index: 50; 
    transform: translateY(-4px) !important; 
}

.news-brick-item.focused-magic .news-back-btn {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* РЕЗИНОВАЯ КАРТОЧКА: Высота становится auto и идеально подстраивается под текст */
.news-brick-item.focused-magic .news-brick-content-card {
    background-color: var(--color-bg-card) !important;
    height: auto !important; 
    min-height: 140px;
    box-shadow: 0 20px 40px rgba(58, 44, 150, 0.25), 0 0 0 3px var(--color-purple-brick);
}

.news-brick-item.focused-magic .news-brick-text-layers {
    background-color: var(--color-bg-card) !important;
    height: auto !important;
    border-radius: 10px;
}

.news-brick-item.focused-magic .text-layer-preview {
    opacity: 0;
    visibility: hidden;
}

.news-brick-item.focused-magic .text-layer-full {
    position: relative; 
    top: 0;
    left: 0;
    right: 0;
    opacity: 1;
    visibility: visible;
}

/* КНОПКА-ЯКОРЬ НАВЕРХ */
.scroll-to-top-anchor {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background-color: var(--color-purple-brick);
    color: var(--color-text-white);
    border: none;
    border-radius: 50%;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 35;
    opacity: 0;
    visibility: hidden;
    transform: translateY(15px);
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s, background-color 0.2s;
}

.scroll-to-top-anchor.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.scroll-to-top-anchor:hover {
    background-color: var(--color-purple-hover);
}

/* ==========================================================================
   4. МОБИЛЬНЫЙ АДАПТИВ
   ========================================================================== */
@media (max-width: 768px) {
    body { padding-top: 30px; }
    .news-page-container { padding: 0 15px 40px 15px; }
    .news-page-title { font-size: 24px; margin-bottom: 25px; }
    .news-filter-panel { padding: 15px; gap: 15px; flex-direction: column; align-items: stretch; }
    .filter-group { flex-direction: column; align-items: flex-start; gap: 5px; }
    .filter-select { width: 100%; }
    .news-bricks-grid { gap: 25px; }
    .news-brick-content-card { height: auto; }
    .text-layer-preview p { max-height: none !important; } /* На мобилках показываем превью целиком */
    .news-brick-text-layers { padding: 20px 15px; }
    .text-layer-full { top: 20px; left: 15px; right: 15px; }
    .news-brick-item.focused-magic { transform: translateY(-2px) !important; }
    .scroll-to-top-anchor { bottom: 20px; right: 20px; width: 45px; height: 45px; font-size: 20px; }
}
