/* Peekaboo Elf (Award a Display page only; added by elf-peek.js). Same size and corner as the Peekaboo Santa and Reindeer. */
.clgoa-elf {
    --el-h: 200px;
    --el-w: calc(var(--el-h) * 267 / 400);
    position: fixed;
    right: 0;
    bottom: 0;
    z-index: 9990;
    width: var(--el-w);
    height: var(--el-h);
    pointer-events: none;
}
.clgoa-elf__window {
    position: absolute;
    inset: 0;
    overflow: visible; /* not clipped: the bell's glow reaches past his box when he tilts his head (the screen edge still hides him) */
}
.clgoa-elf__figure {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
    transform: translateX(10%);
    pointer-events: none;
    -webkit-tap-highlight-color: transparent;
}
.clgoa-elf__figure svg { display: block; width: 100%; height: 100%; overflow: visible; }
.clgoa-elf[data-state="peek"] .clgoa-elf__figure,
.clgoa-elf[data-state="out"] .clgoa-elf__figure { pointer-events: auto; cursor: pointer; }
.clgoa-elf__figure:focus-visible { outline: 3px solid var(--clgoa-gold, #ebab32); outline-offset: -3px; }

/* He slides out from behind the right edge, as if peeking around a door frame... */
.clgoa-elf .el-body {
    transform-box: view-box;
    transform-origin: 267px 400px;
    transform: translate(200px, 6px);
    transition: transform 1.6s cubic-bezier(.25, .85, .3, 1);
}
.clgoa-elf[data-state="peek"] .el-body,
.clgoa-elf[data-state="out"] .el-body { transform: translate(0, 0); }
/* ...then leans in a little as he looks at you. */
.clgoa-elf.is-looking .el-body { transform: translate(-3px, 0) rotate(-2deg); transition-duration: .9s; }
.clgoa-elf[data-state="hiding"] .el-body { transform: translate(200px, 6px); transition: transform .9s ease-in; }

/* Then he tilts his head toward you and looks right at you. */
.clgoa-elf .el-head {
    transform-box: view-box;
    transform-origin: 185px 286px; /* his chin, where his head sits on the collar */
    transform: rotate(6deg);
    transition: transform .9s cubic-bezier(.3, .7, .3, 1);
}
.clgoa-elf .el-pupils { transition: transform .5s ease; }
.clgoa-elf.is-looking .el-head { transform: rotate(-6deg) translate(-3px, 2px); }
.clgoa-elf.is-looking .el-pupils { transform: translate(3px, 1px); }

/* He waves like Santa: one little wave as a hint when he looks at you, three when tapped. */
.clgoa-elf .el-hand { transform-box: view-box; transform-origin: 84px 282px; /* his wrist */ }
.clgoa-elf.is-looking .el-hand { animation: clgoa-el-wave 1.1s ease-in-out .5s 2; }
.clgoa-elf[data-state="out"] .el-hand { animation: clgoa-el-wave 1.1s ease-in-out .3s 3; }
.clgoa-elf.is-rewave .el-hand { animation: clgoa-el-wave 1.1s ease-in-out 0s 2; }
@keyframes clgoa-el-wave {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(-16deg); }
    75% { transform: rotate(12deg); }
}

/* The bell on the tip of his hat jingles and glows, and he blinks twice. */
.clgoa-elf .el-bell { transform-box: view-box; transform-origin: 58px 82px; /* where it hangs from the hat tip */ }
.clgoa-elf.is-looking .el-bell { animation: clgoa-el-jingle .6s ease-in-out .4s 6; }
.clgoa-elf.is-reglow .el-bell { animation: clgoa-el-jingle .6s ease-in-out 0s 4; }
@keyframes clgoa-el-jingle {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(14deg); }
    75% { transform: rotate(-10deg); }
}
.clgoa-elf .el-glow { opacity: 0; transform-box: fill-box; transform-origin: center; }
.clgoa-elf.is-looking .el-glow { animation: clgoa-el-glow 1.2s ease-in-out .4s 4; }
.clgoa-elf.is-reglow .el-glow { animation: clgoa-el-glow 1.2s ease-in-out 0s 3; }
.clgoa-elf .el-lid { transform-box: fill-box; transform-origin: 50% 0; transform: scaleY(0); }
.clgoa-elf.is-looking .el-lid { animation: clgoa-el-blink 3s ease-in-out 1.4s 2; }
@keyframes clgoa-el-glow {
    0%, 100% { opacity: .15; transform: scale(.8); }
    50% { opacity: 1; transform: scale(1.25); }
}
@keyframes clgoa-el-blink {
    0%, 7%, 100% { transform: scaleY(0); }
    3.5% { transform: scaleY(1); }
}

/* Speech bubble, to the left of him beside his face (same look as Santa's). */
.clgoa-elf__bubble {
    box-sizing: border-box;
    position: absolute;
    right: calc(100% - 6px);
    bottom: 34%; /* beside his face and waving hand, below the glowing bell */
    width: max-content;
    max-width: min(290px, calc(100vw - var(--el-w) - 16px));
    margin: 0;
    padding: 14px 34px 14px 18px;
    color: var(--clgoa-ink, #252b28);
    font-family: var(--clgoa-sans, sans-serif);
    font-size: 16px;
    font-weight: 700;
    line-height: 1.4;
    background: #fffaf1;
    border: 2px dashed var(--clgoa-red, #c82d20);
    border-radius: 16px;
    box-shadow: 0 10px 24px rgba(17, 73, 41, .18);
    opacity: 0;
    transform: translateY(8px) scale(.92);
    transform-origin: 100% 100%;
    transition: opacity .35s ease, transform .35s ease;
    pointer-events: none;
}
.clgoa-elf__bubble::after {
    content: "";
    position: absolute;
    right: 18px;
    bottom: -11px;
    width: 18px;
    height: 18px;
    background: #fffaf1;
    border-right: 2px dashed var(--clgoa-red, #c82d20);
    border-bottom: 2px dashed var(--clgoa-red, #c82d20);
    transform: rotate(45deg);
}
.clgoa-elf__bubble p { margin: 0; padding: 0; color: inherit; font: inherit; }
.clgoa-elf[data-state="out"] .clgoa-elf__bubble {
    opacity: 1;
    transform: none;
    transition-delay: .3s;
    pointer-events: auto;
}
.clgoa-elf__close {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 28px;
    height: 28px;
    margin: 0;
    padding: 0;
    color: var(--clgoa-muted, #5a625c);
    font: 700 20px/28px var(--clgoa-sans, sans-serif);
    text-align: center;
    background: none;
    border: 0;
    border-radius: 50%;
}
.clgoa-elf__close:hover,
.clgoa-elf__close:focus-visible { color: var(--clgoa-red, #c82d20); background: rgba(200, 45, 32, .08); outline: none; }

/* Three gold sparkles left behind when he ducks away. */
.clgoa-elf__sparkles { position: absolute; inset: 0; pointer-events: none; }
.clgoa-elf__sparkle {
    position: absolute;
    color: var(--clgoa-gold, #ebab32);
    font-size: 18px;
    line-height: 1;
    text-shadow: 0 0 6px rgba(255, 214, 90, .9);
    opacity: 0;
    pointer-events: none;
}
.clgoa-elf__sparkle:nth-of-type(1) { right: 40%; bottom: 82%; }
.clgoa-elf__sparkle:nth-of-type(2) { right: 10%; bottom: 66%; font-size: 13px; }
.clgoa-elf__sparkle:nth-of-type(3) { right: 28%; bottom: 58%; font-size: 15px; }
.clgoa-elf.is-sparkling .clgoa-elf__sparkle { animation: clgoa-el-sparkle 1.4s ease-out both; }
.clgoa-elf.is-sparkling .clgoa-elf__sparkle:nth-of-type(2) { animation-delay: .18s; }
.clgoa-elf.is-sparkling .clgoa-elf__sparkle:nth-of-type(3) { animation-delay: .34s; }
@keyframes clgoa-el-sparkle {
    0% { opacity: 0; transform: translateY(6px) scale(.4) rotate(0); }
    30% { opacity: 1; transform: translateY(0) scale(1.1) rotate(25deg); }
    100% { opacity: 0; transform: translateY(-16px) scale(.6) rotate(70deg); }
}

@media (max-width: 600px) {
    .clgoa-elf { --el-h: 140px; }
    .clgoa-elf__bubble { font-size: 14px; padding: 12px 30px 12px 14px; }
}

/* Visitors who ask for less motion: he fades in and out already out, with no waving, jingling, glow pulses or blinks. */
@media (prefers-reduced-motion: reduce) {
    .clgoa-elf .el-body,
    .clgoa-elf.is-looking .el-body,
    .clgoa-elf[data-state="hiding"] .el-body { transform: none; transition: none; }
    .clgoa-elf__window { opacity: 0; transition: opacity .4s ease; }
    .clgoa-elf[data-state="peek"] .clgoa-elf__window,
    .clgoa-elf[data-state="out"] .clgoa-elf__window { opacity: 1; }
    .clgoa-elf .el-head, .clgoa-elf .el-pupils { transition: none; }
    .clgoa-elf .el-hand, .clgoa-elf .el-bell { animation: none !important; }
    .clgoa-elf .el-glow { animation: none !important; opacity: .7; }
    .clgoa-elf .el-lid { animation: none !important; }
    .clgoa-elf.is-sparkling .clgoa-elf__sparkle { animation: none; }
}

@media print {
    .clgoa-elf { display: none !important; }
}
