/* Purposeful, progressive site-wide motion. Content remains readable without JS. */

:root {
  --site-motion-fast: 180ms;
  --site-motion-base: 420ms;
  --site-motion-slow: 720ms;
  --site-motion-ease-out: cubic-bezier(.22, 1, .36, 1);
  --site-motion-cyan: #68e1ff;
  --site-motion-violet: #9d8cff;
  --site-motion-gold: #e2b76f;
}

body[data-motion-page] {
  --site-motion-progress: 0;
}

/* Reserve the async-enhanced desktop navigation shell so motion entrypoints do
   not amplify the site's existing nav rewrite into a load-time layout shift. */
@media (min-width: 1100px) {
  body[data-motion-page] .header .navbar {
    min-height: 5.8375rem;
  }

  body[data-motion-page] .nav-links > li:has(> a[href*='store.cloudpeakify.com']),
  body[data-motion-page] .nav-links > li:has(> a[href*='/finance.html']) {
    display: none;
  }
}

/* The homepage rail reflects the existing nine-chapter Three.js story. */
.infrastructure-journey__progress {
  --journey-story-progress: 0;
  position: fixed;
  z-index: 8;
  top: 50%;
  left: clamp(.85rem, 2vw, 2rem);
  display: grid;
  gap: .52rem;
  width: 10.5rem;
  padding: .75rem .8rem;
  border: 1px solid rgba(104, 225, 255, .14);
  border-radius: .65rem;
  background: rgba(3, 9, 14, .72);
  backdrop-filter: blur(8px);
  opacity: 0;
  transform: translateY(-50%) translateX(-.65rem);
  transition: opacity var(--site-motion-base) ease-out, transform var(--site-motion-base) var(--site-motion-ease-out);
  pointer-events: none;
}

.infrastructure-journey[data-visual-active]:not([data-visual-active='0'])[data-visual-visible='true'] .infrastructure-journey__progress {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

.infrastructure-journey__progress-count {
  color: rgba(186, 207, 215, .55);
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .1em;
}

.infrastructure-journey__progress-count strong {
  color: var(--site-motion-cyan);
  font-size: .78rem;
}

.infrastructure-journey__progress-label {
  color: rgba(223, 238, 242, .78);
  font-size: .65rem;
  line-height: 1.25;
  text-wrap: balance;
}

.infrastructure-journey__progress-track {
  position: relative;
  display: block;
  height: 1px;
  overflow: hidden;
  background: rgba(104, 225, 255, .13);
}

.infrastructure-journey__progress-track b {
  position: absolute;
  inset: 0;
  display: block;
  background: linear-gradient(90deg, var(--site-motion-cyan), var(--site-motion-gold));
  box-shadow: 0 0 .9rem rgba(104, 225, 255, .45);
  transform: scaleX(var(--journey-story-progress));
  transform-origin: left center;
}

/* Quiet chapter markers: the content never moves or waits. */
[data-motion-chapter] {
  position: relative;
  isolation: isolate;
}

[data-motion-chapter]::before {
  position: absolute;
  top: clamp(2.3rem, 5vw, 4.8rem);
  left: max(1.25rem, calc((100vw - 1200px) / 2));
  width: clamp(3.5rem, 8vw, 7rem);
  height: 1px;
  background: linear-gradient(90deg, var(--site-motion-cyan), rgba(104, 225, 255, 0));
  box-shadow: 0 0 1.1rem rgba(104, 225, 255, .24);
  content: '';
  transform-origin: left center;
}

body[data-motion-state='ready'][data-motion-tier='full'] [data-motion-chapter]::before,
body[data-motion-state='ready'][data-motion-tier='reduced'] [data-motion-chapter]::before {
  opacity: .28;
  transform: scaleX(.18);
}

body[data-motion-state='ready'] [data-motion-chapter][data-motion-visible]::before {
  opacity: .9;
  transform: scaleX(1);
  transition: opacity var(--site-motion-base) ease-out, transform var(--site-motion-slow) var(--site-motion-ease-out);
}

/* Homepage 3D-to-proof handoff: one transition, no card choreography. */
[data-motion-handoff] {
  --motion-handoff: 1;
  isolation: isolate;
}

[data-motion-handoff]::before {
  position: absolute;
  z-index: 0;
  top: 0;
  left: 50%;
  width: min(76rem, calc(100% - 2.5rem));
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(104, 225, 255, .72), rgba(226, 183, 111, .34), transparent);
  box-shadow: 0 0 2.5rem rgba(104, 225, 255, .32);
  content: '';
  opacity: var(--motion-handoff);
  transform: translateX(-50%) scaleX(var(--motion-handoff));
  transform-origin: center;
}

[data-motion-handoff] > .container {
  position: relative;
  z-index: 1;
}

body[data-motion-state='ready'][data-motion-tier='full'] [data-motion-handoff]:not([data-motion-visible]) {
  --motion-handoff: .08;
}

body[data-motion-state='ready'][data-motion-tier='full'] [data-motion-handoff]::before {
  transition: opacity var(--site-motion-slow) ease-out, transform 900ms var(--site-motion-ease-out);
}

/* Scroll-linked architecture: system relationship first, cards always readable. */
[data-motion-architecture] .layer-grid {
  position: relative;
}

.motion-architecture__system {
  position: relative;
  grid-column: 1 / -1;
  display: grid;
  gap: .8rem;
  min-height: 7.5rem;
  padding: 1.1rem 1.25rem 1.3rem;
  overflow: hidden;
  border: 1px solid rgba(104, 225, 255, .16);
  border-radius: 1rem;
  background:
    radial-gradient(30rem 9rem at calc(var(--architecture-progress, 1) * 100%) 50%, rgba(104, 225, 255, .13), transparent 72%),
    rgba(7, 16, 31, .62);
}

.motion-architecture__label {
  color: rgba(206, 232, 240, .72);
  font-size: .68rem;
  font-weight: 720;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.motion-architecture__track {
  position: relative;
  height: 2px;
  margin-inline: .55rem;
  background: rgba(104, 225, 255, .12);
}

.motion-architecture__fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--site-motion-cyan), var(--site-motion-violet), var(--site-motion-gold));
  box-shadow: 0 0 1.5rem rgba(104, 225, 255, .45);
  transform: scaleX(var(--architecture-progress, 1));
  transform-origin: left center;
}

.motion-architecture__nodes {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: .55rem;
}

.motion-architecture__node {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: .45rem;
  align-items: center;
  min-width: 0;
  color: rgba(193, 214, 224, .56);
  font-size: .68rem;
  line-height: 1.2;
}

.motion-architecture__node::before {
  width: .52rem;
  height: .52rem;
  border: 1px solid rgba(104, 225, 255, .46);
  border-radius: 50%;
  background: rgba(3, 9, 17, .96);
  box-shadow: 0 0 0 .2rem rgba(104, 225, 255, .04);
  content: '';
}

[data-motion-architecture][data-motion-enhanced] .motion-architecture__fill {
  transform: scaleX(0);
}

[data-motion-architecture][data-motion-enhanced] .motion-architecture__node {
  opacity: .42;
}

[data-motion-architecture][data-motion-enhanced] .layer-card {
  transition: border-color var(--site-motion-base) ease-out, box-shadow var(--site-motion-base) ease-out, background-color var(--site-motion-base) ease-out;
}

/* Ordered horizontal delivery. Full desktop is enhanced by ScrollTrigger. */
[data-motion-horizontal] {
  --horizontal-progress: 1;
  position: relative;
}

.motion-horizontal__meta {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin: 0 0 1.25rem;
  color: rgba(200, 221, 230, .64);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.motion-horizontal__meter {
  position: relative;
  flex: 1;
  height: 1px;
  overflow: hidden;
  background: rgba(104, 225, 255, .14);
}

.motion-horizontal__meter::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--site-motion-cyan), var(--site-motion-violet));
  content: '';
  transform: scaleX(var(--horizontal-progress));
  transform-origin: left center;
}

.motion-horizontal__viewport {
  max-width: 100%;
}

body[data-motion-tier='full'] [data-motion-horizontal][data-motion-enhanced] {
  min-height: min(46rem, calc(100svh - 4rem));
  display: grid;
  align-items: center;
}

body[data-motion-tier='full'] [data-motion-horizontal][data-motion-enhanced] .motion-horizontal__viewport {
  overflow: hidden;
}

body[data-motion-tier='full'] [data-motion-horizontal][data-motion-enhanced] .delivery-flow {
  display: flex;
  gap: clamp(1rem, 2vw, 1.6rem);
  width: max-content;
  will-change: transform;
}

body[data-motion-tier='full'] [data-motion-horizontal][data-motion-enhanced] .delivery-step {
  flex: 0 0 min(72vw, 52rem);
  min-height: clamp(17rem, 42vh, 23rem);
  grid-template-columns: 4.2rem 1fr;
  align-content: center;
  padding: clamp(1.5rem, 3vw, 3rem);
}

body[data-motion-tier='full'] [data-motion-horizontal][data-motion-enhanced] .delivery-step p {
  grid-column: 2;
  max-width: 52ch;
}

body[data-motion-tier='minimal'] .motion-horizontal__meta {
  display: none;
}

/* Managed Services sticky narrative. */
.motion-process__layout {
  display: grid;
  grid-template-columns: minmax(18rem, .82fr) minmax(24rem, 1.18fr);
  gap: clamp(2rem, 6vw, 6.5rem);
  align-items: start;
}

.motion-process__visual {
  position: sticky;
  top: clamp(6rem, 13vh, 8.5rem);
  display: grid;
  gap: 1.25rem;
  min-height: min(64vh, 34rem);
  padding: clamp(1.5rem, 3vw, 2.5rem);
  overflow: hidden;
  border: 1px solid rgba(104, 225, 255, .2);
  border-radius: 1.25rem;
  background:
    radial-gradient(24rem 19rem at 50% 38%, rgba(104, 225, 255, .09), transparent 72%),
    linear-gradient(155deg, rgba(11, 25, 47, .96), rgba(7, 13, 27, .92));
  box-shadow: 0 2rem 5rem -3.5rem rgba(0, 0, 0, .9);
}

.motion-process__eyebrow {
  color: rgba(104, 225, 255, .72);
  font-size: .68rem;
  font-weight: 720;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.motion-process__state {
  max-width: 14ch;
  min-height: 2.6em;
  margin: 0;
  color: #f2f6f7;
  font-family: var(--font-heading, 'Space Grotesk', system-ui, sans-serif);
  font-size: clamp(1.75rem, 3vw, 3rem);
  line-height: .98;
  text-wrap: balance;
}

.motion-process__orbit {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 12rem;
}

.motion-process__core {
  display: grid;
  place-items: center;
  width: 7rem;
  aspect-ratio: 1;
  border: 1px solid rgba(104, 225, 255, .4);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(104, 225, 255, .16), rgba(9, 20, 37, .88) 62%);
  box-shadow: 0 0 3rem rgba(104, 225, 255, .11);
  color: #dff8ff;
  font-size: .72rem;
  font-weight: 720;
  letter-spacing: .08em;
  text-align: center;
  text-transform: uppercase;
}

.motion-process__orbit::before,
.motion-process__orbit::after {
  position: absolute;
  width: 11rem;
  aspect-ratio: 1;
  border: 1px solid rgba(157, 140, 255, .2);
  border-radius: 50%;
  content: '';
}

.motion-process__orbit::after {
  width: 15rem;
  border-color: rgba(104, 225, 255, .09);
}

.motion-process__nodes {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .45rem;
}

.motion-process__node {
  display: grid;
  gap: .45rem;
  justify-items: center;
  min-width: 0;
  color: rgba(184, 205, 214, .48);
  font-size: .62rem;
  text-align: center;
}

.motion-process__node::before {
  width: .65rem;
  height: .65rem;
  border: 1px solid rgba(104, 225, 255, .38);
  border-radius: 50%;
  background: #08111f;
  content: '';
}

.motion-process__node[data-active] {
  color: #dff8ff;
}

.motion-process__node[data-active]::before {
  border-color: var(--site-motion-cyan);
  background: var(--site-motion-cyan);
  box-shadow: 0 0 1.2rem rgba(104, 225, 255, .56);
}

.motion-process__meter {
  position: relative;
  height: 2px;
  overflow: hidden;
  background: rgba(104, 225, 255, .12);
}

.motion-process__meter::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, var(--site-motion-cyan), var(--site-motion-violet), var(--site-motion-gold));
  content: '';
  transform: scaleX(var(--process-progress, 1));
  transform-origin: left center;
}

[data-motion-process] .process-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.1rem;
}

[data-motion-process] .process-step {
  position: relative;
  min-height: clamp(15rem, 52vh, 28rem);
  display: grid;
  align-content: center;
  padding: clamp(1.5rem, 3vw, 2.5rem);
  transition: border-color var(--site-motion-base) ease-out, background-color var(--site-motion-base) ease-out, box-shadow var(--site-motion-base) ease-out;
}

[data-motion-process] .process-step[data-motion-active] {
  border-color: rgba(104, 225, 255, .48);
  background: linear-gradient(145deg, rgba(26, 60, 82, .46), rgba(12, 22, 42, .82));
  box-shadow: 0 1.4rem 3rem -2.7rem rgba(104, 225, 255, .42);
}

/* Editorial depth on the founder profile. Only decorative layers move. */
body[data-motion-page='about'] .profile-intro {
  display: grid;
  grid-template-columns: 10rem minmax(0, 1fr) minmax(13rem, auto);
  align-items: center;
  gap: clamp(1.25rem, 2.4vw, 2.5rem);
}

body[data-motion-page='about'] .profile-intro > :nth-child(2) {
  min-width: 0;
}

body[data-motion-page='about'] .profile-contact {
  align-self: center;
}

.motion-editorial-depth {
  position: relative;
  flex: 0 0 10rem;
  display: grid;
  place-items: center;
  width: 10rem;
  aspect-ratio: 1;
  margin: 0;
  overflow: visible;
}

.motion-editorial-depth__back,
.motion-editorial-depth__mid {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
}

.motion-editorial-depth__back {
  inset: -1.1rem;
  border: 1px solid rgba(104, 225, 255, .13);
  background-image:
    linear-gradient(rgba(104, 225, 255, .08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(104, 225, 255, .08) 1px, transparent 1px);
  background-size: 1.2rem 1.2rem;
  -webkit-mask-image: radial-gradient(circle, #000, transparent 72%);
  mask-image: radial-gradient(circle, #000, transparent 72%);
}

.motion-editorial-depth__mid {
  inset: -.45rem;
  border: 1px solid rgba(157, 140, 255, .3);
  background: radial-gradient(circle, rgba(104, 225, 255, .13), transparent 67%);
  box-shadow: 0 0 2.4rem rgba(104, 225, 255, .12);
}

.motion-editorial-depth img {
  position: relative;
  z-index: 2;
  display: block;
  width: 8.4rem;
  height: 8.4rem;
  border-radius: 50%;
  box-shadow: 0 1rem 2.5rem -1.5rem rgba(0, 0, 0, .9);
}

.motion-editorial-depth figcaption {
  position: absolute;
  z-index: 3;
  right: -1.4rem;
  bottom: -.55rem;
  width: max-content;
  max-width: 12rem;
  padding: .45rem .62rem;
  border: 1px solid rgba(104, 225, 255, .2);
  border-radius: .55rem;
  background: rgba(5, 13, 26, .9);
  color: rgba(220, 237, 242, .72);
  font-size: .62rem;
  font-weight: 650;
  letter-spacing: .05em;
  text-transform: uppercase;
}

@supports (animation-timeline: view()) {
  body[data-motion-tier='full'] .motion-editorial-depth__back {
    animation: motion-depth-back linear both;
    animation-timeline: view(block);
    animation-range: entry 0% exit 100%;
  }

  body[data-motion-tier='full'] .motion-editorial-depth__mid {
    animation: motion-depth-mid linear both;
    animation-timeline: view(block);
    animation-range: entry 0% exit 100%;
  }

  body[data-motion-tier='full'] .motion-editorial-depth img {
    animation: motion-depth-front linear both;
    animation-timeline: view(block);
    animation-range: entry 0% exit 100%;
  }
}

@keyframes motion-depth-back {
  from { transform: translateY(-3px) scale(.985); }
  to { transform: translateY(3px) scale(1.015); }
}

@keyframes motion-depth-mid {
  from { transform: translateY(-8px) rotate(-1.5deg); }
  to { transform: translateY(8px) rotate(1.5deg); }
}

@keyframes motion-depth-front {
  from { transform: translateY(-14px); }
  to { transform: translateY(14px); }
}

@media (max-width: 1099px), (pointer: coarse) {
  .infrastructure-journey__progress { display: none; }

  body[data-motion-state='ready'] [data-motion-chapter]::before {
    opacity: .72;
    transform: scaleX(1);
    transition: none;
  }

  .motion-architecture__system {
    min-height: 0;
  }

  .motion-architecture__nodes {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  [data-motion-horizontal] .motion-horizontal__viewport {
    overflow: visible;
  }

  body[data-motion-tier='mobile'] [data-motion-horizontal] .delivery-flow,
  body[data-motion-tier='reduced'] [data-motion-horizontal] .delivery-flow {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: min(86vw, 27rem);
    gap: 1rem;
    max-width: 100%;
    padding: .25rem .2rem 1rem;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-snap-type: inline mandatory;
    scrollbar-width: thin;
  }

  body[data-motion-tier='mobile'] [data-motion-horizontal] .delivery-step,
  body[data-motion-tier='reduced'] [data-motion-horizontal] .delivery-step {
    scroll-snap-align: start;
  }

  .motion-process__layout {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }

  .motion-process__visual {
    position: relative;
    top: auto;
    min-height: 0;
  }

  .motion-process__orbit { display: none; }

  [data-motion-process] .process-step {
    min-height: 0;
  }

  .motion-editorial-depth {
    flex-basis: 8rem;
    width: 8rem;
  }

  body[data-motion-page='about'] .profile-intro {
    grid-template-columns: 8rem minmax(0, 1fr);
    align-items: start;
  }

  body[data-motion-page='about'] .profile-contact {
    grid-column: 2;
    text-align: left;
  }

  body[data-motion-page='about'] .profile-social {
    justify-content: flex-start;
  }

  body[data-motion-page='about'] .profile-cv-btn {
    justify-self: start;
  }

  .motion-editorial-depth img {
    width: 6.8rem;
    height: 6.8rem;
  }
}

body[data-motion-tier='minimal'] .motion-process__state,
body[data-motion-tier='minimal'] .motion-process__orbit {
  display: none;
}

@media (max-width: 680px) {
  [data-motion-chapter]::before {
    top: 2rem;
    left: 1.25rem;
  }

  .motion-architecture__system { padding-inline: .9rem; }
  .motion-architecture__nodes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .motion-horizontal__meta { gap: .65rem; }
  .motion-process__visual { padding: 1.25rem; }
  .motion-process__nodes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .motion-editorial-depth { margin: 0 0 .75rem .3rem; }
  .motion-editorial-depth figcaption { right: -2rem; }

  body[data-motion-page='about'] .profile-intro {
    grid-template-columns: 1fr;
  }

  body[data-motion-page='about'] .profile-contact {
    grid-column: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .infrastructure-journey__progress { display: none !important; }

  [data-motion-chapter]::before,
  [data-motion-handoff]::before,
  [data-motion-architecture] .layer-card,
  [data-motion-process] .process-step {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  [data-motion-handoff] { --motion-handoff: 1 !important; }
  [data-motion-architecture] { --architecture-progress: 1 !important; }
  [data-motion-horizontal] { --horizontal-progress: 1 !important; }
  [data-motion-process] { --process-progress: 1 !important; }

  .motion-editorial-depth__back,
  .motion-editorial-depth__mid,
  .motion-editorial-depth img {
    animation: none !important;
    transform: none !important;
  }
}
