/* ══════════════════════════════════════════════════════════
   MyGriefFellow — Styles
   Midnight blue becoming gold. Dawn.
   (c) 2026 Resonant Catalyst. All rights reserved.
   ══════════════════════════════════════════════════════════ */

:root {
  --bg-deep: #0a0b14;
  --bg-surface: #0f1020;
  --bg-card: rgba(18, 20, 40, 0.85);
  --text-primary: #d4d0c8;
  --text-soft: #8a8778;
  --text-whisper: #5a5848;
  --gold-warm: #c9a84c;
  --gold-soft: #a08838;
  --gold-glow: rgba(201, 168, 76, 0.15);
  --indigo-deep: #1a1840;
  --indigo-mid: #2a2660;
  --purple-soft: #3d3570;
  --dawn-amber: #d4a040;
  --input-bg: rgba(20, 22, 45, 0.9);
  --border-subtle: rgba(201, 168, 76, 0.08);
  --border-warm: rgba(201, 168, 76, 0.15);
  --radius: 16px;
  --radius-sm: 10px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Georgia', 'Times New Roman', serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

/* ── DMT Cymatic Canvas ── */
#dmt-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* ══════ AUTH SCREEN ══════ */
#auth-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #12103000 0%, var(--bg-deep) 70%);
  gap: 20px;
}

.auth-mandala-wrap {
  position: relative;
  width: 280px;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#mandala-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  opacity: 0.7;
  mask-image: radial-gradient(ellipse, black 50%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse, black 50%, transparent 75%);
}

#mandala-img {
  position: absolute;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 2s ease;
  mask-image: radial-gradient(ellipse, black 50%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse, black 50%, transparent 75%);
}

/* Fallback: show image if video fails */
#mandala-video:not([src]), #mandala-video[error] { display: none; }
#mandala-video:not([src]) ~ #mandala-img,
#mandala-video[error] ~ #mandala-img { opacity: 0.7; }

.mandala-glow {
  position: absolute;
  width: 320px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(ellipse, var(--gold-glow) 0%, transparent 70%);
  animation: mandala-breathe 6s ease-in-out infinite;
  pointer-events: none;
}

@keyframes mandala-breathe {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.08); opacity: 0.8; }
}

.auth-title {
  font-size: 1.8rem;
  font-weight: 400;
  letter-spacing: 0.15em;
  color: var(--text-primary);
  text-shadow: 0 0 30px rgba(201, 168, 76, 0.1);
}

.accent-word {
  color: var(--gold-warm);
  text-shadow: 0 0 30px rgba(201, 168, 76, 0.3);
}

.auth-subtitle {
  font-size: 0.95rem;
  color: var(--text-soft);
  font-style: italic;
  letter-spacing: 0.05em;
  margin-top: -8px;
}

.auth-box {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 280px;
  margin-top: 16px;
}

.auth-box input {
  background: var(--input-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.3s ease;
}

.auth-box input:focus {
  border-color: var(--border-warm);
}

.auth-box input::placeholder {
  color: var(--text-whisper);
}

#gate-btn {
  background: linear-gradient(135deg, var(--indigo-mid), var(--purple-soft));
  border: 1px solid var(--border-warm);
  border-radius: var(--radius-sm);
  padding: 12px;
  color: var(--gold-warm);
  font-family: inherit;
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 0.3s ease;
}

#gate-btn:hover {
  background: linear-gradient(135deg, var(--purple-soft), var(--indigo-mid));
  box-shadow: 0 0 20px rgba(201, 168, 76, 0.1);
}

#gate-error {
  color: #c47a7a;
  font-size: 0.8rem;
  text-align: center;
  min-height: 1.2em;
}

/* ══════ ONBOARDING ══════ */
#onboard-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-deep);
  gap: 30px;
  padding: 40px;
}

.onboard-mandala-wrap {
  position: relative;
  width: 160px;
  height: 160px;
}

.onboard-mandala-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  opacity: 0.5;
  mask-image: radial-gradient(circle, black 40%, transparent 70%);
  -webkit-mask-image: radial-gradient(circle, black 40%, transparent 70%);
}

.mandala-breathe {
  position: absolute;
  inset: -20px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--gold-glow) 0%, transparent 60%);
  animation: mandala-breathe 8s ease-in-out infinite;
}

#onboard-content {
  text-align: center;
  max-width: 400px;
}

.onboard-line {
  font-size: 1.05rem;
  line-height: 1.8;
  color: var(--text-primary);
  opacity: 0;
  animation: fadeInSlow 1.5s ease forwards;
  margin-bottom: 8px;
}

.onboard-line:nth-child(2) { animation-delay: 0.8s; }
.onboard-line:nth-child(3) { animation-delay: 1.6s; }

@keyframes fadeInSlow {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

#onboard-btn {
  background: transparent;
  border: 1px solid var(--border-warm);
  border-radius: var(--radius-sm);
  padding: 10px 32px;
  color: var(--gold-soft);
  font-family: inherit;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 0.3s ease;
}

#onboard-btn:hover {
  background: rgba(201, 168, 76, 0.05);
  color: var(--gold-warm);
}

/* ══════ MAIN APP ══════ */
#app-screen {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  background: transparent;
}

/* ── Header ── */
#app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: rgba(10, 11, 20, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 6;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.fellow-presence {
  display: flex;
  align-items: center;
  gap: 8px;
}

.presence-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold-warm);
  box-shadow: 0 0 8px rgba(201, 168, 76, 0.4);
  animation: presence-pulse 3s ease-in-out infinite;
}

@keyframes presence-pulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.2); }
}

.fellow-label {
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--gold-warm);
  letter-spacing: 0.05em;
}

.speaker-btn {
  background: none;
  border: none;
  color: var(--text-soft);
  cursor: pointer;
  padding: 4px;
  transition: color 0.3s ease;
  display: flex;
  align-items: center;
}

.speaker-btn:hover {
  color: var(--gold-warm);
}

.logout-btn {
  background: none;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 16px;
  color: var(--text-soft);
  font-family: inherit;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.3s ease;
}

.logout-btn:hover {
  border-color: var(--border-warm);
  color: var(--text-primary);
}

/* ── Chat Area ── */
#chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px;
  scroll-behavior: smooth;
}

#chat-area::-webkit-scrollbar { width: 4px; }
#chat-area::-webkit-scrollbar-track { background: transparent; }
#chat-area::-webkit-scrollbar-thumb { background: var(--border-subtle); border-radius: 4px; }

#messages {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ── Messages ── */
.msg {
  padding: 16px 20px;
  border-radius: var(--radius);
  line-height: 1.7;
  font-size: 0.95rem;
  animation: msgFade 0.6s ease forwards;
  opacity: 0;
}

@keyframes msgFade {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg-user {
  background: rgba(30, 28, 50, 0.6);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  align-self: flex-end;
  max-width: 85%;
}

.msg-fellow {
  background: rgba(15, 16, 35, 0.5);
  border: 1px solid rgba(201, 168, 76, 0.06);
  color: var(--text-primary);
  align-self: flex-start;
  max-width: 90%;
  border-left: 2px solid rgba(201, 168, 76, 0.15);
}

.msg-speak-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid rgba(201, 168, 76, 0.15);
  color: rgba(201, 168, 76, 0.4);
  border-radius: 4px;
  padding: 3px 5px;
  cursor: pointer;
  float: right;
  margin-top: 2px;
  transition: color 0.2s, border-color 0.2s;
}

.msg-speak-btn:hover {
  color: rgba(201, 168, 76, 0.8);
  border-color: rgba(201, 168, 76, 0.4);
}

.msg-fellow p {
  margin-bottom: 8px;
}

.msg-fellow p:last-child {
  margin-bottom: 0;
}

/* ── Streaming indicator ── */
.streaming .breathing-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--gold-soft);
  border-radius: 50%;
  animation: breatheDot 2s ease-in-out infinite;
}

@keyframes breatheDot {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 0.8; transform: scale(1.2); }
}

/* ── Reply Zone ── */
#reply-zone {
  padding: 16px 20px 24px;
  background: rgba(10, 11, 20, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-subtle);
}

.input-wrap {
  max-width: 680px;
  margin: 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--input-bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 8px 12px;
  transition: border-color 0.3s ease;
}

.input-wrap:focus-within {
  border-color: var(--border-warm);
  box-shadow: 0 0 20px rgba(201, 168, 76, 0.04);
}

#user-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  resize: none;
  outline: none;
  padding: 4px 0;
  max-height: 120px;
}

#user-input::placeholder {
  color: var(--text-whisper);
  font-style: italic;
}

#send-btn {
  background: none;
  border: none;
  color: var(--text-soft);
  cursor: pointer;
  padding: 4px;
  transition: color 0.3s ease, transform 0.2s ease;
  flex-shrink: 0;
}

#send-btn:hover {
  color: var(--gold-warm);
  transform: scale(1.1);
}

/* ══════ UPLOAD / DOWNLOAD ══════ */
.upload-btn {
  background: none;
  border: none;
  color: var(--text-soft);
  cursor: pointer;
  padding: 4px;
  transition: color 0.3s ease, transform 0.2s ease;
  flex-shrink: 0;
}

.upload-btn:hover {
  color: var(--gold-warm);
  transform: scale(1.1);
}

.download-btn {
  background: none;
  border: none;
  color: var(--text-soft);
  cursor: pointer;
  padding: 4px;
  transition: color 0.3s ease;
  display: flex;
  align-items: center;
  margin-right: 8px;
}

.download-btn:hover {
  color: var(--gold-warm);
}

.pdf-context-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  background: rgba(201, 168, 76, 0.06);
  border-top: 1px solid rgba(201, 168, 76, 0.1);
  font-size: 0.8rem;
  color: var(--gold-soft);
}

.pdf-context-bar svg {
  flex-shrink: 0;
  opacity: 0.6;
}

#pdf-context-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pdf-context-clear {
  background: none;
  border: none;
  color: var(--text-soft);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 0.2s ease, background 0.2s ease;
}

.pdf-context-clear:hover {
  color: var(--gold-warm);
  background: rgba(201, 168, 76, 0.08);
}

/* ══════ VOICE ══════ */
.voice-btn {
  background: none;
  border: none;
  color: var(--text-soft);
  cursor: pointer;
  padding: 4px;
  transition: color 0.3s ease, transform 0.2s ease;
  flex-shrink: 0;
}

.voice-btn:hover {
  color: var(--gold-warm);
  transform: scale(1.1);
}

.voice-btn.active {
  color: #e57373;
  animation: pulse-mic 1.5s ease-in-out infinite;
}

@keyframes pulse-mic {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.voice-bar {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  background: rgba(229, 115, 115, 0.08);
  border-top: 1px solid rgba(229, 115, 115, 0.15);
  font-size: 0.8rem;
  color: var(--text-soft);
}

.voice-bar.visible {
  display: flex;
}

.voice-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #e57373;
  animation: pulse-dot 1.5s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

/* ══════ RESPONSIVE ══════ */
@media (max-width: 600px) {
  .auth-title { font-size: 1.4rem; }
  .auth-subtitle { font-size: 0.85rem; }
  .auth-box { width: 260px; }
  .auth-mandala-wrap { width: 220px; height: 140px; }

  #chat-area { padding: 16px 12px; }
  .msg { padding: 12px 16px; font-size: 0.9rem; }
  #messages { gap: 16px; }

  #reply-zone { padding: 12px 12px 20px; }
  .input-wrap { padding: 6px 10px; }
}

/* ══════ SELECTION ══════ */
::selection {
  background: rgba(201, 168, 76, 0.2);
  color: var(--text-primary);
}
