/* Siri AI — Chat page
   Loaded after styles.css: reuses design tokens and shared classes
   (t-body, search-input, etc.) and layers the chat-specific UI on top. */

html, body.chat-body {
  height: 100%;
}

body.chat-body {
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface-black);
  color: var(--on-dark);
  overflow: hidden;
}

/* ---- Top bar ---- */

.chat-topbar {
  position: relative;
  flex-shrink: 0;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-black);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-back {
  position: absolute;
  left: 20px;
  color: var(--primary-on-dark);
  font-family: var(--font-text);
  font-size: 14px;
}

.chat-topbar-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.2px;
}

/* ---- Main scroll area ---- */

.chat-main {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 20px 140px;
  -webkit-overflow-scrolling: touch;
}

.chat-orb-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin: 16px 0 32px;
}

.chat-orb {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: conic-gradient(from 180deg, #2997ff, #bf5af2, #ff375f, #ff9f0a, #2997ff);
  box-shadow: 0 0 40px rgba(41, 151, 255, 0.35);
  animation: orbSpin 6s linear infinite;
}

.chat-orb.thinking {
  animation: orbSpin 1.4s linear infinite, orbPulse 1s ease-in-out infinite;
}

@keyframes orbSpin {
  to { transform: rotate(360deg); }
}

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

.chat-orb-caption {
  color: var(--body-muted);
}

/* ---- Messages ---- */

.chat-messages {
  width: 100%;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-msg {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: var(--r-lg);
}

.chat-msg p { margin: 0; }

.chat-msg-user {
  align-self: flex-end;
  background: var(--primary);
  color: var(--on-primary);
  border-bottom-right-radius: 4px;
}

.chat-msg-assistant {
  align-self: flex-start;
  background: var(--surface-tile-2);
  color: var(--on-dark);
  border-bottom-left-radius: 4px;
}

.chat-msg-error {
  align-self: flex-start;
  background: rgba(255, 55, 95, 0.12);
  color: #ff9f9f;
  border: 1px solid rgba(255, 55, 95, 0.3);
  border-bottom-left-radius: 4px;
}

.chat-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 14px 16px;
  background: var(--surface-tile-2);
  border-radius: var(--r-lg);
  border-bottom-left-radius: 4px;
}

.chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--body-muted);
  animation: typingBounce 1.2s infinite ease-in-out;
}

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

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ---- Input bar ---- */

.chat-input-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px 20px calc(16px + env(safe-area-inset-bottom));
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-input-inner {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
  align-items: center;
}

.chat-input-inner .search-input {
  flex: 1;
  background: var(--surface-tile-2);
  color: var(--on-dark);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-input-inner .search-input::placeholder {
  color: var(--ink-muted-48);
}

.chat-send {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: var(--r-full);
  background: var(--primary);
  color: var(--on-primary);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.chat-send:active { transform: scale(0.92); }

.chat-send:disabled {
  opacity: 0.5;
}

@media (max-width: 640px) {
  .chat-orb { width: 56px; height: 56px; }
  .chat-messages { max-width: 100%; }
  .chat-msg { max-width: 88%; }
}
