/* ============================================================
   Motion layer. Every rule is gated on [data-motion], which the
   head script sets only when the visitor hasn't asked for reduced
   motion — so without JS, or with reduced motion, the page is the
   plain static site.
   ============================================================ */

/* ---------- scroll progress ---------- */

.scroll-progress {
  position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, var(--accent), #a970ff, #ff6fb5);
  transform: scaleX(0); transform-origin: left; pointer-events: none;
}
html:not([data-motion]) .scroll-progress { display: none; }

/* ---------- hero backdrop ---------- */

[data-motion] .hero { position: relative; overflow: hidden; isolation: isolate; }
.hero-canvas, .hero-aurora { display: none; }
[data-motion] .hero-canvas {
  display: block; position: absolute; inset: 0; width: 100%; height: 100%;
  z-index: -1; pointer-events: none;
}
[data-motion] .hero-aurora {
  display: block; position: absolute; inset: -20% -10%; z-index: -2; pointer-events: none;
  transform: translate3d(0, var(--hero-shift, 0px), 0);
}
.hero-aurora span {
  position: absolute; width: 42vmax; height: 42vmax; border-radius: 50%;
  filter: blur(70px); opacity: .28; will-change: transform;
}
.hero-aurora span:nth-child(1) { background: var(--accent); top: 5%; left: 55%; animation: drift-a 22s ease-in-out infinite alternate; }
.hero-aurora span:nth-child(2) { background: #a970ff; top: 35%; left: 10%; animation: drift-b 28s ease-in-out infinite alternate; }
.hero-aurora span:nth-child(3) { background: #ff6fb5; top: 55%; left: 60%; opacity: .16; animation: drift-c 25s ease-in-out infinite alternate; }
[data-theme="dark"] .hero-aurora span { opacity: .22; }
[data-theme="dark"] .hero-aurora span:nth-child(3) { opacity: .12; }

@keyframes drift-a { to { transform: translate(-18vmax, 12vmax) scale(1.2); } }
@keyframes drift-b { to { transform: translate(20vmax, -10vmax) scale(.85); } }
@keyframes drift-c { to { transform: translate(-12vmax, -16vmax) scale(1.15); } }

/* ---------- split headings ---------- */

.split .w  { display: inline-block; overflow: hidden; padding-bottom: .12em; margin-bottom: -.12em; vertical-align: top; }
.split .ch { display: inline-block; white-space: pre; }
[data-motion] .split.reveal { opacity: 1; transform: none; filter: none; }
[data-motion] .split .ch {
  transform: translateY(115%) rotate(10deg); opacity: 0;
  transition: transform .8s cubic-bezier(.2, .9, .25, 1.15), opacity .5s ease;
  transition-delay: calc(var(--c) * 28ms);
}
[data-motion] .visible .split .ch,
[data-motion] .split.visible .ch { transform: none; opacity: 1; }

/* hero name gets a slower, bigger entrance and a live gradient */
[data-motion] .hero h1 .ch {
  transition-duration: 1s, .6s;
  transition-delay: calc(150ms + var(--c) * 45ms);
  background: linear-gradient(100deg, var(--text) 30%, var(--accent) 50%, var(--text) 70%);
  background-size: 400% 100%; background-position: 100% 0;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: sheen 6s ease-in-out infinite;
  animation-delay: calc(1.6s + var(--c) * 60ms);
}
@keyframes sheen { 0%, 60% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* Once the entrance has played, letters respond to the pointer: they lift
   and swell as it passes, like a wave running through the name. */
[data-motion] .hero h1.settled .w { overflow: visible; }
[data-motion] .hero h1.settled .ch {
  transform: translateY(var(--lift, 0px)) scale(var(--grow, 1)) rotate(var(--tilt, 0deg));
  transition: transform .35s cubic-bezier(.2, .9, .3, 1.4); transition-delay: 0s;
  transform-origin: 50% 90%;
}

[data-motion] .hero .accent {
  background: linear-gradient(90deg, var(--accent), #a970ff, #ff6fb5, var(--accent));
  background-size: 300% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: flow 5s linear infinite;
}
@keyframes flow { to { background-position: 300% 0; } }

/* hero buttons and socials cascade in after the name */
[data-motion] .hero-text .btn-row > *,
[data-motion] .hero-text .socials > li {
  opacity: 0; transform: translateY(14px);
  transition: opacity .6s ease, transform .6s cubic-bezier(.2, .8, .2, 1);
}
[data-motion] .hero-text.visible .btn-row > *,
[data-motion] .hero-text.visible .socials > li { opacity: 1; transform: none; }
[data-motion] .hero-text.visible .btn-row > :nth-child(1) { transition-delay: .9s; }
[data-motion] .hero-text.visible .btn-row > :nth-child(2) { transition-delay: 1s; }
[data-motion] .hero-text.visible .socials > :nth-child(1) { transition-delay: 1.1s; }
[data-motion] .hero-text.visible .socials > :nth-child(2) { transition-delay: 1.17s; }
[data-motion] .hero-text.visible .socials > :nth-child(3) { transition-delay: 1.24s; }

/* ---------- reveal: add a focus-pull ---------- */

[data-motion] .reveal { filter: blur(8px); transition: opacity .8s ease, transform .8s cubic-bezier(.2, .8, .2, 1), filter .8s ease; }
[data-motion] .reveal.visible { filter: none; }

/* eyebrow draws a short rule in front of itself */
[data-motion] .eyebrow.reveal { display: flex; align-items: center; gap: 0; }
[data-motion] .eyebrow.reveal::before {
  content: ""; height: 2px; width: 0; background: var(--accent); border-radius: 2px;
  transition: width .7s cubic-bezier(.2, .8, .2, 1) .15s, margin .7s cubic-bezier(.2, .8, .2, 1) .15s;
}
[data-motion] .eyebrow.reveal.visible::before { width: 1.8rem; margin-right: .7rem; }

/* ---------- staggered children ---------- */

[data-motion] .tags li,
[data-motion] .bullets li {
  opacity: 0; transition: opacity .5s ease, transform .55s cubic-bezier(.2, .9, .3, 1.3), background-color .2s, border-color .2s, color .2s;
  transition-delay: calc(250ms + var(--i, 0) * 45ms);
}
[data-motion] .tags li { transform: translateY(10px) scale(.85); }
[data-motion] .bullets li { transform: translateX(-14px); }
[data-motion] .visible .tags li,
[data-motion] .visible .bullets li { opacity: 1; transform: none; }

[data-motion] .tags li:hover {
  border-color: var(--accent); color: var(--accent-text); background: var(--accent-soft);
  transform: translateY(-2px); transition-delay: 0s;
}

/* ---------- timeline draws as you scroll ---------- */

.timeline-progress { display: none; }
[data-motion] .timeline-progress {
  display: block; position: absolute; left: .42rem; top: .6rem; width: 2px;
  height: calc(100% - 1.2rem); transform-origin: top; transform: scaleY(var(--tl, 0));
  background: linear-gradient(var(--accent), #a970ff);
  box-shadow: 0 0 12px var(--accent);
}
[data-motion] .timeline-item::before { transition: background-color .4s ease, box-shadow .4s ease, transform .4s cubic-bezier(.2, .9, .3, 1.6); }
[data-motion] .timeline-item.lit::before {
  background: var(--accent); transform: scale(1.25);
  box-shadow: 0 0 0 6px var(--accent-soft), 0 0 18px var(--accent);
}
@media (max-width: 560px) { [data-motion] .timeline-progress { left: .3rem; } }

/* ---------- cards: 3D tilt + cursor spotlight ---------- */

[data-motion] .tilt { position: relative; transform-style: preserve-3d; will-change: transform; }
[data-motion] .tilt::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), var(--accent-soft), transparent 45%);
  opacity: 0; transition: opacity .3s ease;
}
[data-motion] .tilt.tilting::after { opacity: 1; }
[data-motion] .tilt.tilting { transition: transform .12s ease-out, box-shadow .22s ease, opacity .8s ease, filter .8s ease, border-color .22s ease; }
[data-motion] .tilt:not(.tilting) { transition: transform .6s cubic-bezier(.2, .8, .2, 1), box-shadow .22s ease, opacity .8s ease, filter .8s ease, border-color .22s ease; }
[data-theme="dark"] .tilt::after {
  background: radial-gradient(420px circle at var(--mx, 50%) var(--my, 50%), rgba(108, 155, 255, .16), transparent 45%);
}

/* gradient border that lights up under the cursor */
[data-motion] .tilt::before {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; padding: 1px; pointer-events: none;
  background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 50%), var(--accent), transparent 60%);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: 0; transition: opacity .3s ease; z-index: 1;
}
[data-motion] .tilt.tilting::before { opacity: 1; }

/* project images zoom inside their frame */
[data-motion] .project-card img { transition: transform .8s cubic-bezier(.2, .8, .2, 1); }
[data-motion] .project-card:hover img { transform: scale(1.06); }

/* ---------- buttons ---------- */

[data-motion] .btn { position: relative; overflow: hidden; }
[data-motion] .btn-primary::before {
  content: ""; position: absolute; top: 0; bottom: 0; left: -60%; width: 40%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .45), transparent);
  transform: skewX(-20deg); transition: left .7s ease;
}
[data-motion] .btn-primary:hover::before { left: 130%; }
[data-motion] .magnetic { transition: transform .35s cubic-bezier(.2, .8, .2, 1), background-color .2s, border-color .2s, box-shadow .2s, color .2s; }

/* ---------- about photo parallax ---------- */

[data-motion] .about-photo { overflow: hidden; border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }
[data-motion] .about-photo img {
  box-shadow: none; border-radius: 0;
  transform: scale(1.14) translate3d(0, var(--par, 0px), 0);
}

/* ---------- cursor follower (fine pointers only) ---------- */

.cursor-ring, .cursor-dot {
  position: fixed; top: 0; left: 0; z-index: 9999; pointer-events: none; border-radius: 50%;
  opacity: 0; transition: opacity .3s ease, width .3s ease, height .3s ease, margin .3s ease, background-color .3s ease, border-color .3s ease;
}
.cursor-ring {
  width: 36px; height: 36px; margin: -18px 0 0 -18px;
  border: 1.5px solid var(--accent);
}
.cursor-dot { width: 6px; height: 6px; margin: -3px 0 0 -3px; background: var(--accent); }
.cursor-on .cursor-ring, .cursor-on .cursor-dot { opacity: 1; }
.cursor-hover .cursor-ring {
  width: 64px; height: 64px; margin: -32px 0 0 -32px;
  background: var(--accent-soft); border-color: transparent;
}
.cursor-down .cursor-ring { width: 26px; height: 26px; margin: -13px 0 0 -13px; }

/* ---------- theme switch: circular wipe ---------- */

::view-transition-old(root),
::view-transition-new(root) { animation: none; mix-blend-mode: normal; }

@media print {
  .scroll-progress, .hero-canvas, .hero-aurora, .cursor-ring, .cursor-dot { display: none !important; }
}
