/* ── Guided demo tour ─────────────────────────────────────────
   A spotlight walkthrough shown once per demo session. The mask is
   one element: .tour-hole carries an enormous spread box-shadow, so
   everything outside its rect is dimmed and the rect itself stays
   clear. Cheaper and far steadier than four edge divs, which drift
   apart by a subpixel during resize.                              */

.tour-root {
  position: fixed;
  inset: 0;
  z-index: 10000;
  font-family: var(--font-sans);
}

.tour-root[hidden] { display: none; }

/* Swallows every click while the tour runs, so a stray tap can't
   navigate away from the step being described. */
.tour-blocker {
  position: fixed;
  inset: 0;
  cursor: default;
}

.tour-hole {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  border-radius: 10px;
  box-shadow: 0 0 0 9999px var(--overlay-bg);
  border: 2px solid var(--accent);
  pointer-events: none;
  transition: width 0.28s cubic-bezier(0.25, 1, 0.5, 1),
              height 0.28s cubic-bezier(0.25, 1, 0.5, 1),
              transform 0.28s cubic-bezier(0.25, 1, 0.5, 1);
}

/* Steps with no anchor (welcome, sign-off): dim the whole screen and
   drop the ring, rather than spotlighting a 0×0 rect in the corner. */
.tour-hole--none {
  border-color: transparent;
  transition: none;
}

.tour-card {
  position: fixed;
  width: 340px;
  max-width: calc(100vw - 32px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 34px var(--shadow-color);
  padding: 20px 22px 16px;
  transition: transform 0.28s cubic-bezier(0.25, 1, 0.5, 1),
              opacity 0.18s ease;
  /* A column so the body can take the leftover height and scroll inside it —
     without this a long step on a short screen (landscape phone) pushes its own
     buttons off the bottom. dvh so the mobile URL bar doesn't inflate it. */
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px);
}

.tour-card--centered {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 400px;
}

.tour-eyebrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-family: var(--font-mono);
  font-size: var(--text-caption);
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 10px;
  /* Keeps the step counter clear of the absolutely-positioned skip button. */
  padding-right: 82px;
  flex-shrink: 0;
}

.tour-title {
  font-family: var(--font-display);
  font-size: 21px;
  line-height: 1.2;
  color: var(--text-bright);
  margin: 0 0 8px;
  flex-shrink: 0;
}

/* The only part allowed to give: it absorbs the leftover height and scrolls,
   so the buttons stay put no matter how short the screen is. min-height:0 is
   what actually lets a flex child shrink below its content. */
.tour-body {
  font-size: var(--text-md);
  line-height: 1.55;
  color: var(--text);
  margin: 0 0 16px;
  overflow-y: auto;
  min-height: 0;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* Inline emphasis inside tour copy — a widget name, a control label. */
.tour-body strong {
  color: var(--text-bright);
  font-weight: 600;
}

/* Asides: what the demo can't actually do. */
.tour-body em {
  color: var(--muted);
  font-style: italic;
}

.tour-body .tour-kbd {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text-dim);
}

.tour-foot {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.tour-dots {
  display: flex;
  gap: 5px;
  flex: 1;
  flex-wrap: wrap;
}

.tour-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.2s, transform 0.2s;
}

.tour-dot--done { background: var(--text-dim); }

.tour-dot--active {
  background: var(--accent);
  transform: scale(1.5);
}

.tour-btn {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.tour-btn--primary {
  background: var(--accent);
  color: #fff;
}

.tour-btn--primary:hover { filter: brightness(1.08); }

.tour-btn--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--text-dim);
}

.tour-btn--ghost:hover {
  border-color: var(--accent-border);
  color: var(--accent-text);
}

.tour-skip {
  position: absolute;
  top: 14px;
  right: 14px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  cursor: pointer;
  padding: 2px 4px;
}

.tour-skip:hover { color: var(--accent-text); }

/* Replay control in the demo banner. Inherits the banner's amber
   palette rather than the app's, same as .demo-exit-btn. */
#demoBanner .demo-tour-btn {
  margin-left: 10px;
  padding: 3px 10px;
  background: transparent;
  color: var(--demo-banner-text);
  border: 1px solid var(--demo-banner-border);
  border-radius: 4px;
  cursor: pointer;
  font-size: var(--text-sm);
  font-family: var(--font-sans);
}

#demoBanner .demo-tour-btn:hover { background: rgba(255,255,255,0.08); }

/* The banner is a fixed-height, non-wrapping flex row. With a second button in
   it the sentence no longer fits on a phone, so the detail clause drops out and
   the label carries it. */
#demoBanner .demo-banner-label,
#demoBanner .demo-banner-detail { white-space: nowrap; }

@media (max-width: 620px) {
  #demoBanner .demo-banner-detail { display: none; }
  #demoBanner .demo-tour-btn,
  #demoBanner .demo-exit-btn { margin-left: 8px; }
}

/* ── Mobile ──────────────────────────────────────────────────
   Anchored placement has nowhere to go on a narrow screen, so the
   card becomes a bottom sheet and the spotlight keeps doing the work
   of pointing at things. */
@media (max-width: 640px) {
  .tour-card,
  .tour-card--centered {
    left: 12px;
    right: 12px;
    bottom: 12px;
    top: auto;
    width: auto;
    max-width: none;
    transform: none;
    /* Capped so the spotlight always has screen left above the sheet — the JS
       scrolls the target into exactly that gap. */
    max-height: 58vh;
    max-height: 58dvh;
  }
  .tour-title { font-size: 19px; }
  /* Eleven dots plus two buttons overflow a 320px row, and the "STEP 04 / 11"
     counter already says the same thing more precisely. */
  .tour-dots { display: none; }
  .tour-foot { justify-content: flex-end; }

  /* Scroll headroom. The ＋ button is the last thing on a page, so without room
     below it the browser cannot lift it clear of the sheet no matter what
     scroll-margin asks for, and the step points at something covered up. */
  body.tour-active .page.active {
    padding-bottom: 62vh;
    padding-bottom: 62dvh;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tour-hole,
  .tour-card { transition: none; }
}
