/* ============================================================
   atlvibe — interactive app tour
   Stage 0 slideshow → Stage 1 avatar picker → Stage 2 intro →
   Stage 3 image-on-image onboarding (percentage hotspots).
   All driven by the CARDS/AVATARS config in onboarding.js.
   ============================================================ */

.tour {
  width: min(100% - 3rem, var(--maxw));
  margin: clamp(4rem, 11vh, 7rem) auto 0;
  scroll-margin-top: 2rem;
}

.tour__head { text-align: center; margin-bottom: clamp(1.6rem, 4vw, 2.6rem); }
.tour__title {
  font-family: var(--display); font-weight: 600;
  font-size: clamp(1.9rem, 5vw, 3rem); letter-spacing: -0.03em;
  margin-top: 1rem;
}
.tour__sub { color: var(--muted); margin-top: 0.6rem; }

.tour__panel { position: relative; }
.tour__panel[hidden] { display: none; }

/* stages replace IN PLACE (no page scroll) with an animated swap */
.tour__panel.is-in  { animation: panelIn  0.5s var(--ease-out) both; }
.tour__panel.is-out { animation: panelOut 0.3s var(--ease) both; }
@keyframes panelIn  { from { opacity: 0; transform: translateY(16px) scale(0.985); } }
@keyframes panelOut { to   { opacity: 0; transform: translateY(-12px) scale(0.985); } }

/* ------------------------------------------------------------
   Focus layer: the picker + onboarding stages take over the
   viewport, centered vertically & horizontally, so nothing sits
   low on tall screens and no page scroll is needed. The hero
   slideshow (overview) stays inline in the page.
   `:not([hidden])` keeps the earlier hidden rule working.
   ------------------------------------------------------------ */
.tour__panel[data-panel="picker"]:not([hidden]),
.tour__panel[data-panel="onboarding"]:not([hidden]) {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 1.2rem;
  padding: max(3.5rem, env(safe-area-inset-top)) 1.2rem
           max(1.4rem, env(safe-area-inset-bottom));
  overflow-y: auto;
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255,107,74,0.10), transparent 55%),
    linear-gradient(180deg, rgba(16,11,13,0.90), rgba(16,11,13,0.97));
  -webkit-backdrop-filter: blur(16px);
          backdrop-filter: blur(16px);
}

/* back button pinned to the corner of the focus layer */
.tour__panel[data-panel="picker"] .tour__back,
.tour__panel[data-panel="onboarding"] .tour__back {
  position: absolute; top: max(1rem, env(safe-area-inset-top)); left: 1rem; margin: 0;
}

/* keep the phone within tall-but-short viewports (laptops) */
@media (max-height: 780px) {
  .tour__panel[data-panel="onboarding"] .phone { width: auto; height: min(74vh, 620px); }
}

body.tour-focused { overflow: hidden; }   /* lock background scroll while focused */

.tour__back {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.85rem; color: var(--muted);
  padding: 0.5rem 0.9rem; margin-bottom: 1.4rem;
  border: 1px solid var(--line); border-radius: var(--pill);
  background: rgba(27,20,24,0.5); backdrop-filter: blur(8px);
  transition: color 0.2s var(--ease), border-color 0.2s var(--ease);
}
.tour__back:hover { color: var(--cream); border-color: rgba(255,138,91,0.5); }

/* ============================================================
   STAGE 0 — slideshow of app-screen cards
   ============================================================ */
.slides-wrap { position: relative; }

.slides {
  display: flex; gap: clamp(1rem, 3vw, 1.6rem);
  overflow-x: auto; scroll-snap-type: x mandatory;
  padding: 0.5rem clamp(0.5rem, 6vw, 4rem) 1.5rem;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
}
.slides::-webkit-scrollbar { display: none; }

.card-screen {
  scroll-snap-align: center;
  flex: 0 0 auto;
  width: min(74vw, 264px);
  text-align: left;
  display: flex; flex-direction: column; gap: 0.9rem;
  transition: transform 0.35s var(--ease);
  cursor: default;                    /* click-through disabled for now */
}
.card-screen:hover { transform: translateY(-6px); }

.card-screen__frame {
  position: relative;
  aspect-ratio: 1 / 2;                /* ≈ the screenshots' ratio → almost no letterbox,
                                         so the gap is just the padding below, not letterbox */
  padding: 6px 5px 3px;               /* thin top/bottom bezels, slim sides */
  border-radius: 30px;
  overflow: hidden;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  box-shadow: 0 30px 60px -30px rgba(0,0,0,0.9),
              inset 0 1px 0 rgba(255,255,255,0.06);
  transition: border-color 0.35s var(--ease), box-shadow 0.35s var(--ease);
}
.card-screen:hover .card-screen__frame {
  border-color: rgba(255,138,91,0.4);
  box-shadow: 0 40px 70px -30px rgba(0,0,0,0.9), var(--shadow-glow);
}
/* two stacked layers so multi-frame cards can cross-dissolve smoothly.
   Each <img> sizes to the picture itself (centered), so the whole shot shows
   zoomed out AND the rounded corners clip the actual screenshot. */
.card-screen__stage { position: relative; width: 100%; height: 100%; }
.card-screen__img {
  position: absolute;
  left: 50%; top: 50%; transform: translate(-50%, -50%);
  max-width: 100%; max-height: 100%;
  width: auto; height: auto;
  border-radius: 16px;
  opacity: 0;
  transition: opacity 1.6s var(--ease);   /* slow cross-dissolve between frames */
}
/* iPhone chrome living in the top/bottom bezel gaps */
.card-screen__frame::before {       /* earpiece / mic slit */
  content: ""; position: absolute; z-index: 2;
  top: 6px; left: 50%; transform: translateX(-50%);
  width: 24%; height: 5px; border-radius: 3px;
  background: rgba(0,0,0,0.55);
}
.card-screen__frame::after {        /* home-indicator line */
  content: ""; position: absolute; z-index: 2;
  bottom: 6px; left: 50%; transform: translateX(-50%);
  width: 34%; height: 5px; border-radius: 3px;
  background: rgba(246,237,230,0.5);
}

.card-screen__meta h3 {
  font-family: var(--display); font-weight: 600; font-size: 1.25rem;
  letter-spacing: -0.02em;
}
.card-screen__meta p { color: var(--muted); font-size: 0.9rem; margin-top: 0.1rem; }
.card-screen__cta {
  display: inline-block; margin-top: 0.5rem;
  font-size: 0.82rem; font-weight: 600; color: var(--peach);
}
/* a chip ABOVE the card frame — no longer overlaid on the screenshot */
.card-screen__flag {
  align-self: flex-start;
  font-size: 0.66rem; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 0.3rem 0.7rem; border-radius: var(--pill);
  background: rgba(16,11,13,0.7); border: 1px solid var(--line);
  color: var(--gold);
}

/* arrows + dots */
.slides__arrow {
  position: absolute; top: 38%; z-index: 5;
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.4rem; line-height: 1;
  color: var(--cream);
  background: rgba(27,20,24,0.8); border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  transition: transform 0.2s var(--ease), border-color 0.2s var(--ease), opacity 0.2s;
}
.slides__arrow:hover { border-color: rgba(255,138,91,0.6); transform: scale(1.06); }
.slides__arrow--prev { left: 0; }
.slides__arrow--next { right: 0; }
.slides__arrow[disabled] { opacity: 0.3; pointer-events: none; }
@media (max-width: 620px) { .slides__arrow { display: none; } }

.slides__dots {
  display: flex; justify-content: center; gap: 0.5rem; margin-top: 0.4rem;
}
.slides__dot {
  width: 7px; height: 7px; border-radius: 50%; background: var(--line);
  transition: background 0.2s, width 0.2s;
}
.slides__dot.is-active { background: var(--peach); width: 20px; border-radius: var(--pill); }

/* ============================================================
   STAGE 1 — avatar picker
   ============================================================ */
.picker__prompt {
  text-align: center; font-family: var(--display); font-weight: 600;
  font-size: clamp(1.4rem, 4vw, 2rem); letter-spacing: -0.02em;
  margin-bottom: 1.6rem;
}
.picker__grid {
  display: grid; gap: 1.1rem;
  grid-template-columns: repeat(4, 1fr);
  max-width: 760px; margin: 0 auto;
}
@media (max-width: 620px) { .picker__grid { grid-template-columns: repeat(2, 1fr); } }

.avatar-pick {
  display: flex; flex-direction: column; align-items: center; gap: 0.7rem;
  padding: 1.2rem 0.8rem;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(36,26,31,0.5), rgba(27,20,24,0.35));
  border: 1px solid var(--line);
  transition: transform 0.3s var(--ease), border-color 0.3s var(--ease),
              box-shadow 0.3s var(--ease), opacity 0.4s var(--ease);
}
.avatar-pick:hover {
  transform: translateY(-5px);
  border-color: rgba(255,138,91,0.45);
  box-shadow: 0 24px 44px -26px rgba(0,0,0,0.85), var(--shadow-glow);
}
.avatar-pick__img {
  width: clamp(74px, 20vw, 108px); aspect-ratio: 1;
  border-radius: 50%; object-fit: cover;
  border: 2px solid rgba(255,138,91,0.35);
  background: var(--surface-2);
}
.avatar-pick__name { font-family: var(--display); font-weight: 600; font-size: 1.1rem; }
.avatar-pick__tag { font-size: 0.78rem; color: var(--muted); text-align: center; }

/* when a pick is made: fade the others out */
.picker__grid.is-choosing .avatar-pick:not(.is-chosen) {
  opacity: 0; transform: scale(0.9); pointer-events: none;
}
.picker__grid.is-choosing { grid-template-columns: repeat(4, 1fr); }

/* ============================================================
   STAGE 2 — intro focus + typewriter bubble
   ============================================================ */
.focus {
  display: flex; flex-direction: column; align-items: center; gap: 1.3rem;
  padding: 1rem 0 0.5rem; text-align: center;
}
.focus[hidden] { display: none; }
.focus__avatar {
  width: clamp(130px, 34vw, 190px); aspect-ratio: 1;
  border-radius: 50%; object-fit: cover;
  border: 3px solid rgba(255,138,91,0.5);
  box-shadow: 0 0 0 8px rgba(255,138,91,0.08), var(--shadow-glow);
  animation: focusPop 0.55s var(--ease-out) both;
}
.focus__bubble {
  position: relative; max-width: 34ch;
  padding: 1.1rem 1.3rem; border-radius: 20px;
  background: linear-gradient(180deg, rgba(244,197,107,0.12), rgba(27,20,24,0.65));
  border: 1px solid rgba(244,197,107,0.3);
  animation: focusPop 0.5s 0.12s var(--ease-out) both;
}
.focus__bubble::before { /* speech tail */
  content: ""; position: absolute; top: -9px; left: 50%; transform: translateX(-50%) rotate(45deg);
  width: 16px; height: 16px;
  background: rgba(244,197,107,0.12);
  border-left: 1px solid rgba(244,197,107,0.3); border-top: 1px solid rgba(244,197,107,0.3);
}
.focus__text { font-size: 1.08rem; line-height: 1.55; min-height: 1.5em; }
.focus__text .word { opacity: 0; display: inline-block; animation: wordIn 0.32s var(--ease-out) forwards; }
.focus__caret {
  display: inline-block; width: 2px; height: 1.05em; margin-left: 2px;
  background: var(--peach); vertical-align: -0.15em;
  animation: blink 0.9s steps(1) infinite;
}
.focus__skip {
  font-size: 0.8rem; color: var(--faint);
  padding: 0.4rem 0.9rem; border-radius: var(--pill); border: 1px solid var(--line);
}
.focus__skip:hover { color: var(--cream); border-color: var(--line); }

@keyframes focusPop { from { opacity: 0; transform: scale(0.4); } }
@keyframes wordIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes blink { 50% { opacity: 0; } }

/* ============================================================
   STAGE 3 — image-on-image onboarding
   ============================================================ */
.tour__panel[data-panel="onboarding"] { text-align: center; }

.phone {
  position: relative;
  width: min(88vw, 300px);
  aspect-ratio: 1 / 2;                /* match the screenshots so cover doesn't crop the sides */
  margin: 0 auto;
  padding: 10px 8px;                  /* slim bezel; inner ratio now ≈ the shot → clean fill */
  border-radius: 34px; overflow: hidden;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  box-shadow: 0 40px 80px -34px rgba(0,0,0,0.95), inset 0 1px 0 rgba(255,255,255,0.06);
}
/* inner screen — inset from the phone walls so the shot doesn't touch the edges.
   Hotspots + docked avatar are % positioned against THIS box, so they stay aligned. */
.phone__inner {
  position: relative;
  width: 100%; height: 100%;
  border-radius: 20px; overflow: hidden;
  background: #0c080a;
}
.phone__screen { width: 100%; height: 100%; object-fit: cover; display: block; }

/* the docked avatar — sits at its real spot on the app image (% positioned) */
.phone__avatar {
  position: absolute;
  left: var(--x, 82%); top: var(--y, 88%);
  width: var(--size, 18%); aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%; object-fit: cover;
  border: 2px solid rgba(255,138,91,0.7);
  box-shadow: 0 8px 20px -6px rgba(0,0,0,0.8), 0 0 0 5px rgba(255,138,91,0.14);
  z-index: 4;
}
.phone__avatar[hidden] { display: none; }
.phone__avatar.dock { animation: dockIn 0.75s var(--ease-out) both; }
@keyframes dockIn {
  from { transform: translate(-50%, -50%) scale(2.7); opacity: 0.35; }
  to   { transform: translate(-50%, -50%) scale(1);   opacity: 1; }
}

/* percentage hotspots ("Pressable" equivalents) */
.phone__hotspots { position: absolute; inset: 0; z-index: 3; }
.hotspot {
  position: absolute;
  left: var(--x); top: var(--y); width: var(--w); height: var(--h);
  border-radius: 12px;
  border: 1.5px dashed rgba(255,138,91,0.55);
  background: rgba(255,138,91,0.10);
  opacity: 0; animation: hotspotIn 0.4s var(--ease-out) forwards;
  animation-delay: var(--delay, 0.5s);
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.2s var(--ease);
}
.hotspot::after { /* pulsing dot marker */
  content: ""; position: absolute; top: 8px; right: 8px;
  width: 9px; height: 9px; border-radius: 50%; background: var(--peach);
  box-shadow: 0 0 0 0 rgba(255,138,91,0.6); animation: pulseDot 2s ease-out infinite;
}
.hotspot:hover, .hotspot:focus-visible {
  background: rgba(255,138,91,0.2); border-color: var(--peach); transform: scale(1.02);
}
@keyframes hotspotIn { to { opacity: 1; } }

.phone__hint { color: var(--muted); font-size: 0.9rem; margin-bottom: 1.2rem; }

.phone__tooltip {
  display: inline-block; margin-top: 0.8rem;
  padding: 0.6rem 1rem; border-radius: var(--radius);
  background: rgba(27,20,24,0.85); border: 1px solid rgba(255,138,91,0.4);
  font-size: 0.9rem; color: var(--cream);
  animation: focusPop 0.35s var(--ease-out) both;
}
.phone__tooltip[hidden] { display: none; }

/* ============================================================
   Mobile polish
   ============================================================ */
@media (max-width: 620px) {
  .tour { margin-top: clamp(2.6rem, 8vh, 4rem); }
  .tour__panel { overflow-x: clip; }          /* contain the swap animation */
  .slides { padding-left: 1rem; padding-right: 1rem; }
  .card-screen { width: min(78vw, 260px); }   /* one card centered, next peeking */
  .picker__prompt { margin-bottom: 1.1rem; }
  .avatar-pick { padding: 1rem 0.6rem; }
  .focus__bubble { max-width: min(88vw, 34ch); }
  .tour__back { margin-bottom: 1rem; }
}
@media (max-width: 380px) {
  .picker__grid { gap: 0.7rem; }
  .avatar-pick__tag { font-size: 0.72rem; }
}

/* ============================================================
   Reduced motion
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  .tour__panel.is-in, .tour__panel.is-out { animation: none !important; }
  .card-screen, .avatar-pick, .focus__avatar, .focus__bubble,
  .phone__avatar.dock, .hotspot, .focus__text .word {
    animation: none !important; transition: none !important; opacity: 1 !important;
    transform: none !important;
  }
  .phone__avatar.dock { transform: translate(-50%, -50%) !important; }
  .focus__caret { display: none; }
}
