/* Site-wide motion layer. Hidden states only apply once motion.js (or the
   head snippet) adds .m-js, so the page stays fully visible without JS. */

html {
  scroll-behavior: smooth;
}
section[id] {
  scroll-margin-top: 88px;
}
main {
  overflow-x: clip;
}

/* ---------- Scroll reveal ---------- */
html .m-reveal {
  opacity: 0;
  transition:
    opacity 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) var(--m-delay, 0ms),
    translate 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) var(--m-delay, 0ms),
    scale 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) var(--m-delay, 0ms),
    filter 0.8s ease var(--m-delay, 0ms);
}
html .m-up {
  translate: 0 36px;
}
html .m-left {
  translate: -48px 0;
}
html .m-right {
  translate: 48px 0;
}
html .m-zoom {
  scale: 0.92;
  filter: blur(6px);
}
html .m-grow-x {
  opacity: 1;
  scale: 0 1;
  transform-origin: left center;
  transition: scale 1.4s cubic-bezier(0.6, 0, 0.2, 1) var(--m-delay, 0ms);
}
html .m-reveal.m-in {
  opacity: 1;
  translate: none;
  scale: none;
  filter: none;
}

/* ---------- Cards ---------- */
/* Cards rise with a small scale-up on top of the regular reveal. */
html .m-reveal.m-card {
  scale: 0.94;
}
html .m-reveal.m-card.m-in {
  scale: none;
}
/* Portfolio images wipe up into view. */
html .portfolio-card.m-reveal > div:first-child {
  clip-path: inset(100% 0 0 0 round 16px);
  transition: clip-path 1.1s cubic-bezier(0.7, 0, 0.2, 1)
    calc(var(--m-delay, 0ms) + 150ms);
}
html .portfolio-card.m-reveal.m-in > div:first-child {
  clip-path: inset(0 0 0 0 round 16px);
}
/* Testimonial stars pop in one by one. */
@keyframes m-star {
  from {
    opacity: 0;
    scale: 0.2;
  }
  60% {
    scale: 1.35;
  }
}
html .m-reveal.m-in [data-icon="star"] {
  display: inline-block;
  animation: m-star 0.5s cubic-bezier(0.3, 1.4, 0.5, 1) both;
  animation-delay: calc(var(--m-delay, 0ms) + 350ms);
}
html .m-reveal.m-in [data-icon="star"]:nth-child(2) {
  animation-delay: calc(var(--m-delay, 0ms) + 430ms);
}
html .m-reveal.m-in [data-icon="star"]:nth-child(3) {
  animation-delay: calc(var(--m-delay, 0ms) + 510ms);
}
html .m-reveal.m-in [data-icon="star"]:nth-child(4) {
  animation-delay: calc(var(--m-delay, 0ms) + 590ms);
}
html .m-reveal.m-in [data-icon="star"]:nth-child(5) {
  animation-delay: calc(var(--m-delay, 0ms) + 670ms);
}
/* 3D tilt towards the cursor (rotate is set inline by motion.js). */
html .m-tilt {
  transform-style: preserve-3d;
  will-change: rotate;
}
/* Journey cards brighten when the timeline reaches their marker. */
html #journey .m-timeline > * > div:first-child {
  transition:
    box-shadow 0.4s ease,
    translate 0.4s ease,
    rotate 0.25s ease-out,
    opacity 0.6s ease,
    scale 0.6s cubic-bezier(0.2, 0.7, 0.2, 1),
    filter 0.6s ease;
}
html #journey .m-card-pending {
  opacity: 0.45;
  scale: 0.96;
  filter: saturate(0.3);
}

/* ---------- Timeline fill ---------- */
html .m-track {
  opacity: 0.15;
  scale: none;
}
html .m-dot-anim {
  transition:
    opacity 0.4s ease,
    scale 0.6s cubic-bezier(0.34, 1.8, 0.5, 1),
    filter 0.4s ease,
    box-shadow 0.6s ease,
    transform 0.5s ease;
}
html #journey .m-dot-anim:not(.m-dot-pending) {
  box-shadow: 0 0 0 6px rgba(244, 102, 0, 0.12);
}
html .m-dot-pending {
  opacity: 0.4;
  scale: 0.75;
  filter: grayscale(1);
  box-shadow: none;
}

/* ---------- Hero entrance ---------- */
@keyframes m-rise {
  from {
    opacity: 0;
    translate: 0 40px;
  }
}
@keyframes m-rise-zoom {
  from {
    opacity: 0;
    translate: 0 60px;
    scale: 0.9;
  }
}
@keyframes m-word {
  from {
    opacity: 0;
    translate: 0 0.55em;
    filter: blur(8px);
  }
}
@keyframes m-show {
  to {
    opacity: 1;
  }
}
@keyframes m-float {
  50% {
    translate: 0 -12px;
  }
}
@keyframes m-drift-a {
  to {
    translate: 120px 80px;
    scale: 1.15;
  }
}
@keyframes m-drift-b {
  to {
    translate: -140px -60px;
    scale: 0.9;
  }
}
@keyframes m-drift-c {
  to {
    translate: 60px -110px;
    scale: 1.1;
  }
}
/* The heading waits for motion.js to split it into words; the failsafe shows
   it anyway if the script never runs. */
.m-js main > section:first-child h1 {
  opacity: 0;
  animation: m-show 0s 2.5s forwards;
}
.m-js main > section:first-child h1.m-split {
  opacity: 1;
  animation: none;
}
.m-word {
  display: inline-block;
  animation: m-word 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: calc(var(--i) * 70ms + 100ms);
}
.m-js main > section:first-child h1 ~ * {
  animation: m-rise 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both;
  animation-delay: 0.55s;
}
.m-js main > section:first-child h1 ~ * ~ * {
  animation-delay: 0.7s;
}
.m-js main > section:first-child .lg\:col-span-5 {
  animation: m-rise-zoom 1.1s cubic-bezier(0.2, 0.7, 0.2, 1) 0.3s both;
}
.m-js main > section:first-child .lg\:col-span-5 > .z-10 {
  animation: m-float 6s ease-in-out 1.4s infinite;
}
.m-js main > section:first-child > :not(.m-blobs) {
  position: relative;
  z-index: 1;
}
.m-blobs {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}
.m-blobs span {
  position: absolute;
  border-radius: 9999px;
  filter: blur(70px);
  animation: m-drift-a 16s ease-in-out infinite alternate;
}
.m-blobs span:nth-child(1) {
  width: 420px;
  height: 420px;
  top: -120px;
  left: -80px;
  background: rgba(244, 102, 0, 0.16);
}
.m-blobs span:nth-child(2) {
  width: 360px;
  height: 360px;
  bottom: -140px;
  right: 10%;
  background: rgba(39, 108, 0, 0.13);
  animation-name: m-drift-b;
  animation-duration: 19s;
}
.m-blobs span:nth-child(3) {
  width: 260px;
  height: 260px;
  top: 30%;
  left: 45%;
  background: rgba(255, 133, 51, 0.14);
  animation-name: m-drift-c;
  animation-duration: 22s;
}

/* ---------- Buttons: light sweep on hover ---------- */
.primary-gradient {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}
.primary-gradient::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(
    110deg,
    transparent 30%,
    rgba(255, 255, 255, 0.45) 50%,
    transparent 70%
  );
  translate: -120% 0;
  transition: translate 0.7s ease;
  pointer-events: none;
}
.primary-gradient:hover::after {
  translate: 120% 0;
}

/* ---------- Cards: spotlight that follows the cursor ---------- */
.m-spot {
  position: relative;
  isolation: isolate;
}
.m-spot::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(
    320px circle at var(--mx, 50%) var(--my, 50%),
    rgba(244, 102, 0, 0.09),
    transparent 70%
  );
  opacity: 0;
  transition: opacity 0.4s ease;
  pointer-events: none;
}
.m-spot:hover::before {
  opacity: 1;
}

/* ---------- Header, progress bar, back to top ---------- */
header.sticky {
  transition:
    box-shadow 0.4s ease,
    background-color 0.4s ease;
}
header.sticky.m-scrolled {
  box-shadow: 0 10px 30px -18px rgba(25, 28, 30, 0.35);
}
.m-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 60;
  background: linear-gradient(90deg, #f46600, #ff8533);
  transform-origin: left center;
  scale: 0 1;
  pointer-events: none;
}
.m-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 55;
  width: 48px;
  height: 48px;
  border-radius: 9999px;
  background: #fff;
  color: #191c1e;
  box-shadow: 0 10px 30px -10px rgba(25, 28, 30, 0.35);
  display: grid;
  place-items: center;
  opacity: 0;
  translate: 0 16px;
  pointer-events: none;
  transition:
    opacity 0.35s ease,
    translate 0.35s ease,
    color 0.2s ease;
}
.m-top.is-visible {
  opacity: 1;
  translate: none;
  pointer-events: auto;
}
.m-top:hover {
  color: #f46600;
}
.m-top svg {
  position: absolute;
  inset: 0;
  rotate: -90deg;
}
.m-top circle {
  fill: none;
  stroke-width: 3;
}
.m-top .m-top-track {
  stroke: rgba(25, 28, 30, 0.08);
}
.m-top .m-top-bar {
  stroke: #f46600;
  stroke-linecap: round;
}

/* ---------- Form fields ---------- */
@keyframes m-shake {
  20%,
  60% {
    translate: -6px 0;
  }
  40%,
  80% {
    translate: 6px 0;
  }
}
@keyframes m-pop {
  from {
    opacity: 0;
    scale: 0;
  }
  60% {
    scale: 1.4;
  }
}
@keyframes m-ripple {
  to {
    scale: 1;
    opacity: 0;
  }
}
.m-field {
  position: relative;
}
.m-field label {
  transition:
    color 0.3s ease,
    translate 0.3s ease;
}
.m-field:focus-within label {
  color: #f46600;
  translate: 4px 0;
}
.m-field label::after {
  content: "";
}
.m-field.is-valid label::after {
  content: "\2713";
  display: inline-block;
  margin-left: 6px;
  color: #276c00;
  font-size: 12px;
  animation: m-pop 0.45s cubic-bezier(0.3, 1.4, 0.5, 1) both;
}
.m-field textarea {
  display: block;
}
html .m-field input,
html .m-field textarea,
html .m-field select {
  transition:
    background-color 0.3s ease,
    box-shadow 0.3s ease,
    translate 0.3s ease;
}
html .m-field input:focus,
html .m-field textarea:focus,
html .m-field select:focus {
  background-color: #fff;
  box-shadow:
    0 0 0 4px rgba(244, 102, 0, 0.12),
    0 10px 24px -16px rgba(244, 102, 0, 0.6);
  translate: 0 -2px;
}
.m-field input::placeholder,
.m-field textarea::placeholder {
  transition: opacity 0.3s ease;
}
.m-field :focus::placeholder {
  opacity: 0.4;
}
/* Accent bar that grows from the centre along the bottom of the field. */
.m-field-bar {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 0;
  height: 2px;
  border-radius: 2px;
  background: #f46600;
  scale: 0 1;
  transition:
    scale 0.45s cubic-bezier(0.2, 0.7, 0.2, 1),
    background-color 0.3s ease;
  pointer-events: none;
}
.m-field:focus-within .m-field-bar {
  scale: 1 1;
}
.m-field.is-invalid {
  animation: m-shake 0.45s ease;
}
.m-field.is-invalid label {
  color: #dc2626;
}
.m-field.is-invalid .m-field-bar {
  scale: 1 1;
  background: #dc2626;
}
.m-ripple {
  position: absolute;
  z-index: -1;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.35);
  scale: 0;
  pointer-events: none;
  animation: m-ripple 0.7s ease-out forwards;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  .m-blobs,
  .m-progress {
    display: none;
  }
  .primary-gradient::after {
    display: none;
  }
  .m-field.is-invalid,
  .m-field.is-valid label::after {
    animation: none;
  }
  .m-field:focus-within label,
  html .m-field :focus {
    translate: none;
  }
}
