/* ==========================================================================
   GratisChat Tutorial Overlay — tutorial.css
   Animated, gamified, zero-dependency tour engine styles
   Dark/light/trueblue themes auto-detected via html class
   ========================================================================== */

/* ── Custom properties ───────────────────────────────────────────────────── */
:root {
  --tour-accent: #3b82f6;
  --tour-accent-glow: rgba(59, 130, 246, 0.45);
  --tour-accent-soft: rgba(59, 130, 246, 0.12);
  --tour-card-bg: #ffffff;
  --tour-card-border: rgba(0, 0, 0, 0.1);
  --tour-card-shadow:
    0 24px 60px rgba(0, 0, 0, 0.18), 0 4px 16px rgba(0, 0, 0, 0.1);
  --tour-text: #0f172a;
  --tour-text-muted: #64748b;
  --tour-overlay-bg: rgba(0, 0, 0, 0.62);
  --tour-progress-bg: #e2e8f0;
  --tour-progress-fill: linear-gradient(
    90deg,
    #3b82f6 0%,
    #8b5cf6 60%,
    #ec4899 100%
  );
  --tour-btn-next-bg: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
  --tour-btn-next-text: #ffffff;
  --tour-btn-back-bg: transparent;
  --tour-btn-back-text: #64748b;
  --tour-btn-skip-text: #94a3b8;
  --tour-radius: 18px;
  --tour-arrow-size: 13px;
  --tour-zindex: 99999;
}

/* Dark & TrueBlue overrides */
html.dark :root,
html.trueblue :root,
.dark,
.trueblue {
  --tour-card-bg: #1e2029;
  --tour-card-border: rgba(255, 255, 255, 0.08);
  --tour-card-shadow:
    0 24px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.06);
  --tour-text: #e2e8f0;
  --tour-text-muted: #94a3b8;
  --tour-overlay-bg: rgba(0, 0, 0, 0.74);
  --tour-progress-bg: #2d3748;
  --tour-btn-back-text: #94a3b8;
  --tour-btn-skip-text: #64748b;
}

/* ── Keyframe animations ─────────────────────────────────────────────────── */
@keyframes cn-tour-fadein {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes cn-tour-card-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.94);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes cn-tour-card-out {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-10px) scale(0.96);
  }
}

@keyframes cn-tour-pulse-ring {
  0% {
    box-shadow: 0 0 0 0 var(--tour-accent-glow);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(59, 130, 246, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
  }
}

@keyframes cn-tour-progress-shine {
  0% {
    background-position: -200% center;
  }
  100% {
    background-position: 200% center;
  }
}

@keyframes cn-tour-badge-pop {
  0% {
    opacity: 0;
    transform: translateY(40px) scale(0.7);
  }
  55% {
    opacity: 1;
    transform: translateY(-8px) scale(1.08);
  }
  75% {
    transform: translateY(4px) scale(0.97);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

@keyframes cn-tour-badge-out {
  from {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateY(-20px) scale(0.85);
  }
}

@keyframes cn-tour-step-bounce {
  0%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-4px);
  }
}

@keyframes cn-tour-confetti-drop {
  0% {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translateY(120px) rotate(540deg);
  }
}

/* ── Four-panel spotlight overlay ───────────────────────────────────────── */
/*  Each panel is a fixed rectangle that together form a spotlight "cutout".
    JS sets top/left/width/height of the four panels around the target.     */
.cn-tour-panel {
  position: fixed;
  background: var(--tour-overlay-bg);
  z-index: var(--tour-zindex);
  pointer-events: auto;
  transition:
    top 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    left 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    width 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.cn-tour-panel--top {
  top: 0;
  left: 0;
  right: 0;
}
.cn-tour-panel--bottom {
  left: 0;
  right: 0;
  bottom: 0;
}
.cn-tour-panel--left {
  left: 0;
  top: 0;
  bottom: 0;
}
.cn-tour-panel--right {
  right: 0;
  top: 0;
  bottom: 0;
}

/* ── Spotlight highlight ring on target ─────────────────────────────────── */
.cn-tour-spotlight-ring {
  position: fixed;
  pointer-events: none;
  z-index: calc(var(--tour-zindex) + 1);
  border-radius: 10px;
  box-shadow:
    0 0 0 3px var(--tour-accent),
    0 0 0 6px var(--tour-accent-glow);
  animation: cn-tour-pulse-ring 1.8s ease-in-out infinite;
  transition:
    top 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    left 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    width 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    height 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Tooltip card ───────────────────────────────────────────────────────── */
.cn-tour-card {
  position: fixed;
  z-index: calc(var(--tour-zindex) + 10);
  background: var(--tour-card-bg);
  border: 1px solid var(--tour-card-border);
  border-radius: var(--tour-radius);
  box-shadow: var(--tour-card-shadow);
  padding: 22px 24px 20px;
  width: 340px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  overflow-x: hidden;
  pointer-events: auto;
  animation: cn-tour-card-in 0.38s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.cn-tour-card.cn-tour-card--exit {
  animation: cn-tour-card-out 0.22s ease-in both;
}

/* ── Step badge row ─────────────────────────────────────────────────────── */
.cn-tour-step-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.cn-tour-step-emoji {
  font-size: 20px;
  line-height: 1;
  animation: cn-tour-step-bounce 0.5s ease both;
}

.cn-tour-step-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--tour-accent);
}

/* ── Progress bar ───────────────────────────────────────────────────────── */
.cn-tour-progress-track {
  height: 5px;
  background: var(--tour-progress-bg);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 14px;
}

.cn-tour-progress-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--tour-progress-fill);
  background-size: 200% auto;
  animation: cn-tour-progress-shine 2.2s linear infinite;
  transition: width 0.45s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: width;
}

/* ── Title + description ────────────────────────────────────────────────── */
.cn-tour-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--tour-text);
  margin: 0 0 6px;
  line-height: 1.35;
}

.cn-tour-desc {
  font-size: 13.5px;
  color: var(--tour-text-muted);
  line-height: 1.6;
  margin: 0 0 18px;
}

/* ── Tip chip (optional extra hint) ─────────────────────────────────────── */
.cn-tour-tip {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: var(--tour-accent-soft);
  border-left: 3px solid var(--tour-accent);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 16px;
  font-size: 12.5px;
  color: var(--tour-text-muted);
  line-height: 1.5;
}

.cn-tour-tip-icon {
  font-size: 15px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── Action buttons ─────────────────────────────────────────────────────── */
.cn-tour-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  position: sticky;
  bottom: -20px;
  background: var(--tour-card-bg);
  padding-top: 10px;
  margin-bottom: -20px;
  padding-bottom: 20px;
}

.cn-tour-btn {
  border: none;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 8px 14px;
  transition:
    transform 0.15s,
    box-shadow 0.15s,
    opacity 0.15s;
  line-height: 1;
  white-space: nowrap;
  font-family: inherit;
}

.cn-tour-btn:active {
  transform: scale(0.95);
}

/* Next / Finish */
.cn-tour-btn--next {
  background: var(--tour-btn-next-bg);
  color: var(--tour-btn-next-text);
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.35);
  margin-left: auto;
  padding: 8px 18px;
}

.cn-tour-btn--next:hover {
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
  transform: translateY(-1px);
}

/* Back */
.cn-tour-btn--back {
  background: var(--tour-btn-back-bg);
  color: var(--tour-btn-back-text);
  border: 1px solid rgba(0, 0, 0, 0.12);
}

html.dark .cn-tour-btn--back,
html.trueblue .cn-tour-btn--back {
  border-color: rgba(255, 255, 255, 0.12);
}

.cn-tour-btn--back:hover {
  background: var(--tour-accent-soft);
  color: var(--tour-accent);
  border-color: var(--tour-accent);
}

/* Skip */
.cn-tour-btn--skip {
  background: transparent;
  color: var(--tour-btn-skip-text);
  font-size: 12px;
  font-weight: 500;
  padding: 8px 10px;
}

.cn-tour-btn--skip:hover {
  color: var(--tour-text-muted);
  text-decoration: underline;
}

/* ── Donation tier mini cards in tour step 24 ──────────────────────────── */
.cn-tour-tier-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 10px;
}

.cn-tour-tier-card {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.03);
  transition:
    background 0.15s,
    border-color 0.15s;
}

.cn-tour-tier-card:hover {
  background: rgba(255, 255, 255, 0.07);
}

.cn-tour-tier-card img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  flex-shrink: 0;
}

.cn-tour-tier-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}

.cn-tour-tier-name {
  font-size: 0.85rem;
  font-weight: 700;
}

.cn-tour-tier-price {
  font-size: 0.75rem;
  color: var(--tour-text-muted);
}

/* Tier accents matching the donation modal */
.cn-tour-tier-card--stoetter {
  border-color: rgba(251, 191, 36, 0.3);
}
.cn-tour-tier-card--stoetter .cn-tour-tier-name {
  color: #fbbf24;
}

.cn-tour-tier-card--bidragyder {
  border-color: rgba(148, 163, 184, 0.3);
}
.cn-tour-tier-card--bidragyder .cn-tour-tier-name {
  color: #94a3b8;
}

.cn-tour-tier-card--superfan {
  border-color: rgba(245, 158, 11, 0.3);
}
.cn-tour-tier-card--superfan .cn-tour-tier-name {
  color: #f59e0b;
}

.cn-tour-tier-card--legende {
  border-color: rgba(167, 139, 250, 0.3);
}
.cn-tour-tier-card--legende .cn-tour-tier-name {
  color: #a78bfa;
}

/* Light-mode adjustments */
html.theme-trueblue-light .cn-tour-tier-card,
html:not(.dark):not(.trueblue):not(.theme-trueblue-light) .cn-tour-tier-card {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}
html.theme-trueblue-light .cn-tour-tier-card:hover,
html:not(.dark):not(.trueblue):not(.theme-trueblue-light)
  .cn-tour-tier-card:hover {
  background: rgba(0, 0, 0, 0.06);
}

/* ── Arrow pointer ──────────────────────────────────────────────────────── */
.cn-tour-arrow {
  position: fixed;
  z-index: calc(var(--tour-zindex) + 9);
  width: 0;
  height: 0;
  pointer-events: none;
  transition:
    top 0.35s cubic-bezier(0.4, 0, 0.2, 1),
    left 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Arrow directions — JS sets data-dir="top|bottom|left|right" */
.cn-tour-arrow[data-dir="top"] {
  border-left: var(--tour-arrow-size) solid transparent;
  border-right: var(--tour-arrow-size) solid transparent;
  border-bottom: var(--tour-arrow-size) solid var(--tour-card-bg);
  filter: drop-shadow(0 -2px 3px rgba(0, 0, 0, 0.12));
}

.cn-tour-arrow[data-dir="bottom"] {
  border-left: var(--tour-arrow-size) solid transparent;
  border-right: var(--tour-arrow-size) solid transparent;
  border-top: var(--tour-arrow-size) solid var(--tour-card-bg);
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.12));
}

.cn-tour-arrow[data-dir="left"] {
  border-top: var(--tour-arrow-size) solid transparent;
  border-bottom: var(--tour-arrow-size) solid transparent;
  border-right: var(--tour-arrow-size) solid var(--tour-card-bg);
  filter: drop-shadow(-2px 0 3px rgba(0, 0, 0, 0.12));
}

.cn-tour-arrow[data-dir="right"] {
  border-top: var(--tour-arrow-size) solid transparent;
  border-bottom: var(--tour-arrow-size) solid transparent;
  border-left: var(--tour-arrow-size) solid var(--tour-card-bg);
  filter: drop-shadow(2px 0 3px rgba(0, 0, 0, 0.12));
}

/* ── XP completion badge ────────────────────────────────────────────────── */
.cn-tour-complete-badge {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: calc(var(--tour-zindex) + 20);
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  padding: 14px 28px;
  border-radius: 999px;
  box-shadow:
    0 8px 30px rgba(99, 102, 241, 0.5),
    0 2px 8px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  white-space: nowrap;
}

.cn-tour-complete-badge.cn-tour-badge--in {
  animation: cn-tour-badge-pop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.cn-tour-complete-badge.cn-tour-badge--out {
  animation: cn-tour-badge-out 0.4s ease-in both;
}

/* ── Confetti particle ──────────────────────────────────────────────────── */
.cn-tour-confetti {
  position: fixed;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  pointer-events: none;
  z-index: calc(var(--tour-zindex) + 21);
  animation: cn-tour-confetti-drop 1.2s ease-in forwards;
}

/* ── Topbar "Tutorial" button ───────────────────────────────────────────── */
.topbar-shortcut--tutorial {
  position: relative;
}

.topbar-shortcut--tutorial::after {
  content: "NY";
  position: absolute;
  top: -3px;
  right: -4px;
  background: #ec4899;
  color: #fff;
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 1px 4px;
  border-radius: 99px;
  line-height: 1.4;
  pointer-events: none;
}

/* Hide the "NY" badge once tour has been completed */
.cn-tour-seen .topbar-shortcut--tutorial::after {
  display: none;
}

/* ── Mobile: bottom-sheet at < 640px ───────────────────────────────────── */
@media (max-width: 639px) {
  .cn-tour-card {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    width: 100% !important;
    max-width: 100% !important;
    max-height: 80vh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    border-radius: 20px 20px 0 0 !important;
    padding-bottom: calc(20px + env(safe-area-inset-bottom));
    animation: cn-tour-sheet-in 0.38s cubic-bezier(0.34, 1.1, 0.64, 1) both;
  }

  @keyframes cn-tour-sheet-in {
    from {
      transform: translateY(100%);
      opacity: 0;
    }
    to {
      transform: translateY(0);
      opacity: 1;
    }
  }

  .cn-tour-arrow {
    display: none !important;
  }
}

/* ── Reduced motion ─────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .cn-tour-card,
  .cn-tour-panel,
  .cn-tour-spotlight-ring,
  .cn-tour-progress-fill,
  .cn-tour-arrow,
  .cn-tour-complete-badge {
    animation: none !important;
    transition: none !important;
  }
}

