/* ============================================================================
   portal-legacy.css — bridge between portal.js (uses old class names)
   and Brand System v2 (Claude Design handoff, new class names).

   Created 2026-05-04 to fix /ru/news + other JS-hydrated pages where
   portal.js renders DOM with classes (.section, .section--white, .container-wide,
   .section__title, .category-pill, .reveal, .load-more) that the v2 CSS
   doesn't define — so the page rendered without any styling.

   This is a thin compatibility layer; do NOT add new rules here.
   Long-term: refactor portal.js to use new BEM classes directly.
   ============================================================================ */

/* Section wrappers */
.section {
  display: block;
  padding: 80px 0;
  background: var(--h-bg, #fff);
}
.section--white {
  background: #fff;
  color: var(--h-text, #1a1a1a);
}
.section--dark {
  background: var(--h-bg-dark, #0a0a0a);
  color: #fff;
}

/* Container — wide content area */
.container-wide {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Section header (old portal.js BEM-style → maps to new -dash style) */
.section__header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 32px;
  align-items: flex-start;
}
.section__title {
  font-size: clamp(28px, 4vw, 48px);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--h-text, #1a1a1a);
  margin: 0;
}

/* Categories row + pills — alias to new .chip system */
.categories-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 0 0 32px;
}
.category-pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--h-border, #e5e5e5);
  background: transparent;
  color: var(--h-text, #1a1a1a);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  font-family: inherit;
}
.category-pill:hover {
  border-color: var(--h-text, #1a1a1a);
}
.category-pill--active,
.category-pill.active {
  background: var(--h-text, #1a1a1a);
  color: #fff;
  border-color: var(--h-text, #1a1a1a);
}

/* News list grid */
#news-list-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}
@media (max-width: 1024px) {
  #news-list-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  #news-list-grid { grid-template-columns: 1fr; }
  .section { padding: 40px 0; }
  .container-wide { padding: 0 16px; }
}

/* Reveal animation — no-op (portal.js wraps every card in <div class="reveal">) */
.reveal {
  opacity: 1;
  transform: none;
}

/* Load more button */
.load-more {
  display: flex;
  justify-content: center;
  margin: 48px 0 0;
}
.load-more__btn {
  padding: 14px 32px;
  border-radius: 999px;
  border: 1px solid var(--h-border, #e5e5e5);
  background: #fff;
  color: var(--h-text, #1a1a1a);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: inherit;
}
.load-more__btn:hover {
  background: var(--h-bg-warm, #f7f7f5);
  border-color: var(--h-text, #1a1a1a);
}

/* Skeleton loader for cards (renderSkeletonGrid) */
.skeleton-card {
  background: var(--h-bg-warm, #f7f7f5);
  border-radius: 16px;
  height: 280px;
  animation: skeleton-pulse 1.4s ease-in-out infinite;
}
@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* Article-actions: bookmark + font + theme toggle states (added 2026-05-04) */
.article__share-btn.is-active,
.article__share-btn[data-bookmark].is-active {
  color: var(--h-coral, #e85a3c);
  background: rgba(232, 90, 60, 0.1);
}
[data-font].is-active {
  background: var(--h-text, #1a1a1a);
  color: #fff;
}
.article__body[data-font-size="s"] { font-size: 15px; line-height: 1.65; }
.article__body[data-font-size="m"] { font-size: 17px; line-height: 1.7; }
.article__body[data-font-size="l"] { font-size: 19px; line-height: 1.75; }

/* Dark theme override (when [data-theme-toggle] click adds .h-theme-dark to html) */
html.h-theme-dark {
  background: #0a0a0a;
  color-scheme: dark;
}
html.h-theme-dark body {
  background: #0a0a0a;
  color: #f0f0f0;
}

/* ============================================================================
   News cards — portal.js renderNewsCard() output (different from SSR cards).
   Added 2026-05-04 part 2 (after first portal-legacy.css).
   ============================================================================ */

/* News grid — 3 col → 2 col → 1 col */
.news-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 28px;
}
@media (max-width: 1024px) { .news-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px)  { .news-grid { grid-template-columns: 1fr; gap: 20px; } }

.news-card {
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: 1px solid var(--h-border, #e5e5e5);
}
.news-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.08);
}
.news-card--featured {
  /* Featured: same shape, just used to apply special positioning if needed */
}

.news-card__image {
  display: block;
  background: var(--h-bg-warm, #f7f7f5);
  aspect-ratio: 16 / 9;
  overflow: hidden;
}
.news-card__image picture,
.news-card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.news-card__body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 20px 22px 22px;
  flex: 1;
}

.news-card__title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--h-text, #1a1a1a);
}
.news-card--featured .news-card__title {
  font-size: 22px;
}

.news-card__excerpt {
  font-size: 14px;
  line-height: 1.5;
  color: var(--h-text-muted, #666);
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.news-card__meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
  padding-top: 8px;
  font-size: 12px;
  color: var(--h-text-subtle, #999);
}

.news-card__source {
  font-weight: 600;
  color: var(--h-text-muted, #666);
}

.news-card__dot {
  color: var(--h-text-subtle, #ccc);
  opacity: 0.6;
}

/* Reveal — animation entrance, JS toggles .is-visible */
.reveal {
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.reveal.is-visible {
  opacity: 1;
  transform: none;
}

/* Override above #news-list-grid grid — must be display:block since .news-grid inside has its own grid */
#news-list-grid,
#news-list-grid {
  display: block !important;
  grid-template-columns: none !important;
  gap: 0 !important;
}

/* ============================================================================
   Article page (portal.js render) — block layout, NOT 4-col grid.
   The seo.js article reader uses .article-reader > .article (grid), but
   portal.js renderArticle() uses bare <div class="article"> with different
   children (.article__back, .article__title, .article__meta, .article__image,
   .article__content, .article__engagement, .related). The CSS .article {grid}
   from new design system fights this — override when in #portal-app context.
   ============================================================================ */

#portal-app .article {
  display: block !important;
  grid-template-columns: none !important;
  max-width: 860px !important;
  padding: 32px 24px 80px !important;
  margin: 0 auto !important;
}

#portal-app .article__back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--h-text-muted, #666);
  text-decoration: none;
  font-size: 14px;
  margin-bottom: 24px;
}
#portal-app .article__back::before {
  content: "←";
  margin-right: 4px;
}
#portal-app .article__back:hover {
  color: var(--h-text, #1a1a1a);
}

#portal-app .article__title {
  font-size: clamp(28px, 4vw, 48px);
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0 0 16px;
  width: auto !important;
}

#portal-app .article__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  font-size: 14px;
  color: var(--h-text-muted, #666);
  margin-bottom: 28px;
  width: auto !important;
}

#portal-app .article__image {
  margin: 0 0 32px;
  width: auto !important;
}
#portal-app .article__image img,
#portal-app .article__image picture img {
  width: 100%;
  border-radius: 12px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
}

#portal-app .article__content {
  font-size: 17px;
  line-height: 1.7;
  color: var(--h-text, #1a1a1a);
  width: auto !important;
}
#portal-app .article__content p { margin: 0 0 18px; }
#portal-app .article__content h2 { font-size: 26px; margin: 36px 0 14px; font-weight: 700; }
#portal-app .article__content h3 { font-size: 21px; margin: 28px 0 12px; font-weight: 700; }
#portal-app .article__content a { color: var(--h-primary, #2D2FE8); text-decoration: underline; }
#portal-app .article__content ul, #portal-app .article__content ol { margin: 0 0 18px; padding-left: 24px; }
#portal-app .article__content li { margin: 0 0 6px; }
#portal-app .article__content blockquote {
  border-left: 3px solid var(--h-primary, #2D2FE8);
  padding: 8px 18px;
  margin: 24px 0;
  color: var(--h-text-muted, #666);
  font-style: italic;
}
#portal-app .article__content code {
  background: var(--h-bg-warm, #f7f7f5);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

#portal-app .article__engagement {
  margin: 48px 0 32px;
  padding: 24px;
  background: var(--h-bg-warm, #f7f7f5);
  border-radius: 16px;
  width: auto !important;
}
#portal-app .article__engagement-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--h-primary, #2D2FE8);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 14px;
}

#portal-app .related {
  margin-top: 48px;
  width: auto !important;
}
