/* =============================================================================
   Ask AI — Framer-style pill → single-row icons
   ============================================================================= */

.ask-ai {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
  padding: clamp(2.5rem, 5vw, 4rem) 1.25rem;
  border-top: 1px solid var(--color-border-subtle);
  background:
    radial-gradient(ellipse 55% 70% at 50% 40%, color-mix(in srgb, var(--color-accent) 8%, transparent), transparent 70%),
    var(--color-bg-base);
}

.ask-ai__heading {
  position: relative;
  z-index: 2;
  margin: 0;
  text-align: center;
  font-size: clamp(1.05rem, 2.2vw, 1.25rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--color-text-primary);
}

.ask-ai__stage {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: min(100%, 36rem);
  /* Fixed height — open/close must not resize the page or nudge the footer */
  height: 3.75rem;
}

/* --- Pill (collapsed) ----------------------------------------------------- */

.ask-ai__pill {
  position: relative;
  z-index: 2;
  appearance: none;
  border: 0;
  padding: 2.5px;
  border-radius: 999px;
  cursor: pointer;
  background: conic-gradient(
    from var(--ask-ai-angle, 0deg),
    #14b8a6,
    #4ade80,
    #eab308,
    #22d3ee,
    #a78bfa,
    #14b8a6
  );
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06),
    0 8px 28px rgba(0, 0, 0, 0.45),
    0 0 24px rgba(20, 184, 166, 0.22);
  transition:
    transform 260ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 260ms ease,
    box-shadow 260ms ease,
    visibility 0s linear 0s;
  animation: askAiBorderSpin 2.8s linear infinite;
}

@property --ask-ai-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

@keyframes askAiBorderSpin {
  to {
    --ask-ai-angle: 360deg;
  }
}

@supports not (background: conic-gradient(from var(--ask-ai-angle), red, blue)) {
  .ask-ai__pill {
    background: linear-gradient(105deg, #14b8a6, #4ade80, #eab308, #22d3ee, #14b8a6);
    background-size: 300% 300%;
    animation: askAiBorderSlide 2.8s linear infinite;
  }

  @keyframes askAiBorderSlide {
    0% { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
  }
}

.ask-ai__pill:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.1),
    0 14px 34px rgba(0, 0, 0, 0.5),
    0 0 32px rgba(234, 179, 8, 0.28);
}

.ask-ai__pill:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

/* Dark face — gradient ring stays readable */
.ask-ai__pill-inner {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem 0.65rem 1rem;
  border-radius: inherit;
  background: #07080c;
  color: #f5f7fa;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.ask-ai__sparkles {
  display: block;
  flex-shrink: 0;
  color: #5eead4;
}

.ask-ai__pill-label {
  font-family: var(--font-body);
  font-size: 0.98rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  line-height: 1;
}

/* --- Expanded panel: overlays stage only (no page/footer height change) -- */

.ask-ai__panel {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px) scale(0.97);
  pointer-events: none;
  transition:
    opacity 280ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 300ms cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s linear 300ms;
}

.ask-ai.is-open .ask-ai__pill {
  opacity: 0;
  visibility: hidden;
  transform: scale(0.92);
  pointer-events: none;
  transition:
    transform 240ms cubic-bezier(0.22, 1, 0.36, 1),
    opacity 240ms ease,
    visibility 0s linear 240ms,
    box-shadow 240ms ease;
}

.ask-ai.is-open .ask-ai__panel {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  transition:
    opacity 300ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 320ms cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s linear 0s;
}

.ask-ai__icons {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  gap: 0.65rem;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  padding: 0.15rem 0.1rem;
  scrollbar-width: none;
}

.ask-ai__icons::-webkit-scrollbar {
  display: none;
}

.ask-ai__icon-btn {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 3.15rem;
  height: 3.15rem;
  border-radius: 14px;
  background: #ffffff;
  color: #111111;
  text-decoration: none;
  box-shadow:
    0 6px 18px rgba(0, 0, 0, 0.22),
    0 1px 3px rgba(0, 0, 0, 0.12);
  transition:
    transform 200ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 200ms ease,
    opacity 260ms ease;
}

.ask-ai.is-open .ask-ai__icon-btn {
  animation: askAiIconIn 320ms cubic-bezier(0.22, 1, 0.36, 1) both;
}

.ask-ai.is-open .ask-ai__icon-btn:nth-child(1) { animation-delay: 20ms; }
.ask-ai.is-open .ask-ai__icon-btn:nth-child(2) { animation-delay: 50ms; }
.ask-ai.is-open .ask-ai__icon-btn:nth-child(3) { animation-delay: 80ms; }
.ask-ai.is-open .ask-ai__icon-btn:nth-child(4) { animation-delay: 110ms; }
.ask-ai.is-open .ask-ai__icon-btn:nth-child(5) { animation-delay: 140ms; }
.ask-ai.is-open .ask-ai__icon-btn:nth-child(6) { animation-delay: 170ms; }

.ask-ai:not(.is-open) .ask-ai__icon-btn {
  animation: none;
  opacity: 0;
}

.ask-ai__icon-btn img {
  width: 22px;
  height: 22px;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

.ask-ai__icon-btn:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow:
    0 12px 26px rgba(0, 0, 0, 0.28),
    0 2px 6px rgba(0, 0, 0, 0.14);
}

.ask-ai__icon-btn:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 3px;
}

@keyframes askAiIconIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.92);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* --- Toast ---------------------------------------------------------------- */

.ask-ai__toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  z-index: 80;
  transform: translateX(-50%) translateY(8px);
  padding: 0.7rem 1.05rem;
  border-radius: 999px;
  background: #111111;
  color: #f5f7fa;
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.85rem;
  font-weight: 550;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 220ms ease,
    transform 240ms cubic-bezier(0.22, 1, 0.36, 1);
}

.ask-ai__toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (prefers-reduced-motion: reduce) {
  .ask-ai__pill,
  .ask-ai__panel,
  .ask-ai__icon-btn,
  .ask-ai__toast {
    transition: none;
    animation: none;
  }
}

[data-theme="gaming"] .ask-ai {
  background:
    radial-gradient(ellipse 55% 70% at 50% 40%, color-mix(in srgb, var(--page-accent, #e0455e) 14%, transparent), transparent 70%),
    var(--color-bg-base);
}
