/* =============================================================================
 * NIZU Onboarding — ambient step backgrounds
 * A per-step background layer for the public wizard: a cover image OR one of
 * several self-contained, low-key animated effects (CSS + SVG/canvas built by
 * onboarding-backgrounds.js). Everything is tuned to be SUBTLE and calm so the
 * card content stays readable, uses the flow accent (--ob-primary / the F7
 * --f7-theme-color) and works in light + dark. All motion pauses under
 * prefers-reduced-motion. No external assets (CSP-safe).
 * ========================================================================== */

/* The fixed layer sits behind everything; wizard content is lifted above it. */
#ob-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}
#ob-bg .ob-bg-art {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity .6s ease;
}
#ob-bg .ob-bg-art.is-in {
    opacity: 1;
}
/* Readability veil between the art and the card (opacity set inline per step). */
#ob-bg .ob-bg-overlay {
    position: absolute;
    inset: 0;
    background: var(--f7-page-bg-color, #eceef3);
    opacity: 0;
    transition: opacity .6s ease;
}

/* Cover image. */
#ob-bg .ob-bg-image {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    transform: scale(1.05);
    animation: obBgDrift 32s ease-in-out infinite alternate;
}
@keyframes obBgDrift {
    from { transform: scale(1.05) translate(0, 0); }
    to   { transform: scale(1.12) translate(-1.5%, -1.5%); }
}

/* Accent helpers used by several effects. */
#ob-bg .ob-bg-art {
    --bg-accent: var(--ob-primary, var(--f7-theme-color, #4a7dff));
    color: var(--bg-accent);
}

/* ---------- 1. HEXAGONS — 3D honeycomb flip-wave -------------------------- */
/* A field of extruded hexagonal prisms (6 walls + 2 caps) that flip 180° in
   perspective, staggered by position → a ripple sweeps across the honeycomb.
   (Technique after CodePen ruvenss/vYLaRXe, recoloured to the flow accent.) */
.ob-bg-hexagons {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.ob-hexscene {
    position: absolute;
    inset: 0;
    transform-style: preserve-3d;   /* font-size (em scale) set inline by JS */
}
.ob-prism {
    position: absolute;
    transform-style: preserve-3d;
    animation: obHexFlip 7s ease-in-out infinite;
}
.ob-prism__face {
    position: absolute;
    backface-visibility: hidden;
    background: color-mix(in srgb, var(--bg-accent) 52%, transparent);
}
.ob-prism__face.f3 {
    background: color-mix(in srgb, var(--bg-accent) 80%, transparent);
}
/* 6 side walls */
.ob-prism__w { margin: -1em -0.5em; height: 2em; width: 1em; }
.ob-prism__w1 { transform: rotate(0deg)   translate(1.73205em) rotateY(90deg); }
.ob-prism__w2 { transform: rotate(60deg)  translate(1.73205em) rotateY(90deg); }
.ob-prism__w3 { transform: rotate(120deg) translate(1.73205em) rotateY(90deg); }
.ob-prism__w4 { transform: rotate(180deg) translate(1.73205em) rotateY(90deg); }
.ob-prism__w5 { transform: rotate(240deg) translate(1.73205em) rotateY(90deg); }
.ob-prism__w6 { transform: rotate(300deg) translate(1.73205em) rotateY(90deg); }
/* 2 hexagon caps (a skewed square clipped to a hexagon by the gradient) */
.ob-prism__cap {
    margin: -2em;
    width: 4em;
    height: 4em;
    background: linear-gradient(-45deg,
        rgba(0, 0, 0, 0) 25%,
        color-mix(in srgb, var(--bg-accent) 42%, transparent) 0,
        color-mix(in srgb, var(--bg-accent) 42%, transparent) 75%,
        rgba(0, 0, 0, 0) 0);
}
.ob-prism__cap-t { transform: translateZ(0.5em) rotate(90deg) skewX(30deg) scaleY(0.86603); }
.ob-prism__cap-b { transform: rotateY(0.5turn) translateZ(0.5em) rotate(90deg) skewX(30deg) scaleY(0.86603); }
@keyframes obHexFlip {
    53.333%, 100% { transform: perspective(40em) rotateY(0.5turn); }
}

/* ---------- 2. WAVES ------------------------------------------------------- */
.ob-bg-waves {
    display: flex;
    align-items: flex-end;
}
.ob-bg-waves svg {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 200%;
    height: 60%;
}
.ob-bg-waves .ob-wave {
    animation: obWaveSlide linear infinite;
}
.ob-bg-waves .ob-wave-1 { opacity: .18; animation-duration: 22s; }
.ob-bg-waves .ob-wave-2 { opacity: .13; animation-duration: 30s; animation-direction: reverse; }
.ob-bg-waves .ob-wave-3 { opacity: .09; animation-duration: 42s; }
@keyframes obWaveSlide {
    from { transform: translateX(0); }
    to   { transform: translateX(-50%); }
}

/* ---------- 3. AURORA ------------------------------------------------------ */
.ob-bg-aurora .ob-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(70px);
    opacity: .5;
    mix-blend-mode: normal;
}
.ob-bg-aurora .ob-blob-1 { width: 46vw; height: 46vw; left: -8vw;  top: -10vh; background: var(--bg-accent); animation: obAurora1 26s ease-in-out infinite alternate; }
.ob-bg-aurora .ob-blob-2 { width: 40vw; height: 40vw; right: -6vw; top: 8vh;   background: color-mix(in srgb, var(--bg-accent) 70%, #7c5cff); animation: obAurora2 32s ease-in-out infinite alternate; }
.ob-bg-aurora .ob-blob-3 { width: 38vw; height: 38vw; left: 22vw; bottom: -14vh; background: color-mix(in srgb, var(--bg-accent) 60%, #21d4fd); animation: obAurora3 38s ease-in-out infinite alternate; }
@keyframes obAurora1 { to { transform: translate(6vw, 8vh) scale(1.15); } }
@keyframes obAurora2 { to { transform: translate(-7vw, 6vh) scale(1.1); } }
@keyframes obAurora3 { to { transform: translate(4vw, -8vh) scale(1.2); } }

/* ---------- 4. FLOATING BUBBLES ------------------------------------------- */
.ob-bg-bubbles .ob-bubble {
    position: absolute;
    bottom: -12vh;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, color-mix(in srgb, var(--bg-accent) 55%, #fff), var(--bg-accent));
    opacity: .16;
    animation: obBubbleRise linear infinite;
}
@keyframes obBubbleRise {
    0%   { transform: translateY(0) translateX(0) scale(.9); opacity: 0; }
    12%  { opacity: .2; }
    100% { transform: translateY(-118vh) translateX(var(--bg-sway, 3vw)) scale(1.05); opacity: 0; }
}

/* ---------- 5. PARTICLE CONSTELLATION (canvas from JS) -------------------- */
.ob-bg-particles canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: .55;
}

/* ---------- 6. GRADIENT MESH BLOBS ---------------------------------------- */
.ob-bg-mesh {
    background:
        radial-gradient(40vw 40vw at 18% 22%, color-mix(in srgb, var(--bg-accent) 45%, transparent), transparent 70%),
        radial-gradient(38vw 38vw at 82% 28%, color-mix(in srgb, #7c5cff 45%, transparent), transparent 70%),
        radial-gradient(42vw 42vw at 50% 92%, color-mix(in srgb, #21d4fd 40%, transparent), transparent 72%),
        radial-gradient(36vw 36vw at 88% 82%, color-mix(in srgb, var(--bg-accent) 35%, transparent), transparent 70%);
    background-size: 200% 200%;
    filter: blur(24px);
    opacity: .55;
    animation: obMeshShift 34s ease-in-out infinite alternate;
}
@keyframes obMeshShift {
    from { background-position: 0% 0%; }
    to   { background-position: 100% 100%; }
}

/* ---------- 7. ROTATING EARTH GLOBE (orthographic canvas from JS) ---------- */
/* A true 3D sphere: land dots projected orthographically per frame (front
   hemisphere only, so continents curve around and hide on the back). The whole
   globe is inclined on its axis; a soft glow + radial shading give it depth. */
.ob-bg-globe,
.ob-bg-arcs {
    display: flex;
    align-items: center;
    justify-content: center;
}
.ob-bg-globe { opacity: .55; }
.ob-bg-arcs  { opacity: .6; }
.ob-globe {
    position: relative;
    width: min(80vmin, 860px);
    height: min(80vmin, 860px);
    border-radius: 50%;
    transform: rotate(-21deg);   /* axial tilt (~Earth's 23.5°) */
    box-shadow: 0 14px 90px -16px var(--bg-accent);
}
.ob-globe canvas {
    display: block;
    width: 100%;
    height: 100%;
}
.ob-globe-shade {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    pointer-events: none;
    background:
        radial-gradient(circle at 32% 27%, rgba(255, 255, 255, .22), rgba(255, 255, 255, 0) 44%),
        radial-gradient(circle at 72% 78%, rgba(0, 0, 0, .38), rgba(0, 0, 0, 0) 72%);
}

/* ---------- 8. ROUTES A -> B (SVG from JS) -------------------------------- */
.ob-bg-routes svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: .4;
    overflow: visible;
}
.ob-bg-routes .ob-route-path {
    stroke: var(--bg-accent);
    stroke-width: 1.6;
    fill: none;
    stroke-linecap: round;
    stroke-dasharray: 6 10;
    animation: obRouteDash linear infinite;
}
@keyframes obRouteDash {
    to { stroke-dashoffset: -320; }
}
.ob-bg-routes .ob-route-node {
    fill: var(--bg-accent);
    animation: obRouteNode 3.2s ease-in-out infinite;
}
@keyframes obRouteNode {
    0%, 100% { opacity: .35; transform: scale(1); }
    50%      { opacity: .95; transform: scale(1.5); }
}
.ob-bg-routes .ob-route-node { transform-box: fill-box; transform-origin: center; }

/* ---------- 9. WHATSAPP CONVERSATION -------------------------------------- */
/* A WhatsApp-style chat quietly scrolling up: green outgoing bubbles (right,
   blue double-tick) and white incoming bubbles (left), on the WhatsApp
   tan/dark backdrop. Bubbles sit on the sides, clear of the centred card. */
.ob-bg-whatsapp {
    --wa-bg: #e5ddd5;
    --wa-in: #ffffff;
    --wa-out: #d9fdd3;
    --wa-text: #111b21;
    --wa-meta: rgba(0, 0, 0, .45);
    --wa-tick: #53bdeb;
    background: var(--wa-bg);
    overflow: hidden;
}
html.dark .ob-bg-whatsapp {
    --wa-bg: #0b141a;
    --wa-in: #202c33;
    --wa-out: #005c4b;
    --wa-text: #e9edef;
    --wa-meta: rgba(233, 237, 239, .5);
}
.ob-wa-track {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    padding: 20px clamp(12px, 5vw, 90px);
    display: flex;
    flex-direction: column;
    gap: 9px;
    animation: obWaScroll 55s linear infinite;
}
@keyframes obWaScroll {
    from { transform: translateY(0); }
    to   { transform: translateY(-50%); }
}
.ob-wa-msg {
    max-width: min(60%, 400px);
    padding: 6px 9px 7px;
    border-radius: 9px;
    font: 500 15px/1.35 -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--wa-text);
    box-shadow: 0 1px 1px rgba(0, 0, 0, .13);
    position: relative;
}
.ob-wa-msg.in  { align-self: flex-start; background: var(--wa-in);  border-top-left-radius: 2px; }
.ob-wa-msg.out { align-self: flex-end;   background: var(--wa-out); border-top-right-radius: 2px; }
.ob-wa-msg.in::before {
    content: ""; position: absolute; top: 0; left: -7px;
    border: 7px solid transparent; border-top-color: var(--wa-in); border-right: 0;
}
.ob-wa-msg.out::before {
    content: ""; position: absolute; top: 0; right: -7px;
    border: 7px solid transparent; border-top-color: var(--wa-out); border-left: 0;
}
.ob-wa-line {
    height: 8px;
    border-radius: 4px;
    background: currentColor;
    opacity: .16;
    margin: 3px 0;
}
.ob-wa-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 3px;
    font-size: 11px;
    color: var(--wa-meta);
    margin-top: 1px;
}
.ob-wa-tick { color: var(--wa-tick); font-size: 12px; letter-spacing: -2px; }

/* ---------- 10. ISOMETRIC CUBE WAVE (after thebabydino/wKoVGN) ------------ */
/* A grid of 3D cubes viewed isometrically; each cube's height (Z-scale) pulses,
   staggered by cell → a wave ripples diagonally across the field. Recoloured to
   the flow accent (top bright, sides shaded). Grid classes are scoped so the
   pen's global `div{display:grid}` never leaks to the rest of the page. */
.ob-bg-cubes {
    display: grid;
    place-items: center;
    overflow: hidden;
}
.ob-cubegrid {
    display: grid;
    grid-template-columns: repeat(var(--n), 2.75em);
    grid-gap: 0.5em;
    place-self: center;
    transform: rotateX(55deg) rotate(45deg);
    transform-style: preserve-3d;
}
.ob-cube {
    display: grid;
    aspect-ratio: 1;
    transform-origin: 50% 50% -2.75em;
    transform-style: preserve-3d;
    background: var(--bg-accent);
    animation: obCubeWave 1.5s ease-in-out infinite;
    animation-delay: calc((var(--n) - 1 - var(--j) + var(--i)) * .05 * 1.5s);
}
.ob-cube::before, .ob-cube::after {
    --i: 0;
    --j: calc(1 - var(--i));
    grid-area: 1/1;
    transform-origin: calc(var(--j) * 50%) calc(var(--i) * 50%);
    translate: calc(var(--i) * 100%) calc(var(--j) * 100%);
    rotate: var(--j) var(--i) 0 calc((2 * var(--i) - 1) * 90deg);
    content: "";
}
.ob-cube::before { background: color-mix(in srgb, var(--bg-accent) 72%, #000); }
.ob-cube::after  { --i: 1; background: color-mix(in srgb, var(--bg-accent) 48%, #000); }
@keyframes obCubeWave {
    0%, 50%, 100% { scale: 1 1 0; }
    25% { scale: 1 1 0.5; }
}

/* ---------- 11. DOTTED WORLD MAP + pulsing pins (after DonSinDRom/RwzgBX) -- */
.ob-bg-dotmap canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

/* ---------- 12. FOLDING / TUMBLING CUBES (original, in the spirit of ------- */
/*             thebabydino's 3D-cube work — no copied markup or memorial). */
.ob-bg-foldcubes {
    perspective: 1400px;
    overflow: hidden;
    opacity: .5;
}
.ob-foldscene {
    position: absolute;
    inset: 0;
    transform-style: preserve-3d;
}
.ob-fcube {
    position: absolute;
    transform-style: preserve-3d;
    animation: obFold 12s linear infinite;
}
.ob-fcube__f {
    position: absolute;
    inset: 0;
    border: 1px solid color-mix(in srgb, var(--bg-accent) 55%, transparent);
    background: color-mix(in srgb, var(--bg-accent) 22%, transparent);
}
.ob-fcube__f.f2 { background: color-mix(in srgb, var(--bg-accent) 12%, transparent); }
.ob-fcube__f.f3 { background: color-mix(in srgb, var(--bg-accent) 32%, transparent); }
.ob-fcube__f.front  { transform: translateZ(var(--s)); }
.ob-fcube__f.back   { transform: rotateY(180deg) translateZ(var(--s)); }
.ob-fcube__f.right  { transform: rotateY(90deg) translateZ(var(--s)); }
.ob-fcube__f.left   { transform: rotateY(-90deg) translateZ(var(--s)); }
.ob-fcube__f.top    { transform: rotateX(90deg) translateZ(var(--s)); }
.ob-fcube__f.bottom { transform: rotateX(-90deg) translateZ(var(--s)); }
@keyframes obFold {
    to { transform: rotate3d(1, 1, 0.4, 1turn); }
}

/* ---------- 13. FAITHFUL PEN SCENES (isolated iframe) ---------------------- */
/* Specific illustrated pens (a cargo ship, an SVG scene) are embedded verbatim
   in a sandboxed same-origin iframe — exact fidelity, fully isolated so their
   CSS/markup can never touch the rest of the page. */
.ob-bg-ship,
.ob-bg-svgscene,
.ob-bg-blueprint,
.ob-bg-helix {
    opacity: .9;
}
.ob-bg-ship iframe,
.ob-bg-svgscene iframe,
.ob-bg-blueprint iframe,
.ob-bg-helix iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    pointer-events: none;
}

/* ---------- accessibility: pause everything under reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
    #ob-bg *,
    #ob-bg *::before,
    #ob-bg *::after {
        animation: none !important;
        transition: none !important;
    }
}
