/* Freshness pill + onboarding tour — bottom-left UX overlay
 *
 * Mirrors the .app-beta badge on the bottom-right. Uses the same
 * theme tokens as the rest of the app and respects prefers-reduced-motion.
 */

/* ── Freshness pill ───────────────────────────────── */
.cdx-freshness {
  position: fixed;
  bottom: 18px;
  left: 18px;
  z-index: 90;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding: 0 14px;
  height: 36px;
  min-width: 36px;
  max-width: 320px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  border: 1px solid var(--border);
  box-sizing: border-box;
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  user-select: none;
  cursor: default;
  overflow: hidden;
  transition: max-width .35s cubic-bezier(.4,0,.2,1),
              padding .35s cubic-bezier(.4,0,.2,1),
              gap .35s cubic-bezier(.4,0,.2,1);
}

.cdx-freshness__label {
  white-space: nowrap;
  opacity: 1;
  min-width: 0;
  flex: 0 1 auto;
  transition: opacity .25s ease, max-width .35s cubic-bezier(.4,0,.2,1);
  max-width: 280px;
  overflow: hidden;
}

.cdx-freshness--collapsed {
  max-width: 36px;
  padding: 0;
  gap: 0;
  justify-content: center;
}
.cdx-freshness--collapsed .cdx-freshness__label {
  opacity: 0;
  max-width: 0;
}
.cdx-freshness--collapsed:hover,
.cdx-freshness--collapsed:focus-within {
  max-width: 320px;
  padding: 0 14px;
  gap: 8px;
  justify-content: flex-start;
}
.cdx-freshness--collapsed:hover .cdx-freshness__label,
.cdx-freshness--collapsed:focus-within .cdx-freshness__label {
  opacity: 1;
}

.cdx-freshness__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  box-shadow: 0 0 0 0 currentColor;
  flex-shrink: 0;
}

.cdx-freshness--live .cdx-freshness__dot {
  background: var(--green);
  color: var(--green);
  animation: cdxFreshnessPulse 2.4s ease-in-out infinite;
}
.cdx-freshness--stale .cdx-freshness__dot {
  background: var(--yellow);
  color: var(--yellow);
}
.cdx-freshness--offline .cdx-freshness__dot {
  background: var(--red);
  color: var(--red);
}
.cdx-freshness--unknown .cdx-freshness__dot {
  background: var(--muted);
}

.cdx-freshness--offline { color: var(--red); }
.cdx-freshness--stale  { color: var(--yellow); }

@keyframes cdxFreshnessPulse {
  0%, 100% { box-shadow: 0 0 0 0 currentColor; opacity: 1; }
  50%      { box-shadow: 0 0 0 6px transparent; opacity: 0.6; }
}

/* ── Tour launcher (sits above the pill) ──────────── */
.cdx-tour-launcher {
  position: fixed;
  bottom: 58px;
  left: 18px;
  z-index: 91;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  color: var(--accent);
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
  transition: transform .15s ease, border-color .15s ease, color .15s ease;
}
.cdx-tour-launcher:hover {
  transform: translateY(-1px) scale(1.05);
  border-color: var(--accent);
  color: var(--text);
}

.cdx-tour-launcher--pulse {
  animation: cdxTourPulse 2.6s ease-in-out infinite;
}
@keyframes cdxTourPulse {
  0%, 100% { box-shadow: 0 4px 18px rgba(0,0,0,.35), 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); }
  50%      { box-shadow: 0 4px 18px rgba(0,0,0,.35), 0 0 0 10px transparent; }
}

/* ── Tour overlay ─────────────────────────────────── */
.cdx-tour-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  pointer-events: none;
  opacity: 0;
  transition: opacity .25s ease;
}
.cdx-tour-overlay--open {
  pointer-events: auto;
  opacity: 1;
}

.cdx-tour-spotlight {
  position: absolute;
  border-radius: 14px;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.65),
              0 0 0 2px color-mix(in srgb, var(--accent) 80%, transparent),
              0 0 24px color-mix(in srgb, var(--accent) 50%, transparent);
  transition: top .3s cubic-bezier(.4,0,.2,1),
              left .3s cubic-bezier(.4,0,.2,1),
              width .3s cubic-bezier(.4,0,.2,1),
              height .3s cubic-bezier(.4,0,.2,1);
  pointer-events: none;
}

.cdx-tour-tooltip {
  position: absolute;
  width: 300px;
  max-width: calc(100vw - 24px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 18px 14px;
  color: var(--text);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
  transition: top .3s cubic-bezier(.4,0,.2,1),
              left .3s cubic-bezier(.4,0,.2,1);
}
.cdx-tour-tooltip__title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--accent);
}
.cdx-tour-tooltip__body {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  margin-bottom: 14px;
}
.cdx-tour-tooltip__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.cdx-tour-tooltip__progress {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.cdx-tour-tooltip__buttons { display: flex; gap: 8px; }
.cdx-tour-btn {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  padding: 6px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}
.cdx-tour-btn:hover { opacity: .85; }
.cdx-tour-btn--ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}
.cdx-tour-btn--ghost:hover { color: var(--text); }

/* ── Mobile ──────────────────────────────────────── */
@media (max-width: 768px) {
  .cdx-freshness   { bottom: 14px; left: 14px; height: 34px; min-width: 34px; padding: 0 12px; font-size: 11px; }
  .cdx-freshness--collapsed { max-width: 34px; padding: 0; }
  .cdx-tour-launcher { bottom: 52px; left: 14px; width: 34px; height: 34px; font-size: 16px; }
  .cdx-tour-tooltip { width: calc(100vw - 28px); }
}

/* ── Reduced motion ──────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .cdx-freshness--live .cdx-freshness__dot,
  .cdx-tour-launcher--pulse,
  .cdx-tour-overlay,
  .cdx-tour-spotlight,
  .cdx-tour-tooltip {
    animation: none !important;
    transition: none !important;
  }
}
