/* ==========================================================================
   ESTC — first-visit intro
   A soft light sweep reveals the 40e logo, a hairline draws beneath it,
   then a white + navy double curtain lifts to uncover the page (~1.2s).
   Visibility is decided in base.html <head> (adds html.estc-intro-on).
   ========================================================================== */

html.estc-intro-on,
html.estc-intro-on body { overflow: hidden; }

.estc-intro {
    --ei-navy: #0b1f33;
    --ei-blue: #1b5aa0;
    --ei-red: #9b1c24;
    --ei-ease: cubic-bezier(.76, 0, .24, 1);
    --ei-ease-out: cubic-bezier(.16, 1, .3, 1);

    display: none;
    position: fixed;
    inset: 0;
    z-index: 100000;
}

html.estc-intro-on .estc-intro,
.estc-intro.is-leaving { display: block; }

/* Two stacked layers: navy behind, white in front — they lift one after the other */
.estc-intro__layer {
    position: absolute;
    inset: 0;
    will-change: transform;
}
.estc-intro__layer--back { background: var(--ei-navy); }
.estc-intro__layer--front {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0 16px;
    background: #fff;
}

.estc-intro__logo {
    position: relative;
    width: min(400px, 68vw);
    aspect-ratio: 1400 / 246;
}

.estc-intro__img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    opacity: 0;
    /* soft-edged sweep: the 300%-wide mask slides from its transparent third to its opaque third */
    -webkit-mask: linear-gradient(90deg, #000 33%, transparent 66%) 100% 0 / 300% 100% no-repeat;
    mask: linear-gradient(90deg, #000 33%, transparent 66%) 100% 0 / 300% 100% no-repeat;
}

/* Restrained glint, clipped to the logo's own shape */
.estc-intro__glint {
    position: absolute;
    inset: 0;
    background: linear-gradient(110deg, transparent 42%, rgba(255, 255, 255, .75) 50%, transparent 58%) 140% 0 / 250% 100% no-repeat;
    -webkit-mask: var(--ei-src) center / 100% 100% no-repeat;
    mask: var(--ei-src) center / 100% 100% no-repeat;
    pointer-events: none;
}

/* Hairline that draws out from the centre */
.estc-intro__rule {
    width: min(400px, 68vw);
    height: 1px;
    margin-top: clamp(1.4rem, 3.5vw, 2.2rem);
    background: linear-gradient(90deg, transparent, var(--ei-blue) 30%, var(--ei-red) 70%, transparent);
    transform: scaleX(0);
    opacity: .7;
}

/* ---------- Timeline ---------- */
.estc-intro.is-playing .estc-intro__img   { animation: eiReveal .6s cubic-bezier(.55, 0, .2, 1) .05s both; }
.estc-intro.is-playing .estc-intro__glint { animation: eiGlint .55s ease-in-out .3s both; }
.estc-intro.is-playing .estc-intro__rule  { animation: eiRule .5s var(--ei-ease-out) .2s both; }

@keyframes eiReveal {
    0%   { opacity: 1; -webkit-mask-position: 100% 0; mask-position: 100% 0; transform: scale(1.035); filter: blur(4px); }
    100% { opacity: 1; -webkit-mask-position: 0 0;    mask-position: 0 0;    transform: none;         filter: blur(0); }
}
@keyframes eiGlint {
    from { background-position: 140% 0; }
    to   { background-position: -40% 0; }
}
@keyframes eiRule {
    to { transform: scaleX(1); }
}

/* ---------- Exit: content drifts up, white then navy curtain lift ---------- */
.estc-intro.is-leaving { pointer-events: none; }
.estc-intro.is-leaving .estc-intro__logo {
    transition: opacity .25s ease, transform .4s var(--ei-ease);
    opacity: 0;
    transform: translateY(-24px);
}
.estc-intro.is-leaving .estc-intro__rule {
    transition: opacity .35s ease;
    opacity: 0;
}
.estc-intro.is-leaving .estc-intro__layer--front { animation: eiLift .45s var(--ei-ease) .05s both; }
.estc-intro.is-leaving .estc-intro__layer--back  { animation: eiLift .45s var(--ei-ease) .13s both; }

@keyframes eiLift {
    to { transform: translateY(-100%); }
}

/* ---------- Reduced motion: logo shown as-is, plain fade out ---------- */
@media (prefers-reduced-motion: reduce) {
    .estc-intro *,
    .estc-intro.is-leaving * { animation: none !important; transition: none !important; }
    .estc-intro__img { opacity: 1; -webkit-mask: none; mask: none; }
    .estc-intro__rule { transform: none; }
    .estc-intro__layer--back { display: none; }
    .estc-intro.is-leaving { transition: opacity .35s ease; opacity: 0; }
}
