/* ==========================================================================
   Motion layer — Jaydeep Gadhiya portfolio
   --------------------------------------------------------------------------
   Everything here is additive. Delete this file and motion.js and the site
   still works exactly as before; nothing in the base stylesheet depends on it.

   Costly effects (cursor, magnetic buttons, smooth scroll, tilt) are gated to
   pointer:fine so phones keep native scrolling and never pay for them. The
   whole layer stands down under prefers-reduced-motion.
   ========================================================================== */

/* ==========================================================================
   1. Intro sequence
   ========================================================================== */

/* Set by the inline head script, cleared by motion.js — or by its own failsafe
   timer. It only locks scrolling; the page itself is never hidden.
   An earlier version faded <main> from opacity 0, which meant the content was
   only visible once a CSS transition had finished. Anywhere that transition
   does not run, the page stayed blank. The intro is a full-screen overlay, so
   it already hides the page while it plays — nothing underneath needs to. */
html.is-loading, html.is-loading body { overflow: hidden; }

.intro {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  background: var(--bg);
  transition: opacity .5s ease, visibility .5s;
}
.intro[hidden] { display: none; }
.intro.is-done {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* The curtain wipes upward off the top edge as the page is handed over. */
.intro-curtain {
  position: absolute;
  inset: 0;
  background: var(--bg-soft);
  transform-origin: top;
  transform: scaleY(1);
  transition: transform .85s cubic-bezier(.76, 0, .24, 1);
}
.intro.is-lifting .intro-curtain { transform: scaleY(0); }

.intro-inner {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 1.1rem;
  padding: 0 clamp(1.1rem, 4vw, 2.2rem);
}

.intro-name {
  font-size: clamp(1.6rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: -.03em;
  background: var(--grad);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

.intro-count {
  font-family: var(--mono);
  font-size: clamp(.95rem, 2.4vw, 1.3rem);
  font-variant-numeric: tabular-nums;
  color: var(--text-faint);
}

.intro-bar {
  position: absolute;
  left: clamp(1.1rem, 4vw, 2.2rem);
  right: clamp(1.1rem, 4vw, 2.2rem);
  bottom: clamp(2rem, 6vh, 4rem);
  height: 2px;
  background: var(--border);
  overflow: hidden;
}
.intro-bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--grad);
  transition: width .18s linear;
}

/* ==========================================================================
   2. Custom cursor
   ========================================================================== */

.cursor,
.cursor-ring {
  position: fixed;
  top: 0; left: 0;
  z-index: 400;
  pointer-events: none;
  border-radius: 50%;
  will-change: transform;
  opacity: 0;
  transition: opacity .3s ease;
}
.cursor-active .cursor,
.cursor-active .cursor-ring { opacity: 1; }

.cursor {
  width: 7px; height: 7px;
  margin: -3.5px 0 0 -3.5px;
  background: var(--accent);
}

.cursor-ring {
  width: 34px; height: 34px;
  margin: -17px 0 0 -17px;
  border: 1px solid var(--border-strong);
  transition: opacity .3s ease, width .3s cubic-bezier(.22,.8,.3,1),
              height .3s cubic-bezier(.22,.8,.3,1), margin .3s cubic-bezier(.22,.8,.3,1),
              background-color .3s ease, border-color .3s ease;
}

/* over a link or control the ring swells and fills faintly */
.cursor-ring.is-hot {
  width: 56px; height: 56px;
  margin: -28px 0 0 -28px;
  background: var(--accent-soft);
  border-color: transparent;
}
/* over something with a cursor label the ring becomes the label's backdrop */
.cursor-ring.is-label {
  width: 74px; height: 74px;
  margin: -37px 0 0 -37px;
  background: var(--accent);
  border-color: transparent;
}

.cursor-text {
  position: fixed;
  top: 0; left: 0;
  z-index: 401;
  pointer-events: none;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #fff;
  opacity: 0;
  transform: translate(-50%, -50%) scale(.7);
  transition: opacity .25s ease, transform .25s cubic-bezier(.22,.8,.3,1);
  will-change: transform;
}
.cursor-text.is-on { opacity: 1; }

/* the real pointer is hidden only once the custom one is actually running */
.cursor-active,
.cursor-active a,
.cursor-active button,
.cursor-active .card { cursor: none; }

/* ==========================================================================
   3. Split-text reveals
   ========================================================================== */

/* Lines are built at runtime from the existing text, so the markup a crawler
   sees is unchanged. Each line rides up out of its own clipping mask. */
.split-word {
  display: inline-block;
  overflow: hidden;
  vertical-align: top;
  /* overflow:hidden would shear descenders off g, y and p, so pad the box and
     pull the same amount back off the layout. */
  padding-bottom: .14em;
  margin-bottom: -.14em;
}
.split-word > span {
  display: inline-block;
  transform: translateY(110%);
  transition: transform .9s cubic-bezier(.22, .9, .25, 1);
}
.is-in .split-word > span { transform: translateY(0); }

/* ==========================================================================
   4. Scroll-driven reveals for media and cards
   ========================================================================== */

.mask-reveal {
  clip-path: inset(0 0 100% 0);
  transition: clip-path 1.05s cubic-bezier(.22, .9, .25, 1);
}
.mask-reveal.is-in { clip-path: inset(0 0 0% 0); }

/* the image inside drifts up behind the mask for a touch of depth */
.mask-reveal img {
  transform: scale(1.12);
  transition: transform 1.4s cubic-bezier(.22, .9, .25, 1);
}
.mask-reveal.is-in img { transform: scale(1); }

/* ==========================================================================
   5. Parallax and scroll skew
   ========================================================================== */

/* Parallax and tilt both want to move the same elements. Rather than letting
   them overwrite each other's inline transform every frame, each writes its
   own custom property and CSS composes the single resulting transform. */
.mx-transform {
  transform:
    translate3d(0, var(--mt-y, 0px), 0)
    perspective(900px)
    rotateX(var(--mt-rx, 0deg))
    rotateY(var(--mt-ry, 0deg));
  will-change: transform;
}

/* A whole-page skew driven by scroll velocity. The value is written by
   motion.js; 0 means standing still, so this costs nothing at rest. */
.skew-wrap { will-change: transform; }

/* ==========================================================================
   6. Magnetic controls
   ========================================================================== */

/* Only the wrapper moves. An earlier version also forced `display:inline-flex`
   on every child here, which outranked `.ico-sun { display: none }` and left
   both theme icons showing at once. */
.magnetic { will-change: transform; }

/* ==========================================================================
   7. Film grain
   ========================================================================== */

.grain {
  position: fixed;
  /* The keyframes shift this by at most 6%, so a small bleed is all that is
     needed. -120% made the layer 340% of the viewport in each direction and
     repainted all of it several times a second for nothing. */
  inset: -12%;
  z-index: 250;
  pointer-events: none;
  opacity: .055;
  background-image: var(--grain-src);
  background-size: 180px 180px;
  animation: grain-shift 1.2s steps(6) infinite;
}
[data-theme="light"] .grain { opacity: .04; }

@keyframes grain-shift {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-6%, 3%); }
  40%  { transform: translate(4%, -5%); }
  60%  { transform: translate(-3%, 6%); }
  80%  { transform: translate(5%, 2%); }
  100% { transform: translate(0, 0); }
}

/* ==========================================================================
   8. Hover tilt on cards
   ========================================================================== */

.tilt { transition: transform .4s cubic-bezier(.22,.8,.3,1); }

/* ==========================================================================
   9. Gates — touch, no-hover, and reduced motion
   ========================================================================== */

/* Nothing in the cursor or magnet group should exist on touch devices. */
@media (hover: none), (pointer: coarse) {
  .cursor, .cursor-ring, .cursor-text { display: none !important; }
  .magnetic { transform: none !important; }
  .mx-transform { --mt-rx: 0deg; --mt-ry: 0deg; }
}

@media (prefers-reduced-motion: reduce) {
  .intro { display: none !important; }

  .split-line > span { transform: none !important; transition: none !important; }
  .mask-reveal { clip-path: none !important; transition: none !important; }
  .mask-reveal img { transform: none !important; transition: none !important; }

  .mx-transform { transform: none !important; }
  .skew-wrap { transform: none !important; }
  .magnetic { transform: none !important; }
  .tilt { transform: none !important; }

  .grain { display: none !important; }
  .cursor, .cursor-ring, .cursor-text { display: none !important; }
}

/* ==========================================================================
   11. Intro: name arriving letter by letter, at speed
   --------------------------------------------------------------------------
   Each letter is thrown in from the left, skewed and motion-blurred, then
   decelerates hard into place. Light streaks run behind it, so the name
   arrives rather than simply fading up.
   ========================================================================== */

.intro-letter {
  display: inline-block;
  /* Letters are separate boxes, so a single gradient on the parent would be
     clipped per letter. motion.js sizes and offsets each one so the sweep
     still reads as one continuous gradient across the whole name. */
  background-image: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;

  opacity: 0;
  transform: translate3d(-220px, 0, 0) skewX(-22deg) scaleX(1.6);
  filter: blur(16px);
  transition:
    opacity .34s ease,
    transform .72s cubic-bezier(.11, .87, .18, 1),
    filter .34s ease;
}
.intro.is-go .intro-letter {
  opacity: 1;
  transform: none;
  filter: blur(0);
}

/* the gap between first and last name still needs to occupy space */
.intro-letter.is-space { width: .32em; }

.intro-streaks {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.streak {
  position: absolute;
  left: -40%;
  top: var(--t, 50%);
  width: var(--w, 26%);
  height: 1px;
  border-radius: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0;
  animation: streak-run var(--v, 2.4s) linear var(--d, 0s) infinite;
}
.streak.is-warm { background: linear-gradient(90deg, transparent, var(--accent-2), transparent); }

@keyframes streak-run {
  0%   { transform: translate3d(0, 0, 0) scaleX(.4); opacity: 0; }
  10%  { opacity: .85; }
  85%  { opacity: .5; }
  100% { transform: translate3d(520%, 0, 0) scaleX(1); opacity: 0; }
}

/* ==========================================================================
   12. Living background
   The blobs drift and breathe on their own. They are deliberately left out of
   the parallax list in motion.js — a scroll-driven transform and a keyframe
   transform cannot both own the same property.
   ========================================================================== */

.blob-1 { animation: drift-a 26s ease-in-out infinite alternate; }
.blob-2 { animation: drift-b 31s ease-in-out infinite alternate; }

@keyframes drift-a {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to   { transform: translate3d(-4.5rem, 3.5rem, 0) scale(1.14); }
}
@keyframes drift-b {
  from { transform: translate3d(0, 0, 0) scale(1.06); }
  to   { transform: translate3d(4rem, -3rem, 0) scale(.94); }
}

/* a slow pulse across the grid so the backdrop is never completely still */
.grid-overlay { animation: grid-breathe 14s ease-in-out infinite; }
@keyframes grid-breathe {
  0%, 100% { opacity: .55; }
  50%      { opacity: .3; }
}

/* ambient streaks drifting across the page behind everything */
.bg-streak {
  position: absolute;
  left: -30%;
  top: var(--t, 30%);
  width: var(--w, 22%);
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0;
  animation: bg-streak-run var(--v, 14s) linear var(--d, 0s) infinite;
}
@keyframes bg-streak-run {
  0%   { transform: translate3d(0, 0, 0); opacity: 0; }
  12%  { opacity: .3; }
  80%  { opacity: .18; }
  100% { transform: translate3d(620%, 0, 0); opacity: 0; }
}

/* ==========================================================================
   13. Portrait
   ========================================================================== */

/* the top hairline becomes a light travelling along the edge */
.portrait::before {
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent-2), var(--accent-3), transparent);
  background-size: 220% 100%;
  animation: edge-run 5.5s linear infinite;
}
@keyframes edge-run {
  from { background-position: 220% 0; }
  to   { background-position: -220% 0; }
}

/* a slow drift across the photo, started only once the mask has finished
   wiping it in so the two do not fight over `transform` */
.portrait.is-in img {
  animation: portrait-drift 20s ease-in-out 1.5s infinite alternate;
}
@keyframes portrait-drift {
  from { transform: scale(1) translate3d(0, 0, 0); }
  to   { transform: scale(1.07) translate3d(-1.2%, -1.6%, 0); }
}

/* periodic sheen sweeping across the glass */
.portrait-shine {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(112deg, transparent 42%, rgba(255, 255, 255, .17) 50%, transparent 58%);
  background-size: 260% 100%;
  background-repeat: no-repeat;
  animation: portrait-sheen 8s ease-in-out 2s infinite;
}
@keyframes portrait-sheen {
  0%, 62% { background-position: 170% 0; }
  100%    { background-position: -70% 0; }
}

@media (prefers-reduced-motion: reduce) {
  .blob-1, .blob-2, .grid-overlay,
  .bg-streak, .streak,
  .portrait::before, .portrait.is-in img, .portrait-shine {
    animation: none !important;
  }
  .bg-streak, .streak, .portrait-shine { display: none !important; }
  .intro-letter { opacity: 1 !important; transform: none !important; filter: none !important; }
}

/* ==========================================================================
   14. Developer backdrop
   --------------------------------------------------------------------------
   The ambient layer now echoes the work rather than decorating around it:

     · a dependency graph with data flowing along its edges  (laravel-xray)
     · a request-profiler waterfall filling bar by bar       (time-machine)
     · a scanner sweeping across the page                    (guarddog)
     · drifting PHP syntax

   Same smoothness rules as before: transform and opacity only, linear timing
   for anything that travels, and every loop's first and last keyframe match
   so repeats never jump. Tune the whole layer with --code-ink.
   ========================================================================== */

:root { --code-ink: .15; }
[data-theme="light"] { --code-ink: .11; }

.codefield {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

/* ---------- dependency graph ---------- */
.depgraph {
  position: absolute;
  top: var(--t, 10%);
  left: var(--l, 5%);
  width: var(--w, 230px);
  color: var(--accent);
  opacity: var(--code-ink);
}
.depgraph.is-warm { color: var(--accent-2); }
.depgraph svg { display: block; width: 100%; height: auto; fill: none; stroke: none; }

.depgraph .edge {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.3;
  opacity: .5;
  /* 5 + 9 = 14, so shifting by exactly 14 restarts identically — no jump */
  stroke-dasharray: 5 9;
  animation: edge-flow var(--v, 2.2s) linear infinite;
}
@keyframes edge-flow {
  from { stroke-dashoffset: 0; }
  to   { stroke-dashoffset: -14; }
}

.depgraph .node {
  fill: currentColor;
  stroke: none;
  animation: node-pulse 3.4s ease-in-out infinite;
}
@keyframes node-pulse {
  0%, 100% { opacity: .45; }
  50%      { opacity: 1; }
}

/* ---------- request profiler waterfall ---------- */
.waterfall {
  position: absolute;
  top: var(--t, 30%);
  left: var(--l, 70%);
  width: var(--w, 210px);
  display: flex;
  flex-direction: column;
  gap: 7px;
  opacity: var(--code-ink);
}
.wf-bar {
  height: 5px;
  width: var(--len, 70%);
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transform: scaleX(0);
  transform-origin: left center;
  will-change: transform;
  animation: wf-fill var(--v, 6s) cubic-bezier(.3, .8, .4, 1) var(--d, 0s) infinite;
}
/* grows, holds while the rest of the trace fills, then clears for the next run */
@keyframes wf-fill {
  0%        { transform: scaleX(0); opacity: 0; }
  8%        { opacity: 1; }
  38%, 86%  { transform: scaleX(1); opacity: 1; }
  100%      { transform: scaleX(1); opacity: 0; }
}

/* ---------- scanner sweep ---------- */
.scan {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  /* wide and faint, so it reads as a pass of light rather than a bright bar */
  width: 300px;
  background: linear-gradient(90deg,
    transparent, rgba(160, 107, 255, .35) 45%, rgba(224, 72, 155, .3) 55%, transparent);
  opacity: 0;
  will-change: transform;
  animation: scan-run var(--v, 17s) linear var(--d, 0s) infinite;
}
@keyframes scan-run {
  0%        { transform: translate3d(-14vw, 0, 0); opacity: 0; }
  6%        { opacity: calc(var(--code-ink) * .5); }
  52%       { opacity: calc(var(--code-ink) * .5); }
  70%, 100% { transform: translate3d(108vw, 0, 0); opacity: 0; }
}

/* ---------- drifting syntax ---------- */
.glyph {
  position: absolute;
  left: var(--l, 50%);
  top: 100%;
  font-family: var(--mono);
  font-size: var(--s, 15px);
  font-weight: 500;
  white-space: nowrap;
  color: var(--accent);
  opacity: 0;
  will-change: transform;
  animation: glyph-rise var(--v, 26s) linear var(--d, 0s) infinite;
}
.glyph.is-warm { color: var(--accent-2); }

@keyframes glyph-rise {
  0%   { transform: translate3d(0, 0, 0) rotate(var(--r0, -6deg)); opacity: 0; }
  9%   { opacity: var(--code-ink); }
  80%  { opacity: calc(var(--code-ink) * .7); }
  100% { transform: translate3d(var(--dx, 3vw), -128vh, 0) rotate(var(--r1, 7deg)); opacity: 0; }
}

/* ---------- lighten the load on phones ---------- */
@media (max-width: 760px) {
  .depgraph.is-extra,
  .glyph.is-extra,
  .waterfall.is-extra,
  .scan.is-extra { display: none; }
  .depgraph { width: 150px; }
}

@media (prefers-reduced-motion: reduce) {
  .codefield { display: none !important; }
}
