/* Forki PWA — фронтенд */

.fpwa-banner,
.fpwa-guide,
.fpwa-loader {
  --fpwa-radius: 18px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  box-sizing: border-box;
}
.fpwa-banner *,
.fpwa-guide * { box-sizing: border-box; }

/* ---------- Баннер установки ---------- */

.fpwa-banner {
  position: fixed;
  z-index: 2147483000;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(560px, calc(100% - 24px));
  padding: 14px 14px 14px 16px;
  background: var(--fpwa-banner-bg, #fff);
  color: var(--fpwa-banner-color, #1f2430);
  border-radius: var(--fpwa-radius);
  box-shadow: 0 18px 50px -12px rgba(15, 20, 40, .35), 0 0 0 1px rgba(15, 20, 40, .06);
  opacity: 0;
  transition: transform .35s cubic-bezier(.2, .9, .3, 1.1), opacity .25s ease;
  line-height: 1.35;
}
.fpwa-banner--bottom { bottom: calc(12px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 140%); }
.fpwa-banner--top { top: calc(12px + env(safe-area-inset-top, 0px)); transform: translate(-50%, -140%); }
.fpwa-banner.is-visible { opacity: 1; transform: translate(-50%, 0); }

.fpwa-banner--full {
  left: 0;
  width: 100%;
  border-radius: 0;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(14px, env(safe-area-inset-right, 0px));
}
.fpwa-banner--full.fpwa-banner--bottom { bottom: 0; transform: translateY(100%); padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
.fpwa-banner--full.fpwa-banner--top { top: 0; transform: translateY(-100%); padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
.fpwa-banner--full.is-visible { transform: translateY(0); }

.fpwa-banner__icon {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  object-fit: cover;
}
.fpwa-banner__body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.fpwa-banner__title,
.fpwa-banner__text {
  display: block;
  margin: 0;
  color: inherit;
  text-align: left;
  overflow-wrap: anywhere;
}
.fpwa-banner__title { font-size: 15px; font-weight: 650; line-height: 1.3; }
.fpwa-banner__text {
  font-size: 13px;
  line-height: 1.4;
  opacity: .72;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}
.fpwa-banner__install {
  flex: none;
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 10px 18px;
  background: var(--fpwa-btn-bg, #3a4fe0);
  color: var(--fpwa-btn-color, #fff);
  font: 600 14px/1 inherit;
  font-family: inherit;
  cursor: pointer;
  transition: filter .15s ease, transform .15s ease;
}
.fpwa-banner__install:hover { filter: brightness(1.08); }
.fpwa-banner__install:active { transform: scale(.97); }
.fpwa-banner__close {
  flex: none;
  appearance: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin-left: -4px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  opacity: .55;
  cursor: pointer;
}
.fpwa-banner__close:hover { opacity: 1; background: rgba(127, 127, 127, .14); }
.fpwa-banner button:focus-visible,
.fpwa-guide button:focus-visible { outline: 3px solid var(--fpwa-accent, #3a4fe0); outline-offset: 2px; }

/* Телефоны: текст остаётся видимым, кнопка переносится под него на очень узких экранах */
@media (max-width: 480px) {
  .fpwa-banner { gap: 10px; padding: 12px; align-items: flex-start; }
  .fpwa-banner__icon { width: 40px; height: 40px; border-radius: 10px; }
  .fpwa-banner__title { font-size: 14px; }
  .fpwa-banner__text { font-size: 12.5px; }
  .fpwa-banner__install { align-self: center; padding: 9px 14px; font-size: 13px; }
  .fpwa-banner__close { align-self: flex-start; margin-top: -4px; }
}
@media (max-width: 360px) {
  .fpwa-banner { flex-wrap: wrap; }
  .fpwa-banner__body { flex: 1 1 calc(100% - 90px); }
  .fpwa-banner__install { order: 3; flex: 1 1 100%; margin-left: 50px; }
}

/* ---------- Инструкция по установке (iOS / macOS / прочие) ---------- */

.fpwa-guide {
  position: fixed;
  inset: 0;
  z-index: 2147483001;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  background: rgba(10, 14, 28, 0);
  transition: background .3s ease;
}
.fpwa-guide.is-visible { background: rgba(10, 14, 28, .45); }
@media (min-width: 700px) { .fpwa-guide { align-items: center; } }

.fpwa-guide__sheet {
  width: min(420px, 100%);
  padding: 22px;
  border-radius: 22px;
  background: var(--fpwa-banner-bg, #fff);
  color: var(--fpwa-banner-color, #1f2430);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .45);
  transform: translateY(24px);
  opacity: 0;
  transition: transform .35s cubic-bezier(.2, .9, .3, 1.1), opacity .25s ease;
}
.fpwa-guide.is-visible .fpwa-guide__sheet { transform: none; opacity: 1; }

.fpwa-guide__head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.fpwa-guide__icon { width: 52px; height: 52px; border-radius: 13px; object-fit: cover; }
.fpwa-guide__heading { display: flex; flex-direction: column; gap: 2px; }
.fpwa-guide__heading strong { font-size: 17px; }
.fpwa-guide__heading span { font-size: 13px; opacity: .65; }

.fpwa-guide__steps { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 10px; counter-reset: fpwa; }
.fpwa-guide__steps li {
  counter-increment: fpwa;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(127, 127, 127, .09);
  font-size: 14px;
  line-height: 1.35;
}
.fpwa-guide__step-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--fpwa-btn-bg, #3a4fe0);
  color: var(--fpwa-btn-color, #fff);
}
.fpwa-guide__step-text::before { content: counter(fpwa) ". "; font-weight: 700; }

.fpwa-guide__ok {
  width: 100%;
  appearance: none;
  border: 0;
  border-radius: 14px;
  padding: 13px;
  background: var(--fpwa-btn-bg, #3a4fe0);
  color: var(--fpwa-btn-color, #fff);
  font: 600 15px/1 inherit;
  font-family: inherit;
  cursor: pointer;
}

/* Стрелка-подсказка к кнопке «Поделиться» на iPhone (панель снизу) */
@media (max-width: 699px) {
  .fpwa-guide--ios .fpwa-guide__sheet { position: relative; margin-bottom: 14px; }
  .fpwa-guide--ios .fpwa-guide__sheet::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: -9px;
    width: 18px;
    height: 18px;
    background: inherit;
    transform: translateX(-50%) rotate(45deg);
    border-radius: 3px;
  }
}

/* ---------- Индикатор загрузки ---------- */

.fpwa-loader {
  position: fixed;
  inset: 0;
  z-index: 2147482999;
  display: grid;
  place-items: center;
  background: var(--fpwa-loader-bg, rgba(255, 255, 255, .8));
  opacity: 0;
  visibility: hidden;
  transition: opacity .2s ease, visibility 0s linear .2s;
  pointer-events: none;
}
.fpwa-loader.is-active { opacity: 1; visibility: visible; transition-delay: .12s, 0s; pointer-events: auto; }

.fpwa-loader--bar { inset: 0 0 auto 0; height: 3px; background: transparent; place-items: stretch; }
.fpwa-loader__bar {
  display: block;
  height: 3px;
  width: 100%;
  background: var(--fpwa-loader-color, #3a4fe0);
  transform-origin: 0 50%;
  transform: scaleX(0);
}
.fpwa-loader--bar.is-active .fpwa-loader__bar { animation: fpwa-bar 8s cubic-bezier(.1, .8, .2, 1) forwards; }

.fpwa-loader__spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 4px solid color-mix(in srgb, var(--fpwa-loader-color, #3a4fe0) 22%, transparent);
  border-top-color: var(--fpwa-loader-color, #3a4fe0);
  animation: fpwa-spin .8s linear infinite;
}

.fpwa-loader__dots { display: flex; gap: 8px; }
.fpwa-loader__dots i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--fpwa-loader-color, #3a4fe0);
  animation: fpwa-dot 1s ease-in-out infinite;
}
.fpwa-loader__dots i:nth-child(2) { animation-delay: .15s; }
.fpwa-loader__dots i:nth-child(3) { animation-delay: .3s; }

@keyframes fpwa-spin { to { transform: rotate(360deg); } }
@keyframes fpwa-dot { 0%, 80%, 100% { transform: scale(.55); opacity: .5; } 40% { transform: scale(1); opacity: 1; } }
@keyframes fpwa-bar { to { transform: scaleX(.92); } }

/* ---------- Состояния ---------- */

.fpwa-standalone .forki-pwa-install { display: none; }

@media (prefers-reduced-motion: reduce) {
  .fpwa-banner,
  .fpwa-guide,
  .fpwa-guide__sheet,
  .fpwa-loader { transition: none; }
  .fpwa-loader__spinner,
  .fpwa-loader__dots i { animation-duration: 2.4s; }
}
