/* Talk — conversation with a character */

.talk-container {
    display: none;
    width: 100%;
    max-width: 400px;
}

/* === Intro screen === */

.talk-card {
    background: #FFFFFF;
    border-radius: 24px;
    box-shadow: 0 8px 32px rgba(79, 70, 229, 0.15);
    padding: 32px 28px;
    text-align: center;
}

.talk-avatar-placeholder {
    position: relative;
    width: 180px;
    height: 180px;
    margin: 0 auto 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366F1, #4F46E5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    overflow: hidden;
}

/* Samantha's portrait covers the emoji when images/samantha.png exists */
.talk-avatar-img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.talk-title {
    font-size: 26px;
    font-weight: 700;
    color: #3730A3;
    margin-bottom: 8px;
}

.talk-subtitle {
    font-size: 16px;
    color: #4B5563;
    line-height: 1.5;
}

.talk-status {
    margin-top: 20px;
    padding: 8px 14px;
    border-radius: 12px;
    display: inline-block;
    font-size: 14px;
    background: #E0E7FF;
    color: #4B5563;
}

.talk-status.connected {
    background: #D1FAE5;
    color: #065F46;
}

.talk-status.error {
    background: #FEE2E2;
    color: #991B1B;
}

/* First-visit explanation (Hebrew, RTL) */

.talk-onboarding {
    margin-top: 18px;
    text-align: right;
}

.talk-onboarding-text {
    font-size: 17px;
    color: #4B5563;
    line-height: 1.6;
    text-align: center;
    margin-bottom: 14px;
}

.talk-onboarding-steps {
    background: #E0E7FF;
    border-radius: 16px;
    padding: 14px 16px;
    font-size: 16px;
    color: #3730A3;
    line-height: 1.7;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 6px;
}

.talk-start-btn {
    display: block;
    width: 100%;
    margin-top: 20px;
    padding: 16px;
    border: none;
    border-radius: 16px;
    background: linear-gradient(135deg, #6366F1, #4F46E5);
    color: #FFFFFF;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
}

.talk-start-btn:active {
    background: linear-gradient(135deg, #4F46E5, #4338CA);
}

/* === Chat screen === */

.talk-chat {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 400px;
    height: calc(100vh - 140px);
    height: calc(100dvh - 140px);
}

.talk-chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 4px;
}

.talk-chat-avatar {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366F1, #4F46E5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    overflow: hidden;
    flex-shrink: 0;
}

.talk-chat-name {
    font-size: 19px;
    font-weight: 700;
    color: #3730A3;
}

.talk-mute-btn {
    margin-left: auto;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: #E0E7FF;
    font-size: 17px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Voice state pill: speaking / listening / thinking */

.talk-voice-status {
    align-self: center;
    margin: 4px 0;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 15px;
    background: #E0E7FF;
    color: #3730A3;
}

.talk-voice-status.listening {
    background: #D1FAE5;
    color: #065F46;
}

.talk-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 4px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Speaking view: while Samantha talks, she takes over the chat area —
   a large glowing portrait with her words beneath it. */

.talk-speaking-view {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 12px 8px;
    cursor: pointer;
}

.talk-speaking-portrait {
    position: relative;
    width: 210px;
    height: 210px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366F1, #4F46E5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 84px;
    overflow: hidden;
    flex-shrink: 0;
    animation: talk-speaking-glow 2.2s infinite;
}

@keyframes talk-speaking-glow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.35), 0 0 0 14px rgba(99, 102, 241, 0.10); }
    50% { box-shadow: 0 0 0 12px rgba(99, 102, 241, 0.18), 0 0 0 28px rgba(99, 102, 241, 0.04); }
}

.talk-speaking-name {
    font-size: 24px;
    font-weight: 700;
    color: #3730A3;
}

.talk-speaking-text {
    font-size: 17px;
    color: #4B5563;
    line-height: 1.5;
    text-align: center;
    overflow-y: auto;
    max-height: 130px;
    padding: 0 8px;
}

.talk-speaking-hint {
    font-size: 13px;
    color: #6366F1;
}

/* "You said: ..." confirmation while she thinks/answers */
.talk-heard-text {
    font-size: 15px;
    color: #6366F1;
    text-align: center;
    line-height: 1.4;
    padding: 0 12px;
    max-height: 84px;
    overflow-y: auto;
}

.talk-heard-text:empty {
    display: none;
}

/* While Samantha thinks, her portrait waits calmly (no glow) */
.talk-speaking-view.thinking .talk-speaking-portrait {
    animation: none;
    opacity: 0.85;
}

/* Voice mode: mom's turn — big mic mirroring Samantha's big portrait */

.talk-listen-view {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 12px 8px;
    cursor: pointer;
}

.talk-big-mic {
    width: 210px;
    height: 210px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366F1, #4F46E5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 84px;
    flex-shrink: 0;
}

.talk-listen-view.listening .talk-big-mic {
    background: linear-gradient(135deg, #EF4444, #DC2626);
    animation: talk-mic-pulse 1.4s infinite;
}

.talk-listen-hint {
    font-size: 17px;
    color: #3730A3;
    text-align: center;
    line-height: 1.4;
    padding: 0 16px;
}

/* Live "what the mic heard" while she speaks */
.talk-listen-transcript {
    font-size: 18px;
    color: #4B5563;
    text-align: center;
    line-height: 1.5;
    max-height: 140px;
    overflow-y: auto;
    padding: 0 12px;
}

.talk-listen-transcript:empty {
    display: none;
}

/* Samantha's last reply, quietly, on mom's turn — plus the 🔁 replay chip.
   Deliberately small and grey: readable, but not a chat. */
.talk-listen-reply {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 0 20px;
    width: 100%;
    cursor: default;
}

.talk-listen-reply-text {
    font-size: 14px;
    color: #6B7280;
    text-align: center;
    line-height: 1.45;
    max-height: 84px;
    overflow-y: auto;
}

.talk-replay-btn {
    border: none;
    border-radius: 999px;
    min-height: 40px;
    padding: 8px 20px;
    background: #E0E7FF;
    color: #3730A3;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

/* Voice mode: review what the mic heard before sending it to Samantha */

.talk-review-view {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
    padding: 16px 12px;
}

.talk-review-label {
    font-size: 16px;
    color: #6B7280;
    direction: rtl;
}

.talk-review-text {
    font-size: 24px;
    color: #1F2937;
    text-align: center;
    line-height: 1.5;
    max-height: 42vh;
    overflow-y: auto;
    padding: 0 8px;
}

.talk-review-actions {
    display: flex;
    direction: rtl;
    gap: 16px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

.talk-review-btn {
    min-height: 56px;
    padding: 14px 28px;
    border: none;
    border-radius: 16px;
    font-size: 19px;
    font-weight: 600;
    cursor: pointer;
}

.talk-review-send {
    background: linear-gradient(135deg, #6366F1, #4F46E5);
    color: #fff;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.35);
}

.talk-review-again {
    background: #F3F4F6;
    color: #374151;
    border: 1px solid #D1D5DB;
}

/* Voice mode hides everything textual — pure conversation */
.talk-chat.talk-voice-mode .talk-composer,
.talk-chat.talk-voice-mode .talk-messages,
.talk-chat.talk-voice-mode .talk-starters,
.talk-chat.talk-voice-mode .talk-speaking-text {
    display: none !important;
}

.talk-bubble {
    max-width: 80%;
    padding: 12px 16px;
    font-size: 17px;
    line-height: 1.45;
}

.talk-bubble-character {
    background: #FFFFFF;
    color: #4B5563;
    border-radius: 18px 18px 18px 4px;
    box-shadow: 0 2px 10px rgba(79, 70, 229, 0.10);
    align-self: flex-start;
}

.talk-bubble-user {
    background: linear-gradient(135deg, #6366F1, #4F46E5);
    color: #FFFFFF;
    border-radius: 18px 18px 4px 18px;
    align-self: flex-end;
}

.talk-bubble-error {
    background: #FEE2E2;
    color: #991B1B;
    border-radius: 18px;
    align-self: center;
    text-align: center;
    max-width: 90%;
}

/* Gentle hints (mic recovery) — soft, not alarming like .talk-bubble-error */
.talk-bubble-hint {
    background: #E0E7FF;
    color: #3730A3;
    border-radius: 18px;
    align-self: center;
    text-align: center;
    max-width: 90%;
    font-size: 15px;
}

.talk-mic-btn.talk-mic-denied {
    opacity: 0.4;
}

.talk-retry-btn {
    display: block;
    margin: 10px auto 0;
    padding: 8px 20px;
    border: none;
    border-radius: 999px;
    background: #DC2626;
    color: #FFFFFF;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

/* Typing indicator: three blinking dots in a character bubble */

.talk-typing {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 16px;
}

.talk-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #6366F1;
    animation: talk-blink 1.2s infinite;
}

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

@keyframes talk-blink {
    0%, 60%, 100% { opacity: 0.25; }
    30% { opacity: 1; }
}

/* === Topic starter chips === */

.talk-starters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 0;
}

.talk-starter-chip {
    border: none;
    background: #E0E7FF;
    color: #3730A3;
    border-radius: 999px;
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}

.talk-starter-chip:active {
    background: #C7D2FE;
}

/* === Composer === */

.talk-composer {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 8px 0;
}

.talk-input {
    flex: 1;
    min-width: 0;
    border: 2px solid #C7D2FE;
    border-radius: 999px;
    padding: 12px 16px;
    font-size: 17px;
    color: #4B5563;
    outline: none;
    background: #FFFFFF;
}

.talk-input:focus {
    border-color: #6366F1;
}

.talk-send-btn,
.talk-help-btn {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.talk-send-btn {
    background: linear-gradient(135deg, #6366F1, #4F46E5);
    color: #FFFFFF;
}

.talk-send-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

.talk-help-btn {
    background: #E0E7FF;
    color: #3730A3;
    font-weight: 700;
}

/* Mic button — the primary voice control, larger than send/help */

.talk-mic-btn {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366F1, #4F46E5);
    font-size: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.talk-mic-btn:disabled {
    opacity: 0.5;
    cursor: default;
}

/* While Samantha speaks the mic stays tappable — tapping interrupts her */
.talk-mic-btn.talk-mic-speaking {
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.25);
}

.talk-mic-btn.talk-mic-listening {
    background: linear-gradient(135deg, #EF4444, #DC2626);
    animation: talk-mic-pulse 1.4s infinite;
}

@keyframes talk-mic-pulse {
    0% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.35); }
    70% { box-shadow: 0 0 0 12px rgba(220, 38, 38, 0); }
    100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

/* Live transcript bubble while she speaks */

.talk-bubble-interim {
    opacity: 0.65;
    animation: talk-interim-pulse 1.6s infinite;
}

@keyframes talk-interim-pulse {
    0%, 100% { opacity: 0.65; }
    50% { opacity: 0.85; }
}

/* Sign-in card (stage 1.3): container for the Google Identity button */
.talk-google-btn {
    display: flex;
    justify-content: center;
    margin: 16px 0;
    min-height: 44px;
}

/* Free-minutes countdown pill (stage 1.5) */
.talk-minutes-pill {
    background: #EEF2FF;
    color: #4F46E5;
    border-radius: 999px;
    padding: 4px 10px;
    font-size: 0.8rem;
    white-space: nowrap;
}
.talk-minutes-pill.low {
    background: #FEE2E2;
    color: #B91C1C;
}
