/* ═══════════════════════════════════════════════════════════════════════════
   BLUNDERCHECK — BOARD CELEBRATIONS
   Used by /standings and /live-board. Two pieces:

   1. RESULT BANNER — the arena's "NEW RESULT" card: pops in, a light sweep, confetti,
      gone after a few seconds. One at a time; several results queue.
   2. LEADER SPOTLIGHT (/live-board only) — a slow, continuous loop that features each
      top player ONE AT A TIME: a card glides in from the side, drifts, glides out, and
      the next place follows from the other side, so the board stays readable.

   Sized in viewport units, NOT --sb-scale: the board's scale can be small on a busy
   screen, and the celebration should still be big enough to enjoy from the back.
   pointer-events: none throughout — these are displays, never anything to click.
═══════════════════════════════════════════════════════════════════════════ */

.bc-layer { position: fixed; inset: 0; pointer-events: none; z-index: 900; overflow: hidden; }

/* ── 1. Result banner ─────────────────────────────────────────────────────── */
#bc-result {
    position: fixed; left: 50%; top: 46%;
    transform: translate(-50%, -50%);
    width: min(64vw, 1100px);
    display: flex; justify-content: center;
    opacity: 0; visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s linear 0.3s;
    pointer-events: none; z-index: 950;
}
#bc-result.show { opacity: 1; visibility: visible; transition: opacity 0.3s ease; }

.bc-card {
    position: relative; overflow: hidden;
    background: linear-gradient(150deg, rgba(26,26,30,0.97) 0%, rgba(14,14,16,0.97) 100%);
    border: 2px solid #7a6230; border-radius: 18px;
    padding: clamp(10px, 1.6vh, 20px) clamp(16px, 2vw, 34px) clamp(12px, 1.9vh, 24px);
    text-align: center;
    box-shadow: 0 0 34px rgba(201,168,76,0.45), 0 14px 44px rgba(0,0,0,0.75);
    max-width: 100%;
}
#bc-result .bc-card { transform: scale(0.9); transition: transform 0.45s cubic-bezier(0.2, 1.4, 0.4, 1); }
#bc-result.show .bc-card { transform: scale(1); }
#bc-result.is-draw .bc-card {
    border-color: #5c1f59;
    box-shadow: 0 0 34px rgba(156,64,151,0.5), 0 18px 60px rgba(0,0,0,0.75);
}

/* Light sweeping across the card — the "party" part. */
.bc-card::after {
    content: ''; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(115deg, transparent 38%, rgba(255,255,255,0.16) 50%, transparent 62%);
    transform: translateX(-100%);
}
#bc-result.show .bc-card::after { animation: bcSweep 1.5s ease-in-out 0.25s 2; }
@keyframes bcSweep { to { transform: translateX(100%); } }

.bc-kicker {
    font-family: 'Share Tech Mono', monospace;
    letter-spacing: 0.2em;
    font-size: clamp(11px, 1.35vh, 18px);
    color: #e8c97a;
    margin-bottom: clamp(4px, 0.8vh, 10px);
}
#bc-result.is-draw .bc-kicker { color: #d494cf; }

.bc-main {
    font-family: 'Bebas Neue', 'Impact', sans-serif;
    line-height: 1.06;
    display: flex; align-items: baseline; justify-content: center; flex-wrap: wrap;
    gap: 0.25em 0.45em;
    font-size: clamp(26px, 5vh, 64px);
}
/* Names are never shortened: a long pairing wraps onto a second line instead. */
.bc-player { display: inline-flex; align-items: baseline; gap: 0.3em; }
.bc-winner { color: #c9a84c; text-shadow: 0 0 18px rgba(201,168,76,0.55); }
.bc-loser  { color: #c4c0b8; }
.bc-drawer { color: #e8c97a; }
.bc-role {
    font-family: 'Share Tech Mono', monospace; font-size: 0.3em; letter-spacing: 0.12em;
    color: #a6a29b; padding: 2px 8px; border: 1px solid #3a3a42; border-radius: 20px;
}
.bc-verb { font-size: 0.46em; color: #c4c0b8; letter-spacing: 0.1em; }

.bc-score {
    margin-top: clamp(6px, 1vh, 12px);
    font-family: 'Share Tech Mono', monospace; font-weight: 700;
    font-size: clamp(16px, 2.4vh, 30px);
    display: inline-block; padding: 2px 15px; border-radius: 11px;
    background: rgba(201,168,76,0.14); color: #e8c97a; border: 1px solid #7a6230;
}
#bc-result.is-draw .bc-score { background: rgba(156,64,151,0.16); color: #d494cf; border-color: #5c1f59; }

/* Confetti — generated per showing and cleared afterwards, so nothing animates unseen. */
.bc-confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; border-radius: 18px; }
.bc-bit { position: absolute; top: -14%; width: 9px; height: 15px; opacity: 0; border-radius: 2px; }
.bc-confetti.go .bc-bit { animation: bcFall linear forwards; }
@keyframes bcFall {
    0%   { opacity: 0; transform: translateY(0) rotate(0deg); }
    10%  { opacity: 1; }
    85%  { opacity: 1; }
    100% { opacity: 0; transform: translateY(var(--bc-fall, 320px)) rotate(680deg); }
}

/* ── 2. Leader spotlight ──────────────────────────────────────────────────
   One player at a time: the card glides in from one side, drifts slowly while it's
   up, glides out, and the next place comes in from the OTHER side — so no part of the
   board is covered for long. About a third of the screen wide, never more. */
#bc-spot {
    position: fixed;
    bottom: 7vh;
    width: min(31vw, 540px);
    z-index: 920;
    pointer-events: none;
    opacity: 0;
    transition: transform 1.3s cubic-bezier(0.22, 1, 0.36, 1), opacity 1s ease;
}
#bc-spot.from-right { right: 2.5vw; transform: translateX(calc(100% + 4vw)) rotate(4deg); }
#bc-spot.from-left  { left: 2.5vw;  transform: translateX(calc(-100% - 4vw)) rotate(-4deg); }
#bc-spot.in { opacity: 1; transform: translateX(0) rotate(0deg); }
/* While it's up, it drifts slowly inward — present, but always moving. */
#bc-spot.in.drift.from-right { transform: translateX(-2.5vw); transition: transform 8s linear, opacity 1s ease; }
#bc-spot.in.drift.from-left  { transform: translateX(2.5vw);  transition: transform 8s linear, opacity 1s ease; }
#bc-spot.out { opacity: 0; transition: transform 1.1s cubic-bezier(0.55, 0, 0.75, 0.2), opacity 0.9s ease 0.2s; }
#bc-spot.out.from-right { transform: translateX(calc(100% + 4vw)) rotate(3deg); }
#bc-spot.out.from-left  { transform: translateX(calc(-100% - 4vw)) rotate(-3deg); }

#bc-spot .bc-card {
    text-align: center;
    padding: clamp(12px, 1.9vh, 24px) clamp(16px, 1.8vw, 30px) clamp(14px, 2.1vh, 26px);
    border-width: 2px;
}
#bc-spot.in .bc-card::after { animation: bcSweep 1.8s ease-in-out 0.8s 1; }

/* Colour per place: gold, silver, bronze, then club green. */
#bc-spot.p1 .bc-card { border-color: #e8c97a; background: linear-gradient(160deg, rgba(40,32,12,0.96), rgba(14,12,8,0.96));
                       box-shadow: 0 0 48px rgba(232,201,122,0.55), 0 18px 60px rgba(0,0,0,0.8); }
#bc-spot.p2 .bc-card { border-color: #c9ced6; background: linear-gradient(160deg, rgba(30,32,36,0.96), rgba(12,12,14,0.96));
                       box-shadow: 0 0 40px rgba(201,206,214,0.38), 0 18px 60px rgba(0,0,0,0.8); }
#bc-spot.p3 .bc-card { border-color: #d08a4e; background: linear-gradient(160deg, rgba(38,24,14,0.96), rgba(12,10,8,0.96));
                       box-shadow: 0 0 40px rgba(208,138,78,0.42), 0 18px 60px rgba(0,0,0,0.8); }
#bc-spot.pn .bc-card { border-color: #78c14c; background: linear-gradient(160deg, rgba(18,28,14,0.96), rgba(10,12,10,0.96));
                       box-shadow: 0 0 36px rgba(120,193,76,0.35), 0 18px 60px rgba(0,0,0,0.8); }

/* The section, front and centre: a badge in the board's section-bar style. */
.bc-spot-section {
    display: inline-block;
    font-family: 'Bebas Neue', 'Impact', sans-serif;
    font-size: clamp(24px, 4.2vh, 56px);
    line-height: 1;
    letter-spacing: 0.06em;
    color: #0c0c0c;
    background: #78c14c;
    border-radius: 999px;
    padding: 0.12em 0.7em 0.08em;
    box-shadow: 0 0 18px rgba(120,193,76,0.55);
    margin-bottom: clamp(6px, 1vh, 12px);
    overflow-wrap: anywhere;
}
#bc-spot.p1 .bc-spot-section { background: #e8c97a; box-shadow: 0 0 20px rgba(232,201,122,0.6); }
#bc-spot.p2 .bc-spot-section { background: #d9dde3; box-shadow: 0 0 18px rgba(217,221,227,0.45); }
#bc-spot.p3 .bc-spot-section { background: #e39a5c; box-shadow: 0 0 18px rgba(227,154,92,0.5); }

.bc-spot-kicker {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(10px, 1.3vh, 17px);
    letter-spacing: 0.2em; text-transform: uppercase;
    color: #b8b4ad;
}
.bc-spot-place {
    font-family: 'Bebas Neue', 'Impact', sans-serif;
    font-size: clamp(30px, 5.4vh, 72px);
    line-height: 1;
    letter-spacing: 0.04em;
    margin-top: clamp(4px, 0.7vh, 10px);
    opacity: 0; transform: scale(0.6);
}
#bc-spot.in .bc-spot-place { animation: bcPop 0.65s cubic-bezier(0.2, 1.5, 0.4, 1) 0.55s forwards; }
#bc-spot.p1 .bc-spot-place { color: #ffe08a; text-shadow: 0 0 22px rgba(255,214,106,0.8); }
#bc-spot.p2 .bc-spot-place { color: #e6eaf0; text-shadow: 0 0 18px rgba(230,234,240,0.55); }
#bc-spot.p3 .bc-spot-place { color: #e39a5c; text-shadow: 0 0 18px rgba(227,154,92,0.6); }
#bc-spot.pn .bc-spot-place { color: #96d96a; text-shadow: 0 0 16px rgba(150,217,106,0.5); }
@keyframes bcPop { to { opacity: 1; transform: scale(1); } }

/* The name is the star. Never shortened — it wraps if it must. */
.bc-spot-name {
    font-family: 'Bebas Neue', 'Impact', sans-serif;
    font-size: clamp(30px, 5vh, 66px);
    line-height: 1.02;
    letter-spacing: 0.03em;
    color: #ffffff;
    overflow-wrap: anywhere;
    margin-top: clamp(4px, 0.6vh, 8px);
    opacity: 0; transform: translateY(10px);
}
#bc-spot.in .bc-spot-name { animation: bcRowIn 0.6s ease-out 0.85s forwards; }
@keyframes bcRowIn { to { opacity: 1; transform: none; } }

.bc-spot-stats {
    display: flex; justify-content: center; flex-wrap: wrap;
    gap: clamp(6px, 0.8vw, 12px);
    margin-top: clamp(8px, 1.2vh, 14px);
    opacity: 0;
}
#bc-spot.in .bc-spot-stats { animation: bcRowIn 0.6s ease-out 1.15s forwards; }
.bc-chip {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(12px, 1.6vh, 21px);
    letter-spacing: 0.06em;
    padding: 3px 12px; border-radius: 10px;
    border: 1px solid #3a3a42; color: #dedad3; background: rgba(255,255,255,0.04);
    white-space: nowrap;
}
.bc-chip.bc-pts { font-weight: 700; color: #ffe9b0; border-color: #7a6230; background: rgba(201,168,76,0.16); }
.bc-spot-tb {
    font-family: 'Share Tech Mono', monospace;
    font-size: clamp(10px, 1.3vh, 17px);
    color: #a6a29b; letter-spacing: 0.08em;
    margin-top: clamp(6px, 0.9vh, 10px);
    opacity: 0;
}
#bc-spot.in .bc-spot-tb { animation: bcRowIn 0.6s ease-out 1.35s forwards; }

/* A crown that gently bobs over first place. */
.bc-crown { display: inline-block; margin-right: 0.12em; animation: bcBob 2.4s ease-in-out infinite; }
@keyframes bcBob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }

/* Sparkles drifting up through the card. */
.bc-spark {
    position: absolute; width: 5px; height: 5px; border-radius: 50%;
    background: #ffe9a8; box-shadow: 0 0 8px #ffd56a;
    bottom: -8px; opacity: 0;
    animation: bcSpark linear infinite;
}
#bc-spot.pn .bc-spark { background: #c8f0a8; box-shadow: 0 0 8px #96d96a; }
#bc-spot.p2 .bc-spark { background: #f0f3f8; box-shadow: 0 0 8px #d9dde3; }
@keyframes bcSpark {
    0%   { opacity: 0; transform: translateY(0) scale(0.6); }
    15%  { opacity: 0.9; }
    100% { opacity: 0; transform: translateY(-240px) scale(1.1); }
}

@media (prefers-reduced-motion: reduce) {
    #bc-result.show .bc-card::after, .bc-confetti.go .bc-bit,
    #bc-spot.in .bc-card::after, .bc-crown, .bc-spark { animation: none; }
    #bc-spot, #bc-spot.in.drift { transition: opacity 0.6s ease; transform: none !important; }
    #bc-spot.in .bc-spot-place, #bc-spot.in .bc-spot-name,
    #bc-spot.in .bc-spot-stats, #bc-spot.in .bc-spot-tb { animation: none; opacity: 1; transform: none; }
}

/* Keep both overlays on their own compositing layer for their whole life, so a browser
   (OBS's especially) never has to re-layer the page as a card appears or leaves —
   promoting and demoting a layer mid-animation is a classic source of a one-frame flash. */
#bc-result, #bc-spot {
    will-change: transform, opacity;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}
