/* ============================================================
   aura-compare.css  |  AURA Compare Widget — Doctor Advisor / Teal Theme
   TerraLeap · UpLeap Technologies
   Companion to aura-learn.css — same architecture, different behavior:
   NO persistent launcher icon. Nothing exists on screen until
   terraleap-aura-trigger.js calls window.AuraCompare.open() — the first
   time after the visitor goes idle on a course/exam page, and roughly
   every 3 minutes after that (see that file's repeat-scheduling notes).
   A doctor-with-stethoscope avatar drops in top-right with a plain
   yes/no question; only on "yes" does the comparison panel open, in
   that same top-right spot. See aura-compare.js for the public API
   (open/close) and the flow between advisor → panel.
   ============================================================ */

/* ── Advisor avatar — a complete standing doctor (not a cropped bust),
   drops in top-right (same corner the panel docks in), asks a yes/no
   question via the card below it. No backdrop: this is meant to read
   as a lightweight notification, not a takeover — especially since it
   may reappear every few minutes.

   Real 3D, not just a flat bob: .ac-advisor-badge establishes the
   `perspective`; .ac-advisor-3d is a `preserve-3d` group that continuously
   tilts (rotateY/rotateX); its two child SVGs (coat/legs behind, head +
   free-hanging arms + stethoscope in front) sit at different translateZ
   depths, so the tilt visibly separates them — a real parallax, not a
   flat card spinning. No circular crop this time — it's a free-standing
   silhouette with its own ground shadow baked into the artwork. ── */
.ac-advisor-badge {
  position: fixed;
  top: 16px;
  right: 24px;
  z-index: 10002;
  width: 140px;
  height: 210px;
  pointer-events: none;
  perspective: 700px;
  animation: ac-advisor-drop .6s cubic-bezier(.32,1.1,.4,1) both, ac-advisor-bob 2.8s ease-in-out infinite .6s;
}
.ac-advisor-3d {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  animation: ac-advisor-tilt 4s ease-in-out infinite 1.1s;
  filter: drop-shadow(0 14px 20px rgba(6,10,18,.4)) drop-shadow(0 0 22px rgba(45,212,191,.28));
}
.ac-advisor-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  backface-visibility: hidden;
}
.ac-advisor-layer-back  { transform: translateZ(0); }
.ac-advisor-layer-front { transform: translateZ(14px) scale(.97); transform-origin: 50% 30%; }
@keyframes ac-advisor-tilt {
  0%, 100% { transform: rotateY(0deg) rotateX(0deg); }
  25%      { transform: rotateY(-7deg) rotateX(2deg); }
  75%      { transform: rotateY(7deg) rotateX(-1.5deg); }
}
.ac-advisor-dot {
  position: absolute;
  top: 26px;
  right: 8px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #22c55e;
  border: 3px solid #0B2B2B;
  z-index: 3;
}
@keyframes ac-advisor-drop {
  0%   { opacity: 0; transform: translateY(-320px) rotate(-5deg) scale(.88); }
  60%  { opacity: 1; transform: translateY(9px) rotate(1.5deg) scale(1.03); }
  80%  { transform: translateY(-4px) rotate(-.5deg) scale(1); }
  100% { opacity: 1; transform: translateY(0) rotate(0deg) scale(1); }
}
@keyframes ac-advisor-bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}
.ac-advisor-badge.ac-advisor-out {
  animation: ac-advisor-vanish .3s ease-in forwards;
}
@keyframes ac-advisor-vanish {
  0%   { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-30px) scale(.7); }
}

/* ── Question card — appears just below the avatar's feet, speech-bubble
   tail pointing up at it ── */
.ac-advisor-card {
  position: fixed;
  top: 234px;
  right: 24px;
  z-index: 10002;
  width: min(280px, calc(100vw - 40px));
  background: linear-gradient(180deg, #123B3B 0%, #0B2B2B 100%);
  border: 1px solid rgba(45,212,191,.25);
  border-radius: 14px;
  padding: 14px 14px 12px;
  box-shadow: 0 20px 50px rgba(6,10,18,.5);
  opacity: 0;
  animation: ac-card-in .4s cubic-bezier(.22,1,.36,1) .2s both;
}
.ac-advisor-card::before {
  content: "";
  position: absolute;
  top: -7px;
  right: 30px;
  width: 14px;
  height: 14px;
  background: #123B3B;
  border-left: 1px solid rgba(45,212,191,.25);
  border-top: 1px solid rgba(45,212,191,.25);
  transform: rotate(45deg);
}
@keyframes ac-card-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.ac-advisor-card.ac-advisor-out {
  animation: ac-card-out .25s ease-in forwards;
}
@keyframes ac-card-out {
  to { opacity: 0; transform: translateY(-10px) scale(.96); }
}
.ac-advisor-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #5eead4;
  font-weight: 700;
  margin-bottom: 6px;
}
.ac-advisor-msg {
  font-size: 13px;
  color: #CFFAF3;
  line-height: 1.5;
  margin-bottom: 12px;
}
.ac-advisor-actions { display: flex; gap: 8px; }
.ac-advisor-btn {
  flex: 1;
  padding: 9px 10px;
  border-radius: 9px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  font-family: 'DM Sans', sans-serif;
}
.ac-advisor-btn-yes { background: linear-gradient(135deg, #14B8A6, #0E9488); color: #fff; border: none; }
.ac-advisor-btn-yes:hover { filter: brightness(1.08); }
.ac-advisor-btn-no { background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.16); color: #CFFAF3; }
.ac-advisor-btn-no:hover { background: rgba(255,255,255,.1); color: #fff; }

/* ── Panel — docks top-right, the same corner the advisor appears in,
   tall enough to show a 3-way comparison without cramping. Only
   reachable via "yes" on the advisor card. ── */
.ac-panel {
  position: fixed;
  top: 24px;
  right: 24px;
  width: min(430px, calc(100vw - 40px));
  height: min(78vh, 720px);
  z-index: 10001;
  background: linear-gradient(180deg, #1B0F33 0%, #123B3B 55%, #0B2B2B 100%);
  border-radius: 20px;
  box-shadow: 0 30px 80px rgba(6,10,18,.65), 0 4px 18px rgba(0,0,0,.3);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: 'DM Sans', 'Segoe UI', sans-serif;
  border: 1px solid rgba(45,212,191,.22);
  transform-origin: top right;
}

/* "Poof" entrance — quick overshoot scale-up + glow flash, like it just
   materialized, rather than a slide/fade. */
.ac-panel.ac-open {
  display: flex;
  animation: ac-panel-poof .5s cubic-bezier(.34,1.56,.64,1);
}
@keyframes ac-panel-poof {
  0%   { opacity: 0; transform: scale(.35); filter: brightness(2.2) blur(2px); }
  55%  { opacity: 1; transform: scale(1.04); filter: brightness(1.3) blur(0); }
  100% { opacity: 1; transform: scale(1); filter: brightness(1); }
}

/* Vanish — played briefly before navigating away via a course/register/
   login link, or on manual close. */
.ac-panel.ac-vanishing {
  animation: ac-panel-vanish .28s ease-in forwards;
  pointer-events: none;
}
@keyframes ac-panel-vanish {
  0%   { opacity: 1; transform: scale(1); filter: brightness(1) blur(0); }
  100% { opacity: 0; transform: scale(.55); filter: brightness(2) blur(3px); }
}

/* Header */
.ac-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid rgba(45,212,191,.16);
  flex-shrink: 0;
}
.ac-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #2DD4BF 0%, #1B0F33 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
  box-shadow: 0 3px 12px rgba(45,212,191,.45);
  font-size: 17px;
  line-height: 1;
}
.ac-avatar svg { width: 20px; height: 20px; position: relative; z-index: 1; }
.ac-says {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 15.5px;
  font-weight: 500;
  color: #fff;
  line-height: 1.15;
}
.ac-says em { font-style: normal; color: #5eead4; font-weight: 400; }
.ac-meta {
  font-size: 9.5px;
  color: rgba(192,132,252,.75);
  letter-spacing: .8px;
  text-transform: uppercase;
  margin-top: 2px;
}
.ac-min-btn {
  margin-left: auto;
  background: none;
  border: none;
  color: rgba(255,255,255,.5);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 10px;
  line-height: 1;
  border-radius: 6px;
}
.ac-min-btn:hover { background: rgba(255,255,255,.08); color: #fff; }

/* Body */
.ac-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(45,212,191,.3) transparent;
}
.ac-body::-webkit-scrollbar { width: 5px; }
.ac-body::-webkit-scrollbar-thumb { background: rgba(45,212,191,.3); border-radius: 3px; }

/* Messages */
.ac-msg {
  margin-bottom: 12px;
  max-width: 90%;
  animation: ac-msg-in .32s cubic-bezier(.22,1,.36,1);
}
@keyframes ac-msg-in {
  from { opacity: 0; transform: translateY(5px); }
  to   { opacity: 1; transform: translateY(0); }
}
.ac-msg.ac-bot {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(45,212,191,.2);
  color: #CFFAF3;
  border-radius: 14px 14px 14px 4px;
  padding: 10px 13px;
  font-size: 13px;
  line-height: 1.5;
}
.ac-msg.ac-bot strong { color: #fff; font-weight: 600; }
.ac-msg.ac-bot a { color: #5eead4; text-decoration: none; border-bottom: 1px dotted rgba(94,234,212,.4); }
.ac-msg.ac-user {
  background: linear-gradient(135deg, #6D28D9, #A21CAF);
  color: #fff;
  border-radius: 14px 14px 4px 14px;
  padding: 9px 13px;
  font-size: 13px;
  margin-left: auto;
  box-shadow: 0 2px 10px rgba(109,40,217,.4);
}

/* Category choice buttons (no-context picker) */
.ac-choices {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin: 6px 0 14px;
  max-width: 90%;
  animation: ac-msg-in .4s cubic-bezier(.22,1,.36,1);
}
.ac-choice {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(192,132,252,.35);
  color: #e9d5ff;
  padding: 9px 13px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  font-family: 'DM Sans', sans-serif;
  transition: all .15s ease;
  line-height: 1.35;
}
.ac-choice:hover {
  background: rgba(192,132,252,.14);
  color: #fff;
  border-color: #c084fc;
  transform: translateX(2px);
}
.ac-choice .ac-choice-icon { margin-right: 8px; opacity: .9; }

/* Course comparison cards */
.ac-compare-label {
  font-size: 9.5px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: #5eead4;
  font-weight: 700;
  margin: 4px 0 8px;
}

/* "Everything you've explored" — the full, prioritized browsing summary.
   Every tracked topic gets a row (nothing truncated); rank number reads
   left-to-right as the priority order. Rows are clickable. */
.ac-nav-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 14px;
}
.ac-nav-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(45,212,191,.18);
  border-radius: 10px;
  padding: 8px 11px;
  cursor: pointer;
  text-align: left;
  font-family: 'DM Sans', sans-serif;
  transition: all .15s ease;
}
.ac-nav-row:hover { background: rgba(45,212,191,.1); border-color: rgba(45,212,191,.4); transform: translateX(2px); }
.ac-nav-rank {
  flex: 0 0 auto;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: rgba(45,212,191,.16);
  color: #5eead4;
  font-size: 10px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  font-variant-numeric: tabular-nums;
}
.ac-nav-icon { flex: 0 0 auto; font-size: 15px; }
.ac-nav-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ac-nav-label { font-size: 12.5px; font-weight: 600; color: #fff; }
.ac-nav-views { font-size: 10.5px; color: rgba(207,250,243,.55); }
.ac-course-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 0 14px;
}
.ac-course-card {
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(45,212,191,.25);
  border-radius: 13px;
  padding: 13px 14px;
  animation: ac-msg-in .35s cubic-bezier(.22,1,.36,1);
}
.ac-course-head { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.ac-course-icon {
  width: 34px; height: 34px; border-radius: 9px;
  background: rgba(45,212,191,.14);
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; flex-shrink: 0;
}
.ac-course-name { font-family: 'Fraunces', Georgia, serif; font-size: 14.5px; font-weight: 600; color: #fff; line-height: 1.3; }
.ac-course-tagline { font-size: 11px; color: rgba(207,250,243,.65); margin-top: 2px; line-height: 1.4; }
.ac-course-facts { display: flex; flex-direction: column; gap: 3px; margin: 8px 0 10px; }
.ac-course-fact { display: flex; gap: 6px; font-size: 11.5px; color: #CFFAF3; }
.ac-course-fact b { color: rgba(94,234,212,.8); font-weight: 600; min-width: 70px; flex-shrink: 0; }
.ac-course-reason {
  font-size: 11.5px; color: #e9d5ff; background: rgba(192,132,252,.1);
  border-left: 2px solid #c084fc; padding: 6px 9px; border-radius: 0 8px 8px 0;
  margin-bottom: 11px; line-height: 1.45;
}
.ac-course-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.ac-course-btn {
  flex: 1 1 auto; min-width: 0; text-align: center;
  font-family: 'DM Sans', sans-serif; font-size: 11.5px; font-weight: 600;
  padding: 8px 10px; border-radius: 8px; cursor: pointer;
  text-decoration: none; white-space: nowrap; transition: all .15s ease;
}
.ac-course-btn-primary { background: linear-gradient(135deg, #14B8A6, #7C3AED); color: #fff; border: none; }
.ac-course-btn-primary:hover { filter: brightness(1.08); transform: translateY(-1px); }
.ac-course-btn-ghost { background: rgba(255,255,255,.05); border: 1px solid rgba(192,132,252,.35); color: #e9d5ff; }
.ac-course-btn-ghost:hover { background: rgba(192,132,252,.14); border-color: #c084fc; color: #fff; }
.ac-course-btn-link { background: none; border: none; color: rgba(207,250,243,.6); font-weight: 500; flex: 0 0 auto; padding: 8px 4px; }
.ac-course-btn-link:hover { color: #5eead4; }

/* Typing dots */
.ac-typing {
  display: inline-flex;
  gap: 4px;
  padding: 10px 14px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(45,212,191,.2);
  border-radius: 14px 14px 14px 4px;
  margin-bottom: 12px;
}
.ac-typing span { width: 6px; height: 6px; border-radius: 50%; background: #2dd4bf; animation: ac-typing-bob 1.2s ease-in-out infinite; }
.ac-typing span:nth-child(2) { animation-delay: .15s; background: #a78bfa; }
.ac-typing span:nth-child(3) { animation-delay: .3s;  background: #c084fc; }
@keyframes ac-typing-bob {
  0%,80%,100% { opacity: .25; transform: translateY(0); }
  40%         { opacity: 1;   transform: translateY(-3px); }
}

/* Ask-a-question row */
.ac-ask-row { padding: 4px 0 12px; }
.ac-ask-btn {
  background: none; border: 1px dashed rgba(192,132,252,.4); color: #d8b4fe;
  font-family: 'DM Sans', sans-serif; font-size: 12px; font-weight: 500;
  padding: 8px 12px; border-radius: 9px; cursor: pointer; width: 100%; text-align: left;
}
.ac-ask-btn:hover { border-color: #c084fc; color: #fff; background: rgba(192,132,252,.08); }

.ac-input-row {
  display: none;
  padding: 10px 12px;
  border-top: 1px solid rgba(45,212,191,.16);
  background: rgba(11,20,30,.5);
  flex-shrink: 0;
  gap: 6px;
}
.ac-input-row.ac-show { display: flex; }
.ac-input-row input {
  flex: 1;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(192,132,252,.28);
  color: #fff;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 18px;
  outline: none;
  font-family: 'DM Sans', sans-serif;
}
.ac-input-row input::placeholder { color: rgba(192,132,252,.45); }
.ac-input-row input:focus { border-color: #c084fc; background: rgba(255,255,255,.12); }
.ac-input-row button {
  background: linear-gradient(135deg, #14B8A6, #7C3AED);
  color: #fff; border: none; border-radius: 18px;
  padding: 8px 14px; font-size: 12px; font-weight: 600;
  cursor: pointer; font-family: 'DM Sans', sans-serif;
}
.ac-input-row button:hover { filter: brightness(1.08); }

/* Restart / dismiss row */
.ac-restart-row { text-align: center; padding: 8px 14px 12px; font-size: 11px; color: rgba(45,212,191,.55); flex-shrink: 0; }
.ac-restart-row a { color: rgba(94,234,212,.8); text-decoration: none; cursor: pointer; border-bottom: 1px dotted rgba(94,234,212,.4); }
.ac-restart-row a:hover { color: #fff; }

/* ── Mobile ── */
@media (max-width: 480px) {
  .ac-panel {
    top: 16px; right: 12px; left: 12px;
    width: auto;
    height: min(82dvh, 720px);
    border-radius: 18px;
  }
  .ac-advisor-badge { top: 12px; right: 16px; width: 98px; height: 147px; }
  .ac-advisor-card { top: 167px; right: 12px; left: 12px; width: auto; }
  .ac-course-actions { flex-direction: column; }
  .ac-course-btn-link { text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  .ac-panel.ac-open, .ac-panel.ac-vanishing, .ac-msg, .ac-choices, .ac-course-card, .ac-typing span,
  .ac-advisor-badge, .ac-advisor-card, .ac-advisor-3d {
    animation: none !important;
  }
}
