/* Playfair Rivals — the loading screen.
   The first frame is HTML and CSS: no art download, no animation runtime.

   ⛔ IT IS A LOADING SCREEN AND NOTHING ELSE (docs/283, his words: *"it just
   should be loading screen and loading animation"*, and *"when you load game -
   loading screen should say only 'Welcome to Playfair'"*).

   What this file used to carry and no longer does: a 240px arena seal with an
   orbit and six sparks, a SURRIWORKS PRESENTS header, a two-line wordmark with
   an ornament and a tagline, a separate crossed-blades face for a fight with
   the two fighters' names and a VS medallion, a three-segment progress track, a
   three-step stage list, and a footer. Every one of them was a thing to read
   while waiting to play, and he asked for none of them.

   ⭐ ONE ANIMATION SERVES EVERY WAIT. It is the dot ring off his own
   `01 Loading` frame, whose layer name IS the specification: *"Dot ring (8,
   travelling fade)"*, annotated *"eight dots · travelling fade · 1.15s · drawn,
   not loaded"*. Opening the game puts "Welcome to Playfair" above it; every
   other wait shows the ring alone, which then sits in the middle of the screen.

   Motion is transform and opacity only, and nothing runs per frame (root
   CLAUDE.md, docs/77). */

#boot {
  position: fixed; top: 0; left: 50%; transform: translateX(-50%);
  width: min(100%, 412px); height: 100%; height: 100dvh;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto;
  padding: max(56px, env(safe-area-inset-top)) 14px max(28px, env(safe-area-inset-bottom));
  overflow: hidden; isolation: isolate; z-index: 40; text-align: center;
  color: var(--ink);
  /* ⚠️ NOT `--bg`. The screen's own ground is #1b1819, a warm grey, and against
     his frame that read as a grey card behind the bloom — measured at the
     corners, his is (14,5,12) and `--bg` is (27,24,25). This surface is the one
     place in the client that is darker than the game, because the game has not
     started yet. */
  background: #0e060c;
  background-image: radial-gradient(ellipse at 50% 45%, transparent 8%, rgba(9,4,9,.86) 84%);
  transition: opacity .45s ease;
}
#boot[hidden] { display: none; }
#boot.boot-leaving { opacity: 0; }

/* his ground: near-black with a tyrian bloom behind the middle of the screen,
   measured off the frame — it peaks at about `--wine` and is gone by the
   corners. The same register the fight's own cover uses (docs/282). */
.boot-halo {
  position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(ellipse 68% 36% at 50% 47%, rgba(102,2,60,1), transparent 100%),
    radial-gradient(ellipse 48% 21% at 50% 45%, rgba(208,178,122,.11), transparent);
  animation: bootBreathe 6s ease-in-out infinite;
}
@keyframes bootBreathe {
  0%, 100% { opacity: .9; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.03); }
}

/* ── the sign-in banner ───────────────────────────────────────────────────── */
/* ⛔ The loading screen is the front door (docs/244): a signed-out boot inside
   the shell signs in here and never leaves for /login. His own frame puts the
   answer in a card under the camera band, so that is where it goes.
   ⚠️ It stays HIDDEN until there is a name — an empty "Signed in as" is worse
   than nothing, and before sign-in there is nothing true to say. */
.boot-signin {
  /* ⚠️⚠️ EXPLICIT ROW. A `hidden` child is `display:none` and therefore NOT a
     grid item, so with three declared rows and the banner away, `.boot-center`
     slid into the `auto` row and `.boot-foot` into the `1fr` one: the ring
     jumped to the top of the screen and TRY AGAIN floated into the middle.
     Every wait that is not the game opening hides this banner, so that was the
     common case, and only a screenshot of the failed state showed it. */
  grid-row: 1;
  display: none; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: 10px;
  background: var(--card); border: 1px solid rgba(208,178,122,.34);
  text-align: left;
}
.boot-signin:not([hidden]) { display: flex; }
.boot-face {
  flex: 0 0 32px; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(208,178,122,.1); border: 1px solid rgba(208,178,122,.45);
  font-family: var(--serif); font-size: 15px; line-height: 1; color: var(--gold);
}
.boot-named { flex: 1 1 auto; min-width: 0; display: block; }
.boot-named > span {
  display: block; font-family: var(--sans); font-size: 11px; line-height: 14px;
  color: var(--dim);
}
.boot-named b {
  display: block; font-family: var(--sans); font-weight: 700; font-size: 17px; line-height: 21px;
  color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.boot-src {
  flex: 0 0 auto; font-family: var(--sans); font-weight: 600; font-size: 9px;
  letter-spacing: 1.5px; color: var(--gold); text-transform: uppercase;
}

/* ── the middle ───────────────────────────────────────────────────────────── */
/* Centred. When there is nothing to say the heading is `hidden`, the gap goes
   with it, and the ring lands in the middle of the screen on its own — which is
   the whole of a wait that is not the game opening.
   ⛔⛔ IT SPANS EVERY ROW, SO NOTHING ABOVE OR BELOW IT CAN MOVE IT (docs/363, his
   words: *"once you click it - it disappears, and makes 'WELCOME TO PLAYFAIR'
   move a little down for a second. it looks weird."*). It used to be row 2, the
   `1fr` between the banner and the foot — so the middle was the middle of
   WHATEVER WAS LEFT: a failure's words and TRY AGAIN appearing under it lifted
   the welcome by half their height, the press that hid them dropped it again,
   and "Signed in as …" arriving above it on every ordinary boot pushed it down
   by half the banner. Centred in the whole column it answers to nothing but the
   screen. The banner and the foot are drawn over the same rows; neither reaches
   the middle of a phone, and a line-up changes the composition on purpose (below).
   ⚠️ It passes touches through: it now covers the foot's rows, and TRY AGAIN
   must stay the thing a finger finds.
   ⛔⛔ AND EVERY CHILD NAMES ITS COLUMN TOO. Two items only share a cell when
   BOTH are placed there explicitly: with the middle holding column 1 in every
   row, auto-placement put the banner or the foot in a NEW second column, and
   the grid split the phone in half — the welcome wrapped onto three lines in a
   186px column, and it moved again whenever the banner arrived (the first cut
   of this fix; measured, not guessed). docs/301 paid the row half of this rule. */
.boot-signin, .boot-center, .boot-roster, .boot-foot { grid-column: 1; }
.boot-center {
  grid-row: 1 / -1;
  display: grid; align-content: center; justify-items: center; gap: 104px;
  min-height: 0; pointer-events: none;
}
.boot-welcome {
  margin: 0; max-width: 260px;
  font-family: var(--serif); font-weight: 400; font-size: 44px; line-height: 1.2;
  letter-spacing: -.01em; color: var(--ink);
  /* ⚠️ max-width, not a <br>: it wraps after "to" in Marcellus AND in the
     Georgia fallback, so a font that never arrives cannot leave one long line
     clipped against a 390px phone. */
}
.boot-welcome[hidden] { display: none; }

/* ── the dot ring: eight dots, travelling fade, 1.15s ─────────────────────── */
/* ⭐ ONE animation, not eight. The dots hold fixed opacities down the ring and
   the RING turns, in eight steps — so what a player sees is the brightness
   travelling from dot to dot while every dot stays put, which is what a
   travelling fade looks like. Eight separate opacity animations would be eight
   things to keep in phase, and a smooth turn would make the dots visibly orbit,
   which is a different object.
   The ramp is measured off his frame: 1, .9, .79, .68, .58, .48, .38, .29,
   clockwise from twelve o'clock, in --gold. */
.pf-dots {
  position: relative; width: 44px; height: 44px;
  animation: pfDots 1.15s steps(8, end) infinite;
}
.pf-dots i {
  position: absolute; left: 50%; top: 50%; width: 5px; height: 5px; margin: -2.5px;
  border-radius: 50%; background: var(--gold);
}
.pf-dots i:nth-child(1) { transform: rotate(0deg)   translateY(-17px); opacity: 1; }
.pf-dots i:nth-child(2) { transform: rotate(45deg)  translateY(-17px); opacity: .9; }
.pf-dots i:nth-child(3) { transform: rotate(90deg)  translateY(-17px); opacity: .79; }
.pf-dots i:nth-child(4) { transform: rotate(135deg) translateY(-17px); opacity: .68; }
.pf-dots i:nth-child(5) { transform: rotate(180deg) translateY(-17px); opacity: .58; }
.pf-dots i:nth-child(6) { transform: rotate(225deg) translateY(-17px); opacity: .48; }
.pf-dots i:nth-child(7) { transform: rotate(270deg) translateY(-17px); opacity: .38; }
.pf-dots i:nth-child(8) { transform: rotate(315deg) translateY(-17px); opacity: .29; }
@keyframes pfDots { to { transform: rotate(360deg); } }

/* ── the foot: what a failed boot says, and the way out ───────────────────── */
/* ⚠️ The line is SPOKEN always and SHOWN only on failure. It is the only thing
   a screen reader is told while the game loads, and `stage()` keeps writing to
   it — so a wait that says nothing to the eye is not a wait that says nothing
   at all. Clipped rather than `display:none`, which would take it out of the
   accessibility tree and silence the live region. */
.boot-foot { grid-row: 4; display: grid; justify-items: center; gap: 16px; padding-bottom: 34px; }
.boot-line {
  margin: 0; position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.boot-failed .boot-line {
  position: static; width: auto; height: auto; overflow: visible; clip-path: none;
  white-space: normal; max-width: 300px;
  font-family: var(--sans); font-size: 13px; line-height: 1.45; color: var(--ink);
  /* two lines are always kept for it, and its words sit at the BOTTOM of them, next
     to the key — so "Trying again…" and a two-line failure take the same place on
     the glass and nothing under it moves (docs/363) */
  min-height: 2.9em; display: grid; align-content: end;
}
.boot-action { min-height: 0; }
.boot-action button[hidden] { display: none; }
/* a failed boot stops pretending to make progress */
.boot-failed .pf-dots { animation: none; opacity: .4; }

/* ── the press that tries again (docs/363) ──────────────────────────────────── */
/* ⭐ THE KEY STAYS DOWN WHILE IT TRIES. `.key-sm:active` is the press every key in
   the game answers with; a retry holds that press for as long as the attempt
   takes and lets it back up when it can be pressed again — a key that went down
   and has not come back up is a thing still happening, which is what the player
   needs to be told. It keeps the wine, not the disabled grey: grey says "you
   cannot", and this is "I am".
   ⚠️ One width for all four words (TRY AGAIN, TRYING…, CHECK AGAIN, CHECKING…,
   measured at 130 / 111 / 155 / 136 in Marcellus), so the key never changes size
   under the finger that pressed it. */
#boot [data-boot-retry] { min-width: 164px; }
#boot [data-boot-retry][aria-busy="true"] {
  background: var(--wine); color: rgba(228,224,216,.78);
  transform: translateY(3px); box-shadow: 0 1px 0 var(--wine-d);
}
/* ...and his ring turns again, because this IS a wait */
.boot-failed.boot-retrying .pf-dots { animation: pfDots 1.15s steps(8, end) infinite; opacity: 1; }

.boot-noscript {
  position: fixed; bottom: 110px; z-index: 50; padding: 12px;
  background: var(--bg); color: var(--gold); font-size: 13px;
}

@media (max-height: 740px) {
  #boot { padding-top: max(42px, env(safe-area-inset-top)); padding-bottom: max(20px, env(safe-area-inset-bottom)); }
  .boot-center { gap: 76px; }
  .boot-welcome { font-size: 38px; max-width: 230px; }
}
@media (max-height: 640px) {
  #boot { padding-top: max(28px, env(safe-area-inset-top)); }
  .boot-center { gap: 54px; }
  .boot-welcome { font-size: 33px; max-width: 200px; }
}

/* ⚠️ Belt and braces, and the mutation says so. app.css's global rule collapses
   every animation to .001ms AND forces `animation-iteration-count: 1`, so an
   infinite one here finishes instantly and, with no fill, stops being a running
   animation at all — the ring holds its drawn ramp and does not turn. Removing
   these two lines therefore changes NOTHING today, and
   `pf2_loading_check.mjs` cannot tell the difference. They stay because the
   behaviour would otherwise depend on the iteration-count half of a rule in a
   different file: drop that `!important` in app.css some day and this becomes a
   ring spinning thousands of turns a second at the one player who asked for
   stillness. The claim first written here — that app.css alone would do that —
   was simply wrong, and the mutation is what found it. */
@media (prefers-reduced-motion: reduce) {
  .pf-dots, .boot-halo { animation: none !important; }
}

/* ── who is in this fight, while you wait for it (docs/301, 302) ──────────── */
/* ⛔ TWO COLUMNS, yours on the left and theirs on the right, each with its team
   on top and each scrolling DOWN. ⚠️ The scrolling is the phone's own momentum:
   a hand-rolled inertia here would be a second copy of what the platform does
   well, running in the one place the device is busiest. */
/* ⚠️ A LINE-UP CHANGES THE COMPOSITION, not just adds to it. With the ring
   centred in a full-height row the cards sat on the floor and the two read as
   separate screens with 400px of nothing between them. When there is a line-up
   every row takes its natural height and the whole stack is centred. */
#boot.boot-rostered { grid-template-rows: auto auto auto auto; align-content: center; }
/* a line-up is a stack of its own: the middle goes back to its row in it */
#boot.boot-rostered .boot-center { grid-row: 2; gap: 30px; }
#boot.boot-rostered .boot-foot { padding-bottom: 0; }
.boot-roster {
  grid-row: 3;
  position: relative; z-index: 2;
  /* ⚠️ NO WIDTH OF ITS OWN. #boot is already `min(100%, 412px)` with 14px of
     padding, so a child that sets `100vw` and pads again hangs 28px off the
     right edge — the second column ran under the bezel. It fills the box it is
     in. */
  margin: 16px 0 0;
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  min-height: 0; min-width: 0;
}
.boot-roster[hidden] { display: none; }
.br-side { display: grid; gap: 6px; min-height: 0; min-width: 0; }
.br-label {
  text-align: left;
  font-family: var(--sans, system-ui); font-weight: 600; font-size: 9px;
  letter-spacing: 1.6px; text-transform: uppercase; color: rgba(208,178,122,.75);
}
.br-them .br-label { color: rgba(224,92,106,.8); }
.br-rail {
  display: grid; gap: 6px; align-content: start; min-width: 0;
  max-height: 232px; overflow-y: auto; overscroll-behavior-y: contain;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
  padding-bottom: 2px;
}
.br-rail::-webkit-scrollbar { width: 0; height: 0; }
/* a card is a ROW now: the art on the left, the name and level beside it */
/* ⚠️ The level belongs BESIDE the art, under the name — with both texts as
   plain grid children it fell to a third row and the card grew a chin. */
.br-card {
  display: grid; grid-template-columns: 38px 1fr; grid-template-rows: auto auto;
  align-items: center; column-gap: 8px; row-gap: 0;
  padding: 6px 8px 6px 6px; text-align: left;
  border-radius: 10px;
  background: linear-gradient(rgba(255,255,255,.06), rgba(0,0,0,.2)), rgba(34,30,31,.92);
  border: 1px solid rgba(228,224,216,.14);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 3px 8px rgba(0,0,0,.45);
  animation: pf2-br-in 320ms cubic-bezier(.16,1,.3,1) both;
  animation-delay: calc(var(--in, 0) * 70ms);
}
.br-card.mine { border-color: rgba(208,178,122,.4); }
@keyframes pf2-br-in {
  from { transform: translateY(10px) scale(.94); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.br-art {
  grid-row: 1 / 3; grid-column: 1;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 8px; background: rgba(0,0,0,.3);
  box-shadow: inset 0 -2px 0 rgba(0,0,0,.3);
}
.br-art img { width: 32px; height: 32px; object-fit: contain; image-rendering: pixelated; }
.br-letter { font-family: var(--serif, Georgia), serif; font-size: 17px; color: rgba(208,178,122,.9); }
.br-card b {
  grid-column: 2; align-self: end; min-width: 0;
  display: block; font-family: var(--serif, Georgia), serif; font-weight: 400; font-size: 12.5px;
  line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.br-card span {
  grid-column: 2; align-self: start; min-width: 0;
  display: block;
  font-family: var(--mono, monospace); font-size: 9px; color: rgba(228,224,216,.45);
}
/* theirs arrives first and yours a beat later: it is the half you came to see */
.br-you { opacity: 0; transition: opacity 260ms ease-out; }
.br-mine-in .br-you { opacity: 1; }
@media (prefers-reduced-motion: reduce) {
  .br-card { animation: none; }
  .br-you { transition: none; }
}
