/* Section.css
 * Shared section styles: game-card tiles, tile grids + row paging,
 * skeletons, and the browse-filter panel controls.
 * Used by the play/build/profile/admin pages.
 */

/* ====================
   TILE GRIDS
   ==================== */

/* Game grid: a .tile-grid (common/style.css) positioned so the Show More
   control can anchor to the grid's bottom edge. (Empty states span the grid
   via the shared rule below.) */
.game-grid {
  position: relative;
}

/* Every tile grid lives in a glass panel below the section's heading/text
   (the gallery-panel pattern -- there is no separate featured slot; the
   collection's first tile is the spotlight, below). Covers the game-tile
   grids (.game-grid) and the build page's asset browser (.find-grid). An emptied
   grid disappears entirely so a prompt-only panel keeps its rhythm. */
.section-glass .game-grid,
.section-glass .find-grid {
  margin-top: var(--space-2);
}

.section-glass .game-grid:empty,
.section-glass .find-grid:empty {
  display: none;
}

/* First-tile spotlight: a game-tile grid (.grid-hero, set statically in the
   markup; people grids omit it) enlarges its first tile to a 2x2 hero.
   Entirely CSS -- no JS state. Two gates:
   - width >=3 columns (the grid's panel 770px across: three --tile-min
     tracks and two gaps -- a container query, since the page inset changes
     with the screen and the viewport no longer says how wide a panel is) --
     at 1-2 columns there are no 1x1 tiles beside it to define the two-row
     height, so the first tile stays normal;
   - >=4 card siblings (`:nth-last-child(n + 4 of .game-card)`) -- with
     fewer, the hero's second row can't fill at the 4-column maximum and the
     spotlight would collapse to a short banner. Counting only .game-card
     siblings ignores the Show More control, and a lone placeholder card
     never qualifies, so empty-channel renders stay normal-sized.
   The span's two rows are sized by the 1x1 tiles next to it; the hero card
   stretches to fill (grid items stretch by default) and its thumbnail grows
   into the taller area, dropping the 16:9 lock so the video/screenshot
   covers it. Applies to the first real card AND the first skeleton, so a
   loading state doesn't reflow into the hero shape. */
@container (min-width: 770px) {
  .grid-hero > .game-card:first-child:nth-last-child(n + 4 of .game-card) {
    grid-column: span 2;
    grid-row: span 2;
    /* Fill the two-row area the side tiles define (a flex column with a
       flex:1 thumbnail won't stretch on its own over spanned auto rows). */
    height: 100%;
  }

  .grid-hero > .game-card:first-child:nth-last-child(n + 4 of .game-card) .game-thumbnail,
  .grid-hero > .game-card-skeleton:first-child:nth-last-child(n + 4 of .game-card)::after {
    aspect-ratio: auto;
    flex: 1;
  }
}

/* Show More control: the tile grid pages by rows (see Section.js
   initGridRowPaging). The control (.grid-more) reserves no space of its
   own -- it floats in the panel's bottom padding, filling the band between
   the grid's last row and the panel border and centering itself in it. Its
   base styling + the padding reservation now live in
   common/style.css, shared with the index Welcome scroll hint (which reuses
   the same .grid-more class). The static skeleton ships a .grid-more
   placeholder so the band reserves from first paint; see .grid-more-skeleton
   below. */

/* ====================
   GRID VIEW (the tutorials picker; see ModalTutorials)
   ==================== */

/* A .tile-grid (common/style.css) that packs its rows at the top. */
.section-part-grid {
  align-content: start;
}

.section-part-grid .game-card {
  max-width: calc(var(--tile-min) * 2);
  width: 100%;
}

/* ====================
   GAME CARDS
   ==================== */

.game-card {
  position: relative;
  background: var(--color-surface);
  border: var(--border-width) var(--border-style) var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  padding: 0;
  cursor: pointer;
  transition: all 0.15s ease;
  display: flex;
  flex-direction: column;
  height: auto;
  /* The footer is pulled out of flow (below), which makes the card shorter
     than its row; size it to its content so the row's reserved height does
     not expose the card's surface as a gray bar below the thumbnail. */
  align-self: start;
  /* The footer's height, named so the button on the art can center itself in
     the part of the picture the footer leaves uncovered: a button's padding
     around its 18px line, plus the top border. The glyph-only footer's own
     value is with the rest of glyph-only, below. */
  --game-footer-height: calc(var(--space-2) * 2 + 18px + var(--border-width));
}

/* Accent the border when the tile is "selected": its drawer open on touch
   (the .revealed class, toggled by the footer handle) or focused via keyboard
   (:focus-visible, not :focus-within -- a tapped footer button or handle
   takes focus too, and only the handle should light a touch tile). Pairs with
   the footer reveal so the same state lights the border and floats the menu.
   The hover affordance lives in the shared, hover-device-gated tile rule in
   style.css (gated so iOS's sticky :hover doesn't flash it on touch-scroll),
   and the orbiting glow that pairs with it lives in style.css's Running glow. */
.game-card.revealed,
.game-card:has(:focus-visible) {
  border-color: var(--color-accent);
}

.game-thumbnail {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--color-background);
  flex-shrink: 0;
}

.game-screenshot {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.25s ease-out;
}

.game-screenshot.loaded {
  opacity: 1;
}

/* A tile's hover video (TilePreview): over the cover, under the hover wash
   and the badges. Fades in once it is actually playing, so a slow start
   shows the cover rather than a black frame. */
.game-preview {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  /* A cross-fade, both ways: the cover dissolves into the video once it is
     playing, and the video back into the cover when the tile is left
     (TilePreview #FADE_MS). */
  transition: opacity 0.25s ease-in-out;
  pointer-events: none;
}

.game-card.previewing .game-preview {
  opacity: 1;
}

/* A newly made video fades in by animation, which always plays from its
   first frame; a transition can be skipped when a cached video starts in
   the same moment its element appears. */
.game-card.previewing .game-preview-new {
  animation: game-preview-in 0.25s ease-in-out;
}

@keyframes game-preview-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Overlay chips floating on the thumbnail, above the tile art: one glyph
   per genre (top-left, stacked vertically) and, top-right, an award badge
   for a ranked-stat leader and a medal for the leaderboard's record holder.
   All are icon-only at rest; hover/focus slides the text label out. The
   genre and award chips are real <button>s (keyboard operable, like the
   card's footer actions); the record chip only informs, so it is a span.
   All reset to opaque surface chips -- like floating bits of the
   header/footer strips -- so they stay legible over any art without a
   media-specific scrim, and flip cleanly with the theme. */
.game-genre-stack,
.game-badge-stack {
  position: absolute;
  top: var(--space-1);
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.game-genre-stack {
  left: var(--space-1);
  align-items: flex-start;
}

.game-badge-stack {
  right: var(--space-1);
  align-items: flex-end;
}

.game-genre-badge,
.game-award-badge,
.game-record-badge,
.game-tutorial-badge,
.game-studio-badge {
  display: inline-flex;
  align-items: center;
  appearance: none;
  -webkit-appearance: none;
  padding: var(--space-1);
  background: var(--color-surface);
  border: var(--border-width) var(--border-style) var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-link);
  font-size: var(--font-size-sm);
  cursor: pointer;
  transition: color 0.15s ease;
}

/* Every chip reads the same way, mirroring the footer links: muted at rest,
   brightening on hover. Genre filters the browse view; award applies its
   sort; the record holder and the tutorial mark are read-only, :where(html[data-pointer='mouse']) so they
   brighten without a hand. */
.game-genre-badge:hover,
:where(html[data-pointer='mouse']) .game-award-badge:hover,
:where(html[data-pointer='mouse']) .game-record-badge:hover,
:where(html[data-pointer='mouse']) .game-tutorial-badge:hover,
:where(html[data-pointer='mouse']) .game-studio-badge:hover {
  color: var(--color-link-light);
}

.game-genre-badge:focus-visible,
.game-award-badge:focus-visible {
  outline: var(--focus-outline);
}

.game-record-badge,
.game-tutorial-badge,
.game-studio-badge {
  cursor: default;
}

/* Chip labels are collapsed at rest (icon-only chip) and slide out on
   hover/focus. max-width carries the reveal, out to the word's own width
   (--label-w, measured by Section.js along with whether the word fits at
   all), so the slide ends where the word does -- a word that would not fit
   never slides at all (.glyph-only). line-height matches the 14px icon so
   the label never sets the chip's height, keeping the collapsed chip a
   perfect square. */
.game-badge-label {
  display: block;
  max-width: 0;
  margin-left: 0;
  overflow: hidden;
  white-space: nowrap;
  line-height: 14px;
  transition:
    max-width 0.25s ease-out,
    margin-left 0.25s ease-out;
}

/* Expanded by keyboard focus on any device, and on touch along with the
   footer drawer (the card's .revealed class, toggled by the footer handle --
   see SectionTemplate toggleTileFooter), so one tap opens everything the hover
   would have shown. */
.game-genre-badge:focus-visible .game-badge-label,
.game-award-badge:focus-visible .game-badge-label,
.game-card.revealed .game-badge-label {
  max-width: var(--label-w, 0);
  margin-left: var(--space-1);
}

/* Mouse: also expand on hover. Scoped to a mouse in use so iOS's sticky
   :hover can't expand a chip you merely scrolled past. */
:where(html[data-pointer='mouse']) .game-genre-badge:hover .game-badge-label,
:where(html[data-pointer='mouse']) .game-award-badge:hover .game-badge-label,
:where(html[data-pointer='mouse']) .game-record-badge:hover .game-badge-label,
:where(html[data-pointer='mouse']) .game-tutorial-badge:hover .game-badge-label,
:where(html[data-pointer='mouse']) .game-studio-badge:hover .game-badge-label {
  max-width: var(--label-w, 0);
  margin-left: var(--space-1);
}

/* A chip that would reach under the opened footer is not drawn at all
   (.no-room, measured by Section.js), so a stack never runs further down
   the picture than the picture has room for. */
.game-genre-stack > .no-room,
.game-badge-stack > .no-room {
  display: none;
}

.game-genre-badge svg,
.game-award-badge svg {
  display: block;
  flex-shrink: 0;
  width: 14px;
  height: 14px;
}

/* Header strip above thumbnail */
.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2);
  border-bottom: var(--border-width) var(--border-style) var(--color-border);
}

.game-header .game-title {
  min-width: 0; /* Required for flex truncation */
}

/* The title is the card's link (SectionTemplate.createGameCard). Its
   ::after stretches over the whole tile -- the card is the containing block
   (position: relative, below) -- so a click anywhere on the art follows the
   link, with the browser's own middle-click / Cmd-click / "Open in new tab".
   z-index 1 lifts it over the thumbnail (positioned, for its badges). What
   else is clickable on the card paints above this layer: the badges at 2, the
   footer and header button at 1 as well, following it in the DOM. */
.game-header .game-title[href]::after,
.game-header .game-title-action::after {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 1;
}

/* A card that opens by script rather than by link (a tutorial tile) has a
   button for a title, stretched over the tile the same way, so it opens from
   the keyboard too. Only the button's own chrome is reset; the title rules
   below still size and cut it like the link. */
.game-title-action {
  appearance: none;
  -webkit-appearance: none;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

/* The link stands for the whole card, so keyboard focus is shown by the card's
   accent border and ring (.game-card:has(:focus-visible), above), not by a
   second outline around the title text. */
.game-header .game-title[href]:focus-visible,
.game-header .game-title-action:focus-visible {
  outline: none;
}

/* Shared icon+label action buttons on game cards (header + footer). */
.game-header-btn,
.game-footer-btn {
  background: transparent;
  border: none;
  color: var(--color-link);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
  font-size: var(--font-size-sm);
}

/* No padding of its own: the strip's padding is the hit target's, and the
   chip's 18px line is what makes the header as tall as the footer (39px).
   It never shrinks; the title gives way instead, and where the title would
   be cut short the button drops its word first (.glyph-only, below). */
.game-header-btn {
  position: relative; /* Above the title's stretched link */
  z-index: 1;
  padding: 0;
  flex-shrink: 0;
}

.game-header-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

/* No ellipsis: a word that does not fit drops to its glyph (.glyph-only). */
.game-header-btn-label {
  white-space: nowrap;
  overflow: hidden;
}

:where(html[data-pointer='mouse']) .game-header-btn:hover {
  color: var(--color-link-light);
}

/* Footer action buttons. */
.game-footer-btn {
  flex: 1 1 0; /* Equal shares of the footer, whatever each word's width */
  min-width: 0;
  justify-content: center;
  /* Narrow sides, so each third holds its icon and word on a standard tile */
  padding: var(--space-2) var(--space-1);
  overflow: hidden;
}

/* The footer runs to the card's edge, which clips what is drawn past it:
   the focus ring goes inside the button instead of around it. */
.game-footer-btn:focus-visible {
  outline-offset: calc(-1 * var(--focus-outline-offset));
}

.game-footer-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.game-footer-label {
  white-space: nowrap;
  overflow: hidden;
}

:where(html[data-pointer='mouse']) .game-footer-btn:hover {
  color: var(--color-link-light);
}

:where(html[data-pointer='mouse']) .game-footer-btn.danger:hover {
  color: var(--color-error);
}

/* The footer sits out of the card's flow, floated over the bottom of the
   thumbnail and hidden until the tile is in hand. The reveal trigger differs
   by input: hover or keyboard focus on mouse (below), and on touch a tap on
   the footer's handle (the .revealed class, toggled by SectionTemplate
   toggleTileFooter; it also expands the thumbnail's chip labels) -- so one
   tap on the art plays, as a click does on a hovered tile (except on an open
   tile too small for its open hint, where it closes the drawer). It never
   clips: each button clips its own label, and on touch the handle pokes up
   past the footer's top edge. */
.game-footer {
  display: flex;
  align-items: center;
  border-top: var(--border-width) var(--border-style) var(--color-border);
  position: absolute;
  z-index: 1; /* Above the title's stretched link */
  left: 0;
  right: 0;
  bottom: 0;
  /* Gray bar with top border, floated up over the bottom of the thumbnail. */
  background: var(--color-surface);
  opacity: 0;
  transform: translateY(var(--space-3));
  transition:
    opacity 0.15s ease,
    transform 0.15s ease;
  pointer-events: none;
}

/* Revealed by keyboard focus on any device -- focus stays out of the hover
   gate below so tab-into-footer works on touchscreens too. */
.game-card:has(:focus-visible) .game-footer {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Mouse: also reveal on hover. Scoped to a mouse in use so iOS's sticky :hover
   can't pin the footer to a tile you merely scrolled past. */
:where(html[data-pointer='mouse']) .game-card:hover .game-footer {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* A tile in hand darkens its own picture, on the same cue that slides the
   footer in. Where the tile draws a button on its art that is what the
   button reads against: its backdrop becomes a known one instead of
   whatever the picture happens to be, which for key art is usually busy and
   mid-tone -- the one case a glyph's own shadow handles worst. Every tile
   with a picture takes it, including the few that draw no button there (the
   tutorial picker's, the guest tile); on those it is simply the hover
   state, which is the same thing it says everywhere else. (A placeholder
   that opens nothing takes no hover at all: .game-card-inert.) Paints
   over the picture and under the badges and the button (both z-index 2), and
   takes no clicks, so the title's stretched link still has the whole tile. */
.game-thumbnail::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--overlay-black-25);
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

.game-card:has(:focus-visible) .game-thumbnail::after,
.game-card.revealed .game-thumbnail::after {
  opacity: 1;
}

:where(html[data-pointer='mouse']) .game-card:hover .game-thumbnail::after {
  opacity: 1;
}

/* A playing hover video shows at full brightness: the wash lifts while it
   plays and returns when it fades back to the cover. After the rules above
   so it wins at the same specificity. */
.game-card.previewing .game-thumbnail::after {
  opacity: 0;
}

/* A control drawn on the tile's art rather than in a bar: the open hint in
   the middle of the picture, the footer's "..." handle at its top edge. Not
   a button to look at -- no surface, no border, just the glyph, with a
   shadow to seat it on the wash. White, because what it is read against is
   the scrimmed picture and not a page surface: the footer's muted gray is
   right on the solid strip it sits on and too quiet over key art, and a
   theme's text color would turn this one dark on a backdrop that stays dark
   in both themes. It holds that one color throughout -- white has no
   brighter to go, and hovering it already says its name (Tooltip.js). Each
   user positions itself and says when it shows; this says what it looks
   like. */
.game-art-btn {
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  border: none;
  color: var(--overlay-white-100);
  /* One soft pass is enough now that the picture behind it is scrimmed: the
     shadow only has to seat the glyph against that wash. (A playing hover
     video lifts the wash, so there the shadow stands alone.) Full black rather
     than the page's own background, which in the light theme would leave it
     nothing to separate against. */
  filter: drop-shadow(0 0 5px var(--overlay-black-100));
  cursor: pointer;
}

.game-art-btn svg {
  display: block;
}

/* The footer's handle: a bare "..." overlaid on the art at the footer's top
   edge, centered, that slides the footer in and out on touch. It is a child
   of the footer, so it rides up with it and needs no knowledge of the
   footer's height. Hidden wherever hover exists -- hover does the sliding
   there. */
.game-footer-handle {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-1) var(--space-2);
  pointer-events: auto;
}

/* Touch: the footer is a drawer. Closed, it sits fully below the card's edge
   (the card's overflow:hidden clips it) with only the handle poking up; the
   handle's tap slides it into place, just as hover does on a mouse. */
:where(html[data-pointer='touch']) .game-footer {
  opacity: 1;
  transform: translateY(100%);
}

:where(html[data-pointer='touch']) .game-footer-handle {
  display: flex;
  /* Shown at rest here, over art the scrim has not darkened yet: a tight
     pass under the soft one keeps the white glyph legible on pale art. */
  filter: drop-shadow(0 0 2px var(--overlay-black-100))
    drop-shadow(0 0 5px var(--overlay-black-100));
}

:where(html[data-pointer='touch']) .game-card.revealed .game-footer {
  transform: translateY(0);
  pointer-events: auto;
}

/* A footer that is only a description (a tutorial tile's) holds nothing to
   click, so it never takes the pointer: a click on it lands on the title's
   stretched layer underneath and opens the tile, like a click on the art.
   The touch handle keeps its own. After all three reveals above (focus,
   hover, the touch drawer), which it has to outlast at equal weight. */
.game-card .game-footer:has(> .wizard-tile-desc) {
  pointer-events: none;
}

/* The open hint: the tile's own action (play or edit) as a button centered
   on the art the footer leaves uncovered -- the footer floats over the art's
   bottom, so the center is measured above its height. A tile at rest is
   just its art; a tile in hand shows what a click on the art does,
   since the footer no longer repeats that action as a button. Shown exactly
   when the footer is: keyboard focus, hover on a mouse, the drawer on touch
   -- except on a tile whose art above the open drawer is too short to hold
   it clear of the handle (.no-hint, measured by Section.js), where a tap on
   the art closes the drawer instead of playing.
   It is a link with the title's own href and open action, so it reads,
   hovers and opens like any other button (its title is its tooltip); above
   the title's stretched layer like the badges, and clickable only while
   shown, like the footer. Drawn as a control on the art (.game-art-btn),
   like the footer's handle. */
.game-open-hint {
  position: absolute;
  z-index: 2;
  top: calc((100% - var(--game-footer-height)) / 2);
  left: 50%;
  display: inline-flex;
  padding: var(--space-2);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.75);
  transition:
    opacity 0.15s ease,
    transform 0.15s ease;
  pointer-events: none;
}

.game-card:has(:focus-visible) .game-open-hint,
.game-card.revealed:not(.no-hint) .game-open-hint {
  opacity: 1;
  transform: translate(-50%, -50%);
  pointer-events: auto;
}

:where(html[data-pointer='mouse']) .game-card:hover .game-open-hint {
  opacity: 1;
  transform: translate(-50%, -50%);
  pointer-events: auto;
}

/* ====================
   GLYPH-ONLY
   ====================
   Every word on a tile -- the footer's buttons, the header's button, each
   chip on the art -- keeps its glyph and drops its word where the word does
   not fit (.glyph-only, set by Section.js each time a grid lays out). One
   rule measured against the space itself, never against a width, so a new
   button or a longer name needs nothing here. A dropped word still names its
   button on hover (Tooltip.js). */
.game-footer.glyph-only .game-footer-label,
.game-header-btn.glyph-only .game-header-btn-label,
.game-card .glyph-only .game-badge-label {
  display: none;
}

/* A shorter footer follows the glyph-only buttons, and the button on the art
   centers itself against it. */
.game-card:has(.game-footer.glyph-only) {
  --game-footer-height: calc(var(--space-2) * 2 + 14px + var(--border-width));
}

/* Placeholder cards carry a footer only as a height spacer (its button is
   visibility:hidden). Out of flow it no longer reserves height, so drop it
   entirely -- otherwise its empty surface slides up on reveal. */
.game-card-placeholder .game-footer {
  display: none;
}

/* A placeholder that opens nothing (an empty grid, a search miss) ignores
   the mouse, as a loading tile does: no accent, glow, wash or grow for a
   tile with nothing to do. The guest tile links to the builder, so it is
   not one. */
.game-card-inert {
  pointer-events: none;
}

.game-title {
  color: var(--color-text);
  /* The footer's line (18px on its 12px text), so the header matches it in
     height with the same 10px padding and 1px border on each. */
  line-height: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ====================
   EMPTY STATE
   ==================== */

.empty-state {
  text-align: center;
  padding: var(--space-5) var(--space-4);
  color: var(--color-text-dark);
}

.title-block {
  display: block;
  margin-bottom: var(--space-2);
}

/* Make empty states span full width in grid layouts */
.game-grid .empty-state {
  grid-column: 1 / -1;
  max-width: none;
}

/* ====================
   PLACEHOLDER TILES
   ==================== */

.game-placeholder-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  color: var(--color-text-dark);
}

.game-placeholder-icon svg {
  width: 100%;
  height: 100%;
}

/* ====================
   SKELETON TILES
   ==================== */

@keyframes skeleton-shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Shared skeleton shimmer effect (the end screen's leaderboard rows ride
   it too, see scene/Leaderboard.css, and the player's controls card until
   it is filled, see player.css) */
.game-card-skeleton,
.play-card.play-card-skeleton,
.grid-more-skeleton::before,
.profile-header-skeleton::before,
.profile-username-avatar:not(:has(img.loaded)),
.leaderboard-row.is-loading .leaderboard-name,
.leaderboard-row.is-loading .leaderboard-value {
  background: linear-gradient(
    90deg,
    var(--color-background) 25%,
    var(--color-surface) 50%,
    var(--color-background) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.game-card-skeleton {
  pointer-events: none;
}

/* Grid contexts (tile grids + standalone ones like the games modal):
   the skeleton fills its grid track, and its height comes from the same
   anatomy as a loaded card: a header strip plus a 16:9 thumbnail pane (the
   footer floats out of flow, so it adds nothing). */

/* Header strip: a real text line inside header padding, with a floor at
   the header action button's height (its --font-size-sm label line at the
   body's 1.5 line-height, plus --space-1 button padding) -- every loaded
   card's header carries that row: Rename on private tiles, the author
   button elsewhere, and placeholder cards ship a hidden spacer to hold
   the same height. Token-derived so the strip tracks the real header
   through font or spacing changes. */
.game-grid .game-card-skeleton::before,
.section-part-grid .game-card-skeleton::before {
  content: '\00a0';
  display: block;
  padding: var(--space-2);
  min-height: calc(1.5 * var(--font-size-sm) + 2 * var(--space-1) + 2 * var(--space-2));
}

/* Thumbnail pane: same 16:9 as .game-thumbnail. */
.game-grid .game-card-skeleton::after,
.section-part-grid .game-card-skeleton::after {
  content: '';
  display: block;
  aspect-ratio: 16 / 9;
}

/* Skeleton stand-in for the grid's Show More control: the static markup
   ships one per tile grid so the control's spot in the panel's bottom
   padding shimmers on first paint (a loaded channel usually overflows its
   first row). The loader's grid re-render discards it; applyGridRowPaging
   appends the real control when the channel calls for one. Same element +
   classes as the real control (out of flow, so it never affects layout);
   a shimmer pill stands in for the icon + label. */
.grid-more-skeleton {
  pointer-events: none;
}

.grid-more-skeleton::before {
  content: '\00a0';
  width: 100px;
  border-radius: var(--radius-sm);
}

/* Match the skeleton row to the loaded grid's first row: most grids ship four
   skeleton tiles and one reveals per column (the fifth and sixth columns go
   without on those). The games gallery shows every tile it ships instead
   (.grid-deep, below). Two columns always fit (.tile-grid, common/style.css),
   so two show from the start; the rest reveal as the grid's panel -- the query container,
   whose content box the grid spans -- reaches the width N columns need: N
   --tile-min tracks and N - 1 gaps of --space-2. A container query rather
   than the viewport, since the page inset changes with the screen and the
   viewport no longer says how wide a panel is. */
.game-grid > .game-card-skeleton:nth-child(n + 3) {
  display: none;
}

/* 3 columns: 770px of tiles. */
@container (min-width: 770px) {
  .game-grid > .game-card-skeleton:nth-child(3) {
    display: flex;
  }
}

/* 4 columns: 1030px of tiles. */
@container (min-width: 1030px) {
  .game-grid > .game-card-skeleton:nth-child(4) {
    display: flex;
  }
}

/* 5 columns: 1290px of tiles, which the content cap's 1548 fits. */
@container (min-width: 1290px) {
  .game-grid > .game-card-skeleton:nth-child(5) {
    display: flex;
  }
}

/* 6 columns: 1550px of tiles, 2px past the content cap's 1548, so it
   never shows today. */
@container (min-width: 1550px) {
  .game-grid > .game-card-skeleton:nth-child(6) {
    display: flex;
  }
}

/* A grid with no end in sight (.grid-deep: the games gallery on the play and
   home pages) ships seventy-two skeleton tiles -- twelve rows at six columns,
   more than any screen holds -- and shows them all, at every column count.
   The loading state runs off the bottom of the screen, so nobody sees how
   many there are, and the real tiles run off it the same way (Section.js
   #applyGridRowPaging): what changes in the swap is below the fold. */
.game-grid.grid-deep > .game-card-skeleton:nth-child(n + 3) {
  display: flex;
}

/* Stagger animation for multiple skeletons. Unscoped (not .game-grid >)
   because other skeleton grids share it -- notably admin's larger tile
   grids, whose fifth cell still needs the :nth-child(5) step even though
   most wrapping game grids ship four skeleton tiles (the games gallery
   ships seventy-two, and play.css carries its stagger on from here). */
.game-card-skeleton:nth-child(2) {
  animation-delay: 0.1s;
}
.game-card-skeleton:nth-child(3) {
  animation-delay: 0.2s;
}
.game-card-skeleton:nth-child(4) {
  animation-delay: 0.25s;
}
.game-card-skeleton:nth-child(5) {
  animation-delay: 0.5s;
}

/* ====================
   BROWSE FILTER PANEL (shared by the games gallery and the build/profile/admin
   panels: selects + search composing into one results grid inside a glass
   section; page-specific skeleton/hero rules stay in each page's CSS)
   ==================== */

/* The panel itself is a standard glass section (.section-glass, common). The
   controls row holds the selects plus the search box; the search box grows
   to take the remaining width, and the row breaks into lines when it does
   not fit (below). The 10px gap matches every other search/actions toolbar
   (the builder's find-modal search row, the admin asset-browser header). */
.browse-filter-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  /* Space below the panel's title. */
  margin-top: var(--space-2);
}

/* The select fields share one block, a grid of equal columns, so the
   gallery's Genre and Sort are always the same width: shrink-wrapped
   beside the search box they both take the wider one's width; on a line
   of their own they split it. The block grows too, but next to the search
   box's grow factor (below) its share of a shared line rounds to nothing:
   it only fills a line the search box has dropped off of, where the
   selects stretch into what the search box left. */
.browse-filter-fields {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: var(--space-2);
  flex: 1 1 auto;
}

/* Label paired inline with its control. */
.browse-filter-field {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.browse-filter-label {
  color: var(--color-text-dark);
  white-space: nowrap;
}

/* A glyph that stands in for the label where the words do not fit (below):
   the markup puts it before the label and the panel's script fills it
   (Genre, Sort: GameBrowse; Channel: SectionChannelPanel). */
.browse-filter-icon {
  display: none;
  align-items: center;
  color: var(--color-text-dark);
}

/* Override the shared full-width block <select> base: filter controls size to
   content and sit inline. Height and text size come from .select-compact
   (common/style.css), which every element carrying this class also carries --
   that is what matches them to the search input (.form-inst-search). */
.browse-filter-select {
  display: inline-block;
  flex: 1 1 auto;
  width: auto;
  min-width: 150px;
}

/* Search box: a flex item that grows to fill the row past the selects
   (overrides the standalone .section-search width/margin below). Its basis
   is the least it asks for before the row wraps -- 200px keeps the
   gallery's Genre + Sort + search on one line down to a 620px row. The
   grow factor dwarfs the fields' (above) so that on a shared line the
   slack is all the search box's. */
.browse-filter-search {
  flex: 1000 1 200px;
  width: auto;
  margin-top: 0;
}

/* Optional CTA buttons riding the controls row (the build panel's Tutorials
   and New Game), last in the row so they sit at its far end past the
   search box. They share one wrapper, so the row treats them as one
   control, and a shared min-width keeps their widths equal regardless of
   label length, so they read as one control group. */
.browse-filter-actions {
  display: flex;
  gap: var(--space-2);
  /* Nothing while the search box shares the line (it grows into the
     slack); once the search box has dropped, it holds the pair at the end
     of the line. */
  margin-left: auto;
}

.browse-filter-cta {
  min-width: 100px;
}

/* The row lays itself out by what it holds, not by the screen (Section.js
   #fitFilterRow). It keeps the first of these that fits, each adding to the
   ones before it: everything on one line; the search box on a line of its
   own after the rest; the selects' words traded for their glyphs (a select
   without one is named by its first option); the CTAs on a line of their
   own after that, splitting it evenly (a lone CTA fills it); and last the
   selects giving up their widest option's width, so two still share their
   line however narrow it is. */
.browse-filter-controls.search-apart .browse-filter-search {
  order: 1;
  flex-basis: 100%;
}
.browse-filter-controls.glyph-only .browse-filter-label {
  display: none;
}
.browse-filter-controls.glyph-only .browse-filter-icon:not(:empty) {
  display: inline-flex;
}
.browse-filter-controls.actions-apart .browse-filter-actions {
  order: 2;
  flex-basis: 100%;
}
.browse-filter-controls.actions-apart .browse-filter-cta {
  flex: 1;
}
.browse-filter-controls.squeezed .browse-filter-fields,
.browse-filter-controls.squeezed .browse-filter-field,
.browse-filter-controls.squeezed .browse-filter-select {
  min-width: 0;
}
.browse-filter-controls.squeezed .browse-filter-select {
  flex: 1;
}

/* The pose each layout is measured in, for one synchronous read: the line
   held to one line, each control at its own width (the search box at its
   basis), and what the layout sends to a line of its own left out. */
.browse-filter-controls.measuring {
  flex-wrap: nowrap;
}
.browse-filter-controls.measuring > * {
  flex-shrink: 0;
}
.browse-filter-controls.measuring.search-apart > .browse-filter-search,
.browse-filter-controls.measuring.actions-apart > .browse-filter-actions {
  display: none;
}

/* Results grid sits below the controls inside the same panel. Empty
   (between renders) it collapses so the panel doesn't carry dead space. */
.browse-filter-grid {
  margin-top: var(--space-2);
}

.browse-filter-grid:empty {
  margin-top: 0;
}

/* The search box's inner layout (icon + input + clear button). Width comes
   from its flex sizing (.browse-filter-search), so none is set here. */
.section-search {
  position: relative;
  display: flex;
  align-items: center;
}

/* Positioning/centering come from the shared .search-icon base in
   common/style.css; only color and size are section-specific. */
.section-search-icon {
  color: var(--color-text-dark);
}

.section-search-icon svg {
  width: 16px;
  height: 16px;
}

/* Extends the shared .form-inst-search base; only the trailing gutter for the
   clear (x) button is section-specific. */
.form-inst-search-section {
  padding-right: calc(var(--space-2) + 24px);
}

/* Clear (x) button, mirrors the search icon on the opposite edge */
.button-bare-inst-search-clear {
  position: absolute;
  right: var(--space-2);
  padding: 0;
  line-height: 0;
  appearance: none;
  -webkit-appearance: none;
  color: var(--color-text-dark);
}

.button-bare-inst-search-clear svg {
  width: 16px;
  height: 16px;
}

:where(html[data-pointer='mouse']) .button-bare-inst-search-clear:hover {
  color: var(--color-text);
}
