/* Fairy lights, transitions, crossfades */

/* ── Fairy Lights ── */
.fairy-lights {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
    filter: blur(0.5px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.fairy-lights.ready {
    opacity: 1;
}

.light,
.fairy-light {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: radial-gradient(circle,
        rgba(255, 255, 255, 1) 0%,
        rgba(255, 255, 255, 0.95) 35%,
        rgba(255, 250, 235, 0.85) 50%,
        rgba(255, 245, 190, 0.6) 65%,
        rgba(253, 215, 120, 0.35) 80%,
        transparent 90%);
    filter: blur(0.8px);
    box-shadow:
        0 0 10px rgba(255, 220, 160, 0.5),
        0 0 20px rgba(255, 220, 160, 0.2);
    animation: twinkle 5s ease-in-out infinite;
    will-change: transform, opacity;
}

@keyframes twinkle {
    0%, 100% {
        opacity: 0.75;
        transform: scale(0.9);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* Night mode: fairy lights glow warmer */
body.night-mode .light,
body.night-mode .fairy-light {
    box-shadow: 0 0 18px rgba(255, 200, 120, 0.9);
}

/* ── Theme crossfade ── */
.theme-transition,
.theme-transition *,
.theme-transition *::before,
.theme-transition *::after {
    transition:
        background-color 0.5s ease,
        background 0.5s ease,
        color 0.5s ease,
        border-color 0.5s ease,
        box-shadow 0.5s ease,
        filter 0.5s ease !important;
}

/* ── Typing indicator ── */
.typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 12px 16px;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--identity-accent);
    animation: typingBounce 1.2s ease-in-out infinite;
    will-change: transform, opacity;
}

.typing-dot:nth-child(2) { animation-delay: 0.15s; }
.typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.4;
    }
    30% {
        transform: translateY(-6px);
        opacity: 1;
    }
}

/* ── Connection status indicator ── */
.connection-status {
    position: fixed;
    bottom: 12px;
    right: 12px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-family: var(--font-body);
    font-weight: 600;
    z-index: 100;
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateY(10px);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.connection-status.visible {
    opacity: 1;
    transform: translateY(0);
}

.connection-status.connected {
    background: rgba(91, 168, 154, 0.15);
    color: var(--color-status-connected);
    border: 1px solid rgba(91, 168, 154, 0.2);
}

.connection-status.disconnected {
    background: rgba(196, 122, 138, 0.15);
    color: var(--color-status-disconnected);
    border: 1px solid rgba(196, 122, 138, 0.2);
}

.connection-status.reconnecting {
    background: rgba(201, 168, 64, 0.15);
    color: var(--color-status-reconnecting);
    border: 1px solid rgba(201, 168, 64, 0.2);
    animation: pulse 1.5s ease-in-out infinite;
    will-change: opacity;
}

.connection-status.paused {
    background: rgba(168, 156, 201, 0.2);
    color: #a89cc9;
    border: 1px solid rgba(168, 156, 201, 0.3);
    cursor: pointer;
    padding: 8px 18px;
    font-size: 0.65rem;
    -webkit-tap-highlight-color: transparent;
}

.connection-status.cached {
    background: rgba(168, 125, 74, 0.18);
    color: #9a6a2c;
    border: 1px solid rgba(168, 125, 74, 0.28);
}

@keyframes pulse {
    0%, 100% { opacity: 0.7; }
    50% { opacity: 1; }
}

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
