/**
 * Tool Intro Wizard — first-run onboarding modal for AI tools
 * Follows smart-wizard patterns (wizard.css) with its own namespace.
 */

/* ========================================
   TOOL INTRO WIZARD — SHELL
   ======================================== */

.tool-intro {
  position: fixed;
  inset: 0;
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.tool-intro__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
}

.tool-intro__container {
  position: relative;
  background: white;
  border-radius: 20px;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.3);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: toolIntroSlideUp 0.3s ease;
}

@keyframes toolIntroSlideUp {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ========================================
   HEADER
   ======================================== */

.tool-intro__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  color: white;
}

.tool-intro__header-content {
  display: flex;
  flex-direction: row;
  flex: 1;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-width: 0;
}

.tool-intro__icon {
  flex-shrink: 0;
  font-size: 20px;
  line-height: 1;
}

.tool-intro__title {
  margin: 0;
  flex: 1;
  min-width: 0;
  text-align: left;
  font-size: 20px;
  font-weight: 700;
  color: white;
}

/* Match add-docs-modal__close / auth-modal__close: SVG in flex box (text × baselines are unreliable). */
.tool-intro__close {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  line-height: 0;
  cursor: pointer;
  transition: background 0.15s;
}

.tool-intro__close:hover {
  background: rgba(255, 255, 255, 0.3);
}

.tool-intro__close-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.tool-intro__close-inner svg {
  display: block;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

/* ========================================
   PROGRESS — thin bar + n/total · step (subtle)
   ======================================== */

.tool-intro__progress {
  flex-shrink: 0;
  padding: 10px 24px 12px;
  background: var(--color-neutral-50);
  border-bottom: 1px solid var(--color-neutral-200);
}

.tool-intro__progress-bar {
  width: 100%;
  height: 3px;
  border-radius: 999px;
  background: var(--color-neutral-200);
  overflow: hidden;
}

.tool-intro__progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--color-emerald-600);
  transition: width 0.28s ease;
  max-width: 100%;
}

.tool-intro__progress-caption {
  margin: 6px 0 0;
  text-align: left;
  font-size: 12px;
  line-height: 1.4;
  font-weight: 500;
  color: var(--color-neutral-500);
}

.tool-intro__progress-fraction {
  color: var(--color-neutral-400);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
}

.tool-intro__progress-sep {
  color: var(--color-neutral-400);
}

.tool-intro__progress-name {
  color: var(--color-neutral-600);
  font-weight: 500;
}

@media (prefers-reduced-motion: reduce) {
  .tool-intro__progress-fill {
    transition: none;
  }
}

/* ========================================
   BODY / STEP PANELS
   ======================================== */

.tool-intro__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 32px 24px;
}

.tool-intro__panel {
  animation: toolIntroPanelFade 0.3s ease;
  text-align: center;
}

@keyframes toolIntroPanelFade {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Default step content blocks */

.tool-intro__step-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-neutral-800);
  margin: 0 0 8px;
}

/* Unicode U+2122 — render like a raised trademark (not the full-line codepoint box) */
.tool-intro__tm {
  font-size: 0.55em;
  font-weight: 700;
  vertical-align: super;
  line-height: 0;
  margin-left: 0.06em;
}

.tool-intro__step-desc {
  font-size: 15px;
  line-height: 1.6;
  color: var(--color-neutral-600);
  margin: 0 auto;
  max-width: 420px;
}

/* Fixed 16:9 frame so the modal height does not jump when the image loads */
.tool-intro__step-image {
  position: relative;
  margin-top: 20px;
  aspect-ratio: 16 / 9;
  width: 100%;
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--color-neutral-200);
  background: var(--color-neutral-100);
}

.tool-intro__step-image-skeleton {
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: inherit;
}

/* Reuse global shimmer (loading.css) via .skeleton; fallback fill */
.tool-intro__step-image-skeleton.skeleton {
  width: 100%;
  height: 100%;
}

/* Full image, centered. scale-down avoids upscaling small assets (no cover crop/zoom). */
.tool-intro__step-image-img {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: scale-down;
  object-position: center;
  display: block;
  opacity: 0;
  filter: blur(16px);
  transform: none;
  transition:
    opacity 0.5s ease,
    filter 0.65s ease;
}

.tool-intro__step-image.is-loaded .tool-intro__step-image-img {
  opacity: 1;
  filter: blur(0);
  transform: none;
}

.tool-intro__step-image.is-loaded .tool-intro__step-image-skeleton {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

@media (prefers-reduced-motion: reduce) {
  .tool-intro__step-image-img {
    filter: none;
    transition: opacity 0.2s ease;
  }

  .tool-intro__step-image.is-loaded .tool-intro__step-image-img {
    filter: none;
  }
}

/* ========================================
   FOOTER
   ======================================== */

.tool-intro__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--color-neutral-50);
  border-top: 1px solid var(--color-neutral-200);
}

.tool-intro__footer-left {
  flex-shrink: 0;
}

.tool-intro__skip-btn {
  font-size: 13px;
  color: var(--color-neutral-500);
  cursor: pointer;
}

.tool-intro__skip-btn:hover {
  color: var(--color-neutral-700);
}

.tool-intro__footer-right {
  display: flex;
  gap: 10px;
}

/* ========================================
   MOBILE
   ======================================== */

@media (max-width: 600px) {
  .tool-intro {
    align-items: stretch;
    justify-content: flex-start;
    padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  }

  .tool-intro__container {
    width: 100%;
    max-width: none;
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
  }

  .tool-intro__header {
    padding: 14px 16px;
    flex-shrink: 0;
  }

  .tool-intro__progress {
    padding: 8px 16px 10px;
    flex-shrink: 0;
  }

  .tool-intro__body {
    padding: 24px 16px;
  }

  .tool-intro__footer {
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom, 0px));
  }
}
