/* ==========================================================================
   Calculate All FX3 — "FX3" 3D depth layer (futuristic transformation v3)
   Pure presentation, additive only — same discipline as fx.js / fx2.js:
     * Nothing here applies unless fx3.js adds html.fx3-on. With JS off,
       or if fx3.js fails to load, the site renders exactly as before.
     * fx.js keeps owning hero rotation (--rx/--ry on .hero-calc) and
       card tilt for .cat-tile/.tool-card/.feat-card/.dir-card/.hub-card.
       FX3 layers depth UNDER and AROUND that motion instead of
       fighting it: translateZ strata inside the calculator, orbiting
       holographic rings, a perspective grid floor, a living particle
       field, pointer-tracked card glare, deeper shadows.
     * Dark-only glows are scoped to html[data-theme="dark"]; the light
       theme keeps structural depth with soft, readable shadows.
     * Honors prefers-reduced-motion: every FX3 animation is switched
       off in the final block, and fx3.js skips its motion modules.
   It never touches calculator logic, forms, links, ads or the theme
   toggle. Injected elements (.fx3d-*) are pointer-events:none and
   aria-hidden, created only by fx3.js.
   ========================================================================== */

/* ------------------------------------------------------------------ */
/* 0) Injected living background: particle canvas + aurora blobs       */
/*    (fixed, z-index 0 — the same plane as body::before/::after,      */
/*     below main's z-index 1, so content always paints above)         */
/* ------------------------------------------------------------------ */
html.fx3-on .fx3d-canvas {
  position: fixed; inset: 0; width: 100%; height: 100%;
  z-index: 0; pointer-events: none; display: block;
}
html.fx3-on .fx3d-aurora {
  position: fixed; z-index: 0; pointer-events: none;
  border-radius: 50%; filter: blur(70px);
  will-change: transform, opacity;
}
html.fx3-on .fx3d-aurora-a {
  width: 58vmax; height: 58vmax; left: -16vmax; top: -18vmax;
  background: radial-gradient(circle at 42% 42%, rgba(34, 211, 238, .17), rgba(59, 130, 246, .07) 55%, transparent 72%);
  animation: fx3d-aurora-drift-a 36s ease-in-out infinite alternate;
}
html.fx3-on .fx3d-aurora-b {
  width: 52vmax; height: 52vmax; right: -14vmax; bottom: -20vmax;
  background: radial-gradient(circle at 55% 55%, rgba(139, 92, 246, .16), rgba(217, 70, 239, .06) 55%, transparent 72%);
  animation: fx3d-aurora-drift-b 44s ease-in-out infinite alternate;
}
@keyframes fx3d-aurora-drift-a {
  from { transform: translate3d(0, 0, 0) scale(1); opacity: .85; }
  to   { transform: translate3d(6vmax, 3.5vmax, 0) scale(1.12); opacity: 1; }
}
@keyframes fx3d-aurora-drift-b {
  from { transform: translate3d(0, 0, 0) scale(1.08); opacity: .8; }
  to   { transform: translate3d(-5vmax, -4vmax, 0) scale(.96); opacity: 1; }
}
/* light theme: the site's own soft wash is enough — blobs stand down */
html.fx3-on[data-theme="light"] .fx3d-aurora { display: none; }

/* ------------------------------------------------------------------ */
/* 1) 3D HERO STAGE (homepage .hero-home)                              */
/*    .hero-visual already carries perspective:1400px (styles.css E)   */
/*    and .hero-calc already has transform-style:preserve-3d with      */
/*    fx.js driving --rx/--ry. FX3 adds the strata + the stage.        */
/* ------------------------------------------------------------------ */

/* calculator strata: screen floats highest, keypad mid, keys pop */
html.fx3-on .hero-calc .hc-screen {
  transform: translateZ(52px);
  box-shadow:
    inset 0 2px 12px rgba(0, 0, 0, .6),
    0 22px 34px rgba(1, 3, 13, .5),
    0 0 26px rgba(34, 211, 238, .14);
}
html.fx3-on .hero-calc .hc-keys {
  transform: translateZ(26px);
  transform-style: preserve-3d;
}
html.fx3-on .hero-calc .hc-keys .k { transform: translateZ(7px); }
html.fx3-on .hero-calc .hc-keys .k-op { transform: translateZ(11px); }
html.fx3-on .hero-calc .hc-keys .k-eq {
  transform: translateZ(15px);
  box-shadow: 0 10px 26px rgba(139, 92, 246, .55), 0 3px 0 rgba(0, 0, 0, .35);
}
/* deeper multi-layer shadow under the whole device */
html.fx3-on .hero-calc {
  box-shadow:
    0 50px 100px rgba(2, 6, 23, .75),
    0 24px 44px rgba(2, 6, 23, .5),
    0 0 70px rgba(59, 130, 246, .28),
    inset 0 1px 0 rgba(255, 255, 255, .14);
}
/* slow idle float on the standalone `translate` property — composes
   with fx.js's transform rotation instead of overriding it */
html.fx3-on .hero-calc { animation: calc-float 7s ease-in-out infinite, calc-glow 4s ease-in-out infinite, fx3d-calc-bob 9.5s ease-in-out infinite; }
html.fx3-on .hero-calc.fx-tilt { animation: calc-glow 4s ease-in-out infinite, fx3d-calc-bob 9.5s ease-in-out infinite; }
@keyframes fx3d-calc-bob {
  0%, 100% { translate: 0 0 0; }
  50% { translate: 0 -11px 0; }
}

/* floating chips: per-chip Z depth (fx3.js sets --fx3z from data-depth).
   The standalone `translate` property composes with the chip-float
   transform animation; fx.js's pointer parallax writes inline
   translate while the pointer moves and clears it on leave, which
   restores this depth — no fighting, both effects survive. */
html.fx3-on .f-chip { translate: 0 0 var(--fx3z, 0px); }

/* --- injected stage: grid floor + glow floor + orbit rings --- */
html.fx3-on .fx3d-stage {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  transform: translate3d(
    calc(var(--fx3mx, 0) * 13px),
    calc(var(--fx3my, 0) * 9px), 0);
  will-change: transform;
}
/* perspective grid floor: lines on a rotateX plane, scrolling toward
   the viewer via background-position */
html.fx3-on .fx3d-grid {
  position: absolute; left: -32%; bottom: -7%; width: 164%; height: 54%;
  background-image:
    linear-gradient(rgba(34, 211, 238, .17) 1px, transparent 1px),
    linear-gradient(90deg, rgba(139, 92, 246, .17) 1px, transparent 1px);
  background-size: 46px 46px;
  transform: rotateX(63deg);
  transform-origin: 50% 100%;
  -webkit-mask-image: linear-gradient(to top, rgba(0, 0, 0, .95) 30%, transparent 88%);
  mask-image: linear-gradient(to top, rgba(0, 0, 0, .95) 30%, transparent 88%);
  animation: fx3d-grid-flow 1.5s linear infinite;
}
@keyframes fx3d-grid-flow {
  from { background-position: 0 0, 0 0; }
  to   { background-position: 0 46px, 0 0; }
}
html.fx3-on[data-theme="light"] .fx3d-grid { opacity: .35; }
/* reflective glow floor pooled beneath the calculator */
html.fx3-on .fx3d-glowfloor {
  position: absolute; left: 50%; bottom: 5%;
  width: 430px; height: 92px; margin-left: -215px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center, rgba(59, 130, 246, .42), rgba(139, 92, 246, .16) 52%, transparent 72%);
  filter: blur(14px);
  animation: fx3d-glowfloor-pulse 5.5s ease-in-out infinite;
}
@keyframes fx3d-glowfloor-pulse {
  0%, 100% { opacity: .75; transform: scaleX(1); }
  50% { opacity: 1; transform: scaleX(1.09); }
}
html.fx3-on[data-theme="light"] .fx3d-glowfloor { opacity: .45; }

/* holographic orbit rings around the calculator */
html.fx3-on .fx3d-ring {
  position: absolute; left: 50%; top: 46%;
  border-radius: 50%; pointer-events: none;
  border: 1px solid rgba(34, 211, 238, .30);
  box-shadow:
    0 0 26px rgba(34, 211, 238, .13),
    inset 0 0 26px rgba(139, 92, 246, .13);
  transform-style: preserve-3d;
}
html.fx3-on .fx3d-ring::before {
  content: ""; position: absolute; inset: -1px; border-radius: 50%;
  background: conic-gradient(from 0deg,
    transparent 0deg, rgba(34, 211, 238, .85) 38deg, transparent 84deg,
    transparent 180deg, rgba(217, 70, 239, .8) 218deg, transparent 264deg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 3px), #000 calc(100% - 2px));
}
html.fx3-on .fx3d-ring-1 {
  width: 308px; height: 308px; margin: -154px 0 0 -154px;
  animation: fx3d-ring-spin-a 26s linear infinite;
}
html.fx3-on .fx3d-ring-2 {
  width: 424px; height: 424px; margin: -212px 0 0 -212px;
  border-color: rgba(139, 92, 246, .26);
  animation: fx3d-ring-spin-b 38s linear infinite;
}
html.fx3-on .fx3d-ring-3 {
  width: 540px; height: 540px; margin: -270px 0 0 -270px;
  border-color: rgba(103, 232, 249, .16);
  animation: fx3d-ring-spin-a 55s linear infinite reverse;
}
@keyframes fx3d-ring-spin-a {
  from { transform: rotateX(71deg) rotateZ(0deg); }
  to   { transform: rotateX(71deg) rotateZ(360deg); }
}
@keyframes fx3d-ring-spin-b {
  from { transform: rotateX(68deg) rotateY(-7deg) rotateZ(360deg); }
  to   { transform: rotateX(68deg) rotateY(-7deg) rotateZ(0deg); }
}
@media (max-width: 700px) {
  html.fx3-on .fx3d-ring-1 { width: 236px; height: 236px; margin: -118px 0 0 -118px; }
  html.fx3-on .fx3d-ring-2 { width: 322px; height: 322px; margin: -161px 0 0 -161px; }
  html.fx3-on .fx3d-ring-3 { width: 408px; height: 408px; margin: -204px 0 0 -204px; }
  html.fx3-on .fx3d-glowfloor { width: 300px; margin-left: -150px; }
}

/* --- headline depth (dark theme; gradient line keeps its gradient) --- */
html.fx3-on[data-theme="dark"] .hero-home h1 {
  text-shadow:
    0 1px 0 rgba(103, 232, 249, .22),
    0 3px 0 rgba(59, 130, 246, .14),
    0 16px 38px rgba(1, 3, 13, .7);
}
html.fx3-on[data-theme="dark"] .hero-home .h-grad {
  filter: drop-shadow(0 8px 26px rgba(139, 92, 246, .38));
}
html.fx3-on[data-theme="dark"] .fx-hero-line {
  text-shadow:
    0 0 14px rgba(34, 211, 238, .4),
    0 2px 0 rgba(59, 130, 246, .3),
    0 12px 28px rgba(1, 3, 13, .65);
}

/* ------------------------------------------------------------------ */
/* 2) CARD DEPTH (all pages)                                           */
/*    fx.js tilt cards keep fx.js rotation; FX3 adds the glare span    */
/*    (injected by fx3.js), deeper hover shadows and a gradient        */
/*    border glow. Cards fx.js does not tilt get a gentle fx3 tilt     */
/*    (fx3.js writes --rx/--ry, max 6deg, fine pointers only).         */
/* ------------------------------------------------------------------ */
html.fx3-on .cat-tile, html.fx3-on .tool-card, html.fx3-on .feat-card,
html.fx3-on .dir-card, html.fx3-on .hub-card, html.fx3-on .related-card,
html.fx3-on .article-card, html.fx3-on .content-card, html.fx3-on .example-card {
  position: relative;
}

/* pointer-tracked glare: radial highlight follows --mx/--my (written
   by fx.js on its tilt cards, by fx3.js on the rest), plus a sheen
   sweep that crosses the card each time hover begins */
html.fx3-on .fx3d-glare {
  position: absolute; inset: 0; z-index: 2; border-radius: inherit;
  pointer-events: none; opacity: 0; transition: opacity .35s ease;
  mix-blend-mode: screen;
  background:
    radial-gradient(330px circle at var(--mx, 50%) var(--my, 50%),
      rgba(255, 255, 255, .15), transparent 62%),
    linear-gradient(115deg, transparent 35%, rgba(255, 255, 255, .09) 50%, transparent 65%);
  background-size: auto, 260% 100%;
  background-position: 0 0, 130% 0;
}
html.fx3-on .cat-tile:hover .fx3d-glare, html.fx3-on .tool-card:hover .fx3d-glare,
html.fx3-on .feat-card:hover .fx3d-glare, html.fx3-on .dir-card:hover .fx3d-glare,
html.fx3-on .hub-card:hover .fx3d-glare, html.fx3-on .related-card:hover .fx3d-glare,
html.fx3-on .article-card:hover .fx3d-glare, html.fx3-on .content-card:hover .fx3d-glare,
html.fx3-on .example-card:hover .fx3d-glare {
  opacity: 1; animation: fx3d-sheen 1.15s ease forwards;
}
@keyframes fx3d-sheen {
  from { background-position: 0 0, 130% 0; }
  to   { background-position: 0 0, -130% 0; }
}
html.fx3-on[data-theme="light"] .fx3d-glare { mix-blend-mode: normal; opacity: 0; }
html.fx3-on[data-theme="light"] .cat-tile:hover .fx3d-glare,
html.fx3-on[data-theme="light"] .tool-card:hover .fx3d-glare,
html.fx3-on[data-theme="light"] .feat-card:hover .fx3d-glare,
html.fx3-on[data-theme="light"] .dir-card:hover .fx3d-glare,
html.fx3-on[data-theme="light"] .hub-card:hover .fx3d-glare,
html.fx3-on[data-theme="light"] .related-card:hover .fx3d-glare,
html.fx3-on[data-theme="light"] .article-card:hover .fx3d-glare,
html.fx3-on[data-theme="light"] .content-card:hover .fx3d-glare,
html.fx3-on[data-theme="light"] .example-card:hover .fx3d-glare { opacity: .55; }

/* fx3 gentle tilt for the cards fx.js does not tilt */
html.fx3-on .related-card.fx3d-tilt, html.fx3-on .article-card.fx3d-tilt,
html.fx3-on .content-card.fx3d-tilt, html.fx3-on .example-card.fx3d-tilt {
  transform: perspective(900px)
    rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(-4px);
}
html.fx3-on .related-card, html.fx3-on .article-card,
html.fx3-on .content-card, html.fx3-on .example-card {
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}

/* deeper layered shadows + gradient border glow on hover (dark) */
html.fx3-on[data-theme="dark"] .cat-tile:hover, html.fx3-on[data-theme="dark"] .tool-card:hover,
html.fx3-on[data-theme="dark"] .feat-card:hover, html.fx3-on[data-theme="dark"] .dir-card:hover,
html.fx3-on[data-theme="dark"] .hub-card:hover, html.fx3-on[data-theme="dark"] .related-card:hover,
html.fx3-on[data-theme="dark"] .article-card:hover, html.fx3-on[data-theme="dark"] .content-card:hover,
html.fx3-on[data-theme="dark"] .example-card:hover {
  box-shadow:
    0 26px 50px rgba(1, 3, 13, .55),
    0 10px 20px rgba(1, 3, 13, .45),
    0 0 36px color-mix(in srgb, var(--tile, #8b5cf6) 34%, transparent),
    inset 0 1px 0 rgba(255, 255, 255, .1);
  border-color: color-mix(in srgb, var(--tile, #8b5cf6) 60%, transparent);
}
/* light theme: soft lift only, no neon */
html.fx3-on[data-theme="light"] .cat-tile:hover, html.fx3-on[data-theme="light"] .tool-card:hover,
html.fx3-on[data-theme="light"] .feat-card:hover, html.fx3-on[data-theme="light"] .dir-card:hover,
html.fx3-on[data-theme="light"] .hub-card:hover, html.fx3-on[data-theme="light"] .related-card:hover,
html.fx3-on[data-theme="light"] .article-card:hover, html.fx3-on[data-theme="light"] .content-card:hover,
html.fx3-on[data-theme="light"] .example-card:hover {
  box-shadow:
    0 22px 42px rgba(30, 58, 138, .16),
    0 8px 16px rgba(30, 58, 138, .1),
    inset 0 1px 0 rgba(255, 255, 255, .65);
}

/* ------------------------------------------------------------------ */
/* 3) Section headings: subtle layered depth (dark theme)              */
/* ------------------------------------------------------------------ */
html.fx3-on[data-theme="dark"] main h2 {
  text-shadow:
    0 1px 0 rgba(103, 232, 249, .13),
    0 10px 26px rgba(1, 3, 13, .55);
}

/* ------------------------------------------------------------------ */
/* 4) Reduced motion: every FX3 animation off, depth stays static      */
/* ------------------------------------------------------------------ */
@media (prefers-reduced-motion: reduce) {
  html.fx3-on .fx3d-aurora-a, html.fx3-on .fx3d-aurora-b,
  html.fx3-on .fx3d-grid, html.fx3-on .fx3d-glowfloor,
  html.fx3-on .fx3d-ring-1, html.fx3-on .fx3d-ring-2, html.fx3-on .fx3d-ring-3,
  html.fx3-on .hero-calc, html.fx3-on .hero-calc.fx-tilt {
    animation: none !important;
  }
  html.fx3-on .cat-tile:hover .fx3d-glare, html.fx3-on .tool-card:hover .fx3d-glare,
  html.fx3-on .feat-card:hover .fx3d-glare, html.fx3-on .dir-card:hover .fx3d-glare,
  html.fx3-on .hub-card:hover .fx3d-glare, html.fx3-on .related-card:hover .fx3d-glare,
  html.fx3-on .article-card:hover .fx3d-glare, html.fx3-on .content-card:hover .fx3d-glare,
  html.fx3-on .example-card:hover .fx3d-glare {
    animation: none;
  }
  html.fx3-on .fx3d-stage { transform: none; }
}
