/* Публикации tshop_3: блог и новости — списки, карточки, подборки на главной (blog/_parts/card и др.).
 * Ручки дизайнера стилей на корне блока (.idblock-N):
 *   --title-size, --title-color   шапка блока (.t3-head)
 *   --post-min                    минимальная ширина карточки (колонки — auto-fill)
 *   --post-ratio                  пропорции обложки
 *   --post-radius                 скругление карточки
 *   --post-title-size             размер заголовка карточки
 *   --items-gap                   промежуток между карточками
 *   --aside-width                 ширина боковой колонки списка
 */
@layer modules {
  .t3-posts { container: posts / inline-size; }
  /* статья выводит карточки «Читайте также» — те же переменные */
  .t3-posts, .t3-article {
    --post-min: 250px;
    --post-ratio: 16 / 10;
    --post-radius: var(--radius-l);
    --post-title-size: var(--fs-l);
    --items-gap: clamp(16px, 2vw, 28px);
    --aside-width: 300px;
  }

  /* ── панель: число, выбранные фильтры, сортировка ── */
  .t3-posts__bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3) var(--s-5); margin-bottom: clamp(20px, 2.5vw, 32px); }
  .t3-posts__state { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-4); }
  .t3-posts__count { margin: 0; font-size: var(--fs-s); color: var(--text-2); }
  .t3-posts__count b { color: var(--text); font-variant-numeric: tabular-nums; }
  .t3-posts__active { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin: 0; padding: 0; list-style: none; }
  .t3-posts__chip { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 10px 0 14px; border-radius: var(--radius-pill); background: var(--brand-soft); color: var(--brand-text); font-size: var(--fs-s); font-weight: 600; }
  .t3-posts__chip:hover { background: var(--brand-soft-2); }
  .t3-posts__reset { font-size: var(--fs-s); color: var(--text-2); text-decoration: underline; text-underline-offset: 3px; }
  [data-style="editorial"] .t3-posts__chip { border-radius: 0; }
  .t3-posts__sort .t3-seg__btn { width: auto; height: 36px; padding: 0 var(--s-4); font-size: var(--fs-s); font-weight: 600; white-space: nowrap; }

  /* ── раскладка: список + боковая колонка ── */
  .t3-posts__layout { display: grid; gap: clamp(32px, 4vw, 56px); align-items: start; }
  @container posts (min-width: 1000px) {
    .t3-posts__layout:has(> .t3-posts__aside) { grid-template-columns: minmax(0, 1fr) var(--aside-width); }
    .t3-posts__aside { position: sticky; top: calc(var(--header-h) + var(--s-4)); }
  }
  .t3-posts__main { container: postsmain / inline-size; display: grid; gap: var(--items-gap); min-width: 0; }
  .t3-posts__main > .t3-pagination, .t3-posts__main > nav { margin-top: var(--s-4); }

  .t3-posts__grid { display: grid; gap: var(--items-gap); grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--post-min)), 1fr)); }
  /* подборки на главной: не больше четырёх (three — трёх) в ряд, неполный ряд растягивается */
  .t3-posts__grid--row { grid-template-columns: repeat(auto-fit, minmax(min(100%, max(var(--post-min), (100% - 3 * var(--items-gap)) / 4)), 1fr)); }
  .t3-posts--three .t3-posts__grid--row { grid-template-columns: repeat(auto-fit, minmax(min(100%, max(var(--post-min), (100% - 2 * var(--items-gap)) / 3)), 1fr)); }

  /* ── карточка ── */
  .t3-post { position: relative; display: flex; flex-direction: column; min-width: 0; border-radius: var(--post-radius); }
  [data-style="bento"] .t3-post:not(.t3-post--compact) { background: var(--surface); box-shadow: var(--shadow-1); overflow: hidden; transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease); }
  [data-style="bento"] .t3-post:not(.t3-post--compact):hover { box-shadow: var(--shadow-pop); transform: translateY(-2px); }
  [data-style="editorial"] .t3-post:not(.t3-post--compact) { border: var(--line-w) solid var(--line); border-radius: 0; transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease); }
  [data-style="editorial"] .t3-post:not(.t3-post--compact):hover { transform: translate(-3px, -3px); box-shadow: var(--shadow-pop); }

  .t3-post__media { position: relative; aspect-ratio: var(--post-ratio); overflow: hidden; background: var(--surface-2); }
  [data-style="quiet"] .t3-post__media { border-radius: var(--post-radius); }
  [data-style="editorial"] .t3-post__media { border-bottom: var(--line-w) solid var(--line); }
  .t3-post__img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s var(--ease-out); }
  .t3-post:hover .t3-post__img { transform: scale(1.04); }
  .t3-post__ph {
    display: grid; place-items: center; width: 100%; height: 100%;
    background: radial-gradient(120% 90% at 0% 0%, var(--brand-soft-2), transparent 60%), linear-gradient(135deg, var(--brand-soft), var(--surface-2));
    font-family: var(--font-display); font-weight: var(--display-weight); font-size: clamp(2.5rem, 6cqi, 5rem); color: var(--brand-text); letter-spacing: var(--display-tracking);
  }

  .t3-post__body { display: flex; flex-direction: column; gap: var(--s-2); flex: 1; padding: var(--s-4) var(--s-5) var(--s-5); min-width: 0; }
  [data-style="quiet"] .t3-post__body { padding: var(--s-4) 0 0; }
  .t3-post__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 0; font-size: var(--fs-xs); color: var(--text-3); font-variant-numeric: tabular-nums; }
  .t3-post__meta > * + *::before { content: "·"; margin-right: 8px; }
  [data-style="editorial"] .t3-post__meta { text-transform: uppercase; letter-spacing: .08em; }

  .t3-post__title { margin: 0; font-family: var(--font-display); font-weight: var(--display-weight); font-size: var(--post-title-size); line-height: 1.25; letter-spacing: -.01em; text-wrap: balance; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
  [data-style="editorial"] .t3-post__title { letter-spacing: 0; }
  .t3-post__link { color: inherit; }
  .t3-post__link::after { content: ""; position: absolute; inset: 0; z-index: 1; border-radius: inherit; }
  .t3-post__link:focus-visible { outline: none; }
  .t3-post:has(.t3-post__link:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
  [data-style="quiet"] .t3-post:hover .t3-post__title { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: .2em; }

  .t3-post__excerpt { margin: 0; color: var(--text-2); font-size: var(--fs-s); display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
  .t3-post__tags { display: flex; flex-wrap: wrap; gap: 4px 12px; margin: auto 0 0; padding: var(--s-2) 0 0; list-style: none; font-size: var(--fs-xs); font-weight: 600; }
  .t3-post__tags a { position: relative; z-index: 2; color: var(--brand-text); }
  .t3-post__tags a:hover { text-decoration: underline; text-underline-offset: 3px; }

  /* большая: первая статья списка */
  .t3-post--feature { --post-title-size: clamp(1.5rem, 1.1rem + 1.2vw, 2.25rem); }
  .t3-post--feature .t3-post__title { -webkit-line-clamp: 4; }
  .t3-post--feature .t3-post__excerpt { font-size: var(--fs-m); -webkit-line-clamp: 4; }
  @container postsmain (min-width: 720px) {
    .t3-post--feature { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
    .t3-post--feature .t3-post__media { aspect-ratio: auto; min-height: 100%; }
    .t3-post--feature .t3-post__body { justify-content: center; gap: var(--s-3); padding: clamp(24px, 3vw, 48px); }
    [data-style="quiet"] .t3-post--feature { gap: clamp(24px, 3vw, 48px); }
    [data-style="quiet"] .t3-post--feature .t3-post__body { padding: 0; }
  }

  /* строка ленты новостей */
  .t3-posts__group { display: grid; gap: var(--s-3); }
  .t3-posts__month { margin: var(--s-4) 0 0; font-size: var(--fs-s); font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: .08em; }
  .t3-posts__feed { display: grid; gap: var(--s-2); }
  [data-style="quiet"] .t3-posts__feed, [data-style="editorial"] .t3-posts__feed { gap: 0; border-top: var(--line-w) solid var(--line); }
  .t3-post--row { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: var(--s-4); padding: var(--s-4); align-items: start; }
  [data-style="quiet"] .t3-post--row, [data-style="editorial"] .t3-post--row { padding: var(--s-5) 0; border-bottom: var(--line-w) solid var(--line); }
  [data-style="editorial"] .t3-posts__feed .t3-post--row { border-width: 0 0 var(--line-w); }
  .t3-post--row .t3-post__body { padding: 0; gap: var(--s-1); }
  .t3-post--row .t3-post__media { display: none; }
  .t3-post__day { display: grid; justify-items: center; align-content: start; padding-top: 2px; line-height: 1; color: var(--text); }
  .t3-post__day b { font-family: var(--font-display); font-weight: var(--display-weight); font-size: var(--fs-2xl); letter-spacing: var(--display-tracking); font-variant-numeric: tabular-nums; }
  .t3-post__day span { margin-top: 4px; font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); }
  .t3-post--row .t3-post__excerpt { -webkit-line-clamp: 2; }
  @container postsmain (min-width: 640px) {
    .t3-post--row:not(.t3-post--nocover) { grid-template-columns: 64px minmax(0, 1fr) 200px; }
    .t3-post--row .t3-post__media { display: block; order: 3; border-radius: var(--radius-m); aspect-ratio: 4 / 3; }
  }

  /* короткая строка (подборки) */
  .t3-post--compact { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: var(--s-4); align-items: center; }
  .t3-post--compact .t3-post__media { aspect-ratio: 1; border-radius: var(--radius-m); }
  .t3-post--compact .t3-post__body { padding: 0; gap: 4px; }
  .t3-post--compact .t3-post__title { font-size: var(--fs-m); -webkit-line-clamp: 2; }
  .t3-post--compact .t3-post__ph { font-size: var(--fs-xl); }
  .t3-post--compact:hover .t3-post__title { color: var(--brand-text); }

  /* главная новость + строки (news/in_main) */
  .t3-posts__bento { display: grid; gap: var(--items-gap); }
  .t3-posts__stack { display: grid; gap: var(--s-4); align-content: start; }
  [data-style="bento"] .t3-posts__stack { padding: var(--s-5); border-radius: var(--post-radius); background: var(--surface); box-shadow: var(--shadow-1); }
  [data-style="quiet"] .t3-posts__stack .t3-post--compact + .t3-post--compact,
  [data-style="editorial"] .t3-posts__stack .t3-post--compact + .t3-post--compact { padding-top: var(--s-4); border-top: var(--line-w) solid var(--line); }
  @container posts (min-width: 860px) {
    .t3-posts__bento { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
    .t3-posts__bento > .t3-post { --post-title-size: var(--fs-xl); }
  }

  /* ── боковая колонка ── */
  .t3-posts__aside { display: grid; gap: var(--s-4); min-width: 0; }
  .t3-side { padding: var(--s-5); border-radius: var(--radius-l); background: var(--surface); box-shadow: var(--shadow-1); }
  [data-style="quiet"] .t3-side { background: none; box-shadow: none; padding: 0 0 var(--s-5); border-radius: 0; border-bottom: var(--line-w) solid var(--line); }
  [data-style="editorial"] .t3-side { box-shadow: none; border: var(--line-w) solid var(--line); border-radius: 0; }
  .t3-side__title { margin: 0 0 var(--s-3); font-size: var(--fs-s); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); }
  .t3-side__tags, .t3-side__years { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; }
  .t3-side__tags .chip { min-height: 32px; font-size: var(--fs-s); }
  .t3-side__num { margin-left: 2px; opacity: .55; font-variant-numeric: tabular-nums; }
  .t3-side__years a { display: inline-grid; place-items: center; min-width: 64px; min-height: 32px; padding: 0 12px; border-radius: var(--radius-pill); background: var(--surface-2); font-size: var(--fs-s); font-weight: 600; font-variant-numeric: tabular-nums; }
  .t3-side__years a:hover { background: var(--line); }
  .t3-side__years a[aria-current] { background: var(--text); color: var(--bg); }
  [data-style="editorial"] .t3-side__years a { border-radius: 0; }
  .t3-side__top { display: grid; gap: var(--s-4); margin: 0; padding: 0; list-style: none; }
  .t3-side__top li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: var(--s-3); align-items: start; }
  .t3-side__rank { font-family: var(--font-display); font-weight: var(--display-weight); font-size: var(--fs-xl); line-height: 1; color: var(--brand-text); font-variant-numeric: tabular-nums; }
  .t3-side__top a { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; font-weight: 600; font-size: var(--fs-s); line-height: 1.35; }
  .t3-side__top a:hover { color: var(--brand-text); }
  .t3-side__meta { display: block; margin-top: 4px; font-size: var(--fs-xs); color: var(--text-3); }
}
