:root {
  --immersive-viewport-height: 100vh;
}

body.immersive-open {
  overflow: hidden;
  overscroll-behavior: contain;
}

.immersive-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: stretch;
  background: #fff;
  height: var(--immersive-viewport-height, 100vh);
  min-height: 100vh;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

@supports (height: 100dvh) {
  .immersive-overlay {
    height: 100dvh;
    min-height: 100dvh;
  }
}

.immersive-overlay[data-state="loading"],
.immersive-overlay[data-state="ready"] {
  opacity: 1;
  pointer-events: auto;
}

.immersive-close {
  display: none;
}

.immersive-frame {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  min-height: inherit;
  border: 0;
  background: #fff;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.immersive-overlay[data-state="ready"] .immersive-frame {
  opacity: 1;
}

.immersive-status {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s ease;
}

.immersive-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid #e9e5f9;
  border-top-color: #8b5cf6;
  border-radius: 50%;
  animation: immersiveSpin 0.6s linear infinite;
}

.immersive-overlay[data-state="ready"] .immersive-status {
  opacity: 0;
  pointer-events: none;
}

@keyframes immersiveSpin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .immersive-overlay,
  .immersive-status,
  .immersive-frame {
    transition: none;
  }
  .immersive-spinner {
    animation: none;
    border-color: #8b5cf6;
  }
}
