/* ═══════════════════════════════════════════════════════════════
   Selfa Logo Component — Phase Pulse v2.2 (final)
   ═══════════════════════════════════════════════════════════════ */

.selfa-logo {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  position: relative;
  transition: opacity 0.5s ease, transform 0.3s ease;
}

.selfa-logo.size-cursor { width: 22px; height: 22px; margin: 0 4px; }
.selfa-logo.size-avatar { width: 40px; height: 40px; }
.selfa-logo.size-thinking { width: 36px; height: 36px; }

.selfa-logo svg {
  width: 100%; height: 100%; overflow: visible; display: block;
}

@keyframes selfa-pulse-peak {
  0%, 100% { transform: scale(1);    filter: drop-shadow(0 0 4px rgba(244, 216, 147, 0.4)); }
  50%      { transform: scale(1.10); filter: drop-shadow(0 0 10px rgba(244, 216, 147, 0.7)); }
}
@keyframes selfa-pulse-high {
  0%, 100% { transform: scale(1);    filter: drop-shadow(0 0 3px rgba(201, 169, 97, 0.3)); }
  50%      { transform: scale(1.06); filter: drop-shadow(0 0 7px rgba(201, 169, 97, 0.5)); }
}
@keyframes selfa-pulse-mid {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.04); }
}
@keyframes selfa-pulse-low {
  0%, 100% { transform: scale(1);    opacity: 0.85; }
  50%      { transform: scale(1.02); opacity: 1;    }
}
@keyframes selfa-pulse-sad {
  0%, 100% { transform: scale(1);    opacity: 0.6; }
  50%      { transform: scale(1.01); opacity: 0.8; }
}

.selfa-logo.mood-peak { animation: selfa-pulse-peak 1.4s ease-in-out infinite; }
.selfa-logo.mood-high { animation: selfa-pulse-high 2.0s ease-in-out infinite; }
.selfa-logo.mood-mid  { animation: selfa-pulse-mid  2.5s ease-in-out infinite; }
.selfa-logo.mood-low  { animation: selfa-pulse-low  3.5s ease-in-out infinite; }
.selfa-logo.mood-sad  { animation: selfa-pulse-sad  5.0s ease-in-out infinite; }

.selfa-logo[data-mood="serene"]     svg { filter: hue-rotate(0deg) saturate(1.0) drop-shadow(0 0 4px var(--gold, #d4af37)); }
.selfa-logo[data-mood="joyful"]     svg { filter: hue-rotate(10deg) saturate(1.3) brightness(1.15) drop-shadow(0 0 6px var(--gold-bright, #f0c850)); }
.selfa-logo[data-mood="growing"]    svg { filter: hue-rotate(75deg) saturate(1.1) drop-shadow(0 0 5px var(--green-soft, #4ade80)); }
.selfa-logo[data-mood="reflective"] svg { filter: hue-rotate(180deg) saturate(0.9) drop-shadow(0 0 4px var(--layer-2, #60a5fa)); }
.selfa-logo[data-mood="curious"]    svg { filter: hue-rotate(220deg) saturate(1.0) drop-shadow(0 0 5px var(--layer-1, #a78bfa)); }

/* Hide the big geodesic icon and the tagline */
.header .logo > svg.logo-brain { display: none; }
.header .logo .logo-tagline    { display: none; }

/* "Selfa" text + mood bar in one left-aligned group */
.logo-mood-wrap {
  display: flex; flex-direction: row; align-items: center; gap: 14px;
}
.logo-mood-wrap > .logo-row { display: flex; align-items: center; }
.logo-mood-wrap > #moodBar.mood-bar {
  flex: 0 0 auto; justify-content: flex-start; margin: 0; align-self: center;
}

/* Inline cursor while typing */
.selfa-inline-cursor {
  display: inline-block; width: 20px; height: 20px;
  vertical-align: -5px; margin: 0 4px 0 2px;
  position: relative; opacity: 0; transition: opacity 0.4s ease;
}
.selfa-inline-cursor.visible { opacity: 1; }

/* Trailing logo (after typing) — large, on its own line, clickable */
.selfa-trailing-logo {
  display: block; width: 160px; height: 160px;
  margin: 20px 0 12px 0; opacity: 1; cursor: pointer;
}
.selfa-trailing-logo:hover { transform: scale(1.05); }

/* Typing logo (replaces "SELFA •••") */
.selfa-typing-logo { display: inline-block; margin: 4px 0; }
#typing .typing-author, #typing .typing-dots { display: none !important; }
#typing { min-height: 72px; align-items: center; } #typing:not(.hidden) { display: flex; } #typing.hidden { display: none !important; }

.msg-content .word { opacity: 0; display: inline; white-space: pre-wrap; }
.msg-content .word.visible { opacity: 1; transition: opacity 0.15s ease; }

@media (prefers-reduced-motion: reduce) {
  .selfa-logo, .selfa-logo.mood-peak, .selfa-logo.mood-high,
  .selfa-logo.mood-mid, .selfa-logo.mood-low, .selfa-logo.mood-sad {
    animation: none !important;
  }
  .msg-content .word { opacity: 1; transition: none; }
}


/* ═══════════════════════════════════════════════════════════════
   Compact header right-side: push all identity-bar items + email
   + settings + logout into a tight cluster on the far end.
   ═══════════════════════════════════════════════════════════════ */
.header {
  justify-content: flex-start;
  gap: 16px;
}
.header > .identity-bar,
.header > #identityBar {
  margin-inline-start: auto;
  gap: 8px;
}
.header > .identity-bar .header-actions,
.header > #identityBar .header-actions {
  gap: 6px;
}
.header > .identity-bar .identity-display,
.header > #identityBar .identity-display {
  margin-inline-end: 8px;
}

/* ═══════════════════════════════════════════════════════════════
   Center the IDENTITY badge in the header; keep action icons
   clustered on the left near the logout button.
   ═══════════════════════════════════════════════════════════════ */
.header > .identity-bar,
.header > #identityBar {
  flex: 1;
  display: flex;
  align-items: center;
  position: relative;
  margin-inline-start: 0;
}
.header > .identity-bar .identity-display,
.header > #identityBar .identity-display {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
}
.header > .identity-bar .header-actions,
.header > #identityBar .header-actions {
  margin-inline-start: auto;
}

/* ═══════════════════════════════════════════════════════════════
   Goals Badge (Phase Goals 3a)
   A compact pill in the header showing the user's active monthly
   challenge. Click to expand (popover added in 3b).
   ═══════════════════════════════════════════════════════════════ */
.goals-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px var(--s4);
  background: var(--bg-elevated);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-sm);
  color: var(--gold-soft);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 0.2s ease;
  margin: 0 8px;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.goals-badge:hover {
  border-color: var(--gold-soft);
  filter: brightness(1.15);
}
.goals-badge.empty {
  color: var(--text-muted, #888);
  opacity: 0.7;
}
.goals-badge.empty:hover {
  opacity: 1;
}
.goals-badge-icon { font-size: 14px; line-height: 1; }
.goals-badge-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 170px;
  font-family: inherit;
}

/* ═══════════════════════════════════════════════════════════════
   Goals Popover (Phase Goals 3b)
   ═══════════════════════════════════════════════════════════════ */
.goals-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 50%;
  transform: translateX(50%);
  width: 320px;
  max-width: 90vw;
  background: #1a1a1a;
  border: 1px solid rgba(180, 140, 70, 0.3);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
  z-index: 1000;
  text-align: right;
  direction: rtl;
}
/* LTR languages (English) override */
html[dir="ltr"] .goals-popover {
  text-align: left;
  direction: ltr;
}
.goals-popover.hidden { display: none; }
.goals-popover-section { margin-bottom: 12px; }
.goals-popover-label {
  font-size: 11px;
  color: #d4b378;
  font-weight: 600;
  margin-bottom: 6px;
  opacity: 0.85;
}
.goals-popover-title {
  font-size: 14px;
  color: #f5f5f5;
  font-weight: 500;
  margin-bottom: 4px;
  line-height: 1.4;
}
.goals-popover-why {
  font-size: 12px;
  color: #aaa;
  line-height: 1.5;
  margin-bottom: 8px;
}
.goals-popover-progress { margin-top: 8px; }
.goals-progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 4px;
}
.goals-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #d4b378, #e8c98f);
  border-radius: 3px;
  transition: width 0.4s ease;
}
.goals-progress-text {
  font-size: 11px;
  color: #888;
}
.goals-popover-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 12px 0;
}
.goals-popover-empty {
  padding: 12px;
  text-align: center;
  color: #888;
  font-size: 13px;
  line-height: 1.6;
}
.goals-popover-empty.hidden { display: none; }
.goals-popover-section.hidden { display: none; }

/* Make identity-bar a positioning context so popover sits below badge */
.identity-bar { position: relative; }
