/* ===========================================================================
 * tour.css — Guided onboarding tour (spotlight + tooltip walkthrough)
 * Hand-rolled engine styling. Reuses the app design tokens from global.css
 * (--primary-blue, --text-header, --focus-ring, Nunito) so it feels native.
 * ===========================================================================*/

/* Root layer — sits above factory modals (z 9999). The root itself does not
 * intercept clicks; the mask panels and tooltip do. */
.tour-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  font-family: "Nunito", system-ui, -apple-system, sans-serif;
  pointer-events: none;
}
.tour-overlay.tour-active {
  pointer-events: auto;
}

/* Four dimming panels surrounding the spotlighted target (the "hole").
 * Clicking any panel = skip the tour. */
.tour-mask {
  position: fixed;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  pointer-events: auto;
  transition: all 0.18s ease-out;
}

/* Single full-screen dim for centered (target-less) steps. */
.tour-mask-full {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  pointer-events: auto;
}

/* Glowing ring drawn over the target. Purely decorative — clicks pass through
 * to the real element underneath (we keep the app frozen behind the masks). */
.tour-ring {
  position: fixed;
  pointer-events: none;
  border: 2px solid var(--primary-blue, #1b6fd8);
  border-radius: 12px;
  box-shadow: var(--focus-ring, 0 0 0 3px rgba(27, 111, 216, 0.3));
  transition: all 0.18s ease-out;
  animation: tour-ring-pulse 1.8s ease-in-out infinite;
}
@keyframes tour-ring-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 3px rgba(27, 111, 216, 0.28);
  }
  50% {
    box-shadow: 0 0 0 7px rgba(27, 111, 216, 0.14);
  }
}

/* Tooltip card */
.tour-tip {
  position: fixed;
  width: min(340px, calc(100vw - 32px));
  background: #ffffff;
  border-radius: 14px;
  box-shadow: var(--shadow-modal, 0 25px 50px -12px rgba(0, 0, 0, 0.25));
  padding: 18px 20px 16px;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.16s ease-out, transform 0.16s ease-out;
  box-sizing: border-box;
}
.tour-tip.tour-tip-shown {
  opacity: 1;
  transform: translateY(0);
}
/* Steps with an inline picker (e.g. "Calendar or List?") get a touch more
 * breathing room than the standard 340px card. */
.tour-tip.tour-tip-wide {
  width: min(380px, calc(100vw - 32px));
}

.tour-tip-title {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 800;
  color: var(--text-header, #083463);
  line-height: 1.25;
}
.tour-tip-body {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: #4b5563;
}

/* Inline choice inside a tip card (e.g. "Calendar or List?"). Picking an
 * option both applies it (via the step's pickerHandlerKey) and advances the
 * tour, so this doubles as the step's "Next" action. */
.tour-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}
.tour-picker-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  font-family: inherit;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.tour-picker-btn:hover:not(:disabled) {
  border-color: var(--primary-blue, #1b6fd8);
  background: rgba(27, 111, 216, 0.06);
}
.tour-picker-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}
.tour-picker-btn > .fa-solid:first-child {
  flex-shrink: 0;
  width: 18px;
  text-align: center;
  color: var(--primary-blue, #1b6fd8);
  font-size: 15px;
}
.tour-picker-btn-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}
.tour-picker-btn-text strong {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--text-header, #083463);
}
.tour-picker-btn-text small {
  font-size: 12px;
  color: #64748b;
}
.tour-picker-check {
  flex-shrink: 0;
  font-size: 16px;
  color: var(--primary-blue, #1b6fd8);
  visibility: hidden;
}
.tour-picker-btn-active {
  border-color: var(--primary-blue, #1b6fd8);
  background: rgba(27, 111, 216, 0.08);
}
.tour-picker-btn-active .tour-picker-check {
  visibility: visible;
}
.tour-picker-note {
  margin: 2px 0 0;
  font-size: 12px;
  line-height: 1.4;
  color: #94a3b8;
  font-style: italic;
}

.tour-tip-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}
.tour-counter {
  font-size: 12px;
  font-weight: 700;
  color: #ffffff;
  background: var(--primary-blue, #1b6fd8);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
.tour-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
/* Compact variants of the shared button system for the tight footer. */
.tour-tip .tour-btn {
  padding: 7px 16px;
  font-size: 13px;
  border-radius: 10px;
}
.tour-skip {
  background: none;
  border: none;
  padding: 4px 6px;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  color: #94a3b8;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.tour-skip:hover {
  color: #64748b;
}

/* While the tour runs, it does its own dimming — suppress the app sidebar's
 * separate backdrop (which otherwise shows through the spotlight hole as a dark
 * blob) and its slide transition (so opening/closing it for a step is instant
 * and the spotlight lands on the settled position, not a mid-slide one). */
body.tour-open .sidebar-backdrop {
  opacity: 0 !important;
  pointer-events: none !important;
}
body.tour-open #app-sidebar,
body.tour-open #app-main {
  transition: none !important;
}

/* Mobile: dock the tooltip to an edge as a sheet. It defaults to the bottom and
 * flips to the top (.tour-tip-top) whenever the spotlight is in the lower half,
 * so the card never covers what it's describing. */
@media (max-width: 640px) {
  .tour-tip {
    left: 12px !important;
    right: 12px !important;
    width: auto !important;
    bottom: max(14px, env(safe-area-inset-bottom, 0px)) !important;
    top: auto !important;
  }
  .tour-tip.tour-tip-top {
    top: max(14px, env(safe-area-inset-top, 0px)) !important;
    bottom: auto !important;
  }
}

/* ── Replay entry button (account page footer / anywhere) ─────────────────── */
.tour-replay-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  border: 1px solid #e2e8f0;
  padding: 8px 16px;
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  text-decoration: none;
}
.tour-replay-btn:hover {
  background: #f1f5f9;
  color: #334155;
}
