/* Guided-tour overlay engine (see documentation/40-guided-tours.md).
   Tokened only — no raw hex (CI). rgba()/color-mix are fine. */

.tour-root { position: fixed; inset: 0; z-index: 10000; pointer-events: none; }

/* While a DEMO is active the page can't move — even a touchpad fling
   dodges wheel events, so we belt-and-braces this with `overflow:hidden`
   on the root html element. The tour engine adds/removes the class in
   begin/teardown. */
html.tour-locked, html.tour-locked body {
  overflow: hidden !important;
  overscroll-behavior: none;
  touch-action: none;
}
.tour-root[hidden] { display: none; }

/* Spotlight: a transparent box over the target whose huge box-shadow dims the
   rest of the page. pointer-events:none so the highlighted control stays usable
   in live mode. */
.tour-spot {
  position: fixed; border-radius: var(--radius, 10px);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .55),
              0 0 0 2px color-mix(in srgb, var(--accent) 70%, transparent);
  transition: top .3s ease, left .3s ease, width .3s ease, height .3s ease;
  pointer-events: none;
}
.tour-spot.is-hidden { box-shadow: 0 0 0 9999px rgba(0, 0, 0, .55); width: 0; height: 0; }
.tour-spot::after {   /* soft pulsing ring */
  content: ""; position: absolute; inset: -3px; border-radius: inherit;
  border: 2px solid color-mix(in srgb, var(--accent) 65%, transparent);
  animation: tour-pulse 1.8s ease-out infinite;
}
@keyframes tour-pulse {
  0% { transform: scale(1); opacity: .9; }
  100% { transform: scale(1.14); opacity: 0; }
}

/* Coachmark card */
.tour-coach {
  position: fixed; z-index: 10001; pointer-events: auto;
  width: min(340px, calc(100vw - 2rem));
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius, 12px);
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, .6);
  padding: 1rem 1.1rem 0.9rem;
  font-family: var(--font-ui);
  transition: top .3s ease, left .3s ease;
}
.tour-coach.is-center {
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(420px, calc(100vw - 2rem));
}

.tour-badge {
  display: inline-flex; align-items: center; gap: .35rem;
  font-family: var(--font-mono); font-size: .62rem; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  padding: .18rem .5rem; border-radius: 999px; margin-bottom: .6rem;
}
.tour-badge.is-demo { color: var(--warn); background: color-mix(in srgb, var(--warn) 16%, transparent); }
.tour-badge.is-live { color: var(--accent); background: var(--accent-weak); }
.tour-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.tour-coach__title { margin: 0 0 .35rem; font-size: 1rem; font-weight: 700; color: var(--text); }
.tour-coach__body { margin: 0; font-size: .86rem; line-height: 1.5; color: var(--text-dim, var(--text)); }
.tour-coach__body code {
  font-family: var(--font-mono); font-size: .82em;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 4px; padding: .05em .35em;
}

.tour-coach__foot {
  display: flex; align-items: center; gap: .5rem;
  margin-top: .9rem; padding-top: .75rem; border-top: 1px solid var(--border);
}
.tour-coach__count { font-family: var(--font-mono); font-size: .72rem; color: var(--text-dim); }
.tour-coach__spacer { flex: 1; }
.tour-btn {
  font: inherit; font-size: .78rem; cursor: pointer; border-radius: var(--radius-sm, 7px);
  padding: .4rem .8rem; border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  transition: border-color .12s, background .12s, color .12s;
}
.tour-btn:hover { border-color: var(--border-strong, var(--accent)); }
.tour-btn--primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent, #fff); }
.tour-btn--primary:hover { background: var(--accent-hover, var(--accent)); }
.tour-btn--ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.tour-close {
  position: absolute; top: .5rem; right: .5rem; width: 26px; height: 26px;
  display: grid; place-items: center; border: none; background: transparent;
  color: var(--text-dim); cursor: pointer; border-radius: var(--radius-sm, 6px); font-size: 1.1rem;
}
.tour-close:hover { color: var(--text); background: var(--surface-2); }

/* Launcher button + menu (topbar) */
.tour-launch svg { width: 18px; height: 18px; }
.tour-menu {
  position: absolute; z-index: 10002; min-width: 240px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius, 10px); box-shadow: 0 18px 44px -22px rgba(0,0,0,.6);
  padding: .4rem; margin-top: .4rem;
}
.tour-menu[hidden] { display: none; }
.tour-menu__head { font-size: .66rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-dim); padding: .4rem .6rem .3rem; }
.tour-menu__item {
  display: block; width: 100%; text-align: left; font: inherit; font-size: .84rem;
  padding: .5rem .6rem; border: none; background: transparent; color: var(--text);
  border-radius: var(--radius-sm, 7px); cursor: pointer;
}
.tour-menu__item:hover { background: var(--surface-2); color: var(--accent); }
.tour-menu__empty { padding: .5rem .6rem; font-size: .8rem; color: var(--text-dim); }

/* Persistent "this is a demo" scrolling banner (demo mode only). */
.tour-marquee {
  position: fixed; left: 0; right: 0; bottom: 0; height: 30px;
  z-index: 10003; overflow: hidden; pointer-events: none;
  display: flex; align-items: center;
  background: var(--warn); color: #1a1206;
  box-shadow: 0 -6px 20px -8px rgba(0, 0, 0, .5);
}
.tour-marquee__track {
  display: flex; align-items: center; white-space: nowrap;
  will-change: transform; animation: tour-marquee 26s linear infinite;
}
.tour-marquee__item {
  font-family: var(--font-mono); font-size: .72rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase; padding: 0 .9rem;
}
.tour-marquee__sep { opacity: .5; font-size: .6rem; }
@keyframes tour-marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }

@media (prefers-reduced-motion: reduce) {
  .tour-spot, .tour-coach { transition: none; }
  .tour-spot::after { animation: none; }
  .tour-marquee__track { animation: none; }
}

/* Demo-only widgets baked into the coachmark (simulated progress + result). */
.tour-widget { margin: .75rem 0 .25rem; }
.tour-progress { display: flex; flex-direction: column; gap: .5rem; }
.tour-progress__row {
  display: flex; align-items: center; gap: .6rem;
  font-size: .82rem; color: var(--text-dim); transition: color .2s ease;
}
.tour-progress__dot {
  width: 16px; height: 16px; border-radius: 50%; flex: none; position: relative;
  border: 2px solid var(--border);
  transition: border-color .2s ease, background .2s ease;
}
.tour-progress__row.is-done { color: var(--text); }
.tour-progress__row.is-done .tour-progress__dot {
  border-color: var(--ok); background: var(--ok);
}
.tour-progress__row.is-done .tour-progress__dot::after {
  content: ""; position: absolute; left: 4px; top: 1px;
  width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
.tour-card {
  border: 1px solid var(--border); border-radius: var(--radius, 10px);
  padding: .7rem .85rem; background: var(--surface-2);
  display: flex; flex-direction: column; gap: .5rem;
}
.tour-card__top { display: flex; align-items: center; gap: .5rem; font-weight: 650; }
.tour-card__domain { font-family: var(--font-mono, monospace); font-size: .8rem; letter-spacing: .02em; }
.tour-card__tags { display: flex; gap: .4rem; }
.tour-card__tag {
  font-size: .68rem; padding: .12rem .5rem; border-radius: 999px;
  border: 1px solid var(--border); color: var(--text-dim);
}
.tour-card__tag.is-ok {
  color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent);
  background: color-mix(in srgb, var(--ok) 12%, transparent);
}
.tour-card__url { font-size: .74rem; color: var(--accent); word-break: break-all; }
