/*
 * Hero — headline, calls to action, and the robot orbited by channel chips.
 * Also owns the scroll effect where the hero robot flies into the header logo.
 */
@layer sections {
  .hero {
    padding-block: 40px 72px;
  }

  .hero__layout {
    display: flex;
    align-items: center;
    gap: 40px;
  }

  .hero__content {
    flex: 1 1 0;
    min-width: 0;
  }

  .hero__title {
    margin: 0;
    font-family: var(--font-display);
    font-size: calc(82rem / 16);
    line-height: 0.98;
    font-weight: 600;
    letter-spacing: -0.03em;
  }

  .hero__lead {
    margin: 28px 0 0;
    max-width: 470px;
    font-size: calc(21rem / 16);
    line-height: 1.6;
    color: var(--color-ink-soft);
  }

  .hero__actions {
    margin-top: 36px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
  }

  .hero__visual {
    flex: none;
    width: 600px;
    max-width: 100%;
    height: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
  }

  /* ---------- Orbit ---------- */
  .orbit {
    position: relative;
    width: 600px;
    height: 600px;
    isolation: isolate;
    flex: none;
  }

  .orbit__disc {
    position: absolute;
    inset: 140px;
    border-radius: 50%;
    background: var(--color-violet-wash);
    z-index: 0;
  }

  .orbit__ring {
    position: absolute;
    left: 20px;
    top: 190px;
    width: 560px;
    height: 220px;
    box-sizing: border-box;
    border-radius: 50%;
    border: 1.5px dashed var(--color-violet-line);
    z-index: 1;
  }

  .orbit__bot {
    position: absolute;
    left: 50%;
    top: 50%;
    translate: -50% -50%;
    z-index: 2;
    animation: orbit-float 6s ease-in-out infinite;
  }

  .orbit__track {
    position: absolute;
    left: 20px;
    top: 190px;
    width: 560px;
    height: 220px;
  }

  .orbit__chip {
    position: absolute;
    left: 0;
    top: 0;
    offset-path: path("M 560 110 A 280 110 0 1 1 0 110 A 280 110 0 1 1 560 110");
    offset-rotate: 0deg;
    offset-anchor: center;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    background: var(--color-white);
    border: 1px solid var(--color-line);
    border-radius: var(--radius-pill);
    padding: 7px 14px 7px 8px;
    font-size: calc(15rem / 16);
    font-weight: 600;
    box-shadow: 0 10px 24px rgba(28, 26, 58, 0.10);
    --orbit-step: 0;
    animation: orbit-chip 32s linear infinite;
    animation-delay: calc(var(--orbit-step) * -4s);
  }

  /* Eight chips spaced evenly: each starts one eighth (4s) further round the 32s lap. */
  .orbit__chip:nth-child(2) { --orbit-step: 1; }
  .orbit__chip:nth-child(3) { --orbit-step: 2; }
  .orbit__chip:nth-child(4) { --orbit-step: 3; }
  .orbit__chip:nth-child(5) { --orbit-step: 4; }
  .orbit__chip:nth-child(6) { --orbit-step: 5; }
  .orbit__chip:nth-child(7) { --orbit-step: 6; }
  .orbit__chip:nth-child(8) { --orbit-step: 7; }

  /* Without animation, park each chip at its own point on the ellipse. */
  @media (prefers-reduced-motion: reduce) {
    .orbit__chip {
      offset-distance: calc(var(--orbit-step) * 12.5%);
    }
  }

  html[data-a11y-motion="off"] .orbit__chip {
    offset-distance: calc(var(--orbit-step) * 12.5%);
  }

  @keyframes orbit-chip {
    0% { offset-distance: 0%; z-index: 3; scale: 1.06; opacity: 1; }
    25% { scale: 1.14; z-index: 3; }
    48% { z-index: 3; }
    50% { offset-distance: 50%; scale: 0.92; z-index: 1; opacity: 0.9; }
    75% { scale: 0.8; opacity: 0.65; z-index: 1; }
    98% { z-index: 1; }
    100% { offset-distance: 100%; scale: 1.06; opacity: 1; z-index: 3; }
  }

  @keyframes orbit-float {
    0%,
    100% {
      margin-top: 0;
    }

    50% {
      margin-top: -10px;
    }
  }

  /* Shown only by the desktop scroll effect below. */
  .flying-robot {
    display: none;
  }

  @media (max-width: 900px) {
    .hero__layout {
      flex-direction: column;
    }

    .hero__visual {
      height: 330px;
    }

    .hero__title {
      font-size: calc(54rem / 16);
    }

    .orbit {
      scale: 0.52;
    }
  }

  @supports (animation-timeline: scroll()) {
    .hero__visual {
      animation: hero-recede linear both;
      animation-timeline: view();
      animation-range: exit 0% exit 100%;
    }

    @keyframes hero-recede {
      to {
        scale: 0.78;
        opacity: 0.15;
        translate: 0 -60px;
      }
    }

    /* The orbit opens from a flat ellipse into a circle as the page scrolls. */
    .orbit__chip {
      animation: orbit-chip 32s linear infinite, orbit-open linear both;
      animation-delay: calc(var(--orbit-step) * -4s);
      animation-timeline: auto, scroll();
      animation-range: normal, 0 520px;
    }

    @keyframes orbit-open {
      to {
        offset-path: path("M 560 110 A 280 280 0 1 1 0 110 A 280 280 0 1 1 560 110");
      }
    }

    .orbit__ring {
      animation: orbit-ring-open linear both;
      animation-timeline: scroll();
      animation-range: 0 520px;
    }

    @keyframes orbit-ring-open {
      to {
        top: 20px;
        height: 560px;
        border-color: var(--color-violet-soft);
      }
    }

    @media (min-width: 901px) and (prefers-reduced-motion: no-preference) {
      html:not([data-a11y-motion="off"]) .flying-robot {
        display: block;
        position: fixed;
        z-index: 40;
        left: max(332px, 50% - 320px);
        top: 428px;
        translate: -50% -50%;
        pointer-events: none;
        line-height: 0;
        animation: robot-fly linear both;
        animation-timeline: scroll();
        animation-range: 0 680px;
      }

      /* Left-to-right pages: the hero visual is on the right and the logo on the left. */
      html:not([data-a11y-motion="off"]) [dir="ltr"] .flying-robot {
        left: calc(100% - max(332px, 50% - 320px));
        animation-name: robot-fly-ltr;
      }

      @keyframes robot-fly-ltr {
        0% { left: calc(100% - max(332px, 50% - 320px)); top: 428px; scale: 1; rotate: 0deg; opacity: 0; }
        3% { opacity: 1; }
        55% { rotate: 14deg; }
        96% { opacity: 1; }
        100% { left: calc(100% - min(50% + 601px, 100% - 51px)); top: 34px; scale: 0.2; rotate: 0deg; opacity: 0; }
      }

      @keyframes robot-fly {
        0% { left: max(332px, 50% - 320px); top: 428px; scale: 1; rotate: 0deg; opacity: 0; }
        3% { opacity: 1; }
        55% { rotate: -14deg; }
        96% { opacity: 1; }
        100% { left: min(50% + 601px, 100% - 51px); top: 34px; scale: 0.2; rotate: 0deg; opacity: 0; }
      }

      .orbit .orbit__bot {
        animation: orbit-float 6s ease-in-out infinite, orbit-bot-hide linear both;
        animation-timeline: auto, scroll();
        animation-range: normal, 0 24px;
      }

      @keyframes orbit-bot-hide {
        to {
          opacity: 0;
        }
      }

      .brand__robot {
        animation: brand-robot-in linear both;
        animation-timeline: scroll();
        animation-range: 640px 690px;
      }

      @keyframes brand-robot-in {
        from {
          opacity: 0;
          scale: 0.6;
        }

        to {
          opacity: 1;
          scale: 1;
        }
      }
    }
  }
}
