/* ============================================================
   Mobile-first. Breakpoints: 480px (sm), 768px (tablet), 1024px (desktop)
   ============================================================ */

/* ============================================================
   CSS CUSTOM PROPERTIES
   ============================================================ */
:root {
  /* Фон */
  --color-bg: #ffffff;
  --color-bg-alt: #f0f4ff;
  --color-bg-card: #ffffff;

  /* Текст */
  --color-text: #0f172a;
  --color-text-muted: #64748b;
  --color-text-light: #94a3b8;

  /* Акцент */
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;

  /* Категории / badge */
  --color-badge-marketing-bg: #dbeafe;
  --color-badge-marketing-text: #1d4ed8;
  --color-badge-tech-bg: #dcfce7;
  --color-badge-tech-text: #15803d;
  --color-badge-business-bg: #fef3c7;
  --color-badge-business-text: #b45309;
  --color-badge-education-bg: #ede9fe;
  --color-badge-education-text: #6d28d9;
  --color-badge-design-bg: #fce7f3;
  --color-badge-design-text: #be185d;

  /* Граница и тень */
  --color-border: #e2e8f0;
  --color-shadow: rgba(15, 23, 42, 0.08);

  /* Типографика */
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  --text-5xl: 3rem;

  /* Отступы */
  --space-xs: 0.25rem;
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --space-2xl: 3rem;
  --space-3xl: 4rem;

  /* Скругления */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Тени */
  --shadow-sm: 0 1px 4px var(--color-shadow);
  --shadow-md: 0 4px 20px var(--color-shadow);
  --shadow-lg: 0 8px 32px var(--color-shadow);

  /* Layout */
  --container-max: 1200px;
  --transition: 0.2s ease;
  --sidebar-sticky-top: 80px;
}

/* ============================================================
   RESET / BASE
   ============================================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

a:hover {
  color: var(--color-primary-hover);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  color: inherit;
}

img,
picture,
svg {
  max-width: 100%;
  height: auto;
  display: block;
}

ul,
ol {
  list-style: none;
}

:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.35);
  outline-offset: 3px;
}

/* ============================================================
   CONTAINER / TITLES
   ============================================================ */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--space-md);
}

@media (min-width: 768px) {
  .container {
    padding: 0 var(--space-xl);
  }
}

.section-title {
  font-size: clamp(var(--text-xl), 3vw, var(--text-3xl));
  font-weight: 800;
  line-height: 1.2;
  color: var(--color-text);
  margin-bottom: var(--space-lg);
}

/* ============================================================
   BADGE
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 3px 12px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  background: #e0e7ff;
  color: #3730a3;
}


.badge--tone-1 { background: var(--color-badge-design-bg); color: var(--color-badge-design-text); }
.badge--tone-2 { background: var(--color-badge-education-bg); color: var(--color-badge-education-text); }
.badge--tone-3 { background: var(--color-badge-business-bg); color: var(--color-badge-business-text); }
.badge--tone-4 { background: var(--color-badge-tech-bg); color: var(--color-badge-tech-text); }
.badge--tone-5 { background: var(--color-badge-marketing-bg); color: var(--color-badge-marketing-text); }
.badge--neutral { background: #f1f5f9; color: #475569; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition), transform var(--transition);
}

.btn:hover {
  transform: translateY(-1px);
}

.btn--primary {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.btn--primary:hover {
  background: var(--color-primary-hover);
  border-color: var(--color-primary-hover);
  color: #fff;
}

.btn--outline {
  background: transparent;
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn--outline:hover {
  background: var(--color-primary);
  color: #fff;
}

/* ============================================================
   HEADER
   ============================================================ */
.site-header {
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  min-height: 64px;
}

.site-header__logo {
  flex-shrink: 0;
  color: var(--color-text);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  text-decoration: none;
}

.logo-info { color: var(--color-primary); }
.logo-blog { color: var(--color-text); }

.main-nav {
  display: none;
}

.main-nav__list {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  list-style: none;
}

.main-nav__link {
  display: inline-flex;
  align-items: center;
  color: var(--color-text);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
  text-decoration: none;
  transition: color var(--transition), border-color var(--transition);
}

.main-nav__link:hover,
.main-nav__link--active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.site-header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  flex-shrink: 0;
}

.header-search-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  transition: color var(--transition);
}

.header-search-icon:hover {
  color: var(--color-primary);
}

.lang-switcher {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
}

.lang-switcher__item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 11px;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--color-border);
  color: var(--color-text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.4;
  text-decoration: none;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.lang-switcher__item:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.lang-switcher__item--active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}
.lang-switcher__item--active:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.nav-toggle {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  flex-shrink: 0;
  width: 24px;
  height: 18px;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
}

.nav-toggle__bar {
  display: block;
  height: 2px;
  background: var(--color-text);
  border-radius: 2px;
  transition: transform var(--transition), opacity var(--transition);
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(2) {
  opacity: 0;
}

.nav-toggle[aria-expanded="true"] .nav-toggle__bar:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

@media (min-width: 1024px) {
  .site-header__inner {
    min-height: 60px;
  }

  .main-nav {
    display: block;
  }

  .nav-toggle {
    display: none;
  }
}

@media (max-width: 1023px) {
  .site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--color-bg);
  }

  .site-header__inner {
    position: relative;
    flex-wrap: nowrap;
    min-height: 64px;
    padding-top: 0;
    padding-bottom: 0;
  }

  .site-header__logo {
    position: relative;
    z-index: 1002;
  }

  .site-header__actions {
    position: relative;
    z-index: 1002;
    margin-left: auto;
  }

  .main-nav {
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    z-index: 999;

    display: none;
    width: 100%;

    background: var(--color-bg);
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.08);

    padding: 0;
  }

  .main-nav.is-open {
    display: block;
  }

  .main-nav__list {
    width: 100%;
    max-width: var(--container-max);
    margin: 0 auto;
    padding: var(--space-lg) var(--space-md);

    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }

  .main-nav__list li {
    width: 100%;
  }

  .main-nav__link {
    display: block;
    width: 100%;
    padding: 0.8rem 0;
    border-bottom: 0;
    color: var(--color-text);
    font-size: var(--text-base);
  }

  .main-nav__link:hover,
  .main-nav__link--active {
    color: var(--color-primary);
    background: transparent;
    border-bottom-color: transparent;
  }
}

@media (max-width: 1023px) {
  body.nav-is-open {
    overflow-x: hidden;
  }
}

/* ============================================================
   HERO / PAGE HERO / ARTICLE HERO
   ============================================================ */

/* Главный hero на Home */
.hero {
  position: relative;
  min-height: 520px;
  background: var(--color-bg-alt);
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 1;

  display: none;
  width: 62vw;

  background-image: var(--hero-bg);
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center right;
  pointer-events: none;
}

.hero::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 2;

  display: none;
  width: 72vw;

  background: linear-gradient(
    90deg,
    var(--color-bg-alt) 0%,
    rgba(240, 244, 255, 0.98) 22%,
    rgba(240, 244, 255, 0.72) 42%,
    rgba(240, 244, 255, 0) 70%
  );
  pointer-events: none;
}

.hero__inner {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  min-height: 520px;
  padding-top: 72px;
  padding-bottom: 72px;
}

.hero__text {
  max-width: 560px;
}

.hero__text--article {
  width: 66%;
  max-width: 820px;
}

@media (max-width: 599px) {
  .hero__text--article {
    width: 100%;
    max-width: 100%;
  }
}

.hero__title {
  color: var(--color-text);
  font-size: clamp(2.4rem, 5vw, 4.5rem);
  font-weight: 800;
  line-height: 1.08;
  margin-bottom: var(--space-md);
}

.hero__title--article {
  max-width: 760px;
  font-size: clamp(1.8rem, 3.2vw, 2.9rem);
  line-height: 1.12;
}

.hero__sub {
  max-width: 520px;
  color: var(--color-text-muted);
  font-size: 1.1rem;
  line-height: 1.6;
  margin-bottom: var(--space-xl);
}

/* Tablet: картинка ещё есть, но мягче и правее */
@media (min-width: 600px) {
  .hero::after,
  .hero::before {
    display: block;
  }

  .hero::after {
    width: 58vw;
    opacity: 0.75;
    background-size: cover;
    background-position: center right;
  }

  .hero::before {
    width: 78vw;
  }
}

/* Desktop: картинка крупнее и плотнее */
@media (min-width: 1024px) {
  .hero::after {
    width: 62vw;
    opacity: 1;
    background-position: center right;
  }

  .hero::before {
    width: 72vw;
  }
}

/* Small mobile: без картинки и с маленькими отступами */
@media (max-width: 599px) {
  .hero {
    min-height: auto;
  }

  .hero::after,
  .hero::before {
    display: none;
  }

  .hero__inner {
    min-height: auto;
    padding-top: 16px;
    padding-bottom: 16px;
  }

  .hero__title {
    font-size: clamp(2rem, 9vw, 2.8rem);
  }

  .hero__title--article {
    font-size: clamp(1.6rem, 7vw, 2.1rem);
    line-height: 1.15;
  }

  .hero__sub {
    font-size: 1rem;
    margin-bottom: 24px;
  }
}

/* Inner pages hero: category / index / article */
.hero--inner {
  min-height: auto;
  background: var(--color-bg-alt);
  overflow: hidden;
}

.hero--inner .hero__inner {
  min-height: auto;
  align-items: flex-start;
  padding-top: 32px;
  padding-bottom: 32px;
}

.hero--inner .hero__text {
  max-width: 760px;
}

.hero--inner .hero__text--article {
  width: 100%;
  max-width: 820px;
}

.hero--inner .breadcrumbs {
  margin-bottom: 28px;
}

.hero--inner .hero__title {
  margin-bottom: 20px;
}

.hero--inner .hero__sub {
  margin-bottom: 28px;
}

.hero--inner .article-hero__meta {
  margin-top: 0;
}

@media (min-width: 768px) {
  .hero--inner::after,
  .hero--inner::before {
    display: block;
  }

  .hero--inner::after {
    top: 0;
    bottom: 0;
    width: 62vw;
    opacity: 0.9;
    background-size: cover;
    background-position: right bottom;
  }

  .hero--inner::before {
    top: 0;
    bottom: 0;
    width: 78vw;
  }
}

@media (min-width: 1024px) {
  .hero--inner::after {
    width: 60vw;
    background-position: right bottom;
  }

  .hero--inner::before {
    width: 72vw;
  }
}

@media (max-width: 767px) {
  .hero--inner::after,
  .hero--inner::before {
    display: none;
  }

  .hero--inner .hero__inner {
    padding-top: 24px;
    padding-bottom: 24px;
  }

  .hero--inner .breadcrumbs {
    margin-bottom: 18px;
  }

  .hero--inner .hero__title {
    margin-bottom: 16px;
  }

  .hero--inner .hero__sub {
    margin-bottom: 22px;
  }
}

/* Page hero и article hero отдельно, чтобы Home hero не ломал их */
.page-hero,
.article-hero {
  background: var(--color-bg-alt);
  overflow: hidden;
}

.page-hero__inner,
.article-hero__inner {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-xl);
  padding-top: var(--space-2xl);
  padding-bottom: var(--space-2xl);
  align-items: center;
}

.page-hero__image,
.article-hero__image {
  display: none;
}

.page-hero__text,
.article-hero__text {
  max-width: 600px;
}

.page-hero__title,
.article-hero__title {
  color: var(--color-text);
  font-size: clamp(1.5rem, 4vw, 2.4rem);
  font-weight: 800;
  line-height: 1.2;
  margin: var(--space-sm) 0 var(--space-md);
}

.page-hero__intro,
.article-hero__intro {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  line-height: 1.65;
}

.article-hero__date {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  margin-top: var(--space-md);
}

@media (min-width: 768px) {
  .page-hero__inner,
  .article-hero__inner {
    grid-template-columns: 1fr 1fr;
  }

  .page-hero__image,
  .article-hero__image {
    display: block;
  }
}
/* ============================================================
   BREADCRUMBS
   ============================================================ */

.breadcrumbs {
  width: 100%;
  max-width: 100%;
  margin-bottom: 28px;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.breadcrumbs__list {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0;
  min-width: 0;
  max-width: 100%;
  padding: 0;
  margin: 0;
  list-style: none;
}

.breadcrumbs__item {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.breadcrumbs__item:not(:last-child) {
  flex: 0 0 auto;
}

.breadcrumbs__item:last-child {
  flex: 1 1 auto;
  overflow: hidden;
}

.breadcrumbs__item a {
  color: #2563eb;
  text-decoration: none;
}

.breadcrumbs__item a:hover {
  color: #1d4ed8;
}

.breadcrumbs__sep {
  flex: 0 0 auto;
  margin: 0 14px;
  color: #94a3b8;
  font-weight: 600;
}

.breadcrumbs__item:last-child span {
  display: block;
  overflow: hidden;
  color: var(--color-text-muted);
  white-space: nowrap;
  text-overflow: ellipsis;
}

@media (max-width: 599px) {
  .breadcrumbs {
    margin-bottom: 18px;
    font-size: 0.8rem;
  }

  .breadcrumbs__sep {
    margin: 0 8px;
  }

  .breadcrumbs__item:last-child span {
    max-width: 160px;
  }
}

/* ============================================================
   POST CARD
   ============================================================ */
.post-card {
  display: flex;
  flex-direction: column;
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
}

.post-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.post-card__img-wrap {
  display: block;
  aspect-ratio: 3 / 2;
  overflow: hidden;
}

.post-card__img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.post-card__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
}

.post-card__title {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.35;
}

.post-card__title a {
  color: var(--color-text);
}

.post-card__title a:hover {
  color: var(--color-primary);
}

.post-card__intro {
  flex: 1;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  line-height: 1.55;
}

.post-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-top: auto;
}

.post-card__date {
  flex-shrink: 0;
  color: var(--color-text-light);
  font-size: 0.78rem;
}

.post-card__read-more {
  color: var(--color-primary);
  font-size: 0.82rem;
  font-weight: 600;
}

.post-card__read-more:hover {
  text-decoration: underline;
}

/* ============================================================
   POST CARD HORIZONTAL
   ============================================================ */

.index-posts-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  padding: var(--space-xl) 0;
}

.post-card-h {
  display: grid;
  grid-template-columns: 1fr;
  background: var(--color-bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition:
    box-shadow var(--transition),
    transform var(--transition);
}

.post-card-h:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.post-card-h__img-wrap {
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #dbeafe;
}

.post-card-h__img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.post-card-h__body {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
}

.post-card-h__title {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.35;
}

.post-card-h__title a {
  color: var(--color-text);
}

.post-card-h__title a:hover {
  color: var(--color-primary);
}

.post-card-h__intro {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  line-height: 1.55;
}

.post-card-h__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  margin-top: auto;
}

.post-card-h__date {
  flex-shrink: 0;
  color: var(--color-text-light);
  font-size: 0.78rem;
}

.post-card-h__read-more {
  color: var(--color-primary);
  font-size: 0.85rem;
  font-weight: 600;
}

.post-card-h__read-more:hover {
  text-decoration: underline;
}

/* Small mobile: одна карточка */
@media (max-width: 479px) {
  .post-card-h__img-wrap {
    aspect-ratio: auto;
    height: 200px;
  }

  .post-card-h__title {
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
  }

  .post-card-h__intro {
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
  }
}

/* 480–767px: как на главной/категориях — две карточки в ряд */
@media (min-width: 480px) and (max-width: 767px) {
  .index-posts-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-lg);
  }

  .post-card-h {
    display: flex;
    flex-direction: column;
    min-width: 0;
  }

  .post-card-h__img-wrap {
    aspect-ratio: auto;
    height: 180px;
  }

  .post-card-h__body {
    min-height: 230px;
    padding: 16px 24px;
  }

  .post-card-h__title {
    display: -webkit-box;
    overflow: hidden;
    font-size: 0.95rem;
    line-height: 1.35;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
  }

  .post-card-h__intro {
    display: -webkit-box;
    overflow: hidden;
    font-size: 0.85rem;
    line-height: 1.55;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
  }
}

/* 768px+ : горизонтальный список */
@media (min-width: 768px) {
  .post-card-h {
    min-height: 170px;
  }

  .post-card-h--has-image {
    display: grid;
    grid-template-columns: minmax(260px, 34%) minmax(0, 1fr);
  }

  .post-card-h--no-image {
    display: flex;
    flex-direction: column;
  }

  .post-card-h__img-wrap {
    aspect-ratio: auto;
    height: 100%;
  }

  .post-card-h__body {
    padding: var(--space-lg);
  }

  .post-card-h__title {
    display: -webkit-box;
    overflow: hidden;
    font-size: var(--text-lg);
    line-height: 1.3;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .post-card-h__intro {
    display: -webkit-box;
    overflow: hidden;
    font-size: 0.9rem;
    line-height: 1.55;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
}

/* Desktop: картинка шире, не квадратная */
@media (min-width: 1024px) {
  .post-card-h {
    min-height: 172px;
  }

  .post-card-h--has-image {
    grid-template-columns: minmax(280px, 36%) minmax(0, 1fr);
  }
}

/* ============================================================
   FEATURED ARTICLES
   ============================================================ */
.home-featured {
  padding: 24px 0 0;
}

.featured-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
}

/* 480–1023px: всегда две одинаковые карточки в ряд */
@media (min-width: 480px) and (max-width: 1023px) {
  .featured-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .featured-grid > .post-card {
    min-width: 0;
    height: auto;
  }

  .featured-grid > .post-card .post-card__img-wrap {
    aspect-ratio: auto;
    height: 180px;
  }

  .featured-grid > .post-card .post-card__body {
    min-height: 230px;
    padding: 20px 24px;
  }

  .featured-grid > .post-card .post-card__title {
    font-size: 0.95rem;
    line-height: 1.35;
  }

  .featured-grid > .post-card .post-card__intro {
    font-size: 0.85rem;
    line-height: 1.55;
  }

  .featured-grid > .post-card .post-card__footer {
    margin-top: auto;
  }
}

/* 1024px+: desktop-сетка */
@media (min-width: 1024px) {
  .featured-grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
  }

  .featured-grid > .post-card {
    grid-column: span 3;
  }

  /*
    Первая карточка — широкая горизонтальная.
  */
  .featured-grid > .post-card--featured-main {
    grid-column: 1 / -1;
    height: 260px;
    min-height: 0;
  }

  .featured-grid > .post-card--featured-main.post-card--has-image {
    display: grid;
    grid-template-columns: minmax(0, 45%) minmax(0, 55%);
  }

  .featured-grid > .post-card--featured-main.post-card--no-image {
    display: flex;
    flex-direction: column;
  }

  .featured-grid > .post-card--featured-main .post-card__img-wrap {
    grid-column: 1;
    grid-row: 1;
    aspect-ratio: auto;
    height: 260px;
    min-height: 0;
  }

  .featured-grid > .post-card--featured-main .post-card__img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .featured-grid > .post-card--featured-main .post-card__body {
    height: 260px;
    min-height: 0;
    padding: var(--space-xl);
    overflow: hidden;
  }

  .featured-grid > .post-card--featured-main.post-card--has-image .post-card__body {
    grid-column: 2;
    grid-row: 1;
  }

  .featured-grid > .post-card--featured-main.post-card--no-image .post-card__body {
    width: 100%;
  }

  .featured-grid > .post-card--featured-main .post-card__title {
    font-size: clamp(1.1rem, 2.2vw, var(--text-2xl));
    line-height: 1.3;
  }

  .featured-grid > .post-card--featured-main .post-card__intro {
    font-size: 0.95rem;
    line-height: 1.6;
  }

  /*
    Если после первой широкой карточки в последнем ряду осталась 1 карточка —
    делаем её широкой горизонтальной.
  */
  .featured-grid > .post-card:nth-last-child(1):nth-child(4n + 2) {
    grid-column: 1 / -1;
    height: 260px;
    min-height: 0;
  }

  .featured-grid > .post-card.post-card--has-image:nth-last-child(1):nth-child(4n + 2) {
    display: grid;
    grid-template-columns: minmax(0, 45%) minmax(0, 55%);
  }

  .featured-grid > .post-card.post-card--no-image:nth-last-child(1):nth-child(4n + 2) {
    display: flex;
    flex-direction: column;
  }

  .featured-grid > .post-card:nth-last-child(1):nth-child(4n + 2) .post-card__img-wrap {
    grid-column: 1;
    grid-row: 1;
    aspect-ratio: auto;
    height: 260px;
    min-height: 0;
  }

  .featured-grid > .post-card:nth-last-child(1):nth-child(4n + 2) .post-card__img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .featured-grid > .post-card:nth-last-child(1):nth-child(4n + 2) .post-card__body {
    height: 260px;
    min-height: 0;
    padding: var(--space-xl);
    overflow: hidden;
  }

  .featured-grid > .post-card.post-card--has-image:nth-last-child(1):nth-child(4n + 2) .post-card__body {
    grid-column: 2;
    grid-row: 1;
  }

  .featured-grid > .post-card.post-card--no-image:nth-last-child(1):nth-child(4n + 2) .post-card__body {
    width: 100%;
  }

  .featured-grid > .post-card:nth-last-child(1):nth-child(4n + 2) .post-card__title {
    font-size: clamp(1.1rem, 2.2vw, var(--text-2xl));
    line-height: 1.3;
  }

  .featured-grid > .post-card:nth-last-child(1):nth-child(4n + 2) .post-card__intro {
    font-size: 0.95rem;
    line-height: 1.6;
  }

  /*
    Если после первой широкой карточки в последнем ряду осталось 2 карточки —
    делаем их по половине ряда и подрезаем картинки.
  */
  .featured-grid > .post-card:nth-last-child(2):nth-child(4n + 2),
  .featured-grid > .post-card:nth-last-child(1):nth-child(4n + 3) {
    grid-column: span 6;
  }

  .featured-grid > .post-card:nth-last-child(2):nth-child(4n + 2) .post-card__img-wrap,
  .featured-grid > .post-card:nth-last-child(1):nth-child(4n + 3) .post-card__img-wrap {
    aspect-ratio: auto;
    height: 220px;
  }

  /*
    Если после первой широкой карточки в последнем ряду осталось 3 карточки —
    делаем их по трети ряда.
  */
  .featured-grid > .post-card:nth-last-child(3):nth-child(4n + 2),
  .featured-grid > .post-card:nth-last-child(2):nth-child(4n + 3),
  .featured-grid > .post-card:nth-last-child(1):nth-child(4n + 4) {
    grid-column: span 4;
  }
}

@media (max-width: 479px) {
  .home-featured .post-card__img-wrap {
    aspect-ratio: auto;
    height: 200px;
  }

  .home-featured .post-card__img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
}

/* ============================================================
   CATEGORY POSTS GRID
   1 большая + 3 обычные, повторяется
   ============================================================ */

.category-posts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
  padding: var(--space-xl) 0;
}

.category-posts-grid > .post-card {
  min-width: 0;
}

/* Tablet */
/* Tablet: все карточки по 2 в ряд, без огромных одиночных */
@media (min-width: 480px) and (max-width: 1023px) {
  .category-posts-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .category-posts-grid > .post-card,
  .category-posts-grid > .post-card--category-main {
    grid-column: auto;
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 0;
  }

  .category-posts-grid > .post-card .post-card__img-wrap,
  .category-posts-grid > .post-card--category-main .post-card__img-wrap {
    aspect-ratio: auto;
    height: 180px;
  }

  .category-posts-grid > .post-card .post-card__body,
  .category-posts-grid > .post-card--category-main .post-card__body {
    min-height: 230px;
    padding: 16px 24px;
  }

  .category-posts-grid > .post-card .post-card__title,
  .category-posts-grid > .post-card--category-main .post-card__title {
    display: -webkit-box;
    overflow: hidden;
    font-size: 0.95rem;
    line-height: 1.35;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
  }

  .category-posts-grid > .post-card .post-card__intro,
  .category-posts-grid > .post-card--category-main .post-card__intro {
    display: -webkit-box;
    overflow: hidden;
    font-size: 0.85rem;
    line-height: 1.55;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
  }

  .category-posts-grid > .post-card .post-card__footer,
  .category-posts-grid > .post-card--category-main .post-card__footer {
    margin-top: auto;
  }
}

/* Mobile для категорий: картинка как на главной */
@media (max-width: 479px) {
  .category-posts-grid .post-card__img-wrap {
    aspect-ratio: auto;
    height: 200px;
  }

  .category-posts-grid .post-card__img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .category-posts-grid .post-card__body {
    min-height: auto;
    padding: var(--space-md) var(--space-lg);
  }
}

/* Desktop */
@media (min-width: 1024px) {
  .category-posts-grid {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: var(--space-lg);
  }

  /* Обычные карточки: 3 в ряд */
  .category-posts-grid > .post-card {
    grid-column: span 4;
    min-width: 0;
  }

  /* Основная большая карточка: 1-я, 5-я, 9-я и т.д., если есть полная группа */
  .category-posts-grid > .post-card--category-main {
    grid-column: 1 / -1;
    height: 260px;
    min-height: 0;
  }

  .category-posts-grid > .post-card--category-main.post-card--has-image {
    display: grid;
    grid-template-columns: minmax(0, 45%) minmax(0, 55%);
  }

  .category-posts-grid > .post-card--category-main.post-card--no-image {
    display: flex;
    flex-direction: column;
  }

  .category-posts-grid > .post-card--category-main .post-card__img-wrap {
    grid-column: 1;
    grid-row: 1;
    aspect-ratio: auto;
    height: 260px;
    min-height: 0;
  }

  .category-posts-grid > .post-card--category-main .post-card__img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .category-posts-grid > .post-card--category-main .post-card__body {
    display: flex;
    flex-direction: column;
    height: 260px;
    min-height: 0;
    padding: 16px 24px;
    overflow: hidden;
  }

  .category-posts-grid > .post-card--category-main.post-card--has-image .post-card__body {
    grid-column: 2;
    grid-row: 1;
  }

  .category-posts-grid > .post-card--category-main.post-card--no-image .post-card__body {
    width: 100%;
  }

  /* Если в конце осталась 1 карточка — делаем её такой же горизонтальной */
  .category-posts-grid > .post-card:nth-last-child(1):nth-child(4n + 1) {
    grid-column: 1 / -1;
    height: 260px;
    min-height: 0;
  }

  .category-posts-grid > .post-card.post-card--has-image:nth-last-child(1):nth-child(4n + 1) {
    display: grid;
    grid-template-columns: minmax(0, 45%) minmax(0, 55%);
  }

  .category-posts-grid > .post-card.post-card--no-image:nth-last-child(1):nth-child(4n + 1) {
    display: flex;
    flex-direction: column;
  }

  .category-posts-grid > .post-card:nth-last-child(1):nth-child(4n + 1) .post-card__img-wrap {
    grid-column: 1;
    grid-row: 1;
    aspect-ratio: auto;
    height: 260px;
    min-height: 0;
  }

  .category-posts-grid > .post-card:nth-last-child(1):nth-child(4n + 1) .post-card__img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .category-posts-grid > .post-card:nth-last-child(1):nth-child(4n + 1) .post-card__body {
    display: flex;
    flex-direction: column;
    height: 260px;
    min-height: 0;
    padding: var(--space-xl);
    overflow: hidden;
  }

  .category-posts-grid > .post-card.post-card--has-image:nth-last-child(1):nth-child(4n + 1) .post-card__body {
    grid-column: 2;
    grid-row: 1;
  }

  .category-posts-grid > .post-card.post-card--no-image:nth-last-child(1):nth-child(4n + 1) .post-card__body {
    width: 100%;
  }

  /* Если осталось 2 обычные карточки — по половине */
  .category-posts-grid > .post-card:nth-last-child(2):nth-child(4n + 1),
  .category-posts-grid > .post-card:nth-last-child(1):nth-child(4n + 2) {
    grid-column: span 6;
  }

  /* Если осталось 3 обычные карточки — по трети */
  .category-posts-grid > .post-card:nth-last-child(3):nth-child(4n + 1),
  .category-posts-grid > .post-card:nth-last-child(2):nth-child(4n + 2),
  .category-posts-grid > .post-card:nth-last-child(1):nth-child(4n + 3) {
    grid-column: span 4;
  }

  /* Обычные карточки: фиксируем низ, чтобы дата/read more не уезжали */
  .category-posts-grid > .post-card:not(.post-card--category-main) .post-card__body {
    min-height: 250px;
    overflow: hidden;
  }

  /* Заголовок обычной карточки */
  .category-posts-grid > .post-card:not(.post-card--category-main) .post-card__title {
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
  }

  /* Описание обычной карточки */
  .category-posts-grid > .post-card:not(.post-card--category-main) .post-card__intro {
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
  }

  .category-posts-grid > .post-card:not(.post-card--category-main) .post-card__footer {
    margin-top: auto;
  }

  /* Горизонтальные карточки: основная и последняя одиночная */
  .category-posts-grid > .post-card--category-main .post-card__title,
  .category-posts-grid > .post-card:nth-last-child(1):nth-child(4n + 1) .post-card__title {
    display: -webkit-box;
    overflow: hidden;
    font-size: clamp(1.1rem, 2vw, var(--text-2xl));
    line-height: 1.3;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }

  .category-posts-grid > .post-card--category-main .post-card__intro,
  .category-posts-grid > .post-card:nth-last-child(1):nth-child(4n + 1) .post-card__intro {
    display: -webkit-box;
    overflow: hidden;
    font-size: 0.95rem;
    line-height: 1.6;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
  }

  .category-posts-grid > .post-card--category-main .post-card__footer,
  .category-posts-grid > .post-card:nth-last-child(1):nth-child(4n + 1) .post-card__footer {
    margin-top: auto;
  }
}
/* ============================================================
   POSTS GRID
   ============================================================ */
.posts-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
  padding: var(--space-xl) 0;
}

@media (min-width: 480px) {
  .posts-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 1024px) {
  .posts-grid--4 {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ============================================================
   HOME RECENT / CAROUSEL
   ============================================================ */

.home-recent {
  background: transparent;
  padding: 24px 0 0;
}

.home-recent > .container {
  background: var(--color-bg-alt);
  border-radius: 24px;
  padding-top: 24px;
  overflow: visible;
}

.home-recent__header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: var(--space-md);
  margin-bottom: 24px;
}

.home-recent__header .section-title {
  margin-bottom: 0;
}

.home-recent__all {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  min-height: 44px;
  padding: 0.65rem 1.4rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-primary);
  font-size: 0.9rem;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}

.home-recent__all:hover {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: #fff;
  text-decoration: none;
}

.carousel {
  position: relative;
  padding: 0 64px 36px;
  overflow: visible;
}

.carousel__track-wrap {
  overflow: hidden;
}

.carousel__track {
  display: flex;
  gap: var(--space-lg);
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}

.carousel__track::-webkit-scrollbar {
  display: none;
}

.carousel__slide {
  flex: 0 0 86%;
  min-width: 0;
  scroll-snap-align: start;
}

.carousel__slide .post-card {
  height: 100%;
}

.carousel__slide .post-card__img-wrap {
  height: 180px;
  aspect-ratio: auto;
}

.carousel__slide .post-card__body {
  min-height: 230px;
}

.carousel__btn {
  position: absolute;
  top: 43%;
  z-index: 5;
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: var(--color-bg);
  box-shadow: var(--shadow-md);
  color: var(--color-text);
  cursor: pointer;
  transform: translateY(-50%);
  transition:
    background var(--transition),
    border-color var(--transition),
    color var(--transition),
    opacity var(--transition);
}

.carousel__btn:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.carousel__btn:disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

.carousel__btn--prev {
  left: 12px;
}

.carousel__btn--next {
  right: 12px;
}

.carousel__dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: var(--space-xl);
  min-height: 10px;
}

.carousel__dot {
  width: 10px;
  height: 10px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #cbd5e1;
  cursor: pointer;
  transition:
    background var(--transition),
    transform var(--transition);
}

.carousel__dot--active {
  background: var(--color-primary);
  transform: scale(1.08);
}

@media (min-width: 480px) {
  .carousel__slide {
    flex-basis: calc((100% - var(--space-lg)) / 2);
  }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .carousel__slide {
    flex-basis: calc((100% - var(--space-lg)) / 2);
  }
}

@media (min-width: 1024px) {
  .carousel {
    padding-left: 0;
    padding-right: 0;
  }

  /*
    Desktop:
    показываем 3 полные карточки + кусок 4-й.
    Карточки становятся крупнее и ближе к верхнему блоку.
  */
  .carousel__slide {
    flex-basis: calc((100% - (var(--space-lg) * 3)) / 3.55);
  }

  .carousel__btn {
    display: flex;
  }

  .carousel__btn--prev {
    left: -22px;
  }

  .carousel__btn--next {
    right: -22px;
  }
}

@media (max-width: 767px) {
  .home-recent__header {
    grid-template-columns: 1fr auto;
    align-items: start;
    margin-bottom: 20px;
  }

  .home-recent__all {
    min-height: 38px;
    padding: 0.5rem 0.9rem;
    font-size: 0.82rem;
  }

  .home-recent > .container {
    border-radius: 0;
  }

  .carousel {
    padding-left: 0;
    padding-right: 0;
  }

  .carousel__track-wrap {
    overflow: visible;
  }

  .carousel__btn {
    display: none;
  }

  .carousel__slide .post-card__body {
    min-height: auto;
  }
}
@media (min-width: 768px) and (max-width: 1023px) {
  .home-recent__header {
    grid-template-columns: 1fr auto;
    align-items: start;
    margin-bottom: 24px;
  }
}
/* ============================================================
   HOME FEATURES
   ============================================================ */
.home-features {
  background: transparent;
  padding: 24px 0 0;
  margin-top: 0;
}

.home-features > .container {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: 24px;
  box-shadow: var(--shadow-sm);
  padding-top: 0;
  padding-bottom: 0;
  overflow: hidden;
}

.home-features__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}

.home-feature {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  padding: 24px 16px;
  border-bottom: 1px solid var(--color-border);
}

.home-feature:last-child {
  border-bottom: 0;
}

.home-feature__icon {
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
}

.home-feature__text {
  min-width: 0;
}

.home-feature strong {
  display: block;
  color: var(--color-text);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 6px;
}

.home-feature p {
  color: var(--color-text-muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

@media (min-width: 768px) and (max-width: 1023px) {
  .home-features__grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .home-feature:nth-child(1),
  .home-feature:nth-child(2) {
    border-bottom: 1px solid var(--color-border);
  }

  .home-feature:nth-child(2n + 1) {
    border-right: 1px solid var(--color-border);
  }

  .home-feature:nth-child(3),
  .home-feature:nth-child(4) {
    border-bottom: 0;
  }
}

@media (min-width: 1024px) {
  .home-features__grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .home-feature {
    padding: 24px 16px;
    border-bottom: 0;
    border-right: 1px solid var(--color-border);
  }

  .home-feature:nth-child(1),
  .home-feature:nth-child(2),
  .home-feature:nth-child(3),
  .home-feature:nth-child(4) {
    border-bottom: 0;
  }

  .home-feature:last-child {
    border-right: 0;
  }
}

/* ============================================================
   PAGE LAYOUTS
   ============================================================ */

.article-layout,
.category-layout,
.index-layout {
  padding: var(--space-xl) 0;
}

/* Верх статьи: контент + sidebar */
.article-layout__top {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2xl);
  align-items: start;
}

/* Для категорий и index оставляем старую сетку */
.category-layout,
.index-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-2xl);
}

@media (min-width: 1024px) {
  .home-recent__all {
    transform: translateY(-4px);
  }

  .article-layout__top {
    grid-template-columns: minmax(0, 65%) minmax(280px, 32%);
    gap: 48px;
    align-items: start;
  }

  .category-layout,
  .index-layout {
    grid-template-columns: minmax(0, 65%) minmax(280px, 32%);
    gap: 48px;
    align-items: start;
  }

  .article-sidebar,
  .category-sidebar,
  .index-sidebar {
    position: sticky;
    top: var(--sidebar-sticky-top, 10px);
    align-self: start;
  }
}

/* Похожие статьи всегда идут отдельным широким блоком после верхней сетки */
.article-layout > .similar-articles {
  margin-top: var(--space-2xl);
}

/* ============================================================
   SIDEBAR POPULAR ARTICLES
   ============================================================ */
.sidebar-popular {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.sidebar-popular__title {
  display: none;
  padding: var(--space-lg);
  border-bottom: 1px solid var(--color-border);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
}

.sidebar-popular__mobile-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  font-size: var(--text-base);
  font-weight: 700;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.sidebar-popular__mobile-summary::-webkit-details-marker { display: none; }
.sidebar-popular__mobile-summary::marker { display: none; }

.sidebar-popular__chevron {
  transition: transform var(--transition);
}

.sidebar-popular__mobile-toggle[open] .sidebar-popular__chevron {
  transform: rotate(180deg);
}

.sidebar-popular__inner {
  padding: 0;
}

@media (min-width: 1024px) {
  .sidebar-popular__mobile-summary {
    display: none;
  }

  .sidebar-popular__title {
    display: block;
  }

  details.sidebar-popular__mobile-toggle {
    display: block;
  }

  /* Важно: если <details> закрыт в HTML ради mobile, на desktop всё равно показываем содержимое. */
  details.sidebar-popular__mobile-toggle:not([open]) > .sidebar-popular__inner {
    display: block;
  }
}

.popular-list {
  padding: var(--space-xs) 0;
}

.popular-list__item {
  border-bottom: 1px solid var(--color-border);
}

.popular-list__item:last-child {
  border-bottom: 0;
}

.popular-list__link {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  color: var(--color-text);
  text-decoration: none;
  transition: background var(--transition);
}

.popular-list__link:hover {
  background: var(--color-bg-alt);
}

.popular-list__thumb {
  flex-shrink: 0;
  width: 72px;
  height: 54px;
  border-radius: var(--radius-sm);
  object-fit: cover;
}

.popular-list__text {
  flex: 1;
  min-width: 0;
}

.popular-list__item-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  color: var(--color-text);
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1.35;
}

.popular-list__date {
  display: block;
  color: var(--color-text-light);
  font-size: 0.72rem;
  margin-top: 4px;
}

.sidebar-popular__all {
  display: block;
  margin: var(--space-sm) var(--space-md);
  padding: 0.75rem var(--space-md);
  border: 1.5px solid var(--color-primary);
  border-radius: var(--radius-full);
  color: var(--color-primary);
  font-size: 0.88rem;
  font-weight: 600;
  text-align: center;
  transition: background var(--transition), color var(--transition);
}

.sidebar-popular__all:hover {
  background: var(--color-primary);
  color: #fff;
}

/* ============================================================
   TABLE OF CONTENTS
   ============================================================ */
.toc {
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin: var(--space-xl) 0;
  overflow: hidden;
}

.toc__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border);
}

.toc__label {
  font-size: 0.95rem;
  font-weight: 700;
}

.toc__toggle {
  display: flex;
  align-items: center;
  padding: 4px;
  background: none;
  border: 0;
  color: var(--color-text-muted);
  cursor: pointer;
}

.toc__chevron {
  transition: transform var(--transition);
}

.toc__toggle[aria-expanded="false"] .toc__chevron {
  transform: rotate(-90deg);
}

.toc__list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--space-md) var(--space-lg);
  list-style: none;
}

.toc__list[hidden] {
  display: none;
}

.toc.is-collapsed .toc__header {
  border-bottom: 0;
}

.toc__item--h3 {
  padding-left: 1.25rem;
}

.toc__link {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 3px 0;
  color: var(--color-text);
  font-size: 0.875rem;
  line-height: 1.45;
  text-decoration: none;
  transition: color var(--transition);
}

.toc__link::before {
  content: '•';
  flex-shrink: 0;
  color: var(--color-primary);
  font-size: 0.65rem;
  margin-top: 5px;
}

.toc__item--h3 .toc__link::before {
  content: '○';
  color: var(--color-text-light);
}

.toc__link:hover {
  color: var(--color-primary);
}

/* ============================================================
   ARTICLE BODY
   ============================================================ */
.article__hero-img {
  margin-bottom: var(--space-xl);
  border-radius: var(--radius-lg);
  aspect-ratio: 16 / 9;
  overflow: hidden;
}

.article__hero-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.article__body {
  font-size: var(--text-base);
  line-height: 1.75;
}

.article__body h2 {
  font-size: clamp(1.2rem, 3vw, var(--text-2xl));
  font-weight: 700;
  line-height: 1.3;
  margin: var(--space-2xl) 0 var(--space-md);
}

.article__body h3 {
  font-size: clamp(1.05rem, 2.5vw, var(--text-xl));
  font-weight: 700;
  line-height: 1.35;
  margin: var(--space-xl) 0 var(--space-sm);
}

.article__body p {
  margin-bottom: var(--space-md);
}

.article__body a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.article__body ul,
.article__body ol {
  padding-left: 1.5rem;
  margin-bottom: var(--space-md);
  list-style: revert;
}

.article__body li {
  margin-bottom: 4px;
  line-height: 1.65;
}

.article__body blockquote:not(.twitter-tweet) {
  border-left: 3px solid var(--color-primary);
  padding: var(--space-md) var(--space-lg);
  margin: var(--space-xl) 0;
  background: var(--color-bg-alt);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--color-text-muted);
  font-style: italic;
}

.article__body img {
  border-radius: var(--radius-md);
  margin: var(--space-md) 0;
}

.article__body figure {
  margin: var(--space-xl) 0;
}

.article__body figcaption {
  margin-top: var(--space-sm);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  text-align: center;
}

.article__body table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--space-xl) 0;
  font-size: var(--text-sm);
}

.article__body th,
.article__body td {
  padding: 0.75rem;
  border: 1px solid var(--color-border);
  text-align: left;
  vertical-align: top;
}

.article__body th {
  background: #f8fafc;
  font-weight: 700;
}

.article__body pre {
  overflow-x: auto;
  padding: var(--space-md);
  border-radius: var(--radius-md);
  background: #0f172a;
  color: #e2e8f0;
  margin: var(--space-xl) 0;
}

.article__body code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', monospace;
  font-size: 0.9em;
}

/* Embedded media: YouTube / iframe / Twitter */
.article-layout,
.article-main,
.article,
.article__body {
  min-width: 0;
  max-width: 100%;
}

.article__body .responsive-object {
  position: relative;
  display: block;
  width: 100%;
  max-width: 100%;
  height: 0;
  padding-bottom: 56.25%;
  margin: var(--space-xl) 0;
  overflow: hidden;
  border-radius: var(--radius-md);
}

.article__body .responsive-object iframe,
.article__body .responsive-object embed,
.article__body .responsive-object object {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.article__body > iframe,
.article__body p > iframe,
.article__body div > iframe {
  display: block;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  margin: var(--space-xl) 0;
  border: 0;
}

.article__body video,
.article__body embed,
.article__body object {
  display: block;
  width: 100%;
  max-width: 100%;
}

.article__body .twitter-tweet,
.article__body .twitter-tweet-rendered,
.article__body twitter-widget,
.article__body iframe[id^="twitter-widget-"] {
  display: block !important;
  width: 100% !important;
  max-width: 550px !important;
  min-width: 0 !important;
  margin: var(--space-xl) auto !important;
}

/* ============================================================
   SIMILAR ARTICLES
   ============================================================ */

.similar-articles {
  margin-top: var(--space-2xl);
  padding: 0;
  border-top: 0;
}

/* Внешний блок */
.similar-articles__mobile-toggle {
  display: block;
  background: var(--color-bg-alt);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

/* Summary — как у Popular articles */
.similar-articles__mobile-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;

  min-height: auto;
  padding: var(--space-md) var(--space-lg);

  color: var(--color-text);
  font-size: var(--text-base);
  font-weight: 700;
  line-height: 1.3;

  cursor: pointer;
  list-style: none;
  user-select: none;
}

.similar-articles__mobile-summary::-webkit-details-marker {
  display: none;
}

.similar-articles__mobile-summary::marker {
  display: none;
}

.similar-articles__chevron {
  flex-shrink: 0;
  color: var(--color-text);
  transition: transform var(--transition);
}

.similar-articles__mobile-toggle[open] .similar-articles__chevron {
  transform: rotate(180deg);
}

/* Контент внутри */
.similar-articles__inner {
  padding: var(--space-lg);
  border-top: 1px solid var(--color-border);
}

.similar-articles__title {
  display: none;
  margin-bottom: var(--space-lg);
  color: var(--color-text);
  font-size: var(--text-xl);
  font-weight: 800;
  line-height: 1.3;
}

/* Сетка */
.similar-articles__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-lg);
}

/* Карточка */
.similar-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.similar-card__img-wrap {
  display: block;
  width: 100%;
  height: 120px;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: #dbeafe;
  margin-bottom: var(--space-sm);
}

.similar-card__img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.similar-card__body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.similar-card__title {
  display: -webkit-box;
  overflow: hidden;
  color: var(--color-text);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.35;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.similar-card__title a {
  color: var(--color-text);
}

.similar-card__title a:hover {
  color: var(--color-primary);
}

.similar-card__read-more {
  color: var(--color-primary);
  font-size: 0.85rem;
  font-weight: 700;
  text-decoration: none;
}

/* Tablet + mobile: свернуто, как Popular articles */
@media (max-width: 1023px) {
  .similar-articles {
    margin-top: var(--space-xl);
  }

  .similar-articles__mobile-toggle:not([open]) > .similar-articles__inner {
    display: none;
  }

  .similar-articles__inner {
    padding: var(--space-md) var(--space-lg) var(--space-lg);
  }

  .similar-articles__grid {
    grid-template-columns: 1fr;
  }

  .similar-card--has-image {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: var(--space-md);
    align-items: center;
  }

  .similar-card__img-wrap {
    width: 92px;
    height: 64px;
    margin-bottom: 0;
  }
}

/* Desktop: раскрытый голубой блок */
/* Desktop: раскрытый широкий блок, карточки горизонтальные */
@media (min-width: 1024px) {
  .similar-articles {
    margin-top: var(--space-2xl);
  }

  .similar-articles__mobile-toggle {
    padding: 24px;
    border-radius: 24px;
  }

  .similar-articles__mobile-summary {
    display: none;
  }

  .similar-articles__title {
    display: block;
    margin-bottom: 20px;
    font-size: var(--text-xl);
    font-weight: 800;
  }

  details.similar-articles__mobile-toggle {
    display: block;
  }

  details.similar-articles__mobile-toggle:not([open]) > .similar-articles__inner {
    display: block;
  }

  .similar-articles__inner {
    padding: 0;
    border-top: 0;
  }

  .similar-articles__grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 28px;
  }

  .similar-card--has-image {
    display: grid;
    grid-template-columns: 104px minmax(0, 1fr);
    gap: 16px;
    align-items: center;
    min-width: 0;
  }

  .similar-card__img-wrap {
    width: 104px;
    height: 76px;
    margin-bottom: 0;
    border-radius: var(--radius-md);
  }

  .similar-card__body {
    gap: 8px;
    min-width: 0;
  }

  .similar-card__title {
    font-size: 0.88rem;
    line-height: 1.35;
    -webkit-line-clamp: 2;
  }

  .similar-card__read-more {
    font-size: 0.84rem;
    line-height: 1.2;
  }
}

/* Small mobile */
@media (max-width: 599px) {
  .similar-articles__mobile-summary {
    padding: var(--space-md) var(--space-lg);
    font-size: var(--text-base);
  }

  .similar-articles__inner {
    padding: var(--space-md);
  }

  .similar-card--has-image {
    grid-template-columns: 82px minmax(0, 1fr);
    gap: var(--space-sm);
  }

  .similar-card__img-wrap {
    width: 82px;
    height: 58px;
  }

  .similar-card__title {
    font-size: 0.84rem;
  }

  .similar-card__read-more {
    font-size: 0.8rem;
  }
}

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
  padding: var(--space-2xl) 0;
}

.pagination__load-more {
  width: 100%;
  max-width: 300px;
}

.pagination__load-more .btn {
  width: 100%;
}

.pagination__nav {
  display: flex;
}

.pagination__list {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
}

.pagination__link {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border: 1.5px solid transparent;
  border-radius: 50%;
  color: var(--color-text);
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}

/* Previous / Next — как Load more, но компактнее */
.pagination__link[rel="prev"],
.pagination__link[rel="next"] {
  min-width: 150px;
  height: 40px;
  padding: 0 22px;

  border-radius: var(--radius-full);
  border-color: transparent;

  color: var(--color-text);
  background: transparent;
  font-weight: 500;
}

.pagination__link[rel="prev"]:hover,
.pagination__link[rel="next"]:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: transparent;
}

.pagination__link:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.pagination__link--active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.pagination__link--active,
.pagination__link--active:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
  pointer-events: none;
}


/* ============================================================
   FOOTER
   ============================================================ */
.site-footer {
  border-top: 0;
  padding: 0 0 24px;
  margin-top: 24px;
}

.site-footer > .container {
  border-top: 1px solid var(--color-border);
  padding-top: 24px;
}

.site-footer__inner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-md);
}
.site-footer__logo {
  color: var(--color-text);
  font-size: 0.95rem;
  font-weight: 700;
}

.site-footer__contact {
  color: var(--color-text-muted);
  font-size: 0.875rem;
}

.site-footer__copyright {
  color: var(--color-text-muted);
  font-size: 0.82rem;
}

@media (min-width: 768px) {
  .site-footer__inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

/* ============================================================
   SEARCH
   ============================================================ */
.search-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-xl);
}

.search-form input {
  flex: 1;
  padding: 0.65rem 1rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-full);
  font-family: var(--font-sans);
  font-size: 0.9rem;
}

.search-form input:focus {
  outline: none;
  border-color: var(--color-primary);
}

@media (min-width: 480px) {
  .search-form {
    flex-direction: row;
  }
}

/* ============================================================
   EMPTY STATES / UTILITIES
   ============================================================ */
.no-posts {
  padding: var(--space-2xl) 0;
  color: var(--color-text-muted);
  text-align: center;
  font-size: var(--text-base);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   ARTICLE EMBEDS FIX: YouTube / iframe / Twitter
   ============================================================ */

.article-layout,
.article-main,
.article,
.article__body {
  min-width: 0;
  max-width: 100%;
}

/* Wagtail embed wrapper */
.article__body .responsive-object {
  position: relative;
  display: block;
  width: 100%;
  max-width: 100%;
  height: 0;
  padding-bottom: 56.25%;
  margin: var(--space-xl) 0;
  overflow: hidden;
  border-radius: var(--radius-md);
}

/* iframe inside Wagtail responsive object */
.article__body .responsive-object iframe,
.article__body .responsive-object embed,
.article__body .responsive-object object {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Direct YouTube iframe without wrapper */
.article__body > iframe,
.article__body p > iframe,
.article__body div > iframe {
  display: block;
  width: 100%;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  margin: var(--space-xl) 0;
  border: 0;
}

/* Other embedded media */
.article__body video,
.article__body embed,
.article__body object {
  display: block;
  width: 100%;
  max-width: 100%;
}

/* Twitter / X embeds */
.article__body .twitter-tweet,
.article__body twitter-widget {
  width: 100% !important;
  max-width: 100% !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* Twitter / X embeds */
.article__body .twitter-tweet,
.article__body .twitter-tweet-rendered,
.article__body twitter-widget,
.article__body iframe[id^="twitter-widget-"] {
  display: block !important;
  width: 100% !important;
  max-width: 550px !important;
  min-width: 0 !important;
  margin: var(--space-xl) auto !important;
}

/* ============================================================
   SEARCH PAGE
   ============================================================ */

.search-results {
  padding-top: var(--space-xl);
}

.search-results__count {
  color: var(--color-text-muted);
  font-size: 0.95rem;
  margin-bottom: 0;
}

.search-results__count strong {
  color: var(--color-text);
}

.search-form--hero {
  max-width: 620px;
  margin-bottom: 0;
}

.search-form--hero input {
  min-height: 46px;
  background: var(--color-bg);
}

@media (min-width: 480px) {
  .search-form--hero {
    display: flex;
    flex-direction: row;
  }

  .search-form--hero input {
    flex: 1;
  }
}

@media (max-width: 479px) {
  .search-form--hero .btn {
    width: 100%;
  }
}

/* ============================================================
   ERROR PAGES
   ============================================================ */

.error-hero .hero__text {
  max-width: 620px;
}

.error-page__code {
  color: var(--color-text);
  font-size: clamp(4.5rem, 12vw, 8rem);
  font-weight: 800;
  line-height: 0.9;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-md);
}

.error-page__title {
  margin-bottom: var(--space-md);
}

.error-page__text {
  max-width: 560px;
  color: var(--color-text-muted);
  font-size: 1rem;
  line-height: 1.65;
  margin-bottom: var(--space-md);
}

.error-page__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  margin-top: var(--space-xl);
}

@media (max-width: 479px) {
  .error-page__actions {
    flex-direction: column;
  }

  .error-page__actions .btn {
    width: 100%;
  }
}
