/* Subtle motion system — added without changing readable colors or copy.
   All decoration is disabled for prefers-reduced-motion users.
   Transform/opacity animations avoid expensive layout thrashing. */

/* A slender scroll indicator emphasizes progress without taking space. */
.scroll-progress {
  position: fixed;
  z-index: 75;
  inset: 0 0 auto;
  height: 3px;
  pointer-events: none;
  background: linear-gradient(90deg, #7fdcc5, #9cc9f0 57%, #a99be9);
  transform: scaleX(var(--scroll-progress, 0));
  transform-origin: left center;
  box-shadow: 0 0 11px rgba(119, 218, 194, .36);
}
:root[data-theme="light"] .scroll-progress {
  background: linear-gradient(90deg, #127f66, #3473b5 58%, #7165b8);
  box-shadow: 0 0 9px rgba(19, 130, 106, .22);
}

/* Highlight the currently hovered navigation link, not the full header. */
.desktop-nav a { position: relative; }
.desktop-nav a::after {
  content: "";
  position: absolute;
  bottom: 7px;
  left: 0;
  width: 100%;
  height: 2px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--mint), var(--violet));
  transform: scaleX(0);
  transform-origin: left;
  opacity: .9;
}

/* A little tactile feedback for links, buttons and filter chips. */
.button, .nav-cta, .project-open { overflow: hidden; }
.button .icon, .nav-cta .icon, .project-open .icon, .back-top,
.hero-bottom a span { transition: transform .32s cubic-bezier(.2,.8,.2,1); }
.button:hover .icon, .nav-cta:hover .icon, .project-open:hover .icon { transform: translate(3px,-2px); }
.button:active, .filter:active { transform: scale(.985); }
.back-top:hover { transform: translateY(-3px); }

/* The project spotlight sits BEHIND the contents. It does not alter type color. */
.project-card { position: relative; isolation: isolate; }
.project-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(430px circle at var(--spot-x,50%) var(--spot-y,0px), rgba(122,226,199,.10), transparent 65%);
  transition: opacity .4s ease;
}
:root[data-theme="light"] .project-card::before {
  background: radial-gradient(430px circle at var(--spot-x,50%) var(--spot-y,0px), rgba(19,126,108,.075), transparent 65%);
}
.project-card > .project-visual, .project-card > .project-body { position: relative; z-index: 1; }
.project-card:focus-within { border-color: #6dafa2; }

/* Tiny interaction moments inside the illustrative previews. */
.workflow-node, .query-stage, .chat-answer, .chat-symbol,
.mini-chart span, .stage-indicator, .branch { transition: transform .55s cubic-bezier(.2,.8,.2,1), box-shadow .45s ease, border-color .4s ease; }
.project-card:hover .workflow-node.node-active,
.project-card:focus-within .workflow-node.node-active { transform: translateY(-4px); box-shadow: 0 8px 22px rgba(112,226,185,.13); }
.project-card:hover .query-stage-primary,
.project-card:focus-within .query-stage-primary { transform: translateY(-4px); box-shadow: 0 8px 26px rgba(60,190,169,.15); }
.project-card:hover .chat-answer,
.project-card:focus-within .chat-answer { transform: translateY(-4px); }
.project-card:hover .chat-symbol,
.project-card:focus-within .chat-symbol { transform: rotate(-8deg) scale(1.09); }
.project-card:hover .mini-chart span,
.project-card:focus-within .mini-chart span { transform: scaleY(1.055); }
.mini-chart span { transform-origin: bottom center; }

/* A calm theme change: emphasis on surfaces, NOT flashing or changing text weights. */
:root.theme-changing body,
:root.theme-changing .site-header,
:root.theme-changing .project-card,
:root.theme-changing .expertise-card,
:root.theme-changing .about-panel,
:root.theme-changing .contact-card,
:root.theme-changing .case-dialog,
:root.theme-changing .filters {
  transition: background-color .38s ease, color .38s ease, border-color .38s ease, box-shadow .38s ease;
}

@media (prefers-reduced-motion: no-preference) {
  /* Built-in on-scroll reveal uses one observer and never hides when JS is off. */
  .js.motion-ready .reveal {
    opacity: 0;
    transform: translate3d(0,25px,0);
    transition: opacity .74s ease, transform .87s cubic-bezier(.16,1,.3,1);
  }
  .js.motion-ready .reveal.visible { opacity: 1; transform: translate3d(0,0,0); }
  .js.motion-ready .project-card.reveal.visible:hover { transform: translateY(-6px); transition-delay: 0s; }
  .js.motion-ready .project-card.reveal.visible:focus-within { transform: translateY(-3px); transition-delay: 0s; }
  .js.motion-ready .project-grid .reveal:nth-child(2),
  .js.motion-ready .expertise-grid .reveal:nth-child(2),
  .js.motion-ready .impact-grid .reveal:nth-child(2) { transition-delay: .08s; }
  .js.motion-ready .project-grid .reveal:nth-child(3),
  .js.motion-ready .expertise-grid .reveal:nth-child(3),
  .js.motion-ready .impact-grid .reveal:nth-child(3) { transition-delay: .15s; }
  .js.motion-ready .project-grid .reveal:nth-child(4),
  .js.motion-ready .impact-grid .reveal:nth-child(4) { transition-delay: .22s; }

  /* The first fold: an editorial entrance, then everything settles down. */
  .motion-ready .hero-eyebrow { animation: motion-rise .68s .07s both cubic-bezier(.16,1,.3,1); }
  .motion-ready .hero-copy h1 { animation: motion-rise .86s .17s both cubic-bezier(.16,1,.3,1); }
  .motion-ready .hero-intro { animation: motion-rise .75s .28s both cubic-bezier(.16,1,.3,1); }
  .motion-ready .hero-detail { animation: motion-rise .75s .38s both cubic-bezier(.16,1,.3,1); }
  .motion-ready .hero-actions { animation: motion-rise .75s .48s both cubic-bezier(.16,1,.3,1); }
  .motion-ready .hero-context { animation: motion-rise .7s .59s both cubic-bezier(.16,1,.3,1); }
  .motion-ready .hero-visual { animation: motion-hero-enter 1.1s .28s both cubic-bezier(.16,1,.3,1); }
  .motion-ready .hero-bottom { animation: motion-rise .7s .83s both ease; }
  @keyframes motion-rise { from { opacity: 0; transform: translate3d(0,19px,0); } to { opacity: 1; transform: translate3d(0,0,0); } }
  @keyframes motion-hero-enter { from { opacity: 0; transform: translate3d(0,21px,0) scale(.975); } to { opacity: 1; transform: translate3d(0,0,0) scale(1); } }

  /* Minimal ambient movement: the finance schematic feels active, not busy. */
  .hero-glow { animation: motion-ambient 12s ease-in-out infinite alternate; }
  .visual-orbit.orbit-one { animation: motion-halo 12s ease-in-out infinite alternate; }
  .visual-orbit.orbit-two { animation: motion-orbit-spin 84s linear infinite; }
  .core-ring.ring-one { animation: motion-ring-one 28s linear infinite; }
  .core-ring.ring-two { animation: motion-ring-two 34s linear infinite reverse; }
  .floating-proof { animation: motion-bob 7s ease-in-out infinite; }
  .stage-indicator, .status-dot { animation: motion-status 3.6s ease-in-out infinite; }
  .connector-bottom span { animation-delay: 1.15s; }
  .gradient-text { background-size: 170% 100%; animation: motion-gradient 15s ease-in-out infinite alternate; }
  .hero-bottom a span { animation: motion-arrow 3s ease-in-out infinite; }
  @keyframes motion-ambient { from { opacity: .65; transform: scale(1); } to { opacity: 1; transform: scale(1.08); } }
  @keyframes motion-halo { from { opacity: .55; transform: scale(.99); } to { opacity: 1; transform: scale(1.025); } }
  @keyframes motion-orbit-spin { to { transform: rotate(360deg); } }
  @keyframes motion-ring-one { to { transform: rotate(360deg); } }
  @keyframes motion-ring-two { from { transform: rotate(-28deg); } to { transform: rotate(332deg); } }
  @keyframes motion-bob { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-6px) rotate(-1deg); } }
  @keyframes motion-status { 0%,100% { box-shadow: 0 0 0 0 rgba(138,229,205,0), 0 0 10px rgba(138,229,205,.24); } 50% { box-shadow: 0 0 0 4px rgba(138,229,205,.08), 0 0 13px rgba(138,229,205,.33); } }
  @keyframes motion-gradient { from { background-position: 0% 50%; } to { background-position: 80% 50%; } }
  @keyframes motion-arrow { 0%,85%,100% { transform: translateY(0); } 91% { transform: translateY(4px); } }

  /* The finance illustrations tell their story in a very small entrance sequence. */
  .project-card.visible .workflow-node.node-start { animation: motion-preview-in .5s .10s backwards ease-out; }
  .project-card.visible .workflow-node.node-active { animation: motion-preview-in .5s .21s backwards ease-out; }
  .project-card.visible .workflow-node.node-end { animation: motion-preview-in .5s .32s backwards ease-out; }
  .project-card.visible .query-stage:nth-of-type(1) { animation: motion-preview-in .5s .10s backwards ease-out; }
  .project-card.visible .query-stage:nth-of-type(2) { animation: motion-preview-in .5s .23s backwards ease-out; }
  .project-card.visible .query-stage:nth-of-type(3) { animation: motion-preview-in .5s .36s backwards ease-out; }
  .project-card.visible .chat-question { animation: motion-preview-in .55s .12s backwards ease-out; }
  .project-card.visible .chat-answer { animation: motion-preview-in .55s .27s backwards ease-out; }
  .project-card.visible .mini-chart span { animation: motion-chart-grow .75s backwards cubic-bezier(.16,1,.3,1); transform-origin: bottom center; }
  .project-card.visible .mini-chart span:nth-child(1) { animation-delay: .05s; }
  .project-card.visible .mini-chart span:nth-child(2) { animation-delay: .10s; }
  .project-card.visible .mini-chart span:nth-child(3) { animation-delay: .15s; }
  .project-card.visible .mini-chart span:nth-child(4) { animation-delay: .20s; }
  .project-card.visible .mini-chart span:nth-child(5) { animation-delay: .25s; }
  .project-card.visible .mini-chart span:nth-child(6) { animation-delay: .30s; }
  .project-card.visible .mini-chart span:nth-child(7) { animation-delay: .35s; }
  .project-card.visible .mini-chart span:nth-child(8) { animation-delay: .40s; }
  @keyframes motion-preview-in { from { opacity: .55; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
  @keyframes motion-chart-grow { from { transform: scaleY(.4); opacity:.7; } to { transform: scaleY(1); opacity:1; } }
  .project-card.filter-animating { animation: motion-filter-in .44s cubic-bezier(.16,1,.3,1) both; }
  @keyframes motion-filter-in { from { opacity: .62; translate: 0 9px; } to { opacity: 1; translate: 0 0; } }

  /* Case studies, mobile nav and the timeline respond with gentle confirmation. */
  .case-dialog[open] { animation: motion-dialog-in .32s cubic-bezier(.16,1,.3,1) both; }
  .case-dialog[open]::backdrop { animation: motion-backdrop-in .32s ease both; }
  @keyframes motion-dialog-in { from { opacity: 0; transform: translateY(14px) scale(.982); } to { opacity: 1; transform: translateY(0) scale(1); } }
  @keyframes motion-backdrop-in { from { opacity:0; } to { opacity:1; } }
  .mobile-nav:not([hidden]) { animation: motion-nav-in .32s cubic-bezier(.16,1,.3,1) both; }
  @keyframes motion-nav-in { from { opacity:0; transform: translateY(-7px); } to { opacity:1; transform: translateY(0); } }
  .timeline-item.visible .timeline-dot.current { animation: motion-timeline .85s .2s backwards ease-out; }
  @keyframes motion-timeline { 0% { box-shadow: 0 0 0 0 rgba(132,226,199,.32); } 100% { box-shadow: 0 0 0 10px rgba(132,226,199,0); } }

  .desktop-nav a::after { transition: transform .25s cubic-bezier(.2,.8,.2,1); }
  .desktop-nav a:hover::after,
  .desktop-nav a[aria-current="location"]::after,
  .desktop-nav a:focus-visible::after { transform: scaleX(1); }

  @media (hover: hover) and (pointer:fine) {
    .project-card:hover::before, .project-card:focus-within::before { opacity: 1; }
    .project-card:hover { box-shadow: 0 22px 60px rgba(0,0,0,.18); }
    :root[data-theme="light"] .project-card:hover { box-shadow: 0 20px 52px rgba(32,65,90,.12); }
  }
  @media (hover:hover) and (pointer:fine) {
    .hero-visual .lab-card {
      --hero-rx: 0deg;
      --hero-ry: 0deg;
      transform: perspective(1800px) rotateX(var(--hero-rx)) rotateY(var(--hero-ry));
      transition: transform .52s cubic-bezier(.16,1,.3,1), box-shadow .4s ease;
      will-change: transform;
    }
    .hero-visual .lab-card.is-tilting {
      transition: transform .13s ease-out, box-shadow .4s ease;
    }
    .hero-visual .lab-card:hover { box-shadow: 0 28px 82px rgba(0,0,0,.27), 0 0 65px rgba(132,194,190,.06); }
  }
}

/* On touchscreens, interaction remains immediate and nothing shifts under a tap. */
@media (hover:none), (pointer:coarse) {
  .project-card::before { display:none; }
  .project-card:active { transform:none; }
}
@media (prefers-reduced-motion:reduce) {
  .scroll-progress { display: none; }
  .project-card::before { display:none; }
  .js .reveal, .js .reveal.visible { opacity: 1 !important; transform:none !important; }
  .floating-proof, .core-ring, .visual-orbit, .stage-indicator, .status-dot,
  .gradient-text, .hero-glow { animation: none !important; }
}
@media print {
  .scroll-progress { display:none !important; }
}
