/* ==========================================================================
   Article page (Figma 138:384)
   Container 1224px (locked), dark theme
   ========================================================================== */

.article-page {
  max-width: var(--container-w);
  margin-inline: auto;
  padding-top: 64px;
  padding-bottom: 80px;
}

/* ----- Inner row: back-link aside + content ----- */
.article-page__inner {
  display: grid;
  grid-template-columns: 184px 1fr;
  column-gap: 24px;
  width: 875px;
  max-width: 100%;
  margin-left: auto;
  margin-right: auto;
}

/* ----- Back link (sticky, Figma Frame 153, padding 32/35) ----- */
.article-back {
  position: relative;
}
.article-back__link {
  position: sticky;
  top: 170px;
  display: inline-flex;
  align-items: center;
  gap: 16px;
  padding: 0 35px 0 35px;
  color: var(--text);
  text-decoration: none;
  font-family: var(--font-main);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.5;
  transition: opacity var(--tr);
}
.article-back__link:hover { opacity: 0.7; }
.article-back__link svg {
  width: 24px;
  height: 24px;
  flex: none;
}

/* ----- Article content column (667px) ----- */
.article-content {
  width: 667px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 32px;
}
.article-content__title {
  margin: 0;
  font-family: var(--font-main);
  font-size: 36px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}

/* ----- Article body ----- */
.article-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  /* Spacing via margins on blocks — works even if content is wrapped in <article>/<div> */
  gap: 0;
}
.article-body > * {
  max-width: 100%;
}

/* Global vertical rhythm between any content blocks (Figma gap 32) */
.article-body p,
.article-body h2,
.article-body h3,
.article-body ul,
.article-body ol,
.article-body .article-figure,
.article-body > img {
  margin: 0 0 32px;
  max-width: 100%;
}
.article-body p:last-child,
.article-body h2:last-child,
.article-body h3:last-child,
.article-body ul:last-child,
.article-body ol:last-child,
.article-body .article-figure:last-child,
.article-body > img:last-child,
.article-body article > :last-child,
.article-body section > :last-child,
.article-body div > :last-child {
  margin-bottom: 0;
}

.article-body p,
.article-body li {
  font-family: var(--font-main);
  font-size: 18px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--text);
}
.article-body p {
  width: 100%;
}
.article-body h2,
.article-body h3 {
  font-family: var(--font-main);
  font-size: 28px;
  font-weight: 500;
  line-height: 1.1;
  color: var(--text);
}
.article-body h3 { font-size: 22px; }
.article-body ul,
.article-body ol {
  padding-left: 1.25em;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}
.article-body a {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Images — Figma 138:384: 434×421, object-cover, radius 12 */
.article-body img,
.article-figure img {
  display: block;
  width: 434px;
  max-width: 100%;
  height: 421px;
  object-fit: cover;
  object-position: center;
  border-radius: 12px;
}

/* ----- Figure + caption (Figma Frame 55 / Frame 217) ----- */
.article-figure {
  width: 434px;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
}
.article-figure figcaption {
  margin: 0;
  font-family: var(--font-main);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--text-muted);
}

/* Safety net if Dzen wrappers ever leak through */
.article-body .article-image-item__size,
.article-body .article-image-item__container,
.article-body .article-image-item__background,
.article-body .article-image-with-viewer__image {
  all: unset;
  display: contents;
}

/* ----- Numbered list (Figma 1./2./3. as paragraph, but semantically <ol>) ----- */
.article-list {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: article-item;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.article-list li {
  counter-increment: article-item;
  font-family: var(--font-main);
  font-size: 18px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--text);
  padding-left: 32px;
  position: relative;
}
.article-list li::before {
  content: counter(article-item) ".";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--text);
  font-weight: 700;
}
.article-list li strong {
  font-weight: 700;
}

/* ----- "Читайте также" (Figma Frame 521, 808px centered) ----- */
.article-related {
  max-width: var(--container-w);
  margin: 64px auto 0;
  padding: 0;
  width: 808px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}
.article-related__title {
  margin: 0;
  font-family: var(--font-main);
  font-size: 36px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}
.article-related__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

/* ==========================================================================
   Responsive — strictly by Figma mockups
   Tablet 720  (903:9032):  content 640, no aside (back-link hidden),
                            title 32px, body p 18px, figure image 392 centered,
                            figure caption 14px, related 2 cols × card 310×553 gap 20
   Mobile 360  (555:3726):  content 320, no aside,
                            title 22px, body p 14px, figure image 320 full,
                            figure caption 12px, related 1 col × card 320×529 gap 12
   ========================================================================== */

/* ---------- TABLET (max-width: 1199px) ---------- */
@media (max-width: 1199px) {
  .article-page {
    padding-top: 32px;
    padding-bottom: 48px;
    padding-inline: var(--container-px);
  }

  /* Single column — hide back-link aside, expand content to full width */
  .article-page__inner {
    grid-template-columns: 1fr;
    column-gap: 0;
    width: 100%;
  }
  .article-back { display: none; }
  .article-content {
    width: 100%;
    gap: 24px;
  }

  /* Title 32 */
  .article-content__title { font-size: 32px; line-height: 1.25; }

  /* Body: spacing 24 */
  .article-body p,
  .article-body h2,
  .article-body h3,
  .article-body ul,
  .article-body ol,
  .article-body .article-figure,
  .article-body > img {
    margin-bottom: 24px;
  }
  .article-body p { font-size: 18px; line-height: 1.5; }

  /* Figure image ~392×380 (tablet Figma), caption 14 */
  .article-figure {
    width: 392px;
    align-items: flex-start;
    gap: 12px;
  }
  .article-body img,
  .article-figure img {
    width: 392px;
    max-width: 100%;
    height: 380px;
    border-radius: 12px;
  }
  .article-figure figcaption {
    font-size: 14px;
  }

  /* Numbered list */
  .article-list { gap: 12px; }
  .article-list li {
    font-size: 18px;
    line-height: 1.5;
  }

  /* Related: 2 cols × card 310×553, gap 20 */
  .article-related {
    margin-top: 32px;
    width: 100%;
    gap: 20px;
    padding-inline: var(--container-px);
  }
  .article-related__title { font-size: 32px; line-height: 1.25; }
  .article-related__grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }
  /* Card body tablet — same as blog.css tablet rules */
  .article-related .blog-card { border-radius: 16px; }
  .article-related .blog-card__cover { aspect-ratio: 310 / 234; height: auto; }
  .article-related .blog-card__body { padding: 12px; gap: 16px; }
  .article-related .blog-card__content { min-height: 178px; }
  .article-related .blog-card__main { margin-top: 16px; gap: 10px; }
  .article-related .blog-card__title { font-size: 18px; line-height: 1.2; }
  .article-related .blog-card__excerpt { font-size: 13px; line-height: 1.45; }
}

/* ---------- MOBILE (max-width: 767px) ---------- */
@media (max-width: 767px) {
  .article-page {
    padding-top: 20px;
    padding-bottom: 32px;
    padding-inline: var(--container-px);
  }

  /* Single column, full width */
  .article-page__inner {
    grid-template-columns: 1fr;
    column-gap: 0;
    width: 100%;
  }
  .article-back { display: none; }
  .article-content {
    width: 100%;
    gap: 16px;
  }

  /* Title 22 */
  .article-content__title { font-size: 22px; line-height: 1.18; }

  /* Body: spacing 16, font 14 */
  .article-body p,
  .article-body h2,
  .article-body h3,
  .article-body ul,
  .article-body ol,
  .article-body .article-figure,
  .article-body > img {
    margin-bottom: 16px;
  }
  .article-body p { font-size: 14px; line-height: 1.5; }

  /* Figure image full width, keep cover ratio */
  .article-figure {
    width: 100%;
    gap: 8px;
  }
  .article-body img,
  .article-figure img {
    width: 100%;
    height: auto;
    aspect-ratio: 434 / 421;
    border-radius: 12px;
  }
  .article-figure figcaption {
    font-size: 12px;
    line-height: 1.4;
  }

  /* Numbered list compact */
  .article-list { gap: 8px; }
  .article-list li {
    font-size: 14px;
    line-height: 1.5;
    padding-left: 24px;
  }

  /* Related: 1 col × card 320×529, gap 12 */
  .article-related {
    margin-top: 16px;
    width: 100%;
    gap: 12px;
    padding-inline: var(--container-px);
  }
  .article-related__title { font-size: 22px; line-height: 1.18; }
  .article-related__grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
  /* Card body mobile — same as blog.css mobile rules */
  .article-related .blog-card { border-radius: 12px; height: auto; }
  .article-related .blog-card__cover { aspect-ratio: 310 / 234; height: auto; }
  .article-related .blog-card__body { padding: 12px; gap: 12px; flex: none; }
  .article-related .blog-card__content { min-height: 0; height: auto; }
  .article-related .blog-card__main { margin-top: 12px; gap: 8px; }
  .article-related .blog-card__title { font-size: 16px; line-height: 1.25; }
  .article-related .blog-card__excerpt { font-size: 12px; line-height: 1.4; }
}
