/* 3D hero canvas + motion helpers. Loaded after style.css. */

.hero-backdrop {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.hero-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  /* Fades out at the bottom so the content below stays readable */
  mask-image: linear-gradient(to bottom, #000 60%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, #000 60%, transparent 100%);
}

/* Cards keep their own hover styles; tilt only sets transform via JS */
.project-card,
.stat-card {
  transform-style: preserve-3d;
  transition: transform 0.25s ease-out, box-shadow 0.25s ease-out;
  will-change: transform;
}

/* Reading progress bar. Driven by the page's own scroll timeline where the browser has one;
   motion.js only feeds --scroll-progress where it doesn't. */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 100%;
  transform-origin: 0 50%;
  transform: scaleX(var(--scroll-progress, 0));
  background: linear-gradient(90deg, #7c5cff, #2dd4bf);
  z-index: 1000;
  pointer-events: none;
}
@media (prefers-reduced-motion: no-preference) {
  @supports (animation-timeline: scroll()) {
    @keyframes scroll-progress-grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
    .scroll-progress {
      animation: scroll-progress-grow auto linear;
      animation-timeline: scroll(root);
    }
  }
}

/* Entrance and scroll effects, all in CSS. Content is visible by default: nothing waits
   for a script to show it, so link previews, full-page captures and slow phones see the
   whole page. Motion is added on top only when the user hasn't asked for less of it. */
@media (prefers-reduced-motion: no-preference) {
  /* the hero rises in once, on load */
  @keyframes hero-rise { from { opacity: 0; translate: 0 var(--rise, 24px); } }
  .hero-eyebrow { animation: hero-rise 0.6s cubic-bezier(0.16, 1, 0.3, 1) both; --rise: 18px; }
  .hero-title { animation: hero-rise 0.9s 0.15s cubic-bezier(0.16, 1, 0.3, 1) both; --rise: 40px; }
  .hero-description { animation: hero-rise 0.7s 0.4s cubic-bezier(0.16, 1, 0.3, 1) both; }
  /* buttons and stat cards come in one after another (staggered by their position) */
  .hero-actions .btn { animation: hero-rise 0.5s 0.55s cubic-bezier(0.16, 1, 0.3, 1) both; --rise: 16px; }
  .stat-card { animation: hero-rise 0.6s 0.75s cubic-bezier(0.16, 1, 0.3, 1) both; --rise: 30px; }
  @supports (animation-delay: calc(sibling-index() * 0.1s)) {
    .hero-actions .btn { animation-delay: calc(0.47s + sibling-index() * 0.08s); }
    .stat-card { animation-delay: calc(0.67s + sibling-index() * 0.08s); }
  }
  @supports not (animation-delay: calc(sibling-index() * 0.1s)) {
    .hero-actions .btn:nth-child(2) { animation-delay: 0.63s; }
    .hero-actions .btn:nth-child(3) { animation-delay: 0.71s; }
    .hero-actions .btn:nth-child(4) { animation-delay: 0.79s; }
    .stat-card:nth-child(2) { animation-delay: 0.83s; }
    .stat-card:nth-child(3) { animation-delay: 0.91s; }
    .stat-card:nth-child(4) { animation-delay: 0.99s; }
  }

  /* sections and cards fade up as they scroll into view, tied to the scroll itself */
  @supports ((animation-timeline: view()) and (animation-range: entry)) {
    @keyframes scroll-reveal { from { opacity: 0; translate: 0 36px; } }
    @keyframes heading-sweep { from { opacity: 0; translate: -28px 0; } }
    /* only when the page really scrolls (motion.js adds .can-reveal): on a screen taller than
       the page, like a crawler's render, a view timeline never moves and would stay faded */
    .can-reveal :is(.projects-grid > *, .skill-group-card, .timeline-item, .edu-card, .contact-card) {
      animation: scroll-reveal linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 55%;
    }
    .can-reveal .section-heading {
      animation: heading-sweep linear both;
      animation-timeline: view();
      animation-range: entry 0% entry 70%;
    }
    /* the 3D backdrop drifts slower than the page: depth on scroll */
    @keyframes hero-parallax { to { translate: 0 25%; } }
    .hero-canvas {
      animation: hero-parallax linear both;
      animation-timeline: scroll(root);
      animation-range: 0 100vh;
    }
  }
}

@media (prefers-reduced-motion: reduce) {
  .hero-canvas { display: none; }
  .project-card, .stat-card { transition: none; }
}
