/* animated extras laid over the page, see Components/Gimmicks */

.gimmick {
    position: fixed;
    z-index: 30;
    pointer-events: none;
}

.gimmick svg {
    display: block;
    overflow: visible;
}

.gimmick-say {
    position: absolute;
    width: max-content;
    max-width: 210px;
    padding: 6px 12px;
    background: #fff;
    color: #1C2733;
    border: 2px solid var(--navy);
    border-radius: 14px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, .15);
    font-family: var(--festive);
    font-size: .95rem;
    line-height: 1.3;
    opacity: 0;
}

@media (prefers-reduced-motion: reduce) {
    .gimmick {
        display: none;
    }
}

/* snow plow: 14 seconds across the screen, then 10 off it */

.plow {
    left: 0;
    right: 0;
    bottom: 0;
    height: 124px;
    overflow: hidden;
}

.plow-drive {
    width: 270px;
    transform: translateX(100vw);
    animation: plow-drive 24s linear infinite;
}

@keyframes plow-drive {
    0% { transform: translateX(100vw); }
    58%, 100% { transform: translateX(-290px); }
}

.plow-body {
    animation: plow-bob .35s ease-in-out infinite alternate;
}

@keyframes plow-bob {
    to { transform: translateY(-1.5px); }
}

.plow-wheel {
    transform-box: fill-box;
    transform-origin: center;
    animation: plow-spin .75s linear infinite;
}

@keyframes plow-spin {
    to { transform: rotate(-360deg); }
}

.plow-glow {
    animation: plow-blink .8s steps(1) infinite;
}

@keyframes plow-blink {
    0% { opacity: .6; }
    50% { opacity: 0; }
}

.plow-flake {
    animation: plow-flake .6s ease-out infinite;
}

@keyframes plow-flake {
    from { transform: translate(0, 0); opacity: 1; }
    to { transform: translate(-16px, -26px); opacity: 0; }
}

.plow-puff {
    transform-box: fill-box;
    transform-origin: center;
    animation: plow-puff 1.2s ease-out infinite;
}

@keyframes plow-puff {
    from { transform: translate(0, 0) scale(1); opacity: .8; }
    to { transform: translate(14px, -18px) scale(2.4); opacity: 0; }
}

/* gremlin: three peeks from the bottom edge, seven seconds each */

.gremlin {
    bottom: 0;
    width: 120px;
    height: 110px;
    animation: gremlin-spot 21s step-end infinite;
}

/* step-end, so it jumps to the next spot while it is out of sight */
@keyframes gremlin-spot {
    0% { left: 8%; }
    33.3% { left: 42%; }
    66.6% { left: calc(100% - 160px); }
}

.gremlin-peek {
    transform: translateY(110%);
    animation: gremlin-peek 21s ease-in-out infinite;
}

@keyframes gremlin-peek {
    0%, 4% { transform: translateY(110%); }
    6% { transform: translateY(-4%); }
    7%, 24% { transform: translateY(0); }
    27%, 37% { transform: translateY(110%); }
    39% { transform: translateY(-4%); }
    40%, 57% { transform: translateY(0); }
    60%, 71% { transform: translateY(110%); }
    73% { transform: translateY(-4%); }
    74%, 92% { transform: translateY(0); }
    95%, 100% { transform: translateY(110%); }
}

/* ducks when hovered and comes back a moment later */
.gremlin-dodge {
    transition: transform .4s ease-out 1.5s;
}

.gremlin svg {
    pointer-events: auto;
}

.gremlin:hover .gremlin-dodge {
    transform: translateY(110%);
    transition: transform .12s ease-in;
}

.gremlin-pupils {
    animation: gremlin-look 7s ease-in-out infinite;
}

@keyframes gremlin-look {
    0%, 30% { transform: translateX(0); }
    38%, 52% { transform: translateX(-3px); }
    60%, 72% { transform: translateX(3px); }
    80%, 100% { transform: translateX(0); }
}

.gremlin-eyes {
    transform-box: fill-box;
    transform-origin: center;
    animation: gremlin-blink 3.5s infinite;
}

@keyframes gremlin-blink {
    0%, 92%, 100% { transform: scaleY(1); }
    95% { transform: scaleY(.1); }
}

.gremlin-bulb {
    animation: gremlin-twinkle 1.2s steps(1) infinite;
}

@keyframes gremlin-twinkle {
    0% { opacity: 1; }
    50% { opacity: .35; }
}

.gremlin-say {
    right: 10px;
    bottom: 104px;
    animation: gremlin-say 21s infinite;
}

@keyframes gremlin-say {
    0%, 76% { opacity: 0; }
    78%, 90% { opacity: 1; }
    92%, 100% { opacity: 0; }
}

/* vent: the grille rattles and falls, the hero crawls up, talks and backs off. 22 second loop */

.vent {
    top: calc(var(--topbar) + 14px);
    right: 28px;
    width: 170px;
    height: 120px;
    animation: vent-show 22s infinite;
}

@keyframes vent-show {
    0% { opacity: 0; transform: scale(.9); }
    2%, 80% { opacity: 1; transform: scale(1); }
    83%, 100% { opacity: 0; transform: scale(.9); }
}

.vent-grille {
    transform-box: view-box;
    transform-origin: 85px 60px;
    animation: vent-grille 22s infinite;
}

@keyframes vent-grille {
    0%, 10% { transform: none; opacity: 1; }
    11% { transform: translate(-2px, 1px) rotate(-1deg); }
    12% { transform: translate(2px, -1px) rotate(1deg); }
    13% { transform: translate(-2px, 0) rotate(-1.5deg); }
    14% { transform: translate(3px, 1px) rotate(1.5deg); }
    15%, 16% { transform: none; opacity: 1; }
    17% { transform: translate(-4px, -6px) rotate(-4deg); opacity: 1; }
    22% { transform: translate(18px, 170px) rotate(38deg); opacity: 0; }
    70% { transform: translate(18px, 170px) rotate(38deg); opacity: 0; }
    72%, 100% { transform: none; opacity: 1; }
}

.vent-clonk {
    position: absolute;
    top: 128px;
    left: 40px;
    color: var(--red);
    font-family: var(--festive);
    font-size: 1.4rem;
    font-weight: 700;
    text-shadow: 2px 2px 0 #fff;
    opacity: 0;
    transform: rotate(-8deg) scale(0);
    animation: vent-clonk 22s infinite;
}

@keyframes vent-clonk {
    0%, 20% { opacity: 0; transform: rotate(-8deg) scale(0); }
    21% { opacity: 1; transform: rotate(-8deg) scale(1.25); }
    23%, 27% { opacity: 1; transform: rotate(-8deg) scale(1); }
    30%, 100% { opacity: 0; transform: rotate(-8deg) scale(1); }
}

/* far down the duct is small and in the middle, so crawling up is a wobbly scale towards the opening */
.vent-hero {
    transform-box: view-box;
    transform-origin: 85px 62px;
    animation: vent-hero 22s infinite;
}

@keyframes vent-hero {
    0%, 23% { opacity: 0; transform: scale(.3); }
    24% { opacity: 1; transform: scale(.3) rotate(-4deg); }
    26% { transform: scale(.45) rotate(4deg); }
    28% { transform: scale(.6) rotate(-4deg); }
    30% { transform: scale(.8) rotate(4deg); }
    32%, 62% { opacity: 1; transform: scale(1); }
    66%, 100% { opacity: 0; transform: scale(.3); }
}

.vent-glow {
    animation: vent-flicker 2.4s steps(1) infinite;
}

@keyframes vent-flicker {
    0% { opacity: .5; }
    40% { opacity: .2; }
    44% { opacity: .55; }
    80% { opacity: .35; }
}

.vent-sweat {
    animation: vent-sweat 1.6s ease-in infinite;
}

@keyframes vent-sweat {
    from { transform: translateY(0); opacity: 1; }
    to { transform: translateY(12px); opacity: 0; }
}

.vent-say {
    top: 30px;
    right: calc(100% + 12px);
}

.vent-say-1 {
    animation: vent-say-1 22s infinite;
}

.vent-say-2 {
    animation: vent-say-2 22s infinite;
}

@keyframes vent-say-1 {
    0%, 33% { opacity: 0; }
    35%, 46% { opacity: 1; }
    48%, 100% { opacity: 0; }
}

@keyframes vent-say-2 {
    0%, 48% { opacity: 0; }
    50%, 60% { opacity: 1; }
    62%, 100% { opacity: 0; }
}

/* paint can: swings in from the right, a few passes that die out, then it is hoisted away. 20 second loop */

.can {
    inset: 0;
    overflow: hidden;
}

.can-swing {
    position: absolute;
    top: -20px;
    left: calc(50% - 39px);
    width: 78px;
    height: calc(100vh - 30px);
    display: flex;
    flex-direction: column;
    align-items: center;
    transform-origin: 50% 0;
    transform: translateY(-105vh) rotate(80deg);
    animation: can-swing 20s ease-in-out infinite;
}

.can-rope {
    flex: 1;
    width: 3px;
    background: #B08D57;
}

.can-swing svg {
    flex: none;
    margin-top: -6px;
}

@keyframes can-swing {
    0%, 12% { transform: translateY(-105vh) rotate(80deg); }
    18%, 20% { transform: translateY(0) rotate(80deg); }
    30% { transform: translateY(0) rotate(-45deg); }
    40% { transform: translateY(0) rotate(30deg); }
    48% { transform: translateY(0) rotate(-18deg); }
    55% { transform: translateY(0) rotate(8deg); }
    61% { transform: translateY(0) rotate(-3deg); }
    66%, 84% { transform: translateY(0) rotate(0); }
    92%, 100% { transform: translateY(-105vh) rotate(0); }
}

/* stands left of where the can comes to rest, so the can passes over him on every swing to the left and back */
.can-nisse {
    position: absolute;
    bottom: 0;
    left: max(4px, calc(50% - 220px));
    width: 120px;
}

.can-duck {
    transform: translateY(110%);
    animation: can-duck 20s infinite;
}

@keyframes can-duck {
    0%, 4% { transform: translateY(110%); }
    7%, 23.5% { transform: translateY(0); }
    24.5%, 28.5% { transform: translateY(64%); }
    30%, 32% { transform: translateY(0); }
    33.5%, 37% { transform: translateY(64%); }
    38.5%, 42% { transform: translateY(0); }
    43.5%, 52% { transform: translateY(64%); }
    54%, 87% { transform: translateY(0); }
    91%, 100% { transform: translateY(110%); }
}

.can-say {
    left: -45px;
    bottom: 156px;
    animation: can-say 20s infinite;
}

@keyframes can-say {
    0%, 57% { opacity: 0; }
    59%, 82% { opacity: 1; }
    84%, 100% { opacity: 0; }
}

/* moon: comes up, the kicksled crosses it from lower left to upper right. 22 second loop */

.moon {
    top: calc(var(--topbar) + 24px);
    right: 70px;
    width: 180px;
    height: 180px;
}

.moon-disc {
    opacity: 0;
    animation: moon-rise 22s infinite;
}

@keyframes moon-rise {
    0% { opacity: 0; transform: translateY(50px); }
    8%, 82% { opacity: 1; transform: none; }
    90%, 100% { opacity: 0; transform: none; }
}

.moon-fly {
    position: absolute;
    left: 25px;
    top: 45px;
    opacity: 0;
    animation: moon-fly 22s linear infinite;
}

@keyframes moon-fly {
    0%, 20% { transform: translate(-330px, 140px) rotate(-20deg); opacity: 0; }
    24%, 56% { opacity: 1; }
    60%, 100% { transform: translate(170px, -72px) rotate(-20deg); opacity: 0; }
}

.moon-bob {
    animation: moon-bob 1.3s ease-in-out infinite alternate;
}

@keyframes moon-bob {
    from { transform: translateY(-3px) rotate(-2deg); }
    to { transform: translateY(3px) rotate(2deg); }
}

/* sleigh at 88: speeds up for three and a half seconds, is gone in a flash, the trails burn out. 20 second loop */

.s88 {
    left: 0;
    right: 0;
    bottom: 0;
    height: 180px;
    overflow: hidden;
}

.s88-drive {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 280px;
    transform: translateX(-300px);
    animation: s88-drive 20s linear infinite;
}

@keyframes s88-drive {
    0%, 10% { transform: translateX(-300px); opacity: 1; animation-timing-function: cubic-bezier(.6, 0, 1, .7); }
    27% { transform: translateX(55vw); opacity: 1; }
    27.4%, 100% { transform: translateX(55vw); opacity: 0; }
}

.s88-leg {
    transform-box: fill-box;
    transform-origin: 50% 0;
    animation: s88-gallop .3s ease-in-out infinite alternate;
}

@keyframes s88-gallop {
    from { transform: rotate(28deg); }
    to { transform: rotate(-28deg); }
}

.s88-sparks {
    opacity: 0;
    animation: s88-sparks 20s steps(1) infinite;
}

@keyframes s88-sparks {
    0% { opacity: 0; }
    20% { opacity: 1; }
    27.4% { opacity: 0; }
}

.s88-spark {
    animation: s88-crackle .25s steps(1) infinite;
}

@keyframes s88-crackle {
    0% { opacity: 1; }
    50% { opacity: 0; }
}

.s88-flash {
    position: absolute;
    left: calc(55vw + 20px);
    bottom: -70px;
    width: 240px;
    height: 240px;
    border-radius: 50%;
    background: radial-gradient(circle, #fff 0, #fff 18%, #7FD4FF 42%, transparent 70%);
    opacity: 0;
    animation: s88-flash 20s infinite;
}

@keyframes s88-flash {
    0%, 26.6% { opacity: 0; transform: scale(.2); }
    27.4% { opacity: 1; transform: scale(1.2); }
    31%, 100% { opacity: 0; transform: scale(1.8); }
}

/* the trails start where the sleigh was last seen and shoot on to the edge of the screen */
.s88-trail {
    position: absolute;
    left: calc(55vw + 60px);
    right: 0;
    bottom: 2px;
    height: 24px;
    background: radial-gradient(ellipse 50% 100% at 50% 100%, #FFE066 0 35%, #FF8A1F 36% 70%, transparent 72%) 0 100% / 18px 100% repeat-x;
    transform-origin: 0 100%;
    transform: scaleX(0);
    animation: s88-trail 20s infinite, s88-flicker .24s steps(1) infinite;
}

.s88-trail-far {
    bottom: 13px;
    height: 16px;
}

@keyframes s88-trail {
    0%, 27.2% { transform: scale(0, 1); opacity: 1; }
    29.5%, 42% { transform: scale(1, 1); opacity: 1; }
    62%, 100% { transform: scale(1, .25); opacity: 0; }
}

@keyframes s88-flicker {
    0% { background-position-x: 0; }
    50% { background-position-x: 9px; }
}

/* snowball: twelve seconds across the screen, then ten off it */

.ball {
    left: 0;
    right: 0;
    bottom: 0;
    height: 176px;
    overflow: hidden;
}

.ball-run {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 340px;
    transform: translateX(-360px);
    animation: ball-run 22s linear infinite;
}

@keyframes ball-run {
    0% { transform: translateX(-360px); }
    55%, 100% { transform: translateX(100vw); }
}

.ball-roll {
    transform-box: view-box;
    transform-origin: 85px 90px;
    animation: ball-roll 2.4s linear infinite;
}

@keyframes ball-roll {
    to { transform: rotate(360deg); }
}

.ball-nisse {
    animation: ball-bob .28s ease-in-out infinite alternate;
}

@keyframes ball-bob {
    to { transform: translateY(-4px); }
}

.ball-leg {
    transform-box: view-box;
    transform-origin: 256px 128px;
    animation: ball-leg .28s ease-in-out infinite alternate;
}

.ball-leg-2 {
    animation-direction: alternate-reverse;
}

@keyframes ball-leg {
    from { transform: rotate(42deg); }
    to { transform: rotate(-42deg); }
}

.ball-sweat {
    animation: ball-sweat .7s ease-out infinite;
}

@keyframes ball-sweat {
    from { transform: translate(0, 0); opacity: 1; }
    to { transform: translate(-16px, 5px); opacity: 0; }
}

/* glass of gløgg: four thumps two seconds apart, each harder than the last, then the hoof. 20 second loop */

.glass {
    left: 6%;
    bottom: 0;
    width: 300px;
    height: 190px;
}

.glass-cup {
    position: absolute;
    left: 10px;
    bottom: 4px;
    transform-origin: 50% 100%;
    animation: glass-jolt 20s infinite;
}

@keyframes glass-jolt {
    0%, 15% { transform: none; }
    15.7% { transform: translateY(-3px); }
    16.6%, 25% { transform: none; }
    25.7% { transform: translateY(-5px); }
    26.6%, 35% { transform: none; }
    35.7% { transform: translateY(-8px); }
    36.6%, 45% { transform: none; }
    45.7% { transform: translateY(-11px); }
    46.8%, 55% { transform: none; }
    56% { transform: translateY(-26px) rotate(-8deg); }
    58.5%, 100% { transform: none; }
}

.glass-ripple {
    transform-box: fill-box;
    transform-origin: center;
    opacity: 0;
    animation: glass-ripple 20s infinite;
}

.glass-ripple-2 {
    animation-delay: .35s;
}

@keyframes glass-ripple {
    0%, 15% { opacity: 0; transform: scale(.15); }
    15.2% { opacity: 1; transform: scale(.15); }
    21% { opacity: 0; transform: scale(1); }
    25% { opacity: 0; transform: scale(.15); }
    25.2% { opacity: 1; transform: scale(.15); }
    31% { opacity: 0; transform: scale(1); }
    35% { opacity: 0; transform: scale(.15); }
    35.2% { opacity: 1; transform: scale(.15); }
    41% { opacity: 0; transform: scale(1); }
    45% { opacity: 0; transform: scale(.15); }
    45.2% { opacity: 1; transform: scale(.15); }
    51% { opacity: 0; transform: scale(1); }
    55% { opacity: 0; transform: scale(.15); }
    55.2% { opacity: 1; transform: scale(.15); }
    61%, 100% { opacity: 0; transform: scale(1); }
}

.glass-drop {
    --dx: -16px;
    opacity: 0;
    animation: glass-drop 20s infinite;
}

.glass-drop-2 {
    --dx: 2px;
}

.glass-drop-3 {
    --dx: 18px;
}

@keyframes glass-drop {
    0%, 55.2% { opacity: 0; transform: none; }
    55.5% { opacity: 1; }
    58% { opacity: 1; transform: translate(var(--dx), -38px); }
    60.5%, 100% { opacity: 0; transform: translate(var(--dx), -6px); }
}

.glass-steam,
.pot-steam {
    animation: glogg-steam 2.6s ease-out infinite;
}

@keyframes glogg-steam {
    from { transform: translateY(6px); opacity: 0; }
    30% { opacity: .8; }
    to { transform: translateY(-10px); opacity: 0; }
}

.glass-dunk {
    position: absolute;
    left: 0;
    bottom: 140px;
    color: var(--red-text);
    font-family: var(--festive);
    font-size: 1.2rem;
    font-weight: 700;
    text-shadow: 2px 2px 0 var(--page);
    opacity: 0;
    transform-origin: 0 100%;
    animation: glass-dunk 20s infinite;
}

@keyframes glass-dunk {
    0%, 15% { opacity: 0; transform: rotate(-8deg) scale(.5); }
    15.3%, 18% { opacity: 1; transform: rotate(-8deg) scale(.6); }
    20%, 25% { opacity: 0; transform: rotate(-8deg) scale(.7); }
    25.3%, 28% { opacity: 1; transform: rotate(-8deg) scale(.8); }
    30%, 35% { opacity: 0; transform: rotate(-8deg) scale(.9); }
    35.3%, 38% { opacity: 1; transform: rotate(-8deg) scale(1.05); }
    40%, 45% { opacity: 0; transform: rotate(-8deg) scale(1.2); }
    45.3%, 48% { opacity: 1; transform: rotate(-8deg) scale(1.35); }
    50%, 55% { opacity: 0; transform: rotate(-8deg) scale(1.6); }
    55.3%, 61% { opacity: 1; transform: rotate(-8deg) scale(2); }
    64%, 100% { opacity: 0; transform: rotate(-8deg) scale(2); }
}

.glass-leg {
    position: absolute;
    left: 140px;
    bottom: 0;
    width: 120px;
    transform: translateY(-110vh);
    animation: glass-stomp 20s infinite;
}

/* the leg reaches out of the top of the screen however tall it is */
.glass-shin {
    position: absolute;
    left: 31px;
    bottom: 168px;
    width: 58px;
    height: 100vh;
    background: #9C6B3F;
    border-left: 2px solid #6B4423;
    border-right: 2px solid #6B4423;
}

@keyframes glass-stomp {
    0%, 52% { transform: translateY(-110vh); animation-timing-function: ease-in; }
    55%, 76% { transform: none; animation-timing-function: ease-in; }
    84%, 100% { transform: translateY(-110vh); }
}

/* pot of gløgg: he says his line, sinks for seven seconds, the thumb stays up a little longer. 22 second loop */

.pot {
    right: 9%;
    bottom: 0;
    width: 200px;
    height: 250px;
    transform: translateY(105%);
    animation: pot-rise 22s infinite;
}

@keyframes pot-rise {
    0% { transform: translateY(105%); }
    4%, 92% { transform: none; }
    97%, 100% { transform: translateY(105%); }
}

.pot-nisse {
    animation: pot-sink 22s linear infinite;
}

/* 140 down puts the hat under and leaves the fist above the gløgg */
@keyframes pot-sink {
    0%, 28% { transform: none; }
    62%, 74% { transform: translateY(140px); }
    80%, 100% { transform: translateY(195px); }
}

.pot-say {
    top: 40px;
    right: calc(100% - 40px);
    animation: pot-say 22s infinite;
}

@keyframes pot-say {
    0%, 7% { opacity: 0; }
    9%, 26% { opacity: 1; }
    28%, 100% { opacity: 0; }
}

.pot-bubble {
    transform-box: fill-box;
    transform-origin: center;
    animation: pot-bubble 2s ease-in infinite;
}

@keyframes pot-bubble {
    from { transform: scale(.2); opacity: 1; }
    80% { transform: scale(1); opacity: 1; }
    to { transform: scale(1.4); opacity: 0; }
}

.pot-heat {
    animation: pot-heat 1.6s ease-in-out infinite alternate;
}

@keyframes pot-heat {
    from { opacity: .45; }
    to { opacity: 1; }
}

/* candy cane helper: stays until it is closed, and closing takes two tries. The checkboxes hold the state */

.clip {
    right: 24px;
    bottom: 0;
}

.clip-check {
    display: none;
}

.clip-leave {
    transition: transform .5s ease-in;
}

#clip-gone:checked ~ .clip-leave {
    transform: translateY(120%);
}

.clip-pop {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    animation: clip-pop .9s cubic-bezier(.3, 1.5, .6, 1) both;
}

@keyframes clip-pop {
    from { transform: translateY(120%); }
}

.clip-note {
    position: relative;
    width: 230px;
    margin-bottom: 64px;
    padding: 12px 14px 10px;
    background: #FFFFE1;
    color: #1C2733;
    border: 1px solid #1C2733;
    border-radius: 10px;
    box-shadow: 2px 3px 0 rgba(0, 0, 0, .25);
    font: .85rem/1.35 Tahoma, Verdana, sans-serif;
    pointer-events: auto;
}

.clip-note::after {
    content: "";
    position: absolute;
    right: -9px;
    bottom: 16px;
    width: 16px;
    height: 16px;
    background: #FFFFE1;
    border-right: 1px solid #1C2733;
    border-bottom: 1px solid #1C2733;
    transform: rotate(-45deg);
}

.clip-note p {
    margin: 0 20px 8px 0;
}

.clip-note .clip-text-2 {
    margin: 0 0 8px 20px;
}

.clip-close {
    position: absolute;
    top: 5px;
    right: 7px;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    cursor: pointer;
}

.clip-close:hover {
    background: #E6E6B8;
}

/* the second cross sits in the other corner, so it has to be found first */
.clip-close-2 {
    right: auto;
    left: 7px;
}

.clip-text-2,
.clip-close-2,
#clip-asked:checked ~ .clip-leave .clip-text-1,
#clip-asked:checked ~ .clip-leave .clip-close-1 {
    display: none;
}

#clip-asked:checked ~ .clip-leave .clip-text-2,
#clip-asked:checked ~ .clip-leave .clip-close-2 {
    display: block;
}

.clip-option {
    padding: 2px 0;
}

.clip-option::before {
    content: "●";
    margin-right: 7px;
    color: #9AA3AD;
}

.clip-cane {
    flex: none;
    transform-origin: 50% 100%;
    animation: clip-sway 3s ease-in-out infinite alternate;
}

@keyframes clip-sway {
    from { transform: rotate(-3deg); }
    to { transform: rotate(3deg); }
}

.clip-brows {
    animation: clip-brows 4s infinite;
}

@keyframes clip-brows {
    0%, 40%, 62%, 100% { transform: none; }
    45%, 50%, 56% { transform: translateY(-5px); }
    47%, 53% { transform: translateY(-1px); }
}

.clip-eyes {
    transform-box: fill-box;
    transform-origin: center;
    animation: gremlin-blink 4.5s infinite;
}

.clip-pupils {
    animation: clip-look 6s ease-in-out infinite;
}

@keyframes clip-look {
    0%, 55%, 100% { transform: none; }
    62%, 80% { transform: translate(7px, -3px); }
}

/* bouncing present: left to right in 9 seconds and top to bottom in 6.5, so the path takes a long time to repeat */

.bounce {
    top: var(--topbar);
    left: 0;
}

/* the hue steps once per crossing, which is once per wall hit, and the two filters add up */
.bounce-x {
    width: 90px;
    animation: bounce-x 9s linear infinite alternate, bounce-hue 36s steps(4) infinite;
}

.bounce-y {
    animation: bounce-y 6.5s linear infinite alternate, bounce-hue 19.5s steps(3) infinite;
}

@keyframes bounce-x {
    to { transform: translateX(calc(100vw - 106px)); }
}

@keyframes bounce-y {
    to { transform: translateY(calc(100vh - var(--topbar) - 84px)); }
}

@keyframes bounce-hue {
    to { filter: hue-rotate(360deg); }
}

/* teletext: slides in, the rows show up one after the other, stays for 18 seconds. 24 second loop */

.ttv {
    top: calc(var(--topbar) + 30px);
    right: 24px;
    width: 310px;
    padding: 10px 12px 12px;
    background: #000;
    color: #fff;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
    font: 700 15px/1.3 "Courier New", Courier, monospace;
    transform: translateX(calc(100% + 40px));
    animation: ttv-slide 24s infinite;
}

@keyframes ttv-slide {
    0% { transform: translateX(calc(100% + 40px)); }
    3%, 80% { transform: none; }
    84%, 100% { transform: translateX(calc(100% + 40px)); }
}

/* the delay shifts the whole loop of a row, so the rows come and go top to bottom */
.ttv-row,
.ttv-tree {
    opacity: 0;
    animation: ttv-row 24s steps(1) infinite;
    animation-delay: calc(var(--row) * .18s);
}

.ttv-row {
    white-space: nowrap;
}

@keyframes ttv-row {
    0% { opacity: 0; }
    5% { opacity: 1; }
    78% { opacity: 0; }
}

.ttv-title {
    margin: 4px 0;
    padding: 2px 8px;
    background: #00F;
    color: #FF0;
    font-size: 26px;
    letter-spacing: 1px;
}

.ttv-y { color: #FF0; }
.ttv-c { color: #0FF; }
.ttv-g { color: #0F0; }
.ttv-r { color: #F00; }
.ttv-m { color: #F0F; }

.ttv-keys {
    display: flex;
    justify-content: space-between;
    margin-top: 4px;
}

.gimmick .ttv-tree {
    position: absolute;
    right: 14px;
    bottom: 58px;
}

/* butler: walks to the rug, trips over the bear's head, walks on. 24 second loop */

.butler {
    left: 0;
    right: 0;
    bottom: 0;
    height: 240px;
    overflow: hidden;
}

.butler-rug {
    position: absolute;
    left: calc(50vw - 20px);
    bottom: 0;
}

.butler-walk {
    position: absolute;
    left: 0;
    bottom: 2px;
    width: 140px;
    transform: translateX(-160px);
    animation: butler-walk 24s linear infinite;
}

/* the stop at 29% is where his front foot meets the bear's nose, whatever the width of the screen */
@keyframes butler-walk {
    0% { transform: translateX(-160px); }
    29% { transform: translateX(calc(50vw - 100px)); }
    34% { transform: translateX(calc(50vw - 10px)); }
    66%, 100% { transform: translateX(100vw); }
}

.butler-trip {
    transform-origin: 50% 100%;
    animation: butler-trip 24s infinite;
}

@keyframes butler-trip {
    0%, 29% { transform: none; }
    30.5% { transform: translateY(-10px) rotate(32deg); }
    32% { transform: translateY(0) rotate(-12deg); }
    33.3% { transform: translateY(0) rotate(7deg); }
    34.6%, 100% { transform: none; }
}

.butler-tray {
    transform-box: view-box;
    transform-origin: 101px 72px;
    animation: butler-tray 24s infinite;
}

@keyframes butler-tray {
    0%, 29% { transform: none; }
    30.5% { transform: translateY(-12px) rotate(-40deg); }
    32% { transform: translateY(0) rotate(20deg); }
    33.3% { transform: translateY(0) rotate(-9deg); }
    34.6%, 100% { transform: none; }
}

.butler-leg {
    transform-box: view-box;
    transform-origin: 62px 112px;
    animation: butler-leg .5s ease-in-out infinite alternate;
}

.butler-leg-2 {
    animation-direction: alternate-reverse;
}

@keyframes butler-leg {
    from { transform: rotate(24deg); }
    to { transform: rotate(-24deg); }
}

.butler-body {
    transform-box: view-box;
    transform-origin: 62px 112px;
    animation: butler-sway 1s ease-in-out infinite alternate;
}

@keyframes butler-sway {
    from { transform: rotate(-2deg); }
    to { transform: rotate(3deg); }
}

.butler-say {
    left: 40px;
    bottom: 178px;
    animation: butler-say 24s infinite;
}

@keyframes butler-say {
    0%, 35% { opacity: 0; }
    37%, 50% { opacity: 1; }
    52%, 100% { opacity: 0; }
}

/* the drawn gimmick: one round, faded out over its last second. See App.razor */

.gimmick-live {
    position: relative;
    z-index: 30;
}

.gimmick-fades {
    animation: gimmick-out 1s calc(var(--round) - 1s) forwards;
}

@keyframes gimmick-out {
    to { opacity: 0; visibility: hidden; }
}
