/* ============================================================================
   blog.css — Блог SpellBook на маркет-шелле (список /blog + статья /blog/slug).
   Всё на токенах marketplace.css (--surface/--line/--text…, --font-display/body,
   --r-*, --skeleton) → обе темы работают автоматически, свои цвета не вводим.
   Префиксы: .bl-* список · .bc-* карточка · .art-* статья.
   ============================================================================ */

/* ── Контейнеры ── */
.bl-wrap { max-width: 1160px; margin: 0 auto; padding: 30px clamp(16px, 3vw, 40px) 80px; }
.art-wrap { max-width: 780px; margin: 0 auto; padding: 26px clamp(16px, 3vw, 40px) 80px; }

/* Скелетон-кирпичи внутри флексов должны быть блочными */
.skel-only .sk { display: block; }

/* ── Шапка списка ── */
.bl-head { margin-bottom: 26px; }
.bl-h1 { margin: 0; font: 600 clamp(1.9rem, 3.2vw, 2.5rem)/1.15 var(--font-display); letter-spacing: .01em; color: var(--text); overflow-wrap: break-word; }
.bl-sub { margin: 10px 0 0; color: var(--text-2); font-size: .95rem; }
/* инлайн-иконка, но тач-таргет ≥32px: паддинг + компенсирующий margin */
.bl-rss { display: inline-flex; padding: 9px; margin: -9px -9px -9px 1px; vertical-align: middle; color: var(--text-4); transition: color var(--dur) var(--ease); }
.bl-rss:hover { color: var(--pro-fg); }
.bl-sk-h1 { width: 130px; height: 38px; }
.bl-sk-sub { width: min(430px, 82%); height: 14px; margin-top: 12px; }

/* ── Герой (свежая статья) ── */
.bl-feat {
  display: grid; grid-template-columns: 1.15fr 1fr;
  border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden;
  background: var(--surface); margin: 0 0 22px; text-decoration: none;
  transition: border-color var(--dur) var(--ease);
}
.bl-feat:hover { border-color: var(--line-2); }
.bl-feat-cover { position: relative; overflow: hidden; min-height: 300px; background: var(--raised); }
.bl-feat-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .5s var(--ease); }
.bl-feat:hover .bl-feat-cover img { transform: scale(1.03); }
.bl-feat-body { padding: clamp(20px, 3vw, 38px); display: flex; flex-direction: column; justify-content: center; }
.bl-feat-badge {
  font: 600 .68rem var(--font-display); letter-spacing: .09em; text-transform: uppercase;
  color: var(--verified); border: 1px solid color-mix(in srgb, var(--verified) 35%, transparent);
  padding: 3px 9px; border-radius: 100px;
}
.bl-feat-title { margin-top: 14px; font: 600 clamp(1.3rem, 2.6vw, 1.85rem)/1.25 var(--font-display); color: var(--text); text-wrap: balance; overflow-wrap: break-word; }
.bl-feat-desc {
  margin-top: 12px; color: var(--text-2); font-size: .95rem; line-height: 1.6;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.bl-feat-sk .bl-feat-cover .sk, .bl-sk-cover { position: absolute; inset: 0; border-radius: 0; }

/* ── Сетка карточек ── */
.bl-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.bc-card {
  display: flex; flex-direction: column;
  border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden;
  background: var(--surface); text-decoration: none;
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.bc-card:hover { transform: translateY(-3px); border-color: var(--line-2); }
.bc-card:focus-visible, .bl-feat:focus-visible, .art-rel-card:focus-visible { outline: 2px solid var(--verified); outline-offset: 2px; }
.bc-cover { position: relative; aspect-ratio: 16 / 9; overflow: hidden; background: var(--raised); display: block; }
.bc-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: transform .45s var(--ease); }
.bc-card:hover .bc-cover img { transform: scale(1.045); }
.bc-cover-ph {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 2rem; color: var(--text-4); background: linear-gradient(135deg, var(--raised), var(--surface));
}
.bc-body { display: flex; flex-direction: column; flex: 1; padding: 16px 18px 20px; }
.bc-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; color: var(--text-3); font-size: .8rem; }
.bc-dot { width: 3px; height: 3px; border-radius: 50%; background: var(--text-4); flex: 0 0 auto; }
.bc-title {
  margin-top: 10px; font: 600 1.05rem/1.35 var(--font-display); color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.bc-desc {
  margin-top: 8px; color: var(--text-2); font-size: .875rem; line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.bc-more { margin-top: auto; padding-top: 14px; display: inline-flex; align-items: center; gap: 7px; color: var(--text); font: 600 .8rem var(--font-display); }
.bl-feat .bc-more { padding-top: 0; margin-top: 18px; font-size: .85rem; }
.bc-more i { transition: transform var(--dur) var(--ease); }
.bc-card:hover .bc-more i, .bl-feat:hover .bc-more i { transform: translateX(3px); }

/* стаггер появления карточек после снятия скелетона (и для догруженных) */
@keyframes bcIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
body:not(.loading) .bl-grid .bc-card { animation: bcIn .5s var(--ease) both; animation-delay: calc(var(--bc-i, 0) * 45ms); }

/* ── «Показать ещё» ── */
.bl-more { display: flex; justify-content: center; margin: 30px 0 8px; }
/* display:flex перебил бы UA-правило для [hidden] — возвращаем его явно
   (тот же паттерн, что у .hdr-bell-badge[hidden] в marketplace.css) */
.bl-more[hidden] { display: none !important; }
.bl-more-btn {
  height: 42px; padding: 0 26px; border-radius: 100px; border: 1px solid var(--line-2);
  background: transparent; color: var(--text); font: 600 .875rem var(--font-display);
  cursor: pointer; transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
  display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
}
.bl-more-btn:hover { background: var(--raised); }
.bl-more-btn[disabled] { opacity: .6; cursor: default; }

/* ── Пустое состояние ── */
.bl-empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 70px 24px; }
.bl-empty-ic {
  width: 54px; height: 54px; border-radius: 50%; background: var(--raised); color: var(--text-3);
  display: flex; align-items: center; justify-content: center; font-size: 1.35rem;
}
.bl-empty-t { margin-top: 16px; font: 600 1.1rem var(--font-display); color: var(--text); }
.bl-empty-s { margin-top: 7px; color: var(--text-2); font-size: .9rem; max-width: 340px; }
.bl-empty-btn { margin-top: 20px; }

/* ============================================================================
   СТАТЬЯ
   ============================================================================ */

/* Прогресс чтения — тонкая полоса под шапкой */
.art-progress { position: fixed; top: var(--hdr-h); left: var(--rail-w); right: 0; height: 2px; z-index: 60; pointer-events: none; }
.art-progress span { display: block; height: 100%; background: var(--verified); transform: scaleX(0); transform-origin: 0 50%; }
/* iOS-баннер приложения сдвигает шапку вниз (body.has-appbar) — двигаем и полосу */
body.has-appbar .art-progress { top: calc(var(--hdr-h) + var(--appbar-h, 54px)); }

.art-crumbs { margin-bottom: 4px; }
.art-crumbs a {
  display: inline-flex; align-items: center; gap: 4px; color: var(--text-3);
  font: 500 .85rem var(--font-display); text-decoration: none; transition: color var(--dur) var(--ease);
}
.art-crumbs a:hover { color: var(--text); }

.art-h1 { margin: 14px 0 0; font: 600 clamp(1.65rem, 4vw, 2.4rem)/1.2 var(--font-display); color: var(--text); text-wrap: balance; overflow-wrap: break-word; }
.art-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 14px; color: var(--text-3); font-size: .875rem; }
.art-views { display: inline-flex; align-items: center; gap: 5px; }

.art-hero {
  margin: 26px 0 34px; aspect-ratio: 16 / 9; overflow: hidden; border-radius: var(--r-lg);
  background: var(--raised);
}
.art-hero picture, .art-hero img { display: block; width: 100%; height: 100%; }
.art-hero img { object-fit: cover; }

/* скелетон статьи */
.art-sk-hero { aspect-ratio: 16 / 9; margin: 26px 0 34px; border-radius: var(--r-lg); }
/* Morph обложки (cross-doc View Transitions): имя blog-hero носит РОВНО один
   видимый элемент. Пока body.loading (снимок первого кадра при холодном
   переходе) — скелетон-hero, после reveal — настоящий hero. Иначе на
   непререндеренных переходах пара не находилась и morph не срабатывал. */
body.loading .art-sk-hero { view-transition-name: blog-hero; }
body:not(.loading) .art-hero { view-transition-name: blog-hero; }
.art-sk-lines { display: flex; flex-direction: column; gap: 12px; }
.art-sk-gap { height: 14px; }

/* ── Типографика тела статьи ── */
.art-body { font-size: 1.0625rem; line-height: 1.75; color: var(--text); overflow-wrap: break-word; }
.art-body > :first-child { margin-top: 0; }
.art-body p { margin: 0 0 1.1em; }
.art-body h2 { margin: 2em 0 .75em; font: 600 1.45rem/1.3 var(--font-display); color: var(--text); }
.art-body h3 { margin: 1.7em 0 .6em; font: 600 1.18rem/1.3 var(--font-display); color: var(--text); }
.art-body h4 { margin: 1.5em 0 .5em; font: 600 1.02rem var(--font-display); color: var(--text); }
.art-body ul, .art-body ol { margin: .2em 0 1.2em; padding-left: 1.3em; }
.art-body li { margin: .45em 0; }
.art-body li::marker { color: var(--text-3); }
.art-body a { color: var(--verified); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.art-body a:hover { text-decoration-thickness: 2px; }
.art-body blockquote { margin: 1.6em 0; padding: .4em 0 .4em 1.2em; border-left: 3px solid var(--line-2); color: var(--text-2); }
.art-body blockquote p:last-child { margin-bottom: 0; }
.art-body hr { margin: 2em 0; border: 0; border-top: 1px solid var(--line); }
.art-body img { max-width: 100%; height: auto; border-radius: var(--r-md); }
.art-body :not(pre) > code {
  background: var(--raised); border: 1px solid var(--line); padding: .1em .4em;
  border-radius: 5px; font-family: var(--font-mono); font-size: .85em;
}

/* таблицы — всегда в скролл-контейнере (мобильные) */
.art-scroll { margin: 1.6em 0; border: 1px solid var(--line); border-radius: var(--r-md); overflow-x: auto; -webkit-overflow-scrolling: touch; }
.art-scroll table { margin: 0; min-width: 520px; }
.art-body table { width: 100%; border-collapse: collapse; font-size: .9rem; line-height: 1.5; }
.art-body th, .art-body td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.art-body th { background: var(--raised); font-weight: 600; white-space: nowrap; }
.art-body tr:last-child td { border-bottom: 0; }

/* фигуры и видео */
.art-figure { margin: 1.8em 0; }
.art-figure picture, .art-figure img { display: block; width: 100%; }
.art-figure img { border-radius: var(--r-lg); }
.art-figure figcaption { margin-top: 10px; text-align: center; font-size: .85rem; color: var(--text-3); }
.art-video { position: relative; aspect-ratio: 16 / 9; margin: 1.8em 0; border-radius: var(--r-lg); overflow: hidden; background: var(--void); }
.art-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* код-блок */
.art-code { margin: 1.6em 0; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--surface); }
.art-code-bar { display: flex; justify-content: space-between; align-items: center; padding: 7px 12px; background: var(--raised); border-bottom: 1px solid var(--line); }
.art-code-lang { font: 500 .72rem var(--font-mono); text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); }
.art-code-copy {
  display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent;
  color: var(--text-3); font: 500 .78rem var(--font-body); cursor: pointer; padding: 3px 6px;
  border-radius: var(--r-sm); transition: color var(--dur) var(--ease);
}
.art-code-copy:hover { color: var(--text); }
.art-code-copy.is-ok { color: var(--pos); }
.art-code pre { margin: 0; padding: 14px 16px; overflow-x: auto; }
.art-code code { font-family: var(--font-mono); font-size: .85rem; line-height: 1.6; color: var(--text); }

/* ── Поделиться ── */
.art-foot { margin-top: 44px; border-top: 1px solid var(--line); padding-top: 22px; }
.art-share { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.art-share-l { color: var(--text-3); font: 600 .8rem var(--font-display); text-transform: uppercase; letter-spacing: .07em; margin-right: 4px; }
.art-share-btn {
  display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 14px;
  border-radius: 100px; border: 1px solid var(--line-2); background: transparent;
  color: var(--text-2); font: 500 .85rem var(--font-body); cursor: pointer; text-decoration: none;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.art-share-btn:hover { color: var(--text); background: var(--raised); }
.art-share-btn.is-ok { color: var(--pos); border-color: color-mix(in srgb, var(--pos) 40%, transparent); }
.art-share-btn i, .art-share-btn svg { font-size: 1.05rem; flex: 0 0 auto; }

/* ── Читайте также ── */
.art-rel { margin-top: 52px; }
.art-rel-h { margin: 0 0 16px; font: 600 1.15rem var(--font-display); color: var(--text); }
.art-rel-list { display: grid; gap: 12px; }
.art-rel-card {
  display: flex; align-items: center; gap: 14px; padding: 12px;
  border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface);
  text-decoration: none; transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.art-rel-card:hover { border-color: var(--line-2); background: var(--raised); }
.art-rel-cover { position: relative; flex: 0 0 132px; aspect-ratio: 16 / 9; border-radius: var(--r-md); overflow: hidden; background: var(--raised); }
.art-rel-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.art-rel-body { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.art-rel-title {
  font: 600 .95rem/1.35 var(--font-display); color: var(--text);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* ============================================================================
   Адаптив: 1080 (сетка 2), 900 (моб. шелл), 860 (герой в столбец), 680 (1 кол.),
   480 (плотнее). Проверено до iPhone 12 mini (375px).
   ============================================================================ */
@media (max-width: 1080px) {
  .bl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .art-progress { left: 0; }
}
@media (max-width: 860px) {
  .bl-feat { grid-template-columns: 1fr; }
  .bl-feat-cover { min-height: 0; aspect-ratio: 16 / 9; }
}
@media (max-width: 680px) {
  .bl-grid { grid-template-columns: 1fr; gap: 14px; }
  .bl-wrap { padding-top: 22px; }
  .art-wrap { padding-top: 20px; }
  .art-body { font-size: 1rem; }
  .art-hero { margin: 20px 0 26px; }
  .art-scroll table { min-width: 460px; }
}
@media (max-width: 480px) {
  .bc-body { padding: 14px 14px 16px; }
  .bl-feat-body { padding: 18px 16px 22px; }
  .art-meta { gap: 8px; font-size: .8rem; }
  .art-share-btn { padding: 0 12px; height: 36px; }
  .art-rel-cover { flex-basis: 104px; }
  .art-body th, .art-body td { padding: 8px 10px; }
}

/* Бережно к prefers-reduced-motion (шиммер уже отключает marketplace.css) */
@media (prefers-reduced-motion: reduce) {
  body:not(.loading) .bl-grid .bc-card { animation: none; }
  .bc-card, .bc-cover img, .bl-feat-cover img, .bc-more i { transition: none; }
  .bc-card:hover { transform: none; }
  .bc-card:hover .bc-cover img, .bl-feat:hover .bl-feat-cover img { transform: none; }
}
