/* ===== DWAJO floating ghost mascot ===== */

.dwajo-mascot {
    position: fixed;
    top: 60%;
    left: 16px;
    width: 92px;
    z-index: 850;
    touch-action: none;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    transition: left 1.4s cubic-bezier(.45,.05,.55,.95), top 1.4s cubic-bezier(.45,.05,.55,.95);
    will-change: left, top;
}
.dwajo-mascot.dragging {
    transition: none;
    cursor: grabbing;
    z-index: 950;
}
.dwajo-mascot:focus-visible .dwajo-mascot-art {
    outline: 3px solid #7a1f1f;
    outline-offset: 4px;
    border-radius: 50%;
}

.dwajo-flip {
    display: block;
    transform: scaleX(1);
    transition: transform .35s ease;
}
.dwajo-mascot.facing-left .dwajo-flip {
    transform: scaleX(-1);
}

.dwajo-bob {
    display: block;
    animation: dwajo-bob 2.4s ease-in-out infinite;
}
.dwajo-mascot.dragging .dwajo-bob {
    animation: none;
}

.dwajo-mascot-art {
    display: block;
    width: 100%;
    height: auto;
    filter: drop-shadow(0 10px 10px rgba(61,44,37,.3));
}

@keyframes dwajo-bob {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50%      { transform: translateY(-10px) rotate(-2deg); }
}

/* Speech bubble */
.dwajo-bubble {
    position: absolute;
    left: 50%;
    bottom: calc(100% + 6px);
    --shift: 0px;
    transform: translateX(-50%) translateX(var(--shift)) translateY(6px) scale(.92);
    min-width: 140px;
    max-width: 200px;
    background: #fffdf9;
    color: #3d2c25;
    border: 2px solid #e7cdac;
    border-radius: 16px;
    padding: 8px 12px;
    font-family: inherit;
    font-size: 0.82rem;
    line-height: 1.25;
    font-weight: 600;
    text-align: center;
    box-shadow: 0 8px 18px rgba(61,44,37,.18);
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s ease, transform .3s ease;
    white-space: normal;
}
.dwajo-bubble::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 100%;
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: #e7cdac;
}
.dwajo-bubble::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 100%;
    margin-top: -2px;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: #fffdf9;
    z-index: 1;
}
.dwajo-bubble.show {
    opacity: 1;
    transform: translateX(-50%) translateX(var(--shift)) translateY(0) scale(1);
}

/* When the ghost is near the top of the screen, show the bubble below it instead */
.dwajo-mascot.bubble-below .dwajo-bubble {
    bottom: auto;
    top: calc(100% + 6px);
    transform: translateX(-50%) translateX(var(--shift)) translateY(-6px) scale(.92);
}
.dwajo-mascot.bubble-below .dwajo-bubble.show {
    transform: translateX(-50%) translateX(var(--shift)) translateY(0) scale(1);
}
.dwajo-mascot.bubble-below .dwajo-bubble::after {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: #e7cdac;
}
.dwajo-mascot.bubble-below .dwajo-bubble::before {
    top: auto;
    bottom: 100%;
    margin-top: 0;
    margin-bottom: -2px;
    border-top-color: transparent;
    border-bottom-color: #fffdf9;
}
/* The bubble is a sibling of the flipped character art, not a child of it,
   so it never needs its own flip transform — this keeps its text always
   reading left-to-right regardless of which way the mascot is facing. */

@media (max-width: 640px) {
    .dwajo-mascot { width: 70px; }
    .dwajo-bubble { font-size: 0.74rem; max-width: 155px; min-width: 110px; padding: 7px 10px; }
}

@media (prefers-reduced-motion: reduce) {
    .dwajo-mascot { transition: none; }
    .dwajo-bob { animation: none; }
}

/* Eyes glance up while scrolling down, and down while scrolling up */
.dwajo-mascot .dwajo-eye,
.dwajo-mascot .dwajo-eye-shine {
    transition: transform .25s ease;
    transform-box: fill-box;
    transform-origin: center;
}
.dwajo-mascot.looking-up .dwajo-eye,
.dwajo-mascot.looking-up .dwajo-eye-shine {
    transform: translateY(-4px);
}
.dwajo-mascot.looking-down .dwajo-eye,
.dwajo-mascot.looking-down .dwajo-eye-shine {
    transform: translateY(3px);
}