/*! Fanfare · (c) 2026 Antichaos — antichaosdata.com. All rights reserved. Proprietary. */
:root { --ink: #151b26; --hit: #1f77b4; --accent: #5b8def; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    overflow: hidden;
    background: transparent;             /* blend with the worksheet by default */
    font-family: "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
}
.hidden { display: none !important; }

/* The KPI tile — centred in the worksheet zone, number scales to the space. */
.tile {
    position: fixed;
    inset: 0;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px;
    box-sizing: border-box;
    text-align: center;
    color: var(--ink);
}
.fan-label {
    font-size: clamp(11px, 3.2vmin, 16px);
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    opacity: .65;
}
.fan-number {
    font-size: clamp(30px, 16vmin, 120px);
    font-weight: 800;
    letter-spacing: -.02em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    transition: color .25s ease;
}
/* When the target is met the number stays visibly "won" — hit colour + a soft glow
   so the tile reads triumphant even after the confetti has faded. */
.fan-number.hit {
    color: var(--hit, #1f77b4);
    text-shadow: 0 2px 26px color-mix(in srgb, var(--hit, #1f77b4) 30%, transparent);
}

/* Delta chip: "% of goal · +$28" — the progress-to-target at a glance, and the
   persistent achieved marker (green pill with a ✓ once the goal is met). */
.fan-delta {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: clamp(3px, 1vmin, 5px) clamp(9px, 2.4vmin, 13px);
    border-radius: 999px;
    font-size: clamp(11px, 3vmin, 15px);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -.01em;
    color: var(--ink);
    background: color-mix(in srgb, var(--ink) 8%, transparent);
    transition: background .25s ease, color .25s ease;
}
.fan-delta.hit {
    color: #fff;
    background: var(--hit, #1f77b4);
    box-shadow: 0 2px 12px color-mix(in srgb, var(--hit, #1f77b4) 35%, transparent);
}
.fan-delta[hidden] { display: none; }

.fan-progress { width: min(78%, 360px); }
.fan-bar {
    position: relative;
    height: clamp(7px, 1.5vmin, 12px);
    border-radius: 999px;
    background: color-mix(in srgb, var(--ink) 12%, transparent);
    overflow: hidden;
}
.fan-bar > #fan-bar-fill {
    display: block; height: 100%; width: 0; border-radius: 999px;
    background: linear-gradient(90deg,
        color-mix(in srgb, var(--accent) 78%, #fff 0%),
        var(--accent));
    transition: width .5s cubic-bezier(.34, 1.2, .5, 1), background .25s ease;
}
.fan-progress.hit .fan-bar > #fan-bar-fill {
    background: linear-gradient(90deg,
        color-mix(in srgb, var(--hit, #1f77b4) 72%, #fff),
        var(--hit, #1f77b4));
}
/* Target marker — a tick at the goal line so overshoot is visible (the fill runs
   past it when you're over target, Bullet-graph style). */
.fan-bar-marker {
    position: absolute;
    top: 0; bottom: 0;
    width: 2px;
    margin-left: -1px;
    background: rgba(255, 255, 255, .9);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--ink) 40%, transparent);
    z-index: 1;
    transition: left .5s cubic-bezier(.34, 1.2, .5, 1);
}
.fan-progress:not(.has-marker) .fan-bar-marker { display: none; }
.fan-target {
    margin-top: 7px;
    font-size: clamp(10px, 2.6vmin, 13px);
    font-weight: 600;
    opacity: .6;
    font-variant-numeric: tabular-nums;
}

/* On-tile Test button — preview the celebration while building a dashboard. */
.test-btn {
    position: fixed;
    bottom: 10px;
    right: 10px;
    z-index: 4;
    border: 0;
    border-radius: 999px;
    padding: 7px 14px;
    font: 700 12px "Inter", "Segoe UI", -apple-system, sans-serif;
    background: var(--accent, #5b8def);
    color: #fff;
    cursor: pointer;
    opacity: .9;
    box-shadow: 0 2px 10px rgba(20, 28, 42, .25);
    pointer-events: auto;
    transition: opacity .15s ease, filter .15s ease, transform .15s ease;
}
.test-btn:hover { opacity: 1; filter: brightness(1.06); transform: translateY(-1px); }
.test-btn[hidden] { display: none; }

/* The confetti canvas fills the zone and never intercepts clicks. */
#confetti {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 2;
}

/* Celebration banner */
.message {
    position: fixed;
    top: 22px;
    left: 50%;
    transform: translateX(-50%) translateY(-8px) scale(.92);
    transform-origin: top center;
    z-index: 3;
    max-width: min(90%, 480px);
    padding: 12px 22px;
    border-radius: 14px;
    background: rgba(255, 255, 255, .9);
    -webkit-backdrop-filter: saturate(1.4) blur(12px);
    backdrop-filter: saturate(1.4) blur(12px);
    border: 1px solid rgba(255, 255, 255, .7);
    color: var(--hit, #1f77b4);
    font: 700 16px/1.25 "Inter", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
    text-align: center;
    box-shadow: 0 8px 28px rgba(20, 28, 42, .16), 0 1px 3px rgba(20, 28, 42, .08);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease, transform .4s cubic-bezier(.34, 1.56, .5, 1);
}
.message.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
}

/* Needs-config overlay (only while unconfigured) ----------------------- */
#needs-config {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 5;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    background: var(--ac-bg, #fbfcfe);
}
#needs-config.show { display: flex; }

.setup-card {
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    padding: 28px 26px 22px;
    background: var(--ac-surface, #fff);
    border: 1px solid var(--ac-line, #e7ecf3);
    border-radius: var(--ac-radius, 16px);
    box-shadow: var(--ac-shadow, 0 4px 14px rgba(20, 28, 42, .08), 0 14px 34px rgba(20, 28, 42, .08));
}
.setup-icon {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 20px;
    background: var(--accent-soft, color-mix(in srgb, #4f7cf0 12%, transparent));
    color: var(--accent, #4f7cf0);
    margin-bottom: 2px;
}
.setup-card h2 {
    margin: 0;
    font-size: 19px;
    font-weight: 800;
    letter-spacing: -.01em;
    color: var(--ac-ink, #151b26);
}
.setup-card p {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.6;
    color: var(--ac-ink-soft, #5d6878);
}
.setup-btn {
    margin-top: 6px;
    border: 0;
    background: var(--accent, #5b8def);
    color: #fff;
    font-size: 13.5px;
    font-weight: 700;
    padding: 11px 22px;
    border-radius: 999px;
    cursor: pointer;
    box-shadow: 0 2px 10px color-mix(in srgb, #5b8def 35%, transparent);
    transition: filter .15s ease, transform .15s ease;
}
.setup-btn:hover { filter: brightness(1.06); transform: translateY(-1px); }
.setup-brand { margin-top: 8px; }

@media (max-height: 280px) {
    .setup-card { padding: 18px 22px; gap: 7px; }
    .message { font-size: 14px; top: 12px; }
}

/* Reduce-motion viewers: the confetti burst + wall-mode loop are skipped in JS; here we
   also drop the message banner's slide/scale (fade only) and the springy bar transitions,
   so the tile settles into its "met" state without animation. */
@media (prefers-reduced-motion: reduce) {
    .message,
    .message.show { transform: translateX(-50%); transition: opacity .12s ease; }
    #fan-bar-fill,
    .fan-bar-marker { transition: none; }
}
