/* UNIVERSAL GRID SYSTEM */

.universal-grid {
  /* --- DEFAULT SETTINGS --- */
  --grid-gap: 20px;
  --min-height: 400px;
  
  /* Image Control */
  --img-scale: 1;
  --img-scale-hover: 1.05;
  --img-object-fit: cover;
  --img-pos: center;
  
  /* Color & Opacity Control */
  --overlay-color: rgba(0, 0, 0, 0.65);
  --overlay-opacity-hover: 1;
  
  /* BOX TOGGLE & STYLE */
  --box-bg: rgba(0, 0, 0, 0.4); /* Set to 'transparent' to hide box */
  --box-bg-hover: rgba(0, 0, 0, 0);
  --box-padding: 25px; /* Set to 0px if box is hidden */
  
  /* Text Control */
  --text-color: #ffffff;
  --heading-color: #ffffff;
  --desc-color: #ffffff;
  
  --border-radius: 8px;

  display: grid;
  gap: var(--grid-gap);
  width: 100%;
  grid-template-columns: 1fr; 
}

/* Modifier classes for columns */
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }

/* THE TILE */
.tile-module {
  position: relative;
  overflow: hidden;
  display: flex;
  min-height: var(--min-height);
  border-radius: var(--border-radius);
  background: #222;
}

/* IMAGE LAYER */
.tile-module .bg-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  object-fit: var(--img-object-fit);
  object-position: var(--img-pos);
  transform: scale(var(--img-scale));
  transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* CONTENT & OVERLAY LAYER */
.tile-content-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  padding: 20px;
}

.tile-content-wrapper::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--overlay-color);
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: 1;
}

/* TEXT BOX */
.text-box {
  position: relative;
  z-index: 2;
  /* Toggle logic is applied here */
  background: var(--box-bg);
  padding: var(--box-padding);
  
  border-radius: 10px;
  text-align: center;
  transform: scale(0.95);
  transition: all 0.4s ease;
}

.text-box h3 { color: var(--heading-color); margin-bottom: 5px; }
.text-box p { color: var(--desc-color); margin: 0; }

/* DESKTOP HOVER EFFECTS */
@media (min-width: 769px) {
  .tile-module:hover .bg-image {
    transform: scale(var(--img-scale-hover));
  }
  .tile-module:hover .tile-content-wrapper::before {
    opacity: var(--overlay-opacity-hover);
  }
  .tile-module:hover .text-box {
    transform: scale(1);
    background: var(--box-bg-hover);
  }
}

/* MOBILE STACKING */
@media (max-width: 768px) {
  .universal-grid {
    grid-template-columns: 1fr !important;
    --min-height: 300px;
  }
}