/**
 * Peak Motion — front-end structural styles.
 *
 * Small and safe: only the transition overlay and a couple of state hooks.
 * Colours come from CSS variables so themes can restyle without overrides.
 *
 * @package Peak
 */

/* The full-screen host the transition's overlay is drawn into. Persistent
   (printed outside the Barba container), hidden until a transition drives it.
   Transparent on its own: an overlay (Fade, Sweep, a theme's pixel grid …)
   draws its own layer inside it — see peak-overlays.js. */
.peak-transition {
  position: fixed;
  inset: 0;
  z-index: 99999;
  visibility: hidden;
  pointer-events: none;
  overflow: hidden;
}

/* The composed stage — logo / caption elements shown during a transition.
   Sits above the panel; elements are hidden until peak-stage.js animates them.
   Layout rides on CSS custom properties so responsive overrides are pure CSS. */
.peak-stage {
  position: fixed;
  inset: 0;
  z-index: 100000;
  pointer-events: none;
}
.peak-stage-el {
  position: absolute;
  left: var(--x, 50%);
  top: var(--y, 50%);
  /* The centring rides on `translate`, not `transform`, so the in/out
     animations (which own `transform`) never undo it. */
  translate: -50% -50%;
  visibility: hidden;
  opacity: 0;
  max-width: 90vw;
  will-change: transform, opacity;
}
.peak-stage-el img {
  display: block;
  width: var(--w, 140px);
  height: auto;
  max-width: 90vw;
}
.peak-stage-cap {
  display: block;
  margin: 0;
  font-size: var(--size, 20px);
  text-align: var(--align, center);
  color: var(--cap-color, #fff);
  line-height: var(--st-lh, 1.2);
  font-family: var(--st-ff, inherit);
  font-weight: var(--st-fw, inherit);
  letter-spacing: var(--st-ls, normal);
  text-transform: var(--st-tt, none);
}
/* Placeholder shown when a logo element has no image resolved yet. */
.peak-stage-ph {
  display: block;
  width: var(--w, 140px);
  aspect-ratio: 3 / 1;
  border: 1px dashed rgba(255, 255, 255, 0.4);
  border-radius: 6px;
}

/* Pre-loader overlay — covers the page on first load (bg set inline so it is
   opaque before this sheet arrives; repeated here as a fallback). */
.peak-loader {
  position: fixed;
  inset: 0;
  z-index: 999999;
  background: var(--peak-loader-bg, #0e0f12);
  overflow: hidden;
}
/* Above the overlay's layer, which the leaving animation draws in here. */
.peak-loader > .peak-stage-el {
  z-index: 1;
}

/* Counter element — the live load percentage. */
.peak-stage-count {
  display: inline-flex;
  align-items: baseline;
  justify-content: var(--align, center);
  font-size: var(--size, 48px);
  color: var(--cap-color, #fff);
  line-height: var(--st-lh, 1);
  font-family: var(--st-ff, inherit);
  font-weight: var(--st-fw, inherit);
  letter-spacing: var(--st-ls, normal);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}
.peak-stage-count-suffix {
  font-size: 0.5em;
  margin-left: 0.08em;
  opacity: 0.7;
}

/* Progress fill — a faded base with a solid top copy the runtime reveals from
   0→100% via the --fill custom property, in the element's Fill direction
   (by default a logo fills up, a caption left to right). `lr` is the
   caption's name for `right` before the direction was a setting. */
.peak-stage-fill-base {
  opacity: 0.22;
}
.peak-stage-fill-top {
  position: absolute;
  inset: 0;
  will-change: clip-path;
}
.peak-stage-el[data-fill-dir="right"] .peak-stage-fill-top,
.peak-stage-el[data-fill-dir="lr"] .peak-stage-fill-top {
  clip-path: inset(0 calc(100% - var(--fill, 0) * 1%) 0 0);
}
.peak-stage-el[data-fill-dir="left"] .peak-stage-fill-top {
  clip-path: inset(0 0 0 calc(100% - var(--fill, 0) * 1%));
}
.peak-stage-el[data-fill-dir="up"] .peak-stage-fill-top {
  clip-path: inset(calc(100% - var(--fill, 0) * 1%) 0 0 0);
}
.peak-stage-el[data-fill-dir="down"] .peak-stage-fill-top {
  clip-path: inset(0 0 calc(100% - var(--fill, 0) * 1%) 0);
}

/* While a transition runs, links shouldn't be clickable underneath. */
html.peak-transitioning,
html.peak-transitioning body {
  cursor: progress;
}

html.peak-transitioning a {
  pointer-events: none;
}

/* Progress Bar element (the pre-loader's; drawn by a paid renderer). The fill
   follows `--fill` (0–100), which Peak.stage.progress() writes. */
.peak-stage-bar {
  position: relative;
  display: block;
  width: var(--w, 240px);
  max-width: 90vw;
  height: var(--h, 4px);
  border-radius: var(--bar-radius, 0);
  background: var(--bar-track, rgba(255, 255, 255, 0.2));
  overflow: hidden;
}
.peak-stage-bar-fill {
  position: absolute;
  inset: 0;
  background: var(--bar-fill, #fff);
  border-radius: inherit;
  transform-origin: left center;
  transform: scaleX(calc(var(--fill, 0) / 100));
}
