/* ============================================
   INTERACTIVE TOUCH HOVER GRID — Full Background
   GSAP-style grid of + characters behind all content
   ============================================ */

/* Background grid wrapper — fixed behind everything */
.grid-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.grid-background .interactive-grid {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: auto;
}

/* Mobile: touch hover + scroll together */
@media (hover: none) and (pointer: coarse) {
  .grid-background .interactive-grid {
    pointer-events: auto;
    touch-action: pan-y;
  }
  .grid-background .grid {
    touch-action: pan-y;
  }
  .grid-background .grid div {
    pointer-events: auto;
    touch-action: pan-y;
  }
}

.grid-background .grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-cols, 20), 1fr);
  grid-template-rows: repeat(var(--grid-rows, 10), 1fr);
  font-size: var(--grid-font-size, 1.5rem);
  font-weight: 600;
  line-height: 1;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  cursor: none;
  width: 100%;
  height: 100%;
}

/* Grid cells */
.grid-background .grid div {
  padding: 2px;
  opacity: calc(var(--cell-opacity, 0.1) * 0.3);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  transition-property: opacity, rotate, filter;
  transition-duration: 0.8s, 0.4s, 0.6s;
  transition-timing-function: ease-in, ease-out, ease-out;
  scale: 1.5;
  filter: grayscale(1);
  color: hsl(var(--cell-hue, 0) 80% 50%);
  will-change: transform, opacity, filter;
}

/* Desktop hover */
@media (hover: hover) and (pointer: fine) {
  .grid-background .grid div:hover {
    transition-property: opacity, rotate, filter;
    transition-duration: 0s;
    rotate: calc(var(--cell-grade, 0) * 90deg);
    filter: grayscale(0) brightness(1.5);
    opacity: 1;
  }
}

/* Mobile touch hover */
.grid-background .grid div[data-hover] {
  transition-property: opacity, rotate, filter;
  transition-duration: 0s;
  rotate: calc(var(--cell-grade, 0) * 90deg);
  filter: grayscale(0) brightness(1.5);
  opacity: 1;
}

/* Dark theme adjustments */
.grid-background[data-theme="dark"] .grid div {
  opacity: calc(var(--cell-opacity, 0.1) + 0.2);
}

@media (hover: hover) and (pointer: fine) {
  .grid-background[data-theme="dark"] .grid div:hover {
    opacity: 1;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .grid-background .grid div {
    transition: none;
  }
  .grid-background .grid div:hover,
  .grid-background .grid div[data-hover] {
    transition: none;
  }
}
