@property --hf-cap-turn-angle {
    syntax: '<angle>';
    inherits: true;
    initial-value: 0deg;
}

.hf-cap-preview {
    --cycle: 3.45s;
    --stroke-ease: cubic-bezier(.37, 0, .23, 1);
    --hero: translateY(-8px) scale(1.09);
    position: absolute;
    inset: 0;
    visibility: hidden;
    pointer-events: none;
}

.hf-cap-scene {
    position: absolute;
    inset: 0;
    width: min(100%, 121.95cqh);
    height: min(100%, 82cqw);
    margin: auto;
}

.hf-cap-product,
.hf-cap-tool,
.hf-cap-glint,
.hf-cap-jaw-seams,
.hf-cap-finished {
    opacity: 0;
}

.hf-cap-product {
    transform-box: view-box;
    transform-origin: 50% 68%;
}

.hf-cap-jaw-left,
.hf-cap-jaw-bolt-left { --side: -1; }

.hf-cap-jaw-right,
.hf-cap-jaw-bolt-right { --side: 1; }

.hf-cap-orbit-a { --direction: 1; }
.hf-cap-orbit-b { --direction: -1; }

.hf-cap-orbit {
    --radial: calc(cos(var(--hf-cap-turn-angle)) * var(--direction));
    --depth: calc(sin(var(--hf-cap-turn-angle)) * var(--direction));
    --front: clamp(0, calc(5 * var(--depth)), 1);
}

.hf-cap-link {
    transform: translate(calc(-23px * var(--radial)), calc(2.4px * var(--depth)));
    opacity: clamp(0, calc(1 + 2.3 * var(--depth)), 1);
}

.hf-cap-hose {
    transform-box: view-box;
    transform-origin: 200px 0;
    transform: translateY(calc(2.4px * var(--depth))) scaleX(var(--radial));
    stroke-linecap: round;
}

.hf-cap-hose-body { stroke-width: clamp(.9px, 1cqw, 3px); }
.hf-cap-hose-light { stroke-width: clamp(.26px, .23cqw, .72px); }
.hf-cap-front { opacity: var(--front); }
.hf-cap-back { opacity: calc(1 - var(--front)); }

.hf-cap-jaw-seam {
    transform: translateX(calc(73px * var(--depth)));
    opacity: clamp(0, calc(2.6 * var(--radial)), .86);
}

.hf-cap-jaw-bolt {
    --depth: calc(sin(var(--hf-cap-turn-angle)) * var(--side));
    transform: translate(calc(47px * cos(var(--hf-cap-turn-angle)) * var(--side)), calc(3px * var(--depth)));
    opacity: clamp(0, calc(.85 + var(--depth)), 1);
}

.hf-cap-glint {
    transform: translateX(calc(35px * cos(var(--hf-cap-turn-angle))));
}

.hf-capping-photo.is-previewing .hf-cap-preview { visibility: visible; }

.hf-capping-photo.is-previewing .hf-cap-scene {
    animation: hf-cap-turn var(--cycle) linear both;
}

.hf-capping-photo.is-previewing .hf-cap-product {
    animation: hf-cap-product-in var(--cycle) var(--stroke-ease) both;
}

.hf-capping-photo.is-previewing .hf-cap-lid {
    animation: hf-cap-lid-set var(--cycle) var(--stroke-ease) both;
}

.hf-capping-photo.is-previewing .hf-cap-open {
    animation: hf-cap-open-out var(--cycle) step-end both;
}

.hf-capping-photo.is-previewing .hf-cap-finished {
    animation: hf-cap-finished-in var(--cycle) step-end both;
}

.hf-capping-photo.is-previewing .hf-cap-tool {
    animation: hf-cap-tool-in var(--cycle) ease-in-out both;
}

.hf-capping-photo.is-previewing .hf-cap-head {
    animation: hf-cap-head-stroke var(--cycle) var(--stroke-ease) both;
}

.hf-capping-photo.is-previewing .hf-cap-jaw {
    animation: hf-cap-grip var(--cycle) var(--stroke-ease) both;
}

.hf-capping-photo.is-previewing :is(.hf-cap-glint, .hf-cap-jaw-seams) {
    animation: hf-cap-spin-glint var(--cycle) linear both;
}

@keyframes hf-cap-turn {
    0%, 47% { --hf-cap-turn-angle: 0deg; }
    69%, 100% { --hf-cap-turn-angle: 1440deg; }
}

@keyframes hf-cap-product-in {
    0% { opacity: 0; transform: translateY(4px) scale(.985); }
    10%, 85% { opacity: 1; transform: none; }
    100% { opacity: 1; transform: var(--hero); }
}

@keyframes hf-cap-lid-set {
    0%, 13% {
        transform: translateY(-53px);
        animation-timing-function: cubic-bezier(.48, .09, .78, .55);
    }
    29%, 45% { transform: translateY(-2.6px); }
    69%, 100% { transform: translateY(0); }
}

@keyframes hf-cap-open-out {
    0% { opacity: 1; }
    72%, 100% { opacity: 0; }
}

@keyframes hf-cap-finished-in {
    0% { opacity: 0; }
    72%, 100% { opacity: 1; }
}

@keyframes hf-cap-tool-in {
    0%, 25%, 94%, 100% { opacity: 0; }
    36%, 81% { opacity: 1; }
}

@keyframes hf-cap-head-stroke {
    0%, 31%, 84%, 100% { transform: translateY(0); }
    46%, 70% { transform: translateY(22px); }
}

@keyframes hf-cap-grip {
    0%, 41%, 77%, 100% { transform: translateX(calc(6px * var(--side))); }
    46%, 70% { transform: translateX(0); }
    47%, 69% { transform: translateX(calc(-1.9px * var(--side))); }
}

@keyframes hf-cap-spin-glint {
    0%, 46%, 70%, 100% { opacity: 0; }
    49%, 68% { opacity: .72; }
}

@media (prefers-reduced-motion: reduce) {
    .hf-capping-photo.is-previewing .hf-cap-scene,
    .hf-capping-photo.is-previewing .hf-cap-scene * { animation: none; }

    .hf-capping-photo.is-previewing .hf-cap-product {
        opacity: 1;
        transform: var(--hero);
    }

    .hf-cap-open { opacity: 0; }
    .hf-cap-finished { opacity: 1; }
}
