/* =============================================================================
   SKELETON LOADERS (shared, loaded on every page from base.njk)
   One shimmer, a few reusable building blocks, and per-element hooks.
   Colours come from the design tokens in styles.css (--surface2, --border).
   ============================================================================= */

:root {
  --skel-base:  var(--surface2);
  --skel-shine: rgba(255,255,255,.07);
  --skel-gradient: linear-gradient(100deg, transparent 30%, var(--skel-shine) 50%, transparent 70%);
}

@keyframes skel-shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* The shimmer itself. Apply `.skel` to any block to turn it into a placeholder. */
.skel,
.skel-img,
.skel-line {
  background-color: var(--skel-base);
  background-image: var(--skel-gradient);
  background-size: 200% 100%;
  animation: skel-shimmer 1.6s linear infinite;
}

/* Text-line placeholder: <span class="skel-line" style="width:60%"></span> */
.skel-line {
  display: block;
  height: .9em;
  border-radius: 4px;
  margin: .45em 0;
}

/* Images that haven't loaded yet. skeleton.js adds .skel-img to any <img>
   that is still pending and removes it on load/error, so there is nothing to
   mark up by hand. Opt out with data-no-skel. */
img.skel-img {
  border-radius: 4px;
  color: transparent;        /* hide broken-image alt text while loading */
}
/* skeleton.js adds .skel-sq only to pending images that would otherwise collapse to
   zero height, so images that already have a size are never forced square. */
img.skel-img.skel-sq { aspect-ratio: 1; }

/* Inline SVG slots that are filled by fetch() (the VIP icon). While the
   container is still empty it shows a round shimmer; if the fetch fails,
   JS adds .is-failed so it doesn't shimmer forever. */
.home-title-icon:empty,
.intro-explainer-icon:empty {
  border-radius: 50%;
  background-color: var(--skel-base);
  background-image: var(--skel-gradient);
  background-size: 200% 100%;
  animation: skel-shimmer 1.6s linear infinite;
}
.home-title-icon.is-failed:empty,
.intro-explainer-icon.is-failed:empty {
  background: none;
  animation: none;
}

/* ---------------------------------------------------------------------------
   List/table/timeline placeholders (markup comes from window.Skel in
   skeleton.js). They sit inside the page's real tables and cards, so these
   rules only size the individual pieces.
   --------------------------------------------------------------------------- */
.skel { display: block; border-radius: 4px; }
.skel-line { max-width: 100%; }
.skel-table { pointer-events: none; }
.skel-table tr:hover td { background: none; }
.skel-center { margin-left: auto; margin-right: auto; min-width: 20px; }

/* Flex items that size to their content would collapse the % widths, so
   give the name columns a fixed footprint. */
.skel-table .player-id-block { width: 150px; max-width: 100%; }
.skel-table .map-text { width: 120px; }
.skel-av   { width: 44px; height: 44px; border-radius: 0; flex-shrink: 0; }
.skel-dot  { width: 18px; height: 18px; border-radius: 50%; margin: 0 auto; }
.skel-rank { width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0; }
.skel-tier { margin: 0; }
.skel-name { height: .95em; margin: 0; }
.skel-sub  { height: .7em; margin: 7px 0 0; }
.skel-cell { margin: 0; }
.skel-table .ach-cell .skel-line { margin: 0 auto; }
.skel-table .rank-block-top { justify-content: center; gap: 8px; }
.skel-map   { width: 64px; height: 40px; border-radius: 4px; flex-shrink: 0; }
.skel-badge { width: 54px; height: 20px; border-radius: 3px; }
.skel-month { width: 110px; height: 22px; border-radius: 4px; flex-shrink: 0; }
.skel-icon  { border-color: transparent; }
.skel-date  { width: 74px; margin: 0; }
.tl-item .tl-icon.skel { background-color: var(--skel-base); }

/* ---------------------------------------------------------------------------
   Player profile pages: hero + tab bodies.
   profile-header.js adds .is-loading to .hero (name, avatar) and .level-box
   while loadHero()/loadXP() are in flight, and removes it when they settle.
   Text keeps its box (so nothing jumps) but is painted as a shimmer bar.
   --------------------------------------------------------------------------- */
.hero.is-loading .profile-name,
.hero.is-loading .avatar-fb,
.level-box.is-loading .level-box-num,
.level-box.is-loading .level-box-pct,
.level-box.is-loading .level-box-track {
  color: transparent;
  background-color: var(--skel-base);
  background-image: var(--skel-gradient);
  background-size: 200% 100%;
  animation: skel-shimmer 1.6s linear infinite;
  border-radius: 4px;
}
.hero.is-loading .profile-name { width: fit-content; max-width: 100%; }
.hero.is-loading .avatar-fb { border-color: transparent; }
.level-box.is-loading .level-box-num { width: 5.5em; }
.level-box.is-loading .level-box-pct { min-width: 9em; height: .9em; }
.level-box.is-loading .level-box-track { background-color: var(--skel-base); }
.level-box.is-loading .level-box-fill { visibility: hidden; }

/* Card-shaped blocks that sit inside the real grids (.rk-grid, .ach-grid,
   .pat-grid, .weapons-hero). Real card classes give the grid placement, the
   inline min-height gives the size; these rules just strip the content. */
.skel-card { border-radius: 6px; border-color: transparent; }
/* Double class so the shimmer wins over the real card backgrounds (.rk-card, .ach-card, ...). */
body .skel.skel-card.skel-card {
  background-color: var(--skel-base);
  background-image: var(--skel-gradient);
  background-size: 200% 100%;
  animation: skel-shimmer 1.6s linear infinite;
}
.skel-statval { height: 1.3em; margin: 0 0 8px; }
.skel-statlbl { height: .7em; margin: 0; }
.skel-sechead { width: 130px; height: 14px; }
.skel-num { width: 42px; margin: 0 0 0 auto; }
.skel-rounds { padding: 14px 18px; }
.skel-rounds .skel-line { margin: 12px 0; }

.skel-rank-n { width: 22px; margin: 0; }
.skel-tab { height: 40px; display: block; flex: 1 1 0; min-width: 120px; border-radius: 4px 4px 0 0; }
@media (max-width: 700px) { .skel-tab { flex: 1 1 33%; min-width: 0; } }
.skel-tilegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.skel-gap { height: 14px; }
.skel-hero { border-radius: 6px; }
/* Weapon picker label while its options load. */
#weapon-dd-current.is-loading {
  color: transparent; display: inline-block; min-width: 9em; border-radius: 4px;
  background-color: var(--skel-base);
  background-image: var(--skel-gradient);
  background-size: 200% 100%; animation: skel-shimmer 1.6s linear infinite;
}

@media (max-width: 640px) {
  .skel-hide-sm { display: none; }
  .skel-av { width: 32px; height: 32px; }
  .skel-map { width: 44px; height: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  .skel, .skel-img, .skel-line,
  body .skel.skel-card.skel-card, #weapon-dd-current.is-loading,
  .hero.is-loading .profile-name, .hero.is-loading .avatar-fb,
  .level-box.is-loading .level-box-num, .level-box.is-loading .level-box-pct,
  .level-box.is-loading .level-box-track,
  .home-title-icon:empty, .intro-explainer-icon:empty {
    animation: none;
    background-image: none;   /* flat placeholder, no movement */
  }
}
