/* Detailed raster poses retain the original's sculpted coat and rainbow strands. */
.transaction-heading {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 12px;
    overflow: hidden;
}
.transaction-heading.has-unicorn { padding-top: 8px; }
.transaction-heading.has-unicorn h3 { padding-bottom: 9px; }
.unicorn-scene {
    --weather-rise: 48px;
    margin-top: var(--weather-rise);
    position: relative;
    flex: 0 0 180px;
    width: 180px;
    height: 160px;
    pointer-events: none;
    user-select: none;
}
.unicorn-scene[hidden] { display: none; }
.unicorn-scene svg { display: block; width: 100%; height: 100%; overflow: visible; }
.unicorn-weather, .unicorn-meadow { position: absolute; inset: 0; }
.unicorn-weather { z-index: 2; transform: translateY(calc(-1 * var(--weather-rise))); }
.unicorn-actor { position: absolute; width: 100%; aspect-ratio: 1; bottom: -2.5%; right: 0; }
.unicorn-sprite, .unicorn-pose, .unicorn-wet-sprite, .unicorn-chew-detail {
    position: absolute;
    inset: 0;
    background-image: url('/images/unicorn-detailed-sprites.png');
    background-size: 400% 200%;
    background-position: 100% 0;
    background-repeat: no-repeat;
}
/* The second row's hoof baseline is 5% higher in the atlas. */
.unicorn-wet-sprite { background-position: 100% 95%; opacity: 0; transition: opacity 5s ease; }
.unicorn-dry { position: absolute; inset: 0; transition: opacity 5s ease; }
.unicorn-sprite, .unicorn-pose { transition: opacity .4s linear; }
.unicorn-pose { opacity: 0; }
.unicorn-pose-half { background-position: 0 95%; }
.unicorn-pose-down { background-position: 33.333333% 95%; }
.unicorn-scene.is-wet .unicorn-wet-sprite { opacity: 1; transition-duration: 2s; }
.unicorn-scene.is-wet .unicorn-dry { opacity: 0; transition-duration: 2s; }
.unicorn-chew-detail { opacity: 0; transition: opacity .4s ease; background-position: 100% 0; clip-path: ellipse(7% 4% at 27% 36%); }
.unicorn-grass { transform-origin: 38px 179px; transition: transform 1s; }
.unicorn-scene[data-state="walking"] .unicorn-actor { animation: unicorn-enter 4.2s linear both; }
.unicorn-scene[data-state="walking"] .unicorn-sprite { animation: unicorn-walk .8s step-end infinite; }
.unicorn-scene:is([data-state="lowering"], [data-state="grazing"], [data-state="lifting"], [data-state="drowsy"], [data-state="sleeping"]) .unicorn-sprite { opacity: 0; }
.unicorn-scene:is([data-state="lowering"], [data-state="lifting"], [data-state="drowsy"], [data-state="sleeping"]) .unicorn-pose-half { opacity: 1; }
.unicorn-scene[data-state="grazing"] .unicorn-pose-down { opacity: 1; }
.unicorn-scene[data-state="grazing"] .unicorn-grass { transform: scaleY(.65); }
.unicorn-scene[data-state="chewing"] .unicorn-chew-detail { opacity: 1; animation: unicorn-chew .7s ease-in-out 5; }
/* Chewing uses the standing frame, so the coat and hooves never change on settling. */
.unicorn-mouth-grass {
    position: absolute;
    left: 20%;
    top: 37%;
    width: 8%;
    height: 8%;
    opacity: 0;
    transition: opacity .25s ease;
}
.unicorn-scene[data-state="chewing"] .unicorn-mouth-grass {
    opacity: 1;
    animation: unicorn-chew .7s ease-in-out 5;
}
.unicorn-cloud, .unicorn-rain, .unicorn-sun, .unicorn-moon, .unicorn-puddle { opacity: 0; transition: opacity 1.6s ease; }
.unicorn-scene[data-weather="rain"] .unicorn-cloud,
.unicorn-scene[data-weather="rain"] .unicorn-rain,
.unicorn-scene[data-weather="sun"] .unicorn-sun,
.unicorn-scene[data-weather="moon"] .unicorn-moon,
.unicorn-scene.is-wet .unicorn-puddle { opacity: 1; }
.unicorn-scene[data-weather="rain"] .unicorn-rain path { animation: unicorn-rainfall .7s linear infinite; animation-delay: calc(var(--drop) * -.13s); }
.unicorn-scene.is-paused *, .unicorn-scene.is-paused svg * { animation-play-state: paused !important; }
@keyframes unicorn-enter { from { transform: translateX(var(--entry-distance, 100vw)); } to { transform: translateX(0); } }
@keyframes unicorn-walk {
    0%, 100% { background-position: 0 0; transform: translateY(0); }
    25%, 75% { background-position: 33.333333% 0; transform: translateY(-1px); }
    50% { background-position: 66.666667% 0; transform: translateY(0); }
}
@keyframes unicorn-chew { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(-.5px, 1px); } }
@keyframes unicorn-rainfall { from { transform: translateY(-9px); } to { transform: translateY(17px); } }
/* A quick shake scatters droplets before the bluebird approaches. */
.unicorn-scene[data-state="shaking"] .unicorn-actor {
    transform-origin: 60% 88%;
    animation: unicorn-shake .3s ease-in-out 6;
}
.unicorn-spray { position: absolute; inset: 0; z-index: 3; }
.unicorn-spray ellipse { opacity: 0; }
.unicorn-scene[data-state="shaking"] .unicorn-spray ellipse {
    animation: unicorn-spray .72s ease-out var(--delay) 2 both;
}
.unicorn-bird {
    position: absolute;
    left: 58%;
    top: 15%;
    width: 22%;
    aspect-ratio: 1;
    z-index: 3;
    opacity: 0;
}
.unicorn-bird-sprite {
    width: 100%;
    height: 100%;
    background: url('/images/unicorn-bird-sprites.png') 0 0 / 300% 100% no-repeat;
}
.unicorn-scene[data-bird="landing"] .unicorn-bird { animation: unicorn-bird-land 1.2s ease-out both; }
.unicorn-scene[data-bird="perched"] .unicorn-bird { opacity: 1; }
.unicorn-scene[data-bird="departing"] .unicorn-bird { animation: unicorn-bird-leave 1.4s ease-in both; }
.unicorn-scene[data-bird="landing"] .unicorn-bird-sprite,
.unicorn-scene[data-bird="departing"] .unicorn-bird-sprite { animation: unicorn-bird-flap .16s step-end infinite; }
@keyframes unicorn-shake {
    0%, 100% { transform: translateX(0) rotate(0); }
    25% { transform: translateX(-2px) rotate(-1.5deg); }
    75% { transform: translateX(2px) rotate(1.5deg); }
}
@keyframes unicorn-spray {
    0% { opacity: 0; transform: translate(0, 0); }
    15% { opacity: .95; }
    100% { opacity: 0; transform: translate(var(--dx), var(--dy)); }
}
@keyframes unicorn-bird-land {
    0% { opacity: 0; transform: translate(80px, -48px) rotate(-12deg); }
    15% { opacity: 1; }
    75% { transform: translate(6px, -8px) rotate(3deg); }
    100% { opacity: 1; transform: translate(0, 0) rotate(0); }
}
@keyframes unicorn-bird-leave {
    0% { opacity: 1; transform: translate(0, 0); }
    25% { opacity: 1; transform: translate(-12px, -20px); }
    75% { opacity: 1; }
    100% { opacity: 0; transform: translate(-110px, -75px); }
}
@keyframes unicorn-bird-flap {
    0%, 100% { background-position: 50% 0; }
    50% { background-position: 100% 0; }
}
/* Two wing flaps during each longer perch, then fold the wings again. */
.unicorn-scene[data-bird="perched"] .unicorn-bird-sprite {
    animation: unicorn-perched-flap .65s step-end 6s 2;
}
@keyframes unicorn-perched-flap {
    0%, 100% { background-position: 0 0; }
    20% { background-position: 50% 0; }
    55% { background-position: 100% 0; }
    85% { background-position: 0 0; }
}
.unicorn-actor { transition: filter 1.6s ease; }
.unicorn-scene[data-weather="moon"] .unicorn-actor { filter: brightness(.8) saturate(.8); }
.unicorn-scene[data-state="sleeping"] .unicorn-actor {
    transform-origin: 60% 88%;
    animation: unicorn-breathe 3s ease-in-out infinite;
}
.unicorn-snooze { opacity: 0; transition: opacity 1s ease; position: absolute; left: 30%; top: 13%; z-index: 3; }
.unicorn-snooze span {
    position: absolute;
    opacity: 0;
    font: bold 15px/1 Georgia, serif;
    color: #8996c8;
    text-shadow: 0 0 3px #fff;
}
.unicorn-scene[data-state="sleeping"] .unicorn-snooze { opacity: 1; }
.unicorn-scene[data-state="sleeping"] .unicorn-snooze span { animation: unicorn-zzz 3s ease-out infinite; }
.unicorn-scene[data-state="sleeping"] .unicorn-snooze span:nth-child(2) { animation-delay: 1s; }
.unicorn-scene[data-state="sleeping"] .unicorn-snooze span:nth-child(3) { animation-delay: 2s; }
@keyframes unicorn-breathe {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(1.008); }
}
@keyframes unicorn-zzz {
    0% { opacity: 0; transform: translate(0, 0) scale(.65); }
    20% { opacity: .9; }
    100% { opacity: 0; transform: translate(18px, -35px) scale(1.1); }
}
@media (max-width: 575px) {
    .transaction-heading { gap: 4px; }
    .transaction-heading.has-unicorn h3 { font-size: 1.15rem; padding-bottom: 5px; }
    .unicorn-scene { --weather-rise: 32px; flex-basis: 116px; width: 116px; height: 103px; }
}
@media (prefers-reduced-motion: reduce) {
    .unicorn-scene *, .unicorn-scene svg * { animation: none !important; transition: none !important; }
    #transaction-table .rainbow-row { animation: none !important; }
}
@media print { .unicorn-scene { display: none !important; } }

/* Beside the login card on wide screens, beneath it on narrow screens. */
.login-unicorn-stage {
    position: relative;
    display: flex;
    justify-content: flex-end;
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    pointer-events: none;
    overflow: clip;
}
@media (min-width: 992px) {
    .login-unicorn-stage { overflow: visible; }
    .login-unicorn-stage .unicorn-scene {
        position: absolute;
        left: calc(100% + 24px);
        bottom: 0;
    }
    /* Clip the entrance at the page edge without creating a horizontal scrollbar. */
    #hero-section:has(.login-unicorn-stage) { overflow: clip; }
}
