/* ===== ChromaCards — Spot-themed spotlight reveal grid =====
   Adapted from reactbits.dev/components/chroma-grid.
   Default state: cards softly desaturated/cream-washed.
   Cursor spotlight punches a hole in the mute layer, revealing full-color cards underneath.
*/

.chroma-cards {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
  /* spotlight size + position, animated by GSAP */
  --r: 320px;
  --x: 50%;
  --y: 50%;
  isolation: isolate;
}

@media (max-width: 980px) {
  .chroma-cards { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 560px) {
  .chroma-cards { grid-template-columns: 1fr; }
}

/* ---- individual cards ---- */
.chroma-card {
  position: relative;
  display: block;
  min-height: 320px;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: #efeae3;
  transition: border-color 0.35s ease, transform 0.4s cubic-bezier(.2,.8,.2,1), box-shadow 0.4s ease;
  --mouse-x: 50%;
  --mouse-y: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 6px 18px rgba(0,0,0,0.04);
}

.chroma-card:hover {
  border-color: var(--card-border);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.05), 0 20px 44px rgba(0,0,0,0.08);
}

/* photo background — always full-bleed, full color. Grayscale is applied via the mute overlay. */
.chroma-card__bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  z-index: 0;
}

/* warm gradient tint that sits on the photo — only shows in color state, very light */
.chroma-card__tint {
  position: absolute;
  inset: 0;
  background: var(--card-tint);
  opacity: 0.2;
  mix-blend-mode: overlay;
  z-index: 1;
}

/* bottom scrim so text stays legible over imagery */
.chroma-card__scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
    rgba(255,255,255,0) 0%,
    rgba(255,255,255,0) 38%,
    rgba(255,255,255,0.85) 58%,
    rgba(255,255,255,0.98) 78%,
    #ffffff 100%);
  z-index: 2;
}

/* per-card hover light following the mouse — subtle, adds life */
.chroma-card::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 3;
  background: radial-gradient(circle at var(--mouse-x) var(--mouse-y), rgba(255,255,255,0.35), transparent 55%);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.45s ease;
}
.chroma-card:hover::before { opacity: 1; }

/* card content — grid with fixed rows so titles align across cards.
   z-index: 10 sits above the mute/fade overlays (z 5/6) so text stays
   crisp and full-color even when the photo behind is grayscale-washed. */
.chroma-card__inner {
  position: relative;
  z-index: 10;
  height: 100%;
  min-height: 320px;
  padding: 18px 20px 22px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  row-gap: 14px;
}
.chroma-card__icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(6px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--primary-strong);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  align-self: start;
  justify-self: start;
  grid-row: 1;
}
.chroma-card__text {
  grid-row: 3;
  align-self: end;
}
.chroma-card__text h3 {
  font-family: var(--font-body);
  /* fluid sizing: scales down on narrow columns so the longest title
     ("Discover local favorites") stays on ONE line at every breakpoint. */
  font-size: clamp(15px, 1.55cqw + 8px, 19px);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.2;
  margin: 0 0 8px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chroma-card__text p {
  font-size: 14.5px;
  color: var(--ink);          /* full-strength ink for legibility on busy bg */
  line-height: 1.55;
  margin: 0;
  /* reserve 4 lines so body heights match across cards, titles align */
  min-height: calc(14.5px * 1.55 * 4);
}
/* enable container queries on each card so the h3 can size itself by card width */
.chroma-card { container-type: inline-size; }

/* ---- the mute layer: true grayscale, except where the spotlight reveals full color ---- */
.chroma-cards__mute {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background: rgba(0,0,0,0.001); /* transparent but triggers backdrop-filter */
  backdrop-filter: grayscale(1) brightness(0.95) contrast(0.95);
  -webkit-backdrop-filter: grayscale(1) brightness(0.95) contrast(0.95);
  border-radius: 24px;

  mask-image: radial-gradient(
    circle var(--r) at var(--x) var(--y),
    transparent 0%,
    transparent 18%,
    rgba(0,0,0,0.15) 34%,
    rgba(0,0,0,0.35) 50%,
    rgba(0,0,0,0.55) 65%,
    rgba(0,0,0,0.72) 80%,
    rgba(0,0,0,0.88) 92%,
    black 100%
  );
  -webkit-mask-image: radial-gradient(
    circle var(--r) at var(--x) var(--y),
    transparent 0%,
    transparent 18%,
    rgba(0,0,0,0.15) 34%,
    rgba(0,0,0,0.35) 50%,
    rgba(0,0,0,0.55) 65%,
    rgba(0,0,0,0.72) 80%,
    rgba(0,0,0,0.88) 92%,
    black 100%
  );
}

/* ---- the fade layer: grayscale fill over the spotlight when pointer isn't present ---- */
.chroma-cards__fade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
  background: rgba(0,0,0,0.001);
  backdrop-filter: grayscale(1) brightness(0.95) contrast(0.95);
  -webkit-backdrop-filter: grayscale(1) brightness(0.95) contrast(0.95);
  border-radius: 24px;

  mask-image: radial-gradient(
    circle var(--r) at var(--x) var(--y),
    white 0%,
    white 18%,
    rgba(255,255,255,0.85) 34%,
    rgba(255,255,255,0.65) 50%,
    rgba(255,255,255,0.42) 65%,
    rgba(255,255,255,0.22) 80%,
    rgba(255,255,255,0.08) 92%,
    transparent 100%
  );
  -webkit-mask-image: radial-gradient(
    circle var(--r) at var(--x) var(--y),
    white 0%,
    white 18%,
    rgba(255,255,255,0.85) 34%,
    rgba(255,255,255,0.65) 50%,
    rgba(255,255,255,0.42) 65%,
    rgba(255,255,255,0.22) 80%,
    rgba(255,255,255,0.08) 92%,
    transparent 100%
  );

  opacity: 1;
  transition: opacity 0.25s ease;
}

/* reduced motion — skip the effect, show full color */
@media (prefers-reduced-motion: reduce) {
  .chroma-cards__mute,
  .chroma-cards__fade { display: none; }
}
