/* P8.1B — Calculator dead-zone optimization (soft SSR shell + skeleton)
   Loaded synchronously from nginx head — no calculator logic changes */

html.exs-calculator-stabilizing form.exchange__finally,
html.exs-calculator-stabilizing .exchange__finally {
  position: relative !important;
  display: block !important;
  min-height: clamp(320px, 46vh, 520px);
  max-width: var(--ex-form-max-width, 1040px);
  margin-inline: auto;
  overflow: hidden;
  isolation: isolate;
  box-shadow:
    inset 0 0 0 1px rgba(167, 139, 250, 0.28),
    0 12px 40px rgba(124, 92, 255, 0.14) !important;
}

/* Soft shell: show SSR layout instead of blank clip-hide dead zone */
html.exs-calculator-stabilizing form.exchange__finally > *,
html.exs-calculator-stabilizing .exchange__finally > * {
  visibility: visible !important;
  opacity: 0.36 !important;
  pointer-events: none !important;
  user-select: none !important;
  position: relative !important;
  left: auto !important;
  top: auto !important;
  width: auto !important;
  height: auto !important;
  overflow: visible !important;
  clip: auto !important;
  white-space: normal !important;
  border: inherit;
  margin: inherit;
  padding: inherit;
  filter: saturate(0.88);
  transition: opacity 0.16s ease, filter 0.16s ease;
}

/* CTA visible and tappable during stabilizer (P51 wires after DOMContentLoaded) */
html.exs-calculator-stabilizing .exs-p51-exchange-ssr-cta,
html.exs-calculator-stabilizing .exs-p51-exchange-ssr-cta *,
html.exs-calculator-stabilizing .exs-p51-primary-cta,
html.exs-calculator-stabilizing .exs-p51-primary-cta * {
  opacity: 1 !important;
  filter: none !important;
  pointer-events: auto !important;
  user-select: auto !important;
}

html.exs-calculator-stabilizing .exchange__from input,
html.exs-calculator-stabilizing .exchange__to input,
html.exs-calculator-stabilizing .exchange__finally submit-button,
html.exs-calculator-stabilizing .exchange__finally submit-button button,
html.exs-calculator-stabilizing .exchange__from button:not(.exs-p51-exchange-ssr-cta__btn),
html.exs-calculator-stabilizing .exchange__to button {
  pointer-events: none !important;
}

/* Trust + rate never dimmed */
html.exs-calculator-stabilizing #exs-p81a-exchange-trust,
html.exs-calculator-stabilizing .exs-p81a-exchange-trust,
html.exs-calculator-stabilizing .exchange__rates,
html.exs-calculator-stabilizing .exchange__rates * {
  opacity: 1 !important;
  filter: none !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

@keyframes exs-calc-skeleton-shimmer {
  0% { background-position: 220% 0, 0 0, 0 0, 0 0, 0 0, 0 0, 0 0; }
  100% { background-position: -220% 0, 0 0, 0 0, 0 0, 0 0, 0 0, 0 0; }
}

html.exs-calculator-stabilizing form.exchange__finally::before,
html.exs-calculator-stabilizing .exchange__finally::before {
  content: '';
  position: absolute;
  z-index: 2;
  pointer-events: none;
  inset: 14px;
  border-radius: 12px;
  background-color: rgba(124, 92, 255, 0.06);
  background-image:
    linear-gradient(90deg, transparent 0%, rgba(124, 92, 255, 0.1) 40%, rgba(196, 181, 253, 0.28) 50%, rgba(124, 92, 255, 0.1) 60%, transparent 100%),
    linear-gradient(rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.12)),
    linear-gradient(rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.08)),
    linear-gradient(rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.08)),
    linear-gradient(rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.07)),
    linear-gradient(rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.08)),
    linear-gradient(rgba(124, 92, 255, 0.22), rgba(167, 139, 250, 0.28));
  background-size: 220% 100%, 38% 12px, 100% 46px, 100% 46px, 72% 12px, 46% 18px, 100% 50px;
  background-repeat: no-repeat;
  background-position: 220% 0, 0 14px, 0 38px, 0 96px, 0 158px, 0 188px, 0 222px;
  animation: exs-calc-skeleton-shimmer 1.2s ease-in-out infinite;
  box-shadow: inset 0 0 0 1px rgba(167, 139, 250, 0.18);
}

html.exs-calculator-stabilizing form.exchange__finally::after,
html.exs-calculator-stabilizing .exchange__finally::after {
  content: 'Подготовка калькулятора…';
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  font: 600 11px/1.2 system-ui, sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(196, 181, 253, 0.78);
  pointer-events: none;
}

html.exs-calculator-stable form.exchange__finally,
html.exs-calculator-stable .exchange__finally {
  min-height: 0;
  overflow: visible;
  box-shadow: none !important;
}

html.exs-calculator-stable form.exchange__finally > *,
html.exs-calculator-stable .exchange__finally > * {
  opacity: 1 !important;
  filter: none !important;
  pointer-events: auto !important;
  user-select: auto !important;
}

html.exs-calculator-stable form.exchange__finally::before,
html.exs-calculator-stable .exchange__finally::before,
html.exs-calculator-stable form.exchange__finally::after,
html.exs-calculator-stable .exchange__finally::after {
  display: none !important;
  content: none !important;
}

@media (max-width: 1023px) {
  html.exs-calculator-stabilizing form.exchange__finally,
  html.exs-calculator-stabilizing .exchange__finally {
    min-height: clamp(340px, 52vh, 560px);
  }
}

@media (prefers-reduced-motion: reduce) {
  html.exs-calculator-stabilizing form.exchange__finally::before,
  html.exs-calculator-stabilizing .exchange__finally::before {
    animation: none;
  }
}

html[lang="en"].exs-calculator-stabilizing form.exchange__finally::after,
html[lang="en"].exs-calculator-stabilizing .exchange__finally::after {
  content: 'Preparing calculator…';
}
