/* Custom specific styles overriding or extending Tailwind */

/* Core variables */
:root {
    --glass-bg: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.08);
}

/* Base Body settings */
body {
    background-color: #030014; /* Deep Space Black */
    color: #ffffff;
}

/* Glassmorphism Utilities */
.glass-effect {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

/* Bento Cards Styling with mouse tracking glow */
.bento-card {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 1.5rem; /* 24px */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    will-change: transform;
    position: relative;
    overflow: hidden;
}

/* Mouse tracking border/glow effect */
.bento-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: inherit;
    padding: 2px; /* Border thickness */
    background: radial-gradient(
        800px circle at var(--mouse-x, 50%) var(--mouse-y, 50%), 
        rgba(139, 92, 246, 0.4),
        transparent 40%
    );
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.bento-card:hover::before {
    opacity: 1;
}

/* Inner glow on hover */
.bento-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(
        600px circle at var(--mouse-x, 50%) var(--mouse-y, 50%), 
        rgba(139, 92, 246, 0.08),
        transparent 40%
    );
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    z-index: -1;
}

.bento-card:hover::after {
    opacity: 1;
}

.bento-card:hover {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    transform: translateY(-2px);
}

/* Tech badge */
.tech-badge {
    padding: 0.5rem 1rem;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
}

.tech-badge:hover {
    background: rgba(139, 92, 246, 0.2);
    border-color: rgba(139, 92, 246, 0.5);
    color: #fff;
}

/* Custom Text Glow like Magic UI */
.glow-text {
    text-shadow: 0 0 30px rgba(139, 92, 246, 0.4);
}

/* --- Animations (Framer Motion Mimic) --- */
.reveal-anim {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal-anim.visible {
    opacity: 1;
    transform: translateY(0);
}

.delay-100 {
    transition-delay: 100ms;
}

.delay-200 {
    transition-delay: 200ms;
}

/* Fix Canvas z-index */
canvas#bg-canvas {
    position: fixed !important;
    top: 0;
    left: 0;
    z-index: -10;
}

/* --- ADVANCED SPACE CURSOR --- */

/* 1. Star Core (Dot) */
#cursor-dot {
    position: fixed;
    top: 0;
    left: 0;
    width: 6px;
    height: 6px;
    background-color: #fff;
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 1000;
    box-shadow: 0 0 10px #00f0ff, 0 0 20px #8B5CF6, 0 0 30px #8B5CF6;
    transition: transform 0.1s ease-out;
}

/* 2. HUD Orbit Ring */
#cursor-ring {
    position: fixed;
    top: 0;
    left: 0;
    width: 34px;
    height: 34px;
    border: 1px dashed rgba(0, 240, 255, 0.5);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 999;
    animation: cursorRotate 4s linear infinite;
    transition: width 0.3s ease, height 0.3s ease, border-color 0.3s ease;
}

@keyframes cursorRotate {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* 3. Small Orbiting "Satellite" on the Ring */
#cursor-ring::after {
    content: "";
    position: absolute;
    top: -3px;
    left: 50%;
    width: 4px;
    height: 4px;
    background: #00f0ff;
    border-radius: 50%;
    box-shadow: 0 0 8px #00f0ff;
}

/* 4. Click Effect (Supernova) */
.click-effect {
    position: fixed;
    border: 2px solid #00f0ff;
    border-radius: 50%;
    pointer-events: none;
    z-index: 998;
    transform: translate(-50%, -50%);
    animation: supernova 0.6s ease-out forwards;
}

@keyframes supernova {
    0% { width: 0; height: 0; opacity: 1; border-width: 4px; }
    100% { width: 80px; height: 80px; opacity: 0; border-width: 1px; }
}

/* 5. Space Dust Trail */
.cursor-trail {
    position: fixed;
    width: 3px;
    height: 3px;
    background: #8B5CF6;
    border-radius: 50%;
    pointer-events: none;
    z-index: 997;
    transform: translate(-50%, -50%);
    opacity: 0.6;
}

/* Hover States for Cursor */
body.hovering-link #cursor-dot {
    transform: translate(-50%, -50%) scale(0.5);
    background-color: #00f0ff;
}

body.hovering-link #cursor-ring {
    width: 50px;
    height: 50px;
    border: 2px solid #8B5CF6;
    border-style: solid;
    animation: cursorRotate 1.5s linear infinite; /* Faster rotation on hover */
}

/* --- AI CHATBOT WIDGET --- */
.chat-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 1px solid var(--glass-border);
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    z-index: 900;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.9), rgba(59, 130, 246, 0.9));
    box-shadow: 0 8px 30px rgba(139, 92, 246, 0.5);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    animation: chatPulse 2.5s infinite;
}

.chat-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 10px 40px rgba(139, 92, 246, 0.7);
}

.chat-toggle.active {
    animation: none;
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

@keyframes chatPulse {
    0%, 100% { box-shadow: 0 8px 30px rgba(139, 92, 246, 0.5); }
    50% { box-shadow: 0 8px 30px rgba(139, 92, 246, 0.5), 0 0 0 12px rgba(139, 92, 246, 0.08); }
}

.chat-panel {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 140px);
    border: 1px solid var(--glass-border);
    border-radius: 1.25rem;
    z-index: 901;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    background: rgba(10, 8, 30, 0.85);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.55);
}

.chat-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-bottom: 1px solid var(--glass-border);
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #8B5CF6, #3B82F6);
    color: #fff;
}

.chat-close {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
    color: #cbd5e1;
    cursor: pointer;
    transition: background 0.2s ease;
}

.chat-close:hover {
    background: rgba(255, 255, 255, 0.15);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scrollbar-width: thin;
}

.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(139, 92, 246, 0.4);
    border-radius: 3px;
}

.chat-msg {
    display: flex;
    width: 100%;
}

.chat-msg--user {
    justify-content: flex-end;
}

.chat-msg--bot {
    justify-content: flex-start;
}

.chat-bubble {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.55;
    word-wrap: break-word;
}

.chat-msg--user .chat-bubble {
    background: linear-gradient(135deg, #8B5CF6, #3B82F6);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-msg--bot .chat-bubble {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--glass-border);
    color: #e2e8f0;
    border-bottom-left-radius: 4px;
}

.chat-bubble code {
    background: rgba(139, 92, 246, 0.25);
    padding: 1px 6px;
    border-radius: 6px;
    font-size: 0.82rem;
}

.chat-typing {
    display: flex;
    gap: 5px;
    align-items: center;
}

.chat-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #8B5CF6;
    animation: chatTyping 1.2s infinite ease-in-out;
}

.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

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

.chat-suggest-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 16px 12px;
}

.chat-suggest {
    font-size: 0.75rem;
    padding: 6px 12px;
    border-radius: 9999px;
    background: rgba(139, 92, 246, 0.12);
    border: 1px solid rgba(139, 92, 246, 0.35);
    color: #c4b5fd;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-suggest:hover {
    background: rgba(139, 92, 246, 0.3);
    color: #fff;
}

.chat-form {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    padding: 14px 16px;
    border-top: 1px solid var(--glass-border);
}

.chat-form textarea {
    flex: 1;
    resize: none;
    max-height: 120px;
    padding: 10px 14px;
    border-radius: 14px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.4;
    outline: none;
    transition: border-color 0.2s ease;
}

.chat-form textarea:focus {
    border-color: rgba(139, 92, 246, 0.7);
}

.chat-form textarea::placeholder {
    color: #94a3b8;
}

.chat-send {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #8B5CF6, #3B82F6);
    color: #fff;
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.chat-send:hover:not(:disabled) {
    transform: scale(1.08);
}

.chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

@media (max-width: 480px) {
    .chat-panel {
        right: 16px;
        left: 16px;
        width: auto;
        bottom: 92px;
        height: calc(100vh - 120px);
        max-height: calc(100vh - 120px);
    }
}

/* Large Background Glow */
#cursor-glow {
    position: fixed;
    top: 0;
    left: 0;
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.08) 0%, transparent 70%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 1;
    mix-blend-mode: screen;
}
