/* ==========================================================================
   Animated hero – Drupal version
   Desktop / tablet: screens wider than 768px (mobile has its own hero).

   <header id="hero" class="animated-hero">
     {{ page.blurred_hero_image }}   -> view block 1 (blurred) + view block 2 (slides)
     <div class="container">
       <div class="hero-topbar"> .hero-branding | .hero-menu | .hero-search </div>
     </div>
   </header>

   LAYOUT: the frame (.container) is a flex column, so nothing overlaps:
     1. top bar     (natural height: logo, slogan, menu... whatever it needs)
     2. slides      (takes the remaining space, copy sits at the bottom of it)
     3. cards       (natural height)
   The photo and its overlay are absolutely positioned behind all of it.
   If the content is taller than the window, the frame simply grows.

   The JS moves view block 2 into .container, builds the thumbnail cards,
   the pause button and the sliding menu pill.
   ========================================================================== */

#hero.animated-hero {
  --slide-duration: 10s;
  --transition-duration: 800ms;

  /* Fluid sizes: they scale between 769px and large desktops */
  --hero-gutter: clamp(1rem, 2.4vw, 2.5rem);       /* shared left/right inset */
  --hero-card-h: clamp(96px, min(12vw, 18vh), 160px);
  --hero-card-gap: clamp(.5rem, 1.2vw, 1rem);
  --hero-copy-gap: 2.25rem;           /* space between the copy and the cards */

  --hero-ink: #0b2a4a;                /* dark navy used for text on white + focus rings */
  --hero-glass: rgba(9, 30, 62, .6);  /* glass panels: white text on this is >= 4.5:1 */
  --hero-scrim: 6, 24, 48;            /* RGB of the dark overlay behind the text */

  position: relative;
  display: flex;               /* centres the frame vertically on tall screens */
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 100%;
  min-height: 100vh;
  padding: 24px 0;
  overflow: hidden;
  font-family: 'Inter', Arial, Helvetica, sans-serif;
}

/* Stronger selector: beats theme rules that were collapsing the height */
html body header#hero.animated-hero {
  height: auto;
  min-height: 100vh;
  max-height: none;
}

@supports (height: 100dvh) {
  html body header#hero.animated-hero {
    min-height: 100dvh;
  }
}

/* Mobile has its own hero */
@media (max-width: 768px) {
  html body header#hero.animated-hero {
    display: none;
  }
}

/* Drupal wrappers (contextual-region is position:relative) must not become
   the containing block of the photo: keep them static so it is positioned
   against the frame. */
#hero.animated-hero .contextual-region,
#hero.animated-hero .block-views-blockhero-homepage-block-2,
#hero.animated-hero .block-views-blockhero-homepage-block-2 :is(.block, .views-element-container, .group-list, .item-list, ul, li) {
  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;
}

/* --------------------------------------------------------------------------
   FOCUS (accessibility): a two-tone ring that is visible on light AND dark
   -------------------------------------------------------------------------- */
#hero.animated-hero :is(a, button, input):focus-visible {
  outline: 3px solid var(--hero-ink);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px #fff;
}

/* --------------------------------------------------------------------------
   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;
}

/* Views wrappers shouldn't take part in layout inside the hero */
#hero.animated-hero .hero-blur-slide .views-field,
#hero.animated-hero .hero-blur-slide .field-content,
#hero.animated-hero .hero-slide > .views-field,
#hero.animated-hero .hero-slide > .views-field > .field-content {
  display: contents;
}

#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);
}

/* --------------------------------------------------------------------------
   FRAME (flex column: top bar / slides / cards)
   -------------------------------------------------------------------------- */
#hero.animated-hero > .container {
  position: relative;
  z-index: 1;
  flex: none;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  width: calc(100% - 48px);
  max-width: 1400px;
  min-height: min(calc(100vh - 48px), 860px);
  margin: 0;
  padding: clamp(1rem, 2.2vw, 1.75rem) var(--hero-gutter) 2rem;
  /* If a sub-pixel seam ever appears, it shows navy instead of the page behind */
  background: var(--hero-ink);
  border: 1px solid #434343;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(6, 24, 48, .3);
}

@supports (height: 100dvh) {
  #hero.animated-hero > .container {
    min-height: min(calc(100dvh - 48px), 860px);
  }
}

/* --------------------------------------------------------------------------
   SLIDES (view block 2)
   The block takes the space between the top bar and the cards and pushes the
   copy to its bottom. All slides share ONE grid cell (stacked); only
   .is-active is visible.
   -------------------------------------------------------------------------- */
#hero.animated-hero .block-views-blockhero-homepage-block-2 {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 1.5rem 0 var(--hero-copy-gap); /* never touches the menu or the cards */
}

#hero.animated-hero .block-views-blockhero-homepage-block-2 .item-list > ul {
  display: grid;
}

#hero.animated-hero .hero-slide {
  grid-area: 1 / 1;
  align-self: end;           /* every slide's copy is aligned on the same bottom line */
  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: positioned against the FRAME (the li is static), behind everything.
   It overshoots by 2px on every side (the frame clips it) so rounding never
   leaves a gap, e.g. at the bottom edge. */
#hero.animated-hero .hero-slide .container-image-wrapper {
  position: absolute;
  inset: -2px;
  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;
}

/* Scrim: guarantees readable text on ANY photo (left for the copy,
   top for the menu, bottom for the cards) */
#hero.animated-hero .hero-slide .container-image-wrapper::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(var(--hero-scrim), .74) 0%, rgba(var(--hero-scrim), .55) 45%, rgba(var(--hero-scrim), 0) 78%),
    linear-gradient(180deg, rgba(var(--hero-scrim), .35) 0%, rgba(var(--hero-scrim), 0) 28%),
    linear-gradient(0deg, rgba(var(--hero-scrim), .5) 0%, rgba(var(--hero-scrim), 0) 38%);
}

/* Copy: in the normal flow, so it can never slide under the menu */
#hero.animated-hero .hero-slide article {
  position: relative;
  z-index: 2;
  width: min(36rem, 50%);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  color: #fff;
  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 copy to fade out */
}

#hero.animated-hero .hero-slide article h2 {
  margin: 0 0 1rem;
  font-size: clamp(1.75rem, min(3.6vw, 6.5vh), 3.5rem);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -.02em;
  text-wrap: balance;
  text-shadow: 0 2px 16px rgba(var(--hero-scrim), .35);
}

#hero.animated-hero .hero-slide article h2 a {
  color: inherit;
  text-decoration: none;
}

#hero.animated-hero .hero-slide article h2 a:hover {
  text-decoration: underline;
  text-underline-offset: .15em;
}

#hero.animated-hero .hero-slide article p {
  margin: 0 0 1.75rem;
  font-size: clamp(.875rem, 1.25vw, 1rem);
  font-weight: 400;
  line-height: 1.6;
  text-shadow: 0 1px 10px rgba(var(--hero-scrim), .4);
  color: #f4f4f4;
}

/* Call to action: keeps your theme's button colours, fixes alignment/size.
   Check that its text reaches 4.5:1 against its background. */
#hero.animated-hero .hero-slide article > a {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  min-height: 40px;
  margin: 0;
  padding: .25rem 1.75rem;
  font-weight: 500;
  text-decoration: none;
  font-size: clamp(.95rem, 1.2vw, 1.1rem);
}

#hero.animated-hero .hero-slide article > a::after {
  content: "\F138"; /* decorative arrow, ignored by screen readers */
  transition: transform 200ms ease;
  position: static !important;
  font-family: var(--bs-icons-font);
}

#hero.animated-hero .hero-slide article > a:hover::after {
  transform: translateX(4px);
}

/* --------------------------------------------------------------------------
   TOP BAR: logo (+ slogan) and search on the first row, menu on its own row.
   It is in the normal flow: if the slogan or the menu get taller, the slides
   area just gets smaller.
   -------------------------------------------------------------------------- */
#hero.animated-hero .hero-topbar {
  position: relative;
  z-index: 4; /* above photo and slides, cards (3) */
  flex: none;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "logo . search"
    "menu menu menu";
  align-items: center;
  row-gap: .75rem;
  column-gap: 1.5rem;
}

#hero.animated-hero .hero-topbar .block {
  margin: 0;
}

#hero.animated-hero .navbar-brand
{
  flex-direction: column;
  justify-content: center;
  gap: .25rem;
}

#hero.animated-hero .navbar-brand .site-slogan
{
  color: #fff;
}

#hero.animated-hero .hero-topbar h2 {
  display: none; /* block titles */
}

#hero.animated-hero .hero-branding { grid-area: logo; }

#hero.animated-hero .hero-search { grid-area: search; justify-self: end; }

/* Logo + slogan (both live inside the same link): stacked, normal line height */
#hero.animated-hero .hero-branding a {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: .25rem;
  border-radius: 8px;
}

#hero.animated-hero .hero-branding img,
#hero.animated-hero .hero-branding svg {
  display: block;
  height: clamp(22px, 2.1vw, 28px);
  width: auto;
  max-width: none;
}

/* Menu: strip whatever the theme draws around it, then build ONE glass pill */
#hero.animated-hero .hero-menu {
  grid-area: menu;
  position: relative; /* anchor for the full-width dropdown panels */
  min-width: 0;
}

#hero.animated-hero .hero-menu,
#hero.animated-hero .hero-menu .block,
#hero.animated-hero .hero-menu nav,
#hero.animated-hero .hero-menu .navbar {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  background: none;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}

#hero.animated-hero .hero-menu-pill {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 0;
  width: var(--w, 0);
  height: var(--h, 0);
  background: #fff;
  border-radius: 999px;
  opacity: 0;
  transform: translate(var(--x, 0), var(--y, 0));
  pointer-events: none;
}

#hero.animated-hero .hero-menu-pill.is-visible {
  opacity: 1;
}

@media (prefers-reduced-motion: no-preference) {
  #hero.animated-hero .hero-menu-pill {
    transition:
      transform 350ms cubic-bezier(.4, 0, .2, 1),
      width 350ms cubic-bezier(.4, 0, .2, 1),
      height 350ms cubic-bezier(.4, 0, .2, 1),
      opacity 200ms ease;
  }
}

/* The pill replaces per-item hover/active backgrounds */
#hero.animated-hero .hero-menu .tbm-nav > .tbm-item > .tbm-link-container > .tbm-link,
#hero.animated-hero .hero-menu .tbm-nav > .tbm-item > .tbm-link-container > .tbm-link:hover {
  background: transparent;
}

/* Text on the pill is dark, everywhere else white */
#hero.animated-hero .hero-menu .tbm-nav > .tbm-item:not(.is-pilled) > .tbm-link-container > .tbm-link {
  color: #fff;
}

#hero.animated-hero .hero-menu .tbm-nav > .tbm-item.is-pilled > .tbm-link-container > .tbm-link,
#hero.animated-hero .hero-menu .tbm-nav > .tbm-item.is-pilled > .tbm-link-container > .tbm-submenu-toggle {
  color: var(--hero-ink);
}

#hero.animated-hero .hero-menu .tbm-nav > .tbm-item > .tbm-link-container {
  flex-wrap: nowrap;
  gap: .125em;
  align-items: center;
}

#hero.animated-hero .hero-menu .tbm-nav > .tbm-item > .tbm-link-container > .tbm-link {
  padding: .5em .75em;
  font-size: 1em; /* follows the font-size set on .tbm-nav */
  line-height: 1.2;
  font-weight: 500;
  white-space: nowrap;
}

#hero.animated-hero .hero-menu .tbm-nav > .tbm-item > .tbm-link-container > .tbm-submenu-toggle {
  flex: 0 0 auto;
  width: 1.6em;
  height: 1.6em;
  margin: 0;
  padding: 0;
}

#hero.animated-hero .hero-menu .tbm-nav > .tbm-item--has-dropdown:not(.tbm-justify) {
  position: relative;
}

/* Wide panels span the pill. Delete this block if they already line up. */
#hero.animated-hero .hero-menu .tbm-nav > .tbm-item.tbm-justify {
  position: static;
}

#hero.animated-hero .hero-menu .tbm-nav > .tbm-item.tbm-justify > .tbm-submenu {
  left: 0 !important;
  right: 0 !important;
  width: auto !important;
}

/* Current page: white pill, dark text (13:1) */
#hero.animated-hero .hero-menu a.is-active,
#hero.animated-hero .hero-menu a.active,
#hero.animated-hero .hero-menu a[aria-current="page"] {
  color: var(--hero-ink);
  background: #fff;
}

/* Search pill */
#hero.animated-hero .hero-search form {
  position: relative;
  display: flex;
  align-items: center;
  margin: 0;
}

#hero.animated-hero .hero-search .form-item,
#hero.animated-hero .hero-search .js-form-item,
#hero.animated-hero .hero-search .form-group,
#hero.animated-hero .hero-search .form-actions {
  margin: 0;
}

/* Visually hidden label (still read by screen readers) */
#hero.animated-hero .hero-search label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

#hero.animated-hero .hero-search input[type="search"],
#hero.animated-hero .hero-search input[type="text"] {
  width: clamp(150px, 14vw, 180px);
  height: 48px;
  padding: 0 1rem 0 2.9rem;
  color: #fff;
  font-size: .9375rem;
  background: var(--hero-glass);
  border: 1px solid rgba(255, 255, 255, .55);
  border-radius: 999px;
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: none;
  transition: background-color 200ms ease;
}

#hero.animated-hero .hero-search input::placeholder {
  color: rgba(255, 255, 255, .92);
  opacity: 1;
}

#hero.animated-hero .hero-search input[type="search"]:focus,
#hero.animated-hero .hero-search input[type="text"]:focus {
  background: rgba(9, 30, 62, .8);
}

/* Expanding search: pinned to the right edge, so it grows toward the left */
#hero.animated-hero .hero-search input[type="search"]:focus,
#hero.animated-hero .hero-search input[type="text"]:focus,
#hero.animated-hero .hero-search input[type="search"]:not(:placeholder-shown),
#hero.animated-hero .hero-search input[type="text"]:not(:placeholder-shown) {
  width: clamp(220px, 24vw, 320px);
}

#hero.animated-hero .hero-search input:focus::placeholder {
  color: transparent; /* placeholder fades out on click */
}

@media (prefers-reduced-motion: no-preference) {
  #hero.animated-hero .hero-search input[type="search"],
  #hero.animated-hero .hero-search input[type="text"] {
    transition: width 350ms cubic-bezier(.4, 0, .2, 1), background-color 200ms ease;
  }

  #hero.animated-hero .hero-search input::placeholder {
    transition: color 200ms ease;
  }
}

/* Submit button becomes the magnifier icon inside the pill */
#hero.animated-hero .hero-search button[type="submit"],
#hero.animated-hero .hero-search input[type="submit"] {
  position: absolute;
  z-index: 1;
  left: .8rem;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  box-shadow: none;
  font-size: 0;
  color: transparent;
  cursor: pointer;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23fff' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001q.044.06.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1 1 0 0 0-.115-.1zM12 6.5a5.5 5.5 0 1 1-11 0 5.5 5.5 0 0 1 11 0'/%3E%3C/svg%3E") center / 18px no-repeat;
}

/* --------------------------------------------------------------------------
   THUMBNAIL CARDS (generated by JS) – last row of the frame
   -------------------------------------------------------------------------- */
#hero.animated-hero .hero-navigation {
  position: relative;
  z-index: 3;
  flex: none;
  display: flex;
  gap: var(--hero-card-gap);
}

#hero.animated-hero .hero-navigation li {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, .5);
  border-radius: 18px;
  transition: border-color 300ms ease;
}

/* Current card: solid white frame (not just a thin progress line) */
#hero.animated-hero .hero-navigation li.is-current {
  border-color: #fff;
}

#hero.animated-hero .hero-card {
  display: block;
  position: relative;
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  overflow: hidden;
}

/* Keyboard focus: ring drawn INSIDE the card (the li clips outside rings) */
#hero.animated-hero .hero-card:focus-visible {
  outline: 3px solid #fff;
  outline-offset: -6px;
  box-shadow: inset 0 0 0 3px var(--hero-ink);
}

#hero.animated-hero .small-card-image {
  display: block;
  width: 100%;
  height: var(--hero-card-h);
  object-fit: cover;
  filter: brightness(.7) saturate(.9);
  transition: transform 400ms ease, filter 300ms ease;
}

#hero.animated-hero .hero-navigation li.is-current .small-card-image,
#hero.animated-hero .hero-card:hover .small-card-image,
#hero.animated-hero .hero-card:focus-visible .small-card-image {
  filter: none;
}

#hero.animated-hero .hero-card:hover .small-card-image {
  transform: scale(1.05);
}

/* Dark gradient so the title is always readable */
#hero.animated-hero .hero-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, rgba(var(--hero-scrim), .85) 0%, rgba(var(--hero-scrim), .4) 50%, rgba(var(--hero-scrim), 0) 80%);
}

#hero.animated-hero .hero-card-title {
  position: absolute;
  left: clamp(.5rem, 1vw, 1rem);
  right: clamp(.5rem, 1vw, 1rem);
  bottom: 1.35rem;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  color: #fff;
  font-size: clamp(.6875rem, .9vw + .1rem, .875rem);
  font-weight: 600;
  line-height: 1.3;
  text-align: left;
}

/* Progress line: dark track + white fill = visible on any photo */
#hero.animated-hero .duration-line {
  position: absolute;
  left: clamp(.5rem, 1vw, 1rem);
  right: clamp(.5rem, 1vw, 1rem);
  bottom: .6rem;
  height: 4px;
  overflow: hidden;
  background: rgba(0, 0, 0, .5);
  border-radius: 999px;
}

#hero.animated-hero .duration-line::after {
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  background: #fff;
  transform: scaleX(0);
  transform-origin: left;
}

#hero.animated-hero .hero-card.active .duration-line::after {
  animation: reel-progress var(--slide-duration) linear forwards;
}

/* Paused (button, keyboard focus, or reduced motion): show the bar full */
#hero.animated-hero.is-paused .hero-card.active .duration-line::after {
  animation: none;
  transform: scaleX(1);
}

@keyframes reel-progress {
  to {
    transform: scaleX(1);
  }
}

/* Pause / play button (WCAG 2.2.2): floats just above the cards, bottom right */
#hero.animated-hero .hero-pause {
  position: absolute;
  z-index: 4;
  right: var(--hero-gutter);
  bottom: calc(2rem + var(--hero-card-h) + 4px + 1rem);
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  color: #fff;
  background: var(--hero-glass);
  border: 1px solid rgba(255, 255, 255, .55);
  border-radius: 50%;
  cursor: pointer;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  transition: background-color 200ms ease;
}

#hero.animated-hero .hero-pause:hover {
  background: rgba(9, 30, 62, .85);
}

/* --------------------------------------------------------------------------
   RESPONSIVE (769px and up)
   Most sizes above are fluid (clamp). These are the few layout changes.
   -------------------------------------------------------------------------- */

/* Tablets / small laptops: 7 menu items no longer fit on one line, so the
   pill wraps onto two centred lines */
@media (max-width: 1023px) {
  #hero.animated-hero .hero-menu .tbm-nav {
    flex-wrap: wrap;
    justify-content: center;
    row-gap: .125rem;
    border-radius: 28px;
  }

  #hero.animated-hero .hero-topbar {
    column-gap: 1rem;
  }
}

/* Short windows (small laptops, browser toolbars): keep the copy compact */
@media (max-height: 760px) {
  #hero.animated-hero .hero-slide article h2 {
    margin-bottom: .5rem;
  }

  #hero.animated-hero .hero-slide article p {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
    margin-bottom: 1rem;
  }
}

/* --------------------------------------------------------------------------
   REDUCED MOTION
   -------------------------------------------------------------------------- */
@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 .hero-slide article > a::after,
  #hero.animated-hero .small-card-image,
  #hero.animated-hero .hero-menu a,
  #hero.animated-hero .hero-search input,
  #hero.animated-hero .hero-navigation li {
    transition: none;
  }

  #hero.animated-hero .hero-card.active .duration-line::after {
    animation: none;
    transform: scaleX(1);
  }
}