/* ==========================================================================
   Сетка и карточки материалов (главная, страницы разделов, витрина)
   Подключается после style.css
   ========================================================================== */

.latest {
  position: relative;
  z-index: 2;
  max-width: var(--wrap);
  margin: 0 auto;
  padding: 8px var(--gutter) 72px;
}

.latest-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: 0 0 22px;
}
.latest-head-left { display: flex; flex-direction: column; gap: 10px; }
.latest-head-left h2 {
  font-size: clamp(30px, 4.2vw, 48px);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
  text-transform: uppercase;
}
.latest-head p {
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0;
}
.latest-head .latest-all {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: var(--lime);
  text-decoration: none;
  white-space: nowrap;
}
.latest-head .latest-all:hover { color: var(--lime-bright); }

.posts-counter-badge {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--lime);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: .04em;
}

/* ---------- ФИЛЬТР ПО ТЕГАМ / РУБРИКАМ ---------- */

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 26px;
}
.filter-bar .tag { background: var(--surface); }
.filter-bar .tag.active { background: var(--lime); color: var(--bg); border-color: var(--lime); }
.filter-bar .tag .n {
  margin-left: 6px;
  color: var(--text-dim);
  font-weight: 400;
}
.filter-bar .tag.active .n { color: rgba(8, 9, 9, .6); }

.filter-empty {
  display: none;
  border: 1px dashed var(--line-bright);
  border-radius: var(--radius);
  padding: 36px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 15px;
}
.filter-empty.show { display: block; }

/* ---------- СЕТКА КАРТОЧЕК ---------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  align-items: stretch;
  width: 100%;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  transition: border-color .2s ease, transform .25s var(--ease), box-shadow .25s ease;
  width: 100%;
  min-width: 0;
}
.card:hover {
  border-color: var(--lime);
  transform: translateY(-4px);
  box-shadow: var(--glow), 0 24px 50px rgba(0, 0, 0, .45);
  color: inherit;
}
.card.is-hidden { display: none; }

.card-media {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1200 / 630;
  background: var(--bg-2);
  border-bottom: 1px solid var(--line-soft);
}
.card-media img,
.card > img {
  display: block;
  width: 100%;
  height: 100%;
  aspect-ratio: 1200 / 630;
  object-fit: cover;
  background: var(--bg-2);
  transition: transform .55s var(--ease);
}
.card > img { height: auto; border-bottom: 1px solid var(--line-soft); }
.card:hover .card-media img,
.card:hover > img { transform: scale(1.045); }

.card-body {
  padding: 18px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card-cat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--lime);
}
.card-cat::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--lime);
  flex-shrink: 0;
}

.card-date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
}

.card h3 {
  font-size: 19px;
  font-weight: 800;
  line-height: 1.22;
  letter-spacing: -0.02em;
  margin: 0;
  color: var(--text-strong);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  transition: color .15s ease;
}
.card:hover h3 { color: var(--lime-bright); }

.card p {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-muted);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card .tags { margin-top: 2px; gap: 6px; }
.card .tag { font-size: 10.5px; padding: 5px 9px; cursor: default; }

.card-more {
  margin-top: auto;
  padding-top: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 13.5px;
  color: var(--lime);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.card-more::after {
  content: '';
  width: 14px;
  height: 1.5px;
  background: currentColor;
  transition: width .2s var(--ease);
}
.card:hover .card-more::after { width: 24px; }

/* первая карточка на главной - крупнее */
.card-grid.has-featured .card:first-child { grid-column: span 2; }
.card-grid.has-featured .card:first-child h3 { font-size: clamp(22px, 2.4vw, 28px); -webkit-line-clamp: 3; }
.card-grid.has-featured .card:first-child p { -webkit-line-clamp: 3; font-size: 15px; }

/* ---------- ВИТРИНА: ЦЕНЫ ---------- */

.card-price-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
  gap: 10px;
}
.card-old-price {
  font-size: 12px;
  text-decoration: line-through;
  color: var(--text-dim);
  font-family: var(--font-mono);
  display: block;
}
.card-price-val {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 800;
  color: var(--text-strong);
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.badge-hit {
  display: inline-block;
  padding: 4px 9px;
  font-size: 10.5px;
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--bg);
  background: var(--lime);
  border: 1px solid var(--lime);
  border-radius: 999px;
}

/* ---------- ПУСТОЙ РАЗДЕЛ ---------- */

.cat-empty {
  border: 1px dashed var(--line-bright);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  background: var(--surface);
}
.cat-empty .cat-empty-mono {
  font-family: var(--font-mono);
  font-size: 12.5px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--lime);
  margin: 0 0 14px;
}
.cat-empty p { color: var(--text-muted); font-size: 15px; line-height: 1.6; margin: 0 auto 8px; max-width: 46ch; }
.cat-empty p:last-child { margin-bottom: 0; }
.cat-empty a { color: var(--lime); }

/* ---------- АДАПТИВ ---------- */

@media (max-width: 1000px) {
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .card-grid.has-featured .card:first-child { grid-column: span 2; }
}

@media (max-width: 640px) {
  .latest { padding-bottom: 48px; }
  .card-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .card-grid.has-featured .card:first-child { grid-column: auto; }
  .card { border-radius: 18px; }
  .card-body { padding: 16px 16px 18px; }
  .card h3 { font-size: 18px; }
  .card-grid.has-featured .card:first-child h3 { font-size: 21px; }
  .filter-bar { gap: 6px; }
  .filter-bar .tag { font-size: 11px; padding: 7px 11px; }
}
