/* ============================================================
   AI Walkthrough Tour — tour.css
   Full-screen overlay with glass card, 7-stop flow, gold accents
   ============================================================ */

/* ── Overlay ──────────────────────────────────────────────── */
.tour-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 7, 13, 0.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Card (desktop: centered; mobile: bottom sheet) ────────── */
.tour-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6), 0 0 0 1px var(--border-subtle);
}

@media (max-width: 480px) {
  .tour-card {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    max-width: 100%;
    max-height: 80vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    transform: none;
    max-height: 85vh;
  }
}

/* ── Avatar + AI name header ───────────────────────────────── */
.tour-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-6) var(--space-4);
  border-bottom: 1px solid var(--border-glass);
  flex-shrink: 0;
}

.tour-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--gold-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  box-shadow: 0 0 12px var(--gold-glow-strong);
}

.tour-ai-name {
  font-family: 'Syne', sans-serif;
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--gold-primary);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.tour-stop-indicator {
  font-family: 'DM Sans', sans-serif;
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-left: auto;
  letter-spacing: 0.04em;
}

/* ── Stop content area (scrollable) ────────────────────────── */
.tour-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.tour-body::-webkit-scrollbar {
  width: 4px;
}
.tour-body::-webkit-scrollbar-track {
  background: transparent;
}
.tour-body::-webkit-scrollbar-thumb {
  background: var(--border-glass);
  border-radius: 4px;
}

/* ── AI message (quote) ────────────────────────────────────── */
.tour-ai-message {
  font-family: 'DM Sans', sans-serif;
  font-size: var(--text-base);
  color: var(--text-primary);
  line-height: 1.65;
  padding-left: var(--space-4);
  border-left: 2px solid var(--gold-primary);
  margin-bottom: var(--space-5);
}

.tour-ai-message p {
  margin: 0 0 var(--space-2);
}

.tour-ai-message p:last-child {
  margin-bottom: 0;
}

/* ── Demo block (highlighted element preview) ───────────────── */
.tour-demo {
  background: var(--bg-elevated);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-top: var(--space-3);
}

.tour-demo-label {
  font-family: 'DM Sans', sans-serif;
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--space-3);
}

.tour-demo-stat {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.tour-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
}

.tour-stat-label {
  font-family: 'DM Sans', sans-serif;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.tour-stat-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: var(--text-sm);
  color: var(--gold-bright);
  font-weight: 500;
}

.tour-demo-card {
  background: var(--bg-glass);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.tour-quest-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-family: 'DM Sans', sans-serif;
  font-size: var(--text-xs);
  color: var(--gold-primary);
  border: 1px solid var(--border-gold);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  width: fit-content;
}

.tour-quest-title {
  font-family: 'Syne', sans-serif;
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text-primary);
}

.tour-quest-meta {
  font-family: 'DM Sans', sans-serif;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.tour-connections-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  list-style: none;
  padding: 0;
  margin: 0;
}

.tour-connection-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
}

.tour-connection-name {
  font-family: 'DM Sans', sans-serif;
  font-size: var(--text-sm);
  color: var(--text-primary);
  font-weight: 500;
}

.tour-connection-desc {
  font-family: 'DM Sans', sans-serif;
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-align: right;
}

.tour-ready-cta {
  background: var(--gold-gradient);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  text-align: center;
  margin-top: var(--space-3);
}

.tour-ready-cta p {
  font-family: 'DM Sans', sans-serif;
  font-size: var(--text-sm);
  color: #0a0a0a;
  font-weight: 500;
  margin-bottom: var(--space-2);
}

.tour-ready-cta small {
  font-family: 'DM Sans', sans-serif;
  font-size: var(--text-xs);
  color: rgba(10, 10, 10, 0.6);
}

/* ── Navigation footer ─────────────────────────────────────── */
.tour-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-glass);
  flex-shrink: 0;
  gap: var(--space-3);
}

.tour-progress-dots {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1;
  justify-content: center;
  flex-wrap: nowrap;
}

.tour-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-glass);
  transition: all 0.3s var(--ease-out-expo);
  flex-shrink: 0;
}

.tour-dot.active {
  background: var(--gold-primary);
  box-shadow: 0 0 8px var(--gold-glow-strong);
  transform: scale(1.4);
}

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

/* ── Navigation buttons ────────────────────────────────────── */
.tour-btn {
  font-family: 'Syne', sans-serif;
  font-size: var(--text-sm);
  font-weight: 600;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-pill);
  border: none;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition: all 0.2s ease;
  white-space: nowrap;
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.tour-btn:active {
  transform: scale(0.97);
}

.tour-btn-back {
  background: transparent;
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
}

.tour-btn-back:hover {
  border-color: var(--border-active);
  color: var(--text-primary);
}

.tour-btn-skip {
  background: transparent;
  border: 1px solid var(--border-glass);
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.tour-btn-skip:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.tour-btn-next {
  background: var(--gold-gradient);
  color: #0a0a0a;
  font-weight: 700;
}

.tour-btn-next:hover {
  box-shadow: 0 0 20px var(--gold-glow-med);
  transform: translateY(-1px);
}

.tour-btn-primary {
  background: var(--gold-gradient);
  color: #0a0a0a;
  font-weight: 700;
  flex: 1;
  justify-content: center;
  min-width: 140px;
}

.tour-btn-primary:hover {
  box-shadow: 0 0 20px var(--gold-glow-med);
}

/* ── Tour prompt card ─────────────────────────────────────── */
.tour-prompt-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
}

.tour-prompt-card {
  background: var(--bg-glass);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 0 40px var(--gold-glow);
}

.tour-prompt-icon {
  font-size: 2rem;
  margin-bottom: var(--space-4);
}

.tour-prompt-title {
  font-family: 'Syne', sans-serif;
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--gold-bright);
  margin-bottom: var(--space-2);
  letter-spacing: 0.03em;
}

.tour-prompt-subtitle {
  font-family: 'DM Sans', sans-serif;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: var(--space-6);
}

.tour-prompt-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* ============================================================
   Live System Guide
   A compact map plus an AP coach on the actual feature screens.
   ============================================================ */

.system-guide-hub {
  width: calc(100% - var(--sidebar-expanded));
  margin-left: var(--sidebar-expanded);
  margin-right: 0;
  box-sizing: border-box;
  padding-bottom: 7rem;
}

@media (max-width: 900px) {
  .system-guide-hub {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
  }
}

.system-guide-hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(260px, 0.75fr);
  gap: clamp(1.25rem, 3vw, 3rem);
  align-items: center;
  padding: clamp(1.4rem, 4vw, 3rem);
  border: 1px solid var(--border-gold);
  border-radius: 24px;
  background:
    radial-gradient(circle at 88% 8%, rgba(var(--metal-rgb), 0.2), transparent 34%),
    linear-gradient(135deg, var(--bg-elevated), var(--bg-glass));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.22);
}

.system-guide-hero::after {
  content: '';
  position: absolute;
  width: 210px;
  height: 210px;
  right: -80px;
  bottom: -120px;
  border: 1px solid rgba(var(--metal-rgb), 0.22);
  border-radius: 50%;
  box-shadow: 0 0 0 34px rgba(var(--metal-rgb), 0.035), 0 0 0 68px rgba(var(--metal-rgb), 0.025);
  pointer-events: none;
}

.system-guide-eyebrow,
.system-guide-coach-kicker,
.system-guide-step-group {
  display: block;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.67rem;
  font-weight: 700;
  color: var(--gold-primary);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.system-guide-hero h1 {
  max-width: 720px;
  margin: 0.55rem 0 0.7rem;
  font-family: 'Syne', sans-serif;
  font-size: clamp(1.75rem, 4vw, 3.15rem);
  line-height: 1.05;
  color: var(--text-primary);
}

.system-guide-hero-copy > p {
  max-width: 710px;
  margin: 0;
  color: var(--text-secondary);
  font-size: clamp(0.88rem, 1.6vw, 1rem);
  line-height: 1.7;
}

.system-guide-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1.35rem;
}

.system-guide-hero-status {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  border: 1px solid var(--border-glass);
  border-radius: 18px;
  background: rgba(10, 10, 12, 0.24);
}

.system-guide-hero-status > div:last-child {
  display: grid;
  gap: 0.25rem;
}

.system-guide-hero-status strong {
  color: var(--text-primary);
  font-size: 0.88rem;
}

.system-guide-hero-status span {
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1.45;
}

.system-guide-ring {
  --guide-progress: 0%;
  width: 78px;
  aspect-ratio: 1;
  flex: 0 0 auto;
  display: grid;
  place-content: center;
  text-align: center;
  border-radius: 50%;
  background:
    radial-gradient(circle closest-side, var(--bg-elevated) 76%, transparent 78% 99%),
    conic-gradient(var(--gold-primary) var(--guide-progress), rgba(var(--metal-rgb), 0.13) 0);
}

.system-guide-ring span {
  color: var(--gold-bright);
  font: 700 1.3rem/1 'JetBrains Mono', monospace;
}

.system-guide-ring small {
  margin-top: 0.2rem;
  color: var(--text-muted);
  font: 500 0.62rem/1 'DM Sans', sans-serif;
}

.system-guide-map-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin: clamp(1.8rem, 4vw, 3rem) 0 1rem;
}

.system-guide-map-head h2 {
  margin: 0.35rem 0 0;
  font: 700 clamp(1.15rem, 2.4vw, 1.7rem)/1.2 'Syne', sans-serif;
  color: var(--text-primary);
}

.system-guide-map-head > p {
  max-width: 340px;
  margin: 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-align: right;
}

.system-guide-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.system-guide-map-card {
  position: relative;
  min-width: 0;
  display: grid;
  grid-template-columns: 30px 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.7rem;
  padding: 0.9rem;
  color: inherit;
  text-align: left;
  background: var(--bg-elevated);
  border: 1px solid var(--border-glass);
  border-radius: 15px;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.system-guide-map-card:hover,
.system-guide-map-card:focus-visible {
  transform: translateY(-2px);
  border-color: var(--gold-primary);
  background: linear-gradient(135deg, rgba(var(--metal-rgb), 0.1), var(--bg-elevated));
  outline: none;
}

.system-guide-map-card.current {
  border-color: var(--gold-primary);
  box-shadow: inset 0 0 0 1px rgba(var(--metal-rgb), 0.14);
}

.system-guide-map-card.done {
  border-color: rgba(74, 222, 128, 0.24);
}

.system-guide-map-number {
  color: var(--text-muted);
  font: 600 0.68rem/1 'JetBrains Mono', monospace;
}

.system-guide-map-card.done .system-guide-map-number {
  color: var(--success);
}

.system-guide-map-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  color: var(--gold-bright);
  font-size: 1rem;
  background: rgba(var(--metal-rgb), 0.09);
  border: 1px solid rgba(var(--metal-rgb), 0.18);
  border-radius: 11px;
}

.system-guide-map-copy {
  min-width: 0;
  display: grid;
  gap: 0.17rem;
}

.system-guide-map-copy small {
  color: var(--gold-primary);
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.system-guide-map-copy strong {
  color: var(--text-primary);
  font-size: 0.84rem;
}

.system-guide-map-copy > span {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-muted);
  font-size: 0.67rem;
  line-height: 1.4;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.system-guide-map-open {
  color: var(--gold-primary);
  font-size: 0.65rem;
  white-space: nowrap;
}

.system-guide-control-note {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin-top: 1rem;
  padding: 0.9rem 1rem;
  color: var(--text-secondary);
  font-size: 0.74rem;
  line-height: 1.55;
  border: 1px solid var(--border-glass);
  border-radius: 13px;
  background: var(--bg-glass);
}

.system-guide-control-note strong {
  flex: 0 0 auto;
  color: var(--gold-primary);
}

/* Persistent coach on real feature pages */
.system-guide-coach {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(82px + env(safe-area-inset-bottom));
  z-index: 980;
  width: min(390px, calc(100vw - 32px));
  max-height: min(600px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: var(--text-primary);
  background: color-mix(in srgb, var(--bg-elevated) 94%, transparent);
  border: 1px solid var(--border-gold);
  border-radius: 18px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.44), 0 0 28px rgba(var(--metal-rgb), 0.08);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.system-guide-coach-head {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.75rem 0.8rem;
  border-bottom: 1px solid var(--border-glass);
}

.system-guide-coach-avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  color: #0a0a0a;
  background: var(--gold-gradient);
  border-radius: 50%;
  box-shadow: 0 0 18px var(--gold-glow);
}

.system-guide-coach-progress {
  margin-top: 0.12rem;
  color: var(--text-muted);
  font: 500 0.65rem/1.2 'JetBrains Mono', monospace;
}

.system-guide-icon-btn {
  width: 32px;
  height: 32px;
  margin-left: auto;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border-glass);
  border-radius: 50%;
  cursor: pointer;
}

.system-guide-coach-body {
  overflow-y: auto;
  padding: 0.9rem;
}

.system-guide-coach-body h2 {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0.35rem 0 0.45rem;
  color: var(--text-primary);
  font: 700 1.05rem/1.25 'Syne', sans-serif;
}

.system-guide-coach-body h2 span {
  color: var(--gold-primary);
}

.system-guide-coach-body > p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.76rem;
  line-height: 1.55;
}

.system-guide-try,
.system-guide-intelligence,
.system-guide-away {
  display: grid;
  gap: 0.3rem;
  margin-top: 0.75rem;
  padding: 0.7rem 0.75rem;
  border-radius: 11px;
}

.system-guide-try {
  background: rgba(var(--metal-rgb), 0.09);
  border: 1px solid rgba(var(--metal-rgb), 0.22);
}

.system-guide-try span,
.system-guide-intelligence span {
  color: var(--gold-primary);
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.system-guide-try strong {
  color: var(--text-primary);
  font-size: 0.74rem;
  line-height: 1.5;
}

.system-guide-intelligence {
  color: var(--text-secondary);
  font-size: 0.7rem;
  line-height: 1.48;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border-glass);
}

.system-guide-away {
  color: var(--text-secondary);
  font-size: 0.74rem;
  line-height: 1.5;
  background: rgba(96, 165, 250, 0.08);
  border: 1px solid rgba(96, 165, 250, 0.2);
}

.system-guide-away .btn {
  width: fit-content;
  margin-top: 0.35rem;
}

.system-guide-coach-nav {
  display: flex;
  align-items: center;
  gap: 0.38rem;
  padding: 0.65rem;
  overflow-x: auto;
  border-top: 1px solid var(--border-glass);
}

.system-guide-coach-nav .btn {
  flex: 0 0 auto;
}

.system-guide-coach-nav #system-guide-next {
  margin-left: auto;
}

.system-guide-coach.collapsed {
  width: 250px;
}

.system-guide-coach.collapsed .system-guide-coach-body,
.system-guide-coach.collapsed .system-guide-coach-nav {
  display: none;
}

.system-guide-coach.collapsed .system-guide-coach-head {
  border-bottom: 0;
}

.system-guide-target {
  position: relative;
  z-index: 2;
  border-radius: 12px;
  outline: 2px solid var(--gold-primary) !important;
  outline-offset: 5px;
  animation: system-guide-pulse 1.8s ease-in-out infinite;
}

@keyframes system-guide-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(var(--metal-rgb), 0); }
  50% { box-shadow: 0 0 0 9px rgba(var(--metal-rgb), 0.12); }
}

@media (max-width: 980px) {
  .system-guide-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .system-guide-hero {
    grid-template-columns: 1fr;
  }

  .system-guide-hero-status {
    max-width: 360px;
  }

  .system-guide-map-head {
    display: grid;
  }

  .system-guide-map-head > p {
    text-align: left;
  }

  .system-guide-coach {
    right: 10px;
    bottom: calc(76px + env(safe-area-inset-bottom));
    width: calc(100vw - 20px);
    max-height: min(510px, calc(100vh - 98px));
  }
}

@media (max-width: 560px) {
  .system-guide-grid {
    grid-template-columns: 1fr;
  }

  .system-guide-map-card {
    grid-template-columns: 26px 36px minmax(0, 1fr) auto;
    padding: 0.78rem;
  }

  .system-guide-map-copy > span {
    -webkit-line-clamp: 1;
  }

  .system-guide-control-note {
    display: grid;
  }

  .system-guide-coach-nav {
    scrollbar-width: none;
  }

  .system-guide-coach-nav::-webkit-scrollbar {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .system-guide-target {
    animation: none;
  }

  .system-guide-map-card {
    transition: none;
  }
}
