/* ============================================================================
 * DrNick widget · CHARACTER PRESENCE LAYER
 * ----------------------------------------------------------------------------
 * Makes the DrNick character feel present in the UI using ONLY the existing
 * assets (avt-bot.png portrait, bot.png full body) + CSS. No new artwork.
 *
 * Built on the same tokens as widget.css / themes.css, so every state themes
 * automatically (dark default + [data-theme="light"]). Motion is restrained:
 * slow (2.4–3.2s), breathing not blinking, all gated on prefers-reduced-motion.
 *
 * Load order:  colors_and_type.css → components.css → widget.css → themes.css
 *              → avatar.css
 *
 * Reusable presence component:
 *   <span class="dn-ava sm is-thinking"><span class="dn-ava-orbit"></span>
 *     <img class="dn-ava-img" src="assets/avt-bot.png" alt=""></span>
 * Sizes:  xs(28) · sm(40) · md(56) · lg(88) · xl(112)
 * States: (idle) · is-present · is-thinking · is-streaming · is-serious · is-offline
 * ==========================================================================*/

.dn-ava {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: var(--r-full);
}
.dn-ava-img {
  display: block;
  border-radius: var(--r-full);
  object-fit: cover;
  object-position: 50% 16%;        /* frame the face */
  border: 1px solid var(--gold-line);
  background: var(--dn-fab-img-b);
  position: relative; z-index: 1;
}
.dn-ava.xs .dn-ava-img { width: 28px;  height: 28px; }
.dn-ava.sm .dn-ava-img { width: 40px;  height: 40px; }
.dn-ava.md .dn-ava-img { width: 56px;  height: 56px; }
.dn-ava.lg .dn-ava-img { width: 88px;  height: 88px; }
.dn-ava.xl .dn-ava-img { width: 112px; height: 112px; }

/* warm halo behind the portrait — "the advisor is here" */
.dn-ava-halo {
  position: absolute; inset: -26%;
  border-radius: 50%;
  background: radial-gradient(circle, var(--gold-soft), transparent 62%);
  pointer-events: none; z-index: 0;
}

/* idle presence dot (online) */
.dn-ava-dot {
  position: absolute; right: 4%; bottom: 4%;
  width: 26%; max-width: 12px; aspect-ratio: 1;
  border-radius: 50%;
  background: var(--pos);
  border: 2px solid var(--bg);
  box-shadow: 0 0 8px rgba(45,195,133,0.5);
  z-index: 2;
}

/* ── PRESENT · very slow halo breathe (welcome) ───────────────────────────── */
.dn-ava.is-present .dn-ava-halo {
  animation: dn-halo-breathe 4.6s var(--ease) infinite;
}
@keyframes dn-halo-breathe {
  0%, 100% { transform: scale(1);    opacity: 0.85; }
  50%      { transform: scale(1.08); opacity: 1; }
}

/* ── THINKING · faint breathing ring + one slow orbiting dot ──────────────── */
.dn-ava.is-thinking::before {
  content: ""; position: absolute; inset: -5px;
  border-radius: 50%;
  border: 1px solid var(--gold-line);
  animation: dn-ring-breathe 3.2s var(--ease) infinite;
  z-index: 0;
}
.dn-ava-orbit { position: absolute; inset: -5px; border-radius: 50%; z-index: 2; pointer-events: none; }
.dn-ava.is-thinking .dn-ava-orbit { animation: dn-orbit 3.2s linear infinite; }
.dn-ava.is-thinking .dn-ava-orbit::before {
  content: ""; position: absolute; top: -3px; left: 50%;
  width: 6px; height: 6px; margin-left: -3px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px var(--gold-glow);
}
@keyframes dn-orbit       { to { transform: rotate(360deg); } }
@keyframes dn-ring-breathe { 0%,100% { transform: scale(1); opacity: 0.45; } 50% { transform: scale(1.07); opacity: 0.9; } }

/* ── STREAMING · gentle alive glow on the portrait ────────────────────────── */
.dn-ava.is-streaming .dn-ava-img {
  animation: dn-ava-glow 2.4s var(--ease) infinite;
}
@keyframes dn-ava-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 194, 67,0); border-color: var(--gold-line); }
  50%      { box-shadow: 0 0 14px 1px var(--gold-glow); border-color: var(--gold); }
}

/* ── SERIOUS · steady strong gold ring (a transaction is on the table) ────── */
/* Minimal motion by design — gravity reads as stillness, not animation. */
.dn-ava.is-serious .dn-ava-img {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-soft), 0 0 16px var(--gold-glow);
}
.dn-ava.is-serious::after {
  content: ""; position: absolute; inset: -6px;
  border-radius: 50%;
  border: 1.5px solid var(--gold-line);
  z-index: 0;
}

/* ── OFFLINE · desaturated, calm, no motion ───────────────────────────────── */
.dn-ava.is-offline .dn-ava-img {
  filter: grayscale(1) brightness(0.92);
  border-color: var(--line-strong);
  opacity: 0.85;
}
.dn-ava.is-offline .dn-ava-dot { background: var(--fg-4); box-shadow: none; }

/* ============================================================================
 * FAB · face + presence + new-message
 * ==========================================================================*/
/* idle face crop already in widget.css. New-message adds badge + ONE calm
 * expanding ring (a single slow radar pulse, not a strobe). */
.dn-fab.has-new::after {
  content: ""; position: absolute; inset: 0;
  border-radius: 50%;
  border: 1.5px solid var(--gold-line);
  animation: dn-fab-attn 3s var(--ease-out) infinite;
  pointer-events: none;
}
@keyframes dn-fab-attn {
  0%        { transform: scale(1);    opacity: 0.7; }
  70%, 100% { transform: scale(1.48); opacity: 0; }
}
.dn-fab-badge {
  position: absolute; top: -3px; right: -3px;
  min-width: 21px; height: 21px; padding: 0 5px;
  border-radius: var(--r-full);
  background: var(--gold); color: var(--ink);
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: 11px; font-weight: 700; line-height: 1;
  display: grid; place-items: center;
  border: 2px solid var(--bg);
  z-index: 3;
}

/* optional calm nudge bubble above the FAB */
.dn-fab-nudge {
  position: absolute; right: 0; bottom: 78px;
  width: max-content; max-width: 220px;
  padding: 11px 13px;
  background: var(--elevated);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-2);
  font-size: 12.5px; line-height: 1.45; color: var(--fg-2);
}
.dn-fab-nudge b { color: var(--fg-1); font-weight: 700; }
.dn-fab-nudge::after {
  content: ""; position: absolute; right: 22px; bottom: -6px;
  width: 11px; height: 11px;
  background: var(--elevated);
  border-right: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  transform: rotate(45deg);
}

/* ============================================================================
 * WELCOME · featured warm character (the advisor is here, waiting)
 * ==========================================================================*/
.dn-welcome-hero {
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  padding: 30px 24px 10px;
}
.dn-welcome-hero .dn-ava { margin-bottom: 18px; }
.dn-welcome-hero .dn-eyebrow { justify-content: center; }
.dn-welcome-hero .dn-welcome-h {
  margin: 14px 0 0; max-width: 18ch;
  font-size: 23px; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em;
  color: var(--fg-1); text-wrap: balance;
}
.dn-welcome-hero .dn-welcome-sub {
  margin: 11px auto 0; max-width: 34ch;
  font-size: 13.5px; line-height: 1.6; color: var(--fg-3);
}
.dn-welcome-hero .dn-chips {
  width: 100%; padding: 22px 0 0; margin-top: 4px;
}

/* ============================================================================
 * STATEFUL BODY · empty / error with the character present
 * ==========================================================================*/
.dn-state {
  display: flex; flex-direction: column; align-items: center;
  text-align: center;
  padding: 40px 28px;
  min-height: 100%;
  justify-content: center; gap: 4px;
}
.dn-state .dn-ava { margin-bottom: 18px; }
.dn-state-h {
  margin: 0; font-size: 18px; font-weight: 700; letter-spacing: -0.01em;
  color: var(--fg-1);
}
.dn-state-p {
  margin: 9px 0 0; max-width: 30ch;
  font-size: 13.5px; line-height: 1.6; color: var(--fg-3);
}
.dn-state-actions { display: flex; gap: 9px; margin-top: 22px; }
.dn-state-actions .onfa-btn { min-height: 40px; font-size: 13.5px; }
/* reconnecting micro-status (calm, mono) */
.dn-state-status {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 16px;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--fg-4);
}
.dn-state-status .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--fg-4);
  animation: onfa-pulse 1.6s ease-in-out infinite;
}

/* ── reduced motion: presence holds its end-state, no looping ─────────────── */
@media (prefers-reduced-motion: reduce) {
  .dn-ava.is-present .dn-ava-halo,
  .dn-ava.is-thinking::before,
  .dn-ava.is-thinking .dn-ava-orbit,
  .dn-ava.is-streaming .dn-ava-img,
  .dn-fab.has-new::after,
  .dn-state-status .dot { animation: none; }
  .dn-ava.is-streaming .dn-ava-img { box-shadow: 0 0 12px var(--gold-glow); border-color: var(--gold); }
  .dn-ava.is-thinking .dn-ava-orbit::before { top: -3px; } /* dot rests at 12 o'clock */
}
