/* =========================================================
   HALAL META EGG — Premium futuristic loading animation
   Agri-tech / food-tech · cinematic · GPU-friendly
   ========================================================= */

.hme-loader {
    --hme-void: #020806;
    --hme-emerald: #10b981;
    --hme-emerald-deep: #064e3b;
    --hme-gold: #c9a227;
    --hme-pearl: #f7f4ef;
    --hme-cyan: #67e8f9;
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: grid;
    place-items: center;
    overflow: hidden;
    background: var(--hme-void);
    color: var(--hme-pearl);
    isolation: isolate;
}

.hme-loader-void {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 55% 45% at 50% 42%, rgba(6, 78, 59, 0.35), transparent 70%),
        radial-gradient(ellipse 40% 30% at 50% 55%, rgba(201, 162, 39, 0.06), transparent 65%),
        linear-gradient(180deg, #010504 0%, #020806 50%, #03110c 100%);
    opacity: 0;
    animation: hmeVoidIn 0.55s ease forwards;
}

.hme-loader-stage {
    position: relative;
    z-index: 2;
    width: min(72vw, 220px);
    height: min(72vw, 220px);
    display: grid;
    place-items: center;
    transform: translateY(-18px);
}

/* Pearl egg — appears, glows, gently rotates */
.hme-loader-egg {
    position: relative;
    z-index: 4;
    width: 28px;
    height: 36px;
    opacity: 0;
    transform: scale(0.35);
    animation:
        hmeEggAppear 0.75s cubic-bezier(0.22, 1, 0.36, 1) 0.12s forwards,
        hmeEggRotate 5.5s ease-in-out 0.85s infinite,
        hmeEggToMark 0.75s cubic-bezier(0.22, 1, 0.36, 1) 1.05s forwards;
}

.hme-loader-egg-glow {
    position: absolute;
    inset: -55%;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(247, 244, 239, 0.55) 0%, rgba(16, 185, 129, 0.28) 42%, transparent 70%);
    filter: blur(10px);
    opacity: 0;
    animation: hmeEggGlow 2.2s ease-in-out 0.35s infinite;
}

.hme-loader-egg-body {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50% 50% 50% 50% / 58% 58% 42% 42%;
    background:
        radial-gradient(ellipse 55% 40% at 35% 28%, rgba(255, 255, 255, 0.95), transparent 55%),
        radial-gradient(ellipse 70% 80% at 55% 60%, #f3efe8 0%, #e8e2d8 55%, #d9d2c6 100%);
    box-shadow:
        0 10px 28px rgba(0, 0, 0, 0.35),
        0 0 24px rgba(247, 244, 239, 0.35),
        inset 0 -8px 14px rgba(6, 78, 59, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.85);
    overflow: hidden;
    transition: border-radius 0.8s ease, box-shadow 0.8s ease;
}

.hme-loader.is-mark .hme-loader-egg-body {
    border-radius: 46% 46% 50% 50% / 52% 52% 48% 48%;
    box-shadow:
        0 12px 32px rgba(0, 0, 0, 0.4),
        0 0 36px rgba(16, 185, 129, 0.28),
        0 0 2px rgba(201, 162, 39, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.hme-loader-egg-shine {
    position: absolute;
    top: 12%;
    left: 18%;
    width: 38%;
    height: 28%;
    border-radius: 50%;
    background: linear-gradient(140deg, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0));
    filter: blur(0.4px);
    animation: hmeShineDrift 2.4s ease-in-out 0.5s infinite;
}

.hme-loader-egg-mark {
    position: absolute;
    inset: 22% 28% 28% 28%;
    border-radius: 50%;
    border: 1.5px solid rgba(16, 185, 129, 0);
    box-shadow: inset 0 0 0 0 rgba(201, 162, 39, 0);
    opacity: 0;
    transform: scale(0.6);
    animation: hmeMarkReveal 0.7s ease 1.15s forwards;
}

.hme-loader-egg-mark::before {
    content: '';
    position: absolute;
    inset: 28%;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, rgba(255, 255, 255, 0.7), rgba(16, 185, 129, 0.55));
    opacity: 0.85;
}

/* Energy rings */
.hme-loader-ring,
.hme-loader-ring-soft {
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
}

.hme-loader-ring {
    width: 118px;
    height: 118px;
    border: 1px solid transparent;
    border-top-color: rgba(16, 185, 129, 0.85);
    border-right-color: rgba(201, 162, 39, 0.35);
    box-shadow: 0 0 18px rgba(16, 185, 129, 0.15);
    animation:
        hmeRingIn 0.7s ease 0.55s forwards,
        hmeRingSpin 4.2s linear 0.9s infinite;
}

.hme-loader-ring-soft {
    width: 148px;
    height: 148px;
    border: 1px solid rgba(16, 185, 129, 0.12);
    box-shadow: inset 0 0 24px rgba(16, 185, 129, 0.05);
    animation:
        hmeRingSoftIn 0.75s ease 0.7s forwards,
        hmeRingSpin 6.5s linear 1s infinite reverse;
}

/* Orbiting particles */
.hme-loader-particle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 3px;
    height: 3px;
    margin: -1.5px 0 0 -1.5px;
    border-radius: 50%;
    background: var(--hme-pearl);
    box-shadow: 0 0 8px rgba(247, 244, 239, 0.8), 0 0 14px rgba(16, 185, 129, 0.45);
    opacity: 0;
    will-change: transform, opacity;
}

.hme-loader-p1 { animation: hmeOrbit 4.6s linear 0.7s infinite; }
.hme-loader-p2 { width: 2px; height: 2px; margin: -1px 0 0 -1px; background: var(--hme-emerald); animation: hmeOrbitRev 5.6s linear 0.85s infinite; }
.hme-loader-p3 { width: 2.5px; height: 2.5px; animation: hmeOrbit 6.2s linear 0.95s infinite; }
.hme-loader-p4 { width: 2px; height: 2px; background: rgba(201, 162, 39, 0.9); box-shadow: 0 0 8px rgba(201, 162, 39, 0.55); animation: hmeOrbitWide 7s linear 1s infinite; }
.hme-loader-p5 { width: 2px; height: 2px; background: rgba(103, 232, 249, 0.75); box-shadow: 0 0 8px rgba(103, 232, 249, 0.4); animation: hmeOrbitRev 5.2s linear 0.9s infinite; }
.hme-loader-p6 { width: 1.5px; height: 1.5px; animation: hmeOrbitWide 8s linear 1.05s infinite reverse; }

/* Data-like light trails */
.hme-loader-trail {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 70px;
    height: 1px;
    margin-top: -0.5px;
    transform-origin: left center;
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.55), rgba(201, 162, 39, 0.15), transparent);
    opacity: 0;
    filter: blur(0.3px);
    pointer-events: none;
}

.hme-loader-trail-a {
    animation: hmeTrailSweep 2.2s ease-in-out 1s infinite;
}

.hme-loader-trail-b {
    width: 54px;
    background: linear-gradient(90deg, rgba(103, 232, 249, 0.35), transparent);
    animation: hmeTrailSweepRev 2.6s ease-in-out 1.15s infinite;
}

/* Brand + loading status */
.hme-loader-copy {
    position: absolute;
    z-index: 3;
    top: calc(50% + min(26vw, 92px));
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    width: min(90vw, 360px);
    pointer-events: none;
}

.hme-loader-brand {
    margin: 0;
    font-family: 'Manrope', 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: clamp(0.95rem, 3.4vw, 1.15rem);
    font-weight: 700;
    letter-spacing: 0.28em;
    text-indent: 0.28em;
    color: rgba(247, 244, 239, 0.96);
    text-transform: uppercase;
    opacity: 0;
    transform: translateY(14px);
    animation: hmeBrandIn 0.65s cubic-bezier(0.22, 1, 0.36, 1) 1.35s forwards;
    text-shadow: 0 0 24px rgba(16, 185, 129, 0.18);
}

.hme-loader-status {
    margin: 14px 0 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: 'Manrope', 'Plus Jakarta Sans', system-ui, sans-serif;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.34em;
    text-indent: 0.34em;
    color: rgba(167, 243, 208, 0.72);
    text-transform: uppercase;
    opacity: 0;
    animation: hmeStatusIn 0.5s ease 1.55s forwards;
}

.hme-loader-dots {
    display: inline-flex;
    gap: 5px;
    margin-left: 2px;
}

.hme-loader-dots i {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: rgba(167, 243, 208, 0.55);
    box-shadow: 0 0 0 rgba(16, 185, 129, 0);
    animation: hmeDot 1.35s ease-in-out infinite;
}

.hme-loader-dots i:nth-child(2) { animation-delay: 0.18s; }
.hme-loader-dots i:nth-child(3) { animation-delay: 0.36s; }

/* Final circular light wave */
.hme-loader-wave {
    position: absolute;
    z-index: 5;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(247, 244, 239, 0.95) 0%, rgba(16, 185, 129, 0.35) 35%, rgba(2, 8, 6, 0) 70%);
    opacity: 0;
    transform: scale(0.2);
    pointer-events: none;
}

.hme-loader.is-exit .hme-loader-wave {
    animation: hmeWaveExpand 0.95s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.hme-loader.is-exit .hme-loader-stage,
.hme-loader.is-exit .hme-loader-copy {
    animation: hmeFadeOutSoft 0.45s ease forwards;
}

.hme-loader.is-done {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.4s ease 0.15s, visibility 0.4s ease 0.15s;
}

/* Keyframes */
@keyframes hmeVoidIn {
    to { opacity: 1; }
}

@keyframes hmeEggAppear {
    0% { opacity: 0; transform: scale(0.35); }
    55% { opacity: 1; transform: scale(1.06); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes hmeEggRotate {
    0%, 100% { transform: rotate(-7deg) scale(1); }
    50% { transform: rotate(8deg) scale(1.03); }
}

@keyframes hmeEggToMark {
    to { width: 52px; height: 64px; }
}

@keyframes hmeEggGlow {
    0%, 100% { opacity: 0.35; transform: scale(0.92); }
    50% { opacity: 0.9; transform: scale(1.08); }
}

@keyframes hmeShineDrift {
    0%, 100% { opacity: 0.75; transform: translate(0, 0); }
    50% { opacity: 1; transform: translate(2px, 1px); }
}

@keyframes hmeMarkReveal {
    to { opacity: 1; transform: scale(1); border-color: rgba(16, 185, 129, 0.55); box-shadow: inset 0 0 0 1px rgba(201, 162, 39, 0.2); }
}

@keyframes hmeRingIn {
    from { opacity: 0; transform: scale(0.7); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes hmeRingSoftIn {
    from { opacity: 0; transform: scale(0.75); }
    to { opacity: 0.85; transform: scale(1); }
}

@keyframes hmeRingSpin {
    to { transform: rotate(360deg); }
}

@keyframes hmeOrbit {
    0% { opacity: 0; transform: rotate(0deg) translateX(58px) rotate(0deg); }
    10% { opacity: 1; }
    90% { opacity: 1; }
    100% { opacity: 0; transform: rotate(360deg) translateX(58px) rotate(-360deg); }
}

@keyframes hmeOrbitRev {
    0% { opacity: 0; transform: rotate(0deg) translateX(68px) rotate(0deg); }
    10% { opacity: 0.9; }
    90% { opacity: 0.9; }
    100% { opacity: 0; transform: rotate(-360deg) translateX(68px) rotate(360deg); }
}

@keyframes hmeOrbitWide {
    0% { opacity: 0; transform: rotate(20deg) translateX(78px) rotate(-20deg); }
    12% { opacity: 0.85; }
    88% { opacity: 0.85; }
    100% { opacity: 0; transform: rotate(380deg) translateX(78px) rotate(-380deg); }
}

@keyframes hmeTrailSweep {
    0%, 100% { opacity: 0; transform: rotate(-25deg) scaleX(0.4); }
    40% { opacity: 0.7; transform: rotate(40deg) scaleX(1); }
    70% { opacity: 0.2; transform: rotate(110deg) scaleX(0.7); }
}

@keyframes hmeTrailSweepRev {
    0%, 100% { opacity: 0; transform: rotate(160deg) scaleX(0.35); }
    45% { opacity: 0.55; transform: rotate(240deg) scaleX(1); }
    75% { opacity: 0.15; transform: rotate(310deg) scaleX(0.55); }
}

@keyframes hmeBrandIn {
    to { opacity: 1; transform: translateY(0); }
}

@keyframes hmeStatusIn {
    to { opacity: 1; }
}

@keyframes hmeDot {
    0%, 100% { opacity: 0.25; transform: translateY(0); box-shadow: 0 0 0 rgba(16, 185, 129, 0); }
    40% { opacity: 1; transform: translateY(-2px); box-shadow: 0 0 8px rgba(16, 185, 129, 0.55); }
}

@keyframes hmeWaveExpand {
    0% { opacity: 0.9; transform: scale(0.2); }
    55% { opacity: 1; }
    100% { opacity: 0; transform: scale(42); }
}

@keyframes hmeFadeOutSoft {
    to { opacity: 0; filter: blur(4px); }
}

@media (max-width: 420px) {
    .hme-loader-stage {
        width: 180px;
        height: 180px;
        transform: translateY(-12px);
    }
    .hme-loader-ring { width: 100px; height: 100px; }
    .hme-loader-ring-soft { width: 126px; height: 126px; }
    .hme-loader-brand { letter-spacing: 0.18em; text-indent: 0.18em; }
}

@media (prefers-reduced-motion: reduce) {
    .hme-loader-void,
    .hme-loader-egg,
    .hme-loader-egg-glow,
    .hme-loader-egg-shine,
    .hme-loader-egg-mark,
    .hme-loader-ring,
    .hme-loader-ring-soft,
    .hme-loader-particle,
    .hme-loader-trail,
    .hme-loader-brand,
    .hme-loader-status,
    .hme-loader-dots i,
    .hme-loader-wave {
        animation: none !important;
    }
    .hme-loader-void,
    .hme-loader-egg,
    .hme-loader-brand,
    .hme-loader-status {
        opacity: 1 !important;
        transform: none !important;
    }
    .hme-loader-egg {
        width: 52px;
        height: 64px;
    }
}
