/* Certificate-style background scene (video + poster) — iOS StudioBackdrop */
.wgb-scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(ellipse 42% 36% at 88% 6%, rgba(194, 232, 56, 0.13) 0%, transparent 68%),
    #0B0E11;
  pointer-events: none;
  transform: translateZ(0);
}

/* Soft lime ellipse blur (StudioBackdrop) */
.wgb-scene::after {
  content: '';
  position: absolute;
  top: -140px;
  right: -20px;
  width: 300px;
  height: 240px;
  border-radius: 50%;
  background: rgba(194, 232, 56, 0.13);
  filter: blur(85px);
  z-index: 3;
  pointer-events: none;
  transform: translate3d(50px, 0, 0);
  animation: wgb-scene-lime-float 7s ease-in-out infinite alternate;
}

@keyframes wgb-scene-lime-float {
  from { transform: translate3d(50px, 0, 0); }
  to { transform: translate3d(95px, 0, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .wgb-scene::after {
    animation: none;
  }
}

.wgb-scene__photo {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 1;
  background:
    radial-gradient(ellipse 42% 36% at 88% 6%, rgba(194, 232, 56, 0.13) 0%, transparent 68%),
    #0B0E11;
}

.wgb-scene__photo picture {
  position: absolute;
  inset: 0;
  display: block;
}

.wgb-scene__photo-img {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 38%;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  background: transparent;
  transition: opacity 0.45s ease;
}

html.wgb-bg-ready:not(.wgb-has-video) .wgb-scene__photo-img {
  opacity: 0.3;
  visibility: visible;
}

.wgb-scene__video {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 38%;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  background: transparent;
  transition: none;
}

/*
 * Exclusive layers: never composite poster + video with dual opacity.
 * Video ready → only video; otherwise → only poster photo.
 */
html.wgb-has-video .wgb-scene__photo,
html.wgb-has-video .wgb-scene__photo-img {
  opacity: 0 !important;
  visibility: hidden !important;
  transition: none !important;
}

html.wgb-has-video .wgb-scene__video {
  opacity: 0.3;
  visibility: visible;
}

html:not(.wgb-has-video) .wgb-scene__video {
  opacity: 0 !important;
  visibility: hidden !important;
}

.wgb-scene__top-blur {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: min(34svh, 240px);
  z-index: 2;
  pointer-events: none;
  /* Gradient only — backdrop-filter on video freezes mobile inputs */
  background: linear-gradient(
    180deg,
    rgba(11, 14, 17, 0.72) 0%,
    rgba(11, 14, 17, 0.28) 55%,
    transparent 100%
  );
}

.wgb-scene__vignette {
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(180deg, rgba(11, 14, 17, 0.1) 0%, rgba(11, 14, 17, 0.8) 55%, #0B0E11 100%);
  pointer-events: none;
}

html.wgb-scene .wgb {
  max-width: 430px;
  margin-left: auto;
  margin-right: auto;
  pointer-events: auto;
}

html.wgb-scene:not([data-wgb-theme='light']):not(.wgb-bg-ready) {
  --wgb-card: #12151b;
  --wgb-tabbar-bg: #12151b;
  --wgb-muted: rgba(246, 246, 243, 0.84);
}

html.wgb-scene:not([data-wgb-theme='light']) .wgb {
  /* Непрозрачный запас: фото сцены может ещё качаться. */
  background:
    radial-gradient(ellipse 42% 36% at 88% 6%, rgba(194, 232, 56, 0.13) 0%, transparent 68%),
    #0B0E11;
}

html.wgb-bg-ready.wgb-scene:not([data-wgb-theme='light']):not(.wgb-desktop) .wgb {
  background: transparent;
}

html.wgb-scene:not([data-wgb-theme='light']),
html.wgb-scene:not([data-wgb-theme='light']) body {
  background: #0B0E11;
  color: #f6f6f3;
}

/* ── 2ГИС / in-app WebView: static poster only, no video / fixed layers ── */
html.wgb-2gis .wgb-scene,
html.wgb-2gis .wgb-scene__video,
html.wgb-2gis .wgb-scene__top-blur,
html.wgb-2gis .wgb-scene__vignette,
html.wgb-2gis .wgb-scene__photo {
  display: none !important;
}

/*
 * Phone shell (mobile UA, embed, 2ГИС, narrow / DevTools device mode via wgb-mobile):
 * оболочка = visualViewport (--wgb-app-h). Документ не скроллится.
 * Один вертикальный скролл — #wgb-main-inner.
 * Не используем -webkit-fill-available как высоту оболочки: в desktop DevTools
 * оно может быть больше видимого frame и обрезать нижний таббар (overflow:hidden).
 */
html.wgb-mobile:not(.wgb-desktop),
html.wgb-embedded:not(.wgb-desktop),
html.wgb-2gis:not(.wgb-desktop),
html.wgb-mobile:not(.wgb-desktop) body,
html.wgb-embedded:not(.wgb-desktop) body,
html.wgb-2gis:not(.wgb-desktop) body {
  position: relative;
  width: 100%;
  height: var(--wgb-app-h, 100dvh);
  max-height: var(--wgb-app-h, 100dvh);
  min-height: 0;
  overflow: hidden;
}

html.wgb-2gis,
html.wgb-2gis body {
  background: #0B0E11 !important;
  background-image: none !important;
}

html.wgb-mobile:not(.wgb-desktop) .wgb,
html.wgb-embedded:not(.wgb-desktop) .wgb,
html.wgb-2gis:not(.wgb-desktop) .wgb {
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: hidden;
  /* Keep tabbar as flex footer inside the locked shell */
  display: flex;
  flex-direction: column;
}

html.wgb-2gis .wgb {
  background: #0B0E11 !important;
  max-width: 430px;
  margin-left: auto;
  margin-right: auto;
}

html.wgb-2gis.wgb-bg-ready .wgb {
  background: transparent !important;
}

html.wgb-mobile:not(.wgb-desktop) .wgb-main-shell,
html.wgb-embedded:not(.wgb-desktop) .wgb-main-shell,
html.wgb-2gis:not(.wgb-desktop) .wgb-main-shell {
  flex: 1 1 0%;
  min-height: 0;
  overflow: hidden;
}

html.wgb-mobile:not(.wgb-desktop) #wgb-main-inner,
html.wgb-embedded:not(.wgb-desktop) #wgb-main-inner,
html.wgb-2gis:not(.wgb-desktop) #wgb-main-inner {
  flex: 1 1 0%;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
}

/* Pin tab tray to the bottom of the app shell (not scrolled with #wgb-main-inner). */
html.wgb-mobile:not(.wgb-desktop) .wgb-tabbar,
html.wgb-embedded:not(.wgb-desktop) .wgb-tabbar,
html.wgb-telegram:not(.wgb-desktop) .wgb-tabbar,
html.wgb-2gis:not(.wgb-desktop) .wgb-tabbar {
  flex: 0 0 auto;
  flex-shrink: 0;
  margin-top: auto;
  position: relative;
  z-index: 60;
}

#wgb-static-bg {
  display: none;
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  object-fit: cover;
  object-position: center 38%;
  opacity: 0;
  z-index: 0;
  pointer-events: none;
  background: #0B0E11;
  transition: opacity 0.8s ease;
}

html.wgb-2gis.wgb-bg-ready #wgb-static-bg {
  opacity: 0.3;
}

html.wgb-2gis #wgb-static-bg {
  display: block !important;
}

html.wgb-2gis #wgb-static-bg-shade {
  display: block !important;
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 0;
  pointer-events: none;
  /* Lime ellipse without backdrop-filter — readable in 2GIS static mode */
  background:
    radial-gradient(ellipse 300px 240px at 88% 4%, rgba(194, 232, 56, 0.13), transparent 70%),
    linear-gradient(
      180deg,
      rgba(11, 14, 17, 0.1) 0%,
      rgba(11, 14, 17, 0.8) 55%,
      #0B0E11 100%
    );
}

#wgb-static-bg-shade {
  display: none;
}

html.wgb-2gis .wgb > :not(.wgb-scene) {
  position: relative;
  z-index: 1;
}


/* Светлая тема: сцена и постер остаются, читаемость через светлые оверлеи. */
html[data-wgb-theme='light'] .wgb-scene {
  background:
    radial-gradient(ellipse 42% 36% at 88% 6%, rgba(194, 232, 56, 0.12) 0%, transparent 68%),
    #eef2f8;
}

html[data-wgb-theme='light'] .wgb-scene__photo {
  background:
    radial-gradient(ellipse 42% 36% at 88% 6%, rgba(194, 232, 56, 0.12) 0%, transparent 68%),
    #eef2f8;
}

html[data-wgb-theme='light'] .wgb-scene__top-blur {
  background: linear-gradient(
    180deg,
    rgba(244, 247, 252, 0.88) 0%,
    rgba(244, 247, 252, 0.42) 55%,
    transparent 100%
  );
}

html[data-wgb-theme='light'] .wgb-scene__vignette {
  background: linear-gradient(
    180deg,
    rgba(244, 247, 252, 0.28) 0%,
    rgba(244, 247, 252, 0.72) 55%,
    #f4f7fc 100%
  );
}

html[data-wgb-theme='light'].wgb-bg-ready:not(.wgb-has-video) .wgb-scene__photo-img {
  opacity: 0.22;
  visibility: visible;
}

html[data-wgb-theme='light'].wgb-has-video .wgb-scene__video {
  opacity: 0.2;
  visibility: visible;
}

html.wgb-scene[data-wgb-theme='light'] .wgb {
  background: var(--wgb-page-glow);
}

html.wgb-bg-ready.wgb-scene[data-wgb-theme='light']:not(.wgb-desktop) .wgb {
  background: transparent;
}

html.wgb-scene[data-wgb-theme='light'],
html.wgb-scene[data-wgb-theme='light'] body {
  background: #f4f7fc;
  color: #0b1324;
}

/* 2ГИС-статика на светлой не нужна (2ГИС всегда dark). */
html[data-wgb-theme='light'] #wgb-static-bg,
html[data-wgb-theme='light'] #wgb-static-bg-shade {
  display: none !important;
}

:root[data-wgb-theme='light'].wgb-2gis,
:root[data-wgb-theme='light'].wgb-2gis body,
:root[data-wgb-theme='light'].wgb-2gis .wgb {
  background: var(--wgb-page-glow) !important;
}

/* Keep forms responsive: no backdrop blur over the video scene */
html.wgb-scene .wgb-loading,
html.wgb-scene .wgb-auth__card,
html.wgb-scene .wgb-tabbar,
html.wgb-scene .wgb-svc-card,
html.wgb-scene .wgb-svc,
html.wgb-scene .wgb-bcard {
  -webkit-backdrop-filter: none !important;
  backdrop-filter: none !important;
}

html.wgb-scene:not([data-wgb-theme='light']) .wgb-auth__card,
html.wgb-scene:not([data-wgb-theme='light']) .wgb-svc-card,
html.wgb-scene:not([data-wgb-theme='light']) .wgb-svc,
html.wgb-scene:not([data-wgb-theme='light']) .wgb-bcard {
  background: #12151b;
}

html.wgb-scene:not([data-wgb-theme='light']) .wgb-loading {
  background: #0B0E11;
  color: #c9cfc4;
}

html.wgb-bg-ready.wgb-scene:not([data-wgb-theme='light']) .wgb-loading {
  background: rgba(11, 14, 17, 0.72);
}

html.wgb-2gis .wgb-loading {
  background: rgba(11, 14, 17, 0.72) !important;
}

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