/*
 * @file
 * Styles for the Hero Grid Animate component.
 */

.hero-animate-grid {
  --hero-animate-grid-gap: 16px;
  --hero-animate-grid-background: var(--theme-surface);
  --hero-animate-grid-text-color: var(--theme-text-color-loud);

  position: relative;
  background: var(--hero-animate-grid-background);
  color: var(--hero-animate-grid-text-color);

  .layout--onecol:has(&) {
    @media (width < 600px) {
      padding-bottom: 0;
      margin-bottom: 0;
    }
  }
}

.hero-animate-grid__eyebrow {
  text-transform: uppercase;
}

.hero-animate-grid__title {
  flex-basis: 100%;
  font-size: var(--title-size);
  font-weight: var(--title-weight);
  line-height: var(--title-line-height);
  letter-spacing: var(--title-letter-spacing);
  text-box: trim-both cap alphabetic;
}

.hero-animate-grid__container {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: grid;
  grid-template-columns: auto;
  grid-auto-rows: auto;
  row-gap: var(--sp6);
  align-content: center;
  text-align: center;
  contain: content;

  .hero-animate-grid--align-x-start & {
    text-align: start;
  }

  .hero-animate-grid--align-x-end & {
    text-align: end;
  }

  .button-group {
    margin-inline: auto;
  }
}

.hero-animate-grid__pin {
  display: grid;
  place-items: center;
  grid-template-rows: 100%;
  grid-template-columns: 100%;
}

@property --gradient-start {
  syntax: "<percentage>";
  inherits: true;
  initial-value: 10%;
}

@property --gradient-end {
  syntax: "<percentage>";
  inherits: true;
  initial-value: 50%;
}

.hero-animate-grid__grid {
  --offset-top: 100px;
  --offset-bottom: 500px;
  --gradient-start: 10%;
  --gradient-end: 50%;
  --opacity: 0.4;

  display: grid;
  grid-template-columns: repeat(var(--items-per-row), 1fr);
  gap: var(--hero-animate-grid-gap);
  width: 100%;
  margin-top: calc(-1 * var(--offset-top));
  margin-bottom: calc(-1 * var(--offset-bottom));
  padding-top: var(--offset-top);
  padding-bottom: var(--offset-bottom);
  mask-image: radial-gradient(hotpink var(--gradient-start), transparent var(--gradient-end));
  mask-size: 150% 100%;
  mask-repeat: no-repeat;
  mask-position: center calc(50% - var(--offset-bottom)/2 + var(--offset-top)/2);
  opacity: var(--opacity);

  @media (width < 600px) {
    --items-per-row: 3;

    mask-size: 300% 100%;

    & > *:nth-child(15) ~ * {
      display: none
    }
  }

  @media (600px <= width < 800px) {
    --items-per-row: 4;

    & > *:nth-child(16) ~ * {
      display: none
    }
  }

  @media (800px <= width < 1200px) {
    --items-per-row: 6;

    & > *:nth-child(24) ~ * {
      display: none
    }
  }

  @media (1200px <= width < 1400px) {
    --items-per-row: 8;

    & > *:nth-child(32) ~ * {
      display: none
    }
  }

  @media (width >= 1400px) {
    --items-per-row: 9;
  }
}

.hero-animate-grid__img-wrapper {
  position:relative;
  grid-column: revert;
  will-change: transform;
  transform: translateZ(0.1px);
  backface-visibility: hidden;
  pointer-events: none;
  aspect-ratio: 4/ 3;

  img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
}

/* Prevent layout from shifting on scroll as images become super large via
   the perspective property. Without this, there will be a large gap below
   the footer, which creates layout shift. */
.layout-container {
  overflow: clip;
}
