/*
 * Динамическая лента новостей (.news-feed) + скрытая админка (.news-admin).
 * Лента повторяет вид статичной сетки: бордовые скруглённые карточки 2 колонки,
 * номер → текст → фото у нижнего края; карточки ряда одной высоты.
 */

/* Когда лента загрузилась из БД, статичная сетка скрывается (перебиваем
   display: grid !important из news-adaptive.css) */
html.pokiza-news-doc body.pokiza-page-inner.pokiza-page-news .news .group-17[hidden],
.news .pokiza-scale-sheet .group-17[hidden] {
  display: none !important;
}

.news-feed {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: 1fr;
  gap: clamp(10px, 1.6vw, 22px);
  width: 100%;
  max-width: min(1160px, 100%);
  margin: clamp(16px, 3vw, 36px) auto 0;
  position: relative;
  z-index: 15;
}

.news-card {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: clamp(14px, 2.4vw, 30px) clamp(12px, 2vw, 28px) clamp(16px, 2.6vw, 30px);
  box-sizing: border-box;
  border-radius: clamp(22px, 3vw, 40px);
  background: #6f160c;
  color: #ffffff;
  overflow: hidden;
}

.news-card__num {
  font-family: Involve, var(--font-sans-brand), var(--default-font-family, system-ui, sans-serif);
  font-size: clamp(0.95rem, 2.4vw, 2rem);
  font-weight: 700;
  line-height: 1.15;
}

.news-card__text {
  margin: 0;
  font-family: Involve, var(--font-sans-brand), var(--default-font-family, system-ui, sans-serif);
  font-size: clamp(0.62rem, 1.55vw, 1.2rem);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.news-card__photo {
  margin-top: auto;
  padding-top: 0.5rem;
}

.news-card__photo img {
  display: block;
  width: 100%;
  aspect-ratio: 519 / 336;
  object-fit: cover;
  border-radius: clamp(16px, 2.2vw, 28px);
}

/* Десктоп: лента занимает слот статичной сетки (.group-17) в координатном
   макете; фактическую высоту JS отдаёт в --news-grid-h, двигая подвал */
@media (min-width: 901px) {
  .news .news-feed {
    position: absolute;
    top: calc(
      var(--white-sheet-top) + var(--news-block-top-pad) + 67px + 5px + 48px + 52.9px + 26.6px + 26.6px + 47px
    );
    left: 365.997px;
    width: 1164.351px;
    max-width: none;
    margin: 0;
    gap: 30px;
    z-index: 39;
  }

  .news-card {
    border-radius: 40px;
    padding: 36px 40px 40px;
    gap: 10px;
  }

  .news-card__num {
    font-size: 48px;
    font-weight: 400;
  }

  .news-card__text {
    font-size: 16px;
    line-height: 1.5;
  }

  .news-card__photo img {
    border-radius: 28px;
  }
}

@media (max-width: 900px) {
  .news-feed {
    max-width: min(560px, calc(100vw - 16px));
  }

  .news-card {
    border-radius: clamp(22px, 7vw, 30px);
    padding: 0.5rem 0.45rem 0.85rem;
  }

  .news-card__num {
    font-size: clamp(0.95rem, 4.2vw, 1.65rem);
  }

  .news-card__text {
    font-size: clamp(0.62rem, 2.7vw, 0.8rem);
  }

  .news-card__photo img {
    border-radius: clamp(16px, 5vw, 22px);
  }
}

/* ───────────────────────── Админка ───────────────────────── */

/* Неприметная кнопка входа — правый нижний угол страницы новостей */
.news-admin-fab {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 90000;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: rgba(93, 31, 26, 0.28);
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.45;
  transition: opacity 0.2s ease, background 0.2s ease, transform 0.2s ease;
}

.news-admin-fab:hover,
.news-admin-fab:focus-visible {
  opacity: 1;
  background: #5d1f1a;
  transform: scale(1.06);
}

body.news-admin-open .news-admin-fab {
  display: none;
}

.news-admin {
  position: fixed;
  inset: 0;
  z-index: 100500;
  display: none;
}

.news-admin.is-open {
  display: block;
}

body.news-admin-open {
  overflow: hidden;
}

.news-admin__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 6, 4, 0.6);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.news-admin__sheet {
  position: relative;
  width: min(680px, calc(100vw - 32px));
  max-height: min(92vh, 900px);
  margin: max(4vh, 16px) auto;
  background: #ffffff;
  border-radius: 28px;
  box-shadow: 0 28px 72px rgba(0, 0, 0, 0.28);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.news-admin__dialog {
  position: relative;
  padding: 40px;
}

/* Шапка модалки — единый стиль сайта (как карточка товара) */
.news-admin__badge {
  display: inline-flex;
  align-items: center;
  box-sizing: border-box;
  height: 36px;
  padding: 0 22px 0 20px;
  border-radius: 999px;
  background: #5d1f1a;
  color: #ffffff;
  font-family: var(--heading-font-family, Involve, system-ui, sans-serif);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1.2;
  margin-bottom: 20px;
}

.news-admin__close {
  position: absolute;
  top: 40px;
  right: 40px;
  z-index: 2;
  width: 48px;
  height: 36px;
  border: none;
  padding: 0;
  background: transparent;
  color: #000000;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.news-admin__close:hover {
  opacity: 0.6;
  transform: scale(1.05);
}

.news-admin__title {
  margin: 0 0 16px;
  font-family: var(--heading-font-family, Involve, system-ui, sans-serif);
  font-size: clamp(22px, 4.2vw, 28px);
  font-weight: 600;
  line-height: 1.2;
  color: #000000;
  letter-spacing: 0.02em;
}

.news-admin__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.news-admin__form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 360px;
}

.news-admin__input,
.news-admin__textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 12px 14px;
  border: 1px solid rgba(93, 31, 26, 0.35);
  border-radius: 12px;
  font: 15px/1.45 Manrope, Inter, system-ui, sans-serif;
  color: #1a1a1a;
}

.news-admin__textarea {
  min-height: 96px;
  resize: vertical;
}

.news-admin__input:focus-visible,
.news-admin__textarea:focus-visible {
  outline: 2px solid #6f160c;
  outline-offset: 1px;
}

.news-admin__btn {
  align-self: flex-start;
  border: none;
  cursor: pointer;
  padding: 11px 24px;
  border-radius: 999px;
  background: #5d1f1a;
  color: #ffffff;
  font: 600 14px/1.2 Manrope, Inter, system-ui, sans-serif;
  letter-spacing: 0.04em;
  transition: background 0.15s ease;
}

.news-admin__btn:hover {
  background: #7f2017;
}

.news-admin__btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.news-admin__btn--ghost {
  background: transparent;
  color: #5d1f1a;
  border: 1px solid rgba(93, 31, 26, 0.45);
}

.news-admin__btn--ghost:hover {
  background: rgba(93, 31, 26, 0.08);
}

.news-admin__btn--wide {
  width: 100%;
  margin: 4px 0 16px;
}

.news-admin__item {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  margin-bottom: 14px;
  border: 1px solid rgba(93, 31, 26, 0.18);
  border-radius: 16px;
  background: #faf7f6;
}

.news-admin__item-num {
  font: 700 14px/1.2 Manrope, Inter, system-ui, sans-serif;
  color: #5d1f1a;
}

.news-admin__photo-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.news-admin__preview {
  width: 132px;
  aspect-ratio: 519 / 336;
  object-fit: cover;
  border-radius: 10px;
  background: #e8e0de;
}

.news-admin__preview.is-empty {
  visibility: hidden;
  width: 0;
}

.news-admin__file {
  font: 13px/1.3 Manrope, Inter, system-ui, sans-serif;
}

.news-admin__actions {
  display: flex;
  gap: 10px;
}

.news-admin__error {
  margin: 0;
  min-height: 1em;
  font: 13px/1.3 Manrope, Inter, system-ui, sans-serif;
  color: #a52315;
}

.news-admin__note {
  font: 15px/1.5 Manrope, Inter, system-ui, sans-serif;
  color: #333333;
}

@media (max-width: 600px) {
  .news-admin__dialog {
    padding: 24px 20px 28px;
  }

  .news-admin__close {
    top: 24px;
    right: 20px;
  }
}
