/*
 * «Освежение» сайта: виджеты в стиле Apple, стеклянная шапка, живые карточки.
 * Подключается после CSS темы и brand.css (src/app/layout.tsx).
 */

:root {
  --fx-card-radius: 24px;
  --fx-card-shadow: 0 1px 2px rgba(17, 26, 28, 0.04), 0 10px 30px -12px rgba(17, 26, 28, 0.12);
  --fx-card-shadow-hover: 0 2px 4px rgba(17, 26, 28, 0.04), 0 22px 44px -18px rgba(17, 26, 28, 0.22);
  --fx-muted: #8a9399;
}

/* ---------------------------------------------- Шапка «матовое стекло» */

.header._fixed {
  background-color: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  box-shadow: 0 1px 0 rgba(17, 26, 28, 0.06), 0 10px 30px -20px rgba(17, 26, 28, 0.25);
}

/* ------------------------------------------------ Бенто-виджеты */

.fx-bento {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 24px 0 30px;
}

@media (max-width: 767.98px) {
  .fx-bento {
    grid-template-columns: 1fr;
  }
}

.fx-widget {
  position: relative;
  overflow: hidden;
  border-radius: var(--fx-card-radius);
  padding: 22px;
  background: linear-gradient(160deg, #ffffff 0%, var(--tr) 100%);
  border: 1px solid rgba(17, 26, 28, 0.06);
  box-shadow: var(--fx-card-shadow);
  transition: translate 0.5s var(--fx-spring), box-shadow 0.4s var(--fx-out);
}

@media (hover: hover) {
  .fx-widget:hover {
    translate: 0 -3px;
    box-shadow: var(--fx-card-shadow-hover);
  }
}

.fx-widget__label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fx-muted);
}

/* ------------------------------------ Калькулятор добра */

.fx-calc::after {
  /* мягкое красное «сияние» в углу виджета */
  content: "";
  position: absolute;
  right: -60px;
  top: -60px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--primary) 22%, transparent), transparent 70%);
  pointer-events: none;
}

.fx-calc__result {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 16px 0 18px;
}

.fx-calc__heart {
  width: 44px;
  height: 44px;
  flex: none;
  color: var(--primary);
  filter: drop-shadow(0 6px 10px color-mix(in srgb, var(--primary) 35%, transparent));
  animation: fx-heart-beat 1.6s var(--fx-out) infinite;
}

.fx-calc__num {
  font-size: 44px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
  color: var(--black);
  font-variant-numeric: tabular-nums;
  animation: fx-num-pop 0.35s var(--fx-spring);
}

.fx-calc__unit {
  margin-top: 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--fx-muted);
}

.fx-calc__sum {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 13px;
  color: var(--fx-muted);
  margin-bottom: 10px;
}

.fx-calc__sum b {
  font-size: 18px;
  color: var(--black);
  font-variant-numeric: tabular-nums;
}

/* Слайдер в стиле iOS */
.fx-calc__range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  margin: 6px 0 18px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gradient-start), var(--gradient-end)) 0 / var(--fill, 0%) 100% no-repeat,
    rgba(150, 172, 177, 0.25);
  cursor: pointer;
  outline: none;
}

.fx-calc__range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.04), 0 3px 8px rgba(0, 0, 0, 0.18), 0 0.5px 1px rgba(0, 0, 0, 0.1);
  transition: scale 0.3s var(--fx-spring);
}

.fx-calc__range::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.18), 0 0.5px 1px rgba(0, 0, 0, 0.1);
}

.fx-calc__range:active::-webkit-slider-thumb {
  scale: 1.15;
}

.fx-calc__range:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--primary) 30%, transparent), 0 3px 8px rgba(0, 0, 0, 0.18);
}

.fx-calc__btn {
  width: 100%;
}

@keyframes fx-heart-beat {
  0%,
  40%,
  100% {
    scale: 1;
  }
  10% {
    scale: 1.14;
  }
  20% {
    scale: 1;
  }
  30% {
    scale: 1.08;
  }
}

@keyframes fx-num-pop {
  from {
    opacity: 0.4;
    translate: 0 6px;
  }
  to {
    opacity: 1;
    translate: 0 0;
  }
}

/* ------------------------------ Живая лента: уведомления в стиле iOS */

.fx-feed__live {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #34c759;
}

.fx-feed__live::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: #34c759;
  animation: fx-live 1.8s var(--fx-out) infinite;
}

.fx-feed__stack {
  position: relative;
  height: 212px;
  margin-top: 16px;
}

.fx-feed__card {
  --gap: 70px;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.86);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(17, 26, 28, 0.05);
  box-shadow: 0 6px 18px -10px rgba(17, 26, 28, 0.25);
  translate: 0 calc(var(--pos) * var(--gap));
  scale: calc(1 - var(--pos) * 0.03);
  opacity: calc(1 - var(--pos) * 0.22);
  transition: translate 0.6s var(--fx-spring), scale 0.6s var(--fx-spring), opacity 0.4s var(--fx-out);
  animation: fx-notify-in 0.6s var(--fx-spring);
}

.fx-feed__avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 12px;
  color: #fff;
  background: var(--gradient);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.fx-feed__avatar svg {
  width: 20px;
  height: 20px;
}

.fx-feed__body {
  min-width: 0;
  flex: 1;
}

.fx-feed__name {
  font-size: 13px;
  font-weight: 600;
  color: var(--black);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fx-feed__meta {
  margin-top: 2px;
  font-size: 11px;
  color: var(--fx-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fx-feed__sum {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

@keyframes fx-notify-in {
  from {
    opacity: 0;
    translate: 0 -24px;
    scale: 0.92;
  }
}

@keyframes fx-live {
  0% {
    scale: 1;
    opacity: 0.6;
  }
  100% {
    scale: 2.8;
    opacity: 0;
  }
}

/* ------------------------------------------ Прогресс-бары */

.sproject__form-progress-bar,
.mechety__item-progress-bar {
  position: relative;
  overflow: hidden;
  animation: fx-progress-grow 1.4s var(--fx-out) 0.2s both;
}

.sproject__form-progress-bar::after,
.mechety__item-progress-bar::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.55), transparent);
  translate: -100% 0;
  animation: fx-progress-shine 3.2s var(--fx-out) 1.6s infinite;
}

@keyframes fx-progress-grow {
  from {
    width: 0;
  }
}

@keyframes fx-progress-shine {
  0% {
    translate: -100% 0;
  }
  45%,
  100% {
    translate: 100% 0;
  }
}

/* --------------------------------------- Живые карточки */

.sproject__info-item,
.rating__num,
.mechety__item,
.news__item,
.subscribe__item {
  transition: translate 0.5s var(--fx-spring), box-shadow 0.4s var(--fx-out);
}

@media (hover: hover) {
  .sproject__info-item:hover,
  .rating__num:hover {
    translate: 0 -3px;
    box-shadow: 0 16px 30px -18px color-mix(in srgb, var(--primary) 45%, transparent);
  }

  .mechety__item:hover,
  .news__item:hover,
  .subscribe__item:hover {
    translate: 0 -4px;
    box-shadow: var(--fx-card-shadow-hover);
  }

  .mechety__item-img img,
  .news__item-img img,
  .subscribe__item-thumb img {
    transition: scale 0.8s var(--fx-out);
  }

  .mechety__item:hover .mechety__item-img img,
  .news__item:hover .news__item-img img,
  .subscribe__item:hover .subscribe__item-thumb img {
    scale: 1.05;
  }
}

.sproject__info-item svg {
  transition: scale 0.5s var(--fx-spring);
}

@media (hover: hover) {
  .sproject__info-item:hover svg {
    scale: 1.15;
  }
}

/* ------------------ Вкладки «Топ спонсоров / Платежи»: сегментированный переключатель iOS */

.sproject__tabs.fx-segment {
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--n, 2), 1fr);
  gap: 0;
  width: 100%;
  padding: 4px;
  border-radius: 16px;
  background: #eef1f4;
  box-shadow: inset 0 1px 2px rgba(17, 26, 28, 0.06);
}

/* Белый бегунок под активной вкладкой */
.fx-segment__thumb {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc((100% - 8px) / var(--n, 2));
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(17, 26, 28, 0.08), 0 4px 12px -4px rgba(17, 26, 28, 0.18);
  translate: calc(var(--i, 0) * 100%) 0;
  transition: translate 0.55s var(--fx-spring);
  pointer-events: none;
}

.fx-segment .sproject__tabs-item,
.fx-segment .sproject__tabs-item.active {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 13px 16px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  box-shadow: none;
  color: var(--fx-muted);
  font-size: 13px;
  text-align: center;
  animation: none;
  translate: none;
  transition: color 0.3s var(--fx-out), scale 0.3s var(--fx-spring);
}

.fx-segment .sproject__tabs-item.active {
  color: var(--black);
}

@media (hover: hover) {
  .fx-segment .sproject__tabs-item:not(.active):hover {
    background: transparent;
    box-shadow: none;
    translate: none;
    color: var(--black);
  }
}

.fx-segment .sproject__tabs-item:active {
  scale: 0.97;
}

.fx-segment .sproject__tabs-item .fx-ripple {
  opacity: 0.08;
}

@media (max-width: 767.98px) {
  .fx-segment .sproject__tabs-item,
  .fx-segment .sproject__tabs-item.active {
    padding: 11px 10px;
    font-size: 12px;
  }
}

/* ---------------------------- «Кирпичики»: скрыты до запуска public/js/bricks.js */

html.fx-js .breadcrumbs .container,
html.fx-js .sproject__gallery-wrap,
html.fx-js .sproject__title,
html.fx-js .sproject__info-item,
html.fx-js .sproject__content > .bshare,
html.fx-js .fx-widget,
html.fx-js .sproject__form,
html.fx-js .sproject__section-heading,
html.fx-js .sproject__about-content,
html.fx-js .sproject__tabs,
html.fx-js .sproject__item,
html.fx-js .donation-item,
html.fx-js .sproject__projects-content-item-more,
html.fx-js .mechety__item,
html.fx-js .subscribe__heading,
html.fx-js .subscribe__form,
html.fx-js .subscribe__subtitle,
html.fx-js .subscribe__item,
html.fx-js .rating__heading,
html.fx-js .rating__num,
html.fx-js .supported__heading,
html.fx-js .supported__swiper,
html.fx-js .news__heading,
html.fx-js .news__item,
html.fx-js .spost__img,
html.fx-js .spost__right,
html.fx-js .simple-text .container,
html.fx-js .footer__left,
html.fx-js .footer__center,
html.fx-js .footer__bottom {
  opacity: 0;
}

/* ------------------------------------- Меньше движения — без анимаций */

@media (prefers-reduced-motion: reduce) {
  .fx-calc__heart,
  .fx-calc__num,
  .fx-feed__card,
  .fx-feed__live::after,
  .fx-segment__thumb,
  .sproject__form-progress-bar,
  .mechety__item-progress-bar,
  .sproject__form-progress-bar::after,
  .mechety__item-progress-bar::after {
    animation: none !important;
  }
}
