/* ═══════════════════════════════════════════════════════════════
   AI ASSISTANT — premium floating card (monochrome + ambient glow)
═══════════════════════════════════════════════════════════════ */

/* ── Stage (mount point inside .hero-right) ───────── */
.ai-stage {
  position: relative;
  width: 100%;
  max-width: 440px;
  isolation: isolate;
  transform-origin: center center;
  animation: ai-stage-in 1s var(--ease) .15s backwards;
}
@keyframes ai-stage-in {
  from { opacity: 0; transform: translateY(18px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Ambient orbit glow behind the card ───────────── */
.ai-orbit {
  position: absolute;
  inset: -40px -30px -60px -30px;
  background:
    radial-gradient(60% 50% at 30% 20%, rgba(26,26,28,.08), transparent 70%),
    radial-gradient(55% 45% at 80% 80%, rgba(26,26,28,.05), transparent 70%);
  filter: blur(30px);
  z-index: -1;
  pointer-events: none;
  opacity: .95;
  animation: ai-orbit-breathe 9s ease-in-out infinite;
}
@keyframes ai-orbit-breathe {
  0%,100% { transform: translate(0,0) scale(1); opacity: .9; }
  50%     { transform: translate(-4px,-6px) scale(1.04); opacity: 1; }
}

/* ── Card shell ───────────────────────────────────── */
.ai-card {
  --ai-radius: 20px;
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--ai-radius);
  box-shadow:
    0 40px 90px -30px rgba(0,0,0,.25),
    0 18px 40px -14px rgba(0,0,0,.12),
    0 2px 0 rgba(255,255,255,.60) inset,
    0 0 0 1px rgba(255,255,255,.40) inset;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform-origin: center bottom;
  transition:
    opacity .42s var(--ease),
    transform .5s var(--ease),
    box-shadow .3s var(--ease);
  will-change: transform, opacity;
}
.ai-card:hover {
  box-shadow:
    0 48px 110px -28px rgba(0,0,0,.30),
    0 22px 46px -14px rgba(0,0,0,.14),
    0 2px 0 rgba(255,255,255,.70) inset,
    0 0 0 1px rgba(255,255,255,.50) inset;
}
.ai-card.is-hidden {
  opacity: 0;
  transform: translateY(18px) scale(.94);
  pointer-events: none;
}

/* Soft inner glow at top of card */
.ai-glow {
  position: absolute;
  top: -60%; left: -20%; right: -20%; height: 120%;
  background: radial-gradient(ellipse at center top, rgba(26,26,28,.05), transparent 55%);
  pointer-events: none;
  z-index: 0;
}

/* ── Header ───────────────────────────────────────── */
.ai-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem .95rem;
  background:
    linear-gradient(180deg, #1A1A1C 0%, #141415 100%);
  color: #F5F4F0;
  z-index: 1;
}
.ai-header::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 80% at 0% 0%, rgba(245,244,240,.06), transparent 55%),
    radial-gradient(90% 60% at 100% 100%, rgba(245,244,240,.04), transparent 60%);
  pointer-events: none;
}
.ai-header::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(245,244,240,.14) 25%,
    rgba(245,244,240,.28) 50%,
    rgba(245,244,240,.14) 75%,
    transparent 100%);
}

.ai-head-left {
  display: flex;
  align-items: center;
  gap: .85rem;
  min-width: 0;
  position: relative;
  z-index: 1;
}

/* Avatar with pulsing ring */
.ai-avatar {
  position: relative;
  width: 40px; height: 40px;
  border-radius: 11px;
  background: rgba(245,244,240,.06);
  border: 1px solid rgba(245,244,240,.14);
  display: flex; align-items: center; justify-content: center;
  color: rgba(245,244,240,.94);
  flex-shrink: 0;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.10),
    0 2px 8px rgba(0,0,0,.20);
}
.ai-avatar svg { width: 22px; height: 22px; }
.ai-avatar-ring {
  position: absolute;
  inset: -4px;
  border-radius: 14px;
  border: 1px solid rgba(110,231,161,.35);
  opacity: 0;
  animation: ai-ring-pulse 3.5s ease-out infinite;
}
@keyframes ai-ring-pulse {
  0%   { opacity: 0;   transform: scale(.9); }
  35%  { opacity: .55; transform: scale(1.02); }
  100% { opacity: 0;   transform: scale(1.15); }
}

.ai-head-info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.ai-head-name {
  font-family: 'Oswald', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: .045em;
  text-transform: uppercase;
  color: #F5F4F0;
  line-height: 1.1;
}
.ai-head-name em {
  font-style: normal;
  color: rgba(245,244,240,.55);
  font-weight: 400;
  margin-left: .28rem;
  letter-spacing: .12em;
}
.ai-head-status {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: .62rem;
  letter-spacing: .08em;
  color: rgba(245,244,240,.55);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ai-status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #6EE7A1;
  box-shadow: 0 0 0 3px rgba(110,231,161,.18);
  animation: ai-pulse 2s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes ai-pulse {
  0%,100% { box-shadow: 0 0 0 3px rgba(110,231,161,.20); }
  50%     { box-shadow: 0 0 0 7px rgba(110,231,161,.02); }
}

.ai-close {
  position: relative;
  z-index: 1;
  width: 32px; height: 32px;
  border-radius: 9px;
  background: rgba(245,244,240,.06);
  border: 1px solid rgba(245,244,240,.10);
  color: rgba(245,244,240,.80);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .2s, border-color .2s, color .2s, transform .25s var(--ease);
}
.ai-close:hover {
  background: rgba(245,244,240,.14);
  border-color: rgba(245,244,240,.22);
  color: #fff;
  transform: rotate(90deg);
}
.ai-close:active { transform: rotate(90deg) scale(.92); }

/* ── Body ─────────────────────────────────────────── */
.ai-body {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-card);
}

/* Messages */
.ai-messages {
  padding: 1.1rem 1.1rem .5rem;
  min-height: 240px;
  max-height: 300px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: .55rem;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: var(--text-3) transparent;
  /* subtle top/bottom fade */
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 12px, #000 calc(100% - 8px), transparent 100%);
  mask-image: linear-gradient(to bottom, transparent 0, #000 12px, #000 calc(100% - 8px), transparent 100%);
}
.ai-messages::-webkit-scrollbar { width: 4px; }
.ai-messages::-webkit-scrollbar-track { background: transparent; }
.ai-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.ai-messages::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

.ai-msg {
  max-width: 86%;
  padding: .7rem .9rem;
  border-radius: 14px;
  font-size: .84rem;
  line-height: 1.55;
  letter-spacing: .005em;
  word-wrap: break-word;
  position: relative;
  animation: ai-msg-in .4s var(--ease);
}
@keyframes ai-msg-in {
  from { opacity: 0; transform: translateY(8px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.ai-msg.bot {
  align-self: flex-start;
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-top-left-radius: 5px;
  box-shadow: 0 2px 8px rgba(0,0,0,.03);
}
.ai-msg.user {
  align-self: flex-end;
  background: linear-gradient(180deg, #222226 0%, #18181A 100%);
  color: #F5F4F0;
  border-top-right-radius: 5px;
  box-shadow:
    0 6px 16px rgba(26,26,28,.28),
    inset 0 1px 0 rgba(255,255,255,.08);
}
.ai-msg a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
  transition: text-decoration-thickness .15s;
}
.ai-msg a:hover { text-decoration-thickness: 2px; }
.ai-msg strong { font-weight: 600; }

.ai-msg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .6rem;
}
.ai-msg-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .4rem .7rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-family: 'Inter', sans-serif;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text);
  cursor: pointer;
  transition: background .18s, border-color .18s, color .18s, transform .2s var(--ease), box-shadow .18s;
}
.ai-msg-btn:hover {
  background: var(--accent);
  color: #F5F4F0;
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(26,26,28,.22);
}
.ai-msg-btn svg { width: 11px; height: 11px; }

/* Typing indicator */
.ai-msg.typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: .75rem 1rem;
}
.ai-msg.typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-3);
  animation: ai-typing 1.15s ease-in-out infinite;
}
.ai-msg.typing span:nth-child(2) { animation-delay: .18s; }
.ai-msg.typing span:nth-child(3) { animation-delay: .36s; }
@keyframes ai-typing {
  0%,80%,100% { opacity: .3;  transform: translateY(0); }
  40%         { opacity: 1;   transform: translateY(-4px); }
}

/* ── Suggestion pills ─────────────────────────────── */
.ai-pills {
  display: flex;
  flex-wrap: wrap;
  gap: .36rem;
  padding: .3rem 1.1rem .95rem;
  border-bottom: 1px solid var(--border-2);
}
.ai-pill {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .38rem .78rem;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-family: 'Inter', sans-serif;
  font-size: .7rem;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  transition: background .18s, border-color .18s, color .18s, transform .2s var(--ease);
  white-space: nowrap;
}
.ai-pill::before {
  content: '';
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--text-3);
  opacity: .6;
  transition: background .18s, opacity .18s;
}
.ai-pill:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #F5F4F0;
  transform: translateY(-1px);
}
.ai-pill:hover::before { background: #6EE7A1; opacity: 1; }

/* ── Composer ─────────────────────────────────────── */
.ai-composer {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .85rem 1rem;
  background: var(--bg-card-2);
  border-top: 1px solid var(--border);
}
.ai-input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}
.ai-composer input {
  flex: 1;
  width: 100%;
  min-width: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: .68rem 3rem .68rem .9rem;
  font-family: 'Inter', sans-serif;
  font-size: .84rem;
  color: var(--text);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
.ai-composer input::placeholder { color: var(--text-3); }
.ai-composer input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26,26,28,.07);
}
.ai-kbd {
  position: absolute;
  right: .6rem;
  top: 50%;
  transform: translateY(-50%);
  font-family: 'JetBrains Mono', monospace;
  font-size: .58rem;
  letter-spacing: .08em;
  color: var(--text-3);
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 6px;
  pointer-events: none;
  opacity: .85;
  transition: opacity .2s;
}
.ai-composer input:focus + .ai-kbd { opacity: 0; }

.ai-composer button {
  width: 40px; height: 40px;
  border-radius: 11px;
  background: linear-gradient(180deg, #222226 0%, #18181A 100%);
  border: none;
  color: #F5F4F0;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform .2s var(--ease), box-shadow .2s, opacity .2s;
  box-shadow:
    0 6px 16px rgba(26,26,28,.22),
    inset 0 1px 0 rgba(255,255,255,.08);
}
.ai-composer button:hover {
  transform: translateY(-2px) rotate(8deg);
  box-shadow:
    0 10px 22px rgba(26,26,28,.30),
    inset 0 1px 0 rgba(255,255,255,.12);
}
.ai-composer button:active { transform: translateY(0) rotate(0) scale(.94); }
.ai-composer button:disabled { opacity: .35; cursor: not-allowed; transform: none; box-shadow: none; }

/* ── Footnote ─────────────────────────────────────── */
.ai-footnote {
  padding: .55rem 1rem;
  background: var(--bg-card-2);
  border-top: 1px solid var(--border-2);
  font-family: 'JetBrains Mono', monospace;
  font-size: .56rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-3);
  text-align: center;
  position: relative;
  z-index: 1;
}
.ai-footnote span { opacity: .75; }

/* ── Reopen chip (shown when closed) ──────────────── */
.ai-reopen {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(.9);
  display: none;
  align-items: center;
  gap: .6rem;
  padding: .7rem 1.2rem .7rem .95rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  font-family: 'Inter', sans-serif;
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .04em;
  color: var(--text);
  cursor: pointer;
  box-shadow:
    0 18px 44px -14px rgba(0,0,0,.22),
    0 6px 16px -8px rgba(0,0,0,.12),
    0 0 0 1px rgba(255,255,255,.50) inset;
  opacity: 0;
  transition: opacity .35s var(--ease), transform .35s var(--ease), box-shadow .2s;
}
.ai-reopen.is-shown {
  display: inline-flex;
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.ai-reopen:hover {
  box-shadow:
    0 24px 54px -14px rgba(0,0,0,.28),
    0 10px 22px -8px rgba(0,0,0,.16),
    0 0 0 1px rgba(255,255,255,.60) inset;
  transform: translate(-50%, -50%) scale(1.03);
}
.ai-reopen-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #6EE7A1;
  box-shadow: 0 0 0 3px rgba(110,231,161,.18);
  animation: ai-pulse 2s ease-in-out infinite;
}

/* ── Responsive ───────────────────────────────────── */
@media (max-width: 1024px) {
  .ai-stage { margin: 0 auto; }
}
@media (max-width: 560px) {
  .ai-stage { max-width: 100%; }
  .ai-messages { min-height: 220px; max-height: 260px; padding: .95rem .9rem .3rem; }
  .ai-pills { padding: .25rem .9rem .85rem; }
  .ai-composer { padding: .72rem .85rem; }
  .ai-head-status { font-size: .58rem; }
  .ai-footnote { font-size: .52rem; padding: .5rem .85rem; }
}
