/**
 * @file
 * Interactive Hover Over Banner.
 *
 * Desktop: a full-bleed row of image tiles; the hovered / focused tile grows
 * and reveals its word + description. Mobile (<= 768px): tiles stack and expand
 * on tap (one open at a time, driven by .is-open from the JS).
 */

/* Full-bleed: break out of the Bootstrap container to span the viewport. */
.ihb {
  position: relative;
  left: 50%;
  right: 50%;
  width: 100vw;
  margin-left: -50vw;
  margin-right: -50vw;
}

.ihb__track {
  display: flex;
  width: 100%;
  min-height: 360px;
}

.ihb__tile {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  cursor: pointer;
  outline: none;
  /* Grow/shrink drives the expand animation. */
  transition: flex-grow 0.5s ease;
}

/* Background image fills the tile. */
.ihb__img,
.ihb__img .field,
.ihb__img .field__item,
.ihb__img picture,
.ihb__img img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.ihb__img img {
  object-fit: cover;
}

/* Darkening overlay — subtle when collapsed, stronger when open for legibility. */
.ihb__overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(17, 24, 30, 0.72) 0%, rgba(17, 24, 30, 0.45) 55%, rgba(17, 24, 30, 0.25) 100%);
  opacity: 0.35;
  transition: opacity 0.5s ease;
}

.ihb__inner {
  position: relative;
  z-index: 1;
  height: 100%;
  min-height: 360px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 1.5rem;
  color: #fff;
}

.ihb__letter {
  font-size: clamp(2.5rem, 4vw, 4rem);
  font-weight: 700;
  line-height: 1;
  color: #fff;
  flex: 0 0 auto;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

/* Word + description: hidden until the tile opens. */
.ihb__reveal {
  flex: 1 1 auto;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  transition: opacity 0.45s ease, max-width 0.5s ease;
}

.ihb__word {
  margin: 0 0 0.5rem;
  font-size: clamp(1.25rem, 1.6vw, 1.75rem);
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}

.ihb__desc {
  margin: 0;
  font-size: 0.975rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.9);
  max-width: 34rem;
}

/* ---- Desktop expand: hover, keyboard focus, or JS .is-open ---------------- */
@media (min-width: 769px) {
  .ihb__tile:hover,
  .ihb__tile:focus-visible,
  .ihb__tile.is-open {
    flex-grow: 4.5;
  }

  .ihb__tile:hover .ihb__overlay,
  .ihb__tile:focus-visible .ihb__overlay,
  .ihb__tile.is-open .ihb__overlay {
    opacity: 1;
  }

  .ihb__tile:hover .ihb__inner,
  .ihb__tile:focus-visible .ihb__inner,
  .ihb__tile.is-open .ihb__inner {
    justify-content: flex-start;
    padding-left: clamp(1.5rem, 3vw, 3.5rem);
  }

  .ihb__tile:hover .ihb__reveal,
  .ihb__tile:focus-visible .ihb__reveal,
  .ihb__tile.is-open .ihb__reveal {
    max-width: 40rem;
    opacity: 1;
  }
}

/* ---- Mobile / tablet: vertical accordion, tap to expand ------------------- */
@media (max-width: 768px) {
  .ihb__track {
    flex-direction: column;
    min-height: 0;
  }

  .ihb__tile {
    flex: none;
    width: 100%;
    min-height: 84px;
    transition: min-height 0.4s ease;
  }

  .ihb__inner {
    min-height: 84px;
    justify-content: flex-start;
    gap: 1rem;
    padding: 1rem 1.5rem;
    align-items: center;
  }

  .ihb__overlay {
    opacity: 0.55;
    background: linear-gradient(90deg, rgba(17, 24, 30, 0.78) 0%, rgba(17, 24, 30, 0.5) 100%);
  }

  .ihb__letter {
    font-size: 2.25rem;
  }

  /* Collapsed on mobile still shows the word so tiles are identifiable. */
  .ihb__reveal {
    max-width: 100%;
    opacity: 1;
  }

  .ihb__desc {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    transition: max-height 0.4s ease, opacity 0.4s ease, margin-top 0.4s ease;
  }

  .ihb__tile.is-open {
    min-height: 180px;
  }

  .ihb__tile.is-open .ihb__overlay {
    opacity: 0.72;
  }

  .ihb__tile.is-open .ihb__desc {
    max-height: 12rem;
    opacity: 1;
    margin-top: 0.35rem;
  }
}

/* Respect reduced-motion preferences. */
@media (prefers-reduced-motion: reduce) {
  .ihb__tile,
  .ihb__reveal,
  .ihb__overlay,
  .ihb__desc {
    transition: none;
  }
}
