/* ===========================================================
   Category Posts Grid
   Единая строгая стилистика сайта: скругления 8px везде,
   никаких «прыжков» на ховере — только чуть более удобная
   лента рубрик на мобильном (горизонтальный скролл вместо
   переноса по строкам).
   =========================================================== */

/* ===== HERO на странице категории ===== */

.cpg-hero{
  position: relative;
  width: 100%;
  min-height: 520px;              /* было 440px — геро-блок выше, текст опускается ниже */
  margin: 0 0 24px;
  border-radius: 16px;
  overflow: hidden;               /* обрезаем всё по радиусу */
  background: #0f1218 center/cover no-repeat;
  box-sizing: border-box;
}

.cpg-hero__overlay{
  position:absolute; inset:0;
  /* чуть более выраженный градиент, чтобы низ читался лучше */
  background: linear-gradient(180deg, rgba(0,0,0,.15) 0%, rgba(0,0,0,.35) 45%, rgba(0,0,0,.78) 100%);
  border-radius: inherit;         /* наследуем радиус */
  pointer-events: none;
}

.cpg-hero__inner{
  position: relative;
  z-index: 2;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;      /* текст прижат к низу */
  gap: 14px;
  padding: 280px 30px 40px;        /* нижний отступ, текст опускается ниже */
  color: #fff;
  border-radius: inherit;         /* наследуем радиус */
}

.cpg-hero__tag{
  align-self: flex-start;
  font-size: 12px;
  line-height: 1;
  font-weight: 700;
  padding: 6px 10px;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 8px;
  color: #fff;
  text-decoration: none;
  -webkit-backdrop-filter: blur(10px) saturate(160%);
  backdrop-filter: blur(10px) saturate(160%);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: background-color .2s ease, border-color .2s ease;
}

.cpg-hero__tag:hover{ background: rgba(255,255,255,.2); border-color: rgba(255,255,255,.4); text-decoration:none; color:#fff; }

.cpg-hero__title{
  margin: 4px 0 0;               /* небольшой отступ сверху */
  font-weight: 800;
  font-size: clamp(22px, 3.2vw, 44px);
  line-height: 1.1;
  letter-spacing: -0.02em;

  /* ключ: отталкиваем заголовок и всё ниже к низу */
  margin-top: auto !important;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.cpg-hero__title a{ color:#fff; text-decoration:none; }
.cpg-hero__title a:hover{ text-decoration:none; color: #dddcdf;}

.cpg-hero__excerpt{
  margin: 0;
  max-width: 80ch;
  opacity: .92;
  font-size: 16px;
}

/* тёмная тема (если используется) */
.gdt-dark .cpg-hero__tag,
.darkmysite_dark_mode_enabled .cpg-hero__tag,
.dark-mode .cpg-hero__tag{ background: rgba(19,24,35,.55); border-color: rgba(234,238,246,.18); text-transform: uppercase;}

/* ===== ОСНОВНАЯ СЕТКА ===== */

.cpg-container {
    display: flex;
    margin: 0 auto;
}

.cpg-main-content {
    flex: 2;
    margin-right: 15px;
}

.cpg-sidebar {
    flex: 1;
}

/* ===== ВИТРИНА: 1 крупный материал + до 2 рядом =====
   Журнальный приём — после hero не сразу ровная сетка, а материал
   покрупнее с парой соседних, и только потом обычная сетка 3×3. */
.cpg-featured-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
    margin: 24px 0;
}

.cpg-featured-row--solo {
    grid-template-columns: 1fr;
}

.cpg-featured-aside {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}

.cpg-featured-aside .cpg-post--compact {
    flex: 1;
    min-height: 0;
}

/* Лид и соседние карточки должны заканчиваться на одном уровне (не
   вразнобой), но лишнюю высоту забирает ФОТО, а не текстовый блок —
   иначе под текстом появляется пустая дыра. Фото гибкое (растёт через
   flex, кроп через object-fit:cover — без искажений), контент — нет. */
.cpg-post--lead .cpg-thumbnail {
    aspect-ratio: auto;
    flex: 1 1 auto;
    min-height: 220px;
}

.cpg-post--lead .cpg-content {
    flex: 0 0 auto;
}

.cpg-post--lead .cpg-title {
    font-size: clamp(20px, 2vw, 27px);
    line-height: 1.18;
    -webkit-line-clamp: 3;
    /* Явно обнуляем, а не просто не указываем: базовое правило
       .cpg-title ниже по специфичности, но всё равно применило бы
       свой min-height (расчёт на 3 строки) поверх куда большего
       шрифта лида. Лид-карточка одна в своём ряду — ей не с кем
       выравниваться, короткий заголовок не должен оставлять дыру. */
    min-height: 0;
}

.cpg-post--lead .cpg-excerpt {
    font-size: 15px;
    -webkit-line-clamp: 3;
}

.cpg-post--compact .cpg-content {
    padding: 12px 14px 14px;
    gap: 6px;
}

.cpg-post--compact .cpg-title {
    font-size: 15px;
    -webkit-line-clamp: 2;
    min-height: calc(1.24em * 2);
}

@media (max-width: 1280px) {
    .cpg-featured-row {
        grid-template-columns: 1fr;
    }

    .cpg-featured-aside {
        flex-direction: row;
    }
}

.cpg-posts-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
    margin: 24px 0;
}

@media (max-width: 1280px) {
    .cpg-posts-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.cpg-post {
    background: #fff;
    border: 1px solid #e4e4e7;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 100%;
    position: relative;
    margin: 0;
    transition: border-color 0.2s ease, background-color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.cpg-post:hover,
.cpg-post:focus-within {
    border-color: #cfd5e2;
    background: #fcfcff;
}

.cpg-thumbnail {
    width: 100%;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    display: block;
}

.cpg-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.6s cubic-bezier(.2,.8,.2,1);
}

.cpg-post:hover .cpg-thumbnail img {
    transform: scale(1.06);
}

.cpg-content {
    padding: 16px 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 9px;
    min-width: 0;
    flex: 1 1 auto;
}

.cpg-title {
    margin: 0;
    padding: 0;
    font-size: 17px;
    font-weight: 700;
    color: #202432;
    line-height: 1.24;
    letter-spacing: -0.01em;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    overflow: hidden;
    min-height: calc(1.24em * 3);
}

.cpg-title a {
    color: inherit;
    text-decoration: none;
}

.cpg-title a:hover {
    color: #0b008a;
    text-decoration: none;
}

.cpg-date {
    margin: 0;
    font-size: 12px;
    color: #7a8192;
    font-weight: 500;
    line-height: 1.2;
}

.cpg-excerpt {
    margin: 0 0 8px;
    font-size: 14px;
    color: #4a5160;
    line-height: 1.42;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.cpg-post.no-thumbnail {
    min-height: 0;
    background: linear-gradient(155deg, #f7f7fc 0%, #ffffff 55%);
}

.cpg-post.no-thumbnail .cpg-content {
    padding: 18px;
}

.gdt-dark .cpg-post,
.darkmysite_dark_mode_enabled .cpg-post {
    background: #1f2430;
    border-color: rgba(255, 255, 255, 0.14);
}

.gdt-dark .cpg-post.no-thumbnail,
.darkmysite_dark_mode_enabled .cpg-post.no-thumbnail {
    background: linear-gradient(155deg, #232838 0%, #1f2430 60%);
}

.gdt-dark .cpg-post:hover,
.gdt-dark .cpg-post:focus-within,
.darkmysite_dark_mode_enabled .cpg-post:hover,
.darkmysite_dark_mode_enabled .cpg-post:focus-within {
    background: #242a38;
    border-color: rgba(169, 181, 255, 0.38);
}

.gdt-dark .cpg-title,
.darkmysite_dark_mode_enabled .cpg-title {
    color: #eef2ff;
}

.gdt-dark .cpg-title a:hover,
.darkmysite_dark_mode_enabled .cpg-title a:hover {
    color: #b7c3ff;
}

.gdt-dark .cpg-date,
.darkmysite_dark_mode_enabled .cpg-date {
    color: #a7afc3;
}

.gdt-dark .cpg-excerpt,
.darkmysite_dark_mode_enabled .cpg-excerpt {
    color: #c7cde0;
}


.cpg-category-header {
    margin: 8px 0 0;
}

.cpg-category-title {
    margin: 0;
    color: #1f222b;
    font-size: clamp(42px, 7vw, 64px);
    font-weight: 700;
    letter-spacing: -0.03em;
    line-height: 1.02;
}

.cpg-category-description {
    color: #343a46;
    font-size: 17px;
    letter-spacing: -0.01em;
    line-height: 1.48;
    margin: 16px 0 0;
    padding: 0;
    border-left: 0;
    width: 100%;
    max-width: 920px;
    overflow-wrap: anywhere;
    word-break: normal;
}

.cpg-category-description p {
    color: inherit;
    font: inherit;
    letter-spacing: inherit;
    line-height: inherit;
    margin: 0;
    max-width: 100%;
}

/* ===== ЛЕНТА РУБРИК =====
   Строгая рамка-бокс, как и было. Единственное отличие от
   исходника: внутри строка не переносится, а скроллится вбок —
   на телефоне с 6+ рубриками список не превращается в стену
   текста из нескольких строк. */
.cpg-category-links {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 10px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    background: #fff;
    border: 1px solid #e4e4e7;
    border-radius: 8px;
    box-shadow: none;
    margin-top: 18px;
    padding: 12px;
}

.cpg-category-links::-webkit-scrollbar { display: none; }

.cpg-category-links a {
    flex: 0 0 auto;
    border: 1px solid transparent;
    border-radius: 8px;
    color: #1d212b;
    display: inline-flex;
    font-family: "Share Tech Mono", monospace !important;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.045em;
    line-height: 1.15;
    padding: 6px 10px;
    text-decoration: none;
    text-transform: uppercase;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.22s ease, border-color 0.22s ease, color 0.22s ease, box-shadow 0.22s ease;
}

.cpg-normal-category:hover {
    background: rgba(255, 255, 255, 0.58);
    border-color: rgba(11, 0, 138, 0.18);
    color: #0b008a;
    text-decoration: none;
}

.cpg-active-category {
    background: #0b008a !important;
    border-color: #0b008a !important;
    color: #fff !important;
    pointer-events: none;
}

.gdt-dark .cpg-category-title,
.darkmysite_dark_mode_enabled .cpg-category-title {
    color: #f2f4fb;
}

.gdt-dark .cpg-category-description,
.darkmysite_dark_mode_enabled .cpg-category-description {
    color: #c2cada;
}

.gdt-dark .cpg-category-links,
.darkmysite_dark_mode_enabled .cpg-category-links {
    background: #22252f;
    border-color: rgba(255, 255, 255, 0.12);
}

.gdt-dark .cpg-category-links a,
.darkmysite_dark_mode_enabled .cpg-category-links a {
    color: #e8ebf6;
    border-color: transparent;
}

.gdt-dark .cpg-normal-category:hover,
.darkmysite_dark_mode_enabled .cpg-normal-category:hover {
    background: rgba(169, 181, 255, 0.16);
    border-color: rgba(169, 181, 255, 0.38);
    color: #d8e0ff;
}

.gdt-dark .cpg-active-category,
.darkmysite_dark_mode_enabled .cpg-active-category {
    background: #6b7aff !important;
    border-color: #6b7aff !important;
    color: #f5f7ff !important;
}

/* ===== МОБИЛЬНАЯ ВЕРСИЯ ===== */
@media (max-width: 600px) {

    /* Герой: строго в пределах экрана, не «вылезает» за края */
    .cpg-hero{
      width: calc(100% - 32px) !important;  /* ширина с учётом боковых полей */
      margin-left: 16px !important;
      margin-right: 16px !important;
      margin-bottom: 20px !important;

      border-radius: 14px !important;
      overflow: clip;                   /* современная обрезка */
      -webkit-mask-image: -webkit-radial-gradient(white, black); /* фикс Safari */
      min-height: 460px;               /* повыше на мобилке, чтобы текст был ниже */
      box-sizing: border-box;
    }
    .cpg-hero__overlay,
    .cpg-hero__inner{
      border-radius: inherit;
      overflow: hidden;                /* на всякий случай — обрезка внутренних углов */
    }
    .cpg-hero__inner{
      padding: 270px 20px 52px;         /* больше нижний отступ — заголовок и описание ниже */
    }
    .cpg-hero__title{
      margin-top: auto !important;     /* фикс в любом случае */
    }

    .cpg-featured-row {
        grid-template-columns: 1fr;
        gap: 14px;
        margin: 15px;
    }

    .cpg-featured-aside {
        flex-direction: column;
    }

    .cpg-post--lead .cpg-title {
        font-size: 18px;
    }

    .cpg-posts-grid {
        grid-template-columns: 1fr;
        gap: 14px;
        margin: 15px;
        padding-top: 20px;
    }

    .cpg-post {
      min-height: 0;
      border-radius: 8px;
    }

    .cpg-thumbnail {
      aspect-ratio: 16 / 10;
      min-height: 0;
    }

    .cpg-content {
      padding: 13px 14px 18px;
      gap: 7px;
    }

    .cpg-container {
        flex-direction: column;
    }

    .cpg-category-header {
      padding: 0;
    }

    .cpg-category-title {
      font-size: 52px;
      line-height: 1.03;
    }

    .cpg-category-description {
      font-size: 15px;
      line-height: 1.46;
      margin-top: 12px;
      padding-left: 0;
    }

    .cpg-title {
      font-size: 15px;
      line-height: 1.3;
      margin: 0;
      padding: 0;
      min-height: calc(1.3em * 3);
    }

    .cpg-date {
      font-size: 11px;
    }

    .cpg-excerpt {
      margin-bottom: 6px;
      font-size: 13px;
      line-height: 1.34;
      -webkit-line-clamp: 2;
    }

    .cpg-post.no-thumbnail .cpg-content {
      padding: 14px;
    }

    .cpg-category-links {
      gap: 8px;
      margin-top: 14px;
      padding: 10px;
    }

    .cpg-category-links a {
      font-size: 12px;
      letter-spacing: 0.04em;
      padding: 6px 10px;
    }

    .cpg-main-content {
      margin-right: 0;
    }

    .cpg-sidebar {
      margin-top: 30px;
    }

    /* Чтобы блоки шли по тем же полям, что и герой */
    .cpg-category-header,
    .cpg-category-links,
    .cpg-featured-row,
    .cpg-posts-grid{
      margin-left: 16px !important;
      margin-right: 16px !important;
    }
}

/* ===== ПАГИНАЦИЯ ===== */

.cpg-pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 36px 0 24px;
}

.cpg-pagination .cpg-page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 8px;
    font-size: 15px;
    font-weight: 500;
    font-family: 'Rubik', sans-serif;
    color: #1b1b1b;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s ease-in-out;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
}

.cpg-pagination a.cpg-page-numbers:hover {
    background: #0b008af0;
    border-color: #bdbdbd;
    color: #fff;
    text-decoration: none;
}

.cpg-pagination .cpg-page-numbers:focus-visible {
    outline: 2px solid #0b008a;
    outline-offset: 2px;
}

.cpg-pagination .cpg-page-numbers.current {
    background-color: #0b008a;
    color: #fff;
    border-color: #0b008a;
    pointer-events: none;
}

.cpg-pagination .cpg-next {
    font-size: 20px;
    font-weight: 300;
    min-width: 40px;
}

.cpg-pagination .cpg-dots {
    border: none;
    box-shadow: none;
    background: transparent;
    color: #999;
    pointer-events: none;
    min-width: 24px;
}

.gdt-dark .cpg-pagination .cpg-page-numbers,
.darkmysite_dark_mode_enabled .cpg-pagination .cpg-page-numbers {
    background: #1f2430;
    border-color: rgba(255, 255, 255, 0.12);
    color: #e8ebf6;
}

.gdt-dark .cpg-pagination a.cpg-page-numbers:hover,
.darkmysite_dark_mode_enabled .cpg-pagination a.cpg-page-numbers:hover {
    background: #6b7aff;
    border-color: #6b7aff;
    color: #f5f7ff;
}

.gdt-dark .cpg-pagination .cpg-page-numbers.current,
.darkmysite_dark_mode_enabled .cpg-pagination .cpg-page-numbers.current {
    background-color: #6b7aff;
    border-color: #6b7aff;
    color: #f5f7ff;
}

.gdt-dark .cpg-pagination .cpg-dots,
.darkmysite_dark_mode_enabled .cpg-pagination .cpg-dots {
    color: #7a8192;
}

@media (max-width: 600px) {
    .cpg-pagination {
        margin-left: 16px !important;
        margin-right: 16px !important;
    }
}

/* ===== ПРОМО-КАРТОЧКА (пост из другой рубрики) ===== */

.cpg-post--promo {
    position: relative;
    border-color: #0b008a;
}

/* Метка рубрики в верхнем левом углу */
.cpg-promo-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 10;
    display: inline-flex;
    align-items: center;
    padding: 5px 10px;
    background: rgba(11, 0, 138, 0.82);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    font-family: 'Share Tech Mono', monospace;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    line-height: 1.1;
    border-radius: 999px;
    text-decoration: none;
    transition: background 0.2s ease, border-color 0.2s ease;
    white-space: nowrap;
    -webkit-backdrop-filter: saturate(130%) blur(8px);
    backdrop-filter: saturate(130%) blur(8px);
}

.cpg-promo-badge:hover {
    background: rgba(11, 0, 138, 0.95);
    border-color: rgba(255, 255, 255, 0.45);
    text-decoration: none;
    color: #fff;
}

/* Нет миниатюры — метка сдвигается */
.cpg-post--promo.no-thumbnail .cpg-promo-badge {
    top: 14px;
    left: 14px;
}

/* Уважаем настройку "меньше анимаций" */
@media (prefers-reduced-motion: reduce) {
    .cpg-post,
    .cpg-thumbnail img,
    .cpg-category-links a,
    .cpg-pagination .cpg-page-numbers {
        transition: none !important;
    }
    .cpg-post:hover .cpg-thumbnail img { transform: none; }
}
