/* ===========================
   GLOBAL STYLES & RESET
   =========================== */
* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Poppins', sans-serif;
    background: #0a0a1a;
    color: #e0f0ff;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 0;
}

/* ===========================
   WAVE BACKGROUND CANVAS
   =========================== */
/* Fixed position canvas for quantum wave particle effect */
#wave-canvas {
    position: fixed;
    inset: 0;
    z-index: 0;
    opacity: 1.0;
}

/* ===========================
   MAIN CONTAINER
   =========================== */
/* Main content container with flex layout */
.container {
    z-index: 2;
    text-align: center;
    width: 90%;
    max-width: 500px;
    padding: 2rem 1rem;
    padding-bottom: 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    transition: gap 1.0s ease-out;
    min-height: 100vh;
}

/* Compact state when recording/processing */
.container.compact {
    gap: 0.5rem;
}

/* ===========================
   TITLE STYLING
   =========================== */
/* Gradient text with glow animation */
h1 {
    font-family: 'Exo 2', sans-serif;
    font-size: clamp(1.8rem, 7vw, 4.5rem);
    font-weight: 700;
    letter-spacing: 0.08em;
    background: linear-gradient(90deg, #6e6eff, #00ffff);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 30px rgba(0, 255, 255, 0.4);
    animation: titleGlow 10s infinite alternate;
    white-space: nowrap;
    margin-bottom: clamp(0.5rem, 2vw, 1.4rem);
}

/* Title glow animation */
@keyframes titleGlow {
    from { text-shadow: 0 0 40px rgba(110, 110, 255, 0.5); }
    to   { text-shadow: 0 0 70px rgba(0, 255, 255, 0.9); }
}

/* ===========================
   QUANTUM BALL STYLING
   =========================== */
/* Ball container with 3D perspective */
#ball-container {
    perspective: 1200px;
    margin: clamp(0.5rem, 2vw, 1rem) 0;
    margin-bottom: clamp(2rem, 5vw, 3rem);
}

/* Main ball with neon gradient border and glow effects */
#ball {
    width: clamp(280px, 70vw, 420px);
    height: clamp(280px, 70vw, 420px);
    background: radial-gradient(circle at 35% 35%, #0a0a28, #040410, #000);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
     /* Gradient border using background-clip technique */
    border: 3px solid transparent;
    background-image:
        radial-gradient(circle at 35% 35%, #0a0a28, #040410, #000),
        linear-gradient(135deg,
            #ff00ff 0%,      /* Bright magenta */
            #b844ff 20%,     /* Purple */
            #00b4ff 50%,     /* Bright cyan */
            #00e5ff 80%,     /* Electric blue */
            #00ffff 100%     /* Cyan */
        );
    background-origin: padding-box, border-box;
    background-clip: padding-box, border-box;
    /* Multi-layer neon glow effect */
    box-shadow:
        0 0 20px rgba(0, 255, 255, 0.8),
        0 0 40px rgba(0, 212, 255, 0.7),
        0 0 60px rgba(138, 43, 226, 0.6),
        0 0 80px rgba(0, 150, 255, 0.5),
        0 0 100px rgba(100, 100, 255, 0.4),
        0 0 140px rgba(0, 100, 200, 0.3),
        inset 0 0 80px rgba(0, 0, 0, 0.95);
    animation: idleBreath 4s ease-in-out infinite;
    transition: transform 0.8s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.8s ease;
}

/* Breathing animation for idle state */
@keyframes idleBreath {
    0%, 100% {
        transform: scale(1);
        box-shadow:
            0 0 20px rgba(0, 255, 255, 0.8),
            0 0 40px rgba(0, 212, 255, 0.7),
            0 0 60px rgba(138, 43, 226, 0.6),
            0 0 80px rgba(0, 150, 255, 0.5),
            0 0 100px rgba(100, 100, 255, 0.4),
            0 0 140px rgba(0, 100, 200, 0.3),
            inset 0 0 80px rgba(0, 0, 0, 0.95);
    }
    50% {
        transform: scale(1.02);
        box-shadow:
            0 0 30px rgba(0, 255, 255, 1),
            0 0 60px rgba(0, 212, 255, 0.9),
            0 0 90px rgba(138, 43, 226, 0.8),
            0 0 120px rgba(0, 150, 255, 0.7),
            0 0 150px rgba(100, 100, 255, 0.6),
            0 0 180px rgba(0, 100, 200, 0.4),
            inset 0 0 80px rgba(0, 0, 0, 0.95);
    }
}

/* Ball state when displaying answer */
#ball.answering {
    transform: scale(1.05);
    box-shadow:
        0 0 30px rgba(0, 255, 255, 1),
        0 0 60px rgba(0, 255, 255, 0.9),
        0 0 100px rgba(0, 212, 255, 0.8),
        0 0 140px rgba(138, 43, 226, 0.7),
        0 0 180px rgba(0, 150, 255, 0.5),
        inset 0 0 100px rgba(0, 0, 0, 0.9);
}

/* Ball state when accessing quantum grid */
#ball.accessing {
    animation: pulseFast 1.5s ease-in-out infinite;
}

/* Fast pulse animation for accessing state */
@keyframes pulseFast {
    0%, 100% {
        transform: scale(1);
        box-shadow:
            0 0 25px rgba(0, 255, 255, 0.9),
            0 0 50px rgba(0, 212, 255, 0.8),
            0 0 75px rgba(138, 43, 226, 0.7),
            0 0 100px rgba(0, 150, 255, 0.6),
            0 0 130px rgba(100, 100, 255, 0.5);
    }
    50% {
        transform: scale(1.04);
        box-shadow:
            0 0 40px rgba(0, 255, 255, 1),
            0 0 80px rgba(0, 212, 255, 1),
            0 0 120px rgba(138, 43, 226, 0.9),
            0 0 160px rgba(0, 150, 255, 0.8),
            0 0 200px rgba(100, 100, 255, 0.6);
    }
}

/* Inner window/display area of the ball */
#ball-window {
    width: clamp(260px, 66vw, 395px);
    height: clamp(260px, 66vw, 395px);
    background: rgba(5, 5, 20, 0.98);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    border: 3px solid rgba(30, 30, 60, 0.5);
    box-shadow:
        inset 0 0 60px rgba(0, 0, 0, 0.9),
        inset 0 0 100px rgba(0, 0, 0, 0.7);
    padding: clamp(1.5rem, 4vw, 2.5rem);
    overflow-y: auto;
    word-break: break-word;
    position: relative;
    z-index: 2;
}

/* ===========================
   BALL RESPONSE TEXT
   =========================== */
/* Text displayed inside the ball */
#ball-response {
    font-family: 'Special Elite', sans-serif;
    font-weight: 700;
    font-size: clamp(0.9rem, 2.5vw, 1.25rem);
    line-height: 1.5;
    text-align: center;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.8s ease, transform 0.8s ease;
    position: relative;
    z-index: 3;
}

/* Visible state with fade-in animation */
#ball-response.visible { opacity: 1; transform: translateY(0); }

/* Markdown formatting for bold and italic text */
#ball-response b { font-weight: 900; color: #00ffff; text-shadow: 0 0 15px #0ff; }
#ball-response i { font-style: italic; color: #a0f0ff; }

/* ===========================
   BUTTON STYLING
   =========================== */
/* Base button styles with glassmorphism effect */
.btn {
    font-family: 'Exo 2', sans-serif;
    font-weight: 600;
    font-size: clamp(1.0rem, 2.2vw, 1.1rem);
    padding: clamp(0.7rem, 1.8vw, 1rem) clamp(1.2rem, 3.5vw, 2rem);
    border: none;
    border-radius: 50px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    backdrop-filter: blur(10px);
    background: rgba(255,255,255,0.12);
    color: #fff;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    width: clamp(200px, 50vw, 280px);
    max-width: 90%;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

/* Icon sizing within buttons */
.btn .icon {
    width: clamp(1rem, 2.8vw, 1.4rem);
    height: clamp(1rem, 2.8vw, 1.4rem);
    stroke-width: 2.5;
    flex-shrink: 0;
}
/* Button hover effect */
.btn:hover { transform: translateY(-4px); box-shadow: 0 12px 40px rgba(0,0,0,0.4); }
.btn:active { transform: translateY(0); }

/* Record button gradient */
#record-button { background: linear-gradient(135deg, #6e6eff, #00d0ff);  margin-top: 1rem; }

/* Recording state - red gradient */
#record-button.recording { background: linear-gradient(135deg, #ff5252, #ff1744); }

/* Send button gradient */
#send-button { background: linear-gradient(135deg, #50fa7b, #00e676); }

/* Ripple effect on button click */
.btn::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.3);
    border-radius: 50px;
    transform: scale(0);
    opacity: 0;
}
.btn:active::after { animation: ripple 0.6s ease-out; }

@keyframes ripple {
    to { transform: scale(4); opacity: 0; }
}

/* Microphone icon pulse animation during recording */
#record-button.recording .icon {
    animation: micPulse 1.5s infinite;
}

@keyframes micPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* ===========================
   AUDIO PLAYBACK (Desktop only)
   =========================== */
/* Native audio player styling */
#audio-playback {
    margin: 0.8rem 0;
    width: clamp(200px, 50vw, 280px);
    max-width: 90%;
    height: 54px;
    border-radius: 8px;
    background: transparent;
    backdrop-filter: none;
    border: none;
    box-shadow: none;
    outline: none;
    transition: opacity 0.4s ease;
    opacity: 0.9;
}

/* Hidden state with smooth transition */
#audio-playback[style*="display: none"] {
    opacity: 0;
    height: 0;
    margin: 0;
    overflow: hidden;
}

/* ===========================
   STATUS TEXT
   =========================== */
/* Status messages below buttons */
#status-text {
    margin-top: 0.95rem;
    font-family: 'Exo 2', sans-serif;
    font-size: clamp(0.9rem, 2.5vw, 1.1rem);
    font-weight: 400;
    opacity: 0.9;
    color: #5ce1e6;
    min-height: 28px;
}

/* Accessing state with flash animation */
#status-text.accessing {
    animation: flashText 1.5s ease-in-out infinite;
    color: #4dd0e1;
    text-shadow: 0 0 10px rgba(92, 225, 230, 0.6);
}

/* Text flash animation */
@keyframes flashText {
    0%, 100% {
        opacity: 0.3;
    }
    50% {
        opacity: 0.9;
        text-shadow: 0 0 10px rgba(92, 225, 230, 0.6);
    }
}

/* Animated dots for "Accessing..." */
#status-text.accessing::after {
    content: '...';
    animation: dots 1.5s infinite;
}
@keyframes dots {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

/* ===========================
   UTILITY CLASSES
   =========================== */
/* Hidden state with smooth transitions */
.hidden {
    opacity: 0 !important;
    pointer-events: none;
    height: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

/* ===========================
   RESPONSIVE DESIGN
   =========================== */
/* Desktop: Center content vertically */
@media (min-width: 481px) {
    body {
        align-items: center;
    }
}

/* Mobile optimizations */
@media (max-width: 480px) {
    body {
        align-items: flex-start;
        padding-top: 1rem;
        overflow-y: auto;
    }

    .container {
        gap: 0.2rem;
        padding: 1rem 0.5rem;
        padding-bottom: 2rem;
        justify-content: flex-start;
        padding-top: 2rem;
        min-height: 100vh;
    }

    h1 {
        margin-bottom: 0.8rem;
        margin-top: 0;
    }

    #ball-container {
        margin: 0.5rem 0;
    }

    .container.compact {
        gap: 0.4rem;
    }

    /* Smaller buttons for mobile */
    .btn {
        font-size: 0.85rem;
        padding: 0.65rem 1.2rem;
        min-width: 150px;
        gap: 0.5rem;
    }

    .btn .icon {
        width: clamp(1rem, 2.8vw, 1.4rem);
        height: clamp(1rem, 2.8vw, 1.4rem);
        stroke-width: 2.5;
    }

    /* Hide audio playback on mobile for performance */
    #audio-playback {
        display: none !important;
    }

    #status-text {
        margin-top: -0.07rem;
    }

    /* Extra spacing between buttons on mobile */
    #send-button {
        margin-top: 1.2rem;
    }
}

/* Very small screens (e.g., iPhone SE) */
@media (max-width: 360px) {
    #ball {
        width: 240px;
        height: 240px;
    }

    #ball-window {
        width: 220px;
        height: 220px;
        padding: 1.2rem;
    }

    /* Even smaller buttons for tiny screens */
    .btn {
        font-size: 0.8rem;
        padding: 0.6rem 1rem;
        min-width: 140px;
    }

    .btn .icon {
        font-size: 0.9rem;
    }

     #audio-playback {
        max-width: 95%;
        height: 46px;
    }
}