/* ============================================================================================
   Play Live only — index-quests/quests-modal.php + js/quest-play-live.js.

   This file is loaded by both leaderboards. The in-game one is the .lb-* block at the bottom;
   everything above it belongs to Play Live and must not be folded into that redesign.
   `.top-list-user-item`, `.loading-result` and `.popup-item-content` in particular look generic
   but are Play Live's markup (quest-play-live.js:427, quests-modal.php:38,48).
   ============================================================================================ */

.leaderboard-popup-play-live .popup-section-header-play-live {
	background: #000;
	border-radius: 10px;
    box-shadow: 5px 5px #1eff00;
    margin-bottom: 30px;
	padding: 10px;
	font-size: 32px;
	color: #fff;
	text-shadow: none
}

.leaderboard-top-list-section-teacher {
    background: #282727;
    border-radius: 15px;
    text-align: left;
    padding: 10px 20px;
    font-size: 24px;
    text-shadow: none;
    color: white;
}

.play-live-leaderboard-background {
    animation:gradient 10s ease infinite;
    background:linear-gradient(115deg,#000,#ff7300,#ffae00,#ff5100);
    background-size:200%;
}

.top-list-user-item.selected {
	background: #ffd849;
    border-radius: 15px;
    box-shadow: 1px 3px #733381;
    text-align: left;
    padding: 5px;
    font-size: 24px;
    text-shadow: none;
    color: #4a3050;
    width: calc(100% - 10px);
	border: 1px solid #733381;
	margin: 5px 0px 5px -10px;
}

.popup-item-content {
	position: relative;
}

/* Lives inline in the start/end modal footers (see js/leaderboard.js),
   not floating in the page corner.

   Deliberately declares NO `display`. This file is injected into <head> at
   runtime by addCssFiles(), so it lands after the per-game stylesheets and wins
   ties. Games that hide the button do so with `.leader-board-open-button {
   display: none }` — spelling-supporters.css (all Spelling Zone games) without
   !important — so any `display` here would silently un-hide it. A <button>
   centres its own content, so none is needed.

   The button is a bare, transparent wrapper: Leaderboardbtn.png already draws
   its own rounded background and its corners are transparent, so a background
   or radius on the button shows as a rim around them. Radius and shadow go on
   the <img> instead — the same treatment .exitbutton / .teacherbutton /
   .levelbutton get in layout_2021-7.css. */
.leader-board-open-button {
    background: none;
    border: none;
    padding: 0px;
    font-size: 24px;
    cursor: pointer;
}

/* End modal only — the start footer sizes and drop-shadows every child itself
   (src/scss/games/components/_custom-modal.scss), so this would double the shadow. */
.button-footer .leader-board-open-button img {
    display: block;
    border-radius: 15px;
    box-shadow: 5px 5px #733381;
}

/* Hug the artwork so the button box *is* the image, with no gap at any edge. */
.button-footer > .leader-board-open-button {
    min-width: unset;
    max-width: unset;
    width: auto;
    flex: 0 0 auto;
}

/* End modal only. Five buttons don't fit one phone-width row, and .button-footer
   is nowrap, so without this the flex line squeezes the Home link to zero width
   and pushes the leaderboard button off-screen. Scoped to #end-overlay because
   .button-footer is also used for in-game button rows (common/games/base/*.php). */
#end-overlay .button-footer {
    flex-wrap: wrap;
    gap: 8px;
}

#leaderboardModal .modal-content {
    border-radius: 16px;
    background-color: #545454;
}

.loading-result {
    text-align: center;
    background-color:rgba(0,0,0,0.5);
    position: absolute;
    right: 0;
    top: 66px;
    border-radius: 14px;
    height: calc(100% - 66px)
}

/* ============================================================================================
   .lb-* — the redesigned in-game leaderboard.

   Entirely additive: nothing emits these classes yet, so the live board and the Play Live board
   (which shares .top-list-user-item / .loading-result / .popup-item-content above) are untouched
   until js/leaderboard.js is switched over. Preview at tools/leaderboard-preview.php.

   Sizing follows the end-card (src/scss/games/components/_end-card.scss): container queries off
   the sheet, one radius token, one gap token. Ranks are set apart by SIZE and COLOUR only —
   llamarollFont has a single weight, so bold renders regular by design (rule 14) — and never by
   gold/silver/bronze, which already mean the difficulty level.
   ============================================================================================ */

/* A full-cover frame with the sheet placed by flex, never px — px-placed fixed boxes render
   displaced on real iPhones inside the game iframe (L-175). Doubles as the dimmer. */
.lb-frame {
    position: fixed;
    inset: 0;
    z-index: 99;
    display: flex;
    padding: 16px;
    background: rgba(0, 0, 0, 0.55);
    overflow: auto;
    overscroll-behavior: contain;
}

.lb-sheet {
    container-type: inline-size;

    --lb-radius: clamp(10px, 3cqw, 18px);
    --lb-gap: clamp(6px, 1.8cqw, 12px);
    --lb-ink: #4a3050;
    --lb-panel: #ed9d57;
    --lb-shadow: 5px 5px #733381;

    position: relative;
    width: 100%;
    max-width: 994px;
    margin: auto;              /* centres the card, and pins the sheet down when it can't fit */
    padding: clamp(12px, 3cqw, 20px);
    border-radius: var(--lb-radius);
    background: #545454;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    gap: var(--lb-gap);
    text-shadow: none;
}

.lb-sheet * {
    font-family: inherit;
}

.lb-close {
    position: absolute;
    top: 6px;
    right: 10px;
    z-index: 2;
    padding: 0 6px;
    border: none;
    background: none;
    color: #fff;
    font-size: clamp(22px, 5cqw, 30px);
    line-height: 1;
    cursor: pointer;
}

/* ---- Header ------------------------------------------------------------------------------ */

.lb-head {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: clamp(6px, 2cqw, 12px) 40px;
    border-radius: var(--lb-radius);
    background: #fb8d35;
    box-shadow: var(--lb-shadow);
    color: var(--lb-ink);
    text-align: center;
}

.lb-head__title {
    max-width: min(340px, 100%);
    height: auto;
}

.lb-head__game {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45em;
    font-size: clamp(1rem, 3.4cqw, 1.6rem);
    line-height: 1.15;
}

/* The game's own menu banner. Sized by HEIGHT at its natural ratio, never cropped: these are
   landscape images with the game's name drawn into them, so any square crop cuts the title. */
.lb-head__icon {
    flex: none;
    height: clamp(30px, 6cqw, 50px);
    width: auto;
    max-width: 40%;
    object-fit: contain;
    border-radius: calc(var(--lb-radius) * 0.4);
}

/* ---- Filters ----------------------------------------------------------------------------- */

/* Narrow: three centred rows stacked. Wide: time on the left, scope on the right, as the old
   board had them — the level row is hidden there, so the two ends are all that is left. */
.lb-filters {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--lb-gap);
}

.lb-filters__row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: clamp(4px, 1.4cqw, 10px);
}

.lb-pill {
    display: flex;
    align-items: center;
    gap: 0.35em;
    padding: clamp(4px, 1.4cqw, 9px) clamp(9px, 2.4cqw, 16px);
    border: none;
    border-radius: 999px;
    background: #fee9aa;
    color: var(--lb-ink);
    box-shadow: 3px 3px #733381;
    font-size: clamp(0.85rem, 2.6cqw, 1.25rem);
    line-height: 1.2;
    cursor: pointer;
}

.lb-pill.is-on {
    background: #fbca3f;
    box-shadow: inset 0 0 0 2px #733381, 3px 3px #733381;
}

.lb-pill--scope {
    background: #ee9d57;
}

/* The level pills carry the medal art itself, so the pill row and the list headings read as the
   same thing. Phone-only — above the breakpoint all three lists are on screen at once. */
.lb-pill--level img {
    width: clamp(20px, 6cqw, 28px);
    height: auto;
}

/* ---- Lists ------------------------------------------------------------------------------- */

.lb-lists {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    align-items: start;        /* an empty board is a short box, not a tall orange void */
    gap: var(--lb-gap);
}

.lb-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: clamp(6px, 1.6cqw, 12px);
    border-radius: var(--lb-radius);
    background: var(--lb-panel);
    box-shadow: var(--lb-shadow);
    color: var(--lb-ink);
    font-size: clamp(0.78rem, 1.9cqw, 1rem);
}

/* The medal art has "Gold Level" drawn into it, so the heading is the picture — no caption. */
.lb-list__head {
    display: flex;
    justify-content: center;
    margin: 0 0 2px;
}

.lb-list__head img {
    width: 75px;
    max-width: 100%;
    height: auto;
}

.lb-list__rows {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* ---- Row --------------------------------------------------------------------------------- */

.lb-row {
    display: grid;
    grid-template-columns: 1.9em minmax(0, 1fr) auto;
    gap: 0.1em 0.45em;
    align-items: center;
    padding: 0.22em 0.4em;
    border-radius: calc(var(--lb-radius) * 0.6);
    animation: lb-row-in 0.3s ease-out both;
}

/* A flat tint, not odd/even striping: a :nth-child stripe is (0-2-0) and would outrank the
   medal colours below, which are plain single-class rules. */
.lb-row {
    background: rgba(255, 255, 255, 0.2);
}

.lb-row__rank {
    text-align: right;
    opacity: 0.75;
}

.lb-row__who {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.lb-row__name {
    overflow-wrap: anywhere;   /* long names wrap instead of forcing the column open */
    line-height: 1.1;
}

.lb-row__meta {
    font-size: 0.8em;
    opacity: 0.7;
    line-height: 1.1;
}

.lb-row__meta:empty {
    display: none;
}

.lb-row__points {
    justify-self: end;
    white-space: nowrap;
}

.lb-row__unit {
    font-size: 0.75em;
    opacity: 0.7;
    margin-left: 0.15em;
}

/* Rank 1 leads on size and the shimmer; 2 and 3 sit between it and the rest, and the three carry
   medal fills (Andrew, 15 Aug). No bold anywhere — llamarollFont has one weight (rule 14).
   Gradients rather than flats so they read as struck metal against the panel's orange. */
.lb-row--1 {
    font-size: 1.4em;
    background: linear-gradient(160deg, #ffe488, #f2b705);
}

.lb-row--2 {
    font-size: 1.18em;
    background: linear-gradient(160deg, #f6f8fa, #c4c9d0);
}

.lb-row--3 {
    font-size: 1.08em;
    /* The dark stop is the binding one: the ink has to clear 4.5:1 against it, which #cf8b4f
       did not (4.08:1). Guarded by tests/visual/contrast.spec.js. */
    background: linear-gradient(160deg, #f2c39b, #d99a63);
}

.lb-row--1 .lb-row__rank,
.lb-row--2 .lb-row__rank,
.lb-row--3 .lb-row__rank {
    opacity: 1;
}

/* The child looking at the board, wherever they land. The ring and the marker carry it, so a
   medal row keeps its metal — only rank 4 and below take the yellow fill. */
.lb-row--you {
    box-shadow: inset 0 0 0 2px #733381;
}

/* Cyan, not the panel's yellow — "this is you" has to read as a different kind of thing from
   the three medal fills right above it. */
.lb-row--you:not(.lb-row--1):not(.lb-row--2):not(.lb-row--3) {
    background: #c5fcff;
}

.lb-row--you .lb-row__rank::before {
    content: "\25B8";          /* ▸ — marks the row without spending a column */
    margin-right: 0.15em;
}

.lb-empty {
    padding: 0.6em 0.2em;
    text-align: center;
    opacity: 0.85;
    line-height: 1.25;
}

/* ---- Your position ----------------------------------------------------------------------- */

/* Sticks to the foot of the sheet so it survives a long list without a second scroll region.
   Same three columns as .lb-lists, so each chip sits under the board it reports on. */
.lb-you {
    position: sticky;
    bottom: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    align-items: center;
    gap: 2px var(--lb-gap);
    padding: clamp(6px, 1.8cqw, 12px);
    border-radius: var(--lb-radius);
    background: #c5fcff;       /* the "you" colour, shared with .lb-row--you */
    box-shadow: var(--lb-shadow);
    color: var(--lb-ink);
    font-size: clamp(0.85rem, 2.4cqw, 1.15rem);
}

/* Its own row above the chips — as a grid item it would eat a column and break the alignment. */
.lb-you__label {
    grid-column: 1 / -1;
    text-align: center;
    opacity: 0.7;
}

.lb-you__chip {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3em;
}

.lb-you__chip img {
    width: clamp(20px, 5cqw, 30px);
    height: auto;
}

.lb-you__rank {
    font-size: 1.25em;
}

.lb-you__of {
    font-size: 0.85em;
    opacity: 0.7;
}

.lb-you__chip--none {
    opacity: 0.65;
}

/* ---- Loading ----------------------------------------------------------------------------- */

.lb-skeleton {
    height: 1.6em;
    margin: 3px 0;
    border-radius: calc(var(--lb-radius) * 0.6);
    background: linear-gradient(90deg, rgba(255,255,255,0.15), rgba(255,255,255,0.45), rgba(255,255,255,0.15));
    background-size: 300% 100%;
    animation: lb-sheen 1.4s linear infinite;
}

@keyframes lb-sheen {
    to { background-position: 300% 0; }
}

/* ---- Phone: one level at a time ---------------------------------------------------------- */

/* The whole mobile fix. The JS always renders all three lists and marks the selected one, so a
   pill click is an attribute swap, never a re-render. */
@container (max-width: 620px) {
    .lb-lists {
        grid-template-columns: 1fr;
    }

    .lb-list:not([data-lb-active]),
    .lb-you__chip:not([data-lb-active]) {
        display: none;
    }

    /* One board, so one column — otherwise the surviving chip sits stranded in column 1. */
    .lb-you {
        grid-template-columns: 1fr;
    }

    /* One list has the full sheet width, so the type can be bigger here than in the 3-up view. */
    .lb-list {
        font-size: clamp(0.95rem, 4cqw, 1.2rem);
    }

    .lb-list__head {
        display: none;         /* the selected pill already names the level */
    }

    .lb-sheet {
        margin-top: auto;      /* a bottom sheet, without ever positioning it in px (L-175) */
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
    }

    .lb-frame {
        padding: 0;
    }
}

@container (min-width: 621px) {
    .lb-filters__row--level {
        display: none;         /* all three lists are already on screen */
    }

    .lb-filters {
        flex-direction: row;
        align-items: flex-start;
        justify-content: space-between;
    }
}

/* ---- Shimmer ----------------------------------------------------------------------------- */

/* The end-card's .ec-rainbow recipe (src/scss/games/components/_end-card.scss), duplicated rather
   than imported — this file is hand-written and must stay out of the gulp output (rule 12).
   The two selectors give (0-2-0), so body.dark-mode's span whitener can never outrank the clip.

   Darker stops than the end-card's: that one shimmers on a near-white row, this one on peach over
   #ed9d57, where the end-card's yellows and mints leave the winner's name unreadable. */
.lb-row__name.lb-shimmer,
.lb-row__name.lb-shimmer span {
    background: linear-gradient(90deg, #7b1fa2, #c2185b, #d84315, #2e7d32, #7b1fa2);
    background-size: 300% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent !important;
    animation: lb-rainbow 2.4s linear infinite;
}

@keyframes lb-rainbow {
    to { background-position: 300% 0; }
}

@keyframes lb-row-in {
    from { opacity: 0; transform: translateY(3px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .lb-row,
    .lb-skeleton,
    .lb-row__name.lb-shimmer,
    .lb-row__name.lb-shimmer span {
        animation: none;
    }
}

/* ---- Dark and plain mode ----------------------------------------------------------------- */

/* dark-mode.css reaches inside the game iframe (common/games/partials/head.php) and whitens bare
   span/li/a/small with !important — ~2:1 on these fills. Same restore-the-ink fix as the end-card
   and the Snapshot pills (L-070/L-071). Two selectors each, to clear the catch-all's specificity. */
body.dark-mode .lb-sheet {
    background: #3b3b3b;
}

body.dark-mode .lb-list,
body.dark-mode .lb-list span,
body.dark-mode .lb-list li,
body.dark-mode .lb-head,
body.dark-mode .lb-head span,
body.dark-mode .lb-you,
body.dark-mode .lb-you span {
    color: var(--lb-ink) !important;
    text-shadow: none !important;
}

/* NOT restored: the rank-1 shimmer needs color:transparent, and a restore would paint the clip. */
body.dark-mode .lb-row__name.lb-shimmer,
body.dark-mode .lb-row__name.lb-shimmer span {
    color: transparent !important;
}

/* dark-mode.css paints every <button> black with a white rim, which flattens on/off to identical
   pills. These re-state both states at a specificity it cannot reach. */
/* The label span needs naming too — the whitener hits it directly, so colour on the button alone
   is only inherited and loses. */
body.dark-mode .lb-sheet .lb-pill,
body.dark-mode .lb-sheet .lb-pill span {
    background: #fee9aa !important;
    color: var(--lb-ink) !important;
    border: none !important;
    box-shadow: 3px 3px #733381 !important;
}

body.dark-mode .lb-sheet .lb-pill span {
    background: none !important;
    box-shadow: none !important;
}

body.dark-mode .lb-sheet .lb-pill--scope {
    background: #ee9d57 !important;
}

body.dark-mode .lb-sheet .lb-pill.is-on {
    background: #fbca3f !important;
    box-shadow: inset 0 0 0 2px #733381, 3px 3px #733381 !important;
}

body.dark-mode .lb-sheet .lb-close {
    background: none !important;
    border: none !important;
    color: #fff !important;
    box-shadow: none !important;
}

/* Same treatment for plain mode — css/plain-mode.css mirrors every one of those catch-alls. */
body.plain-mode .lb-sheet {
    background: #e8e8e8;
}

body.plain-mode .lb-list,
body.plain-mode .lb-list span,
body.plain-mode .lb-list li,
body.plain-mode .lb-head,
body.plain-mode .lb-head span,
body.plain-mode .lb-you,
body.plain-mode .lb-you span {
    color: #000 !important;
    text-shadow: none !important;
}

body.plain-mode .lb-sheet .lb-pill,
body.plain-mode .lb-sheet .lb-pill span {
    background: none !important;
    color: #000 !important;
    box-shadow: none !important;
}

body.plain-mode .lb-sheet .lb-pill {
    background: #fff !important;
    border: 2px solid #000 !important;
}

body.plain-mode .lb-sheet .lb-pill.is-on {
    background: #000 !important;
}

body.plain-mode .lb-sheet .lb-pill.is-on,
body.plain-mode .lb-sheet .lb-pill.is-on span {
    color: #fff !important;
}

/* The shimmer has no meaning in plain mode — it is decoration the theme exists to remove. */
body.plain-mode .lb-row__name.lb-shimmer,
body.plain-mode .lb-row__name.lb-shimmer span {
    background: none;
    color: #000 !important;
    animation: none;
}
