/* --- AI Mode: scripted, client-only guided site tour (ai-mode.js) ---
   No API calls anywhere in here — every stop and every word of narration is
   a static config in ai-mode.js. Tokens-only colors, so it follows the
   site's light/dark theme automatically. */

/* --- Entry popup --- */
.explore-popup {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-toast) + 30);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
}

.explore-popup[hidden] {
  display: none;
}

.explore-popup__backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 20, 0.6);
}

.explore-popup__card {
  position: relative;
  width: min(100%, 30rem);
  padding: var(--space-xl);
  border-radius: var(--radius-lg);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: explore-popup-in var(--duration-base) var(--ease-out);
}

@keyframes explore-popup-in {
  from { opacity: 0; transform: translateY(1rem) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .explore-popup__card {
    animation: none;
  }
}

.explore-popup__close {
  position: absolute;
  top: var(--space-sm);
  right: var(--space-sm);
  width: 2rem;
  height: 2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  border: none;
  background: var(--color-bg-surface);
  color: var(--color-text-faint);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
}

.explore-popup__close:hover {
  background: var(--color-bg-surface-hover);
  color: var(--color-text);
}

.explore-popup__eyebrow {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-accent-blue);
  margin-bottom: var(--space-2xs);
}

.explore-popup__title {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: var(--fs-xl);
  margin-bottom: var(--space-2xs);
}

.explore-popup__body {
  color: var(--color-text-faint);
  font-size: var(--fs-sm);
  margin-bottom: var(--space-lg);
}

.explore-popup__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.explore-popup__ai-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2xs);
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-full);
  border: none;
  background: var(--color-gradient-brand);
  color: #ffffff;
  font-weight: var(--fw-semibold);
  font-size: var(--fs-sm);
  cursor: pointer;
}

.explore-popup__ai-btn:hover {
  filter: brightness(1.08);
}

.explore-popup__ai-icon {
  width: 1.5rem;
  height: 1.5rem;
  flex-shrink: 0;
}

/* --- AI Mode active state --- */
body.ai-mode-active .site-ambient-bg {
  filter: saturate(0.8);
}

.ai-mode-highlight {
  position: relative;
  z-index: 1;
  outline: 3px solid var(--color-accent-blue);
  outline-offset: 6px;
  border-radius: var(--radius-md);
  animation: ai-mode-pulse 1.8s ease-in-out infinite;
  scroll-margin-top: 6rem;
}

@keyframes ai-mode-pulse {
  0%, 100% { outline-color: var(--color-accent-blue); box-shadow: 0 0 0 0 rgba(49, 130, 206, 0.35); }
  50% { outline-color: var(--color-accent-blue-strong); box-shadow: 0 0 0 10px rgba(49, 130, 206, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .ai-mode-highlight {
    animation: none;
  }
}

.ai-mode-overlay {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-toast) + 10);
  background: rgba(4, 8, 16, 0.35);
  pointer-events: none;
}

/* --- Caption card (desktop only — see ai-mode.js) --- */
.ai-mode-caption {
  position: fixed;
  left: 50%;
  bottom: 7rem;
  transform: translateX(-50%);
  z-index: calc(var(--z-toast) + 22);
  width: min(90vw, 26rem);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-lg);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
  text-align: left;
}

.ai-mode-caption[hidden] {
  display: none;
}

/* Narration text is desktop-only by design (not just a smaller layout on
   mobile) — the tour itself (scroll + highlight) still runs everywhere. */
@media (max-width: 48rem) {
  .ai-mode-caption {
    display: none !important;
  }
}

.ai-mode-caption__eyebrow {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-accent-blue);
  margin-bottom: 0.2em;
}

.ai-mode-caption__title {
  font-family: var(--font-display);
  font-weight: var(--fw-bold);
  font-size: var(--fs-md);
  margin-bottom: var(--space-2xs);
}

.ai-mode-caption__text {
  font-size: var(--fs-sm);
  color: var(--color-text-faint);
  line-height: 1.5;
}

/* --- Control bar --- */
.ai-mode-bar {
  position: fixed;
  left: 50%;
  bottom: var(--space-md);
  transform: translateX(-50%);
  z-index: calc(var(--z-toast) + 25);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-2xs) var(--space-sm);
  border-radius: var(--radius-full);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  box-shadow: var(--shadow-lg);
}

/* An author-stylesheet `display` rule always beats the browser's own
   `[hidden] { display: none }` UA default, regardless of selector
   specificity — without this the bar ignored its `hidden` attribute
   entirely and showed before the tour even started. */
.ai-mode-bar[hidden] {
  display: none;
}

.ai-mode-bar__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--radius-full);
  border: none;
  background: var(--color-bg-surface);
  color: var(--color-text);
  cursor: pointer;
}

.ai-mode-bar__btn:hover {
  background: var(--color-bg-surface-hover);
}

.ai-mode-bar__btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.ai-mode-bar__btn--next {
  background: var(--color-gradient-brand);
  color: #ffffff;
}

.ai-mode-bar__progress {
  position: relative;
  width: 3.75rem;
  height: 0.35rem;
  border-radius: var(--radius-full);
  background: var(--color-border);
  overflow: hidden;
}

.ai-mode-bar__progress-fill {
  position: absolute;
  inset: 0;
  width: 0%;
  background: var(--color-gradient-brand);
  transition: width 0.2s linear;
}

.ai-mode-bar__label {
  font-size: var(--fs-xs);
  color: var(--color-text-faint);
  white-space: nowrap;
}

.ai-mode-bar__exit {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--color-text-faint);
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-2xs) var(--space-2xs);
}

.ai-mode-bar__exit:hover {
  color: var(--color-text);
}

@media (max-width: 30rem) {
  .ai-mode-bar {
    width: calc(100vw - 1.5rem);
    justify-content: space-between;
  }

  .ai-mode-bar__label {
    display: none;
  }
}
