/* Taskly — 3D motion: sign-in globe and parallax, leaning cards, pages that
 * swing in, and the 3D next-step orb. Loaded last. Every animation is listed
 * in the reduced-motion block at the end, and none is needed to read a page.
 */

/* ======================================================== Sign-in globe */
.auth-globe { display: none; }
@media (min-width: 980px) {
  body.locked .auth-show { perspective: 1100px; }
  body.locked .auth-globe {
    display: block; position: absolute; z-index: 1; pointer-events: none;
    width: min(560px, 56%); aspect-ratio: 1; right: -15%; top: 48%; translate: 0 -50%;
    animation: globe-in 1400ms cubic-bezier(0.2, 0.8, 0.2, 1) 200ms backwards;
  }
  /* The floating cards sit at different depths and drift with the pointer. */
  body.locked .auth-float {
    --depth: 1; transform-style: preserve-3d;
    translate: calc(var(--px, 0) * -34px * var(--depth)) calc(var(--py, 0) * -26px * var(--depth));
    rotate: y calc(var(--px, 0) * 18deg * var(--depth));
    transition: translate 500ms cubic-bezier(0.2, 0.8, 0.2, 1), rotate 500ms cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  body.locked .auth-float.f1 { --depth: 1.3; }
  body.locked .auth-float.f2 { --depth: 0.8; }
  body.locked .auth-float.f3 { --depth: 1.05; }
  body.locked .auth-show-text { translate: calc(var(--px, 0) * 10px) calc(var(--py, 0) * 8px); transition: translate 600ms cubic-bezier(0.2, 0.8, 0.2, 1); }
}
/* Smaller laptops: a smaller globe, further right, clear of the headline. */
@media (min-width: 980px) and (max-width: 1279px) {
  body.locked .auth-globe { width: min(440px, 48%); right: -22%; }
}
@keyframes globe-in { from { opacity: 0; scale: 0.7; } }

/* Phones and tablets: a short brand band with the globe sits above the sign-in card,
 * and the card overlaps its lower edge. The floating cards stay desktop-only. */
@media (max-width: 979px) {
  body.locked .auth-gate { display: block; overflow-y: auto; padding: 0 0 24px; place-items: normal; -webkit-overflow-scrolling: touch; }
  body.locked .auth-show {
    position: relative; display: block; width: 100%; overflow: hidden; color: #fff; perspective: 900px;
    padding: 34px 22px 64px; min-height: 230px;
    background: linear-gradient(135deg, #0B1030 0%, #18257A 34%, #2C58DD 62%, #6F3CC2 100%);
    background-size: 160% 160%; animation: hero-pan 18s ease-in-out infinite alternate;
  }
  body.locked .auth-show::before { width: 300px; height: 300px; right: -120px; top: -140px; }
  body.locked .auth-show::after { width: 240px; height: 240px; left: -100px; bottom: -150px; }
  body.locked .auth-show .auth-float { display: none; }
  body.locked .auth-show-text { max-width: 62%; }
  body.locked .auth-kicker { margin-bottom: 8px; font-size: 0.7rem; }
  body.locked .auth-headline { font-size: clamp(1.55rem, 6.4vw, 2.3rem); }
  body.locked .auth-sub { margin-top: 10px; font-size: 0.9rem; line-height: 1.45; }
  body.locked .auth-globe {
    display: block; position: absolute; z-index: 1; pointer-events: none;
    width: min(260px, 52vw); aspect-ratio: 1; right: -14%; top: 50%; translate: 0 -54%;
    animation: globe-in 1200ms cubic-bezier(0.2, 0.8, 0.2, 1) 150ms backwards;
  }
  body.locked .auth-gate .auth-card { position: relative; z-index: 3; margin: -40px auto 0; width: min(440px, calc(100% - 28px)); }
}
@media (max-width: 380px) {
  body.locked .auth-sub { display: none; }
  body.locked .auth-show { min-height: 190px; padding-bottom: 58px; }
}

/* ======================================================== Leaning cards */
.next-step, .kpi, .q-score, .home-hero { transform-origin: center; }
:is(.next-step, .kpi, .q-score).leaning {
  transform: perspective(700px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateY(-2px);
  transition: transform 90ms linear, box-shadow var(--ease), border-color var(--ease);
  box-shadow: 0 16px 34px rgba(18, 24, 66, 0.16);
}
.home-hero.leaning { transform: perspective(1400px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform 120ms linear; }
.next-step, .kpi, .q-score, .home-hero { transition: transform 420ms cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow var(--ease), border-color var(--ease), background var(--ease); }
:root[data-theme="dark"] :is(.next-step, .kpi, .q-score).leaning { box-shadow: 0 16px 34px rgba(0, 0, 0, 0.45); }

/* ==================================================== Pages swing in 3D */
.tab-panel.enter { perspective: 1200px; }
.tab-panel.enter > * { animation-name: swing-in; transform-origin: 50% 0%; }
@keyframes swing-in { from { opacity: 0; transform: translateY(18px) rotateX(10deg) scale(0.98); } }

/* ====================================================== 3D next-step orb */
/* A small planet with a ring that orbits it in 3D. */
.next-orb { position: relative; transform-style: preserve-3d; }
.next-orb::before, .next-orb::after {
  content: ""; position: absolute; inset: -9px; border-radius: 50%; pointer-events: none;
  border: 2px solid transparent; border-top-color: rgba(52, 208, 207, 0.85); border-right-color: rgba(251, 189, 8, 0.7);
  animation: orb-orbit 4.8s linear infinite;
}
.next-orb::after { inset: -5px; border-top-color: rgba(161, 73, 212, 0.7); border-right-color: transparent; border-left-color: rgba(44, 88, 221, 0.6); animation-duration: 6.4s; animation-direction: reverse; }
@keyframes orb-orbit { from { transform: rotateX(68deg) rotateZ(0deg); } to { transform: rotateX(68deg) rotateZ(360deg); } }

@media (prefers-reduced-motion: reduce) {
  body.locked .auth-globe, .tab-panel.enter > *, .next-orb::before, .next-orb::after { animation: none !important; }
  body.locked .auth-float, body.locked .auth-show-text { translate: none; rotate: none; }
  :is(.next-step, .kpi, .q-score, .home-hero).leaning { transform: none; }
}
