/* ==========================================================================
   motion-advanced.css  |  NEARLY Studio
   Additive layer. Load AFTER styles.css (and selected-concepts.css).
   Reuses the site's own tokens and class names (.button, .section-head).
   Does not redefine .reveal, .scroll-progress, the .tile spotlight or any
   page-load animation; those stay exactly as styles.css + script.js have them.
   ========================================================================== */

/* ---- Tokens --------------------------------------------------------------- */
:root {
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --dur-fast: 150ms;
  --dur-base: 250ms;
  --dur-slow: 500ms;

  /* Fallback first: a browser without linear() would otherwise drop the whole
     transition declaration that uses var(--bounce). */
  --bounce: var(--ease-out);
}

/* Damped spring (about 31% overshoot, three visible bounces) */
@supports (transition-timing-function: linear(0, 1)) {
  :root {
    --bounce: linear(
      0, 0.076 2.3%, 0.268 4.5%, 0.518 6.8%, 0.776 9.1%, 1.002 11.4%,
      1.171 13.6%, 1.272 15.9%, 1.309 18.2%, 1.291 20.5%, 1.235 22.7%, 1.159 25.0%,
      1.079 27.3%, 1.008 29.5%, 0.953 31.8%, 0.919 34.1%, 0.905 36.4%, 0.908 38.6%,
      0.924 40.9%, 0.947 43.2%, 0.972 45.5%, 0.995 47.7%, 1.013 50.0%, 1.024 52.3%,
      1.029 54.5%, 1.029 56.8%, 1.024 59.1%, 1.017 61.4%, 1.01 63.6%, 1.002 65.9%,
      0.997 68.2%, 0.993 70.5%, 0.991 72.7%, 0.991 75.0%, 0.992 77.3%, 0.994 79.5%,
      0.997 81.8%, 0.999 84.1%, 1.001 86.4%, 1.002 88.6%, 1.003 90.9%, 1.003 93.2%,
      1.002 95.5%, 1.002 97.7%, 1
    );
  }
}

/* ---- Content must stay visible when JavaScript is off --------------------- */
/* styles.css hides .reveal by default and only script.js shows it. */
@media (scripting: none) {
  .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* ---- Lively motion: bounce, 3D tilt, magnetic pull, parallax --------------- */
/* Everything lively lives inside no-preference. With "reduce motion" on, the
   site's own reduced-motion rules in styles.css apply untouched.
   Reveal bounce and the tilt/parallax values are driven by motion-advanced.js. */
@media (prefers-reduced-motion: no-preference) {
  /* Cards: bouncy lift plus a 3D tilt toward the pointer.
     .tile.reveal is listed as well: styles.css sets its own transition on
     .tile.reveal, which is more specific than .tile and silently dropped
     translate and scale from the list, so the lift used to snap. */
  .tile,
  .tile.reveal {
    transform-style: preserve-3d;
    /* overflow: clip still clips to the rounded corners but, unlike hidden,
       does not flatten preserve-3d, so the layered depth below is real.
       Browsers without clip keep hidden and just lose the depth. */
    overflow: hidden;
    overflow: clip;
    transition:
      opacity 0.65s,
      transform 700ms var(--bounce),
      translate 700ms var(--bounce),
      scale 700ms var(--bounce),
      box-shadow 0.45s,
      padding 0.3s,
      background 0.3s;
    transition-delay: var(--d, 0s);
  }

  /* Touch: tilt only while a finger is down (set by JS, cleared as soon as the
     browser starts scrolling). */
  .tile.is-touch-tilted {
    transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
    translate: 0 -6px;
    scale: 1.015;
    box-shadow: 0 20px 48px rgb(0 0 0 / 0.1);
  }

  .tile > h3,
  .tile > .number {
    transition: transform 300ms ease;
  }

  /* Specificity matches `.tile a { transition: letter-spacing }` in styles.css */
  .tile > a:not(.button) {
    transition:
      transform 300ms ease,
      letter-spacing 0.3s ease;
  }

  .tile.is-touch-tilted > h3 {
    transform: translateZ(16px);
  }

  .tile.is-touch-tilted > .number {
    transform: translateZ(10px);
  }

  .tile.is-touch-tilted > a:not(.button) {
    transform: translateZ(20px);
  }

  /* Buttons: bouncy hover, squashy press, magnetic pull */
  .button {
    translate: var(--mag-x, 0px) var(--mag-y, 0px);
    transition:
      background-color 0.2s ease,
      color 0.2s ease,
      box-shadow 0.25s ease,
      transform 650ms var(--bounce),
      translate 250ms var(--ease-out);
  }

  .button:hover {
    transform: translateY(-3px) scale(1.07);
  }

  .button--quiet:hover {
    transform: translateX(5px);
  }

  .button:active {
    transform: scale(0.9);
    transition-duration: 0.2s, 0.2s, 0.2s, 90ms, 250ms;
  }

  .button--quiet:active {
    transform: scale(0.96);
  }

  /* Hero visuals drift at a different speed from the page (--py set in JS).
     Uses the translate property, so it never fights the float animation on
     .mini-window or the fadeUp entrance. */
  .stage,
  .visual-card {
    translate: 0 var(--py, 0px);
  }

  /* The stage supplies perspective; motion-advanced.js applies the rotations
     directly to the browser, matching the original pointer-driven effect. */
  .browser {
    overflow: hidden;
    overflow: clip;
    transform-style: preserve-3d;
    transform: rotateX(var(--stage-rx, 0deg)) rotateY(var(--stage-ry, 0deg));
    transition: transform 380ms cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 380ms ease;
  }

  .browser::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    pointer-events: none;
    opacity: var(--stage-shine, 0);
    background: linear-gradient(135deg, rgb(255 255 255 / 0.45) 0%, transparent 65%);
    transition: opacity 0.3s ease;
    z-index: 5;
  }

  .demo-site {
    transform-style: preserve-3d;
  }

  .demo-copy {
    transform: translateZ(24px);
  }

  .demo-product {
    transform: translateZ(40px);
    box-shadow: 0 24px 50px rgb(97 123 154 / 0.35);
  }

  /* Price pop when the payment-plan switch changes the numbers */
  [data-plan-price],
  [data-plan-total] {
    display: inline-block;
  }

  .is-popping {
    animation: pop 700ms var(--bounce) backwards;
    animation-delay: var(--pop-delay, 0ms);
  }

  @keyframes pop {
    from {
      transform: scale(1.35);
      opacity: 0.2;
    }
  }
}

/* Mouse and trackpad only. On touch screens :hover sticks after a tap, which
   left cards stuck in their lifted state. */
@media (prefers-reduced-motion: no-preference) and (hover: hover) and (pointer: fine) {
  .tile:hover,
  .tile.reveal:hover {
    transform: perspective(900px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
    translate: 0 -12px;
    scale: 1.025;
    transition-duration: 0.65s, 140ms, 700ms, 700ms, 0.45s, 0.3s, 0.3s;
  }

  .tile:hover > h3 {
    transform: translateZ(16px);
  }

  .tile:hover > .number {
    transform: translateZ(10px);
  }

  /* Not .button: plan cards put a real button directly inside the tile and it
     keeps its own hover and press transforms. */
  .tile:hover > a:not(.button) {
    transform: translateZ(20px);
  }
}

/* Keep interaction colours, but remove button movement while motion is reduced.
   The base stylesheet also applies a hover transform outside this file. */
@media (prefers-reduced-motion: reduce) {
  .tile:hover,
  .tile.reveal:hover,
  .tile:hover > h3,
  .tile:hover > .number,
  .tile:hover > a:not(.button),
  .feature-list li:hover,
  .button:hover,
  .button:active,
  .button--quiet:hover,
  .button--quiet:active {
    transform: none;
    translate: none;
    scale: none;
  }

  .nav-links a:not(.button):hover::after,
  .brand:hover .brand-mark {
    transform: none;
  }

  .button:hover::before {
    transform: translateX(-120%);
  }
}

/* ---- Before / after comparison (illustrative, CSS-built, no photos) ------- */
.cmp {
  max-width: 1000px;
  margin: 0 auto;
}

.cmp__stage {
  --split: 50%;
  container-type: inline-size;
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
  user-select: none;
}

.cmp__layer {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}

/* The focused page sits on top and is clipped from the right. clip-path is
   compositor-friendly and avoids resizing anything while dragging. */
.cmp__layer--after {
  clip-path: inset(0 calc(100% - var(--split)) 0 0);
}

.cmp__tag {
  position: absolute;
  bottom: 3cqw;
  padding: 0.5em 0.9em;
  border-radius: 999px;
  font-size: max(11px, 1.3cqw);
  font-weight: 700;
  letter-spacing: 0.02em;
  z-index: 1;
}

@container (max-width: 520px) {
  .cmp__tag {
    padding: 0.4em 0.75em;
    font-size: 10px;
  }
}

.cmp__layer--before .cmp__tag {
  right: 3cqw;
  background: rgb(29 29 31 / 0.82);
  color: #fff;
}

.cmp__layer--after .cmp__tag {
  left: 3cqw;
  background: var(--blue);
  color: #fff;
}

/* Generic template mock: busy and unfocused on purpose */
.cmp__layer--before {
  background: #e9e9ee;
  color: #3a3a3c;
  font-family: Arial, Helvetica, sans-serif;
}

.cmp__bar {
  display: flex;
  justify-content: space-between;
  gap: 2cqw;
  padding: 2.2cqw 3cqw;
  background: #cfcfd6;
  font-size: max(8px, 1.1cqw);
}

.cmp__bar span {
  opacity: 0.8;
}

.cmp__banner {
  margin: 2cqw 3cqw 0;
  padding: 3cqw;
  background: #b7b7c0;
  font-size: max(11px, 2.6cqw);
  font-weight: 700;
  text-transform: uppercase;
  text-align: center;
}

.cmp__clutter {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.6cqw;
  margin: 2cqw 3cqw 0;
}

.cmp__clutter i {
  display: block;
  height: 8cqw;
  background: #d5d5dc;
  border: 1px solid #bdbdc6;
}

.cmp__btns {
  display: flex;
  justify-content: space-between;
  gap: 1.4cqw;
  margin: 2cqw 3cqw 0;
}

.cmp__btns b {
  padding: 0.9cqw 1.8cqw;
  background: #8e8e98;
  color: #fff;
  font-size: max(8px, 1.1cqw);
  font-weight: 400;
}

/* Focused page mock: one message, one next step */
.cmp__layer--after {
  justify-content: center;
  align-items: flex-start;
  padding: 0 6cqw;
  background: linear-gradient(120deg, #f9f9fb, #e9eef7);
  color: var(--ink);
}

.cmp__kicker {
  margin: 0 0 1.4cqw;
  font-size: max(8px, 1.1cqw);
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.cmp__headline {
  margin: 0;
  max-width: 8em;
  font: 800 min(5.2cqw, 56px) / 0.98 Manrope, sans-serif;
  letter-spacing: -0.07em;
}

.cmp__sub {
  margin: 1.6cqw 0 0;
  max-width: 36cqw;
  font-size: max(10px, 1.5cqw);
  color: var(--muted);
}

.cmp__cta {
  margin-top: 2.4cqw;
  padding: 1.1cqw 2.4cqw;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: max(9px, 1.3cqw);
  font-weight: 600;
}

/* Handle. Visual only; the invisible range input does the work. */
.cmp__handle {
  position: absolute;
  top: 0;
  bottom: 0;
  left: var(--split);
  width: 2px;
  margin-left: -1px;
  background: #fff;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.08);
  pointer-events: none;
  z-index: 2;
}

.cmp__knob {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.28);
  transform: translate(-50%, -50%);
}

.cmp__range {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: ew-resize;
  /* Let vertical swipes scroll the page; only horizontal drags move the slider. */
  touch-action: pan-y;
}

.cmp__range[hidden] {
  display: none;
}

/* The input is invisible, so show keyboard focus on the knob instead. */
.cmp__range:focus-visible ~ .cmp__handle .cmp__knob {
  outline: 3px solid #005fcc;
  outline-offset: 3px;
}

.cmp__note {
  margin: 14px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}


/* ---- Ambient hero canvas --------------------------------------------------- */
/* styles.css already gives .hero position: relative and isolation: isolate, so
   z-index -1 keeps the canvas behind the hero text and above the hero glow.
   The canvas stays within the hero to avoid introducing horizontal overflow. */
.hero-3d-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  opacity: 1;
}

/* Keep the ambient scene visible between the hero background and its content. */
.hero > :not(.hero-3d-canvas) {
  position: relative;
  z-index: 1;
}

/* styles.css staggers every direct child of .hero with fadeUp. */
.hero > .hero-3d-canvas {
  animation: none;
}

@media (max-width: 600px) {
  .hero {
    padding: 48px 0 30px;
  }

  .hero .eyebrow {
    margin-bottom: 14px;
  }

  .hero .intro {
    margin-bottom: 20px;
  }

  .hero .microcopy {
    margin-top: 14px;
  }

  .hero .actions {
    gap: 4px;
  }

  .hero .actions > .button {
    padding-inline: 14px;
    font-size: 13px;
    white-space: nowrap;
  }

  .hero .actions > .button--quiet {
    padding-inline: 4px;
  }

  .stage {
    margin-top: 10px;
    touch-action: pan-y;
  }

  .stage .browser {
    min-height: 0;
  }

  .stage .demo-site {
    min-height: 180px;
    padding: 16px 12px;
  }

  .stage .demo-product {
    height: 110px;
  }

  .hero ~ .section {
    padding-block: 48px;
  }

  .hero ~ .section .section-head {
    margin-bottom: 24px;
  }

  .hero ~ .section .section-head h2 {
    font-size: clamp(32px, 9vw, 42px);
  }

  .hero ~ .section .section-head > p:not(.eyebrow) {
    font-size: 15px;
  }

  .hero ~ .section:not(#services, #process) .section-head > p:not(.eyebrow) {
    display: none;
  }

  #services .grid-3,
  #process .grid-3 {
    gap: 10px;
  }

  #services .tile,
  #process .tile {
    display: grid;
    grid-template-columns: minmax(76px, 0.32fr) minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-items: start;
    gap: 4px 12px;
    padding: 16px;
  }

  #services .tile .number,
  #process .tile .number {
    grid-column: 1;
    grid-row: 1 / span 2;
    margin: 3px 0 0;
    font-size: 10px;
    line-height: 1.35;
  }

  #services .tile h3,
  #process .tile h3 {
    grid-column: 2;
    grid-row: 1;
    margin: 0;
  }

  #services .tile p,
  #process .tile p {
    grid-column: 2;
    grid-row: 2;
    margin: 0;
    font-size: 13px;
    line-height: 1.4;
  }

  #services .tile > a {
    grid-column: 2;
    margin: 8px 0 0;
    font-size: 13px;
  }

  #process .tile {
    grid-template-rows: auto auto;
  }

  .cta-band {
    padding: 26px;
  }
}
