/* Geometric faceted hourglass — teal fine sand follows --hg-p (0–1) */
.hg-loader {
    --hg-p: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 5.35rem;
    height: 7.55rem;
    margin: 0 auto;
    line-height: 0;
}

.hg-loader svg {
    width: 5.35rem;
    height: 7.55rem;
    overflow: visible;
    filter: drop-shadow(0 8px 14px rgba(12, 70, 68, 0.22));
}

.hg-loader .hg-sand-top,
.hg-loader .hg-sand-bottom {
    /* SVG transform is set in JS so parent clipPath can contain the sand. */
    transition: opacity 0.2s ease-out;
}

.hg-loader.is-done .hg-sand-top {
    opacity: 0;
}

.hg-loader .hg-stream-wrap {
    clip-path: inset(0 0 calc(var(--hg-p) * 68%) 0);
    opacity: 0;
    transition: opacity 0.18s ease;
}

.hg-loader.is-flowing .hg-stream-wrap {
    opacity: 1;
}

.hg-loader.is-done .hg-stream-wrap,
.hg-loader.is-done .hg-grain {
    opacity: 0;
    animation: none;
}

.hg-loader .hg-stream {
    opacity: 0;
}

.hg-loader.is-flowing .hg-stream-a {
    opacity: 0.95;
    animation: hg-sand-fall 0.42s linear infinite;
}

.hg-loader.is-flowing .hg-stream-b {
    opacity: 0.8;
    animation: hg-sand-fall 0.5s linear infinite reverse;
}

.hg-loader.is-flowing .hg-stream-c {
    opacity: 0.7;
    animation: hg-sand-fall 0.38s linear infinite;
}

.hg-loader .hg-grain {
    opacity: 0;
}

.hg-loader.is-flowing .hg-grain {
    animation: hg-grain-fall 0.72s linear infinite;
}

.hg-loader.is-flowing .hg-grain-b {
    animation-duration: 0.86s;
    animation-delay: 0.18s;
}

.hg-loader.is-flowing .hg-grain-c {
    animation-duration: 0.64s;
    animation-delay: 0.34s;
}

.hg-loader.is-flowing .hg-grain-d {
    animation-duration: 0.78s;
    animation-delay: 0.5s;
}

body.reader-night .hg-loader svg {
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.5));
}

@keyframes hg-sand-fall {
    to {
        stroke-dashoffset: -16;
    }
}

@keyframes hg-grain-fall {
    0% {
        opacity: 0;
        transform: translateY(0);
    }
    12% {
        opacity: 1;
    }
    82% {
        opacity: 0.75;
        transform: translateY(2.45rem);
    }
    100% {
        opacity: 0;
        transform: translateY(2.85rem);
    }
}

@media (prefers-reduced-motion: reduce) {
    .hg-loader .hg-sand-top,
    .hg-loader .hg-sand-bottom,
    .hg-loader .hg-stream-wrap {
        transition: none;
    }

    .hg-loader .hg-stream,
    .hg-loader .hg-grain {
        animation: none !important;
    }

    .hg-loader.is-flowing .hg-stream-a,
    .hg-loader.is-flowing .hg-stream-b,
    .hg-loader.is-flowing .hg-stream-c {
        opacity: 0.85;
    }
}
