/* ========================================
   VOICE INPUT & EXTERNAL CHAT
   Breakpoints: 900px (exhibited/contained), 600px (large/small contained)
   ======================================== */

/* External chat input - positioned below the frame */
.external-chat-input {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    width: 500px;
    max-width: 90vw;
    z-index: 10001;
    display: block;
}

.external-chat-input.hidden {
    display: none;
}

/* Background container */
.external-chat-input::before {
    content: '';
    position: absolute;
    top: -50px;
    left: -60px;
    right: -60px;
    bottom: -30px;
    background: rgba(0, 0, 0, 0.65);
    border-radius: 40px;
    filter: blur(20px);
    z-index: -1;
    pointer-events: none;
    touch-action: none;
}

/* ========================================
   VOICE STATE TEXT
   ======================================== */

.voice-state-text {
    position: absolute;
    top: -35px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 13px;
    font-family: 'Jost', sans-serif;
    font-weight: 600;
    color: #fff4e6;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    letter-spacing: 0.5px;
    padding: 4px 10px;
    text-shadow: 0 0 10px rgba(255, 244, 230, 0.8);
}

.voice-state-text.visible {
    opacity: 1;
}

.voice-state-text.listening {
    color: #FFD764;
    animation: textPulse 1.5s ease-in-out infinite;
}

.voice-state-text.processing {
    color: #888;
}

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

/* ========================================
   WALL INSCRIPTION (input container)
   ======================================== */

.wall-inscription {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Engraved line on wall */
.wall-inscription::before {
    content: '';
    position: absolute;
    bottom: 8px;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(255, 244, 230, 0.6) 10%, 
        rgba(255, 244, 230, 0.9) 50%, 
        rgba(255, 244, 230, 0.6) 90%, 
        transparent 100%
    );
    box-shadow: 
        0 0 10px rgba(255, 244, 230, 0.8),
        0 0 20px rgba(255, 244, 230, 0.4),
        0 2px 4px rgba(0, 0, 0, 0.6);
    pointer-events: none;
    animation: linePulse 3s ease-in-out infinite;
}

@keyframes linePulse {
    0%, 100% {
        opacity: 0.7;
        box-shadow: 
            0 0 8px rgba(255, 244, 230, 0.6),
            0 0 16px rgba(255, 244, 230, 0.3),
            0 2px 4px rgba(0, 0, 0, 0.6);
    }
    50% {
        opacity: 1;
        box-shadow: 
            0 0 15px rgba(255, 244, 230, 1),
            0 0 30px rgba(255, 244, 230, 0.6),
            0 2px 4px rgba(0, 0, 0, 0.6);
    }
}

/* ========================================
   TEXT INPUT
   ======================================== */

#user-input {
    flex: 1;
    background: transparent;
    border: none;
    color: #fff4e6;
    font-family: 'Merriweather', serif;
    font-size: 16px;
    padding: 8px 0 18px 0;
    outline: none;
    text-shadow: 
        0 0 10px rgba(255, 244, 230, 0.8),
        0 0 20px rgba(255, 244, 230, 0.4);
}

#user-input:disabled {
    color: rgba(255, 244, 230, 0.3);
    cursor: not-allowed;
}

#user-input::placeholder {
    color: rgba(255, 244, 230, 0.7);
    text-shadow: 0 0 8px rgba(255, 244, 230, 0.5);
    font-style: italic;
}

#user-input:focus {
    text-shadow: 
        0 0 15px rgba(255, 244, 230, 1),
        0 0 30px rgba(255, 244, 230, 0.6);
}

/* ========================================
   SEND BUTTON
   ======================================== */

#send-button {
    background: transparent;
    border: none;
    color: rgba(255, 244, 230, 0.3);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    
    opacity: 0.4;
    filter: drop-shadow(0 0 4px rgba(255, 244, 230, 0.2));
    transition: all 0.3s ease;
    
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

#send-button.active {
    opacity: 1;
    color: rgba(255, 244, 230, 0.9);
    filter: drop-shadow(0 0 12px rgba(255, 244, 230, 0.6));
    animation: sendPulse 2s ease-in-out infinite;
}

#send-button.active:hover {
    color: #fff4e6;
    filter: drop-shadow(0 0 18px rgba(255, 244, 230, 0.9));
}

#send-button.active:active {
    transform: scale(0.92);
    filter: drop-shadow(0 0 25px rgba(255, 244, 230, 1));
}

@keyframes sendPulse {
    0%, 100% {
        filter: drop-shadow(0 0 10px rgba(255, 244, 230, 0.5));
    }
    50% {
        filter: drop-shadow(0 0 18px rgba(255, 244, 230, 0.8));
    }
}

/* ========================================
   MICROPHONE BUTTON
   ======================================== */

#mic-button {
    background: transparent;
    border: none;
    color: rgba(255, 244, 230, 0.8);
    cursor: pointer;
    padding: 8px;
    transition: all 0.3s ease;
    filter: drop-shadow(0 0 12px rgba(255, 244, 230, 0.5));
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
}

#mic-button:hover {
    color: rgba(255, 244, 230, 1);
    filter: drop-shadow(0 0 16px rgba(255, 244, 230, 0.8));
}

#mic-button.voice-on {
    color: #FFD764;
    filter: drop-shadow(0 0 20px rgba(255, 215, 100, 1));
    animation: micPulse 2s ease-in-out infinite;
}

@keyframes micPulse {
    0%, 100% {
        filter: drop-shadow(0 0 15px rgba(255, 215, 100, 0.6));
    }
    50% {
        filter: drop-shadow(0 0 25px rgba(255, 215, 100, 1));
    }
}

#mic-button.listening {
    color: #FFD764;
    filter: drop-shadow(0 0 25px rgba(255, 215, 100, 1));
    animation: listeningPulse 1s ease-in-out infinite;
}

@keyframes listeningPulse {
    0%, 100% {
        filter: drop-shadow(0 0 20px rgba(255, 215, 100, 0.8));
    }
    50% {
        filter: drop-shadow(0 0 35px rgba(255, 215, 100, 1));
    }
}

#mic-button.processing {
    color: rgba(255, 244, 230, 0.4);
    cursor: wait;
    animation: processingRotate 2s linear infinite;
}

@keyframes processingRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ========================================
   VOICE NOTIFICATIONS
   ======================================== */

.voice-hint {
    position: absolute;
    bottom: -50px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 10px;
    font-family: 'Jost', sans-serif;
    color: rgba(255, 244, 230, 0.5);
    opacity: 0;
    transition: opacity 0.4s ease;
    pointer-events: none;
    font-style: italic;
}

.voice-hint.visible {
    opacity: 1;
}

.voice-notification {
    position: absolute;
    bottom: -30px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 11px;
    font-family: 'Jost', sans-serif;
    font-weight: 500;
    color: rgba(255, 244, 230, 0.6);
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
}

.voice-notification.visible {
    opacity: 1;
}

/* ========================================
   SHORT DESKTOP/LAPTOP: Wide but not tall
   When height is the limiting factor
   ======================================== */

@media (min-width: 900px) and (max-height: 800px) {
    .external-chat-input {
        bottom: 5vh;
    }
}

@media (min-width: 900px) and (max-height: 650px) {
    .external-chat-input {
        bottom: 3vh;
    }
}

/* ========================================
   CONTAINED LARGE: 600px - 899px
   ======================================== */

@media (max-width: 899px) and (min-width: 600px) {
    .external-chat-input {
        width: 70vw;
        max-width: 450px;
        bottom: 10vh;
    }
    
    #send-button {
        width: 57px;
        height: 57px;
        padding: 12px;
    }
    
    #send-button svg {
        width: 30px;
        height: 30px;
    }
}

/* ========================================
   CONTAINED SMALL: < 600px
   Input sits well above nav arrows
   ======================================== */

@media (max-width: 599px) {
    .external-chat-input {
        width: 85vw;
        max-width: 420px;
        /* Move input DOWN - more space between frame and input */
        bottom: 18vh;
    }
    
    #send-button {
        width: 57px;
        height: 57px;
        padding: 12px;
    }
    
    #send-button svg {
        width: 30px;
        height: 30px;
    }
}

/* ========================================
   EXTRA SMALL: < 400px (includes Galaxy Fold outer at 344px)
   ======================================== */

@media (max-width: 399px) {
    .external-chat-input {
        width: 90vw;
        max-width: 340px;
        bottom: 16vh;
    }
    
    #user-input {
        font-size: 14px;
        padding: 6px 0 14px 0;
    }
    
    #mic-button {
        width: 32px;
        height: 32px;
    }
    
    #send-button {
        width: 48px;
        height: 48px;
        padding: 10px;
    }
    
    #send-button svg {
        width: 24px;
        height: 24px;
    }
}

/* ========================================
   TALL/NARROW DEVICES (Z Flip folded ONLY)
   Z Flip outer: ~260px wide
   Galaxy Fold outer: ~344px - should NOT match this rule
   ======================================== */

@media (max-aspect-ratio: 55/100) and (max-width: 290px) {
    .external-chat-input {
        width: 85vw;
        max-width: 300px;
        bottom: 50px;
    }
    
    #user-input {
        font-size: 13px;
        padding: 5px 0 12px 0;
    }
    
    /* Smaller blur backdrop on narrow screens */
    .external-chat-input::before {
        left: -30px;
        right: -30px;
        top: -30px;
        bottom: -20px;
    }
}

/* ========================================
   Z FLIP SPECIFIC: Very narrow + short width
   Z Flip outer: ~260px wide
   ======================================== */

@media (max-width: 290px) and (max-aspect-ratio: 55/100) {
    .external-chat-input {
        width: 90vw;
        max-width: 250px;
        bottom: 40px;
    }
    
    #user-input {
        font-size: 12px;
        padding: 4px 0 10px 0;
    }
    
    #send-button {
        width: 42px;
        height: 42px;
        padding: 8px;
    }
    
    #send-button svg {
        width: 21px;
        height: 21px;
    }
    
    .wall-inscription {
        gap: 8px;
    }
}

/* ========================================
   LANDSCAPE PHONE MODE
   Wide but short viewport
   ======================================== */

@media (min-aspect-ratio: 150/100) and (max-height: 500px) {
    .external-chat-input {
        bottom: 30px;
        width: 400px;
        max-width: 70vw;
    }
}