/* Motion for the home and quote pages. Everything that starts hidden is scoped
   under html.rz-motion (set by js/boot.js, never under reduced motion), so no
   JavaScript and reduced motion both get the finished page. transform and
   opacity only; will-change only while an element is animating. */

html { scrollbar-gutter: stable; }

/* ---------- Intro film (js/intro.js) ---------- */

.intro { display: none; }
html.rz-intro .intro {
  display: block; position: fixed; inset: 0; z-index: 1000; overflow: hidden;
  background: #CFDBE8 url("../media/v2/video/intro-poster.jpg") center / cover no-repeat;
  opacity: 1; transition: opacity 700ms ease-out; touch-action: none; overscroll-behavior: contain;
}
@media (max-width: 767px) and (orientation: portrait) { html.rz-intro .intro { background-image: url("../media/v2/video/intro-portrait-poster.jpg"); } }
html.rz-intro .intro.is-leaving { opacity: 0; pointer-events: none; }
html.rz-intro .intro.is-quick { transition-duration: 250ms; }
html.rz-intro-on, html.rz-intro-on body { overflow: hidden; overscroll-behavior: none; }
.intro__video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; background: transparent; }
.intro__skip {
  position: absolute; top: max(16px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right));
  min-height: 44px; min-width: 76px; padding: 0 20px; cursor: pointer;
  font-family: var(--rz-font-data); font-weight: 500; font-size: 13px; letter-spacing: .08em; text-transform: uppercase;
  color: #fff; background: rgba(15, 15, 15, .66); border: 1px solid rgba(255, 255, 255, .75); border-radius: var(--rz-radius-sm);
}
.intro__skip:hover { background: var(--rz-ink); }
.intro__skip:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

/* ---------- Lines rise, body fades up ---------- */

html.rz-motion [data-rise]:not(.is-split) { visibility: hidden; }
html.rz-rise-off [data-rise] { visibility: visible !important; }
.rl { display: block; overflow: hidden; padding-block: .08em .14em; margin-block: -.08em -.14em; }
.rl__in { display: block; }
html.rz-motion [data-rise].is-split .rl__in { transform: translateY(112%); }
html.rz-motion [data-rise].is-in .rl__in { transform: none; transition: transform 600ms cubic-bezier(.16, .84, .3, 1); transition-delay: calc(var(--i, 0) * 90ms); }
html.rz-motion [data-rise].is-animating .rl__in { will-change: transform; }

html.rz-motion [data-fade] { opacity: 0; transform: translateY(14px); }
html.rz-motion [data-fade].is-in { opacity: 1; transform: none; transition: opacity 500ms ease-out, transform 600ms cubic-bezier(.16, .84, .3, 1); transition-delay: var(--fade-delay, 0ms); }
html.rz-motion [data-fade].is-animating { will-change: transform, opacity; }
html.rz-rise-off [data-fade] { opacity: 1 !important; transform: none !important; }

/* ---------- Page turn between sections ---------- */

html.rz-motion .turn { opacity: 0; transform: perspective(1400px) rotateY(12deg); transform-origin: left center; }
html.rz-motion .turn.turn-in { opacity: 1; transform: none; transition: transform 900ms cubic-bezier(.16, .84, .3, 1), opacity 600ms ease-out; }
html.rz-motion .turn.is-turning { will-change: transform, opacity; }
html.rz-rise-off .turn { opacity: 1 !important; transform: none !important; }

/* ---------- Scroll scrub (js/scrub.js) ---------- */

.scrub { position: relative; padding: 0; border-top: var(--ink-rule); background: var(--rz-paper); }
.scrub__sticky {
  position: sticky; top: 0; height: 100vh; height: 100svh; overflow: hidden;
  display: grid; place-items: center;
}
.scrub__glow { position: absolute; inset: 0; background: radial-gradient(60% 55% at 50% 48%, rgba(150, 25, 28, .07), transparent 70%); pointer-events: none; }
.scrub__canvas {
  position: absolute; left: 50%; top: 50%; width: min(40vw, 480px); height: min(40vw, 480px);
  transform: translate(-50%, -50%); display: block; object-fit: contain;
}
.scrub__panel {
  position: absolute; top: 50%; z-index: 2; width: min(380px, 32vw);
  padding-top: var(--rz-space-sm); border-top: 1px solid var(--rz-ink);
  opacity: 0; transform: translateY(-46%); transition: opacity .45s ease-out, transform .6s cubic-bezier(.16, .84, .3, 1);
}
.scrub__panel:not(.is-on):not(:focus-within) { pointer-events: none; }
.scrub__panel.is-on { opacity: 1; transform: translateY(-50%); }
.scrub__panel:focus-within { opacity: 1; transform: translateY(-50%); }
.scrub__panel--left { left: max(var(--gut), calc((100vw - var(--wrap)) / 2 + var(--gut))); }
.scrub__panel--right { right: max(var(--gut), calc((100vw - var(--wrap)) / 2 + var(--gut))); }
.scrub__panel h2, .scrub__panel h3 { font-size: clamp(28px, 21px + 1.5vw, 42px); line-height: 1.1; overflow-wrap: break-word; margin-bottom: var(--rz-space-sm); }
.scrub__panel p { margin-bottom: var(--rz-space-sm); }
.scrub__panel .label { padding-right: 4.5em; font-size: 13px; }
/* Step counter (01 / 03): the data face of the label, pinned to the rule's right end. */
.scrub__count {
  position: absolute; top: var(--rz-space-sm); right: 0;
  font-family: var(--rz-font-data); font-weight: 500; font-size: 13px; line-height: 1.4;
  letter-spacing: .08em; font-variant-numeric: tabular-nums; color: var(--rz-aluminium);
}
.scrub__panel .small, .scrub__list { font-size: clamp(17px, 15px + .45vw, 21px); line-height: 1.45; }
/* Photo under the text: one still per step, no filter, shadow or animation. */
.scrub__photo { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; margin-top: var(--rz-space-sm); border-radius: var(--rz-radius-md); background: var(--rz-aluminium-light); }
.scrub__list { list-style: none; margin: 0 0 var(--rz-space-sm); padding: 0; }
.scrub__list li { margin: 0 0 6px; }
.scrub__list li:last-child { margin-bottom: 0; }
.scrub__ticks { position: absolute; left: 50%; bottom: max(22px, 4vh); transform: translateX(-50%); z-index: 3; display: flex; gap: 7px; }
.scrub__ticks span { width: 26px; height: 3px; border-radius: 2px; background: var(--rz-aluminium-light); overflow: hidden; }
.scrub__ticks span::after { content: ""; display: block; height: 100%; width: 100%; background: var(--rz-oxblood); transform: scaleX(0); transform-origin: left; transition: transform .4s ease; }
.scrub__ticks span.is-done::after { transform: scaleX(1); }
.scrub__ticks span.is-active::after { transform: scaleX(.5); }

/* Phones, tablets, low-power: the same sticky scrub with the lighter frame set.
   The picture sits in the upper part, the one active panel under it. */
@media (max-width: 1023.98px) {
  .scrub__sticky { display: block; }
  .scrub__canvas { top: calc(68px + 2svh); transform: translateX(-50%); width: min(78vw, calc(100svh - 68px - 96px - 300px - env(safe-area-inset-bottom)), 420px); height: min(78vw, calc(100svh - 68px - 96px - 300px - env(safe-area-inset-bottom)), 420px); }
  .scrub__panel { top: auto; padding: var(--rz-space-sm) 0 var(--rz-space-sm); background: rgba(255, 255, 255, .96); bottom: calc(76px + env(safe-area-inset-bottom) + 20px); left: var(--gut); right: var(--gut); width: auto; max-width: 520px; margin-inline: auto; transform: translateY(14px); }
  .scrub__panel h2, .scrub__panel h3 { font-size: clamp(25px, 21px + 1vw, 30px); margin-bottom: var(--rz-space-xs); }
  .scrub__panel .label { margin-bottom: var(--rz-space-xs); }
  .scrub__list { margin-bottom: var(--rz-space-xs); }
  .scrub__list li { margin-bottom: 4px; }
  /* Bottom sheet: the photo is a thumbnail beside the text so the sheet stays short. */
  .scrub__panel { display: grid; grid-template-columns: minmax(0, 1fr) 96px; column-gap: var(--rz-space-sm); align-items: start; }
  .scrub__panel > * { grid-column: 1; }
  .scrub__panel > .scrub__photo { grid-column: 2; grid-row: 2 / span 4; margin-top: 0; width: 96px; align-self: end; }
  .scrub__panel.is-on { transform: none; }
  .scrub__panel--left, .scrub__panel--right { left: var(--gut); right: var(--gut); }
  .scrub__ticks { bottom: calc(76px + env(safe-area-inset-bottom) + 4px); }
}

/* Static layout: the poster, then every step stacked. No JavaScript, reduced motion,
   and any set whose frames have not been added yet. */
.scrub.is-static .scrub__sticky { position: relative; height: auto; display: grid; gap: var(--rz-space-md); padding-block: var(--rz-space-xl); justify-items: center; }
.scrub.is-static .scrub__canvas { position: static; transform: none; width: min(70vw, 360px); height: auto; aspect-ratio: 1; }
.scrub.is-static .scrub__panel { position: relative; inset: auto; pointer-events: auto; opacity: 1; transform: none; width: min(460px, calc(100vw - 2 * var(--gut))); margin: 0; }
.scrub.is-static .scrub__panel { display: block; }
.scrub.is-static .scrub__photo { width: 100%; margin-top: var(--rz-space-sm); }
.scrub.is-static .scrub__ticks, .scrub.is-static .scrub__glow { display: none; }

/* The XRF and cash frames are opaque photographs, not cut-outs: soften their corners. */
.scrub[data-frame-dir$="xrf-read"] .scrub__canvas, .scrub[data-frame-dir$="cash-handover"] .scrub__canvas { border-radius: var(--rz-radius-lg); }

/* Desktop: the photo fits the gap between the two panel columns, never under the text. */
@media (min-width: 1024px) {
  .scrub[data-frame-dir$="xrf-read"]:not(.is-static) .scrub__canvas,
  .scrub[data-frame-dir$="cash-handover"]:not(.is-static) .scrub__canvas {
    --scrub-inset: max(var(--gut), calc((100vw - var(--wrap)) / 2 + var(--gut)));
    --scrub-fit: min(480px, calc(100vw - 2 * (var(--scrub-inset) + min(380px, 32vw) + var(--rz-space-md))));
    width: var(--scrub-fit); height: var(--scrub-fit);
  }
}
