/* Let the opening shape study settle before assembly begins. */
.svg-project {
    --assembly-delay: 450ms;
    --shape-duration: 16s;
}

/* Reuse the site's spacing, borders, and neutral palette. */
.svg-study {
    margin-block: var(--space-6);
    margin-inline: 0;
}

.svg-stage {
    background: var(--white);
    border: var(--border-thin) solid var(--gray-3);
    border-radius: var(--radius-card);
}

.svg-study figcaption {
    margin-block-start: var(--space-4);
    color: var(--gray-8);
}

/* Scale the viewBox within the same wrapper at every screen size. */
.geometric-art {
    display: block;
    inline-size: 100%;
    block-size: auto;
    aspect-ratio: 8 / 5;
}

/* Keep transforms centered on each independent shape. */
/* SVG coordinates use pixels to stay aligned with the viewBox at every display size. */
.geometric-art .shape {
    transform-box: fill-box;
    transform-origin: center;
    transform: var(--camera-pose, none);
    animation: var(--motion) var(--shape-duration) var(--ease-standard) var(--assembly-delay) infinite both;
}

#circle {
    --motion: seat-shutter;
    --shape-pose: translate(-5px, -55px) scale(0.71);
    --camera-pose: translate(120px, 9px) scale(0.34, 0.13);
}

#semicircle {
    --motion: seat-grip;
    --shape-pose: translate(485px, -100px) rotate(0deg) scale(0.79);
    --camera-pose: translate(375px, -90px) rotate(-90deg) scale(1.03, 0.86);
}

#rectangle {
    --motion: seat-finder;
    --shape-pose: translate(-226px, -100px) scale(0.75);
    transform-origin: left center;
    --camera-pose: translate(-60px, -141px) scale(0.3, 0.24);
}

#rings {
    --motion: seat-glass;
    --shape-pose: translate(5px, -255px) scale(0.80);
}

/* Keep the outer cells clear of the assembled camera silhouette. */
.lens-mount {
    --motion: seat-mount;
    --shape-pose: translate(-485px, 55px) scale(0.73);
}

#rings, .lens-mount, .lens-core {
    --camera-pose: translate(-240px, -100px) scale(0.92);
}

/* Expand the lower-right square into the frame behind the seated optics. */
#square {
    --shape-pose: translate(245px, 145px) rotate(0deg) scale(0.27, 0.495);
    --motion: seat-frame;
}
#triangle { --shape-pose: translate(-5px, -49px); --motion: seat-prism; }

/* Keep each contour on its parent’s clock as the silhouette changes. */
@media (prefers-reduced-motion: no-preference) {
    .geometric-art .shape > .contour {
        animation: inherit;
        animation-name: var(--contour-motion, none);
    }
}

#circle .contour { --contour-motion: shutter-profile; }

@keyframes shutter-profile {
    0%, 29%, 94%, 100% { rx: 76px; }
    35%, 92% { rx: 18px; }
}

@keyframes seat-shutter {
    0%, 29%, 94%, 100% { transform: var(--shape-pose); }
    35%, 92% { transform: var(--camera-pose); }
}

/* Split the triangle’s apex into the two top corners of the prism housing. */
#triangle .contour { --contour-motion: prism-profile; }

@keyframes prism-profile {
    0%, 23%, 96%, 100% { d: path("M344.2 195 L405 93 L405 93 L465.8 195 Z"); }
    29%, 94% { d: path("M344.2 170.1 L366.6 117.9 L443.4 117.9 L465.8 170.1 Z"); }
}

@keyframes seat-prism {
    0%, 23%, 96%, 100% { transform: var(--shape-pose); }
    29%, 94% { transform: none; }
}

/* The free-standing bar meets the expanding frame to build the two-tone body. */
.body-panel {
    --shape-pose: translateY(113.8px) scale(0.50, 0.18);
    --motion: seat-panel;
}

@keyframes seat-frame {
    0%, 10%, 100% { transform: var(--shape-pose); }
    17%, 98% { transform: none; }
}

@keyframes seat-panel {
    0%, 17%, 98%, 100% { transform: var(--shape-pose); }
    23%, 96% { transform: none; }
}

/* Keep the center disk fixed while the other eight pieces join its optical axis. */
.lens-core {
    --motion: seat-aperture;
    --shape-pose: var(--camera-pose);
}

@keyframes seat-grip {
    0%, 40%, 90%, 100% { transform: var(--shape-pose); }
    48%, 87% { transform: var(--camera-pose); }
}

@keyframes seat-finder {
    0%, 35%, 92%, 100% { transform: var(--shape-pose); }
    40%, 90% { transform: var(--camera-pose); }
}

@keyframes seat-glass {
    0%, 54%, 84%, 100% { transform: var(--shape-pose); }
    60%, 82% { transform: var(--camera-pose); }
}

@keyframes seat-mount {
    0%, 48%, 87%, 100% { transform: var(--shape-pose); }
    54%, 84% { transform: var(--camera-pose); }
}

@keyframes seat-aperture {
    0%, 60%, 82%, 100% { transform: var(--shape-pose); }
    65%, 80% { transform: var(--camera-pose); }
}

/* Normalize each stroke so its dash travels the full length of the engraving. */
.engraving { fill: none; stroke: var(--white); stroke-width: 4px; stroke-dasharray: 1; }
#grip-first { --contour-motion: draw-first-rib; }
#grip-middle { --contour-motion: draw-middle-rib; }
#grip-last { --contour-motion: draw-last-rib; }

@keyframes draw-first-rib {
    0%, 41%, 90%, 100% { stroke-dashoffset: 1; }
    43%, 89% { stroke-dashoffset: 0; }
}
@keyframes draw-middle-rib {
    0%, 43%, 89%, 100% { stroke-dashoffset: 1; }
    45%, 88% { stroke-dashoffset: 0; }
}
@keyframes draw-last-rib {
    0%, 45%, 88%, 100% { stroke-dashoffset: 1; }
    48%, 87% { stroke-dashoffset: 0; }
}

.mount-rim { --contour-motion: draw-mount; stroke-dasharray: 1.01; }
/* Extend the gap past the closed circle to prevent a residual stroke at the seam. */
.aperture { --contour-motion: draw-aperture; stroke-dasharray: 1.01; }
.finder-frame { --contour-motion: draw-finder; stroke-width: 7px; }

@keyframes draw-finder {
    0%, 36%, 92%, 100% { stroke-dashoffset: 1; }
    40%, 90% { stroke-dashoffset: 0; }
}

@keyframes draw-mount {
    0%, 49%, 87%, 100% { stroke-dashoffset: 1.01; }
    54%, 84% { stroke-dashoffset: 0; }
}
@keyframes draw-aperture {
    0%, 60%, 82%, 100% { stroke-dashoffset: 1.01; }
    65%, 80% { stroke-dashoffset: 0; }
}

/* Show the completed illustration immediately when motion is reduced. */
@media (prefers-reduced-motion: reduce) {
    .geometric-art .shape {
        animation: none;
    }
}
