/*
 * “3D Earth” background of the homepage hero (earth.js). The Earth is a layer
 * (`.jits-earth-layer`) put just before the `jits-bg-drift` container (the hero),
 * placed over it by earth.js and running on below it, behind the top of the next
 * container. It sits under the hero (content and overlays: ::before gradient,
 * ::after `jits-fade-top`) and under the next container, even while a menu of the
 * hero is open (the hero then goes above the next container, not the Earth).
 */

:root {
    /* Black of space while the globe loads (no image, as the approved design asks). */
    --jits-earth-sky: #000;
}

/*
 * From the page load, the hero is black (space behind the globe) instead of its
 * drifting image (no image while the globe loads), without the drift animation.
 * Without WebGL (`is-earth-unavailable`, set by earth.js) the image comes back.
 * `jits-bg-drift` twice and !important: above the background of Elementor and the
 * drift rules of the theme (size, animation).
 */
.elementor .e-con.jits-bg-drift.jits-bg-drift:not(.is-earth-unavailable) {
    background: var(--jits-earth-sky) !important;
    animation: none;
}

/*
 * Earth layer in place (black until the globe fades in): the hero is transparent and
 * its bottom fade (Elementor background overlay) goes, as the black runs on under the
 * next container. The top fade from the header (`jits-fade-top`, ::after) stays.
 */
.elementor .e-con.jits-bg-drift.jits-bg-drift.jits-has-earth {
    background: none !important;

    &::before {
        opacity: 0;
        transition: opacity 1.2s ease;
    }
}

.jits-earth-layer {
    position: absolute;
    z-index: 0;
    overflow: hidden;
    background: var(--jits-earth-sky);
    pointer-events: none;
}

.jits-earth {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity 1.2s ease;
}

.jits-earth-layer.is-earth-ready .jits-earth {
    opacity: 1;
}

/*
 * Blue veil over the whole globe, under the content and the overlays of the hero.
 * Color: --jits-earth-veil, the dark blue of the site (--footer-bg) at 10% by default.
 */
.jits-earth__veil {
    position: absolute;
    inset: 0;
    background: var(--jits-earth-veil, color-mix(in srgb, var(--footer-bg, #0e1b56) 10%, transparent));
}

/*
 * Next container: from transparent over the Earth to its own background colour
 * (--jits-earth-blue, read by earth.js) at --jits-earth-fade (end of the Earth layer,
 * just below its first heading). Same colour throughout, only the alpha changes (no
 * band). --jits-earth-reveal goes from 0 (solid colour, as without the Earth) to 1
 * once the layer is in place.
 */
@property --jits-earth-reveal {
    syntax: "<number>";
    inherits: false;
    initial-value: 0;
}

.elementor .e-con.jits-has-earth + .e-con {
    --jits-earth-color: var(--jits-earth-blue, #0d1d57);

    background-color: transparent !important;
    /* Eased stops (alpha 0, .2, .5, .8, .95, 1): the Earth blends into the colour without an edge. */
    background-image: linear-gradient(
        color-mix(in srgb, var(--jits-earth-color) calc(100% - var(--jits-earth-reveal) * 100%), transparent) 0,
        color-mix(in srgb, var(--jits-earth-color) calc(100% - var(--jits-earth-reveal) * 80%), transparent) calc(var(--jits-earth-fade, 420px) * 0.3),
        color-mix(in srgb, var(--jits-earth-color) calc(100% - var(--jits-earth-reveal) * 50%), transparent) calc(var(--jits-earth-fade, 420px) * 0.55),
        color-mix(in srgb, var(--jits-earth-color) calc(100% - var(--jits-earth-reveal) * 20%), transparent) calc(var(--jits-earth-fade, 420px) * 0.75),
        color-mix(in srgb, var(--jits-earth-color) calc(100% - var(--jits-earth-reveal) * 5%), transparent) calc(var(--jits-earth-fade, 420px) * 0.9),
        var(--jits-earth-color) var(--jits-earth-fade, 420px)
    ) !important;
    transition: --jits-earth-reveal 1.2s ease;
}

/* From solid to the gradient once the layer is behind it (black, then the globe). */
.elementor .e-con.jits-has-earth.is-earth-layer + .e-con {
    --jits-earth-reveal: 1;
}

@media (prefers-reduced-motion: reduce) {
    .jits-earth,
    .elementor .e-con.jits-has-earth::before,
    .elementor .e-con.jits-has-earth + .e-con {
        transition: none;
    }
}

/* Credit line of the live clouds (EUMETSAT), bottom left of the hero (the cookie tab is on the right). */
.jits-earth__credit {
    position: absolute;
    left: 1rem;
    bottom: 0.75rem;
    z-index: 1;
    margin: 0;
    font-size: 0.6875rem;
    line-height: 1.2;
    color: rgb(255 255 255 / 0.6);
    opacity: 0;
    transition: opacity 1.2s ease;
}

.is-earth-ready > .jits-earth__credit {
    opacity: 1;
}
