/* roby-island (10 Nov): the polish layer (src/polish.js). Motion only: no layout, no colours of record.
   Everything here is off under prefers-reduced-motion. */

/* ---- things leaving the screen (ghostOut): the copy fades while the real element is already hidden */
.ghost { pointer-events: none !important; }
.ghost.ld-out { position: fixed; inset: 0; z-index: 99; background: #2f9be9; animation: polFade .26s ease-out forwards; }
.modal.ghost.card-out { animation: polFade .16s ease-in forwards; }
.modal.ghost.card-out .card { animation: polCardOut .16s cubic-bezier(.4, 0, 1, 1) forwards; }
@keyframes polFade { to { opacity: 0; } }
@keyframes polCardOut { to { transform: scale(.92) translateY(10px); opacity: 0; } }

/* ---- going back slides the other way (app.js go('back')) */
.screen.enter.back { animation-name: polScrBack; }
@keyframes polScrBack { from { opacity: 0; transform: translateY(-12px); } }

/* ---- toasts: tap to dismiss; the newest pushes the others down smoothly */
.toast.bye { animation: polToastBye .16s ease-in forwards; }
@keyframes polToastBye { to { opacity: 0; transform: translateY(-120%); } }

/* ---- every tappable answers the finger. .btn already sinks 5 px; the rest (icon buttons, tabs, slots, pills)
        dim a touch. filter, not transform: many of them are positioned with transforms. */
button:not(.btn):not(:disabled):active, [role="button"]:active, [role="tab"]:active { filter: brightness(.9) saturate(1.1); }
.btn:disabled { transition: filter .15s, opacity .15s; }

/* ---- keyboard focus is visible everywhere (it was the browser default, lost on dark panels) */
:focus-visible { outline: 3px solid #ffd23f; outline-offset: 2px; }
canvas:focus-visible, #stage:focus-visible { outline: none; }

/* ---- state-driven styling (src/fsm.js mirrors each machine on <body>) */
body[data-fsm-boot="failed"] #loading .ld-ring::after { animation-play-state: paused; }
body[data-fsm-raid="attack"] .raid-target { pointer-events: none; }   /* no second pick while the attack plays */

/* ---- a waiting button shows it (add .busy while a server call is out; pairs with disabled) */
.btn.busy { position: relative; color: transparent !important; -webkit-text-stroke: 0 !important; pointer-events: none; }
.btn.busy::after { content: ""; position: absolute; left: 50%; top: 50%; width: 18px; height: 18px; margin: -11px 0 0 -11px; border: 3px solid #fff; border-right-color: transparent; border-radius: 50%; animation: polSpin .7s linear infinite; }
@keyframes polSpin { to { transform: rotate(360deg); } }

/* ---- art that arrives late fades in instead of popping (opt in: class="pol-img") */
img.pol-img { opacity: 0; transition: opacity .2s ease-out; }
img.pol-img.in { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .ghost { display: none !important; }
  .screen.enter.back, .toast.bye, .btn.busy::after { animation: none; }
  img.pol-img { transition: none; opacity: 1; }
}

/* ---- 10 Nov (2): the proposed items ---- */
/* busy(btn, work): a spinner over any button while its server call is out */
.pol-rel { position: relative; }
.pol-busy { pointer-events: none; }
.pol-busy > :not(.pol-spin) { opacity: .35; }
.pol-spin { position: absolute; left: 50%; top: 50%; width: 22px; height: 22px; margin: -14px 0 0 -14px; border: 4px solid #fff; border-right-color: transparent; border-radius: 50%; box-shadow: 0 0 0 1px #14161f33; animation: polSpin .7s linear infinite; z-index: 2; }

/* a READY chest: a hard-edged glint crosses it every 3.6 s (a solid band, no soft scrim) */
.fh-slot.ready .fh-sart::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(105deg, transparent 0 44%, rgba(255, 255, 255, .55) 44% 52%, transparent 52% 56%, rgba(255, 255, 255, .3) 56% 59%, transparent 59%); background-size: 320% 100%; background-position: 130% 0; -webkit-mask: var(--pol-mask, none) center / contain no-repeat; mask: var(--pol-mask, none) center / contain no-repeat; animation: polGlint 3.6s ease-in-out infinite; mix-blend-mode: screen; }
@keyframes polGlint { 0%, 72% { background-position: 130% 0; } 100% { background-position: -30% 0; } }

/* the chest timer rolls when the minute changes */
.fh-time.roll { animation: polRoll .32s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes polRoll { 0% { transform: translateY(-45%); opacity: 0; } 100% { transform: none; opacity: 1; } }

/* the home bird: tapped → a short hop; idle → a blink and a look around (home.js drives both) */
.fh-bird { cursor: pointer; }
.fh-bird.hop > * { animation: polHop .42s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes polHop { 0% { translate: 0 0; scale: 1 1; } 25% { translate: 0 6%; scale: 1.08 .9; } 60% { translate: 0 -22%; scale: .96 1.06; } 100% { translate: 0 0; scale: 1 1; } }
.fh-bird.look > * { animation: polLook 1.1s ease-in-out; }
@keyframes polLook { 0%, 100% { rotate: 0deg; } 30% { rotate: -7deg; } 65% { rotate: 5deg; } }
.pol-blink { position: absolute; pointer-events: none; background: #14161f; border-radius: 40%; transform-origin: center; animation: polBlink .16s ease-in-out; }
@keyframes polBlink { 0%, 100% { transform: scaleY(0); } 50% { transform: scaleY(1); } }

/* a landmark stage goes up: dust, and the island takes the weight */
.pol-puff { position: fixed; z-index: 60; border-radius: 50%; pointer-events: none; box-shadow: 0 0 0 2px #14161f22; }
.pol-nudge { animation: polNudge .38s cubic-bezier(.3, .7, .3, 1); }
@keyframes polNudge { 0% { translate: 0 0; scale: 1; } 30% { translate: 0 5px; scale: 1.012; } 62% { translate: 0 -2px; scale: 1.004; } 100% { translate: 0 0; scale: 1; } }

@media (prefers-reduced-motion: reduce) {
  .fh-slot.ready .fh-sart::after, .pol-spin { animation: none; }
  .fh-slot.ready .fh-sart::after { display: none; }
  .fh-time.roll, .fh-bird.hop > *, .fh-bird.look > *, .pol-nudge { animation: none; }
  .pol-blink, .pol-puff { display: none; }
}

/* 12 Nov UI pass on the older screens (Roby: one look everywhere): Settings, Events, Trophy Road, Activity, Profile,
   Friends and the 7-day calendar speak in the game's face (Futura Bold / League Spartan Bold), in capitals, like the new
   screens. Typed fields keep the player's own case. Toasts follow. */
:is(#s-settings, #s-events, #s-trophyroad, #s-activity, #s-profile, #s-friends, #s-daily, #s-worldmap) :is(p, small, b, strong, em, h1, h2, h3, h4, span, div, label, button, li, a) {
  font-family: var(--font-ui); font-weight: 700; text-transform: uppercase; letter-spacing: .01em; }
:is(#s-settings, #s-events, #s-trophyroad, #s-activity, #s-profile, #s-friends, #s-daily) :is(input, textarea, select) { text-transform: none; }
.toast, .toast-bar { font-family: var(--font-ui); font-weight: 700; text-transform: uppercase; letter-spacing: .02em; }
/* (Settings' button grid: one line per button, the label shrinks to fit rather than wrapping) */
#s-settings .btn.xs, #s-settings .btn.sm { white-space: nowrap; letter-spacing: 0; padding-left: 4px; padding-right: 4px; font-size: var(--f36)!important; overflow: hidden; text-overflow: clip; --ow: 5.2; }
/* The in-game alert pill speaks the game's face too, and steps aside while a card is open (it covered card titles) */
.perch, .perch * { font-family: var(--font-ui) !important; font-weight: 700; text-transform: uppercase; }
body:has(#modal:not([hidden])) .perch { display: none; }
/* Older cards (How to play, Rewards & odds, Rescue log…) in the game's face; their sentences keep their case */
#modal .card :is(p, li, small, b, strong, em, span, div, label, td, th) { font-family: var(--font-ui); font-weight: 700; }
/* Rewards & odds: a pocket's name never runs under its odds pill */
.board-rewards .br-row { grid-template-columns: 44px minmax(0, 1fr) auto auto; }
.board-rewards .br-row b { line-height: 1.1; }
.board-rewards .br-row { grid-template-columns: 40px minmax(76px, 1fr) auto minmax(0, auto); gap: 8px; }
.board-rewards .br-row span { white-space: normal; flex-wrap: wrap; justify-content: flex-end; text-align: right; }
.board-rewards .note img { width: 16px; height: 16px; vertical-align: -3px; }
/* (race result: a tapped CONTINUE / PLAY AGAIN shows it was taken while the next screen loads) */
#raceResult .busy { filter: brightness(.8) saturate(.8); transform: translateY(2px) scale(.97); pointer-events: none; transition: transform .08s, filter .08s; }
#raceResult .busy ~ .busy, #raceResult :is(#raceAgain, #raceHome).busy:not(:focus) { opacity: .85; }

/* ==== 13 Nov: Siddharth's Figma review (comments #1-#55 on "Final Screens") ==== */
/* #6: a two-digit nav badge grows to the left from the tab's corner (style.css's old right: 6% squeezed it to its
   minimum, so "16" ran out of the circle); no text stroke on it */
.fc-nav .fc-badge.tab-badge { left: auto !important; right: calc(var(--m) * 12); white-space: nowrap; -webkit-text-stroke: 0; }
/* #9, #10, #14, #15: the race banner: GAME OVER is the kit's title art, the other heads are lettered like it, the
   line under them is the mock's sub-line (white capitals, a black outline) */
.race-banner { isolation: isolate; }
.race-banner .rb-art { display: block; margin: 0 auto; width: calc(var(--colw, 390px) * .72); height: auto; }
.race-banner b { position: relative; display: inline-block; font-family: var(--font-ui); font-weight: 700; text-transform: uppercase; letter-spacing: 0; line-height: 1.1; text-shadow: none; -webkit-text-stroke: 0;
  background: linear-gradient(#fff36b 8%, #ffd21c 42%, #ff9a05 88%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.race-banner b::before { content: attr(data-t); position: absolute; inset: 0; z-index: -1; color: #0d1c52; -webkit-text-stroke: min(18px, calc(var(--colw, 390px) * .038)) #0d1c52; paint-order: stroke fill; }
.race-banner span { display: block; margin-top: .25em; font-family: var(--font-ui); font-weight: 700; text-transform: uppercase; color: #fff; -webkit-text-stroke: calc(var(--m) * var(--ow, 5.5) * 2) var(--oc); paint-order: stroke fill; }
/* #11: the pause button's bars where the mock has them (11 x 49 at 34 / 54, 25 in the 100 px button; they sat 2.5 up and left) */
.race-stage .race-pause::before, .race-stage .race-pause::after { top: calc(var(--u) * 24.2); width: calc(var(--u) * 8.6); height: calc(var(--u) * 38.3); }
.race-stage .race-pause::before { left: calc(var(--u) * 31.25); }
.race-stage .race-pause::after { left: calc(var(--u) * 46.9); }
/* #13, #17: LEAVE RACE? / PAUSED and ELIMINATED are the mock's popup (the chest card: the blue panel, the title, a
   light panel, 130 px button rows) */
.race-pausecard .card.race-pop { animation: none; }
.rpop-panel { box-sizing: border-box; min-height: calc(var(--m) * 200); padding: calc(var(--m) * 40) calc(var(--m) * 36); border-radius: calc(var(--m) * 20); background: linear-gradient(#fff, #9de4fd);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: calc(var(--m) * 22); }
.card.race-pop .rpop-note { margin: 0; font: 700 var(--f40)/1.15 var(--font-ui); text-transform: uppercase; text-align: center; color: #0f3f86; --ow: 5.5; }
.card.race-pop .rpop-note.sm { font-size: var(--f32); color: #2a6fb5; --ow: 4.5; }
.card.race-pop .rpop-note:empty { display: none; }
.card.race-pop .cc-row { display: flex; align-items: center; justify-content: center; font: 700 var(--f40)/1 var(--font-ui); color: #fff; text-transform: uppercase;
  -webkit-text-stroke: calc(var(--m) * var(--ow, 5.5) * 2) var(--oc); paint-order: stroke fill; --ow: 5.5; }
.cc-row.blue { background: linear-gradient(#5dc2fd, #2b8ce5); box-shadow: 0 0 0 calc(var(--m) * 5) #000, inset 0 calc(var(--m) * -10) 0 #0159a4, inset 0 calc(var(--m) * 5) 0 #fff; }
/* #54: OUT OF PINBALLS on the same popup */
.cc-row.grey { background: linear-gradient(#eef1f6, #a3adc0); box-shadow: 0 0 0 calc(var(--m) * 5) #000, inset 0 calc(var(--m) * -10) 0 #6b7386, inset 0 calc(var(--m) * 5) 0 #fff; }
.card.race-pop .cc-row { gap: calc(var(--m) * 14); }
.card.race-pop .cc-row .g-chip { font-size: var(--f24); -webkit-text-stroke: 0; white-space: nowrap; --ow: 4; }
.rpop-panel .oob-ball { display: block; width: calc(var(--m) * 170); height: auto; }
/* #23: the trophy bar fills as trophies land in it, and the cup bumps */
.wb-fill { transition: width .6s cubic-bezier(.2, .8, .3, 1); }
.wb-cup.bump { animation: hudPump .3s; }
/* #21: the Home alert ("YOU CAN RAISE THE BIRDHOUSE") in the mock's toast (Race 289:436, Rectangle 93: a black rounded
   box, radius 20, white 36 px text with a black outline); it was a navy pill with a gold border */
.perch { background: #000000cc; border: 0; border-radius: calc(var(--m) * 20); box-shadow: none; min-height: calc(var(--m) * 100); gap: calc(var(--m) * 20);
  padding: calc(var(--m) * 14) calc(var(--m) * 16) calc(var(--m) * 14) calc(var(--m) * 30); max-width: calc(var(--colw, 100vw) - 16px); }
.perch.drop { animation: none; }
.perch .pc-ico { display: none; }
.perch .pc-t { font-size: var(--f36); line-height: 1.1; --ow: 5.2; }
.perch .pc-t b, .perch .pc-t small { color: #fff; -webkit-text-stroke: calc(var(--m) * var(--ow, 5.5) * 2) var(--oc); paint-order: stroke fill; }
.perch.t-raided .pc-t b { color: #ff8a8a; }
.perch .pc-act { min-height: calc(var(--m) * 72); padding: 0 calc(var(--m) * 26) calc(var(--m) * 6); border-radius: calc(var(--m) * 14); font-size: var(--f32); color: #fff;
  -webkit-text-stroke: calc(var(--m) * var(--ow, 5.5) * 2) var(--oc); paint-order: stroke fill; background: linear-gradient(#f9e51a, #fc9407);
  box-shadow: 0 0 0 calc(var(--m) * 4) #000, inset 0 calc(var(--m) * -8) 0 #af3f01, inset 0 calc(var(--m) * 4) 0 #fff; margin: calc(var(--m) * 4); --ow: 4.5; }
