/*
 * Balance Homes — splash screen (BI-387).
 *
 * Shown from the moment index.html is parsed until React mounts into #root.
 * The background and the wordmark are plain HTML and CSS so they paint on the
 * first frame, with no JavaScript involved; bh-splash.js then draws the
 * instrument dial on top once anime.js has loaded. If either script fails the
 * splash still renders — it just sits still.
 *
 * Every class here is prefixed `bh-` and scoped under #bh-splash so nothing
 * can collide with Lightdash's own styles. Fonts are deliberately limited to
 * Inter, which index.html already loads, so the splash costs no extra font
 * request on the critical path.
 */

#bh-splash {
    position: fixed;
    inset: 0;
    z-index: 9000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background-color: #ffffff;
    color: #1f1b2e;
    font-family: Inter, system-ui, -apple-system, sans-serif;
    /* Set by bh-splash.js so the fixed 400px rig scales to the viewport. */
    --bh-fit: 0.92;
    --bh-accent: #d97706;
    --bh-accent-deep: #b45309;
}

/* Lightdash has mounted: fade out, then bh-splash.js removes the node. */
#bh-splash[data-bh-done] {
    opacity: 0;
    pointer-events: none;
    transition: opacity 400ms ease;
}

#bh-splash::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background: radial-gradient(
        circle at 50% 44%,
        rgba(217, 119, 6, 0.08),
        transparent 62%
    );
}

/* ---------------------------------------------------------------- the rig */

#bh-splash .bh-fitbox {
    scale: var(--bh-fit);
    display: grid;
    place-items: center;
}

#bh-splash .bh-rig {
    position: relative;
    width: 400px;
    height: 400px;
    aspect-ratio: 1 / 1;
    color: var(--bh-accent);
    flex: none;
}

#bh-splash .bh-grid-canvas,
#bh-splash .bh-ring,
#bh-splash .bh-clock-grid,
#bh-splash .bh-clock {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

#bh-splash .bh-grid-canvas {
    z-index: 0;
    opacity: 0.5;
}

#bh-splash .bh-ring {
    overflow: visible;
}

#bh-splash .bh-clock-grid {
    scale: 0.8;
    color: var(--bh-accent);
}

#bh-splash .bh-clock {
    backface-visibility: hidden;
}

/*
 * Dial geometry, after the anime.js reference implementation: a 1px x 10px
 * bar whose origin sits at its own top-right, so rotating it about the dial
 * centre leaves it pointing outward. 193 of these make the ring.
 */
#bh-splash .bh-tick {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 1px;
    height: 10px;
    opacity: 0.5;
    color: var(--bh-accent);
    background-color: currentColor;
    transform-origin: 100% 0%;
    backface-visibility: hidden;
    will-change: transform, opacity;
}

#bh-splash .bh-shape {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100px;
    height: 100px;
    margin-left: -50px;
    margin-top: -50px;
    border: 4px solid currentColor;
    /* Hidden until bh-splash.js scales them in, so they never flash at full
       size on a slow connection. */
    scale: 0;
    will-change: transform;
}

#bh-splash .bh-shape--circle { border-radius: 50%; }
#bh-splash .bh-shape--square { border-radius: 10px; }
#bh-splash .bh-shape--fill { background-color: currentColor; }

/* ----------------------------------------------------------- the wordmark */

#bh-splash .bh-mark {
    position: relative;
    z-index: 2;
    margin: clamp(34px, 7.5vh, 78px) 0 0;
    text-align: center;
    font-weight: 700;
    font-size: clamp(0.95rem, 1.45vw + 0.62rem, 1.42rem);
    letter-spacing: 0.085em;
    line-height: 1.1;
    text-transform: uppercase;
    animation: bh-splash-fade 2.4s ease-in-out infinite;
}

#bh-splash .bh-mark span {
    display: block;
    margin-top: 0.72em;
    font-weight: 500;
    font-size: 0.52em;
    letter-spacing: 0.36em;
    /* Offsets the trailing letter-space so the word reads optically centred. */
    text-indent: 0.36em;
    color: var(--bh-accent-deep);
}

@keyframes bh-splash-fade {
    0%,
    100% { opacity: 0.74; }
    50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    #bh-splash .bh-mark { animation: none; }
    #bh-splash[data-bh-done] { transition: none; }
}
