/* ═════════════════════════════════════════════════════════════════
   RIVIO — Site v2
   ═════════════════════════════════════════════════════════════════ */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  background: var(--light-01);
  color: var(--dark-02);
  font-family: var(--font-display);
  font-weight: 400;
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: clip;
}

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

ul {
  list-style: none;
}

::selection {
  background: rgba(102, 148, 255, 0.22);
}

.u-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ─────────────────────────────────────────────────────────────────
   Entrance — a timed load sequence for the nav and the hero.
   Time-based, not scroll-based: it plays once, on its own clock.

   Every hidden state is scoped to `.js`, which an inline script in the
   document head sets before first paint — so with JS off, or if the
   sequence never fires, the header is simply visible.
   ───────────────────────────────────────────────────────────────── */

.js [data-reveal] {
  opacity: 0;
  transform: translateY(var(--ry, 14px));
}

.js.is-ready [data-reveal] {
  opacity: 1;
  transform: none;
  transition: opacity 0.85s var(--ease-out-expo) var(--d, 0ms),
    transform 0.95s var(--ease-out-expo) var(--d, 0ms);
}

/* Headline: one mask per rendered line, each sliding up from behind its
   own bottom edge. The padding/margin pair keeps descenders off the mask. */
.line {
  display: block;
  overflow: hidden;
  padding-bottom: 0.14em;
  margin-bottom: -0.14em;
}

.js .line__i {
  display: block;
  transform: translateY(115%);
}

.js.is-ready .line__i {
  transform: none;
  transition: transform 1.05s var(--ease-out-expo) var(--d, 0ms);
}

/* The photographic plate settles out of a slow push-in */
.js .hero__media {
  opacity: 0;
  transform: scale(1.09);
}

.js.is-ready .hero__media {
  opacity: 1;
  transform: none;
  transition: opacity 1.3s ease 0.05s, transform 2.1s var(--ease-out-expo) 0.05s;
}

/* Landing mid-page (a reload, a restored scroll position) skips the
   sequence — the entrance is for arrivals, not returns. */
.js.is-instant [data-reveal],
.js.is-instant .line__i,
.js.is-instant .hero__media {
  transition: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .js [data-reveal],
  .js .line__i,
  .js .hero__media {
    opacity: 1;
    transform: none;
    transition: none !important;
  }
}

/* ─────────────────────────────────────────────────────────────────
   Navigation — fixed, theme-aware (light over hero, dark over the
   Intelligence stage)
   ───────────────────────────────────────────────────────────────── */

.nav {
  position: fixed;
  inset: 0 0 auto;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px var(--gutter);
  backdrop-filter: blur(17px);
  -webkit-backdrop-filter: blur(17px);
  color: var(--light-80);
  transition: color 0.5s var(--ease-out-soft),
    background-color 0.5s var(--ease-out-soft);
}

.nav.is-dark {
  color: rgba(49, 53, 61, 0.82);
  background: rgba(247, 249, 255, 0.62);
}

.nav__logo {
  display: block;
  width: 80.633px;
  height: 24px;
}

.nav__logo svg {
  width: 100%;
  height: 100%;
}

.nav__menu {
  display: flex;
  align-items: center;
  gap: 48px;
}

.nav__link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-label);
  font-weight: 500;
  font-size: 12px;
  line-height: 1;
  letter-spacing: 0.72px;
  text-transform: uppercase;
  color: currentColor;
  opacity: 1;
  transition: opacity 0.3s var(--ease-out-soft);
}

.nav__link:hover {
  opacity: 0.62;
}

.nav__link svg {
  width: 14px;
  height: 14px;
}

.nav__lang {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 200px;
  background: var(--light-32);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: background-color 0.5s var(--ease-out-soft);
}

.nav.is-dark .nav__lang {
  background: rgba(49, 53, 61, 0.08);
}

.nav__lang button {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50px;
  background: transparent;
  color: currentColor;
  font-family: var(--font-label);
  font-weight: 600;
  font-size: 8px;
  line-height: 1;
  letter-spacing: 0.48px;
  text-transform: uppercase;
  cursor: pointer;
  transition: background-color 0.3s var(--ease-out-soft),
    color 0.3s var(--ease-out-soft);
}

.nav__lang button[aria-pressed='true'] {
  background: var(--light-48);
  color: var(--light-01);
}

.nav.is-dark .nav__lang button[aria-pressed='true'] {
  background: rgba(49, 53, 61, 0.88);
  color: var(--light-01);
}

/* ─────────────────────────────────────────────────────────────────
   Hero
   ───────────────────────────────────────────────────────────────── */

.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 100svh;
  padding: 102px var(--gutter) 32px;
  overflow: clip;
  isolation: isolate;
  /* the plate fades up out of this, so the open reads as cinematic
     rather than as a white flash */
  background: #23262c;
}

.hero__media {
  position: absolute;
  inset: -6% 0 0;
  z-index: -1;
  pointer-events: none;
}

.hero__media img {
  width: 100%;
  height: 106%;
  object-fit: cover;
  will-change: transform;
}

.hero__media::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.42) 0%,
    rgba(0, 0, 0, 0.24) 34%,
    rgba(0, 0, 0, 0.34) 100%
  );
}

.hero__inner {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.hero__tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  font-family: var(--font-label);
  font-weight: 600;
  font-size: 12px;
  line-height: 1.5;
  letter-spacing: 0.72px;
  text-transform: uppercase;
  color: var(--light-64);
}

.hero__tag::before {
  content: '';
  width: 8px;
  height: 8px;
  background: var(--light-48);
}

.hero__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 48px;
  min-height: 144px;
}

.hero__headline {
  max-width: 646px;
  font-weight: 300;
  font-size: clamp(34px, 4.167vw, 60px);
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--light-01);
}

.hero__aside {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 16px;
  width: 347px;
  padding: 8px 0;
  flex: none;
}

.hero__lede {
  font-size: 16px;
  line-height: 1.5;
  color: var(--light-01);
}

/* Shared "Scroll to explore" affordance */
.scroll-hint {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-size: 16px;
  line-height: 1.2;
  color: var(--light-80);
}

.scroll-hint svg {
  width: 14px;
  height: 20px;
  overflow: visible;
}

.scroll-hint__wheel {
  animation: wheel 2.4s var(--ease-in-out-soft) infinite;
  transform-origin: 50% 50%;
}

@keyframes wheel {
  0%,
  100% {
    transform: translateY(0);
    opacity: 1;
  }
  45% {
    transform: translateY(3px);
    opacity: 0.35;
  }
  70% {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ─────────────────────────────────────────────────────────────────
   Clientes
   ───────────────────────────────────────────────────────────────── */

.clients {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 28px;
  background: var(--light-01);
}

.clients__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  width: 100%;
  max-width: 1384px;
}

.clients__row img {
  height: 40px;
  width: auto;
  object-fit: contain;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.9s var(--ease-out-expo),
    transform 0.9s var(--ease-out-expo);
}

.clients.is-in img {
  opacity: 1;
  transform: none;
}

/* ─────────────────────────────────────────────────────────────────
   Section 2 + 3 — Hospital Intelligence / Intelligence Layers
   One continuous scroll-driven stage.
   ───────────────────────────────────────────────────────────────── */

.intel {
  position: relative;
  background: var(--light-01);
}

.intel__track {
  position: relative;
  height: calc(100svh + var(--intel-range));
}

.intel__viewport {
  position: sticky;
  top: 0;
  height: 100svh;
  overflow: clip;
  isolation: isolate;
}

/* Ground: flat Light-01 in section 2, soft gradient once the stage opens */
.intel__ground {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: var(--intel-bg);
  opacity: 0;
  will-change: opacity;
}

/* ── The headline ────────────────────────────────────────────────
   Single element. Starts at 60px dead-center, scrubs up to a
   full-bleed 161px lockup docked at the top of the screen.
   Sizing + origin are measured in JS so the cap-height lands
   exactly where Figma puts it.                                    */

.intel__title {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  display: flex;
  justify-content: center;
  width: 100%;
  pointer-events: none;
}

.intel__title-text {
  --grad-end: 285.37%;
  font-weight: 300;
  font-size: 11.18vw; /* replaced by measured value in JS */
  line-height: 1.24;
  letter-spacing: -0.04em;
  white-space: nowrap;
  background-image: linear-gradient(
    180deg,
    var(--dark-05) 28.947%,
    rgba(122, 133, 153, 0.14) var(--grad-end)
  );
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  opacity: 0;
  transform-origin: 50% 50%;
  will-change: transform, opacity;
}

/* ── The layer stack ─────────────────────────────────────────────
   Each plate is an isolated glass render. Design geometry:
   plate box 833.33 × 520, stacked with a 38px vertical pitch, the
   whole stack staying optically centred as it grows.              */

.intel__stage {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

/* Absolutely centred rather than layout-centred: the stack is 833px wide
   in design space and would overflow — and mis-align — a narrow viewport
   before `--stage-scale` is applied. */
.intel__stack {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 833.33px;
  height: 520px;
  margin: -260px 0 0 -416.665px;
  transform: scale(var(--stage-scale, 1)) translateY(-8px);
  transform-origin: 50% 50%;
}

.plate {
  position: absolute;
  inset: 0;
  opacity: 0;
  will-change: transform, opacity;
  backface-visibility: hidden;
}

.plate img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Soft contact shadow that grows as the stack deepens */
.intel__shadow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 640px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(
    50% 50% at 50% 50%,
    rgba(49, 66, 102, 0.16) 0%,
    rgba(49, 66, 102, 0) 72%
  );
  transform: translate(-50%, -50%);
  opacity: 0;
  will-change: transform, opacity;
  pointer-events: none;
}

/* ── Bottom-left copy — one block per layer, subtle crossfade ──── */

.intel__hud {
  position: absolute;
  inset: auto 0 0;
  z-index: 3;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  padding: var(--gutter);
  pointer-events: none;
}

.intel__copy {
  position: relative;
  width: min(648px, 62vw);
  min-height: 125px;
  opacity: 0; /* driven by the scrub */
}

.layer-copy {
  position: absolute;
  inset: 0 auto auto 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  opacity: 0;
  visibility: hidden;
  transform: translateY(14px);
  filter: blur(3px);
  transition: opacity 0.52s var(--ease-out-soft),
    transform 0.62s var(--ease-out-expo), filter 0.52s var(--ease-out-soft),
    visibility 0s linear 0.62s;
}

.layer-copy.is-active {
  opacity: 1;
  visibility: visible;
  transform: none;
  filter: blur(0);
  transition-delay: 0.08s, 0.08s, 0.08s, 0s;
}

/* leaving block drifts up and out */
.layer-copy.is-leaving {
  opacity: 0;
  transform: translateY(-12px);
  filter: blur(3px);
}

.layer-copy__meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-label);
  font-weight: 600;
  font-size: 14px;
  line-height: 1;
  letter-spacing: 0.56px;
  text-transform: uppercase;
  color: var(--dark-05);
}

.layer-copy__status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--yellow);
}

.layer-copy[data-status='on'] .layer-copy__status {
  color: var(--blue);
}

.layer-copy__status::before {
  content: '';
  width: 5px;
  height: 5px;
  background: currentColor;
  animation: pulse 2.6s var(--ease-in-out-soft) infinite;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.32;
  }
}

.layer-copy__title {
  font-weight: 400;
  font-size: clamp(26px, 2.5vw, 36px);
  line-height: 1.2;
  color: var(--dark-02);
}

.layer-copy__desc {
  font-size: 16px;
  line-height: 1.5;
  color: var(--dark-05);
}

.intel__hint {
  flex: none;
  color: var(--dark-05);
  opacity: 0; /* driven by the scrub */
}

.intel__hint .scroll-hint {
  color: var(--dark-05);
}

/* ── Right rail ─────────────────────────────────────────────────── */

.intel__rail {
  position: absolute;
  top: 50%;
  right: var(--gutter);
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 11px;
  width: 8px;
  transform: translateY(calc(-50% - 8px));
  opacity: 0; /* driven by the scrub */
}

.rail__dot {
  position: relative;
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50px;
  background: rgba(122, 133, 153, 0.32); /* Dark-05 @ 32% */
  overflow: hidden;
  will-change: height;
}

/* the lit pill is Dark-88 @ 30%, crossfaded in as the layer takes over */
.rail__dot > i {
  position: absolute;
  inset: 0;
  border-radius: 50px;
  background: rgba(0, 0, 0, 0.3); /* Dark-88 @ 30% opacity */
  opacity: 0;
}

/* ─────────────────────────────────────────────────────────────────
   Foot
   ───────────────────────────────────────────────────────────────── */

.foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 40px var(--gutter);
  background: var(--light-01);
  border-top: 1px solid rgba(122, 133, 153, 0.16);
  font-family: var(--font-label);
  font-weight: 500;
  font-size: 12px;
  letter-spacing: 0.72px;
  text-transform: uppercase;
  color: var(--dark-05);
}

.foot__logo {
  width: 80.633px;
  height: 24px;
  color: var(--dark-02);
}

/* ─────────────────────────────────────────────────────────────────
   Responsive
   ───────────────────────────────────────────────────────────────── */

@media (max-width: 1100px) {
  .nav__menu {
    gap: 28px;
  }
  .hero__row {
    flex-direction: column;
    align-items: flex-start;
    gap: 28px;
  }
  .hero__aside {
    width: 100%;
    max-width: 420px;
  }
  .clients__row {
    flex-wrap: wrap;
    justify-content: center;
    gap: 28px 40px;
  }
  .clients__row img {
    height: 32px;
  }
}

@media (max-width: 860px) {
  .nav__menu {
    display: none;
  }
  .intel__hud {
    flex-direction: column;
    align-items: flex-start;
    gap: 20px;
  }
  .intel__copy {
    width: 100%;
    min-height: 150px;
  }
  .intel__hint {
    display: none;
  }
  .intel__rail {
    right: 14px;
  }
  .layer-copy__desc {
    font-size: 15px;
  }
  .foot {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
}

/* ─────────────────────────────────────────────────────────────────
   Reduced motion — everything still reads, nothing moves on its own
   ───────────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .scroll-hint__wheel,
  .layer-copy__status::before {
    animation: none;
  }
  .layer-copy {
    filter: none;
    transform: none;
    transition-duration: 0.18s;
  }
  .layer-copy.is-leaving {
    transform: none;
    filter: none;
  }
  .clients__row img {
    transition: none;
    opacity: 1;
    transform: none;
  }
}
