/*
 * Roca Professionals, public site: motion. Scroll reveals, parallax layers, the loading screen, page
 * transitions and the frame of the animated scenes. public/assets/js/site.js sets the classes; without it
 * (or with prefers-reduced-motion) everything stays in its final, readable place.
 */

/* Scenes (templates/scene-*.php) animate only while they are on screen: site.js adds is-in. */
.rp-scene {
  position: relative;
  width: 100%;
  color: var(--rp-ink);
}

.rp-scene svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.rp-scene:not(.is-in) *,
.rp-scene:not(.is-in) *::before,
.rp-scene:not(.is-in) *::after {
  animation-play-state: paused !important;
}

/* ---- Page transitions: cross-document view transitions where the browser has them ------------ */

@view-transition {
  navigation: auto;
}

.rp-site-header {
  view-transition-name: rp-site-header;
}

::view-transition-old(root) {
  animation: rp-vt-out var(--rp-dur-slow) var(--rp-ease) both;
}

::view-transition-new(root) {
  animation: rp-vt-in var(--rp-dur-count) var(--rp-ease) both;
}

@keyframes rp-vt-out { to { opacity: 0; transform: translateY(calc(-1 * var(--rp-sp-4))); } }
@keyframes rp-vt-in { from { opacity: 0; transform: translateY(var(--rp-sp-6)); } }

/* ---- Loading screen: the Roca mark fills with water, then the curtain lifts ------------------- */

/*
 * The whole timeline is CSS, so the page never waits for a script: the curtain appears after 120 ms, the
 * mark fills by 1.3 s, the curtain lifts by 1.8 s. site.js skips it on later pages of the visit by adding
 * rp-skip-intro to <html> within those first 120 ms.
 */
.rp-loader {
  position: fixed;
  z-index: 100;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: var(--rp-sp-4);
  background: var(--rp-paper);
  color: var(--rp-ink);
  opacity: 0;
  pointer-events: none;
  animation: rp-loader-in 1ms 120ms both, rp-loader-out 600ms 1500ms var(--rp-ease) both;
}

.rp-loader__mark {
  position: relative;
  width: calc(var(--rp-sp-30) + var(--rp-sp-10));
  aspect-ratio: var(--rp-logo-ar);
  overflow: hidden;
  background: var(--rp-line-strong);
  -webkit-mask: var(--rp-logo);
  mask: var(--rp-logo);
}

/* Water: a wide wave image rising and drifting sideways inside the mark. */
.rp-loader__water {
  position: absolute;
  inset: -40% -100% 0 -100%;
  background: var(--rp-loader-wave) 0 0 / 50% 40% repeat-x,
    linear-gradient(var(--rp-accent), var(--rp-accent)) 0 39% / 100% 61% no-repeat;
  transform: translateY(100%);
  animation: rp-loader-fill 1100ms 200ms var(--rp-ease) both, rp-loader-drift 900ms linear infinite;
}

.rp-loader__word {
  font-size: var(--rp-fs-caption);
  font-weight: var(--rp-fw-medium);
  letter-spacing: 0.32em;
  text-transform: uppercase;
  opacity: 0;
  animation: rp-rise-in var(--rp-dur-count) 700ms var(--rp-ease) both;
}

@keyframes rp-loader-in { to { opacity: 1; } }
@keyframes rp-loader-out { to { opacity: 0; transform: translateY(-100%); visibility: hidden; } }
@keyframes rp-loader-fill { to { transform: translateY(0); } }
@keyframes rp-loader-drift { to { background-position: 50% 0, 0 39%; } }

.rp-skip-intro .rp-loader {
  display: none;
}

/* ---- Scroll reveals ---------------------------------------------------------------------------- */

.rp-js [data-reveal] {
  transition: opacity var(--rp-dur-count) var(--rp-ease), transform 700ms var(--rp-ease);
}

.rp-js [data-reveal]:not(.is-in) {
  opacity: 0;
  transform: translateY(var(--rp-sp-8));
}

.rp-js [data-reveal="fade"]:not(.is-in) {
  transform: none;
}

.rp-js [data-reveal="scale"]:not(.is-in) {
  transform: scale(0.94);
}

/* Children of a staggered group come one after another. */
.rp-js [data-stagger] > * {
  transition: opacity var(--rp-dur-count) var(--rp-ease), transform 700ms var(--rp-ease);
}

.rp-js [data-stagger]:not(.is-in) > * {
  opacity: 0;
  transform: translateY(var(--rp-sp-6));
}

.rp-js [data-stagger] > :nth-child(2) { transition-delay: 80ms; }
.rp-js [data-stagger] > :nth-child(3) { transition-delay: 160ms; }
.rp-js [data-stagger] > :nth-child(4) { transition-delay: 240ms; }
.rp-js [data-stagger] > :nth-child(5) { transition-delay: 320ms; }
.rp-js [data-stagger] > :nth-child(6) { transition-delay: 400ms; }

/* ---- Hero: a framed photo that opens to the whole screen while scrolling ----------------------- */

/* --p (0..1) is the scroll progress through the hero, set by site.js; without it the photo is open. */
.rp-hx {
  --p: 1;
  position: relative;
  height: 210vh;
  height: 210svh;
  background: var(--rp-paper);
}

.rp-js .rp-hx {
  --p: 0;
}

.rp-hx__sticky {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
}

.rp-hx__media {
  /* The frame the photo starts in: the right half on a computer, the lower half on a phone. */
  --t0: 56%;
  --r0: 5%;
  --b0: 6%;
  --l0: 5%;
  position: absolute;
  inset: 0;
  overflow: hidden;
  clip-path: inset(calc((1 - var(--p)) * var(--t0)) calc((1 - var(--p)) * var(--r0)) calc((1 - var(--p)) * var(--b0)) calc((1 - var(--p)) * var(--l0)) round calc((1 - var(--p)) * var(--rp-r-frame)));
  will-change: clip-path;
}

@media (min-width: 900px) {
  .rp-hx__media {
    --t0: 14%;
    --r0: 4%;
    --b0: 8%;
    --l0: 52%;
  }
}

.rp-hx__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(calc(1.18 - var(--p) * 0.18));
  will-change: transform;
}

.rp-hx__media::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--rp-scrim-media);
  opacity: var(--p);
}

/* The opening title stands above the framed photo and leaves as it opens. */
.rp-hx__intro {
  position: absolute;
  inset: 0 0 auto;
  padding-top: var(--rp-sp-10);
  opacity: calc(1 - var(--p) * 2.2);
  transform: translateY(calc(var(--p) * -12vh));
}

@media (min-width: 900px) {
  .rp-hx__intro {
    inset: 0 auto 0 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 50%;
    max-width: none;
    margin: 0;
    padding-top: 0;
    padding-left: max(var(--rp-site-gutter), calc((100% - var(--rp-w-content)) / 2 + var(--rp-site-gutter)));
  }
}

.rp-hx__title {
  margin-top: var(--rp-sp-3);
  font-size: clamp(36px, 5cqi, 72px);
  font-weight: var(--rp-fw-heading);
  line-height: var(--rp-lh-tight);
  letter-spacing: var(--rp-ls-display);
}

.rp-hx__lead {
  max-width: 30em;
  margin-top: var(--rp-sp-5);
  font-size: var(--rp-site-lead);
  color: var(--rp-text-secondary);
}

/* The statement over the open photo. */
.rp-hx__over {
  position: absolute;
  inset: auto 0 0;
  padding-bottom: var(--rp-site-hero-pb);
  color: var(--rp-text-inverse);
  opacity: calc((var(--p) - 0.65) * 3);
  transform: translateY(calc((1 - var(--p)) * 8vh));
}

/* The signature of the style: the white Roca mark at the bottom left of the open photo (it appears with the statement). */
.rp-hx__over {
  padding-bottom: calc(var(--rp-site-hero-pb) + var(--rp-sp-12));
}

.rp-hx__over::after {
  content: "";
  position: absolute;
  bottom: var(--rp-sp-6);
  left: max(var(--rp-site-gutter), calc((100% - var(--rp-w-content)) / 2 + var(--rp-site-gutter)));
  height: var(--rp-sp-6);
  aspect-ratio: var(--rp-logo-ar);
  background: var(--rp-text-inverse);
  -webkit-mask: var(--rp-logo);
  mask: var(--rp-logo);
}

.rp-hx__over-title {
  max-width: 15em;
  font-size: var(--rp-site-h1);
  font-weight: var(--rp-fw-heading);
  line-height: var(--rp-lh-tight);
  letter-spacing: var(--rp-ls-display);
}

.rp-hx__over .rp-actions {
  margin-top: var(--rp-sp-6);
}

/* Floating chips over the photo, moved by the parallax at their own speed. */
.rp-hx__chip {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: var(--rp-sp-2);
  padding: var(--rp-sp-2) var(--rp-sp-3);
  border-radius: var(--rp-r-md);
  background: var(--rp-surface);
  box-shadow: var(--rp-sh-2);
  font-size: var(--rp-fs-small);
  font-weight: var(--rp-fw-medium);
  white-space: nowrap;
  opacity: calc(var(--p) * 1.6 - 0.2);
}

.rp-hx__chip .rp-icon {
  color: var(--rp-accent);
}

.rp-hx__chip--1 { top: 24%; left: 8%; }
.rp-hx__chip--2 { top: 34%; right: 10%; }
.rp-hx__chip--3 { top: 48%; left: 30%; }

@media (max-width: 899px) {
  .rp-hx__chip--1 { top: 22%; left: var(--rp-gutter-m); }
  .rp-hx__chip--2 { top: 34%; right: var(--rp-gutter-m); }
  .rp-hx__chip--3 { display: none; }
}

/* A scroll cue under the intro. */
.rp-hx__cue {
  position: absolute;
  left: 50%;
  bottom: var(--rp-sp-4);
  width: var(--rp-bw-strong);
  height: var(--rp-sp-10);
  overflow: hidden;
  background: var(--rp-line);
  opacity: calc(1 - var(--p) * 4);
}

.rp-hx__cue::after {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--rp-ink);
  animation: rp-cue 1.6s var(--rp-ease) infinite;
}

@keyframes rp-cue {
  from { transform: translateY(-100%); }
  to { transform: translateY(100%); }
}

/* Words of the title take turns in a slot: проектирует, продаёт, монтирует, создаёт (the first again closes the loop). */
.rp-words {
  display: inline-block;
  height: 1.2em;
  line-height: 1.2;
  overflow: hidden;
  vertical-align: bottom;
  color: var(--rp-accent);
}

.rp-words__track {
  display: flex;
  flex-direction: column;
  animation: rp-words 10s var(--rp-ease) infinite;
}

.rp-words__track > span {
  height: 1.2em;
  line-height: 1.2;
  white-space: nowrap;
}

@keyframes rp-words {
  0%, 20% { transform: translateY(0); }
  25%, 45% { transform: translateY(-1.2em); }
  50%, 70% { transform: translateY(-2.4em); }
  75%, 95% { transform: translateY(-3.6em); }
  100% { transform: translateY(-4.8em); }
}

/* The first entrance waits for the loading screen, unless it was skipped. */
.rp-hx__intro > * {
  animation: rp-rise-in 900ms 1550ms var(--rp-ease) both;
}

.rp-hx__intro > :nth-child(2) { animation-delay: 1650ms; }
.rp-hx__intro > :nth-child(3) { animation-delay: 1750ms; }
.rp-hx__intro > :nth-child(4) { animation-delay: 1850ms; }

.rp-skip-intro .rp-hx__intro > * {
  animation-delay: 0ms;
  animation-duration: var(--rp-dur-count);
}

/* ---- Parallax (site.js moves [data-speed] by translateY) --------------------------------------- */

[data-speed] {
  will-change: transform;
}

/* The frame clips its photo; where it sits is up to its own block (absolute in bands, in flow in splits). */
.rp-parallax-frame {
  overflow: hidden;
}

.rp-benefits__photo,
.rp-page-hero__photo {
  position: relative;
}

.rp-parallax-frame > img {
  position: absolute;
  inset: -12% 0;
  width: 100%;
  height: 124%;
  object-fit: cover;
}

/* ---- Water lines behind a section (21st.dev: Background Paths) -------------------------------- */

.rp-paths {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  color: var(--rp-line-strong);
}

.rp-paths svg {
  position: absolute;
  inset: -10% -5%;
  width: 110%;
  height: 120%;
}

.rp-paths path {
  fill: none;
  stroke: currentColor;
  stroke-width: 1;
  stroke-dasharray: 6 14;
  animation: rp-flow 14s linear infinite;
}

.rp-paths path:nth-child(3n) {
  color: var(--rp-accent);
  stroke: var(--rp-accent);
  stroke-opacity: 0.35;
  animation-duration: 9s;
}

.rp-paths path:nth-child(2n) {
  animation-direction: reverse;
  animation-duration: 18s;
}

@keyframes rp-flow { to { stroke-dashoffset: -400; } }

/* ---- Steps joined by a pipe that fills while scrolling ---------------------------------------- */

.rp-pipe {
  position: relative;
}

.rp-pipe::before,
.rp-pipe::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--rp-sp-0-5) * -1);
  height: var(--rp-bw-strong);
  background: var(--rp-line-strong);
}

.rp-pipe::after {
  background: var(--rp-accent);
  transform: scaleX(var(--pipe, 1));
  transform-origin: 0 50%;
}

.rp-js .rp-pipe {
  --pipe: 0;
}

/* ---- Image stream: two rows of interiors drifting (21st.dev: Image Stream, Marquee) ------------ */

.rp-stream {
  display: grid;
  gap: var(--rp-sp-4);
  overflow: hidden;
  padding-block: var(--rp-sp-4);
  -webkit-mask: linear-gradient(90deg, transparent, var(--rp-mask-solid) 8%, var(--rp-mask-solid) 92%, transparent);
  mask: linear-gradient(90deg, transparent, var(--rp-mask-solid) 8%, var(--rp-mask-solid) 92%, transparent);
}

.rp-stream__row {
  display: flex;
  gap: var(--rp-sp-4);
  width: max-content;
  animation: rp-stream 60s linear infinite;
}

.rp-stream__row--back {
  animation-direction: reverse;
  animation-duration: 70s;
}

.rp-stream:hover .rp-stream__row {
  animation-play-state: paused;
}

.rp-stream img {
  width: clamp(200px, 26vw, 360px);
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: var(--rp-r-lg);
}

@keyframes rp-stream { to { transform: translateX(-50%); } }

/* ---- A phone that straightens while scrolling (21st.dev: Container Scroll Animation) ---------- */

/* The tilted phone is wider in projection than in layout: its section clips the sides. */
.rp-section--phone {
  overflow-x: clip;
}

.rp-phone3d {
  --p: 1;
  display: grid;
  justify-items: center;
  perspective: 1200px;
}

.rp-js .rp-phone3d {
  --p: 0;
}

.rp-phone3d__device {
  width: min(320px, 78vw);
  aspect-ratio: 9 / 19.5;
  padding: var(--rp-sp-3);
  border-radius: var(--rp-r-device);
  background: var(--rp-ink);
  box-shadow: var(--rp-sh-device);
  transform: rotateX(calc((1 - var(--p)) * 32deg)) scale(calc(1.06 - var(--p) * 0.06)) translateY(calc((1 - var(--p)) * 40px));
  transform-origin: 50% 0;
  will-change: transform;
}

.rp-phone3d__screen {
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: var(--rp-r-device-screen);
  background: var(--rp-paper);
}

.rp-phone3d__screen img {
  width: 100%;
  height: auto;
}

/* Points around the phone, each at its own parallax speed. */
.rp-phone3d__wrap {
  position: relative;
  display: grid;
  justify-items: center;
}

.rp-phone3d__note {
  position: absolute;
  display: grid;
  gap: var(--rp-sp-0-5);
  max-width: 14em;
  padding: var(--rp-sp-3) var(--rp-sp-4);
  border-radius: var(--rp-r-lg);
  background: var(--rp-surface);
  box-shadow: var(--rp-sh-2);
  font-size: var(--rp-fs-small);
}

.rp-phone3d__note b {
  font-weight: var(--rp-fw-medium);
}

.rp-phone3d__note span {
  color: var(--rp-text-tertiary);
}

.rp-phone3d__note--1 { top: 14%; left: calc(50% - 360px); }
.rp-phone3d__note--2 { top: 40%; right: calc(50% - 380px); }
.rp-phone3d__note--3 { top: 70%; left: calc(50% - 380px); }

@media (max-width: 899px) {
  .rp-phone3d__note { display: none; }
}

/* ---- Cards that tilt toward the pointer and light up under it (21st.dev: Spotlight Card) ------- */

[data-tilt] {
  transform: perspective(900px) rotateX(var(--ry, 0deg)) rotateY(var(--rx, 0deg));
  transition: transform var(--rp-dur-slow) var(--rp-ease);
}

[data-tilt].is-tilting {
  transition: none;
}

.rp-spot {
  position: relative;
  isolation: isolate;
}

.rp-spot::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  background: radial-gradient(320px circle at var(--mx, 50%) var(--my, 50%), var(--rp-glint), transparent 60%);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--rp-dur) var(--rp-ease);
}

.rp-spot:hover::after {
  opacity: 1;
}

/* ---- Reduced motion: everything in its final place, nothing moves ------------------------------ */

@media (prefers-reduced-motion: reduce) {
  .rp-loader { display: none; }
  .rp-js .rp-hx, .rp-js .rp-phone3d { --p: 1; }
  .rp-hx { height: auto; }
  .rp-hx__sticky { position: relative; height: 100svh; }
  .rp-hx__intro { display: none; }
  .rp-hx__over { opacity: 1; transform: none; }
  .rp-js [data-reveal]:not(.is-in), .rp-js [data-stagger]:not(.is-in) > * { opacity: 1; transform: none; }
  .rp-js .rp-pipe { --pipe: 1; }
  .rp-stream { overflow-x: auto; }
  [data-speed] { transform: none !important; }
}
