/* Baron Forms - Welcome Tour styles
 * Live-DOM spotlight + tooltip card. The visual-emphasis story is:
 *   1. Backdrop dims the page (rgba 0.78) so nothing competes with the highlighted area.
 *   2. The "spotlight" is a transparent rect sized to the target's bounding box. Its visual edge
 *      is created by an outset box-shadow — the shadow IS the dim layer, leaving the rect itself
 *      as a clear cutout. We get a soft glow inside via inset shadow + a subtle outline.
 *   3. On step change the spotlight smoothly transitions (top/left/width/height all animated),
 *      then plays a scale 0.94 → 1.0 pulse so the eye is pulled toward the new region.
 *   4. The tooltip card slides in from the spotlight edge with an arrow pointing back at it.
 *
 * Dark-mode aware via the project's existing CSS custom properties (--bg-card / --text / --border).
 */

/* Lock body scroll while a tour is active so the spotlight doesn't drift away from its target. */
/* During a tour, allow body scroll so a tall card on a small viewport doesn't get
 * clipped — better to scroll the page than to show an internal scrollbar inside the card. */
body.bf-tour-on { overflow: auto; }

/* ---------- Backdrop ---------- */
.bf-tour-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100000;
    pointer-events: auto;
    /* Hidden by default — fades in on .bf-tour-backdrop-on */
    opacity: 0;
    transition: opacity 280ms ease-out;
    /* Dim the page when there is no spotlight (hero step) by giving the backdrop itself a tint.
     * When a spotlight exists the box-shadow trick on .bf-tour-spot dims everything; the
     * backdrop stays transparent so we don't double up. */
    background: transparent;
}
.bf-tour-backdrop-on   { opacity: 1; }
.bf-tour-backdrop-full { background: rgba(15, 23, 42, 0.86); }

/* Overview mode — barely-there tint so the page below stays legible. The card itself is the
 * only thing the eye should snap to; the dashboard/admin context behind needs to be visible. */
.bf-tour-backdrop-overview { background: rgba(15, 23, 42, 0.18); }

/* ---------- Spotlight (the cutout that highlights one element) ---------- */
.bf-tour-spot {
    position: absolute;
    border-radius: 10px;
    pointer-events: none;          /* let clicks fall through to the highlighted element */
    opacity: 0;
    /* The dim layer IS this shadow. Inset glow + a thin outline give a soft halo. */
    /* The 9999px outset is the dim layer. Two stacked rgba(0,0,0) shadows (instead of one
     * navy at 0.78) give a noticeably darker page so the spotlight really pops. The white
     * outline + indigo glow form the "highlight ring" that pulls the eye in. */
    box-shadow:
        0 0 0 9999px rgba(0, 0, 0, 0.62),
        0 0 0 9999px rgba(15, 23, 42, 0.55),
        0 0 0 2px rgba(255, 255, 255, 0.95),
        0 0 28px 10px rgba(46, 120, 181, 0.55),     /* Baron blue glow */
        inset 0 0 0 1px rgba(255, 255, 255, 0.18);
    transition:
        top 360ms cubic-bezier(0.4, 0.0, 0.2, 1),
        left 360ms cubic-bezier(0.4, 0.0, 0.2, 1),
        width 360ms cubic-bezier(0.4, 0.0, 0.2, 1),
        height 360ms cubic-bezier(0.4, 0.0, 0.2, 1),
        opacity 240ms ease-out;
}
.bf-tour-spot-on { opacity: 1; }

/* The "zoom-in" emphasis — added each time we land on a new step. Brief scale-from-95% so the
 * cutout feels like it's pulling forward. transform-origin is set inline by the JS so the
 * scale is anchored to the cutout's center, not its top-left corner. */
.bf-tour-pulse { animation: bf-tour-pulse 540ms cubic-bezier(0.34, 1.56, 0.64, 1); }
@keyframes bf-tour-pulse {
    0%   { transform: scale(0.94); }
    60%  { transform: scale(1.04); }
    100% { transform: scale(1.00); }
}

/* ---------- Hero card (welcome / outro — no specific element) ---------- */
.bf-tour-hero {
    position: fixed;
    z-index: 100002;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.96);
    width: min(520px, 92vw);
    background: var(--bg-card, #ffffff);
    color: var(--text, #0f172a);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 14px;
    padding: 28px 28px 22px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35), 0 4px 12px rgba(15, 23, 42, 0.18);
    opacity: 0;
    pointer-events: none;
    transition: transform 320ms cubic-bezier(0.34, 1.56, 0.64, 1), opacity 280ms ease-out;
    text-align: center;
}
.bf-tour-hero-on {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.0);
    pointer-events: auto;
}
.bf-tour-hero .bf-tour-title { font-size: 22px; }
.bf-tour-hero .bf-tour-body  { font-size: 15px; line-height: 1.55; margin-top: 10px; }

/* Welcome-card pop — applied to step bodies whose chip says WELCOME. Bigger title, gradient
 * header strip behind the chip, more breathing room. Triggered via :has() — no JS required. */
.bf-tour-hero:has(.bf-tour-chip:is([data-welcome])) { padding-top: 38px; }
.bf-tour-hero .bf-tour-chip[data-welcome] {
    /* Baron red/white/blue brand palette — uses the navy and red CSS custom properties when the
     * tenant has overridden them via Settings, falling back to Baron's default navy + crimson. */
    background: linear-gradient(135deg, var(--baron-blue, #1a4d7c) 0%, var(--baron-red, #a50c25) 100%);
    color: #ffffff;
    font-size: 12px;
    padding: 5px 14px;
    box-shadow: 0 4px 14px rgba(26, 77, 124, 0.35);
}
.bf-tour-hero:has(.bf-tour-chip[data-welcome]) .bf-tour-title  { font-size: 28px; line-height: 1.2; margin-bottom: 10px; }
.bf-tour-hero:has(.bf-tour-chip[data-welcome]) .bf-tour-body   { font-size: 16px; line-height: 1.6; }
.bf-tour-hero:has(.bf-tour-chip[data-welcome]) .bf-tour-actions {
    /* Cross-tour buttons in the welcome card lay out as a centered, multi-column row so the
     * reader sees the full library at a glance. */
    justify-content: center;
}
.bf-tour-hero:has(.bf-tour-chip[data-welcome])::before {
    /* Baron red/white/blue halo — navy → white → red sweep so the card reads as on-brand. */
    background: linear-gradient(135deg, rgba(26, 77, 124, 0.85), rgba(255, 255, 255, 0.6), rgba(165, 12, 37, 0.65));
    filter: blur(20px);
    opacity: 0.7;
}

/* Soft accent ring around the hero so it feels like a "card on a stage." */
.bf-tour-hero::before {
    content: "";
    position: absolute;
    inset: -1px;
    border-radius: 15px;
    background: linear-gradient(135deg, rgba(46, 120, 181, 0.55), rgba(165, 12, 37, 0.45));
    z-index: -1;
    filter: blur(14px);
    opacity: 0.55;
}

/* Overview-mode hero — pinned bottom-right (no centering transform) when text-only, so the page
 * stays visible. When the card carries a screenshot, switch back to centered+big since the
 * embedded image already provides the dashboard context. */
.bf-tour-hero-overview {
    top: auto;
    left: auto;
    right: 24px;
    bottom: 24px;
    transform: scale(0.96);
    width: min(440px, 92vw);
    text-align: left;
}
.bf-tour-hero-overview.bf-tour-hero-on {
    transform: scale(1.0);
}
.bf-tour-hero-overview::before { display: none; }   /* skip the iridescent halo for the corner card */

/* Image-bearing overview cards re-center and grow — the screenshot inside IS the dashboard
 * preview, so we no longer need the corner-card layout to keep the live page visible. */
.bf-tour-hero-overview:has(.bf-tour-shot) {
    top: 50%;
    left: 50%;
    right: auto;
    bottom: auto;
    width: min(80vw, 1320px);
    transform: translate(-50%, -50%) scale(0.96);
    text-align: center;
}
.bf-tour-hero-overview:has(.bf-tour-shot).bf-tour-hero-on {
    transform: translate(-50%, -50%) scale(1.0);
}

/* ---------- Step tooltip (the floating card next to the spotlight) ---------- */
.bf-tour-tip {
    position: fixed;
    z-index: 100002;
    width: min(360px, 88vw);
    background: var(--bg-card, #ffffff);
    color: var(--text, #0f172a);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 12px;
    padding: 18px 18px 14px;
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.32), 0 2px 8px rgba(15, 23, 42, 0.14);
    opacity: 0;
    pointer-events: none;
    transform: translateY(6px);
    transition: opacity 240ms ease-out, transform 280ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.bf-tour-tip-on { opacity: 1; pointer-events: auto; transform: translateY(0); }

/* Arrow (a tiny rotated square peeking out the side that faces the spotlight). */
.bf-tour-tip::after {
    content: "";
    position: absolute;
    width: 14px;
    height: 14px;
    background: var(--bg-card, #ffffff);
    border: 1px solid var(--border, #e5e7eb);
    transform: rotate(45deg);
}
.bf-tour-arrow-top::after    { top: -8px; left: 50%; margin-left: -7px; border-right: none; border-bottom: none; }
.bf-tour-arrow-bottom::after { bottom: -8px; left: 50%; margin-left: -7px; border-left: none; border-top: none; }
.bf-tour-arrow-left::after   { left: -8px; top: 50%; margin-top: -7px; border-right: none; border-top: none; }
.bf-tour-arrow-right::after  { right: -8px; top: 50%; margin-top: -7px; border-left: none; border-bottom: none; }

/* ---------- Card content ---------- */
.bf-tour-chip {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--baron-blue, #1a4d7c);
    padding: 3px 9px;
    border-radius: 999px;
    background: rgba(46, 120, 181, 0.10);
    margin-bottom: 8px;
}
.bf-tour-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text, #0f172a);
    margin: 0 0 6px;
    line-height: 1.3;
}
.bf-tour-body {
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-muted, #475569);
}
.bf-tour-body strong { color: var(--text, #0f172a); }
.bf-tour-body kbd {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    padding: 1px 6px;
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 4px;
    background: var(--bg-input, #f8fafc);
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.08);
}

/* ---------- Nav row ---------- */
.bf-tour-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
}
.bf-tour-progress {
    font-size: 12px;
    color: var(--text-muted, #94a3b8);
    letter-spacing: 0.02em;
}
.bf-tour-spacer { flex: 1; }
.bf-tour-btn {
    appearance: none;
    border: 1px solid var(--border, #e5e7eb);
    background: var(--bg-input, #f8fafc);
    color: var(--text, #0f172a);
    font-weight: 600;
    font-size: 13px;
    padding: 7px 14px;
    border-radius: 7px;
    cursor: pointer;
    transition: background 160ms, transform 120ms;
}
.bf-tour-btn:hover  { background: var(--bg-hover, #eef2f7); }
.bf-tour-btn:active { transform: translateY(1px); }
.bf-tour-btn.bf-tour-next {
    background: linear-gradient(135deg, var(--baron-blue, #1a4d7c) 0%, var(--baron-red, #a50c25) 100%);
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 2px 6px rgba(26, 77, 124, 0.32);
}
.bf-tour-btn.bf-tour-next:hover { filter: brightness(1.08); }

/* ---------- Skip-tour pill (top-right, always visible during a tour) ---------- */
.bf-tour-skip {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 100003;
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.32);
    background: rgba(15, 23, 42, 0.55);
    color: rgba(255, 255, 255, 0.92);
    font-size: 12px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 999px;
    cursor: pointer;
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: background 160ms;
}
.bf-tour-skip:hover { background: rgba(15, 23, 42, 0.78); }

/* ---------- Help "?" launcher (added by PHP next to the user's name) ---------- */
.bf-tour-launcher {
    appearance: none;
    border: 1px solid var(--border, #e5e7eb);
    background: var(--bg-input, #f8fafc);
    color: var(--text-muted, #475569);
    font-size: 13px;
    font-weight: 600;
    width: 26px; height: 26px;
    border-radius: 50%;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 6px;
    transition: background 160ms, color 160ms, transform 120ms;
    line-height: 1;
}
.bf-tour-launcher:hover  { background: var(--bg-hover, #eef2f7); color: var(--text, #0f172a); transform: scale(1.06); }
.bf-tour-launcher:active { transform: scale(0.96); }

/* ---------- Cross-tour action buttons (rendered above the nav row) ---------- */
.bf-tour-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px dashed var(--border, #e5e7eb);
}
.bf-tour-action {
    appearance: none;
    border: 1px solid rgba(46, 120, 181, 0.35);
    background: rgba(46, 120, 181, 0.08);
    color: var(--baron-blue, #1a4d7c);
    font-weight: 600;
    font-size: 12.5px;
    padding: 6px 12px;
    border-radius: 999px;
    cursor: pointer;
    transition: background 160ms, transform 120ms, box-shadow 160ms;
}
.bf-tour-action:hover  { background: rgba(46, 120, 181, 0.18); box-shadow: 0 2px 6px rgba(46, 120, 181, 0.22); }
.bf-tour-action:active { transform: translateY(1px); }
.bf-tour-action::after { content: " →"; color: rgba(26, 77, 124, 0.65); }

/* Current-tour pill in the welcome action row — rendered as the SELECTED chip so the user sees
 * "you're watching this one" alongside the other library entries. Filled with Baron red, no
 * arrow, no hover lift — it's a status indicator, not a navigation button. */
.bf-tour-action.bf-tour-action-current {
    background: var(--baron-red, #a50c25);
    color: #ffffff;
    border-color: transparent;
    cursor: default;
    box-shadow: 0 2px 6px rgba(165, 12, 37, 0.30);
}
.bf-tour-action.bf-tour-action-current:hover  { background: var(--baron-red, #a50c25); box-shadow: 0 2px 6px rgba(165, 12, 37, 0.30); }
.bf-tour-action.bf-tour-action-current::after  { content: " ✓"; color: rgba(255, 255, 255, 0.85); }

/* ---------- Inline screenshots inside step bodies ---------- */
.bf-tour-body .bf-tour-shot {
    display: block;
    max-width: 100%;
    /* Hard cap on image height so the card always fits within the viewport with title + body +
     * nav still visible, no scrollbars. Image scales down maintaining aspect ratio. */
    max-height: 62vh;
    height: auto;
    width: auto;
    margin: 8px auto 12px;
    border-radius: 8px;
    border: 1px solid var(--border, #e5e7eb);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.12);
    object-fit: contain;
    /* Click-to-zoom: cursor + subtle hover affordance so the user knows the image is interactive. */
    cursor: zoom-in;
    transition: box-shadow 160ms ease-out, transform 160ms ease-out;
}
.bf-tour-body .bf-tour-shot:hover {
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.22);
    transform: translateY(-1px);
}

/* ---------- Click-to-zoom lightbox (welcome-tour.js handles the lifecycle) ---------- */
.bf-tour-lightbox {
    position: fixed;
    inset: 0;
    z-index: 100020;  /* above tour backdrop (100000) + spotlight (100001) + cards (100002) */
    background: rgba(15, 23, 42, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    cursor: zoom-out;
    opacity: 0;
    transition: opacity 180ms ease-out;
}
.bf-tour-lightbox-on { opacity: 1; }
.bf-tour-lightbox img {
    max-width: 96vw;
    max-height: 92vh;
    border-radius: 6px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
    /* Keep the image its natural size up to the viewport cap — sharper than the in-card scaled-down version. */
    width: auto;
    height: auto;
    object-fit: contain;
}
.bf-tour-lightbox-hint {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    color: rgba(255, 255, 255, 0.78);
    font-size: 12px;
    font-weight: 500;
    background: rgba(15, 23, 42, 0.5);
    padding: 6px 14px;
    border-radius: 16px;
    pointer-events: none;
}

/* When a step's body contains a screenshot, the card grows to ~3/4 of the viewport so the image
 * actually reads at typical browser sizes. The vw-first sizing (with a sensible upper cap) lets
 * tours feel "full-bleed" on big monitors and still fit on smaller ones. :has() handles the
 * parent-targeting from the descendant img.
 *
 * Sizing strategy: cap the IMAGE at ~62vh and let the card flow naturally. That keeps the title,
 * body, and nav buttons always visible (no scrollbars) while shrinking the screenshot to fit
 * vertical space. Detail-preserving alternative was to scrollbar the image; opted for the simpler
 * scaled-fit since the steps usually accompany the screenshot with explanatory text. */
.bf-tour-tip:has(.bf-tour-shot)              { width: min(78vw, 1280px); }
.bf-tour-hero:has(.bf-tour-shot)             { width: min(80vw, 1320px); }

/* No internal scrollbars on tour cards — let the card grow to fit its content. The image cap
 * at 62vh above keeps the dominant element bounded; remaining content (title + body + nav)
 * adds maybe 200-260px on top, fitting cleanly within the 720-900px effective viewport of a
 * 13"+ laptop. On smaller-than-13" displays the body scrolls naturally because we no longer
 * lock body overflow during the tour (see body.bf-tour-on rule above). */
.bf-tour-tip,
.bf-tour-hero,
.bf-tour-hero-overview {
    max-height: none;
    overflow: visible;
}
/* .bf-tour-hero-overview:has(.bf-tour-shot) — sized + re-centered up at the hero-overview block above. */

/* ---------- "?" launcher dropdown menu (lists every tour the user can replay) ---------- */
.bf-tour-launcher-menu {
    position: absolute;
    z-index: 100004;
    min-width: 220px;
    padding: 6px;
    background: var(--bg-card, #ffffff);
    color: var(--text, #0f172a);
    border: 1px solid var(--border, #e5e7eb);
    border-radius: 10px;
    box-shadow: 0 16px 36px rgba(15, 23, 42, 0.22), 0 2px 8px rgba(15, 23, 42, 0.10);
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    transition: opacity 180ms ease-out, transform 200ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.bf-tour-launcher-menu.bf-tour-launcher-menu-on { opacity: 1; transform: translateY(0); pointer-events: auto; }
.bf-tour-launcher-menu-header {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted, #94a3b8);
    padding: 8px 12px 4px;
}
.bf-tour-launcher-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--text, #0f172a);
    font-size: 13.5px;
    font-weight: 600;
    text-align: left;
    padding: 8px 12px;
    border-radius: 7px;
    cursor: pointer;
    transition: background 140ms;
}
.bf-tour-launcher-item:hover { background: var(--bg-hover, #eef2f7); }
.bf-tour-launcher-item .bf-tour-launcher-icon {
    width: 22px; height: 22px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--baron-blue, #1a4d7c) 0%, var(--baron-red, #a50c25) 100%);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}
.bf-tour-launcher-item .bf-tour-launcher-meta {
    margin-left: auto;
    font-size: 10.5px;
    font-weight: 500;
    color: var(--text-muted, #94a3b8);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

/* ---------- Mobile tweaks ---------- */
@media (max-width: 640px) {
    .bf-tour-tip  { width: calc(100vw - 24px); }
    .bf-tour-hero { padding: 22px 18px 18px; }
    .bf-tour-launcher-menu { min-width: 200px; }
}
