.theme-video-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-index-modal);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 48px;
  box-sizing: border-box;
}

.theme-video-modal.is-open {
  display: flex;
}

.theme-video-modal__backdrop {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.theme-video-modal__frame {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  max-width: 100%;
  max-height: 100%;
}

.theme-video-modal__dialog {
  position: relative;
  width: min(1310px, calc(100vw - 96px - 152px), calc((100vh - 96px) * 16 / 9));
  max-width: 100%;
  max-height: calc(100vh - 96px);
  aspect-ratio: 16 / 9;
}

.theme-video-modal:not(.theme-video-modal--has-nav) .theme-video-modal__dialog {
  width: min(1310px, calc(100vw - 96px), calc((100vh - 96px) * 16 / 9));
}

.theme-video-modal__stage {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: inherit;
  overflow: hidden;
  background: #000;
  border-radius: 12px;
  box-shadow: 0 0 20px 0 rgba(14, 20, 31, 0.12);
}

.theme-video-modal__slide {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  background: #000;
}

.theme-video-modal__slide[hidden] {
  display: none !important;
}

.theme-video-modal__player,
theme-video-media.theme-video-modal__player {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  background: #000;
}

.theme-video-modal__player {
  display: block;
}

.theme-video-modal__player .theme-video-media {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: auto;
  background: #000;
}

.theme-video-modal__player .theme-video-media__poster,
.theme-video-modal__player .theme-video-media__media {
  width: 100%;
  height: 100%;
  background-color: #000;
}

.theme-video-modal__player .theme-video-media__poster img,
.theme-video-modal__player .theme-video-media__poster svg {
  border-radius: 0;
}

.theme-video-modal__player video,
.theme-video-modal__player iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  vertical-align: top;
}

.theme-video-modal__player--desktop,
theme-video-media.theme-video-modal__player.theme-video-modal__player--desktop {
  display: block;
}

.theme-video-modal__player--mobile,
theme-video-media.theme-video-modal__player.theme-video-modal__player--mobile {
  display: none;
}

@media (max-width: 991px) {
  .theme-video-modal__player--desktop,
  theme-video-media.theme-video-modal__player.theme-video-modal__player--desktop {
    display: none;
  }

  .theme-video-modal__player--mobile,
  theme-video-media.theme-video-modal__player.theme-video-modal__player--mobile {
    display: block;
  }

  .theme-video-modal__player .theme-video-media__play-button {
    inset-block-start: 50%;
    inset-block-end: auto;
    inset-inline-start: 50%;
    inset-inline-end: auto;
    transform: translate(-50%, -50%);
  }
}

.theme-video-modal__close {
  position: absolute;
  top: 24px;
  right: 24px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  color: #0e141f;
  cursor: pointer;
  background: #fff;
  border: 0;
  border-radius: 50%;
  transition: background-color 0.2s ease;
}

.theme-video-modal__close:hover {
  background: rgba(238, 244, 255, 1);
}

.theme-video-modal__close .icon {
  width: 20px;
  height: 20px;
}

.theme-video-modal__nav {
  position: relative;
  z-index: 2;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  padding: 0;
  color: #0e141f;
  cursor: pointer;
  background: #fff;
  border: 0;
  border-radius: 50%;
  transition: background-color 0.2s ease;
}

.theme-video-modal__nav:hover {
  background: rgba(238, 244, 255, 1);
}

.theme-video-modal__nav[hidden] {
  display: none !important;
}

.theme-video-modal__nav--prev .icon {
  transform: scaleX(-1);
}

.theme-video-modal__nav .icon {
  width: 20px;
  height: 20px;
}

body.theme-video-modal-open {
  overflow: hidden;
}

@media (max-width: 767px) {
  .theme-video-modal {
    padding: 0;
  }

  .theme-video-modal__backdrop {
    background-color: #000;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .theme-video-modal__frame {
    width: 100%;
    height: 100%;
    gap: 0;
  }

  .theme-video-modal__dialog,
  .theme-video-modal:not(.theme-video-modal--has-nav) .theme-video-modal__dialog {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: auto;
  }

  .theme-video-modal__stage {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    box-shadow: none;
  }

  .theme-video-modal__slide:not([hidden]) {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
  }

  .theme-video-modal__player {
    display: grid;
    place-items: center;
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 100%;
  }

  theme-video-media.theme-video-modal__player.theme-video-modal__player--desktop {
    display: none;
  }

  theme-video-media.theme-video-modal__player.theme-video-modal__player--mobile {
    display: grid;
  }

  .theme-video-modal__player .theme-video-media {
    width: 100%;
    height: auto;
    max-width: 100%;
    max-height: 100%;
    aspect-ratio: 16 / 9;
  }

  .theme-video-modal__close {
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
  }

  .theme-video-modal__close .icon {
    width: 14px;
    height: 14px;
  }

  /* Mobile uses swipe instead of arrow buttons */
  .theme-video-modal__nav {
    display: none !important;
  }
}
