/* ============================================
   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;
  touch-action: none;
}

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

.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 {
  touch-action: none;
  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;
  }
}

/* Cursor follower (desktop) */
.grid-background .cursor-follower {
  position: fixed;
  width: 20px;
  height: 20px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  pointer-events: none;
  z-index: 100;
  transform: translate(-50%, -50%);
  transition: width 0.2s, height 0.2s, border-color 0.2s;
  display: none;
}

@media (hover: hover) and (pointer: fine) {
  .grid-background .cursor-follower {
    display: block;
  }
  .grid-background:hover .cursor-follower {
    width: 40px;
    height: 40px;
    border-color: rgba(255, 255, 255, 0.8);
  }
}

/* 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;
  }
}
