/* اسأل شاطر — kid chat */

.ask-page {
  background:
    radial-gradient(circle at 90% 10%, #ede9fe 0 140px, transparent 141px),
    radial-gradient(circle at 5% 85%, #fff4cc 0 160px, transparent 161px),
    var(--sky);
  min-height: 100vh;
}
.chat-wrap { max-width: 820px; padding: 20px 0 40px; display: flex; flex-direction: column; min-height: calc(100vh - 70px); }

.chat-head { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.chat-head h1 { margin: 0; color: var(--blue-900); font-size: clamp(1.6rem, 4vw, 2.2rem); line-height: 1.2; }
.chat-head p { margin: 2px 0 0; color: var(--ink-soft); font-weight: 600; }

.talker { position: relative; flex-shrink: 0; }
.talker img {
  width: 96px; height: 96px; border-radius: 50%; object-fit: cover; object-position: top;
  border: 5px solid var(--white); box-shadow: var(--shadow-soft);
}
.talker .waves { position: absolute; bottom: 4px; left: -6px; display: flex; gap: 3px; align-items: flex-end; height: 22px; opacity: 0; transition: opacity 0.2s; }
.talker .waves i { width: 5px; height: 6px; background: var(--orange); border-radius: 3px; }
.talker.speaking .waves { opacity: 1; }
.talker.speaking .waves i { animation: wave 0.6s ease-in-out infinite; }
.talker.speaking .waves i:nth-child(2) { animation-delay: 0.15s; }
.talker.speaking .waves i:nth-child(3) { animation-delay: 0.3s; }
.talker.speaking img { animation: talk 0.35s ease-in-out infinite alternate; }
.talker.thinking img { animation: think 1.2s ease-in-out infinite; }

.chat {
  flex: 1; display: flex; flex-direction: column; gap: 12px;
  background: var(--white); border-radius: var(--radius-lg); padding: 18px;
  box-shadow: var(--shadow-soft); min-height: 320px; max-height: 58vh; overflow-y: auto;
  scroll-behavior: smooth;
}
.msg { display: flex; gap: 10px; align-items: flex-end; max-width: 88%; animation: pop-in 0.35s var(--bounce); }
.msg img { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; object-position: top; flex-shrink: 0; }
.msg .bubble { padding: 10px 16px; border-radius: 20px; font-size: 1.15rem; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.msg.bot { align-self: flex-start; }
.msg.bot .bubble { background: var(--sky); color: var(--ink); border-bottom-right-radius: 6px; }
.msg.me { align-self: flex-end; flex-direction: row-reverse; }
.msg.me .bubble { background: var(--blue-500); color: var(--white); border-bottom-left-radius: 6px; }
.msg .replay {
  border: 0; background: none; font-size: 1.1rem; padding: 2px; opacity: 0.6; flex-shrink: 0;
}
.msg .replay:hover { opacity: 1; }
.msg.error .bubble { background: #fee2e2; color: #991b1b; }

.typing .bubble { display: flex; gap: 6px; padding: 14px 18px; }
.typing .bubble i { width: 9px; height: 9px; border-radius: 50%; background: var(--blue-300); animation: bounce-dot 1s infinite; }
.typing .bubble i:nth-child(2) { animation-delay: 0.15s; }
.typing .bubble i:nth-child(3) { animation-delay: 0.3s; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }
.chips button {
  border: 2px solid var(--blue-100); background: var(--white); color: var(--blue-800);
  border-radius: 999px; padding: 6px 14px; font-weight: 700; font-size: 1rem;
  transition: transform 0.2s var(--bounce), border-color 0.2s;
}
.chips button:hover { transform: translateY(-3px); border-color: var(--blue-300); }

.composer {
  display: flex; gap: 10px; align-items: center;
  background: var(--white); border-radius: 999px; padding: 8px; box-shadow: var(--shadow-soft);
}
.composer input {
  flex: 1; min-width: 0; border: 0; outline: none; font: inherit; font-size: 1.2rem;
  padding: 8px 12px; background: transparent; color: var(--ink);
}
.composer .send { padding: 10px 22px; font-size: 1.1rem; box-shadow: 0 4px 0 var(--btn-shadow); }
.mic {
  width: 50px; height: 50px; border-radius: 50%; border: 0; flex-shrink: 0;
  background: var(--pink-soft); font-size: 1.4rem;
  transition: transform 0.2s var(--bounce);
}
.mic.on { background: var(--pink); animation: pulse 0.9s infinite; }

.fineprint { text-align: center; color: var(--ink-soft); font-size: 0.9rem; margin: 10px 0 0; }

.chat-note {
  background: var(--white); border-radius: var(--radius-lg); padding: 26px;
  box-shadow: var(--shadow-soft); text-align: center;
}
.chat-note .big { font-size: 3.4rem; }
.chat-note h2 { margin: 4px 0; color: var(--blue-900); }
.chat-note p { color: var(--ink-soft); }
.chat-note ol { text-align: right; display: inline-block; color: var(--ink); line-height: 2; margin: 6px 0 0; }
.chat-note code { background: var(--sky); padding: 1px 8px; border-radius: 6px; direction: ltr; display: inline-block; }

#voiceBtn.off { filter: grayscale(1); opacity: 0.5; }

@keyframes wave { 0%, 100% { height: 6px; } 50% { height: 20px; } }
@keyframes talk { from { transform: scale(1); } to { transform: scale(1.04) rotate(-1deg); } }
@keyframes think { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-5deg); } 75% { transform: rotate(5deg); } }
@keyframes bounce-dot { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-7px); } }

@media (max-width: 600px) {
  .talker img { width: 70px; height: 70px; }
  .chat { max-height: 52vh; padding: 12px; }
  .msg { max-width: 96%; }
  .msg .bubble { font-size: 1.05rem; }
  .composer .send { padding: 10px 14px; }
}
