/* =====================================================================
   JobSpider "Dangling Helper" spider
   Works with /job/include/js-spider.js. All class names start with
   "jsx-spider" so they can't collide with the existing js-* styles.
   ===================================================================== */

/* Layering: the thread passes BEHIND the headline text and the search box */
.js-hero-wrap.has-spider { position: relative; }
.js-hero-wrap.has-spider .js-hero-header { position: relative; z-index: 1; }

/* Reserve the spider's resting spot between the subtitle and the search box on
   every screen size. This is set in CSS (not by the script) so nothing on the
   page moves after it loads: no layout shift. Was 28px. */
.js-hero-header { margin-bottom: 56px; }
.js-hero-wrap.has-spider #jobSearchForm { position: relative; z-index: 2; }

.jsx-spider {
  position: absolute;
  top: 0;              /* JS sets top/left */
  left: 0;
  width: 34px;
  z-index: 0;
  pointer-events: none;
  visibility: hidden;  /* shown once JS has measured the page */
}
.jsx-spider.is-ready { visibility: visible; }

.jsx-spider__swing  { transform-origin: 17px 0; }
.jsx-spider__thread {
  width: 1.5px; height: var(--rest, 160px); margin: 0 auto;
  /* fades out toward the top so it stays quiet where it passes behind the headline */
  background: linear-gradient(to bottom, rgba(160,174,192,0) 0%, rgba(160,174,192,.45) 45%, #a0aec0 100%);
}
.jsx-spider__bug svg { display: block; width: 34px; height: 34px; transform: rotate(180deg); } /* head down */
.jsx-wave { transform-box: view-box; transform-origin: 25px 21px; }

/* ---------- 1. Drop & Settle ---------- */
.jsx-spider.is-ready.m-dropSettle .jsx-spider__thread { animation: jsxDropBounce 1.8s cubic-bezier(.3,.7,.4,1); }
.jsx-spider.is-ready.m-dropSettle .jsx-spider__swing  { animation: jsxSettle 10s ease-in-out 1.6s; }

/* ---------- 2. Pendulum Swing ---------- */
.jsx-spider.is-ready.m-pendulum .jsx-spider__thread { animation: jsxDrop .9s cubic-bezier(.2,.8,.3,1); }
.jsx-spider.is-ready.m-pendulum .jsx-spider__swing  { animation: jsxPendulum 9s ease-in-out .7s; }

/* ---------- 3. Yo-Yo Bounce (then a small bob every 20s, 3 times) ---------- */
.jsx-spider.is-ready.m-yoyo .jsx-spider__thread { animation: jsxYoyo 2.6s ease-in-out, jsxBob 20s ease-in-out 2.6s 3; }

/* ---------- 4. Curious Peek ---------- */
.jsx-spider.is-ready.m-curiousPeek .jsx-spider__thread { animation: jsxPeek 5.5s ease-in-out; }
.jsx-spider.is-ready.m-curiousPeek .jsx-spider__bug    { transform-origin: 17px 0; animation: jsxTilt 5.5s ease-in-out; }

/* ---------- 5. Slow Twirl ---------- */
.jsx-spider.is-ready.m-slowTwirl .jsx-spider__thread { animation: jsxDrop 2.2s cubic-bezier(.25,.8,.35,1); }
.jsx-spider.is-ready.m-slowTwirl .jsx-spider__bug    { animation: jsxTwirl 3.2s ease-in-out .4s 2; }
.jsx-spider.is-ready.m-slowTwirl .jsx-spider__swing  { animation: jsxSettle 8s ease-in-out 6.8s; }

/* ---------- 6. Wave Hello ---------- */
.jsx-spider.is-ready.m-waveHello .jsx-spider__thread { animation: jsxDropBounce 1.8s cubic-bezier(.3,.7,.4,1); }
.jsx-spider.is-ready.m-waveHello .jsx-wave           { animation: jsxWave 1.6s ease-in-out 2.2s 2; }
.jsx-spider.is-ready.m-waveHello .jsx-spider__swing  { animation: jsxSettle 9s ease-in-out 5.6s; }

/* ---------- 7. Follows the Cursor (JS sets the rotation) ---------- */
.jsx-spider.is-ready.m-followCursor .jsx-spider__thread { animation: jsxDrop 1.6s cubic-bezier(.25,.8,.35,1); }
.jsx-spider.m-followCursor .jsx-spider__swing { transition: transform 1.6s cubic-bezier(.22,.9,.24,1); }

/* ---------- 8. Passing Breeze (4 gusts, 15s apart, then still) ---------- */
.jsx-spider.is-ready.m-breeze .jsx-spider__thread { animation: jsxDrop 1.8s cubic-bezier(.25,.8,.35,1); }
.jsx-spider.is-ready.m-breeze .jsx-spider__swing  { animation: jsxGust 15s ease-in-out 3s 4; }

/* ---------- 9. Zips Up on Search ---------- */
.jsx-spider.is-ready.m-zipOnSearch .jsx-spider__thread { animation: jsxDropBounce 1.8s cubic-bezier(.3,.7,.4,1); }

/* Search reactions (motion 9, or any motion when alwaysReactToSearch is on) */
.jsx-spider.react .jsx-spider__thread { transition: height .9s cubic-bezier(.34,1.4,.64,1); }
.jsx-spider.react.is-hover .jsx-spider__thread { animation: none !important; height: calc(var(--rest) + 12px); }
.jsx-spider.react.is-zip .jsx-spider__thread { animation: none !important; height: 0; transition: height .35s cubic-bezier(.6,0,.9,.4); }

/* ---------- Keyframes (lengths follow --rest, which JS measures) ---------- */
@keyframes jsxDrop { from { height: 0; } to { height: var(--rest); } }
@keyframes jsxDropBounce {
  0% { height: 0; } 55% { height: calc(var(--rest) + 12px); } 72% { height: calc(var(--rest) - 8px); }
  86% { height: calc(var(--rest) + 4px); } 100% { height: var(--rest); }
}
@keyframes jsxSettle {
  0%,100% { transform: rotate(0); } 10% { transform: rotate(2.2deg); } 26% { transform: rotate(-1.8deg); }
  42% { transform: rotate(1.3deg); } 58% { transform: rotate(-.9deg); } 74% { transform: rotate(.5deg); } 88% { transform: rotate(-.2deg); }
}
@keyframes jsxPendulum {
  0%,100% { transform: rotate(0); } 7% { transform: rotate(11deg); } 19% { transform: rotate(-8.5deg); }
  31% { transform: rotate(6.5deg); } 43% { transform: rotate(-4.8deg); } 55% { transform: rotate(3.4deg); }
  67% { transform: rotate(-2.2deg); } 79% { transform: rotate(1.2deg); } 90% { transform: rotate(-.5deg); }
}
@keyframes jsxYoyo {
  0% { height: 0; } 35% { height: calc(var(--rest) + 12px); } 50% { height: calc(var(--rest) - 40px); }
  65% { height: calc(var(--rest) + 8px); } 78% { height: calc(var(--rest) - 14px); } 90% { height: calc(var(--rest) + 3px); } 100% { height: var(--rest); }
}
@keyframes jsxBob { 0%,86%,100% { height: var(--rest); } 90% { height: calc(var(--rest) - 20px); } 95% { height: calc(var(--rest) + 5px); } }
@keyframes jsxPeek {
  0% { height: 0; } 25%,45% { height: calc(var(--rest) * .58); } 55%,68% { height: calc(var(--rest) * .36); }
  88% { height: calc(var(--rest) + 6px); } 100% { height: var(--rest); }
}
@keyframes jsxTilt { 0%,26%,46%,100% { transform: rotate(0); } 32% { transform: rotate(-14deg); } 39% { transform: rotate(12deg); } }
@keyframes jsxTwirl { 0%,100% { transform: scaleX(1); } 25%,75% { transform: scaleX(.12); } 50% { transform: scaleX(-1); } }
@keyframes jsxWave { 0%,100% { transform: rotate(0); } 20%,60% { transform: rotate(40deg); } 40%,80% { transform: rotate(12deg); } }
@keyframes jsxGust {
  0%,32%,100% { transform: rotate(0); } 6% { transform: rotate(4.5deg); } 12% { transform: rotate(-3.2deg); }
  18% { transform: rotate(2deg); } 24% { transform: rotate(-.9deg); } 29% { transform: rotate(.3deg); }
}

/* Visitors who ask for less motion get a still spider */
@media (prefers-reduced-motion: reduce) {
  .jsx-spider, .jsx-spider * { animation: none !important; transition: none !important; }
}
