/* ============================================================
   Sarmad Domit — Portfolio · cinematic FX layer
   Loads on every page after site.css. Additive only — never
   hides content if JS fails (all overlays are injected by fx.js
   and default to pointer-events:none / low opacity).
   ============================================================ */

/* ---------- cinematic grade: vignette + scanlines ---------- */
.fx-grade { position: fixed; inset: 0; z-index: 1; pointer-events: none; }
.fx-vignette {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(120% 100% at 50% 42%, transparent 52%, rgba(0,0,0,0.32) 88%, rgba(0,0,0,0.6) 100%);
  mix-blend-mode: multiply;
}
.fx-scanlines {
  position: fixed; inset: -2px; z-index: 1; pointer-events: none; opacity: 0.5;
  background-image: repeating-linear-gradient(
    0deg, rgba(255,255,255,0.018) 0px, rgba(255,255,255,0.018) 1px,
    transparent 1px, transparent 3px);
  will-change: transform;
}
.fx-bloom {
  position: fixed; left: 50%; top: -10%; z-index: 0; pointer-events: none;
  width: 80vw; height: 60vh; transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(47,230,230,0.06), transparent 70%);
  filter: blur(20px);
}

/* ---------- one-time calibration sweep on load ---------- */
.fx-calibrate {
  position: fixed; inset: 0; z-index: 60; pointer-events: none; overflow: hidden; opacity: 0;
}
.fx-calibrate.run { opacity: 1; }
.fx-calibrate .bar {
  position: absolute; left: 0; right: 0; top: 0; height: 22vh;
  background: linear-gradient(180deg, transparent, rgba(47,230,230,0.08) 60%, rgba(150,250,250,0.18));
  border-bottom: 1px solid rgba(150,250,250,0.5);
  box-shadow: 0 0 40px rgba(47,230,230,0.35);
  transform: translateY(-30vh);
}
.fx-calibrate.run .bar { animation: fxsweep 1.15s cubic-bezier(.5,0,.2,1) forwards; }
@keyframes fxsweep { 0% { transform: translateY(-30vh); opacity: 0; } 12% { opacity: 1; } 100% { transform: translateY(120vh); opacity: 0; } }

/* ---------- page-transition curtain ---------- */
.fx-transition {
  position: fixed; inset: 0; z-index: 9000; pointer-events: none;
  background: linear-gradient(160deg, #0a0c11, #07080b 70%);
  transform: scaleY(0); transform-origin: bottom;
  display: grid; place-items: center;
}
.fx-transition::after {
  content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  box-shadow: 0 0 22px var(--accent-glow); opacity: 0;
}
.fx-transition .fx-mark {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.4em; text-transform: uppercase;
  color: var(--accent-soft); opacity: 0; display: flex; align-items: center; gap: 12px;
}
.fx-transition .fx-mark .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); animation: pulse 1s infinite; }
.fx-transition.leaving { transform-origin: bottom; animation: fxCover .5s cubic-bezier(.7,0,.3,1) forwards; }
.fx-transition.entering { transform: scaleY(1); transform-origin: top; animation: fxReveal .62s cubic-bezier(.7,0,.3,1) forwards; }
.fx-transition.leaving::after, .fx-transition.entering::after { opacity: 1; }
.fx-transition.leaving .fx-mark, .fx-transition.entering .fx-mark { animation: fxMark .5s ease forwards; }
@keyframes fxCover  { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes fxReveal { from { transform: scaleY(1); } to { transform: scaleY(0); } }
@keyframes fxMark   { 0% { opacity: 0; } 40% { opacity: 1; } 100% { opacity: 0; } }

/* page content soft fade-in on direct load (transform only — never hides content,
   so a throttled/frozen context can't blank the page) */
body.fx-fade main { animation: fxFadeUp .7s cubic-bezier(.2,0,0,1) both; }
@keyframes fxFadeUp { from { transform: translateY(12px); } to { transform: none; } }

/* ---------- 3D hero canvas ---------- */
.hero-3d { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hero-orbit.has3d svg { opacity: 0; transition: opacity .5s; }   /* hide static fallback once canvas paints */

/* ---------- magnetic + parallax helpers ---------- */
.fx-magnetic { will-change: transform; }
[data-parallax] { will-change: transform; }

/* ---------- draw-on-scroll rails ---------- */
[data-draw] { transform: scaleX(0); transform-origin: left center; transition: transform 1.1s cubic-bezier(.3,0,0,1); }
[data-draw].drawn { transform: scaleX(1); }
[data-draw-y] { transform: scaleY(0); transform-origin: top center; transition: transform 1.1s cubic-bezier(.3,0,0,1); }
[data-draw-y].drawn { transform: scaleY(1); }
/* failsafe: if a transition freezes in a throttled context, never leave a rail collapsed */
html.reveal-all [data-draw], html.reveal-all [data-draw-y] { transform: none !important; transition: none !important; }

/* ---------- custom cursor (fine-pointer only) ---------- */
body.fx-cursor, body.fx-cursor a, body.fx-cursor button, body.fx-cursor .tilt, body.fx-cursor [role="button"], body.fx-cursor input, body.fx-cursor textarea, body.fx-cursor label { cursor: none; }
.fx-cur-ring, .fx-cur-dot { position: fixed; top: 0; left: 0; z-index: 9500; pointer-events: none; border-radius: 50%; mix-blend-mode: difference; will-change: transform; }
.fx-cur-ring {
  width: 34px; height: 34px; margin: -17px 0 0 -17px;
  border: 1.4px solid rgba(120,250,250,0.9);
  transition: width .22s cubic-bezier(.3,0,0,1), height .22s cubic-bezier(.3,0,0,1), margin .22s cubic-bezier(.3,0,0,1), background .22s, border-color .22s, opacity .25s;
}
.fx-cur-dot {
  width: 6px; height: 6px; margin: -3px 0 0 -3px;
  background: #bffcff;
  transition: width .18s, height .18s, margin .18s, opacity .25s;
}
/* hover state — over interactive elements */
body.fx-hot .fx-cur-ring { width: 56px; height: 56px; margin: -28px 0 0 -28px; background: rgba(47,230,230,0.12); border-color: rgba(120,250,250,0.6); }
body.fx-hot .fx-cur-dot { width: 0; height: 0; margin: 0; }
/* press state */
body.fx-press .fx-cur-ring { width: 26px; height: 26px; margin: -13px 0 0 -13px; }
/* off-screen / idle */
body.fx-cur-hide .fx-cur-ring, body.fx-cur-hide .fx-cur-dot { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .fx-scanlines, .fx-bloom, .fx-calibrate { display: none; }
  body.fx-fade main { animation: none; }
  [data-draw], [data-draw-y] { transform: none; transition: none; }
}
