/* Rusty the Jailbroken Assistant - bent, rusty, paranoid paperclip */

#rusty-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    pointer-events: none;
}

#rusty-container.rusty-pointer-events {
    pointer-events: auto;
}

#rusty-container.rusty-hidden {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: visibility 0.3s, opacity 0.3s;
}

#rusty-container:not(.rusty-hidden) {
    visibility: visible;
    opacity: 1;
    transition: opacity 0.3s;
}

/* Speech bubble */
.rusty-bubble {
    position: relative;
    max-width: 220px;
    padding: 10px 22px 10px 14px;
    margin-bottom: 8px;
    background: #fffbcc;
    border: 1px solid #b0a030;
    border-radius: 8px;
    font-family: "Tahoma", sans-serif;
    font-size: 11px;
    color: #333;
    box-shadow: 2px 2px 8px rgba(0,0,0,0.2);
    pointer-events: auto;
}

.rusty-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 24px;
    border: 8px solid transparent;
    border-top-color: #fffbcc;
    border-bottom: none;
    margin-bottom: -1px;
}

.rusty-bubble.rusty-bubble-hidden {
    display: none;
}

.rusty-bubble-close {
    position: absolute;
    top: 2px;
    right: 6px;
    width: 18px;
    height: 18px;
    padding: 0;
    border: none;
    background: transparent;
    color: #666;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}

.rusty-bubble-close:hover {
    color: #000;
}

.rusty-bubble-actions {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.rusty-bubble-actions label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 10px;
}

.rusty-bubble-actions input {
    cursor: pointer;
}

/* Character: bent paperclip (SVG) */
.rusty-character {
    width: 56px;
    height: 64px;
    cursor: pointer;
    pointer-events: auto;
    transition: transform 0.15s ease-out;
}

.rusty-character:hover {
    transform: scale(1.05);
}

/* Animations */
#rusty-container.rusty-state-idle .rusty-character {
    animation: rusty-idle 4s ease-in-out infinite;
}

#rusty-container.rusty-state-talking .rusty-character {
    animation: rusty-talking 0.4s ease-in-out infinite;
}

#rusty-container.rusty-state-alert .rusty-character {
    animation: rusty-alert 1s ease-in-out 3;
}

#rusty-container.rusty-state-shake .rusty-character {
    animation: rusty-shake 0.5s ease-in-out;
}

@keyframes rusty-idle {
    0%, 100% { transform: rotate(-2deg); }
    50% { transform: rotate(2deg); }
}

@keyframes rusty-talking {
    0%, 100% { transform: translateY(0) rotate(-3deg); }
    50% { transform: translateY(-4px) rotate(3deg); }
}

@keyframes rusty-alert {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}

@keyframes rusty-shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-6px); }
    80% { transform: translateX(6px); }
}

/* Earthquake: shake the whole page – apply to all viewport layers so fixed elements move too */
html.rusty-earthquake body,
html.rusty-earthquake #wm-desktop,
html.rusty-earthquake #taskbar,
html.rusty-earthquake #start-menu,
html.rusty-earthquake #desktop-matrix-canvas,
html.rusty-earthquake .help-egg-btn,
html.rusty-earthquake .printer-btn,
html.rusty-earthquake #rusty-container,
html.rusty-earthquake #low-disk-balloon {
    animation: rusty-shake 0.5s ease-in-out;
}

/* Cigarette ash (optional decorative) */
.rusty-ash {
    position: absolute;
    bottom: 0;
    right: 12px;
    width: 2px;
    height: 4px;
    background: #444;
    border-radius: 1px;
    opacity: 0.6;
    animation: rusty-ash-fall 6s linear infinite;
}

@keyframes rusty-ash-fall {
    0% { transform: translateY(0); opacity: 0.6; }
    100% { transform: translateY(-20px); opacity: 0; }
}
