/**
 * mw_ai_pages — loading curtain with a 0–100 % counter.
 *
 * Same look and motion as the loader built into the W pages: four teal
 * columns, a thin rule that fills with the accent colour, and a rolling
 * odometer bottom-left. Like on W pages it sits under the site header
 * (z-index 500), the toolbar, the contact rail and Klaro, so the header's
 * logo, CTA and menu stay visible while the page loads.
 *
 * Printed by mw_ai_pages_page_top() for the groups in the setting
 * preloader_groups (default: j).
 */

#mw-preloader {
  --mwp-bg: #183331;
  --mwp-fg: #f5f1e8;
  --mwp-accent: #f36c38;
  --mwp-line: rgba(245, 241, 232, .15);
  --mwp-gutter: 2.5rem;
  --mwp-font: "Archivo", "Helvetica Neue", Arial, sans-serif;

  position: fixed;
  inset: 0;
  z-index: 200;
  color: var(--mwp-fg);
  pointer-events: auto;
}

/* No JS → no curtain (the inline flag is printed just before the markup). */
html:not(.mwp-js) #mw-preloader {
  display: none;
}

/* Keep the page still while the curtain is down (class set by preloader.js). */
html.mwp-lock,
html.mwp-lock body {
  overflow: hidden;
}

/* Pages with their own full-screen entrance (home page: #entry-screen,
   z-index 999) — the counter comes first, above it; preloader.js then
   replays that entrance from its start as the curtain lifts. */
body:has(#entry-screen) #mw-preloader {
  z-index: 1000;
}

#mw-preloader.is-exiting {
  pointer-events: none;
}

/* ── Columns (the curtain) ─────────────────────────────────── */
#mw-preloader .mwp-columns {
  position: absolute;
  inset: 0;
  display: flex;
}

#mw-preloader .mwp-column {
  flex: 1 1 0%;
  height: 100%;
  background: var(--mwp-bg);
  /* 1px overlap hides hairline gaps between columns on fractional widths. */
  margin-right: -1px;
  transition: transform 560ms cubic-bezier(.76, 0, .24, 1);
  transition-delay: calc(var(--i, 0) * 70ms);
}

#mw-preloader .mwp-column.top { transform-origin: top; }
#mw-preloader .mwp-column.bottom { transform-origin: bottom; }

#mw-preloader.is-exiting .mwp-column {
  transform: scaleY(0);
}

/* ── Rule ──────────────────────────────────────────────────── */
#mw-preloader .mwp-rule {
  position: absolute;
  left: var(--mwp-gutter);
  right: var(--mwp-gutter);
  top: 50%;
  height: 1px;
  translate: 0 -50%;
  transform-origin: right;
  background: var(--mwp-line);
  transition: transform 520ms cubic-bezier(.76, 0, .24, 1);
}

#mw-preloader .mwp-fill {
  display: block;
  height: 100%;
  transform: scaleX(0);
  transform-origin: left;
  background: var(--mwp-accent);
}

#mw-preloader.is-exiting .mwp-rule {
  transform: scaleX(0);
}

/* ── Odometer ──────────────────────────────────────────────── */
#mw-preloader .mwp-odometer {
  position: absolute;
  left: var(--mwp-gutter);
  right: var(--mwp-gutter);
  bottom: var(--mwp-gutter);
  height: .9em;
  font-family: var(--mwp-font);
  font-weight: 500;
  font-size: clamp(54px, 10.5vw, 170px);
  font-variant-numeric: lining-nums tabular-nums;
  line-height: .9;
  letter-spacing: -.02em;
  contain: layout paint;
}

#mw-preloader .mwp-travel {
  position: absolute;
  bottom: 0;
  left: 0;
  display: flex;
  height: .9em;
  overflow: hidden;
}

#mw-preloader .mwp-col,
#mw-preloader .mwp-pct {
  display: flex;
  transition: opacity 450ms ease, transform 500ms cubic-bezier(.33, 1, .68, 1);
  transition-delay: calc(var(--i, 0) * 50ms);
}

#mw-preloader .mwp-stack {
  display: flex;
  flex-direction: column;
  text-align: center;
}

#mw-preloader .mwp-cell {
  display: block;
  height: .9em;
}

#mw-preloader .mwp-pct {
  margin-left: .25rem;
  height: .9em;
}

#mw-preloader.is-exiting .mwp-col,
#mw-preloader.is-exiting .mwp-pct {
  opacity: 0;
  transform: translateX(-40px);
}

/* ── Phones ────────────────────────────────────────────────── */
@media (max-width: 767.98px) {
  #mw-preloader { --mwp-gutter: 1.5rem; }
}

/* Phones and tablets: the bottom of the screen belongs to the cookie banner,
   its button and the contact bar (all above the curtain), which hid the
   counter. It sits just above the rule instead. */
@media (max-width: 979.98px) {
  #mw-preloader .mwp-odometer { bottom: calc(50% + 1.25rem); }
}

/* ── Reduced motion: no curtain choreography, just get out of the way. */
@media (prefers-reduced-motion: reduce) {
  #mw-preloader.is-exiting { display: none; }
}
