/* Мобильная версия как приложение (10.2026): касания, меню и нижняя панель, медиа, листание записей. Подключается сразу после mix_ui.css. */

/* ===== [mobile-touch] Касания: отклик, размеры целей, мелкий текст (владелец: волна «касание») ===== */
html {
  -webkit-tap-highlight-color: rgba(17, 24, 39, 0.1);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

a,
button,
summary,
label,
input,
select,
textarea,
[role="button"] {
  touch-action: manipulation;
}

/* Видимый отклик на нажатие (на наведение не полагаемся: на телефоне оно «залипает»). */
a:active,
button:active,
summary:active,
[role="button"]:active {
  opacity: 0.65;
}

.home-news-row a:active,
.home-list-row a:active,
.post-more-link:active,
.post-adjacent-link:active,
.reader-followed-card:active {
  background: var(--mx-surface-soft);
}

.home-media-card {
  transition: transform 0.12s ease;
}

.home-media-card:active {
  transform: scale(0.98);
}

@media (prefers-reduced-motion: reduce) {
  .home-media-card,
  .home-media-card:active {
    transform: none;
    transition: none;
  }
}

/* Цели нажатия не меньше 44 px; «body» перебивает стили внутри страниц. */
body .topic-chip,
body .mx-logo,
body .mx-footer-links a {
  min-height: 44px;
}

body .mx-footer-links {
  gap: 0.5rem 1.5rem;
}

body .mx-footer-links a,
.breadcrumb a {
  align-items: center;
  display: inline-flex;
}

.breadcrumb a {
  min-height: 44px;
}

.breadcrumb-bar {
  padding-block: 0;
}

/* Служебный текст не мельче 15 px. */
body .home-block-head.home-block-head,
body .home-channel-text,
body .home-list-date,
body .home-media-foot,
body .post-date-label,
body .channel-archive-pagination__status,
body .mx-btn-sm,
body .home-media-card:not(.home-media-card--rail) .feed-card-video-badge {
  font-size: 0.9375rem;
}
/* ===== [/mobile-touch] ===== */

/* ===== [mobile-chrome] Меню, нижняя панель, плашка cookie, полосы тем (владелец: волна «навигация») ===== */
/* Липкие полосы: mx_public.css ставит overflow-x: hidden на html и body, и это отключает position: sticky.
   clip режет вылезающее так же, но липкость не трогает. Где clip не знают, остаётся hidden. */
@supports (overflow: clip) {
  html,
  body {
    overflow-x: clip;
  }
}

/* Нижняя панель вкладок: только телефон. Высоту панели --mx-tabbar-h и то, сколько она занимает сейчас
   (--mx-tabbar-space: убрана прокруткой вниз — остаётся отступ под жестовую полосу), задаёт сам блок панели
   (partials/_mobile_tabbar.html), поэтому без панели переменных нет. Место под панель в конце страницы — .mx-tabbar-spacer
   (без :has(), он не везде есть: iOS до 15.4). */
.mx-tabbar,
.mx-tabbar-spacer {
  display: none;
}

@media (max-width: 760px) {
  .mx-tabbar-spacer {
    display: block;
    height: var(--mx-tabbar-h);
  }

  /* Плашка cookie закрывает низ страницы: оставляем под ней место. */
  body.mx-has-consent .mx-tabbar-spacer {
    height: calc(var(--mx-tabbar-h) + var(--mx-consent-h, 0px));
  }

  .mx-tabbar {
    background: #fff;
    border-top: 1px solid var(--mx-line);
    bottom: 0;
    box-sizing: border-box;
    display: flex;
    height: var(--mx-tabbar-h);
    left: 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    position: fixed;
    right: 0;
    transition: transform 0.2s ease;
    z-index: 40;
  }

  html.mx-chrome-hidden .mx-tabbar {
    transform: translateY(100%);
  }

  .mx-tabbar-item {
    -webkit-tap-highlight-color: transparent;
    align-items: center;
    background: none;
    border: 0;
    border-radius: 0;
    color: var(--mx-muted);
    cursor: pointer;
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    font: inherit;
    font-size: 15px;
    font-weight: 600;
    gap: 2px;
    justify-content: center;
    line-height: 1.1;
    min-height: 56px;
    min-width: 44px;
    padding: 0;
    position: relative;
    text-decoration: none;
    touch-action: manipulation;
  }

  .mx-tabbar-item svg {
    fill: none;
    height: 24px;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
    width: 24px;
  }

  .mx-tabbar-item:active {
    background: var(--mx-surface-soft, #f2f1ee);
  }

  .mx-tabbar-item:focus-visible {
    outline: 3px solid var(--mx-ink);
    outline-offset: -3px;
  }

  /* Выбранный раздел: тёмный цвет, жирнее значок и полоса сверху. */
  .mx-tabbar-item[aria-current="page"] {
    color: var(--mx-ink);
    font-weight: 800;
  }

  .mx-tabbar-item[aria-current="page"] svg {
    stroke-width: 2.6;
  }

  .mx-tabbar-item[aria-current="page"]::before {
    background: var(--mx-ink);
    border-radius: 0 0 3px 3px;
    content: "";
    height: 3px;
    left: 20%;
    position: absolute;
    right: 20%;
    top: -1px;
  }

  @media (prefers-reduced-motion: reduce) {
    .mx-tabbar {
      transition: none;
    }
  }
}

/* Уменьшение движения: бегущая заглушка ленты стоит на месте, страница не прокручивается плавно. */
@media (prefers-reduced-motion: reduce) {
  .feed-skeleton-card {
    animation: none;
  }

  html {
    scroll-behavior: auto;
  }
}

/* Открытое меню: страница под ним не прокручивается. Позицию (top) задаёт шапка и возвращает при закрытии. */
body.mx-menu-open {
  left: 0;
  position: fixed;
  right: 0;
  width: 100%;
}

/* Ряд тем идёт от края до края: левая колонка не сдвигается и не режет ряд справа,
   отступ 16px — у самого ряда (padding и scroll-padding), поэтому крайние плашки не прилипают к краю. */
@media (max-width: 980px) {
  .home-left {
    margin-left: 0;
    margin-right: 0;
    max-width: none;
    padding-left: 0;
    padding-right: 0;
    width: auto;
  }

  /* Страницы, где у контейнера свой отступ 1rem («Авторы», тема): колонка выходит за него, ряд — нет. */
  .mx-container.mx-section:not(:has(.home-discovery-panel)):not(:has(.post-page-layout)) .home-left {
    margin-left: -1rem;
    margin-right: -1rem;
  }

  .mx-container.mx-section:not(:has(.home-discovery-panel)):not(:has(.post-page-layout)) .home-topic-nav {
    margin-left: 0;
    margin-right: 0;
  }

  .home-topic-nav,
  .home-tabs {
    scroll-padding-left: 16px;
    scroll-padding-right: 16px;
  }
}

/* Без скриптов «Меню» не откроется: оставляем три ссылки. */
html:not(.js) .mx-tabbar [data-mx-menu-open] {
  display: none;
}
/* ===== [/mobile-chrome] ===== */

/* ===== [mobile-media] Фото и видео в записи, просмотр фото (владелец: волна «медиа») ===== */
/* Одиночное фото целиком: ширина колонки, высота до 70% экрана, без обрезки до 16:9. */
.post-media.single-image {
  aspect-ratio: auto;
  background: var(--mx-surface);
}

.post-media.single-image img {
  width: 100%;
  height: auto;
  min-height: 12rem;
  max-height: 70vh;
  max-height: 70dvh;
  object-fit: contain;
  margin: 0 auto;
}

/* Кнопка «Смотреть видео»: переносится, не режется краем экрана. */
.post-video .play-btn {
  white-space: normal;
  width: max-content;
  max-width: calc(100% - 2rem);
  text-align: center;
  line-height: 1.3;
}

@media (max-width: 600px) {
  /* Отрицательные поля были применены дважды (рамка и вложенная плитка): всё строго в колонке. */
  .post-media,
  .post-album,
  .carousel-container:has(> .post-album) {
    margin: 1.5rem 0;
  }

  .post-media .post-video,
  .post-album > *,
  .carousel-container > .post-album {
    margin: 0;
  }
}

/* Точки альбома не накрывают плашку «Смотреть в МАКСе»: уходят вверх. */
.carousel-container:has(.feed-card-video-badge) .carousel-indicators {
  bottom: auto;
  top: 0.6rem;
}

/* Просмотр фото: сплошной фон (ничего не просвечивает), вырезы экрана, dvh. */
.mx-lightbox {
  background: rgba(0, 0, 0, var(--mx-lb-alpha, 1));
  height: 100vh;
  height: 100dvh;
  overscroll-behavior: contain;
}

html:has(body.mx-lightbox-open) {
  overflow: hidden;
}

.mx-lightbox-open {
  overscroll-behavior: none;
}

.mx-lightbox-stage {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  overflow: hidden;
  cursor: auto;
  padding: calc(env(safe-area-inset-top, 0px) + 3.5rem) max(0.5rem, env(safe-area-inset-right, 0px))
    calc(env(safe-area-inset-bottom, 0px) + 4rem) max(0.5rem, env(safe-area-inset-left, 0px));
}

/* Жесты на сцене забираем себе только пока просмотр открыт. */
.mx-lightbox.active .mx-lightbox-stage {
  touch-action: none;
}

.mx-lightbox-stage img {
  transform-origin: 50% 50%;
  will-change: transform;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

.mx-lightbox.is-loading .mx-lightbox-stage img {
  opacity: 0;
}

.mx-lightbox.is-loading .mx-lightbox-stage::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 40px;
  height: 40px;
  margin: -20px 0 0 -20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: mx-lb-spin 0.8s linear infinite;
}

@keyframes mx-lb-spin {
  to {
    transform: rotate(360deg);
  }
}

.mx-lightbox-close {
  top: max(1rem, calc(env(safe-area-inset-top, 0px) + 0.5rem));
  right: max(1rem, calc(env(safe-area-inset-right, 0px) + 0.5rem));
}

.mx-lightbox-prev {
  left: max(0.4rem, env(safe-area-inset-left, 0px));
}

.mx-lightbox-next {
  right: max(0.4rem, env(safe-area-inset-right, 0px));
}

.mx-lightbox-footer {
  bottom: max(1rem, calc(env(safe-area-inset-bottom, 0px) + 0.5rem));
}

.mx-lightbox-counter {
  font-size: 1rem;
}

/* На телефоне точки только показывают место: листают пальцем, стрелками. */
@media (pointer: coarse) {
  .mx-lightbox-dots {
    pointer-events: none;
  }
}

/* Телефон лёжа: полям сверху и снизу отдано мало места. */
@media (max-height: 500px) {
  .mx-lightbox-stage {
    padding-top: max(0.5rem, env(safe-area-inset-top, 0px));
    padding-bottom: max(0.5rem, env(safe-area-inset-bottom, 0px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .mx-lightbox {
    transition: none;
  }

  .mx-lightbox.is-loading .mx-lightbox-stage::after {
    animation: none;
  }
}
/* ===== [/mobile-media] ===== */

/* ===== [mobile-reader] Листание записей: подсказка, счётчик, карточка-превью (владелец: волна «листание») ===== */
.feed-more {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1.5rem auto 2rem;
  max-width: 28rem;
  padding: 0 1rem;
  text-align: center;
}
.feed-more[hidden],
.feed-more [hidden] {
  display: none;
}
.feed-more-btn {
  min-height: 48px;
  min-width: 12rem;
}
.feed-more-end {
  color: var(--text-secondary, #4b5563);
  font-size: 1rem;
  margin: 0;
}

.mx-reader-peek {
  align-items: center;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  height: 100%;
  justify-content: center;
  padding: 2rem 1.5rem;
  text-align: center;
}
.mx-reader-peek--next {
  align-items: flex-end;
  text-align: right;
}
.mx-reader-peek--prev {
  align-items: flex-start;
  text-align: left;
}
.mx-reader-peek-label,
.mx-reader-peek-author {
  color: var(--text-secondary, #4b5563);
  font-size: 1rem;
  margin: 0;
}
.mx-reader-peek-title {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.3;
  margin: 0;
  max-width: 22rem;
}
.mx-reader-peek-image {
  border-radius: 12px;
  max-height: 32dvh;
  max-width: min(100%, 22rem);
  object-fit: cover;
}

.mx-reader-counter,
.mx-reader-hint {
  background: rgba(15, 23, 42, 0.82);
  border-radius: 999px;
  color: #fff;
  font-size: 0.9375rem;
  left: 50%;
  line-height: 1.2;
  padding: 0.5rem 0.9rem;
  pointer-events: none;
  position: fixed;
  transform: translateX(-50%);
  white-space: nowrap;
  z-index: 49;
}
.mx-reader-counter {
  display: none;
  top: calc(env(safe-area-inset-top, 0px) + 18px);
  transition: opacity 180ms ease;
}
html.mx-chrome-hidden .mx-reader-counter {
  opacity: 0;
}
[data-post-reader-shell] {
  touch-action: pan-y pinch-zoom;
}
@media (max-width: 980px) {
  .mx-reader-counter {
    display: block;
  }
}
.mx-reader-hint {
  top: calc(env(safe-area-inset-top, 0px) + 80px);
  border-radius: 16px;
  max-width: calc(100vw - 2rem);
  white-space: normal;
  text-align: center;
}
@media (prefers-reduced-motion: reduce) {
  .mx-reader-counter {
    transition: none;
  }
}
/* ===== [/mobile-reader] ===== */
