/* =============================================
   ADVISOR ORB — Living portrait + council chamber
   ============================================= */

/* ── Orb Wrapper (holds circle + speech bubble) ── */
.orb-wrap {
  position: fixed;
  z-index: 400;
  opacity: 0;
  transition: opacity 800ms ease;
}

/* Center position (entry sequence — floating, alive, demanding attention) */
.orb-wrap.orb-at-center {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: orbFloat 3s ease-in-out infinite;
}
.orb-wrap.orb-at-center .orb-circle {
  width: 130px;
  height: 130px;
}

/* Floating / bobbing at center — organic, not mechanical */
@keyframes orbFloat {
  0%, 100% { transform: translate(-50%, -50%) translateY(0) translateX(0); }
  20%      { transform: translate(-50%, -50%) translateY(-10px) translateX(4px); }
  40%      { transform: translate(-50%, -50%) translateY(-4px) translateX(-5px); }
  60%      { transform: translate(-50%, -50%) translateY(-12px) translateX(3px); }
  80%      { transform: translate(-50%, -50%) translateY(-3px) translateX(-2px); }
}

/* Resting position (right side, vertical center) */
.orb-wrap.orb-at-rest {
  top: 45%;
  left: calc(100% - 130px);
  right: auto;
  transform: translateY(-50%);
}

/* Glide transition from center to rest */
.orb-wrap.orb-gliding {
  transition: top 800ms ease-out, left 800ms ease-out, transform 800ms ease-out, opacity 800ms ease;
}

/* Hidden when panel is open */
.orb-wrap.orb-hidden {
  opacity: 0;
  pointer-events: none;
  transition: opacity 300ms ease;
}

/* ── The Circle ──────────────────────────── */
.orb-circle {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid transparent;
  cursor: pointer;
  position: relative;
  background-clip: padding-box;
  animation: orbGlow 3s ease-in-out infinite alternate;
  transition: width 500ms ease, height 500ms ease, box-shadow 300ms ease;
}
/* Mute toggle */
.orb-mute {
  position: absolute;
  bottom: -8px;
  right: -8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  transition: background 0.2s;
  padding: 0;
}
.orb-mute:hover { background: var(--surface-2); }

/* Holographic spinning border — lemonslice style */
.orb-circle::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, #f0c040, #40f0c0, #c040f0, #f04080, #f0c040);
  animation: borderSpin 4s linear infinite;
  z-index: -1;
}
@keyframes borderSpin {
  to { transform: rotate(360deg); }
}
.orb-circle:hover {
  box-shadow: 0 0 40px rgba(240, 192, 64, 0.6);
  transform: scale(1.05);
}

/* Glow animation */
@keyframes orbGlow {
  0%   { box-shadow: 0 0 15px 0 rgba(240, 192, 64, 0.3), 0 0 4px 0 rgba(240, 192, 64, 0.6); }
  100% { box-shadow: 0 0 30px 5px rgba(240, 192, 64, 0.5), 0 0 8px 0 rgba(240, 192, 64, 0.8); }
}

/* ── Parallax Layer (moves with mouse) ───── */
.orb-parallax {
  width: 100%;
  height: 100%;
  transition: transform 50ms linear; /* smoothed in JS via rAF */
}

/* ── The Portrait Image ──────────────────── */
.orb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 15%;
  position: absolute;
  top: 0;
  left: 0;
  animation: orbBreathe 4s ease-in-out infinite alternate, orbFirelight 6s ease-in-out infinite;
  will-change: transform, filter;
}

/* Video portrait in the orb circle */
.orb-vid {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 15%;
  position: absolute;
  top: 0;
  left: 0;
  border-radius: inherit;
  pointer-events: none;
}

/* Breathing — the person inhales/exhales */
@keyframes orbBreathe {
  0%   { transform: scale(1.0) translateY(0); }
  100% { transform: scale(1.06) translateY(-1px); }
}

/* Firelight — flickering torchlight on the face */
@keyframes orbFirelight {
  0%   { filter: brightness(1.0) contrast(1.0); }
  15%  { filter: brightness(1.07) contrast(1.02); }
  35%  { filter: brightness(0.96) contrast(1.01); }
  55%  { filter: brightness(1.04) contrast(0.99); }
  75%  { filter: brightness(0.98) contrast(1.03); }
  100% { filter: brightness(1.0) contrast(1.0); }
}

/* ── Speech Bubble ───────────────────────── */
.orb-speech {
  position: absolute;
  right: calc(100% + 14px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--surface-2);
  color: var(--gold);
  font-size: 13px;
  font-style: italic;
  line-height: 1.4;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  white-space: normal;
  max-width: 240px;
  width: max-content;
  opacity: 0;
  pointer-events: none;
  transition: opacity 500ms ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  z-index: 401;
}
.orb-speech.visible {
  opacity: 1;
  pointer-events: auto;
}
/* Arrow pointing right toward orb */
.orb-speech::after {
  content: '';
  position: absolute;
  right: -8px;
  top: 50%;
  margin-top: -6px;
  border: 6px solid transparent;
  border-left-color: var(--surface-2);
}

/* Center-stage speech bubble — below the orb, bigger, attention-grabbing */
.orb-wrap.orb-at-center .orb-speech {
  right: auto;
  left: 50%;
  top: calc(100% + 16px);
  transform: translateX(-50%);
  white-space: normal;
  text-align: center;
  max-width: 300px;
  font-size: 15px;
  padding: 16px 24px 20px;
  border: 1px solid var(--gold);
  cursor: pointer;
  animation: speechPulse 2s ease-in-out infinite;
  line-height: 1.6;
}
.orb-wrap.orb-at-center .orb-speech.visible {
  transform: translateX(-50%);
}
.orb-wrap.orb-at-center .orb-speech::after {
  right: auto;
  left: 50%;
  top: -10px;
  bottom: auto;
  margin-left: -6px;
  margin-top: 0;
  border: 6px solid transparent;
  border-bottom-color: var(--gold);
  border-left-color: transparent;
}
@keyframes speechPulse {
  0%, 100% { box-shadow: 0 0 8px rgba(240, 192, 64, 0.2); }
  50%      { box-shadow: 0 0 20px rgba(240, 192, 64, 0.5); }
}
.orb-tap-hint {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  font-style: normal;
  font-weight: 600;
  letter-spacing: 0.5px;
  opacity: 0.7;
  animation: hintPulse 1.5s ease-in-out infinite;
}
@keyframes hintPulse {
  0%, 100% { opacity: 0.5; }
  50%      { opacity: 1; }
}

/* ── Backdrop ────────────────────────────── */
.orb-backdrop {
  position: fixed;
  inset: 0;
  z-index: 390;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 400ms ease;
}
.orb-backdrop.visible {
  opacity: 1;
  pointer-events: all;
}

/* ── Council Chamber Panel ───────────────── */
.orb-panel {
  position: fixed;
  top: 50%;
  right: 30px;
  transform: translateY(-50%) scale(0.9);
  z-index: 500;
  width: 400px;
  max-height: 600px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6), 0 0 30px rgba(240, 192, 64, 0.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 400ms ease, transform 400ms cubic-bezier(0.4, 0, 0.2, 1);
}
.orb-panel.visible {
  opacity: 1;
  pointer-events: all;
  transform: translateY(-50%) scale(1);
}

/* Panel portrait — she must be SEEN. Face, expression, posture. */
.orb-panel-portrait {
  width: 100%;
  height: 300px;
  overflow: hidden;
  position: relative;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.orb-panel-portrait .orb-img {
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  object-fit: contain;
  object-position: center top;
  animation: none;
}
.orb-panel-portrait video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center top;
  display: block;
}

/* Tap to hear audio overlay */
.orb-tap-audio {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: var(--gold);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 24px;
  cursor: pointer;
  z-index: 3;
  backdrop-filter: blur(4px);
  border: 1px solid var(--gold);
  animation: orbMsgIn 400ms ease both;
  white-space: nowrap;
}
.orb-tap-audio:hover {
  background: var(--gold);
  color: var(--bg);
}

/* Minimize button */
.orb-panel-min {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  transition: background 200ms;
  z-index: 2;
}
.orb-panel-min:hover { background: rgba(0, 0, 0, 0.7); }

/* Name + title */
.orb-panel-name {
  padding: 12px 16px 8px;
  font-size: 16px;
  color: var(--gold);
}
.orb-panel-name span {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
}

/* Chat area */
.orb-panel-chat {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* Messages */
.orb-msg { display: flex; }
.orb-msg-adv { justify-content: flex-start; }
.orb-msg-usr { justify-content: flex-end; }

.orb-msg-bub {
  max-width: 88%;
  font-size: 13px;
  line-height: 1.6;
  padding: 10px 14px;
  border-radius: 12px;
  animation: orbMsgIn 300ms ease both;
}
@keyframes orbMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.orb-msg-adv .orb-msg-bub {
  background: var(--surface-2);
  color: var(--text-muted);
  border-radius: 12px 12px 12px 4px;
  border-left: 3px solid var(--gold);
}
.orb-msg-usr .orb-msg-bub {
  background: var(--gold);
  color: var(--bg);
  border-radius: 12px 12px 4px 12px;
  font-weight: 500;
}
.orb-msg-bub strong { color: var(--text); }
.orb-msg-adv .orb-msg-bub em { color: var(--gold); font-style: normal; font-weight: 600; }

/* Tips in messages */
.orb-tip {
  font-size: 12px;
  line-height: 1.5;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.orb-tip:last-child { border-bottom: none; }
.orb-tip strong { color: var(--gold); font-size: 13px; }
.orb-tip span { color: var(--text-muted); }

/* Input / quick replies area */
.orb-panel-input {
  padding: 10px 16px 14px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}
.orb-replies {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.orb-reply-btn {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: border-color 200ms, background 200ms;
}
.orb-reply-btn:hover {
  border-color: var(--gold);
  background: var(--surface);
}

/* ── Cookie Consent Banner ────────────────── */
.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9000;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.4);
}
.cookie-text {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
  flex: 1;
}
.cookie-buttons {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.cookie-btn {
  padding: 8px 16px;
  font-size: 13px;
  white-space: nowrap;
}
@media (max-width: 640px) {
  .cookie-banner { flex-direction: column; text-align: center; }
  .cookie-buttons { width: 100%; }
  .cookie-btn { flex: 1; }
}

/* ── Advisory Voice ───────────────────────── */
.advice-advisor {
  color: var(--gold);
  font-weight: 600;
  font-style: italic;
}
.advice-insight {
  border-left: 3px solid var(--gold);
  background: rgba(240, 192, 64, 0.05);
}

/* ── Sidebar Advisor Panel ────────────────── */
.sb-advisor {
  padding: 12px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.sb-adv-teaser {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 8px;
}
.sb-adv-teaser-icon { font-size: 18px; }

.sb-adv-card {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
}

.sb-adv-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.sb-adv-img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--gold);
  flex-shrink: 0;
}

.sb-adv-info { flex: 1; min-width: 0; }

.sb-adv-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sb-adv-arch {
  font-size: 11px;
  color: var(--text-muted);
}

.sb-adv-level {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: transparent;
  border: 2px solid var(--gold);
  color: var(--gold);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sb-adv-xp-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sb-adv-xp-bar {
  flex: 1;
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}

.sb-adv-xp-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 3px;
  transition: width 600ms ease;
}

.sb-adv-xp-label {
  font-size: 10px;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 55px;
  text-align: right;
}

/* ── Level-Up Banner ─────────────────────── */
.levelup-banner {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  z-index: 700;
  background: linear-gradient(135deg, #1a1608, #2d2410);
  border: 2px solid var(--gold);
  color: var(--gold);
  padding: 14px 28px;
  border-radius: 12px;
  font-size: 15px;
  box-shadow: 0 4px 24px rgba(240, 192, 64, 0.3);
  opacity: 0;
  transition: opacity 400ms ease, transform 400ms ease;
  pointer-events: none;
  white-space: nowrap;
}
.levelup-banner.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.levelup-icon { font-size: 18px; }

/* XP Toast notification */
.xp-toast {
  position: fixed;
  top: 70px;
  right: 30px;
  z-index: 600;
  background: var(--gold);
  color: var(--bg);
  font-size: 15px;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(240, 192, 64, 0.4);
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 300ms ease, transform 300ms ease;
  pointer-events: none;
}
.xp-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ── AI Chat Input Row ────────────────────── */
.orb-chat-input-row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.orb-chat-input-row input {
  flex: 1;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
.orb-chat-input-row input:focus {
  outline: none;
  border-color: var(--gold);
}
.orb-chat-input-row input::placeholder { color: var(--text-muted); }
.orb-chat-send-btn {
  padding: 10px 16px;
  background: var(--gold);
  color: var(--bg);
  border: none;
  border-radius: 8px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.orb-chat-send-btn:hover { opacity: 0.9; }

/* Energy bar */
.orb-energy-wrap {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-muted);
}
.orb-energy-track {
  height: 4px;
  background: var(--bg);
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
}
.orb-energy-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 2px;
  transition: width 400ms ease;
}

/* Typing dots */
.typing-dots {
  display: inline-block;
  animation: typingPulse 1.2s ease-in-out infinite;
  color: var(--gold);
  font-size: 18px;
  letter-spacing: 3px;
}
@keyframes typingPulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* In-chat Player ID input */
.orb-fid-input {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.orb-fid-input input {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  box-sizing: border-box;
}
.orb-fid-input input:focus {
  outline: none;
  border-color: var(--gold);
}
.orb-fid-input input::placeholder {
  color: var(--text-muted);
}

/* ── Alliance Card in Sidebar ─────────────── */
.sb-alliance {
  padding: 12px;
}
.sb-alliance-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
}
.sb-alliance-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.sb-alliance-tag {
  font-size: 14px;
  font-weight: 700;
  color: var(--gold);
}
.sb-alliance-kingdom {
  font-size: 11px;
  color: var(--text-muted);
}
.sb-alliance-role {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--gold);
  color: var(--bg);
  margin-left: auto;
}
.sb-alliance-credits {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.sb-alliance-credits strong {
  color: var(--gold);
}
.sb-alliance-actions {
  display: flex;
  gap: 6px;
}
.sb-alliance-actions a,
.sb-alliance-actions button {
  flex: 1;
  padding: 4px 8px;
  font-size: 10px;
  text-align: center;
  border-radius: 4px;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
}
.sb-alliance-link-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.sb-alliance-link-form input,
.sb-alliance-link-form select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  padding: 6px 8px;
  font-size: 12px;
  font-family: inherit;
}
.sb-alliance-link-form input:focus,
.sb-alliance-link-form select:focus {
  outline: none;
  border-color: var(--gold);
}
.sb-alliance-link-btn {
  background: var(--gold);
  color: var(--bg);
  border: none;
  border-radius: 4px;
  padding: 6px;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
}

/* ── Referral Section ─────────────────────── */
.orb-referral {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 12px;
  color: var(--text-muted);
}
.orb-referral-title {
  color: var(--gold);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.orb-referral-link {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}
.orb-referral-link input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  font-size: 11px;
  padding: 4px 8px;
  font-family: monospace;
}
.orb-referral-copy {
  background: var(--gold);
  color: var(--bg);
  border: none;
  border-radius: 4px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.orb-referral-copy:hover { opacity: 0.9; }
.orb-referral-count {
  color: var(--text-muted);
  font-size: 11px;
}
.orb-referral-badge {
  display: inline-block;
  background: var(--gold);
  color: var(--bg);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  margin-left: 6px;
}

/* ── Mobile ──────────────────────────────── */
@media (max-width: 640px) {
  .orb-wrap.orb-at-rest {
    top: auto;
    bottom: 20px;
    right: auto;
    left: 50%;
    transform: translateX(-50%);
  }
  .orb-wrap.orb-at-rest .orb-circle {
    width: 70px;
    height: 70px;
  }

  .orb-speech {
    right: auto;
    left: 50%;
    top: auto;
    bottom: calc(100% + 10px);
    transform: translateX(-50%);
    white-space: normal;
    text-align: center;
    max-width: 220px;
  }
  .orb-speech.visible { transform: translateX(-50%); }
  .orb-speech::after {
    right: auto;
    left: 50%;
    top: auto;
    bottom: -10px;
    margin-left: -6px;
    border: 6px solid transparent;
    border-top-color: var(--surface-2);
    border-left-color: transparent;
  }

  .orb-panel {
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 75vh;
    transform: translateY(20px);
    border-radius: 16px 16px 0 0;
  }
  .orb-panel.visible { transform: translateY(0); }

  .orb-panel-portrait { height: 240px; }
}
