/* Home Screen lobby layout (Clement, 2026-11-28; Vault board 1206). See home-lobby.js.
 *
 * One hero, centre stage, full-tall, on a ground spot; three back spots for teammates; the mode
 * card with PLAY on the left (under the stage on a phone). Loaded after styles.css, experience.css
 * and piece-idle.css, and scoped under .home-party so it outranks the old four-figure squad rules
 * without editing them.
 *
 * No animation is declared in this file. The figures' only motion is the one MM-16 idle that
 * piece-life.js / piece-idle.css already run, which Reduced Motion, Performance Mode and Calm still.
 *
 * Sizes are in container units of the stage (.home-party), so the hero is tall in whatever room
 * the stage has: --home-fig is the height of the visible figure, head to toe.
 */
#screen-lobby .home-hero .home-party {
  container-type: size;
  overflow: hidden;
  /* HEADROOM (Clement, 2026-11-28): the clear space between the top of the stage and the top of the
     hero's head is what keeps the Home Screen clean, so it is one value and the hero's height is
     derived from it: the figure fills the stage from its feet (--home-hero-y) up to the headroom.
     Nothing is drawn in that space above the hero: the name tag sits in the stage's top-left corner.
     The width cap only guards very wide figures on narrow stages; it does not normally bind. */
  --home-headroom: clamp(36px, 12cqh, 160px);
  --home-fig: min(calc(100cqh - var(--home-headroom) - var(--home-hero-y)), 62cqw);
  --home-hero-x: 50cqw;
  --home-hero-y: 15cqh;
  /* Where the figure stands in its square frame: share of the frame the figure fills, and the gap
     under its feet. The baked 200px figure frames (frameFill 0.70) and the painted portraits differ. */
  --home-fill: .95;
  --home-foot-gap: .02;
}

/* The old squad header ("<name>'s squad / Ready to play") is replaced by the hero's name tag. The
   node stays: lobby.js, experience.js and profile.js still write the name into it. */
#screen-lobby .home-hero .home-party .party-status { display: none; }

/* ---------------------------------------------------------------- the hero ---- */
#screen-lobby .home-hero .home-party .lobby-character.home-hero-piece {
  --character-x: var(--home-hero-x);
  position: absolute;
  z-index: 5;
  top: auto;
  right: auto;
  bottom: var(--home-hero-y);
  left: var(--home-hero-x);
  width: 0;
  height: 0;
  transform: none;
  animation: none;
  filter: drop-shadow(0 18px 20px rgba(8, 5, 30, .42));
}
#screen-lobby .home-hero .home-party .lobby-character.home-hero-piece::before { content: none; }

#screen-lobby .home-hero .home-party .home-hero-piece > img {
  --home-img: calc(var(--home-fig) / var(--home-fill));
  position: absolute;
  bottom: calc(var(--home-img) * var(--home-foot-gap) * -1);
  left: calc(var(--home-img) / -2);
  width: var(--home-img);
  max-width: none;
  height: auto;
  aspect-ratio: 1 / 1;
  pointer-events: none;
}
#screen-lobby .home-hero .home-party .home-hero-piece > img[data-squad-3d] {
  --home-fill: .70;
  --home-foot-gap: .165;
}

/* ------------------------------------------------------------ ground spots ---- */
#screen-lobby .home-hero .home-party .home-spot {
  font-style: normal;
  position: absolute;
  display: block;
  border-radius: 50%;
}

/* The hero's spot: lit in the hero's colour. */
#screen-lobby .home-hero .home-party .home-spot-hero {
  --spot-w: calc(var(--home-fig) * .64);
  z-index: -1;
  bottom: calc(var(--spot-w) * -.13);
  left: calc(var(--spot-w) / -2);
  width: var(--spot-w);
  height: calc(var(--spot-w) * .26);
  border: 2px solid color-mix(in srgb, var(--character-color), white 30%);
  background:
    radial-gradient(ellipse at 50% 45%, color-mix(in srgb, var(--character-color), white 45%) 0%, color-mix(in srgb, var(--character-color), transparent 35%) 58%, color-mix(in srgb, var(--character-color), transparent 70%) 100%);
  box-shadow:
    0 0 26px color-mix(in srgb, var(--character-color), transparent 20%),
    0 0 70px color-mix(in srgb, var(--character-color), transparent 55%),
    inset 0 0 22px rgba(255, 255, 255, .35);
}

/* Back spots: pale discs. A teammate stands on a filled one; open and closed ones are empty. */
#screen-lobby .home-hero .home-party .home-spots {
  position: absolute;
  z-index: 2;
  inset: 0;
  pointer-events: none;
}
#screen-lobby .home-hero .home-party .home-spot-back {
  --spot-x: 50cqw;
  --spot-y: 30cqh;
  --spot-scale: .6;
  --spot-w: calc(var(--home-fig) * .64 * var(--spot-scale));
  --mate-color: #ffffff;
  bottom: calc(var(--spot-y) - var(--spot-w) * .13);
  left: calc(var(--spot-x) - var(--spot-w) / 2);
  width: var(--spot-w);
  height: calc(var(--spot-w) * .26);
  border: 1px solid rgba(255, 255, 255, .5);
  background: radial-gradient(ellipse at 50% 40%, rgba(255, 255, 255, .5), rgba(226, 228, 255, .26) 62%, rgba(226, 228, 255, .12) 100%);
  box-shadow: 0 6px 18px rgba(8, 5, 30, .3), inset 0 0 12px rgba(255, 255, 255, .28);
}
#screen-lobby .home-hero .home-party .home-spot-back[data-slot-state="closed"] { opacity: .5; }
#screen-lobby .home-hero .home-party .home-spot-back[data-slot-state="open"] { opacity: .9; }
#screen-lobby .home-hero .home-party .home-spot-back[data-slot-state="filled"] {
  border-color: color-mix(in srgb, var(--mate-color), white 35%);
  background: radial-gradient(ellipse at 50% 40%, color-mix(in srgb, var(--mate-color), white 50%), color-mix(in srgb, var(--mate-color), transparent 55%) 70%);
  box-shadow: 0 0 22px color-mix(in srgb, var(--mate-color), transparent 40%), inset 0 0 12px rgba(255, 255, 255, .3);
}
#screen-lobby .home-hero .home-party .home-spot-back[data-team="blue"] { --mate-color: #52aaff; }
#screen-lobby .home-hero .home-party .home-spot-back[data-team="yellow"] { --mate-color: #ffd751; }
#screen-lobby .home-hero .home-party .home-spot-back[data-team="red"] { --mate-color: #ff5b6c; }
#screen-lobby .home-hero .home-party .home-spot-back[data-team="green"] { --mate-color: #50e997; }

/* The formation (Clement's reference, 2026-11-28): a tight group, not a spread. The hero is front and
   largest; teammates stand close behind, one at its left shoulder and two stepping back to the right,
   each on its own spot, overlapping like people standing together.
   The spacing is one rule: the four figures stand one PITCH apart along the row (left teammate,
   hero, right teammate, far-right teammate), and each row back is one STEP further up the floor and
   one size smaller. Pitch and step are in hero heights (--home-fig), so the group keeps exactly this
   shape at every screen size. Tuned on the Sahara set, whose four figures share one build.
   TUCK: the far-right figure is smaller, so at a full pitch it would overlap its neighbour less than
   the others do. It stands a little closer, so every neighbouring pair overlaps by the same amount.
   Measured on the rendered Sahara figures (blue, red, green, yellow, left to right). */
#screen-lobby .home-hero .home-party {
  --form-pitch: .37;
  --form-tuck: .022;
  --form-step: .09;
  --form-near: .88;
  --form-far: .78;
}
#screen-lobby .home-hero .home-party .home-spot-back[data-home-slot="1"] { --spot-x: calc(var(--home-hero-x) - var(--home-fig) * var(--form-pitch)); --spot-y: calc(var(--home-hero-y) + var(--home-fig) * var(--form-step)); --spot-scale: var(--form-near); }
#screen-lobby .home-hero .home-party .home-spot-back[data-home-slot="2"] { --spot-x: calc(var(--home-hero-x) + var(--home-fig) * var(--form-pitch)); --spot-y: calc(var(--home-hero-y) + var(--home-fig) * var(--form-step)); --spot-scale: var(--form-near); }
#screen-lobby .home-hero .home-party .home-spot-back[data-home-slot="3"] { --spot-x: calc(var(--home-hero-x) + var(--home-fig) * (var(--form-pitch) * 2 - var(--form-tuck))); --spot-y: calc(var(--home-hero-y) + var(--home-fig) * var(--form-step) * 2); --spot-scale: var(--form-far); }

/* A teammate's piece on a back spot: same framing rules as the hero, smaller. */
#screen-lobby .home-hero .home-party .home-spot-back > img {
  --home-fill: .95;
  --home-foot-gap: .02;
  --mate-img: calc(var(--home-fig) * var(--spot-scale) / var(--home-fill));
  position: absolute;
  bottom: calc(50% - var(--mate-img) * var(--home-foot-gap));
  left: calc(50% - var(--mate-img) / 2);
  width: var(--mate-img);
  max-width: none;
  height: auto;
  aspect-ratio: 1 / 1;
  /* Above every back spot's disc, so a far spot never paints over a nearer teammate's legs. */
  z-index: 2;
  filter: drop-shadow(0 10px 12px rgba(8, 5, 30, .4));
}
/* The far-right spot stands behind the right-hand one. */
#screen-lobby .home-hero .home-party .home-spot-back[data-home-slot="3"] > img { z-index: 1; }
#screen-lobby .home-hero .home-party .home-spot-back > img[data-squad-3d] {
  --home-fill: .70;
  --home-foot-gap: .165;
}
/* A teammate's name sits over their head, clear of the feet, the spots and the Locker link. */
#screen-lobby .home-hero .home-party .home-spot-back > span {
  position: absolute;
  z-index: 3;
  bottom: calc(50% + var(--home-fig) * var(--spot-scale) + 4px);
  left: 50%;
  max-width: 28cqw;
  padding: 3px 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(8, 8, 30, .62);
  color: rgba(255, 255, 255, .86);
  font-size: .62rem;
  font-weight: 800;
  letter-spacing: .03em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  transform: translateX(-50%);
  white-space: nowrap;
}

/* ------------------------------------------------- name tag and Locker link ---- */
#screen-lobby .home-hero .home-party .home-hero-tag {
  position: absolute;
  z-index: 6;
  top: clamp(8px, 2cqh, 18px);
  left: clamp(10px, 3cqw, 48px);
  max-width: 30cqw;
  padding: 5px 12px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(8, 8, 30, .5);
  color: #fff;
  font-size: clamp(.78rem, 1.1vw, .95rem);
  font-weight: 800;
  text-overflow: ellipsis;
  text-shadow: 0 2px 10px rgba(6, 4, 24, .7);
  white-space: nowrap;
  pointer-events: none;
}

#screen-lobby .home-hero .home-party .home-locker-link {
  position: absolute;
  z-index: 7;
  bottom: clamp(6px, 2cqh, 22px);
  left: var(--home-hero-x);
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  max-width: 86cqw;
  padding: 8px 16px;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: 999px;
  background: rgba(10, 10, 34, .72);
  color: #fff;
  font: inherit;
  cursor: pointer;
  transform: translateX(-50%);
  pointer-events: auto;
  backdrop-filter: blur(10px);
}
#screen-lobby .home-hero .home-party .home-locker-link > span {
  overflow: hidden;
  font-size: .78rem;
  font-weight: 900;
  letter-spacing: .04em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}
#screen-lobby .home-hero .home-party .home-locker-link > small {
  flex: 0 0 auto;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f3ff20;
  color: #151724;
  font-size: .6rem;
  font-weight: 900;
  letter-spacing: .04em;
  text-transform: uppercase;
  white-space: nowrap;
}
#screen-lobby .home-hero .home-party .home-locker-link:hover { border-color: rgba(243, 255, 32, .6); }
#screen-lobby .home-hero .home-party .home-locker-link:focus-visible {
  outline: 3px solid #f3ff20;
  outline-offset: 2px;
}

/* ------------------------------------------------------------------ layouts ---- */
/* Narrow desktop / tablet landscape: keep the hero clear of the mode card on the left. */
@media (min-width: 901px) and (max-width: 1200px) {
  #screen-lobby .home-hero .home-party { --home-hero-x: 60cqw; --home-fig: min(calc(100cqh - var(--home-headroom) - var(--home-hero-y)), 60cqw); }
}

/* Phone and tablet portrait: the stage is the room above the mode card. The hero takes the middle,
   two spots flank it and the third stands further back on the right. */
@media (max-width: 900px) {
  #screen-lobby .home-hero .home-party {
    --home-fig: min(calc(100cqh - var(--home-headroom) - var(--home-hero-y)), 125cqw);
    --home-hero-x: 50cqw;
    --home-hero-y: 58px;
  }
  /* The name sits in the stage's top-left corner, clear of the hero's head at every phone height. */
  #screen-lobby .home-hero .home-party .home-hero-tag {
    top: 8px;
    bottom: auto;
    left: 10px;
    max-width: 30cqw;
    transform: none;
  }
  /* With teammates on the stage, the whole group must fit a phone's width with equal margins left
     and right. The group, not the hero alone, is centred, so the hero stands left of the middle (as
     in the reference, where the party extends to the hero's right).
     The hero stands .167 hero heights left of the middle; that centres the group (measured on the
     rendered Sahara figures: equal margins left and right). */
  #screen-lobby .home-hero .home-party[data-home-party="on"] {
    --home-fig: min(calc(100cqh - var(--home-headroom) - var(--home-hero-y)), 66cqw);
    --home-hero-x: calc(50cqw - var(--home-fig) * .167);
    --form-pitch: .36;
  }
  #screen-lobby .home-hero .home-party[data-home-party="on"] .home-spot-back > span { max-width: 20cqw; }

  /* The mode card is what limits the hero's height on a phone, so it is kept short: title, then the
     mode and Change game side by side, then PLAY. */
  #screen-lobby .home-hero .home-mode-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 8px;
    padding: 10px 12px 12px;
  }
  #screen-lobby .home-hero .home-mode-panel > .mode-eyebrow,
  #screen-lobby .home-hero .home-mode-panel > h2,
  #screen-lobby .home-hero .home-mode-panel > p,
  #screen-lobby .home-hero .home-mode-panel > .home-play-button { grid-column: 1 / -1; }
  #screen-lobby .home-hero .home-mode-panel > .mode-eyebrow { margin-bottom: 4px; }
  #screen-lobby .home-hero .home-mode-panel > h2 { font-size: clamp(1.4rem, 6.4vw, 1.9rem); }
  #screen-lobby .home-hero .home-mode-panel > p { margin: 3px 0 8px; font-size: .68rem; }
  #screen-lobby .home-hero .home-mode-panel > .queue-picker { grid-column: 1; grid-row: 4; margin-bottom: 8px; }
  #screen-lobby .home-hero .home-mode-panel > .home-change-button {
    grid-column: 2;
    grid-row: 4;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 2px;
    min-height: 46px;
    margin: 0 0 8px;
    padding: 6px 10px;
    text-align: left;
  }
  #screen-lobby .home-hero .home-mode-panel > .home-play-button { grid-row: 5; min-height: 54px; }
}

/* Phone landscape: mode card left, hero right of it. */
@media (max-width: 900px) and (max-height: 500px) and (orientation: landscape) {
  #screen-lobby .home-hero .home-party {
    --home-fig: min(calc(100cqh - var(--home-headroom) - var(--home-hero-y)), 40cqw);
    --home-hero-x: 68cqw;
    --home-hero-y: max(16cqh, 54px);
  }
  /* With teammates: the group is centred in the room to the right of the mode card. */
  #screen-lobby .home-hero .home-party[data-home-party="on"] {
    --home-fig: min(calc(100cqh - var(--home-headroom) - var(--home-hero-y)), 36cqw);
    --home-hero-x: calc(68.5cqw - var(--home-fig) * .167);
  }
  #screen-lobby .home-hero .home-party .home-hero-tag { top: 6px; bottom: auto; left: auto; right: 10px; }
}

/* ------------------------------------------------- Home Screen backgrounds ---- */
/* Vault board 1210. The equipped background's scene replaces the starter scene behind the hero; the
   starter gradient stays underneath while it loads. home-lobby.js sets --home-scene from the Locker's
   body[data-home-background]. A still picture: no motion. */
#screen-lobby .home-lobby-art[data-home-scene] {
  background:
    var(--home-scene) 50% 68% / cover no-repeat,
    linear-gradient(145deg, #201144, #a83b76 60%, #ff934d);
}

/* Portrait phones and tablets: the picture is scaled by the screen's height, so its floor starts at a
   fixed share of the screen (about 60% down), while the hero's feet sit higher on a short phone because
   the mode card takes the bottom (57% down at 360x640): the hero stood on the horizon. The scene is
   drawn 30% larger and anchored to the bottom, which lifts the floor line to about 48% down, under the
   feet at every portrait size. Applies to the starter scene and to every sold background. */
@media (max-width: 900px) and (orientation: portrait) {
  #screen-lobby .home-lobby .home-lobby-art {
    background-size: auto 130%, auto;
    background-position: 58% 100%, 0 0;
  }
  #screen-lobby .home-lobby .home-lobby-art[data-home-scene] {
    background-size: auto 130%, auto;
    background-position: 50% 100%, 0 0;
  }
}

/* ------------------------------------------------ high-resolution Home figures ---- */
/* Clement, 2026-11-28: the board-size figures (200 px frames) looked soft standing full-tall. A set with
   figures under home-figures/** shows those instead: the same idle, baked larger and cropped to the
   figure's column, so the cell is taller than it is wide. home-lobby.js puts the cell's size and where
   the figure stands in it (--home-fill, --home-foot-gap) on the image; the height rule is unchanged:
   the visible figure is still exactly --home-fig tall with its feet on the spot. */
/* Piece size standardisation (2026-11-29): figure-size.js measures every hero / back-spot figure's own
   ink and writes the same five numbers on it (--home-fill, --home-foot-gap, --home-cx, --home-cell-w,
   --home-cell-h, data-fig-size="measured"), whatever art it is: a high-resolution cell, a 200 px board
   frame or a painted portrait. So every set stands exactly --home-fig tall with its feet on the spot. */
/* Live QA of #210 (Vault board 1280): the hero now also shows the code-drawn sets (home-lobby.js), whose
   pawns are much wider than a figure, and Holo Squad's halo floats above its head. figure-size.js measures
   the body alone and writes the whole drawing's width (--home-aspect, per body height) and the halo's
   reach above the head (--home-over); the body stands --home-fig tall unless the whole drawing would then
   leave the stage's width or its headroom. */
#screen-lobby .home-hero .home-party .home-hero-piece > img[data-home-hires],
#screen-lobby .home-hero .home-party .home-hero-piece > img[data-fig-size="measured"] {
  --home-body: min(var(--home-fig), calc(92cqw / var(--home-aspect, .5)), calc((var(--home-fig) + var(--home-headroom) - 8px) / (1 + var(--home-over, 0))));
  --home-h: calc(var(--home-body) / var(--home-fill));
  --home-w: calc(var(--home-h) * var(--home-cell-w) / var(--home-cell-h));
  bottom: calc(var(--home-h) * var(--home-foot-gap) * -1);
  left: calc(var(--home-w) * var(--home-cx, .5) * -1);
  width: var(--home-w);
  aspect-ratio: var(--home-cell-w) / var(--home-cell-h);
}
#screen-lobby .home-hero .home-party .home-spot-back > img[data-home-hires],
#screen-lobby .home-hero .home-party .home-spot-back > img[data-fig-size="measured"] {
  --home-h: calc(var(--home-fig) * var(--spot-scale) / var(--home-fill));
  --home-w: calc(var(--home-h) * var(--home-cell-w) / var(--home-cell-h));
  bottom: calc(50% - var(--home-h) * var(--home-foot-gap));
  left: calc(50% - var(--home-w) * var(--home-cx, .5));
  width: var(--home-w);
  aspect-ratio: var(--home-cell-w) / var(--home-cell-h);
}
