/* =====================================================================
   ICA CRICKET OLYMPIAD - SHARED CRICKET EFFECTS  (added 21-11-2026)
   Loaded on every page (candidate, admin, home). Works with
   assets/js/ica-fx.js. Remove both files' <link>/<script> tags to switch
   everything here off. Every effect stops for visitors who turn on
   "Reduce motion" in their device settings.

   1. Floodlight switch-on (first page of each visit)      README #1
   2. Scoreboard digits                                    README #3, #26
   3. Stitched-seam underline (sidebar nav, footer links)   README #4
   4. Cursor ball (home page, desktop only)                 README #5
   5. Scroll reveal from fielding positions (home page)     README #7
   6. One-shot confetti burst (result page)                 README #17
   ===================================================================== */

/* ---------- 1. FLOODLIGHT SWITCH-ON ----------
   html.fl-intro is added by a tiny script in <head> only on the first page
   of a browser visit (session cookie "icaLights", cleared when the browser closes). The photo starts dark, flickers and
   comes up to full brightness; two glows pulse on the lamp heads. */
html.fl-intro body::before {                     /* dark while the photo downloads ... */
  filter: blur(var(--site-bg-blur, 5px)) saturate(.6) brightness(.12);
}
html.fl-intro.fl-go body::before {               /* ... then the lights come on (ica-fx.js adds fl-go) */
  animation: flOn 1.35s linear both;
}
@keyframes flOn {
  0%, 14% { filter: blur(var(--site-bg-blur, 5px)) saturate(.6)  brightness(.12); }
  18%     { filter: blur(var(--site-bg-blur, 5px)) saturate(.9)  brightness(.75); }
  23%     { filter: blur(var(--site-bg-blur, 5px)) saturate(.7)  brightness(.22); }
  30%     { filter: blur(var(--site-bg-blur, 5px)) saturate(1)   brightness(.95); }
  35%     { filter: blur(var(--site-bg-blur, 5px)) saturate(.8)  brightness(.45); }
  55%     { filter: blur(var(--site-bg-blur, 5px)) saturate(1.1) brightness(1.18); }
  100%    { filter: blur(var(--site-bg-blur, 5px)) saturate(1.08) brightness(1); }
}
.fl-glow {
  position: fixed; z-index: -1; pointer-events: none;
  width: var(--fl-size, 26vmin); height: var(--fl-size, 26vmin);
  margin: calc(var(--fl-size, 26vmin) / -2) 0 0 calc(var(--fl-size, 26vmin) / -2);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.95) 0, rgba(214,232,255,.6) 12%, rgba(120,170,255,.22) 34%, rgba(90,140,255,0) 68%);
  mix-blend-mode: screen;
  opacity: var(--fl-rest, .3);
  transition: opacity .6s;
}
html.fl-intro .fl-glow { opacity: 0; }
html.fl-intro.fl-go .fl-glow { animation: flGlow 2.2s ease-out both; }
@keyframes flGlow {
  0%, 14% { opacity: 0;   transform: scale(.4); }
  18%     { opacity: .9;  transform: scale(.9); }
  23%     { opacity: .1;  transform: scale(.6); }
  30%     { opacity: 1;   transform: scale(1.05); }
  35%     { opacity: .35; transform: scale(.85); }
  50%     { opacity: 1;   transform: scale(1.25); }
  68%     { opacity: .55; transform: scale(1); }
  82%     { opacity: .85; transform: scale(1.12); }
  100%    { opacity: var(--fl-rest, .3); transform: scale(1); }
}
body.admin-body { --fl-rest: .12; }
body.exam-body  { --fl-rest: 0; }

/* ---------- 2. SCOREBOARD DIGITS ----------
   ica-fx.js turns the text of any [data-scoreboard] element into rolling
   digit strips. Each digit spins through 0-9 and stops on its value, one
   after another from left to right, with an LED glow while rolling. */
/* digits always take the size/colour of the number they replace, even if the page styles "span" inside it */
.sbd, .sbd span { font-size: inherit !important; font-weight: inherit !important; color: inherit !important; letter-spacing: inherit;
  margin: 0 !important; padding: 0 !important; border: 0 !important; background: none !important; box-shadow: none !important; }
.sbd { -webkit-user-select: none; user-select: none; display: inline-flex; align-items: flex-end; line-height: 1.12; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sbd-d { display: inline-block; height: 1.12em; overflow: hidden; vertical-align: bottom; }
.sbd-s { display: flex; flex-direction: column; transform: translateY(calc(var(--n, 0) * -1.12em));
  transition: transform var(--sb-dur, 1.1s) cubic-bezier(.22,.9,.28,1) var(--sb-delay, 0s); }
.sbd-s > span { display: block; height: 1.12em; text-align: center; }
.sbd-c { display: inline-block; }
.sbd.rolling .sbd-d { text-shadow: 0 0 10px rgba(255,198,41,.75), 0 0 22px rgba(255,170,20,.35); }
.sbd-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- 3. STITCHED-SEAM UNDERLINE ----------
   A red ball seam with white stitches draws in from the left on hover. */
.side-nav a > span,
.foot .ln a, .guest-foot a, .app-foot a { position: relative; }
.side-nav a > span::after,
.foot .ln a::after, .guest-foot a::after, .app-foot a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -5px; height: 6px; pointer-events: none;
  background:
    repeating-linear-gradient(90deg, rgba(255,244,236,.95) 0 3px, transparent 3px 7px) 0 0 / 100% 1.5px no-repeat,
    linear-gradient(#d7262e, #a3121a) 0 2px / 100% 2px no-repeat,
    repeating-linear-gradient(90deg, rgba(255,244,236,.95) 0 3px, transparent 3px 7px) 2px 4.5px / 100% 1.5px no-repeat;
  filter: drop-shadow(0 0 3px rgba(226,48,42,.55));
  transform: scaleX(0); transform-origin: left center;
  transition: transform .38s cubic-bezier(.3,.8,.3,1);
}
.side-nav a:hover > span::after, .side-nav a:focus-visible > span::after,
.foot .ln a:hover::after, .foot .ln a:focus-visible::after,
.guest-foot a:hover::after, .app-foot a:hover::after { transform: scaleX(1); }

/* ---------- 4. CURSOR BALL (home page, mouse/trackpad only) ---------- */
.fx-trail { position: fixed; left: 0; top: 0; z-index: 9999; width: 16px; height: 16px; pointer-events: none;
  opacity: 0; transition: opacity .25s; will-change: transform; }
.fx-trail.on { opacity: 1; }
.fx-trail svg { display: block; width: 100%; height: 100%; filter: drop-shadow(0 3px 4px rgba(0,0,0,.45)) drop-shadow(0 0 6px rgba(255,90,60,.45)); }
.fx-trail i { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%;
  background: rgba(255,120,90,.55); opacity: 0; }

/* ---------- 5. SCROLL REVEAL FROM FIELDING POSITIONS ----------
   cover = comes in from the off side, low
   mid-wicket = from the leg side, low
   slip = from behind, high and to the right
   Uses the separate translate / rotate properties so it never fights the
   cards' own hover transforms. */
.fx-field.fx-field {
  opacity: 0;
  translate: var(--fx-x, 0) var(--fx-y, 40px);
  rotate: var(--fx-r, 0deg);
  transition: opacity .6s ease var(--fx-delay, 0s), translate .85s cubic-bezier(.2,.8,.2,1) var(--fx-delay, 0s), rotate .85s cubic-bezier(.2,.8,.2,1) var(--fx-delay, 0s),
              transform .3s ease, box-shadow .3s ease, border-color .3s ease, background .3s ease;
}
.fx-field.fx-cover      { --fx-x: -70px; --fx-y: 46px;  --fx-r: -4deg; }
.fx-field.fx-midwicket  { --fx-x: 70px;  --fx-y: 46px;  --fx-r: 4deg; }
.fx-field.fx-slip       { --fx-x: 46px;  --fx-y: -50px; --fx-r: 6deg; }
.fx-field.fx-field.fx-in { opacity: 1; translate: 0 0; rotate: 0deg; }

/* ---------- 6. ONE-SHOT CONFETTI (same pieces and colours as the home page) ---------- */
.fx-confetti { position: absolute; left: 50%; top: 50%; width: 0; height: 0; z-index: 6; pointer-events: none; }
.fx-confetti i { position: absolute; left: 0; top: 0; width: var(--w); height: var(--h); margin: calc(var(--h) / -2) 0 0 calc(var(--w) / -2);
  border-radius: 2px; background: var(--c); opacity: 0; box-shadow: 0 0 6px rgba(255,255,255,.35);
  animation: fxBurst 2.6s cubic-bezier(.2,.7,.3,1) var(--d) both; }
.fx-confetti i:nth-child(4n+1) { border-radius: 50%; }
@keyframes fxBurst {
  0%   { opacity: 0; transform: translate(0, 0) rotate(0) scale(.3); }
  6%   { opacity: 1; }
  45%  { opacity: 1; transform: translate(var(--x), var(--y)) rotate(var(--r)) scale(1); }
  100% { opacity: 0; transform: translate(calc(var(--x) * 1.25), calc(var(--y) + 170px)) rotate(calc(var(--r) * 2)) scale(.85); }
}

@media (prefers-reduced-motion: reduce) {
  html.fl-intro body::before, html.fl-intro .fl-glow { animation: none !important; }
  .sbd-s { transition: none !important; }
  .side-nav a > span::after, .foot .ln a::after, .guest-foot a::after, .app-foot a::after { transition: none; }
  .fx-trail { display: none !important; }
  .fx-field.fx-field { opacity: 1 !important; translate: none !important; rotate: none !important; }
  .fx-confetti { display: none !important; }
}
@media print {
  .fl-glow, .fx-trail, .fx-confetti { display: none !important; }
}
