@property --hf-can-orbit-angle {
    syntax: '<angle>';
    inherits: false;
    initial-value: 0deg;
}

@property --hf-can-orbit-radius {
    syntax: '<length>';
    inherits: false;
    initial-value: 92px;
}

.hf-can-preview {
    --cycle: 3.6s;
    --stroke-ease: cubic-bezier(.37, 0, .23, 1);
    --lift: translateY(-22px);
    --result-pose: translateY(-7px) scale(1.09);
    position: absolute;
    inset: 0;
    visibility: hidden;
    pointer-events: none;
}

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

.hf-can-product,
.hf-can-tool,
.hf-can-support,
.hf-can-rim,
.hf-can-finished {
    opacity: 0;
}

.hf-can-product {
    transform-box: view-box;
    transform-origin: 50% 68.3%;
}

.hf-can-roller-a { --direction: 1; }
.hf-can-roller-b { --direction: -1; }

/* Keep the circumference elliptical in projection and hide each roll behind the chuck. */
.hf-can-roller {
    --depth: calc(sin(var(--hf-can-orbit-angle)) * var(--direction));
    transform: translateX(calc(-92px * var(--direction)));
    transform: translate(
        calc(-1 * var(--hf-can-orbit-radius) * cos(var(--hf-can-orbit-angle)) * var(--direction)),
        calc(26px * var(--depth))
    );
    opacity: clamp(0, calc(1 + 1.25 * var(--depth)), 1);
}

.hf-can-seaming-photo.is-previewing .hf-can-preview { visibility: visible; }

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

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

.hf-can-seaming-photo.is-previewing .hf-can-unsealed {
    animation: hf-can-unsealed-out var(--cycle) step-end both;
}

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

.hf-can-seaming-photo.is-previewing .hf-can-lift {
    animation: hf-can-rise var(--cycle) var(--stroke-ease) both;
}

.hf-can-seaming-photo.is-previewing .hf-can-support {
    animation: hf-can-support-view var(--cycle) ease-in-out both;
}

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

.hf-can-seaming-photo.is-previewing .hf-can-roller {
    animation: hf-can-seaming-orbit var(--cycle) linear both;
}

.hf-can-seaming-photo.is-previewing .hf-can-rim {
    animation: hf-can-rim-light var(--cycle) ease-out both;
}

@keyframes hf-can-product-in {
    0% { opacity: 0; transform: translateY(4px) scale(.985); }
    8%, 87% { opacity: 1; transform: none; }
    100% { opacity: 1; transform: var(--result-pose); }
}

@keyframes hf-can-lid-set {
    0%, 13% {
        transform: translateY(-74px);
        animation-timing-function: cubic-bezier(.5, .05, .86, .54);
    }
    28%, 45% { transform: translateY(-2.3px); }
    55%, 100% { transform: translateY(0); }
}

@keyframes hf-can-unsealed-out {
    0% { opacity: 1; }
    76%, 100% { opacity: 0; }
}

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

@keyframes hf-can-rise {
    0%, 29%, 89%, 100% { transform: translateY(0); }
    41%, 77% { transform: var(--lift); }
}

@keyframes hf-can-support-view {
    0%, 95%, 100% { opacity: 0; }
    12%, 85% { opacity: 1; }
}

@keyframes hf-can-tool-view {
    0%, 26%, 93%, 100% { opacity: 0; }
    36%, 83% { opacity: 1; }
}

/* Eight turns during the clamped portion of the cycle. */
@keyframes hf-can-seaming-orbit {
    0%, 40% { --hf-can-orbit-angle: 0deg; --hf-can-orbit-radius: 92px; }
    45% { --hf-can-orbit-angle: 0deg; --hf-can-orbit-radius: 79px; }
    75% { --hf-can-orbit-angle: 2880deg; --hf-can-orbit-radius: 79px; }
    82%, 100% { --hf-can-orbit-angle: 2880deg; --hf-can-orbit-radius: 92px; }
}

@keyframes hf-can-rim-light {
    0%, 73%, 100% { opacity: 0; }
    80%, 86% { opacity: .6; }
}

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

    .hf-can-seaming-photo.is-previewing .hf-can-product {
        opacity: 1;
        transform: var(--result-pose);
    }

    .hf-can-unsealed { opacity: 0; }
    .hf-can-finished { opacity: 1; }
}
