.shopify-app-block:has(> joy-loyalty-page-v2) {
  width: 100%;
  align-self: stretch;
}

joy-loyalty-page-v2[section-id] {
  display: block;
  width: 100%;
}

/* The all-in-one block takes precedence when both delivery modes are present.
   Apply this before the bundle mounts so duplicate section skeletons never
   flash while JavaScript is loading. */
body:has(joy-loyalty-page-v2:not([section-id]))
  .shopify-app-block:has(> joy-loyalty-page-v2[section-id]),
body:has(joy-loyalty-page-v2:not([section-id])) joy-loyalty-page-v2[section-id] {
  display: none;
}

joy-loyalty-page-v2[data-lp-ready] > .joy-lpv2-skel {
  display: none;
}

/* ── The skeleton ──────────────────────────────────────────────────────────
   One vocabulary for both delivery modes. Shapes are chosen per section in
   `snippets/loyalty-page-v2-skeleton-band.liquid`; this file only draws them.

   Why the numbers are what they are. The skeleton is replaced in place, so a
   gap that does not match the real one does not merely read cramped — it moves
   every band the moment the bundle mounts. Numbers below are the page's own
   (tokens.css, shared-styles.ts).

   Modelled the way the page is BUILT, not with one blanket margin: a section
   owns 48px of padding top and bottom (--joy-space-12), while a hero owns
   nothing at all (joy-loyalty-hero.ts :host is display+font only, and it is not
   wrapped in a section). That one difference gives every case for free — 96px
   between two sections, 48px between a hero and a section, 0 above a hero at
   the top of the page, 0 between two heroes — and needs no :last-child rule.

   Header: title is --joy-space-2 (8px) off its subtitle, subtitle 40px off the
   content. 40 is the landingSectionStyles rhythm (faq, howItWorks, tiers);
   earn/redeem run .joy-lp-v2__programs, which is 16+32 = 48. One skeleton
   cannot be both — 40 is chosen and the 8px accepted, rather than pretending a
   single number is exact for all bands.

   Only the horizontal gutter steps down on a phone, at the width the page
   steps it (upTo640, joy-loyalty-page-v2.ts:261-268). The vertical rhythm
   deliberately does not: .joy-lp-v2__programs has no phone step-down, and
   earn/redeem are the two bands almost every page carries. */

.joy-lpv2-skel {
  display: block;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding-inline: 24px;
  box-sizing: border-box;
}

.joy-lpv2-skel__band {
  padding-block: 48px;
}

.joy-lpv2-skel__band--flush {
  padding-block: 0;
}

.joy-lpv2-skel__sh {
  background: linear-gradient(90deg, #ececec 25%, #f4f4f4 37%, #ececec 63%);
  background-size: 400% 100%;
  animation: joy-lpv2-skel-shimmer 1.4s ease infinite;
  border-radius: 12px;
}

/* Banner — hero, inlineBanner. */
.joy-lpv2-skel__banner {
  min-height: clamp(300px, 42vw, 500px);
}

/* Section header — drawn by every shape that has one on the real page. Banner
   and split deliberately do not: a hero's title is inside the banner artwork,
   and referral's is inside its content column, so a centred pair of bars above
   them was inventing a header the section never draws. */
.joy-lpv2-skel__line {
  width: min(340px, 62%);
  height: 24px;
  margin: 0 auto 8px;
}

.joy-lpv2-skel__subline {
  width: min(440px, 78%);
  height: 16px;
  margin: 0 auto 40px;
}

/* Grid — earn, redeem, myRewards, redeemProgram, and the card/carousel tier
   variants. Column count comes from the stored `columns`, so a two-up page
   does not flash three cards. */
.joy-lpv2-skel__grid {
  display: grid;
  grid-template-columns: repeat(var(--joy-skel-cols, 3), minmax(0, 1fr));
  gap: 20px;
}

.joy-lpv2-skel__card {
  min-height: 170px;
}

/* Split — referral and walletPass. Tracks come from the stored imageLayout;
   `--joy-skel-a` is whichever column the snippet placed first. */
/* calc, not `var(--joy-skel-a)fr` — a custom property cannot be concatenated
   with a unit, and that form parses as invalid and drops the whole
   declaration. */
.joy-lpv2-skel__split {
  display: grid;
  grid-template-columns: calc(var(--joy-skel-a, 6) * 1fr) calc(var(--joy-skel-b, 6) * 1fr);
  gap: 24px;
  align-items: center;
}

.joy-lpv2-skel__copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

/* The header bars are centred on a full-width band; inside a content column
   they are not. */
.joy-lpv2-skel__copy .joy-lpv2-skel__line,
.joy-lpv2-skel__copy .joy-lpv2-skel__subline {
  margin-inline: 0;
  width: 100%;
}

.joy-lpv2-skel__copy .joy-lpv2-skel__subline {
  margin-bottom: 24px;
}

/* The referral link box / wallet button row. */
.joy-lpv2-skel__field {
  width: 100%;
  height: 44px;
}

.joy-lpv2-skel__media {
  min-height: clamp(260px, 34vw, 420px);
}

/* Table — the matrix / tinted-columns / dark-header tier variants, which draw
   a header band over benefit rows rather than a row of cards. */
.joy-lpv2-skel__table {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.joy-lpv2-skel__thead {
  height: 56px;
}

.joy-lpv2-skel__trow {
  height: 52px;
}

/* Rows — activity, faq, referralManagement, linkAccounts, and the
   list/text/pill program layouts. */
.joy-lpv2-skel__rows {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.joy-lpv2-skel__row {
  height: 64px;
}

/* Panel — accountDashboard: one wide surface rather than a card row. */
.joy-lpv2-skel__panel {
  min-height: 220px;
}

.joy-lpv2-section-empty {
  padding: 48px 24px;
  color: #6b7280;
  font-family: sans-serif;
  text-align: center;
  border: 1px dashed #d0d0d0;
  border-radius: 8px;
}

@keyframes joy-lpv2-skel-shimmer {
  0% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0 50%;
  }
}

/* The referral card stacks to one column at 768, not at the page's own phone
   width — joy-referral.ts:766 wraps its `onPhone` block in that query — so the
   band standing in for it has to turn at the same width or it will re-flow
   under the real one. */
@media (max-width: 768px) {
  .joy-lpv2-skel__split {
    grid-template-columns: 1fr;
  }
}

/* A phone never draws the tier table at all — TIERS_MOBILE_LAYOUTS is cards or
   carousel only, and PHONE_VIEWPORT_QUERY (joy-loyalty-page-v2.ts:445) turns at
   760. Liquid has no viewport to branch on, so the table stand-in it printed
   for the desktop shape is reshaped here into the card the shopper will
   actually get. The component needs no equivalent rule: it resolves the variant
   through _resolveTiersVariant and never renders a table at this width. */
@media (max-width: 760px) {
  .joy-lpv2-skel__thead {
    display: none;
  }

  .joy-lpv2-skel__trow {
    height: 170px;
  }
}

/* The two step-downs the real programs grid takes, at the widths it takes them
   (joy-loyalty-page-v2.ts:374-378 tablet, :392-425 phone). The counts are
   resolved in the band snippet from the same formula the grid itself uses, so
   what stands in for earn/redeem is the number of cards that will land. */
@media (max-width: 1024px) {
  .joy-lpv2-skel__grid {
    grid-template-columns: repeat(var(--joy-skel-cols-tablet, 3), minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .joy-lpv2-skel__grid {
    grid-template-columns: repeat(var(--joy-skel-cols-mobile, 1), minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .joy-lpv2-skel {
    padding-inline: 16px;
  }

  .joy-lpv2-skel__grid {
    gap: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .joy-lpv2-skel__sh {
    animation: none;
  }
}
