/* ===== Product tour (/product): guided replica of the signed-in workspace =====
   The replica reuses the real workspace component classes from style.css
   (workspace-panel, telemetry-item, trend-item, ...) and only tightens their
   spacing so a whole screen fits in the framed window. All colours come from
   the design tokens, so the light and dark themes both work.

   States on .tour:
     (none)       no JavaScript: steps read as a plain list, replica is static
     .is-ready    script initialised, waiting for the visitor to press Start
     .is-running  tour in progress
     .is-final    last step (no spotlight target)                              */

.tour { scroll-margin-top: 80px; }

.tour__stage {
  position: relative;
  max-width: 1080px;
  margin: 0 auto;
}

.tour__badge {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--color-warning);
  background: var(--color-warning-soft);
  color: var(--color-warning);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.tour__caption {
  max-width: 1080px;
  margin: var(--space-md) auto 0;
  color: var(--color-text-secondary);
  font-size: 0.88rem;
  text-align: center;
}

/* ---------- App window ---------- */
.tour__window {
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.tour__chrome {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  min-height: 44px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg-elevated);
}

.tour__lights { display: inline-flex; gap: 6px; flex-shrink: 0; }
.tour__lights i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-border-strong);
}

.tour__url {
  flex: 1 1 auto;
  min-width: 0;
  padding: 5px 12px;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--color-surface-strong);
  color: var(--color-text-secondary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tour__viewport {
  position: relative;
  height: 600px;
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
}

.tour__canvas {
  position: relative;
  display: grid;
  gap: 14px;
  min-width: 0;
  padding: 20px;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--color-text);
  user-select: none;
}

.tour__canvas p { margin: 0; }

.tour__screen { display: none; gap: 14px; min-width: 0; }
.tour__screen.is-active { display: grid; }

.tour__grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  min-width: 0;
}
.tour__grid--wide { grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr); }
.tour__grid > * { min-width: 0; }

.tour__page-head { display: grid; gap: 4px; justify-items: start; }
.tour__h1 { font-family: var(--font-display); font-size: 1.5rem; font-weight: 700; line-height: 1.15; }
.tour__h2 { margin-bottom: 10px !important; font-family: var(--font-display); font-size: 1.05rem; font-weight: 700; }
.tour__body { margin-bottom: 10px !important; color: var(--color-text-secondary); }

/* Tighter versions of the real workspace components. */
.tour__canvas .workspace-panel { padding: 16px; border-radius: 16px; }
.tour__canvas .workspace-panel__header { margin-bottom: 12px; }
.tour__canvas .section-label { margin-bottom: 2px; font-size: 0.68rem; }
.tour__canvas .eyebrow { font-size: 0.68rem; }
.tour__canvas .workspace-identity { gap: 6px; }
.tour__canvas .workspace-chip { padding: 4px 9px; font-size: 0.72rem; }
.tour__canvas .metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.tour__canvas .metric-card { padding: 10px 12px; border-radius: 12px; }
.tour__canvas .metric-card__label { margin-bottom: 4px; font-size: 0.72rem; }
.tour__canvas .metric-card strong { font-size: 1.3rem; }
.tour__canvas .stack-list { gap: 10px; }
.tour__canvas .telemetry-item,
.tour__canvas .trend-item,
.tour__canvas .recommendation-item { padding: 12px; border-radius: 12px; }
.tour__canvas .telemetry-item__header,
.tour__canvas .recommendation-item__header { gap: 10px; margin-bottom: 6px; }
.tour__canvas .telemetry-item__title,
.tour__canvas .recommendation-item__title,
.tour__canvas .trend-item__title { font-size: 0.92rem; font-weight: 700; }
.tour__canvas .telemetry-meta,
.tour__canvas .recommendation-meta { gap: 8px; margin-top: 8px; }
.tour__canvas .telemetry-meta--two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tour__canvas .telemetry-meta span,
.tour__canvas .recommendation-meta span { font-size: 0.7rem; }
.tour__canvas .telemetry-meta strong,
.tour__canvas .recommendation-meta strong { margin-top: 2px; font-size: 0.8rem; }
.tour__canvas .telemetry-meta__source,
.tour__canvas .telemetry-item__seen { font-size: 0.72rem; }
.tour__canvas .trend-item__context { margin-top: 4px; font-size: 0.74rem; }
.tour__canvas .telemetry-controls { margin-top: 10px; }
.tour__canvas .severity-pill { padding: 3px 8px; font-size: 0.68rem; white-space: nowrap; }
.tour__canvas .telemetry-id { gap: 6px; }
.tour__canvas code { font-size: 0.92em; }
/* Controls in the replica are pictures of controls: not focusable, not live. */
.tour__canvas .btn { padding: 4px 10px; font-size: 0.72rem; pointer-events: none; box-shadow: none; }
.tour__canvas .btn--tiny { padding: 1px 6px; font-size: 0.66rem; }
.tour__btn-disabled { opacity: 0.6; }

/* API responses shown as the JSON the endpoint returns. */
.tour__api {
  max-width: 58%;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-instrument);
  color: var(--color-instrument-text);
  overflow: hidden;
}
.tour__api--cmd { max-width: 58%; }
.tour__api-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  padding: 9px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--color-instrument-panel);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.74rem;
  overflow-wrap: anywhere;
}
.tour__verb {
  padding: 1px 7px;
  border-radius: 6px;
  background: rgba(98, 212, 162, 0.18);
  color: #8fe6bf;
  font-weight: 700;
}
.tour__api-note { margin-left: auto; color: var(--color-instrument-muted); }
.tour__json {
  margin: 0;
  padding: 12px;
  overflow: auto;
  background: transparent;
  border: 0;
  border-radius: 0;
  color: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  line-height: 1.55;
  white-space: pre;
  tab-size: 2;
}
.tour__json code { padding: 0; background: none; border: 0; color: inherit; font: inherit; }
.tour__hl { color: #ffd68a; }
.tour__dim { color: var(--color-instrument-muted); }

/* ---------- Spotlight ---------- */
.tour__spot {
  position: absolute;
  z-index: 2;
  border: 2px solid var(--color-accent);
  border-radius: 16px;
  box-shadow: 0 0 0 4000px rgba(8, 14, 24, 0.58);
  pointer-events: none;
  transition: top 240ms ease, left 240ms ease, width 240ms ease, height 240ms ease;
}
.tour__spot[hidden] { display: none; }

.tour.is-running .tour__canvas .is-target { cursor: pointer; }
.tour.is-running .tour__canvas .is-click {
  position: relative;
  z-index: 3;
  cursor: pointer;
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  background: var(--color-accent-soft);
  animation: tour-pulse 1.8s ease-in-out infinite;
}
@keyframes tour-pulse {
  0%, 100% { outline-offset: 2px; }
  50% { outline-offset: 5px; }
}

/* Final step and the pre-start state dim the whole replica. */
.tour.is-final .tour__canvas::after,
.tour.is-ready:not(.is-running) .tour__canvas::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background: rgba(8, 14, 24, 0.58);
}
/* Darker before the start so the cover text stays readable in the light theme. */
.tour.is-ready:not(.is-running) .tour__canvas::after { background: rgba(8, 14, 24, 0.76); }

/* ---------- Start cover ---------- */
.tour__cover {
  position: absolute;
  inset: 44px 0 0 0;
  z-index: 5;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: var(--space-md);
  padding: var(--space-lg);
  text-align: center;
  color: #edf5ff;
}
.tour__cover[hidden] { display: none; }
.tour__cover-title {
  max-width: 34ch;
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.3;
  color: inherit;
}
.tour__cover-note { margin: 0; color: #c6d3e3; font-size: 0.9rem; }

/* ---------- Coachmark ---------- */
.tour__coach {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
  padding: var(--space-lg);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface-strong);
  box-shadow: var(--shadow-lg);
  color: var(--color-text);
}
.tour__coach:focus { outline: none; }
.tour__coach:focus-visible { outline: 3px solid var(--color-accent); outline-offset: 3px; }
.tour.is-ready:not(.is-running) .tour__coach { display: none; }

.tour__coach-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}
.tour__count {
  margin: 0;
  color: var(--color-text-secondary);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.tour__steps {
  display: grid;
  gap: var(--space-lg);
  margin: 0;
  padding: 0;
  list-style: none;
}
.tour__step { display: grid; gap: 8px; min-width: 0; }
.tour__step[hidden] { display: none; }
.tour__step-title { margin: 0; font-size: 1.1rem; line-height: 1.25; }
.tour__step p { margin: 0; color: var(--color-text-secondary); font-size: 0.92rem; line-height: 1.5; }
.tour__step code { font-size: 0.88em; overflow-wrap: anywhere; }
.tour__why { padding-left: 10px; border-left: 3px solid var(--color-accent); }
.tour__why strong { color: var(--color-text); }
.tour__step .tour__hint { color: var(--color-accent); font-weight: 600; }
.tour:not(.is-running) .tour__hint { display: none; }
.tour__finish { display: flex; flex-wrap: wrap; gap: var(--space-sm); margin-top: 6px; }

.tour__nav {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px var(--space-sm);
  margin-top: 4px;
}
.tour__nav[hidden] { display: none; }
.tour__nav-btn { padding: 8px 16px; }
.tour__nav-btn[hidden] { display: none; }
.tour__nav-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.tour__dots { display: flex; justify-content: center; min-width: 0; }
.tour__dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.tour__dot::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-input-border);
  transition: transform var(--transition), background var(--transition);
}
.tour__dot[aria-current="step"]::before { background: var(--color-accent); transform: scale(1.5); }
.tour__dot:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 1px; }
.tour__exit {
  grid-column: 1 / -1;
  justify-self: center;
  padding: 4px 8px;
  border: 0;
  background: none;
  color: var(--color-text-secondary);
  font: inherit;
  font-size: 0.82rem;
  text-decoration: underline;
  cursor: pointer;
}
.tour__exit:hover { color: var(--color-text); }
.tour__exit:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- Desktop: floating coachmark beside the spotlight ---------- */
@media (min-width: 901px) {
  .tour.is-running .tour__coach {
    position: absolute;
    z-index: 6;
    top: 60px;
    left: 24px;
    width: 340px;
    margin: 0;
    padding: 18px;
    transition: top 240ms ease, left 240ms ease;
  }
  .tour.is-running .tour__coach::before {
    content: "";
    position: absolute;
    top: 26px;
    width: 14px;
    height: 14px;
    border: 1px solid var(--color-border-strong);
    background: var(--color-surface-strong);
    transform: rotate(45deg);
  }
  .tour.is-running .tour__coach[data-side="right"]::before { left: -8px; border-top: 0; border-right: 0; }
  .tour.is-running .tour__coach[data-side="left"]::before { right: -8px; border-bottom: 0; border-left: 0; }
  .tour.is-running .tour__coach[data-side="over"]::before,
  .tour.is-running .tour__coach[data-side="center"]::before { display: none; }
  .tour.is-running .tour__nav-btn { padding: 8px 12px; }
  .tour.is-running .tour__dot { width: 18px; }
  .tour.is-running .tour__step-title { font-size: 1.02rem; }
  .tour.is-running .tour__step p { font-size: 0.86rem; }

  /* No JavaScript: the steps read as a two-column list above the replica. */
  .tour:not(.is-ready) .tour__steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------- Narrow screens: one card per step, no miniature replica ----------
   The coachmark becomes a normal card and the window shows only the region
   that step is about, at full width, instead of a shrunken dashboard.        */
@media (max-width: 900px) {
  .tour__viewport { height: auto; overflow: visible; }
  .tour__canvas { padding: 12px; user-select: auto; }
  .tour__lights { display: none; }
  .tour__spot { display: none; }
  .tour__grid,
  .tour__grid--wide { grid-template-columns: minmax(0, 1fr); }
  .tour__api,
  .tour__api--cmd { max-width: none; }
  .tour__json { max-height: 320px; }
  .tour__canvas .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tour__canvas .telemetry-meta,
  .tour__canvas .recommendation-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .tour.is-running .tour__screen > :not(.is-path),
  .tour.is-running .tour__grid > :not(.is-path) { display: none; }
  .tour.is-running .tour__canvas .is-target { cursor: default; }
  .tour.is-final .tour__window,
  .tour.is-ready:not(.is-running) .tour__window { display: none; }

  .tour__cover {
    position: static;
    padding: var(--space-xl) var(--space-lg);
    border-radius: var(--radius-md);
    background: var(--color-instrument);
  }
  .tour__coach { padding: var(--space-md); }
  .tour__finish .btn { flex: 1 1 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .tour__spot,
  .tour.is-running .tour__coach,
  .tour__dot::before { transition: none; }
  .tour.is-running .tour__canvas .is-click { animation: none; }
}

@media print {
  .tour__cover, .tour__nav, .tour__spot { display: none !important; }
}
