/**
 * Image pair: a large pallet image and a small parcel image side by side,
 * each inside a slot frame (four floor-marking corners). The brand's image
 * rule: images come in pairs, large 3:2 with light blue corners, small 1:1
 * with dark blue corners. Project block (PPL Logistiikka).
 *
 * globalClass: image-pair
 *
 * Structure:
 *   .image-pair.gb-container
 *     figure.gb-block-image > img      large, 3:2
 *     figure.gb-block-image > img      small, 1:1
 *
 * The corners arrive from outside and their arms grow when a third of the
 * image is on screen (js/blocks/image-pair.js adds .is-framed). Without the
 * script or with reduced motion the frame is simply there.
 *
 * Variables:
 *   --slot-frame-t         corner thickness of the large frame (6px)
 *   --slot-frame-t-small   corner thickness of the small frame (4px)
 *
 * Chain animations: animate the .image-pair container as one member, not the
 * figures (the frame motion is the block's own).
 */

@property --slot-frame-a {
    syntax: "<length>";
    inherits: true;
    initial-value: 0px;
}

.image-pair {
    --slot-frame-t: 6px;
    --slot-frame-t-small: 4px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(14px, 2vw, 26px);
    align-items: end;
}

.image-pair > .block-editor-inner-blocks,
.image-pair > .block-editor-inner-blocks > .block-editor-block-list__layout {
    display: contents;
}

.image-pair figure {
    --c: var(--accent-clr);
    --t: var(--slot-frame-t);
    --a: calc(var(--t) * 5);
    position: relative;
    grid-column: 1 / -1;
    aspect-ratio: 3 / 2;
    margin: 0;
    padding: calc(var(--t) * 3);
}

.image-pair figure + figure {
    --c: var(--pak-clr);
    --t: var(--slot-frame-t-small);
    grid-column: 1;
    aspect-ratio: 1 / 1;
}

/* The figure owns the box; the image fills it inside the frame's padding */
.image-pair figure img {
    position: absolute;
    inset: calc(var(--t) * 3);
    width: calc(100% - var(--t) * 6);
    height: calc(100% - var(--t) * 6);
    object-fit: cover;
}

.image-pair figure::before {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(var(--c) 0 0) left top / var(--a) var(--t), linear-gradient(var(--c) 0 0) left top / var(--t) var(--a),
        linear-gradient(var(--c) 0 0) right top / var(--a) var(--t), linear-gradient(var(--c) 0 0) right top / var(--t) var(--a),
        linear-gradient(var(--c) 0 0) left bottom / var(--a) var(--t), linear-gradient(var(--c) 0 0) left bottom / var(--t) var(--a),
        linear-gradient(var(--c) 0 0) right bottom / var(--a) var(--t), linear-gradient(var(--c) 0 0) right bottom / var(--t) var(--a);
    background-repeat: no-repeat;
}

@media (prefers-reduced-motion: no-preference) {
    .js .image-pair figure::before {
        inset: -14px;
        opacity: 0;
        --a: var(--slot-frame-a);
        --slot-frame-a: calc(var(--t) * 1.5);
    }

    .js .image-pair figure.is-framed::before {
        inset: 0;
        opacity: 1;
        --slot-frame-a: calc(var(--t) * 5);
        transition:
            inset 0.75s cubic-bezier(0.2, 0.8, 0.2, 1) var(--slot-frame-delay, 0.15s),
            opacity 0.25s var(--slot-frame-delay, 0.15s),
            --slot-frame-a 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) calc(var(--slot-frame-delay, 0.15s) + 0.35s);
    }

    .js .image-pair figure + figure {
        --slot-frame-delay: 0.4s;
    }
}

@media (min-width: 768px) {
    .image-pair {
        grid-template-columns: 2fr 1fr;
    }

    .image-pair figure {
        grid-column: auto;
    }

    .image-pair figure + figure {
        grid-column: auto;
    }
}
