/* =====================================================================
   Guided tour ("Take the tour") + welcome modal + toast + tooltips.
   Reusable, framework-free. Matches the site tokens (teal/sky, Bricolage
   display font). Everything degrades: without JS nothing renders.
   z-index sits above the sticky header (~50).
   ===================================================================== */

/* ---------- shared ---------- */
.rtour, .rtour-welcome, .rtour-toasts { --rt-dim: rgba(15, 23, 42, .62); }
.rtour *, .rtour-welcome * { box-sizing: border-box; }

/* ---------- spotlight overlay ---------- */
.rtour { position: fixed; inset: 0; z-index: 9000; }
.rtour__catch { position: fixed; inset: 0; background: transparent; cursor: default; }
.rtour__spot {
    position: fixed; top: 0; left: 0; width: 0; height: 0;
    border-radius: var(--r-lg, 14px);
    box-shadow: 0 0 0 9999px var(--rt-dim), 0 0 0 2px var(--teal, #0369a1), 0 0 22px 2px color-mix(in srgb, var(--sky, #38bdf8) 60%, transparent);
    pointer-events: none;
    transition: top .38s var(--ease, cubic-bezier(.2,.6,.2,1)), left .38s var(--ease), width .38s var(--ease), height .38s var(--ease), box-shadow .38s var(--ease);
}
.rtour__spot::after {
    content: ""; position: absolute; inset: -3px; border-radius: inherit;
    border: 2px solid color-mix(in srgb, var(--sky, #38bdf8) 85%, transparent);
    animation: rt-pulse 1.8s var(--ease, ease) infinite;
}
@keyframes rt-pulse { 0%, 100% { opacity: .9; transform: scale(1); } 50% { opacity: .35; transform: scale(1.015); } }

/* ---------- tour card ---------- */
.rtour__card {
    position: fixed; top: 0; left: 0; width: min(92vw, 360px);
    display: flex; flex-direction: column; gap: 12px;
    background: var(--surface, #fff); color: var(--ink, #0f172a);
    border: 1px solid var(--line-2, #bfdcec); border-radius: var(--r-lg, 14px);
    box-shadow: 0 24px 60px rgba(15, 23, 42, .28), 0 4px 14px rgba(15, 23, 42, .12);
    padding: 16px 16px 14px; pointer-events: auto;
    opacity: 0; transform: translateY(8px) scale(.98);
    transition: top .34s var(--ease), left .34s var(--ease), opacity .26s var(--ease), transform .26s var(--ease);
}
.rtour__card.is-in { opacity: 1; transform: none; }

.rtour__head { display: flex; align-items: center; gap: 11px; }
.rtour__ic {
    flex: 0 0 auto; width: 40px; height: 40px; border-radius: 11px;
    display: grid; place-items: center; color: #fff;
    background: linear-gradient(135deg, var(--rt-accent, var(--teal, #0369a1)) 0%, color-mix(in srgb, var(--rt-accent, var(--sky, #38bdf8)) 55%, var(--sky, #38bdf8)) 100%);
    box-shadow: 0 4px 12px color-mix(in srgb, var(--rt-accent, var(--teal, #0369a1)) 32%, transparent);
    animation: rt-pop .4s var(--ease, ease) both;
}
.rtour__ic .ico { width: 21px; height: 21px; }
@keyframes rt-pop { from { opacity: 0; transform: scale(.6) rotate(-8deg); } to { opacity: 1; transform: none; } }
.rtour__meta { min-width: 0; }
.rtour__count { font: 700 .7rem/1 var(--mono, monospace); letter-spacing: .08em; text-transform: uppercase; color: var(--muted, #64748b); }
.rtour__title { margin: 3px 0 0; font-family: var(--font-display, sans-serif); font-weight: 700; font-size: 1.06rem; line-height: 1.15; color: var(--ink, #0f172a); }
.rtour__text { margin: 0; font-size: .92rem; line-height: 1.5; color: var(--ink-2, #475569); }

.rtour__dots { display: flex; gap: 6px; margin: 2px 0 0; }
.rtour__dot { width: 7px; height: 7px; border-radius: 50%; background: var(--line-2, #bfdcec); transition: background .25s var(--ease), transform .25s var(--ease); }
.rtour__dot.is-active { background: var(--teal, #0369a1); transform: scale(1.35); }
.rtour__dot.is-done { background: color-mix(in srgb, var(--teal, #0369a1) 55%, transparent); }

.rtour__foot { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.rtour__skip { margin-right: auto; background: none; border: 0; padding: 6px 2px; font: inherit; font-size: .84rem; font-weight: 600; color: var(--muted, #64748b); cursor: pointer; border-radius: 6px; }
.rtour__skip:hover { color: var(--ink-2, #475569); text-decoration: underline; }
.rtour__btn {
    font: inherit; font-weight: 650; font-size: .88rem; cursor: pointer;
    padding: 9px 15px; border-radius: 9px; border: 1px solid var(--line-2, #bfdcec);
    background: var(--surface, #fff); color: var(--ink, #0f172a);
    display: inline-flex; align-items: center; gap: 6px;
    transition: transform .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease), border-color .15s var(--ease);
}
.rtour__btn:hover { background: var(--surface-2, #eaf6fd); border-color: var(--teal-tint-2, #bae6fd); }
.rtour__btn:active { transform: translateY(1px); }
.rtour__btn--primary { background: linear-gradient(135deg, var(--teal, #0369a1), var(--teal-600, #0284c7)); border-color: transparent; color: #fff; box-shadow: 0 6px 16px color-mix(in srgb, var(--teal, #0369a1) 30%, transparent); }
.rtour__btn--primary:hover { background: linear-gradient(135deg, var(--teal, #0369a1), var(--teal-600, #0284c7)); color: #fff; transform: translateY(-1px); box-shadow: 0 10px 22px color-mix(in srgb, var(--teal, #0369a1) 36%, transparent); }
.rtour__btn .ico { width: 15px; height: 15px; }
.rtour__btn:focus-visible, .rtour__skip:focus-visible { outline: 2px solid var(--teal, #0369a1); outline-offset: 2px; }
.rtour__btn[hidden] { display: none; }

/* little arrow pointing at the spot */
.rtour__arrow { position: absolute; width: 14px; height: 14px; background: var(--surface, #fff); border: 1px solid var(--line-2, #bfdcec); transform: rotate(45deg); }
.rtour__card[data-place="bottom"] .rtour__arrow { top: -8px; border-right: 0; border-bottom: 0; }
.rtour__card[data-place="top"]    .rtour__arrow { bottom: -8px; border-left: 0; border-top: 0; }
.rtour__card[data-place="right"]  .rtour__arrow { left: -8px; border-top: 0; border-right: 0; }
.rtour__card[data-place="left"]   .rtour__arrow { right: -8px; border-bottom: 0; border-left: 0; }
.rtour__card[data-place="center"] .rtour__arrow { display: none; }

/* ---------- welcome modal (advanced alert popup) ---------- */
.rtour-welcome { position: fixed; inset: 0; z-index: 9100; display: grid; place-items: center; padding: 18px; }
.rtour-welcome__scrim { position: absolute; inset: 0; background: var(--rt-dim); backdrop-filter: blur(3px); opacity: 0; transition: opacity .3s var(--ease); }
.rtour-welcome.is-in .rtour-welcome__scrim { opacity: 1; }
.rtour-welcome__box {
    position: relative; width: min(94vw, 420px); text-align: center;
    background: var(--surface, #fff); border: 1px solid var(--line-2, #bfdcec);
    border-radius: var(--r-xl, 20px); padding: 28px 24px 22px;
    box-shadow: 0 30px 70px rgba(15, 23, 42, .35);
    overflow: hidden; opacity: 0; transform: translateY(14px) scale(.96);
    transition: opacity .32s var(--ease), transform .32s var(--ease);
}
.rtour-welcome.is-in .rtour-welcome__box { opacity: 1; transform: none; }
.rtour-welcome__box::before { content: ""; position: absolute; inset: -40% -20% auto -20%; height: 220px; background: radial-gradient(60% 100% at 50% 0, color-mix(in srgb, var(--sky, #38bdf8) 30%, transparent), transparent 70%); pointer-events: none; }
.rtour-welcome__ic {
    position: relative; width: 62px; height: 62px; margin: 0 auto 14px; border-radius: 18px;
    display: grid; place-items: center; color: #fff;
    background: linear-gradient(135deg, var(--teal, #0369a1), var(--sky, #38bdf8));
    box-shadow: 0 10px 26px color-mix(in srgb, var(--teal, #0369a1) 38%, transparent);
    animation: rt-float 3.4s var(--ease, ease) infinite alternate;
}
.rtour-welcome__ic .ico { width: 30px; height: 30px; }
@keyframes rt-float { from { transform: translateY(0); } to { transform: translateY(-7px); } }
.rtour-welcome__title { position: relative; margin: 0 0 6px; font-family: var(--font-display, sans-serif); font-size: 1.42rem; font-weight: 800; letter-spacing: -.02em; }
.rtour-welcome__text { position: relative; margin: 0 auto 20px; max-width: 34ch; color: var(--ink-2, #475569); font-size: .96rem; line-height: 1.55; }
.rtour-welcome__btns { position: relative; display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.rtour-welcome__btns .btn { min-width: 132px; }

/* ---------- toast ("advanced alert") ---------- */
.rtour-toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 9200; display: flex; flex-direction: column; gap: 10px; align-items: center; pointer-events: none; width: max-content; max-width: 92vw; }
.rtour-toast {
    pointer-events: auto; display: flex; align-items: center; gap: 11px;
    padding: 12px 16px; border-radius: 13px; background: var(--ink, #0f172a); color: #fff;
    box-shadow: 0 16px 40px rgba(15, 23, 42, .3); font-size: .9rem; font-weight: 550;
    opacity: 0; transform: translateY(16px) scale(.96);
    transition: opacity .3s var(--ease), transform .3s var(--ease);
}
.rtour-toast.is-in { opacity: 1; transform: none; }
.rtour-toast__ic { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: color-mix(in srgb, var(--rt-accent, var(--teal, #0369a1)) 85%, #000); }
.rtour-toast__ic .ico { width: 17px; height: 17px; color: #fff; }
.rtour-toast__x { margin-left: 4px; background: none; border: 0; color: color-mix(in srgb, #fff 70%, transparent); cursor: pointer; padding: 4px; border-radius: 6px; display: inline-flex; }
.rtour-toast__x:hover { color: #fff; background: rgba(255, 255, 255, .12); }
.rtour-toast__x .ico { width: 15px; height: 15px; }
.rtour-toast a { color: var(--sky, #7dd3fc); font-weight: 650; }

/* ---------- hover tooltips (data-tip) ---------- */
.rt-tip {
    position: fixed; z-index: 9300; pointer-events: none; max-width: 240px;
    padding: 7px 11px; border-radius: 9px; font-size: .82rem; font-weight: 550; line-height: 1.35;
    background: var(--ink, #0f172a); color: #fff; box-shadow: 0 10px 26px rgba(15, 23, 42, .28);
    opacity: 0; transform: translateY(4px); transition: opacity .18s var(--ease), transform .18s var(--ease);
}
.rt-tip.is-in { opacity: 1; transform: none; }
.rt-tip::after { content: ""; position: absolute; left: 50%; bottom: -5px; width: 10px; height: 10px; background: inherit; transform: translateX(-50%) rotate(45deg); }
.rt-tip[data-pos="below"]::after { bottom: auto; top: -5px; }

/* footer "Take the tour" trigger */
.rtour-trigger { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; background: none; border: 0; font: inherit; }
.rtour-trigger .ico { width: 15px; height: 15px; color: var(--teal, #0369a1); }

/* ---------- RTL ---------- */
[dir="rtl"] .rtour__skip { margin-right: 0; margin-left: auto; }
[dir="rtl"] .rtour-toasts { }

/* ---------- reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    .rtour__spot, .rtour__card, .rtour-welcome__scrim, .rtour-welcome__box, .rtour-toast, .rt-tip { transition: opacity .01ms linear !important; }
    .rtour__spot::after, .rtour-welcome__ic, .rtour__ic { animation: none !important; }
    .rtour__card { transform: none !important; }
}

/* ---------- small screens ---------- */
@media (max-width: 420px) {
    .rtour__card { width: calc(100vw - 16px); left: 8px !important; right: 8px; }
    .rtour__card[data-place] .rtour__arrow { display: none; }
}
