/* --------- Card block (blocks/card) --------- */

/* Fills its column, so cards in a row match in height. The text follows the
   icon or figure at the top, so in a row the titles line up whatever the
   length of the text — some mockups bottom-align it, by mistake. */
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--wp--preset--spacing--70);
  box-sizing: border-box;
  height: 100%;
  padding: clamp(24px, 0.75vw + 21.6px, 36px);
  border: 1px solid var(--wp--preset--color--outline);
  border-radius: clamp(24px, 0.75vw + 21.6px, 36px);
  background-color: var(--wp--preset--color--base);
  color: var(--wp--preset--color--contrast);
  transition:
    background-color 0.2s ease,
    border-color 0.2s ease,
    color 0.2s ease;
}

/* A card with an anchor (the Savings menu links to its three): a jump to
   it stops short of the card. In a row, far enough up to show the
   section's heading and lead above it; stacked, just clear of the edge. */
.card[id] {
  scroll-margin-top: var(--wp--preset--spacing--50);
}

@media (min-width: 782px) {
  .card[id] {
    scroll-margin-top: 12rem;
  }
}

.card-icon {
  display: block;
  flex: none;
  width: 52px;
  height: 52px;
  background-color: var(--wp--preset--color--primary);
  mask: var(--card-icon) no-repeat left center / contain;
  -webkit-mask: var(--card-icon) no-repeat left center / contain;
  transition: background-color 0.2s ease;
}

/* A figure in place of the icon. */
.card .card-figure {
  margin: 0;
  color: var(--wp--preset--color--primary);
  font-size: var(--wp--preset--font-size--display);
  font-weight: 300;
  line-height: 1;
  transition: color 0.2s ease;
}

.card-arrow {
  display: block;
  flex: none;
  width: 16px;
  height: 16px;
  margin-top: auto;
  background-color: var(--wp--preset--color--primary);
  mask: url(../../assets/img/arrow-list.svg) no-repeat center / contain;
  -webkit-mask: url(../../assets/img/arrow-list.svg) no-repeat center / contain;
  transition: background-color 0.2s ease;
}

.card .card-title {
  margin: 0;
  color: var(--wp--preset--color--primary);
  font-size: var(--wp--preset--font-size--xl);
  font-weight: 500;
  line-height: 1.2;
  transition: color 0.2s ease;
}

.card .card-text {
  max-width: 32rem;
  margin: 0.75rem 0 0;
}

/* Blocks placed inside the card, under its text and a line; the icon sits
   closer. */
.card--more {
  gap: var(--wp--preset--spacing--60);
}

.card--more .card-text {
  max-width: none;
}

/* The inner blocks sit at the bottom of the card: in a row, where the texts
   above differ in length, the lines and what is under them still line up. */
.card--more .card-body {
  display: flex;
  flex: 1;
  flex-direction: column;
}

.card--more .card-body > :has(+ .card-more) {
  margin-bottom: var(--wp--preset--spacing--60);
}

.card--more .card-more {
  margin-top: auto;
}

.card-more {
  margin-top: var(--wp--preset--spacing--60);
  padding-top: var(--wp--preset--spacing--60);
  border-top: 1px solid color-mix(in srgb, currentColor 15%, transparent);
}

.card-more > :first-child {
  margin-top: 0;
}

.card-more > :last-child {
  margin-bottom: 0;
}

.card--small {
  gap: var(--wp--preset--spacing--60);
  border-radius: 24px;
}

.card--small .card-title {
  font-size: var(--wp--preset--font-size--large);
}

.card-title a {
  color: inherit;
  text-decoration: none;
}

/* The title's link covers the whole card. */
.card-title a::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.card-title a:focus-visible {
  outline: none;
}

.card:has(.card-title a:focus-visible) {
  outline: 2px solid var(--wp--preset--color--primary);
  outline-offset: 2px;
}

/* On a navy section a card is its outline: yellow line, yellow title, white
   text. */
.has-primary-background-color .card {
  border-color: var(--wp--preset--color--secondary);
  background-color: transparent;
  color: var(--wp--preset--color--base);
}

.has-primary-background-color .card :is(.card-title, .card-figure) {
  color: var(--wp--preset--color--secondary);
}

/* Under an icon or a figure the title is white; a card without either
   keeps it yellow (Corporate). Stays above the hover rules: at equal weight
   the yellow hover has to win. */
.has-primary-background-color :is(.card-icon, .card-figure) + .card-body .card-title {
  color: var(--wp--preset--color--base);
}

.has-primary-background-color :is(.card-icon, .card-arrow) {
  background-color: var(--wp--preset--color--secondary);
}

/* Numbered steps on navy the other way round, as Corporate Service Providers
   draws them: a white figure on the right, the title yellow. The class
   cards-figure-right sits on the section, typed by hand. */
.cards-figure-right .card-figure {
  align-self: flex-end;
}

.cards-figure-right .card .card-figure {
  color: var(--wp--preset--color--base);
}

.cards-figure-right .card-figure + .card-body .card-title {
  color: var(--wp--preset--color--secondary);
}

/* Figures that are words or years rather than step numbers, smaller than the
   display size (Client Testimonials: 1969, BMA, SWIFT). The class
   cards-figure-small sits on the section, typed by hand. */
.cards-figure-small .card .card-figure {
  font-size: var(--wp--preset--font-size--xxl);
}

/* Cards with neither icon nor figure that keep a white title on navy, as
   Insurance draws them. The class cards-title-white sits on the section,
   typed by hand. */
.cards-title-white .card .card-title {
  color: var(--wp--preset--color--base);
}

/* Yellow icons on a white section, as Our Community draws them; with hover
   navy they stay yellow under the mouse. The class cards-icon-yellow sits on
   the section, typed by hand. */
.cards-icon-yellow .card-icon {
  background-color: var(--wp--preset--color--secondary);
}

/* On the pale yellow a card is white without an outline: navy text, yellow
   icon. */
.has-tint-background-color .card {
  border-color: var(--wp--preset--color--base);
  color: var(--wp--preset--color--primary);
}

.has-tint-background-color :is(.card-icon, .card-arrow) {
  background-color: var(--wp--preset--color--secondary);
}

/* Touch screens have no hover; a tap would leave the colour stuck. */
@media (hover: hover) {
  .card--hover-yellow:hover {
    border-color: var(--wp--preset--color--secondary);
    background-color: var(--wp--preset--color--secondary);
    color: var(--wp--preset--color--primary);
  }

  .card--hover-navy:hover {
    border-color: var(--wp--preset--color--primary);
    background-color: var(--wp--preset--color--primary);
    color: var(--wp--preset--color--base);
  }

  .card--hover-navy:hover :is(.card-title, .card-figure) {
    color: var(--wp--preset--color--base);
  }

  .card--hover-navy:hover :is(.card-icon, .card-arrow) {
    background-color: var(--wp--preset--color--secondary);
  }

  .has-primary-background-color .card--hover-yellow:hover :is(.card-title, .card-figure) {
    color: var(--wp--preset--color--primary);
  }

  .has-primary-background-color .card--hover-yellow:hover :is(.card-icon, .card-arrow) {
    background-color: var(--wp--preset--color--primary);
  }
}
