/* Mavan header pieces: sticky main header + announcement bar (from Mavan style.css 09–10). Loaded on every page. */

/* ==========================================================================
   09. HEADER (sticky) — Container → Layout → "Mavan" → Sticky main header
   (or class "site-main-header" on the main header container).
   ========================================================================== */

/* The whole <header> sticks, pulled up by the height of anything above the
   main header (the announcement bar), so the bar scrolls away and only
   .site-main-header stays on screen. js/interactions/sticky-header.js
   measures --announcement-height and --header-height, and adds
   .header-scrolled to <body> once it's stuck. Off in the Elementor editor. */
body:not(.elementor-editor-active) .elementor-location-header:has(.site-main-header) {
  position: sticky;
  top: calc(var(--wp-admin--admin-bar--height, 0px) - var(--announcement-height, 0px));
  z-index: 100;
}

/* Elementor editor: the header isn't sticky there, so it had no stacking
   level, and with "Transparent over the hero" the page's first section
   (pulled up under the header) painted over it — the header looked
   missing while editing. Keep it on top, like the live site. */
body.elementor-editor-active .elementor-location-header:has(.site-main-header) {
  position: relative;
  z-index: 100;
}

/* Phones: the WP admin bar scrolls away, so don't leave room for it */
@media (max-width: 600px) {
  body.admin-bar:not(.elementor-editor-active) .elementor-location-header:has(.site-main-header) {
    top: calc(-1 * var(--announcement-height, 0px));
  }
}

/* Default colours. A background set on the container in Elementor wins over
   these; the "Background when stuck" control sets the stuck colour. */
.site-main-header {
  background-color: var(--color-primary);
  transition: background-color 0.3s ease;
}

.header-scrolled .site-main-header {
  background-color: var(--color-black);
}

/* Transparent over the hero (opt-in: "Transparent over the hero").
   "header-overlay" = homepage only, "header-overlay-all" = every page.
   The page content starts under the header; the background fills in once
   the header is stuck. */
body.home .elementor-location-header:has(.site-main-header.header-overlay),
.elementor-location-header:has(.site-main-header.header-overlay-all) {
  margin-bottom: calc(-1 * var(--header-height, 0px));
}

body.home:not(.header-scrolled) .elementor-location-header .elementor-element.site-main-header.site-main-header.header-overlay,
body:not(.header-scrolled) .elementor-location-header .elementor-element.site-main-header.site-main-header.header-overlay-all {
  background-color: transparent !important;
  background-image: none !important;
}

/* ==========================================================================
   10. ANNOUNCEMENT BAR — Container → Layout → "Mavan" → Announcement bar
   (or class "announcement-bar"). Scrolls on mobile (<= 767px) by default;
   "Scroll on" can widen it to tablet (<= 1024px) or every screen:
   js/interactions/announcement-bar.js moves the bar's items (children with
   "block-item", or else all of its children) into .announcement-track,
   repeats them, and adds .is-marquee to the bar; the track scrolls for a
   seamless loop. Elsewhere the items render as normal Elementor content.
   Speed: --marquee-speed (px per second), read by the script.
   ========================================================================== */

.announcement-track {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  width: max-content;
  animation: announcement-marquee 30s linear infinite;
  will-change: transform;
}

.announcement-track > * {
  --width: auto;           /* Elementor container width override */
  flex: 0 0 auto;
  width: auto;
  max-width: none;
  padding-right: var(--marquee-gap, 80px); /* space between message repeats */
}

.announcement-track .elementor-heading-title { white-space: nowrap; }

/* Pause on hover so links/buttons are easy to click. Mouse devices only:
   on touch screens :hover sticks after a tap and would freeze the marquee. */
@media (hover: hover) {
  .announcement-bar:not(.marquee-no-pause):hover .announcement-track { animation-play-state: paused; }
}

@keyframes announcement-marquee {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

/* Mobile bar layout while scrolling: one row, clipped to the bar's width
   (otherwise the track makes the whole page scroll sideways) */
.announcement-bar.is-marquee,
.announcement-bar.is-marquee > .e-con-inner {
  flex-wrap: nowrap;
  overflow: hidden;
}

/* The track must start at the bar's left edge. If the bar is a centered
   column in Elementor, the wide track would be centered and hang off both
   sides, so the loop would run out of copies on the right. */
.elementor .announcement-bar.is-marquee > .e-con-inner,
.elementor .announcement-bar.is-marquee:not(:has(> .e-con-inner)) {
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
}

.announcement-bar.is-marquee .announcement-track {
  flex: 0 0 auto;
  align-self: center;
  margin: 0;
}
