/* ========================================================================
 * Tessera tour — overlay + tooltip + floating help button
 * All class names prefixed with `tessera-tour-` to isolate from upstream.
 * Uses the same CSS variables as the main Tessera theme (loaded first).
 * ======================================================================== */

.tessera-tour-root {
  position: fixed;
  inset: 0;
  z-index: 2147483600; /* above everything, below browser chrome */
  pointer-events: none;
}

.tessera-tour-root > * {
  pointer-events: auto;
}

.tessera-tour-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.tessera-tour-ring {
  animation: tessera-tour-pulse 1.6s ease-in-out infinite;
  transform-origin: center;
}

@keyframes tessera-tour-pulse {
  0%, 100% { opacity: 1;   stroke-width: 2; }
  50%      { opacity: 0.6; stroke-width: 4; }
}

/* -----------------------------------------------------------------------
 * Tooltip card
 * --------------------------------------------------------------------- */

.tessera-tour-tooltip {
  position: absolute;
  width: 340px;
  max-width: calc(100vw - 32px);
  background: var(--background-primary, #ffffff);
  color: var(--text-normal, #0f172a);
  border-radius: 14px;
  border: 1px solid var(--elevation-stroke, #e2e8f0);
  box-shadow:
    0 24px 48px -12px rgba(15, 23, 42, 0.22),
    0 8px 16px -4px rgba(15, 23, 42, 0.10),
    0 0 0 1px rgba(15, 23, 42, 0.04);
  padding: 20px 22px 16px 22px;
  font-family: "Inter", "Helvetica Neue", Helvetica, Arial, sans-serif;
  opacity: 0;
  transform: translateY(8px) scale(0.985);
  transition:
    opacity 220ms cubic-bezier(0.16, 1, 0.3, 1),
    transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

.tessera-tour-tooltip--in {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.tessera-tour-stepnum {
  font-size: 11px;
  font-weight: 600;
  color: var(--tessera-brand-800, #1565c0);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.tessera-tour-title {
  margin: 0 0 8px 0;
  font-size: 18px;
  line-height: 1.3;
  font-weight: 700;
  color: var(--header-primary, #0f172a);
  letter-spacing: -0.015em;
}

.tessera-tour-body {
  margin: 0 0 14px 0;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-muted, #475569);
}

.tessera-tour-optout {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted, #475569);
  margin-bottom: 14px;
  cursor: pointer;
  user-select: none;
}

.tessera-tour-optout input[type="checkbox"] {
  width: 14px;
  height: 14px;
  accent-color: var(--tessera-brand-800, #1565c0);
  cursor: pointer;
}

.tessera-tour-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border-internal-stripe, #f1f5f9);
}

.tessera-tour-footer-right {
  display: flex;
  gap: 8px;
}

.tessera-tour-btn {
  font-family: inherit;
  font-weight: 500;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition:
    background 160ms cubic-bezier(0.16, 1, 0.3, 1),
    color 160ms cubic-bezier(0.16, 1, 0.3, 1),
    border-color 160ms cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 160ms cubic-bezier(0.16, 1, 0.3, 1),
    transform 100ms cubic-bezier(0.16, 1, 0.3, 1);
}

.tessera-tour-btn:active {
  transform: translateY(1px);
}

.tessera-tour-btn-ghost {
  background: transparent;
  color: var(--text-muted, #475569);
  border-color: transparent;
}

.tessera-tour-btn-ghost:hover:not([disabled]) {
  background: var(--background-modifier-hover, #f1f5f9);
  color: var(--text-normal, #0f172a);
}

.tessera-tour-btn-ghost[disabled] {
  opacity: 0.35;
  cursor: not-allowed;
}

.tessera-tour-btn-primary {
  background: linear-gradient(180deg, #1e88e5 0%, #1565c0 100%);
  color: #ffffff;
  border-color: transparent;
  box-shadow: 0 6px 16px -4px rgba(21, 101, 192, 0.28), 0 2px 6px -1px rgba(21, 101, 192, 0.15);
  min-width: 88px;
}

.tessera-tour-btn-primary:hover {
  background: linear-gradient(180deg, #1976d2 0%, #0d47a1 100%);
  box-shadow: 0 10px 24px -6px rgba(21, 101, 192, 0.38), 0 4px 10px -2px rgba(21, 101, 192, 0.22);
  transform: translateY(-1px);
}

/* -----------------------------------------------------------------------
 * Floating help button — bottom-left, always visible
 * --------------------------------------------------------------------- */

.tessera-tour-help-button {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 2147483500;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(180deg, #1e88e5 0%, #1565c0 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow:
    0 8px 20px -4px rgba(21, 101, 192, 0.40),
    0 3px 8px -2px rgba(21, 101, 192, 0.20),
    0 0 0 1px rgba(255, 255, 255, 0.06) inset;
  transition:
    transform 200ms cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 200ms cubic-bezier(0.16, 1, 0.3, 1),
    background 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

.tessera-tour-help-button svg {
  width: 22px;
  height: 22px;
  display: block;
}

.tessera-tour-help-button:hover {
  transform: translateY(-2px) scale(1.05);
  background: linear-gradient(180deg, #1976d2 0%, #0d47a1 100%);
  box-shadow:
    0 14px 28px -4px rgba(21, 101, 192, 0.52),
    0 6px 12px -2px rgba(21, 101, 192, 0.28),
    0 0 0 1px rgba(255, 255, 255, 0.10) inset;
}

.tessera-tour-help-button:active {
  transform: translateY(0) scale(0.97);
}

.tessera-tour-help-button:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 4px rgba(21, 101, 192, 0.25),
    0 8px 20px -4px rgba(21, 101, 192, 0.40),
    0 3px 8px -2px rgba(21, 101, 192, 0.20);
}

/* Gentle attention pulse on first mount, one cycle only */
.tessera-tour-help-button {
  animation: tessera-help-entrance 600ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes tessera-help-entrance {
  0%   { opacity: 0; transform: translateY(10px) scale(0.8); }
  100% { opacity: 1; transform: translateY(0)    scale(1); }
}

/* -----------------------------------------------------------------------
 * Dark mode tweaks
 * --------------------------------------------------------------------- */

html[data-theme="dark"] .tessera-tour-tooltip {
  background: var(--background-primary, #0f172a);
  color: var(--text-normal, #f1f5f9);
  border-color: var(--elevation-stroke, #334155);
  box-shadow:
    0 32px 64px rgba(0, 0, 0, 0.6),
    0 12px 24px rgba(0, 0, 0, 0.4),
    0 0 0 1px rgba(255, 255, 255, 0.06);
}

html[data-theme="dark"] .tessera-tour-stepnum {
  color: #64b5f6;
}

html[data-theme="dark"] .tessera-tour-footer {
  border-top-color: rgba(255, 255, 255, 0.05);
}

html[data-theme="dark"] .tessera-tour-btn-ghost:hover:not([disabled]) {
  background: rgba(255, 255, 255, 0.06);
  color: #f1f5f9;
}

/* -----------------------------------------------------------------------
 * Responsive — on narrow viewports the tooltip goes full-width bottom sheet
 * --------------------------------------------------------------------- */

@media (max-width: 640px) {
  .tessera-tour-tooltip {
    left: 16px !important;
    right: 16px !important;
    top: auto !important;
    bottom: 16px !important;
    width: auto;
    max-width: none;
  }
}

/* Reduce motion preference */
@media (prefers-reduced-motion: reduce) {
  .tessera-tour-tooltip,
  .tessera-tour-ring,
  .tessera-tour-help-button,
  .tessera-tour-btn {
    animation: none !important;
    transition: none !important;
  }
}
