/* ─────────────────────────────────────────────────────────────
   paint-cursor.css — glass pointer + paint trail (decoration only)

   Companion to assets/paint-cursor.js. Nothing here hides the native
   cursor unless <html> carries .has-cursor, which paint-cursor.js adds
   ONLY after it has successfully built a custom cursor on a fine pointer.
   If the script never runs, throws, or the device is touch-only, the user
   keeps a normal, visible mouse cursor.

   Every element styled here is created by the script with aria-hidden="true"
   and is unfocusable and pointer-events:none.
   ───────────────────────────────────────────────────────────── */

:root {
  /* House easing curve — shared with the reference site's motion signature.
     Exposed so the rest of the page can use the same one. */
  --pc-ease: cubic-bezier(0.2, 0.75, 0.2, 1);
}

/* Native cursor is hidden ONLY once the custom one is proven alive. */
html.has-cursor,
html.has-cursor * {
  cursor: none !important;
}

/* ─── Paint trail ──────────────────────────────────────────
   A body-level layer between #hover-bg and all top-level content.

   z-index 0 is measured, not assumed. Every top-level section (.hero, #work,
   #about, #contact, footer) is a stacking context at z-index 1 with a
   TRANSPARENT background, so a canvas at 0 shows through all of them while
   being occluded by the paintings and by both video loops — the wanted
   behaviour, with no changes to index.html.

   It must remain AFTER #hover-bg in DOM order: that layer is opaque
   (rgb(10,10,8)) and also sits at z-index 0, so paint order decides.
   Giving #hover-bg a z-index above 0 would hide the trail page-wide. */
#pc-trail {
  position: fixed;
  inset: 0;
  /* A canvas is a REPLACED element: with width:auto, `inset: 0` does not size
     it — width resolves to the intrinsic size, i.e. the backing store. At
     DPR 1 that happens to equal the viewport, so the bug hides; at DPR 2 the
     canvas lays out at 2560x1600 CSS px and the trail renders offscreen.
     These two lines are load-bearing on retina. */
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  /* Ceiling on how much the trail can brighten what it crosses, so it reads as
     stain soaked into the ground rather than paint sitting on top. */
  opacity: 0.75;
}

/* ─── Glass pointer ────────────────────────────────────────
   Values taken from the reference site, not approximated.
   backdrop-filter ONLY — no mix-blend-mode, no filter: blur().
   Those two are what break the effect on WebKit.

   Position is driven by --cursor-x / --cursor-y inside transform, and
   transform is deliberately ABSENT from the transition list: the JS lerp
   owns position. Transitioning transform as well is what makes custom
   cursors feel like they are dragging behind the pointer. */
#pc-cursor {
  --cursor-size: 3.75rem;              /* 60px at rest */
  --cursor-x: -200px;
  --cursor-y: -200px;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100000;                     /* see note: NOT the reference's 90 */
  width: var(--cursor-size);
  height: var(--cursor-size);
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.035));
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(13px) saturate(125%);
  -webkit-backdrop-filter: blur(13px) saturate(125%);
  transform: translate3d(var(--cursor-x), var(--cursor-y), 0) translate(-50%, -50%) scale(0.82);
  opacity: 0;
  pointer-events: none;
  will-change: transform;
  transition: width 220ms cubic-bezier(0.2, 0.75, 0.2, 1),
              height 220ms cubic-bezier(0.2, 0.75, 0.2, 1),
              border-color 220ms ease,
              background 220ms ease,
              box-shadow 220ms ease,
              opacity 220ms ease;
}

#pc-cursor.pc-visible { opacity: 1; }

/* Over a link/button it INVERTS: the 60px translucent glass disc becomes a
   ~11.5px opaque white dot. Reads as far more intentional than growing a ring. */
body.cursor-link #pc-cursor {
  --cursor-size: 0.72rem;
  border-color: rgba(255, 255, 255, 0.68);
  background: rgba(255, 255, 255, 0.82);
  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(8px) saturate(130%);
  -webkit-backdrop-filter: blur(8px) saturate(130%);
}

/* No backdrop-filter support → a fully OPAQUE ring, never an invisible one.
   The ring itself is opaque (alpha 1) with a dark outer contour so it stays
   legible over both the dark ground and a bright painting. The interior stays
   a light wash rather than a solid disc, which would hide the work beneath it. */
html.pc-no-backdrop #pc-cursor {
  background: rgba(232, 224, 212, 0.18);
  border: 2px solid #ece4d2;
  box-shadow: 0 0 0 1px rgba(10, 10, 8, 0.85), inset 0 0 0 1px rgba(10, 10, 8, 0.55);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
html.pc-no-backdrop body.cursor-link #pc-cursor {
  background: #ece4d2;                 /* the inverted dot: fully opaque */
}

/* Hidden container for the optional feTurbulence/feDisplacementMap defs. */
#pc-defs {
  position: fixed;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
  visibility: hidden;
}

/* Belt and braces: if this stylesheet loads but the script does not run,
   nothing is hidden and nothing is drawn. Under reduced motion the script
   creates no nodes at all; these rules simply neutralise any leftovers. */
@media (prefers-reduced-motion: reduce) {
  #pc-trail,
  #pc-cursor { display: none !important; }
  html.has-cursor,
  html.has-cursor * { cursor: auto !important; }
}
