/* The customer flow after the 2026-12-04 audit (adr/0029): Grella's header, the business's face,
   the one-tap confirm screen, and the card with its QR first. */
@layer components {
  /* Grella, small and centred, above every customer screen. */
  .customer-header {
    display: flex;
    justify-content: center;
    padding-block: var(--block-space) 0;

    & .customer-header__logo { display: block; block-size: 1.375rem; inline-size: auto; }
  }

  /* The business: its logo on a white tile so any logo reads on any card colour, then its name. */
  .business {
    display: flex;
    align-items: center;
    gap: var(--inline-space);
    margin: 0;
    font-weight: 700;
  }

  .business__logo {
    display: grid;
    place-items: center;
    flex: none;
    inline-size: 2rem;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 0.5rem;
    background: #fff;
    color: var(--card-color, #6448e8); /* the initials, when there is no logo */
    font-size: var(--text-x-small);
    font-weight: 800;
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.18);

    & img { inline-size: 100%; block-size: 100%; object-fit: contain; }
  }

  /* Off the card (the confirm screen), the tile takes Grella's violet. */
  .customer > .business .business__logo { background: var(--color-link); color: var(--color-text-reversed); box-shadow: none; }

  /* The join page's card is a header: no QR yet, the slots in one row, the form below it. */
  .loyalty-card--header {
    padding: calc(var(--block-space) * 1.25);
    gap: var(--block-space-half);

    & .stamp-progress__stamps { --slot: 1.375rem; gap: 0.25rem; flex-wrap: nowrap; }
  }

  /* On the card, stickers in rows of five under the QR, at a size that keeps the card short. */
  .customer .loyalty-card .stamp-progress__stamps--stickers {
    --slot: 2.375rem;
    gap: calc(var(--slot) * 0.2);
    max-inline-size: calc(var(--slot) * 6); /* five and their gaps (5.8 slots), with room to spare for rounding */
  }

  /* The official WhatsApp glyph, in the button's own colour (adr/0029: a third-party mark). */
  .whatsapp-mark {
    display: inline-block;
    inline-size: 1.375rem;
    aspect-ratio: 1;
    background: currentColor;
    mask: url("/assets/whatsapp/logo-dedd0052.svg") center / contain no-repeat;
  }

  .customer .or {
    display: flex;
    align-items: center;
    gap: var(--inline-space);
    color: var(--color-subtle);
    font-size: var(--text-small);

    &::before, &::after { content: ""; flex: 1; border-block-start: 1px solid var(--color-border); }
  }

  .link-with-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--inline-space);
    font-weight: 600;
  }

  .customer .quiet { margin: 0; color: var(--color-subtle); text-align: center; }

  /* An email on its way: one line on the positive tint, the icon naming the state. */
  .customer .sent {
    display: flex;
    gap: var(--inline-space);
    align-items: flex-start;
    margin: 0;
    padding: var(--block-space-half) var(--block-space);
    border-radius: var(--radius);
    background: var(--color-positive-tint);
    color: var(--color-text);
  }

  /* "Confirma que eres tú" under the card: a line with its action, never a box. */
  .card-unverified {
    display: flex;
    align-items: center;
    gap: var(--inline-space);
    margin: 0;
    padding-block-start: var(--block-space-half);
    border-block-start: 1px solid var(--color-border);
    font-size: var(--text-small);

    & a { margin-inline-start: auto; font-weight: 600; white-space: nowrap; }
  }

  /* "Mis tarjetas" (adr/0029): the cards on one grid cell, so the stack is as tall as its tallest
     card; card_stack_controller sets each card's place, tilt and layer. */
  .card-stack {
    display: grid;
    padding: var(--block-space-half) var(--inline-space) var(--block-space-double);
    touch-action: pan-y; /* the page still scrolls; sideways is the card's */
    border-radius: var(--radius-large);
  }

  .card-stack__card {
    grid-area: 1 / 1;
    color: #fff;
    text-decoration: none;
    box-shadow: 0 1px 2px rgb(27 24 40 / 0.15), 0 10px 24px -8px rgb(27 24 40 / 0.35);
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    transition: transform 260ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 200ms;

    & .stamp-progress__label { display: none; } /* the count below says it, larger */
    & .stamp-progress__stamps--stickers { --slot: 2.25rem; gap: calc(var(--slot) * 0.2); max-inline-size: calc(var(--slot) * 6); }
    align-self: start; /* each card its own height: a short one sits on the pile, it doesn't stretch */
  }

  .card-stack__card--dragging { transition: none; cursor: grabbing; }

  /* The cards underneath show their backs: colour only, the content fades in as one comes up. */
  .card-stack__card > * { transition: opacity 200ms; }
  .card-stack__card--behind { align-self: stretch; } /* as tall as the stack, so a short card still peeks out */
  .card-stack__card--behind > * { opacity: 0; }

  @media (prefers-reduced-motion: reduce) {
    .card-stack__card { transition: none; }
  }

  .card-stack__count {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--inline-space);
  }

  .card-stack__stamps {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;

    & small { font-size: var(--text-normal); font-weight: 600; color: inherit; opacity: 0.85; }
  }

  .card-stack__ready {
    display: inline-flex;
    align-items: center;
    gap: var(--inline-space-half);
    padding: 0.125rem 0.625rem 0.125rem 0.25rem;
    border-radius: 999px;
    background: var(--color-reward, #c9f45a);
    color: #1b1828;
    font-weight: 700;
    font-size: var(--text-small);
  }

  .card-stack__nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: calc(var(--inline-space) * 3);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
  }

  .card-stack__button {
    display: grid;
    place-items: center;
    inline-size: 2.75rem;
    aspect-ratio: 1;
    padding: 0;
    border-radius: 50%; /* colours come from .btn's variables, so hover fills it and the ring turns white */
  }
}
