/* ==========================================================================
   Nav hover motion (2026-11-17): Work, Resume, LinkedIn, Playground in the
   homepage header / sidebar, the case-study header and Field Notes.

   Layout options → Sidebar → "Nav hover motion" (data-navhover):
   - icons (default): see the second half of this file.
   - lift: the icon hops up 2px and tilts 8° with a small overshoot,
     and the word slides 2px right. A translate + rotate on the icon; the word
     is a translate on the whole link. Nothing changes size, so the row never
     reflows.
   - underline: a 1px line draws in under the word, left to right (scaleX on
     a pseudo-element, origin left), and retracts to the right on the way out.
   - off: colour change only (before).
   Only on devices that hover, and never with reduced motion.
   ========================================================================== */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  :is(.masthead__nav, .cmast) a[data-nav] {
    transition: translate .24s cubic-bezier(.2, .7, .2, 1), color .2s ease;
  }
  :is(.masthead__nav, .cmast) a[data-nav] .nav-ico {
    transition: transform .32s cubic-bezier(.34, 1.56, .64, 1);   /* a little overshoot: a hop, not a slide */
  }

  /* lift */
  :root[data-navhover="lift"] :is(.masthead__nav, .cmast) a[data-nav]:not(.btn):hover { translate: 2px 0 }
  :root[data-navhover="lift"] :is(.masthead__nav, .cmast) a[data-nav]:hover .nav-ico { transform: translateY(-2px) rotate(-8deg) }

  /* underline */
  :root[data-navhover="underline"] :is(.masthead__nav, .cmast) a[data-nav]:not(.btn) { position: relative }
  :root[data-navhover="underline"] :is(.masthead__nav, .cmast) a[data-nav]:not(.btn)::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: -3px; height: 1px;
    background: currentColor; transform: scaleX(0); transform-origin: right center;
    transition: transform .32s cubic-bezier(.2, .7, .2, 1);
  }
  :root[data-navhover="underline"] :is(.masthead__nav, .cmast) a[data-nav]:not(.btn):hover::after {
    transform: scaleX(1); transform-origin: left center;
  }
}

/* ==========================================================================
   Icons act it out (data-navhover="icons", the default; nav-anim.js builds
   the drawings). Mechanisms, so they can be tuned by name:
   - Resume (≈0.65s, rebuilt 2026-11-17): the briefcase opens and the page
     comes out of it. The animated case is the static icon split at the seam
     (custom: its divider; Lucide: halfway). 1) The lid swings open on a
     hinge at the seam's right end (rotate 0 → 32°, ease-out, .24s). 2) The
     page, lines already on it, rises out of the case (translateY 13 → 0
     units, .44s from .06s, ease-out); it's clipped at the case's bottom
     (a straight edge on a whole pixel) and hidden by the case front's fill.
     3) The lid and front sink 5 units and fade (.26s from .3s), leaving the
     page. Only the lid rotates; the page only slides and rests on whole
     pixels at 16px, so it ends crisp. Going off: the drawing resets to the
     closed case as it fades out over the static briefcase fading back in.
   - LinkedIn bubble: logo scale → 0; bubble scale .3 → 1 from the tail
     (bottom left) with an overshoot; then the three dots pulse in turn.
     Plane: translate in from −9,+9px (lower left) on an ease-out, then bob.
   - Playground: the telescope zooms toward you (scale 1.8 + fade) into its
     eyepiece view: a round lens frame, ≈19px across, a little larger than
     the 16px icon (scale .4 → 1.1, overshoot) with the
     four-point star floating inside and small stars blinking, the whole
     field drifting ±1.2px inside the lens.
   Going off the link, everything eases back in 180ms.
   ========================================================================== */
.nav-icowrap{position:relative;display:inline-flex;flex:none}
.nav-icowrap[hidden]{display:none}
.nav-fx{position:absolute;inset:0;pointer-events:none;opacity:0}
.nav-fx svg{--fx-sw:1.333px;position:absolute;inset:0;width:100%;height:100%;overflow:visible;fill:none;stroke:currentColor;stroke-width:var(--fx-sw);stroke-linecap:round;stroke-linejoin:round}
:root[data-navicons="custom"] .nav-fx svg{--fx-sw:1.25px}
/* every line in the animations is drawn at the static icon's own screen weight
   (1.333px Lucide, 1.25px custom), however its part is scaled or squashed */
.nav-fx :is(path,rect,circle){vector-effect:non-scaling-stroke}
.nav-fx :is(.fx-page,.fx-lid,.fx-case,.fx-scope,.fx-bubble,.fx-plane,.fx-star,.fx-glint){transform-box:view-box}
.nav-fx .fx-dot{fill:currentColor}
:root:not([data-liicon="plane"]) .nav-fx--linkedin svg:last-child,
:root[data-liicon="plane"] .nav-fx--linkedin svg:first-child{display:none}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  :root:is(:not([data-navhover]),[data-navhover="icons"]) {
    --fx-out: .18s ease;
    --fx-pop: cubic-bezier(.34, 1.56, .64, 1);
  }
  /* the static icon steps aside */
  :root:is(:not([data-navhover]),[data-navhover="icons"]) .nav-icowrap > .nav-ico{transition:scale var(--fx-out),opacity var(--fx-out),translate var(--fx-out)}
  :root:is(:not([data-navhover]),[data-navhover="icons"]) .nav-fx{transition:opacity .12s ease}
  :root:is(:not([data-navhover]),[data-navhover="icons"]) a[data-nav]:hover .nav-fx{opacity:1}
  :root:is(:not([data-navhover]),[data-navhover="icons"]) a[data-nav]:hover .nav-icowrap:has(.nav-fx) > .nav-ico{opacity:0}

  /* Resume (see the header for the timeline) */
  .nav-fx--resume :is(.fx-page,.fx-lid,.fx-case){transform-box:view-box}
  .nav-fx--resume .fx-page rect,.nav-fx--resume .fx-fill{fill:var(--fx-bg,#fff)}
  .nav-fx--resume .fx-fill{stroke:none}
  .nav-fx--resume .fx-page{transform:translateY(13px)}
  .nav-fx--resume .fx-case--custom .fx-lid{transform-origin:21.75px 14.25px}
  .nav-fx--resume .fx-case--lucide .fx-lid{transform-origin:22px 13px}
  .nav-fx--resume .fx-case--custom,:root[data-navicons="custom"] .nav-fx--resume .fx-case--lucide{display:none}
  :root[data-navicons="custom"] .nav-fx--resume .fx-case--custom{display:inline}
  :root:is(:not([data-navhover]),[data-navhover="icons"]) a[data-nav]:hover .nav-fx--resume .fx-lid{animation:fx-open .24s cubic-bezier(.3,.7,.3,1) both}
  :root:is(:not([data-navhover]),[data-navhover="icons"]) a[data-nav]:hover .nav-fx--resume .fx-page{animation:fx-out .44s .06s cubic-bezier(.2,.8,.25,1) both}
  :root:is(:not([data-navhover]),[data-navhover="icons"]) a[data-nav]:hover .nav-fx--resume .fx-case{animation:fx-away .26s .3s ease-in both}

  /* LinkedIn: bubble */
  .nav-fx--linkedin .fx-bubble{transform-origin:6px 21px;scale:.3;transition:scale var(--fx-out,.18s)}
  :root:is(:not([data-navhover]),[data-navhover="icons"]) a[data-nav]:hover .nav-fx--linkedin .fx-bubble{scale:1;transition:scale .34s var(--fx-pop)}
  :root:is(:not([data-navhover]),[data-navhover="icons"]) a[data-nav]:hover .nav-fx--linkedin .fx-dot{animation:fx-typing 1.1s .3s ease-in-out infinite}
  :root:is(:not([data-navhover]),[data-navhover="icons"]) a[data-nav]:hover .nav-fx--linkedin .fx-dot:nth-of-type(2){animation-delay:.45s}
  :root:is(:not([data-navhover]),[data-navhover="icons"]) a[data-nav]:hover .nav-fx--linkedin .fx-dot:nth-of-type(3){animation-delay:.6s}
  /* LinkedIn: paper plane */
  .nav-fx--linkedin .fx-plane{translate:-9px 9px;transition:translate var(--fx-out,.18s)}
  :root:is(:not([data-navhover]),[data-navhover="icons"]) a[data-nav]:hover .nav-fx--linkedin .fx-plane{translate:0 0;transition:translate .4s cubic-bezier(.2,.8,.2,1);
    animation:fx-bob 1.8s .4s ease-in-out infinite}
  :root:is(:not([data-navhover]),[data-navhover="icons"]) a[data-nav="linkedin"]:hover .nav-icowrap > .nav-ico{scale:0}

  /* Playground: the eyepiece view */
  .nav-fx--playground .fx-scope{transform-origin:12px 12px;scale:.4;opacity:0;transition:scale var(--fx-out,.18s),opacity var(--fx-out,.18s)}
  .nav-fx--playground .fx-lens{fill:none}
  .nav-fx--playground :is(.fx-big,.fx-tw){fill:currentColor;stroke:none}
  .nav-fx--playground :is(.fx-field,.fx-float,.fx-tw){transform-box:view-box;transform-origin:12px 12px}
  .nav-fx--playground .fx-tw{opacity:.45}
  :root:is(:not([data-navhover]),[data-navhover="icons"]) a[data-nav="playground"]:hover .nav-icowrap > .nav-ico{scale:1.8}
  :root:is(:not([data-navhover]),[data-navhover="icons"]) a[data-nav]:hover .nav-fx--playground .fx-scope{scale:1.1;opacity:1;transition:scale .4s .08s var(--fx-pop),opacity .2s .08s}
  :root:is(:not([data-navhover]),[data-navhover="icons"]) a[data-nav]:hover .nav-fx--playground .fx-field{animation:fx-pan 5s .3s ease-in-out infinite}
  :root:is(:not([data-navhover]),[data-navhover="icons"]) a[data-nav]:hover .nav-fx--playground .fx-float{animation:fx-float 2.6s .5s ease-in-out infinite}
  :root:is(:not([data-navhover]),[data-navhover="icons"]) a[data-nav]:hover .nav-fx--playground .fx-tw--a{animation:fx-twk 1.4s .3s steps(3) infinite}
  :root:is(:not([data-navhover]),[data-navhover="icons"]) a[data-nav]:hover .nav-fx--playground .fx-tw--b{animation:fx-twk 1.9s .6s steps(3) infinite}
  :root:is(:not([data-navhover]),[data-navhover="icons"]) a[data-nav]:hover .nav-fx--playground .fx-tw--c{animation:fx-twk 1.6s .9s steps(3) infinite}
  :root:is(:not([data-navhover]),[data-navhover="icons"]) a[data-nav]:hover .nav-fx--playground .fx-tw--d{animation:fx-twk 2.2s .4s steps(3) infinite}
}
@keyframes fx-typing{0%,60%,100%{opacity:.25}30%{opacity:1}}
@keyframes fx-bob{0%,100%{transform:translate(0,0)}50%{transform:translate(1px,-1.5px)}}
@keyframes fx-float{0%,100%{transform:translateY(0) rotate(-6deg)}50%{transform:translateY(-1.5px) rotate(6deg)}}
/* Resume: the lid swings open, the page rises out, the case sinks and fades */
@keyframes fx-open{to{transform:rotate(32deg)}}
@keyframes fx-out{from{transform:translateY(13px)}to{transform:translateY(0)}}
@keyframes fx-away{to{opacity:0;transform:translateY(5px)}}
/* Playground: the field drifts left and right inside the lens; the small stars blink in pixel steps */
@keyframes fx-pan{0%,100%{transform:translateX(1.2px)}50%{transform:translateX(-1.2px)}}
@keyframes fx-twk{0%,100%{opacity:.25}50%{opacity:1}}
