/**
 * Focus corners: a card that is hovered or focused, the running step of a
 * process and a focused form field get four corners around them instead of
 * a plain border or outline. Focus is a state, not decoration: the permanent
 * slot frame belongs to images only (image-pair), so corners show on one
 * target at a time. Project utility (PPL Logistiikka), no class to add:
 *
 *   .card                 when it holds a link or a button
 *   .step-card.is-active
 *   form fields           css/forms-brand.css (uses the same properties)
 *
 * The corners take the color of action (--link-clr): dark blue on light
 * sections, bright blue on ink.
 */

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

.card,
.step-card {
    position: relative;
}

.card::after,
.step-card::after {
    --c: var(--link-clr);
    --t: 4px;
    --a: var(--focus-corner-a);
    content: "";
    position: absolute;
    inset: -1px;
    pointer-events: none;
    opacity: 0;
    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;
    transition: opacity 0.2s, --focus-corner-a 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.card:has(a, button):focus-within::after,
.step-card.is-active::after {
    opacity: 1;
    --focus-corner-a: 22px;
}

@media (hover: hover) {
    .card:has(a, button):hover::after {
        opacity: 1;
        --focus-corner-a: 22px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .card::after,
    .step-card::after {
        transition: none;
    }
}
