/* ============================================================
   Afterx — Guided Tour overlay
   Self-contained, injected by public/js/tour.js. Every rule is
   scoped under .ax-tour and every class is prefixed .axt- so it
   never collides with the site stylesheet. Colors come from the
   site theme tokens (--background / --foreground / --hero-sub)
   and the brand gradient, so the tour follows the same day/night
   theme as the rest of afterx (html[data-theme="light"]).
   ============================================================ */

/* ---- theme tokens (dark is the base, like the site) ---- */
.ax-tour{
  --t-ink:hsl(var(--foreground));
  --t-muted:hsl(var(--hero-sub));
  --t-faint:hsl(var(--hero-sub)/.72);
  --t-surface:#140f28;
  --t-s2:#1c1540;
  --t-line:rgba(255,255,255,.12);
  --t-line2:rgba(255,255,255,.22);
  --t-scrim:rgba(5,2,14,.72);
  --t-panel:rgba(16,11,34,.88);
  --t-panel-brd:rgba(255,255,255,.1);
  --t-card:rgba(255,255,255,.045);
  --grad:linear-gradient(to left,#6366f1,#a855f7,#fcd34d);
  --accent:#818cf8;            /* set per-slide by tour.js */
}
html[data-theme="light"] .ax-tour{
  --t-surface:#ffffff;
  --t-s2:#f3f1fc;
  --t-line:rgba(40,25,90,.12);
  --t-line2:rgba(40,25,90,.2);
  --t-scrim:rgba(246,245,253,.8);
  --t-panel:#ffffff;
  --t-panel-brd:rgba(40,25,90,.1);
  --t-card:#ffffff;
  --grad:linear-gradient(to left,#4f46e5,#9333ea,#d97706);
  --accent:#6d28d9;
}

/* ---- overlay ---- */
.ax-tour{
  position:fixed;inset:0;z-index:2147483200;  /* above the chat widget (z 2147483000) */
  display:flex;align-items:center;justify-content:center;
  padding:max(14px,env(safe-area-inset-top,0px)) max(14px,env(safe-area-inset-right,0px)) max(14px,env(safe-area-inset-bottom,0px)) max(14px,env(safe-area-inset-left,0px));
  background:var(--t-scrim);
  -webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);
  opacity:0;visibility:hidden;transition:opacity .35s ease,visibility .35s ease;
  direction:rtl;
}
.ax-tour.is-open{opacity:1;visibility:visible}
body.axt-lock{overflow:hidden}

/* ---- panel ---- */
.axt-panel{
  position:relative;width:100%;max-width:1060px;
  height:min(90vh,680px);max-height:92vh;      /* explicit height so the absolutely-positioned slides get a stage to fill */
  display:flex;flex-direction:column;
  background:var(--t-panel);
  border:1px solid var(--t-panel-brd);
  border-radius:24px;
  box-shadow:0 40px 90px -40px rgba(0,0,0,.65),0 10px 30px -14px rgba(0,0,0,.4);
  -webkit-backdrop-filter:blur(14px);backdrop-filter:blur(14px);
  overflow:hidden;
  transform:translateY(18px) scale(.985);transition:transform .4s cubic-bezier(.2,.75,.25,1);
}
.ax-tour.is-open .axt-panel{transform:none}
.axt-panel *{box-sizing:border-box}

/* ---- header ---- */
.axt-head{flex:0 0 auto;display:flex;align-items:center;justify-content:space-between;gap:12px;
  padding:16px clamp(16px,3vw,26px) 8px}
.axt-brand{display:flex;align-items:center;gap:9px;font-weight:600;font-size:17px;letter-spacing:-.01em}
.axt-brand .axt-mark{width:30px;height:30px;flex:none;border-radius:9px;display:grid;place-items:center;
  background:var(--grad)}
.axt-brand .axt-mark svg{width:17px;height:17px}
.axt-brand .axt-word{direction:ltr}
.axt-brand .axt-word b{background:var(--grad);-webkit-background-clip:text;background-clip:text;-webkit-text-fill-color:transparent;color:transparent}
.axt-headmeta{display:flex;align-items:center;gap:12px}
.axt-counter{font-weight:600;color:var(--t-muted);font-size:14px;font-variant-numeric:tabular-nums;white-space:nowrap}
.axt-counter .axt-cur{color:var(--accent)}
.axt-close{width:34px;height:34px;flex:none;border-radius:999px;display:grid;place-items:center;
  color:var(--t-muted);background:var(--t-card);border:1px solid var(--t-line);
  transition:color .2s,background .2s,transform .2s}
.axt-close:hover{color:var(--t-ink);transform:rotate(90deg)}
.axt-close svg{width:16px;height:16px;stroke:currentColor;stroke-width:2.2;fill:none;stroke-linecap:round}

/* ---- stage ---- */
.axt-stage{position:relative;flex:1 1 auto;min-height:0}
.axt-slide{position:absolute;inset:0;overflow-y:auto;overflow-x:hidden;
  opacity:0;visibility:hidden;transform:translateY(14px) scale(.99);
  transition:opacity .5s ease,transform .5s cubic-bezier(.2,.7,.2,1),visibility .5s;
  pointer-events:none;
  padding:6px clamp(16px,3vw,30px) 14px}
.axt-slide.is-active{opacity:1;visibility:visible;transform:none;pointer-events:auto}
.axt-inner{min-height:100%;display:grid;grid-template-columns:1fr 1.02fr;gap:clamp(18px,3.4vw,46px);align-items:center}

/* figure side */
.axt-fig{position:relative;width:100%;max-width:400px;margin-inline:auto;aspect-ratio:1/1}
.axt-fig svg{width:100%;height:100%;display:block;overflow:visible}

/* text side — editorial treatment: tracked label → big display title → muted lead → emphasized statement */
.axt-copy{max-width:34ch}
.axt-eyebrow{display:inline-flex;align-items:center;gap:10px;font-size:12.5px;font-weight:600;
  letter-spacing:.16em;color:var(--accent)}
.axt-eyebrow::before{content:"";width:26px;height:2px;border-radius:2px;background:var(--grad)}
.axt-h1{font-size:clamp(26px,4vw,42px);line-height:1.18;font-weight:800;margin:16px 0 0;
  letter-spacing:-.005em;text-wrap:balance}
.axt-lead{margin:14px 0 0;color:var(--t-muted);font-size:clamp(14.5px,2vw,16.5px);line-height:1.75;font-weight:400}
.axt-say{position:relative;margin:16px 0 0;padding-inline-start:16px;color:var(--t-ink);
  font-size:clamp(17px,2.6vw,22px);line-height:1.5;font-weight:600;text-wrap:balance}
.axt-say::before{content:"";position:absolute;inset-inline-start:0;top:5px;bottom:5px;width:3.5px;border-radius:999px;background:var(--grad)}
.axt-note{margin-top:18px;display:flex;gap:8px;align-items:flex-start;font-size:13px;color:var(--t-faint);line-height:1.7}
.axt-note svg{flex:none;width:16px;height:16px;margin-top:3px;stroke:var(--t-faint);fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.axt-points{display:flex;flex-wrap:wrap;gap:8px;margin-top:18px}
.axt-tag{font-size:12.5px;font-weight:600;color:var(--accent);
  background:color-mix(in srgb,var(--accent) 12%,transparent);
  border:1px solid color-mix(in srgb,var(--accent) 30%,transparent);
  padding:6px 12px;border-radius:999px}

/* reveal stagger */
.axt-rv{opacity:0;transform:translateY(12px)}
.axt-slide.is-active .axt-rv{animation:axt-rv .65s cubic-bezier(.2,.75,.25,1) forwards;animation-delay:calc(var(--d,0)*90ms + 120ms)}
@keyframes axt-rv{to{opacity:1;transform:none}}

/* CTA */
.axt-cta{display:flex;flex-wrap:wrap;gap:11px;margin-top:22px}
.axt-btn{appearance:none;border:0;cursor:pointer;font-family:inherit;font-weight:600;font-size:15px;
  padding:13px 24px;border-radius:13px;transition:transform .18s ease,box-shadow .25s ease,background .25s}
.axt-btn:active{transform:translateY(1px) scale(.99)}
.axt-btn-primary{color:#fff;background:var(--grad);box-shadow:0 14px 30px -14px rgba(124,58,237,.6)}
.axt-btn-primary:hover{transform:translateY(-2px);filter:brightness(1.05)}
.axt-btn-ghost{color:var(--t-ink);background:var(--t-card);border:1.5px solid var(--t-line2)}
.axt-btn-ghost:hover{border-color:var(--accent);color:var(--accent)}

/* footer nav */
.axt-nav{flex:0 0 auto;display:flex;align-items:center;justify-content:space-between;gap:12px;
  padding:10px clamp(16px,3vw,26px) 16px}
.axt-navbtn{display:inline-flex;align-items:center;gap:7px;cursor:pointer;font-family:inherit;
  border:1.5px solid var(--t-line2);background:var(--t-card);color:var(--t-ink);
  font-weight:600;font-size:14.5px;padding:10px 17px;border-radius:12px;
  transition:border-color .2s,color .2s,background .2s,opacity .2s,transform .18s}
.axt-navbtn:hover{border-color:var(--accent);color:var(--accent)}
.axt-navbtn:active{transform:translateY(1px)}
.axt-navbtn[disabled]{opacity:0;pointer-events:none}
.axt-navbtn svg{width:17px;height:17px;stroke:currentColor;fill:none;stroke-width:2.4;stroke-linecap:round;stroke-linejoin:round}
.axt-next{background:var(--grad);color:#fff;border-color:transparent}
.axt-next:hover{color:#fff;filter:brightness(1.05)}
.axt-dots{display:flex;gap:8px;align-items:center}
.axt-dot{width:8px;height:8px;border-radius:50%;background:var(--t-line2);border:0;padding:0;cursor:pointer;transition:all .3s}
.axt-dot.is-active{background:var(--accent);width:24px;border-radius:999px}

/* reopen pill */
/* the fab lives OUTSIDE .ax-tour (on <body>), so it can't read the tour's --grad token:
   give it its own solid indigo→purple gradient (white text stays readable in both themes). */
.axt-fab{position:fixed;z-index:9000;inset-block-end:max(18px,env(safe-area-inset-bottom,0px));
  inset-inline-start:max(18px,env(safe-area-inset-left,0px));
  display:inline-flex;align-items:center;gap:8px;cursor:pointer;font-family:inherit;font-weight:700;font-size:14px;
  color:#fff;background:linear-gradient(135deg,#6366f1,#a855f7);border:0;padding:12px 18px;border-radius:999px;
  box-shadow:0 10px 26px -8px rgba(99,70,230,.7),0 2px 6px rgba(0,0,0,.25);
  transform:translateY(0);transition:transform .2s ease,box-shadow .25s ease,filter .2s ease;direction:rtl}
.axt-fab:hover{transform:translateY(-2px);filter:brightness(1.07);box-shadow:0 16px 34px -10px rgba(99,70,230,.75),0 2px 6px rgba(0,0,0,.25)}
.axt-fab svg{width:17px;height:17px;fill:#fff}
html[data-theme="light"] .axt-fab{background:linear-gradient(135deg,#4f46e5,#9333ea);
  box-shadow:0 10px 26px -8px rgba(79,70,229,.5),0 1px 3px rgba(40,25,90,.25)}

/* ============================================================
   Figure animations — only run while the slide is active
   ============================================================ */
.ax-tour .axt-card{fill:var(--t-surface);stroke:var(--t-line2);stroke-width:2}
.ax-tour .axt-scr{fill:var(--t-s2)}
.ax-tour .ac{fill:var(--accent)}
.ax-tour .acs{stroke:var(--accent)}

/* S1 camera */
.ax-tour .grid-l{stroke:var(--accent);stroke-width:1.6;opacity:.45;stroke-dasharray:160;stroke-dashoffset:160}
.axt-slide.is-active .grid-l{animation:axt-dash 1s ease forwards .3s}
@keyframes axt-dash{to{stroke-dashoffset:0}}
.ax-tour .brk{stroke:var(--accent);stroke-width:4;fill:none;stroke-linecap:round;opacity:0}
.axt-slide.is-active .brk1{animation:axt-brk1 1.1s cubic-bezier(.3,1.3,.4,1) forwards .5s}
.axt-slide.is-active .brk2{animation:axt-brk2 1.1s cubic-bezier(.3,1.3,.4,1) forwards .5s}
.axt-slide.is-active .brk3{animation:axt-brk3 1.1s cubic-bezier(.3,1.3,.4,1) forwards .5s}
.axt-slide.is-active .brk4{animation:axt-brk4 1.1s cubic-bezier(.3,1.3,.4,1) forwards .5s}
@keyframes axt-brk1{from{opacity:0;transform:translate(-14px,-14px)}to{opacity:1;transform:none}}
@keyframes axt-brk2{from{opacity:0;transform:translate(14px,-14px)}to{opacity:1;transform:none}}
@keyframes axt-brk3{from{opacity:0;transform:translate(-14px,14px)}to{opacity:1;transform:none}}
@keyframes axt-brk4{from{opacity:0;transform:translate(14px,14px)}to{opacity:1;transform:none}}
.ax-tour .reticle{transform-origin:200px 215px}
.axt-slide.is-active .reticle{animation:axt-retic 2.6s ease-in-out infinite 1.4s}
@keyframes axt-retic{0%,100%{transform:scale(1);opacity:.9}50%{transform:scale(.8);opacity:1}}
.ax-tour .flash{opacity:0;transform-origin:200px 215px}
.axt-slide.is-active .flash{animation:axt-flash 3.4s ease-out infinite 1.6s}
@keyframes axt-flash{0%{opacity:0;transform:scale(.3)}8%{opacity:.5}26%{opacity:0;transform:scale(1.5)}100%{opacity:0}}
.ax-tour .ok{opacity:0;stroke-dasharray:40;stroke-dashoffset:40}
.axt-slide.is-active .ok{animation:axt-okin .6s ease forwards 1.5s,axt-okdash .6s ease forwards 1.5s}
@keyframes axt-okin{to{opacity:1}}
@keyframes axt-okdash{to{stroke-dashoffset:0}}

/* S2 archive gather */
.ax-tour .ph{transform-origin:center}
.axt-slide.is-active .p1{animation:axt-g1 5s ease-in-out infinite}
.axt-slide.is-active .p2{animation:axt-g2 5s ease-in-out infinite}
.axt-slide.is-active .p3{animation:axt-g3 5s ease-in-out infinite}
.axt-slide.is-active .p4{animation:axt-g4 5s ease-in-out infinite}
.axt-slide.is-active .p5{animation:axt-g5 5s ease-in-out infinite}
.axt-slide.is-active .p6{animation:axt-g6 5s ease-in-out infinite}
@keyframes axt-g1{0%,12%{transform:translate(-120px,-80px) rotate(-18deg);opacity:0}30%,72%{transform:none;opacity:1}92%,100%{transform:translate(-120px,-80px) rotate(-18deg);opacity:0}}
@keyframes axt-g2{0%,12%{transform:translate(130px,-60px) rotate(16deg);opacity:0}32%,72%{transform:none;opacity:1}92%,100%{transform:translate(130px,-60px) rotate(16deg);opacity:0}}
@keyframes axt-g3{0%,12%{transform:translate(-140px,70px) rotate(12deg);opacity:0}34%,72%{transform:none;opacity:1}92%,100%{transform:translate(-140px,70px) rotate(12deg);opacity:0}}
@keyframes axt-g4{0%,12%{transform:translate(140px,90px) rotate(-14deg);opacity:0}36%,72%{transform:none;opacity:1}92%,100%{transform:translate(140px,90px) rotate(-14deg);opacity:0}}
@keyframes axt-g5{0%,12%{transform:translate(10px,-130px) rotate(22deg);opacity:0}38%,72%{transform:none;opacity:1}92%,100%{transform:translate(10px,-130px) rotate(22deg);opacity:0}}
@keyframes axt-g6{0%,12%{transform:translate(-10px,140px) rotate(-20deg);opacity:0}40%,72%{transform:none;opacity:1}92%,100%{transform:translate(-10px,140px) rotate(-20deg);opacity:0}}
.ax-tour .scan{opacity:0}
.axt-slide.is-active .scan{animation:axt-scan 5s ease-in-out infinite}
@keyframes axt-scan{0%,44%{opacity:0;transform:translateY(-14px)}52%{opacity:1}66%{opacity:1;transform:translateY(0)}74%,100%{opacity:0}}

/* S3 before/after sweep */
.axt-slide.is-active .afterlayer{animation:axt-sweep 6s ease-in-out infinite}
@keyframes axt-sweep{0%,100%{clip-path:inset(0 100% 0 0)}42%,58%{clip-path:inset(0 0 0 0)}}
.ax-tour .handle{transform:translateX(130px)}
.axt-slide.is-active .handle{animation:axt-handle 6s ease-in-out infinite}
@keyframes axt-handle{0%,100%{transform:translateX(130px)}42%,58%{transform:translateX(-130px)}}
.ax-tour .spk{transform-origin:center;opacity:0}
.axt-slide.is-active .spk{animation:axt-spk 6s ease-in-out infinite}
@keyframes axt-spk{0%,40%{opacity:0;transform:scale(0)}50%{opacity:1;transform:scale(1)}66%{opacity:1}76%,100%{opacity:0;transform:scale(.4)}}

/* S4 content fan */
.ax-tour .fan{transform-origin:200px 215px;opacity:0}
.axt-slide.is-active .f1{animation:axt-f1 4.4s ease-in-out infinite}
.axt-slide.is-active .f2{animation:axt-f2 4.4s ease-in-out infinite}
.axt-slide.is-active .f3{animation:axt-f3 4.4s ease-in-out infinite}
@keyframes axt-f1{0%,14%{opacity:0;transform:none}34%,80%{opacity:1;transform:translate(-118px,-14px) rotate(-9deg)}94%,100%{opacity:0;transform:none}}
@keyframes axt-f2{0%,18%{opacity:0;transform:none}40%,80%{opacity:1;transform:translate(0,-26px)}94%,100%{opacity:0;transform:none}}
@keyframes axt-f3{0%,22%{opacity:0;transform:none}46%,80%{opacity:1;transform:translate(118px,-14px) rotate(9deg)}94%,100%{opacity:0;transform:none}}
.ax-tour .play{transform-origin:center}
.axt-slide.is-active .play{animation:axt-play 2s ease-in-out infinite}
@keyframes axt-play{0%,100%{transform:scale(1)}50%{transform:scale(1.14)}}
.ax-tour .prog{stroke-dasharray:70;stroke-dashoffset:70}
.axt-slide.is-active .prog{animation:axt-prog 3s linear infinite 1.4s}
@keyframes axt-prog{to{stroke-dashoffset:0}}
.ax-tour .sprk{transform-origin:center;opacity:0}
.axt-slide.is-active .sprk{animation:axt-sprk 4.4s ease-in-out infinite}
@keyframes axt-sprk{0%,50%{opacity:0;transform:scale(0) rotate(0)}66%{opacity:1;transform:scale(1) rotate(45deg)}82%,100%{opacity:0;transform:scale(.3) rotate(90deg)}}

/* S5 CTA orbit */
.ax-tour .orbit{transform-origin:200px 200px}
.axt-slide.is-active .orbit{animation:axt-orbit 18s linear infinite}
@keyframes axt-orbit{to{transform:rotate(360deg)}}
.ax-tour .chip{transform-origin:center}
.axt-slide.is-active .chip{animation:axt-chip 18s linear infinite}
@keyframes axt-chip{to{transform:rotate(-360deg)}}
.ax-tour .pulse,.ax-tour .pulse2{transform-origin:200px 200px;opacity:0}
.axt-slide.is-active .pulse{animation:axt-pulse 3s ease-out infinite}
.axt-slide.is-active .pulse2{animation:axt-pulse 3s ease-out infinite 1.5s}
@keyframes axt-pulse{0%{transform:scale(.7);opacity:.5}100%{transform:scale(1.6);opacity:0}}
.ax-tour .corelogo{transform-origin:200px 200px}
.axt-slide.is-active .corelogo{animation:axt-breathe 3s ease-in-out infinite}
@keyframes axt-breathe{0%,100%{transform:scale(1)}50%{transform:scale(1.06)}}

/* ---- responsive ---- */
@media (max-width:720px){
  /* mobile = hero layout: the motion fills the slide large, the typography sits over it with a scrim */
  .ax-tour{padding:max(10px,env(safe-area-inset-top,0px)) max(10px,env(safe-area-inset-right,0px)) max(10px,env(safe-area-inset-bottom,0px)) max(10px,env(safe-area-inset-left,0px))}
  .axt-panel{height:min(90vh,640px);max-height:94vh;border-radius:20px}  /* explicit height: absolute slides need a stage to fill */
  .axt-head{padding:12px 16px 4px}
  .axt-stage{flex:1 1 auto}
  .axt-slide{padding:0}
  /* fixed two-zone layout so the frame height never changes between slides, whatever the text length */
  .axt-inner{display:block;position:relative;height:100%}
  .axt-fig{position:absolute;top:0;left:50%;transform:translateX(-50%);
    width:auto;height:46%;max-height:none;max-width:72vw;margin:0;z-index:0;pointer-events:none}
  .axt-copy{position:absolute;left:0;right:0;bottom:0;height:56%;z-index:1;max-width:100%;overflow-y:auto;
    display:flex;flex-direction:column;justify-content:center;padding:14px 20px 16px;
    background:linear-gradient(to top,var(--t-panel) 64%,color-mix(in srgb,var(--t-panel) 80%,transparent) 82%,transparent)}
  .axt-eyebrow{font-size:12px}
  .axt-h1{font-size:clamp(21px,6vw,27px);line-height:1.22;margin:0 0 0}
  .axt-lead{margin-top:7px;font-size:14px;line-height:1.6}
  .axt-say{margin-top:11px;padding-inline-start:13px;font-size:16px;line-height:1.5}
  .axt-note{margin-top:10px;font-size:12px;line-height:1.55}
  .axt-points{margin-top:12px;gap:6px}
  .axt-tag{font-size:11.5px;padding:5px 10px}
  .axt-cta{margin-top:16px;gap:9px}
  .axt-btn{padding:12px 20px;font-size:14.5px}
  .axt-nav{padding:8px 16px 12px}
  .axt-navbtn{padding:9px 13px;font-size:13px}
}
@media (max-width:400px){
  .axt-navbtn .axt-opt{display:none}
}
/* very short screens (landscape phones): pull the motion in so text still fits */
@media (max-width:720px) and (max-height:520px){
  .axt-fig{height:40%}
  .axt-copy{height:62%}
  .axt-say{font-size:15px}
}
@media (prefers-reduced-motion: reduce){
  .ax-tour *,.ax-tour *::before{animation:none!important;transition:opacity .2s ease!important}
  .axt-rv{opacity:1!important;transform:none!important}
  .grid-l{stroke-dashoffset:0}
  .brk,.ok{opacity:1}
  .ph,.fan,.sprk,.spk,.scan{opacity:1!important}
  .afterlayer{clip-path:inset(0 0 0 50%)}
  .prog{stroke-dashoffset:0}
  .ax-tour.is-open .axt-panel{transform:none}
}
