/*
 * CAPP_GUIDEBOOK_LIVING_PEARL_V1
 *
 * Dashboard-only floating Guidebook action.
 *
 * UX:
 * - Vertical TikTok-style footprint.
 * - Living pearl icon above.
 * - "Cẩm nang" label below.
 * - Orbit trace + breathing halo + occasional shimmer.
 * - Theme-aware Blue / Mint.
 * - Reduced-motion safe.
 */

body[data-capp-guidebook-pearl="1"] .capp-guidebook-fab {
    --guide-pearl-accent: #221DF3;
    --guide-pearl-accent-2: #514CFF;
    --guide-pearl-label: #221DF3;
    --guide-pearl-halo: rgba(34,29,243,.22);
    --guide-pearl-ring-soft: rgba(34,29,243,.18);

    position: fixed;

    right: max(
        10px,
        env(safe-area-inset-right)
    );

    bottom: calc(
        82px
        +
        env(safe-area-inset-bottom)
    );

    z-index: 80;

    width: 74px;
    min-height: 82px;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;

    gap: 7px;

    padding: 0;

    border: 0;
    border-radius: 0;

    background: transparent !important;

    color:
        var(--guide-pearl-label) !important;

    text-decoration: none !important;

    box-shadow: none !important;

    isolation: isolate;

    -webkit-tap-highlight-color:
        transparent;

    transform:
        translateZ(0);

    transition:
        transform .16s ease,
        opacity .18s ease;
}


/*
 * Living breathing halo.
 * Deliberately soft; this is not a notification pulse.
 */
body[data-capp-guidebook-pearl="1"]
.capp-guidebook-fab::before {
    content: "";

    position: absolute;

    top: 5px;
    left: 50%;

    width: 52px;
    height: 52px;

    z-index: -2;

    border-radius: 50%;

    background:
        var(--guide-pearl-halo);

    filter:
        blur(11px);

    opacity: .42;

    transform:
        translateX(-50%)
        scale(.88);

    animation:
        cappGuidePearlBreath
        4.8s
        ease-in-out
        infinite;

    pointer-events: none;
}


/*
 * Signature orbit ring.
 */
body[data-capp-guidebook-pearl="1"]
.capp-guidebook-fab::after {
    content: "";

    position: absolute;

    top: -2px;
    left: 50%;

    width: 64px;
    height: 64px;

    z-index: 2;

    padding: 1.5px;

    border-radius: 50%;

    background:
        conic-gradient(
            from 0deg,
            transparent 0deg,
            transparent 208deg,
            var(--guide-pearl-ring-soft) 236deg,
            #FE8AF9 269deg,
            #FFFFFF 298deg,
            #76F5BC 325deg,
            var(--guide-pearl-accent) 348deg,
            transparent 360deg
        );

    -webkit-mask:
        linear-gradient(#fff 0 0)
        content-box,
        linear-gradient(#fff 0 0);

    -webkit-mask-composite:
        xor;

    mask:
        linear-gradient(#fff 0 0)
        content-box,
        linear-gradient(#fff 0 0);

    mask-composite:
        exclude;

    transform:
        translateX(-50%)
        rotate(0deg);

    transform-origin:
        50% 50%;

    animation:
        cappGuidePearlOrbit
        7.5s
        linear
        infinite;

    pointer-events: none;
}


body[data-capp-guidebook-pearl="1"]
.capp-guidebook-fab-icon {
    position: relative;

    width: 58px;
    height: 58px;

    flex:
        0 0 58px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    overflow: hidden;

    border-radius: 50%;

    color: #FFFFFF;

    background:
        radial-gradient(
            circle at 30% 22%,
            rgba(255,255,255,.30),
            transparent 29%
        ),
        linear-gradient(
            145deg,
            var(--guide-pearl-accent-2),
            var(--guide-pearl-accent)
        );

    box-shadow:
        inset 0 1px 0
            rgba(255,255,255,.34),

        inset 0 -8px 18px
            rgba(8,5,117,.14),

        0 5px 12px
            rgba(34,29,243,.20),

        0 13px 26px
            rgba(34,29,243,.26);

    transform:
        translateZ(0)
        scale(1);

    transition:
        transform .18s
        cubic-bezier(.2,.8,.2,1),

        box-shadow .18s ease;
}


/*
 * Light shimmer travels through the pearl only occasionally.
 */
body[data-capp-guidebook-pearl="1"]
.capp-guidebook-fab-icon::after {
    content: "";

    position: absolute;

    top: -18%;
    bottom: -18%;

    left: -72%;

    width: 36%;

    background:
        linear-gradient(
            100deg,
            transparent 0%,
            rgba(255,255,255,.10) 26%,
            rgba(255,255,255,.90) 50%,
            rgba(255,255,255,.10) 74%,
            transparent 100%
        );

    transform:
        skewX(-14deg);

    animation:
        cappGuidePearlShimmer
        5.8s
        ease-in-out
        infinite;

    pointer-events: none;
}


body[data-capp-guidebook-pearl="1"]
.capp-guidebook-fab-icon i {
    position: relative;
    z-index: 1;

    font-size: 21px;

    transform:
        translateZ(0)
        scale(1);

    transform-origin:
        center;

    text-shadow:
        0 2px 8px
        rgba(0,0,0,.15);

    animation:
        cappGuideBookLiving
        4.8s
        ease-in-out
        infinite;

    transition:
        transform .18s
        cubic-bezier(.2,.8,.2,1);
}


body[data-capp-guidebook-pearl="1"]
.capp-guidebook-fab-copy {
    min-width: 0;

    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    line-height: 1;
}


body[data-capp-guidebook-pearl="1"]
.capp-guidebook-fab-copy strong {
    display: block;

    max-width: 74px;

    overflow: hidden;

    color:
        var(--guide-pearl-label) !important;

    font-size: 10.5px;
    line-height: 1.1;
    font-weight: 800;

    letter-spacing: -.18px;

    text-align: center;
    text-overflow: ellipsis;
    white-space: nowrap;

    text-shadow:
        0 1px 8px
        rgba(255,255,255,.54);
}


/*
 * The former long subtitle is intentionally removed
 * from visual presentation to keep a tiny footprint.
 */
body[data-capp-guidebook-pearl="1"]
.capp-guidebook-fab-copy small {
    display: none !important;
}


/*
 * Press morph:
 * pearl compresses and book reacts.
 */
body[data-capp-guidebook-pearl="1"]
.capp-guidebook-fab:active {
    transform:
        translateY(2px)
        scale(.96);
}


body[data-capp-guidebook-pearl="1"]
.capp-guidebook-fab:active
.capp-guidebook-fab-icon {
    transform:
        scale(.90)
        rotate(-3deg);

    box-shadow:
        inset 0 1px 0
            rgba(255,255,255,.30),

        0 3px 8px
            rgba(34,29,243,.17),

        0 7px 14px
            rgba(34,29,243,.20);
}


body[data-capp-guidebook-pearl="1"]
.capp-guidebook-fab:active
.capp-guidebook-fab-icon i {
    transform:
        scale(.90)
        rotate(-6deg);
}


/*
 * Dark theme: living Mint pearl.
 */
body.theme-dark[data-capp-guidebook-pearl="1"]
.capp-guidebook-fab {
    --guide-pearl-accent: #76F5BC;
    --guide-pearl-accent-2: #A6FFD7;
    --guide-pearl-label: #76F5BC;
    --guide-pearl-halo: rgba(118,245,188,.19);
    --guide-pearl-ring-soft: rgba(118,245,188,.18);
}


body.theme-dark[data-capp-guidebook-pearl="1"]
.capp-guidebook-fab-icon {
    color: #073A2A;

    background:
        radial-gradient(
            circle at 30% 22%,
            rgba(255,255,255,.52),
            transparent 30%
        ),
        linear-gradient(
            145deg,
            #A6FFD7,
            #76F5BC
        );

    box-shadow:
        inset 0 1px 0
            rgba(255,255,255,.62),

        inset 0 -8px 18px
            rgba(7,58,42,.08),

        0 5px 12px
            rgba(0,0,0,.24),

        0 13px 27px
            rgba(118,245,188,.16);
}


body.theme-dark[data-capp-guidebook-pearl="1"]
.capp-guidebook-fab-copy strong {
    text-shadow:
        0 1px 9px
        rgba(0,0,0,.56);
}


/*
 * Small devices:
 * keep label because it is part of the feature identity,
 * but tighten total footprint.
 */
@media (max-width: 380px) {

    body[data-capp-guidebook-pearl="1"]
    .capp-guidebook-fab {
        right: max(
            7px,
            env(safe-area-inset-right)
        );

        width: 68px;
    }

    body[data-capp-guidebook-pearl="1"]
    .capp-guidebook-fab-copy strong {
        max-width: 68px;
        font-size: 10px;
    }
}


/*
 * Living effects.
 */
@keyframes cappGuidePearlOrbit {

    to {
        transform:
            translateX(-50%)
            rotate(360deg);
    }

}


@keyframes cappGuidePearlBreath {

    0%,
    100% {
        opacity: .25;

        transform:
            translateX(-50%)
            scale(.84);
    }

    50% {
        opacity: .60;

        transform:
            translateX(-50%)
            scale(1.10);
    }

}


@keyframes cappGuidePearlShimmer {

    0%,
    66%,
    100% {
        left: -72%;
        opacity: 0;
    }

    69% {
        opacity: .25;
    }

    75% {
        left: 138%;
        opacity: .92;
    }

    78% {
        opacity: 0;
    }

}


@keyframes cappGuideBookLiving {

    0%,
    72%,
    100% {
        transform:
            scale(1)
            rotate(0deg);
    }

    79% {
        transform:
            scale(1.07)
            rotate(-3deg);
    }

    86% {
        transform:
            scale(1.03)
            rotate(2deg);
    }

    92% {
        transform:
            scale(1)
            rotate(0deg);
    }

}


/*
 * Accessibility:
 * preserve visual identity without continuous movement.
 */
@media (prefers-reduced-motion: reduce) {

    body[data-capp-guidebook-pearl="1"]
    .capp-guidebook-fab,

    body[data-capp-guidebook-pearl="1"]
    .capp-guidebook-fab::before,

    body[data-capp-guidebook-pearl="1"]
    .capp-guidebook-fab::after,

    body[data-capp-guidebook-pearl="1"]
    .capp-guidebook-fab-icon,

    body[data-capp-guidebook-pearl="1"]
    .capp-guidebook-fab-icon::after,

    body[data-capp-guidebook-pearl="1"]
    .capp-guidebook-fab-icon i {
        animation:
            none !important;

        transition:
            none !important;
    }

}


/* CAPP_GUIDEBOOK_PEARL_ICON_DARK1 */
/* Dark icon only. Preserve Living Pearl effects. */
:is(
    html.theme-dark body,
    html[data-theme="dark"] body,
    html[data-bs-theme="dark"] body,
    html.dark-mode body,
    html.dark body,
    body.theme-dark,
    body[data-theme="dark"],
    body[data-bs-theme="dark"],
    body.dark-mode,
    body.dark
)[data-capp-guidebook-pearl="1"]
.capp-guidebook-fab .capp-guidebook-fab-icon i,
:is(
    html.theme-dark body,
    html[data-theme="dark"] body,
    html[data-bs-theme="dark"] body,
    html.dark-mode body,
    html.dark body,
    body.theme-dark,
    body[data-theme="dark"],
    body[data-bs-theme="dark"],
    body.dark-mode,
    body.dark
)[data-capp-guidebook-pearl="1"]
.capp-guidebook-fab .capp-guidebook-fab-icon i::before {
    color: #102219 !important;
    -webkit-text-fill-color: #102219 !important;
}

/* CAPP_NAV1_FABMINT2 — CIRCULAR ICON ONLY */

body[data-capp-guidebook-pearl="1"]
a.capp-guidebook-fab .capp-guidebook-fab-icon {
    background: linear-gradient(
        145deg,
        #087C80 0%,
        #0CA797 54%,
        #18B99F 100%
    ) !important;

    color: #FFFFFF !important;

    box-shadow:
        0 10px 26px rgba(8,124,128,.27),
        inset 0 1px 0 rgba(255,255,255,.24)
        !important;
}

body[data-capp-guidebook-pearl="1"]
a.capp-guidebook-fab .capp-guidebook-fab-copy strong {
    color: #087C80 !important;
}

/* END CAPP_NAV1_FABMINT2 */
