/* ==========================================================================
   Animated hero – Drupal version
   Markup comes from two Views blocks inside <header id="hero" class="animated-hero">:
   - block-views-blockhero-homepage-block-1 : blurred images (li > img)
   - block-views-blockhero-homepage-block-2 : slides (li > .container-image-wrapper + article)
   The JS moves block 2 into the .container and builds the .hero-navigation cards.
   ========================================================================== */

#hero.animated-hero {
  --slide-duration: 10s;
  --transition-duration: 800ms;

  position: relative;
  width: 100%;
  height: 100vh;
  min-height: 630px;
  max-height: none;
  overflow: hidden;
  font-family: 'Montserrat', Arial, Helvetica, sans-serif;
}

/* Drupal's contextual-region is position:relative, which would trap the
   absolutely-positioned slides. Neutralise it inside the hero. */
#hero.animated-hero .contextual-region {
  position: static;
}

/* Reset lists generated by Views */
#hero.animated-hero .item-list > ul,
#hero.animated-hero .hero-navigation {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* --------------------------------------------------------------------------
   BLURRED BACKGROUND (view block 1)
   -------------------------------------------------------------------------- */
#hero.animated-hero .region-blurred-hero-image {
  position: absolute;
  inset: -10px;
  z-index: 0;
  overflow: hidden;
}

#hero.animated-hero .hero-blur-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity var(--transition-duration) ease;
}

#hero.animated-hero .hero-blur-slide.is-active,
html:not(.js) #hero.animated-hero .hero-blur-slide:first-child {
  opacity: 1;
}

#hero.animated-hero .hero-blur-slide img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  filter: blur(8px);
  transform: scale(1.03);
}

/* --------------------------------------------------------------------------
   MAIN CONTAINER
   -------------------------------------------------------------------------- */
#hero.animated-hero > .container {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  width: calc(100% - 48px);
  height: calc(100% - 48px);
  max-height: 750px;
  min-height: 550px;
  margin: 40px auto;
  padding: 2rem;
  border: 2px solid #fff;
  border-radius: 16px;
  overflow: hidden;
}

/* --------------------------------------------------------------------------
   SLIDES (view block 2) – every <li> is stacked, only .is-active is visible
   -------------------------------------------------------------------------- */
#hero.animated-hero .hero-slide {
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-duration) ease;
}

#hero.animated-hero .hero-slide.is-active,
html:not(.js) #hero.animated-hero .hero-slide:first-child {
  opacity: 1;
  pointer-events: auto;
}

/* Sharp image */
#hero.animated-hero .hero-slide .container-image-wrapper {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

#hero.animated-hero .hero-slide .container-image-wrapper img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: cover;
  object-position: center;
}

/* Article */
#hero.animated-hero .hero-slide article {
  position: absolute;
  z-index: 2;
  top: 25%;
  left: 2rem;
  width: 40%;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 400ms ease, transform 400ms ease;
}

#hero.animated-hero .hero-slide.is-active article,
html:not(.js) #hero.animated-hero .hero-slide:first-child article {
  opacity: 1;
  transform: none;
  transition-delay: 400ms; /* wait for the previous article to fade out */
}

#hero.animated-hero .hero-slide article h2 {
  font-size: 2rem;
  margin-bottom: 1rem;
}

#hero.animated-hero .hero-slide article h2 a {
  color: inherit;
  text-decoration: none;
}

#hero.animated-hero .hero-slide article p {
  font-size: 1rem;
  line-height: 1.5;
  margin-bottom: 1rem;
}

/* --------------------------------------------------------------------------
   NAVIGATION CARDS (generated by JS)
   -------------------------------------------------------------------------- */
#hero.animated-hero .hero-navigation {
  display: flex;
  gap: 1rem;
  position: absolute;
  z-index: 3;
  bottom: 2rem;
  left: 2rem;
  right: 2rem;
}

#hero.animated-hero .hero-navigation li {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, .6);
  border-radius: 16px;
}

#hero.animated-hero .hero-card {
  display: block;
  position: relative;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  overflow: hidden;
}

#hero.animated-hero .hero-card:focus-visible {
  outline: 3px solid #28ABF0;
  outline-offset: -3px;
}

#hero.animated-hero .small-card-image {
  display: block;
  width: 100%;
  height: 180px;
  object-fit: cover;
  transition: transform 400ms ease;
}

#hero.animated-hero .hero-card:hover .small-card-image {
  transform: scale(1.05);
}

/* Progress line */
#hero.animated-hero .duration-line {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, .4);
}

#hero.animated-hero .duration-line::after {
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  background: #28ABF0;
  transform: scaleX(0);
  transform-origin: left;
}

#hero.animated-hero .hero-card.active .duration-line::after {
  animation: reel-progress var(--slide-duration) linear forwards;
}

@keyframes reel-progress {
  to {
    transform: scaleX(1);
  }
}

/* --------------------------------------------------------------------------
   RESPONSIVE (small additions, adjust to taste)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  #hero.animated-hero .hero-slide article {
    width: calc(100% - 4rem);
    top: 12%;
  }

  #hero.animated-hero .hero-navigation {
    gap: .5rem;
  }

  #hero.animated-hero .small-card-image {
    height: 90px;
  }
}

/* --------------------------------------------------------------------------
   ACCESSIBILITY
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  #hero.animated-hero .hero-blur-slide,
  #hero.animated-hero .hero-slide,
  #hero.animated-hero .hero-slide article,
  #hero.animated-hero .small-card-image {
    transition: none;
  }

  #hero.animated-hero .hero-card.active .duration-line::after {
    animation: none;
    transform: scaleX(1);
  }
}