.qid-atoms-image {
    position: relative;
    width: 100%;
}

.qid-atoms-image__stage {
    position: relative;
    width: 100%;
    min-height: 2px;
    overflow: hidden;
}

.qid-atoms-image__image {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    height: auto;
    opacity: 1;
}

.qid-atoms-image__canvas {
    position: absolute;
    inset: 0;
    z-index: 2;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.qid-atoms-image[data-start-with="picture"] .qid-atoms-image__image {
    opacity: 1;
}

.qid-atoms-image.qid-reduced-motion .qid-atoms-image__image,
.qid-atoms-image.qid-fallback .qid-atoms-image__image {
    opacity: 1 !important;
}

.qid-atoms-image.qid-reduced-motion .qid-atoms-image__canvas,
.qid-atoms-image.qid-fallback .qid-atoms-image__canvas {
    display: none;
}

.qid-atoms-image.qid-active[data-start-with="atoms"] .qid-atoms-image__image {
    opacity: 0;
}

/* Show nothing until the animation is ready. The picture used to be visible from the first
   paint and was hidden only once the script had started, so a cached image could flash on
   screen first. The space stays reserved (opacity, not display), so nothing jumps.
   Safety nets: no JavaScript -> the <noscript> rule in the page head shows the picture; reduced
   motion or a failure -> .qid-reduced-motion / .qid-fallback show it (rule above); and if the
   script never starts at all, the picture appears after 8 seconds. */
.qid-atoms-image:not(.qid-active):not(.qid-fallback):not(.qid-reduced-motion) .qid-atoms-image__image {
    opacity: 0;
    animation: qid-reveal-failsafe 0.01s 8s forwards;
}

@keyframes qid-reveal-failsafe {
    to { opacity: 1; }
}

/* Promote the picture to its own layer while animating, so opacity and scale
   changes are composited instead of repainted every frame. */
.qid-atoms-image.qid-active .qid-atoms-image__image {
    will-change: opacity, transform;
}
