/*
 * Pattern group "cards" (docs/design/pattern-library.md): link cards
 * (site/snippets/patterns/link-cards.php) and choice cards
 * (choice-cards.php). Linked once per page by the first of these
 * snippets, never in the head and never on a page that does not use them.
 * The grid itself is the shared .grid (site.css); cards reveal and
 * stagger through the shared observer (.grid > *, key "reveal").
 *
 * Classes are the snippets' default block names (pt-*). When a snippet
 * mirrors the tier pages (tier-next, tier-fit) the tier styles in
 * tiers.css apply instead, so this file never changes the tier pages.
 *
 * Interaction: the card's one link covers the card; hover adds the hard
 * shadow, keyboard focus draws the 3px ring around the whole card. The
 * lift on hover is interface feedback (no key), under reduced motion it
 * stays still.
 */

@layer templates {
  .pt-links__cards,
  .pt-choice__cards {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  :is(.pt-links__card, .pt-choice__card) {
    position: relative;
    padding: var(--space-4);
    border: var(--border);
    border-radius: var(--radius-sm);
    background: var(--color-white);
    color: var(--color-ink);
    text-align: center;
  }

  :is(.pt-links__card, .pt-choice__card) > * {
    margin: 0;
  }

  :is(.pt-links__card, .pt-choice__card) > * + * {
    margin-block-start: var(--space-2);
  }

  /* The card's one link covers the whole card */
  :is(.pt-links__card, .pt-choice__card) a::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
  }

  :is(.pt-links__card, .pt-choice__card):hover {
    box-shadow: var(--shadow-hard);
  }

  :is(.pt-links__card, .pt-choice__card):has(a:focus-visible) {
    outline: 3px solid var(--focus-ring);
    outline-offset: 2px;
  }

  /* ---------- Link cards ---------- */

  .pt-links__cards {
    max-width: 52rem;
    margin-inline: auto;
  }

  .pt-links__cards.grid--3 {
    max-width: none;
  }

  /* As on the tier pages: regular-weight sentences, a lone link is the
     shared link button (.link-line, blocks.css) */

  /* ---------- Choice cards ---------- */

  .pt-choice__media {
    max-width: 12rem;
    margin-inline: auto;
  }

  .pt-choice__media > :is(svg, img) {
    display: block;
    width: 100%;
    height: auto;
  }

  .pt-choice__title {
    font-size: var(--step-2);
  }

  .pt-choice__title a {
    text-decoration: none;
  }

  .pt-choice__title a:hover {
    text-decoration: underline;
  }

  .pt-choice__card.is-current {
    background: var(--accent-pale);
    box-shadow: var(--shadow-hard);
  }

  .pt-choice__here {
    display: inline-block;
    padding: 0.35em 0.9em;
    border: var(--border);
    border-radius: var(--radius-pill);
    background: var(--accent);
    font-size: var(--step--1);
    font-weight: var(--weight-strong);
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .pt-choice__scope {
    font-size: var(--step--1);
    font-weight: 600;
  }

  .pt-choice__price {
    font-family: var(--font-heading);
    font-size: var(--step-1);
  }

  .pt-choice__more {
    max-width: var(--measure);
    margin: var(--space-5) auto 0;
    text-align: center;
  }
}

@layer motion {
  @media screen and (prefers-reduced-motion: no-preference) {
    /* Interface feedback (no key, like the other cards): a 4px lift with the shadow on
       hover (hover devices) and on keyboard focus inside the card. The card is the grid
       item the shared reveal moves with "transform" and "opacity", so the lift uses
       "translate" (one property per effect), and this one transition list repeats the
       reveal's two entries with their stagger delay (motion.css, fx:reveal) so neither
       effect drops the other's timing. */
    :is(.pt-links__card, .pt-choice__card) {
      transition:
        opacity var(--motion-reveal) var(--ease-out) calc(var(--i, 0) * var(--motion-stagger)),
        transform var(--motion-reveal) var(--ease-out) calc(var(--i, 0) * var(--motion-stagger)),
        translate var(--motion-base) var(--ease-out);
    }

    :is(.pt-links__card, .pt-choice__card):has(a:focus-visible) {
      translate: 0 -4px;
    }

    @media (hover: hover) {
      :is(.pt-links__card, .pt-choice__card):hover {
        translate: 0 -4px;
      }
    }
  }
}
