/*
 * FarmFinder card template: the standard and holo foil variants.
 *
 * A card is a canvas face (drawn by card-template.js) with optional foil,
 * sparkle and glare layers above it. Pointer position arrives as custom
 * properties: --ffc-mx and --ffc-my place the light, --ffc-rx and --ffc-ry
 * tilt the card, and --ffc-hyp grows the sheen toward the edges.
 */
.ffc-card {
  --ffc-width: 220px;
  --ffc-rx: 0deg;
  --ffc-ry: 0deg;
  --ffc-mx: 50%;
  --ffc-my: 50%;
  --ffc-hyp: 0;
  position: relative;
  display: inline-block;
  flex: none;
  width: var(--ffc-width);
  aspect-ratio: 500 / 700;
  border-radius: calc(var(--ffc-width) * 0.052);
  background: #161616;
  box-shadow: 0 10px 22px rgba(20, 28, 14, 0.28), 0 2px 5px rgba(20, 28, 14, 0.22);
  isolation: isolate;
  overflow: hidden;
  transform: perspective(900px) rotateX(var(--ffc-rx)) rotateY(var(--ffc-ry));
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.3s ease;
  vertical-align: top;
}

button.ffc-card {
  padding: 0;
  border: 0;
  margin: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.ffc-card:focus-visible {
  outline: 3px solid #c5d733;
  outline-offset: 3px;
}

.ffc-card.is-active {
  box-shadow: 0 18px 38px rgba(20, 28, 14, 0.34), 0 4px 10px rgba(20, 28, 14, 0.24);
  transition: transform 0.08s linear, box-shadow 0.2s ease;
}

.ffc-card__face {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.ffc-card.is-ready .ffc-card__face {
  opacity: 1;
}

.ffc-card__glare,
.ffc-card__foil,
.ffc-card__sparkle {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
}

/* Every card catches the light. */
.ffc-card__glare {
  background: radial-gradient(circle at var(--ffc-mx) var(--ffc-my), rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0.12) 24%, rgba(255, 255, 255, 0) 56%);
  mix-blend-mode: soft-light;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.ffc-card.is-active .ffc-card__glare {
  opacity: 1;
}

/* Holo foil: a rainbow band that slides as the card turns. */
.ffc-card__foil {
  background:
    repeating-linear-gradient(115deg,
      hsl(2 95% 72%) 0%, hsl(45 100% 68%) 7%, hsl(96 90% 66%) 14%, hsl(178 95% 70%) 21%,
      hsl(222 100% 74%) 28%, hsl(282 90% 74%) 35%, hsl(2 95% 72%) 42%),
    linear-gradient(160deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0) 40%, rgba(255, 255, 255, 0.25) 80%);
  background-size: 260% 260%, 100% 100%;
  background-position: var(--ffc-mx) var(--ffc-my), center;
  mix-blend-mode: color-dodge;
  opacity: 0.2;
  transition: opacity 0.3s ease;
}

.ffc-card--foil.is-active .ffc-card__foil {
  opacity: calc(0.26 + var(--ffc-hyp) * 0.3);
}

.ffc-card__sparkle {
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.95) 0 1px, transparent 1.6px),
    radial-gradient(circle, rgba(255, 244, 196, 0.9) 0 1px, transparent 1.8px);
  background-size: 23px 29px, 37px 31px;
  background-position: calc(var(--ffc-mx) * -0.4) calc(var(--ffc-my) * -0.3), calc(var(--ffc-mx) * 0.3) calc(var(--ffc-my) * 0.5);
  mix-blend-mode: overlay;
  opacity: 0.35;
}

.ffc-card--foil.is-active .ffc-card__sparkle {
  opacity: 0.75;
}

/* Resting foil cards keep a slow shimmer so they read as special. */
@keyframes ffc-foil-drift {
  from { background-position: 0% 40%, center; }
  to { background-position: 100% 60%, center; }
}

.ffc-card--foil:not(.is-active) .ffc-card__foil {
  animation: ffc-foil-drift 7s ease-in-out infinite alternate;
}

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

  .ffc-card--foil .ffc-card__foil {
    animation: none;
  }
}

@media (prefers-contrast: more) {
  .ffc-card__foil,
  .ffc-card__sparkle,
  .ffc-card__glare {
    display: none;
  }
}

.ffc-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
