/* ==========================================================================
   FINAL PHASE — CONSTELLATION, CURSOR, READING PROGRESS, WIGGLE
   Everything here is transform/opacity only. The canvas pauses on hidden tabs.
   ========================================================================== */

@layer components {
  /* ---------- Constellation canvas ---------- */
  .constellation {
    position: fixed;
    inset: 0;
    z-index: 0;
    display: block;
    inline-size: 100%;
    block-size: 100%;
    pointer-events: none;
  }

  main,
  .site-footer {
    position: relative;
    z-index: 1;
  }

  /* ---------- Reading progress ---------- */
  .read-progress {
    position: fixed;
    inset-block-start: 0;
    inset-inline: 0;
    z-index: 110;
    block-size: 3px;
    background: transparent;
    pointer-events: none;
  }

  .read-progress span {
    display: block;
    inline-size: 100%;
    block-size: 100%;
    transform: scaleX(0);
    transform-origin: right;
    background: linear-gradient(
      90deg,
      var(--office-word),
      var(--office-excel)
    );
    will-change: transform;
  }

  /* ---------- Magnetic elements ---------- */
  [data-magnetic] {
    will-change: translate;
  }

  /* ---------- First-view wiggle on the slider ---------- */
  .compare.is-wiggle .compare__handle,
  .compare.is-wiggle .compare__divider {
    animation: compare-wiggle 1.2s var(--ease-spring) 1;
  }

  .compare.is-wiggle .compare__hint {
    animation: hint-nudge 1.2s var(--ease-out) 1;
  }

  @keyframes compare-wiggle {
    0%,
    100% {
      translate: 0 0;
    }

    22% {
      translate: 7px 0;
    }

    48% {
      translate: -6px 0;
    }

    72% {
      translate: 4px 0;
    }
  }

  @keyframes hint-nudge {
    0%,
    100% {
      opacity: 0.85;
      transform: translateX(-50%) translateY(0);
    }

    50% {
      opacity: 1;
      transform: translateX(-50%) translateY(-3px);
    }
  }
}

/* ---------- Two-layer cursor, fine pointers only ---------- */
@media (hover: hover) and (pointer: fine) {
  html.has-custom-cursor,
  html.has-custom-cursor * {
    cursor: none !important;
  }

  .cursor-dot,
  .cursor-halo {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 9999;
    border-radius: 50%;
    pointer-events: none;
    opacity: 0;
    transition:
      opacity var(--dur-2) var(--ease-out),
      inline-size var(--dur-2) var(--ease-spring),
      block-size var(--dur-2) var(--ease-spring),
      background-color var(--dur-2) var(--ease-out);
  }

  .cursor-dot {
    inline-size: 6px;
    block-size: 6px;
    background: var(--office-word);
  }

  .cursor-halo {
    inline-size: 36px;
    block-size: 36px;
    border: 1px solid color-mix(in oklab, var(--office-word) 35%, transparent);
    background: color-mix(in oklab, var(--office-word) 6%, transparent);
  }

  .cursor-halo.is-active {
    inline-size: 56px;
    block-size: 56px;
    background: color-mix(in oklab, var(--office-word) 10%, transparent);
  }

  .cursor-dot.is-down {
    background: var(--office-ppt);
  }

  html.has-custom-cursor .cursor-dot,
  html.has-custom-cursor .cursor-halo {
    opacity: 1;
  }
}

@media (hover: none), (pointer: coarse) {
  .cursor-dot,
  .cursor-halo {
    display: none !important;
  }
}
