/* ─────────────────────────────────────────────────────────────────
   ChromaGrid — spotlight cursor effect for portfolio
   Vanilla JS/CSS adaptation · ChaChing brand palette
   ───────────────────────────────────────────────────────────────── */

/* Force a stacking context so overlay z-index is contained */
.projects-grid {
  position: relative;
  isolation: isolate;
  align-items: stretch;   /* guarantee all cells in a row share the same height */

  /* cursor-tracking CSS vars — set by JS */
  --x: 50%;
  --y: 50%;
  --r: 380px;
}

/* ── Per-card gradient + local mouse-spotlight ── */
.project-card {
  background: var(--card-gradient, var(--color-surface));
  border-color: var(--card-border-default, var(--color-border));

  /* per-card mouse position — set by JS */
  --mouse-x: 50%;
  --mouse-y: 50%;
}

/* Glow spot that follows the mouse inside each card */
.project-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle 200px at var(--mouse-x) var(--mouse-y),
    var(--card-spotlight, rgba(166, 255, 22, 0.10)),
    transparent 70%
  );
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: 2;
  border-radius: inherit;
}

.project-card:hover::before { opacity: 1; }

/* Highlighted border on hover uses card's own color */
.project-card:hover {
  border-color: var(--card-border, rgba(166,255,22,0.3));
}

/* ── Grid-level overlay ─────────────────────────────────────────
   Always present. The radial mask reveals full color under the
   cursor and grays out cards that are farther away.
────────────────────────────────────────────────────────────────── */
.chroma-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  border-radius: inherit;

  backdrop-filter: grayscale(1) brightness(0.62);
  -webkit-backdrop-filter: grayscale(1) brightness(0.62);
  background: rgba(0, 0, 0, 0.001); /* needed to trigger backdrop-filter in some browsers */

  mask-image: radial-gradient(
    circle var(--r) at var(--x) var(--y),
    transparent      0%,
    transparent      12%,
    rgba(0,0,0,0.07) 28%,
    rgba(0,0,0,0.20) 44%,
    rgba(0,0,0,0.38) 58%,
    rgba(0,0,0,0.58) 74%,
    rgba(0,0,0,0.78) 88%,
    black            100%
  );
  -webkit-mask-image: radial-gradient(
    circle var(--r) at var(--x) var(--y),
    transparent      0%,
    transparent      12%,
    rgba(0,0,0,0.07) 28%,
    rgba(0,0,0,0.20) 44%,
    rgba(0,0,0,0.38) 58%,
    rgba(0,0,0,0.58) 74%,
    rgba(0,0,0,0.78) 88%,
    black            100%
  );
}

/* ── Fade overlay ───────────────────────────────────────────────
   Starts at opacity 1 (full gray). Fades to 0 when cursor enters
   the grid, revealing colors. Fades back to 1 when cursor leaves.
────────────────────────────────────────────────────────────────── */
.chroma-fade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 21;
  border-radius: inherit;

  backdrop-filter: grayscale(1) brightness(0.62);
  -webkit-backdrop-filter: grayscale(1) brightness(0.62);
  background: rgba(0, 0, 0, 0.001);

  opacity: 1;
  /* JS controls opacity transitions via GSAP */
}

/* ── Coming-soon card ── */
.project-card--soon {
  border-style: dashed;
  --card-border-default: rgba(255,255,255,0.1);
  cursor: default;
}

.project-card--soon:hover {
  transform: none;
  border-color: rgba(166,255,22,0.18);
}

.project-card--soon::before { display: none; } /* no spotlight on soon card */

.soon-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.018);
}

.soon-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2rem;
}

.soon-icon {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.12);
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.25);
}

.soon-label {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.2);
  text-align: center;
}

/* ── Responsive grid ────────────────────────────────────────────
   Fluid columns: 3 → 2 → 1
   Cards fill their column — no fixed widths.
────────────────────────────────────────────────────────────────── */
@media (max-width: 980px) {
  .projects-grid { grid-template-columns: repeat(2, 1fr); }
  .project-card--soon { display: none; } /* hide on 2-col so grid stays even */
}

@media (max-width: 560px) {
  .projects-grid { grid-template-columns: 1fr; }
  .project-card--soon { display: none; }
  .project-card__img-wrap { aspect-ratio: 4 / 3; }  /* landscape on single-col */
}

/* Disable ChromaGrid overlay effects on touch devices */
@media (hover: none) {
  .chroma-overlay,
  .chroma-fade { display: none; }
}
