.route-pulse, .cover-assembly { display: none; }

@media (prefers-reduced-motion: no-preference) {
  .board-strip.has-scroll-cursor { position: relative; }
  .board-strip.has-scroll-cursor::after {
    content: "";
    position: absolute;
    box-sizing: border-box;
    inset-block: 0;
    inset-inline-start: 0;
    inline-size: 10%;
    border: 1.5px solid var(--oxide);
    border-radius: .2rem;
    background: color-mix(in srgb, var(--oxide) 12%, transparent);
    box-shadow: 0 0 .5rem color-mix(in srgb, var(--oxide) 16%, transparent);
    pointer-events: none;
    transform: translateX(calc(var(--board-step, 0) * 100%));
  }

  @media (pointer: coarse) {
    .home-page .hardware-case:has(.has-scroll-cursor) { scroll-snap-align: none; }
  }

  .state-cycles.is-motion-in-view .state-cycle-row strong,
  .state-cycles.is-motion-in-view + .state-result strong {
    border-radius: .15rem;
    animation: cycle-accent .95s ease-out both;
  }
  .state-cycles.is-motion-in-view [data-series="resident"] strong { animation-delay: 140ms; }
  .state-cycles.is-motion-in-view + .state-result strong { animation-delay: 320ms; }

  @supports (animation-timeline: view()) and (animation-range: entry 0% cover 32%) {
    .profile-cover { view-timeline-name: --cover-leave; }
    .state-route { view-timeline-name: --state-travel; }
    .software-figure { view-timeline-name: --project-enter; }

    .profile-cover, .state-route, .software-figure {
      view-timeline-inset: calc(var(--mast-inset) + var(--mast-height)) 0px;
    }

    .cover-art {
      --cover-texture: url("./assets/state-study.webp");
      --cover-join-distance: clamp(2rem, 17svh, 13rem);
      position: relative;
      overflow: clip;
    }

    .cover-assembly, .cover-plates, .cover-plate, .cover-signal {
      display: block;
      position: absolute;
      inset: 0;
      pointer-events: none;
    }

    .cover-assembly {
      animation: cover-frame auto linear both;
      animation-timeline: --cover-leave;
      animation-range: exit 0px exit var(--cover-join-distance);
    }

    .cover-plates {
      animation: cover-plates-out auto linear both;
      animation-timeline: --cover-leave;
      animation-range: exit 0px exit var(--cover-join-distance);
    }

    .cover-plate, .cover-signal {
      animation: cover-join auto linear both;
      animation-timeline: --cover-leave;
      animation-range: exit 0px exit var(--cover-join-distance);
    }

    .cover-plate--right, .cover-signal { --cover-offset: 20%; }

    /* Each plate uses its own unobscured strip of the original texture.
       Stretch the strip across the plate while preserving its row spacing. */
    .cover-plate::before {
      content: "";
      position: absolute;
      inset-inline-start: var(--cover-plate-left);
      inset-block-start: calc(var(--cover-plate-top) * 100%);
      inline-size: 54.8%;
      block-size: calc(var(--cover-plate-height) * 100%);
      background-image: var(--cover-texture);
      background-repeat: no-repeat;
      background-size: calc(1514 / var(--cover-sample-width) * 100%) calc(100% / var(--cover-plate-height));
      background-position:
        calc(var(--cover-sample-x) / (1514 - var(--cover-sample-width)) * 100%)
        calc(var(--cover-plate-top) / (1 - var(--cover-plate-height)) * 100%);
    }

    .cover-plate--left {
      --cover-offset: -20%;
      --cover-plate-left: 11.8%;
      --cover-plate-top: .007;
      --cover-plate-height: .676;
      --cover-sample-x: 200;
      --cover-sample-width: 299;
    }

    .cover-plate--right {
      --cover-plate-left: 33.6%;
      --cover-plate-top: .281;
      --cover-plate-height: .719;
      --cover-sample-x: 1018;
      --cover-sample-width: 58;
    }

    .cover-art img {
      animation: cover-original auto linear both;
      animation-timeline: --cover-leave;
      animation-range: exit 0px exit var(--cover-join-distance);
    }

    .cover-signal::before, .cover-signal::after {
      content: "";
      position: absolute;
      inset-block-start: 56.03%;
      transform: translateY(-50%);
    }

    .cover-signal::before {
      inset-inline-start: 69.4%;
      inline-size: 15.4%;
      block-size: 7%;
      background: radial-gradient(ellipse closest-side, #ae3c32a3, #ae3c3240 50%, transparent);
      animation: cover-halo-breathe 4.6s ease-in-out infinite;
    }

    .cover-signal::after {
      inset-inline-start: 72.3%;
      inline-size: 9.6%;
      block-size: clamp(1px, .52%, 3px);
      border-radius: 999px;
      background: #ac392f;
      animation: cover-line-breathe 4.6s ease-in-out infinite;
    }

    .state-study:has([value="resident"]:checked) .route-pulse[data-path="resident"],
    .state-study:has([value="writeback"]:checked) .route-pulse[data-path="writeback"] {
      display: inline;
      stroke: color-mix(in srgb, var(--oxide) 60%, #f0a36b);
      stroke-width: 4.5;
      stroke-dasharray: .18 1.08;
      vector-effect: none;
      pointer-events: none;
      animation: route-travel auto linear both;
      animation-timeline: --state-travel;
      animation-range: entry 0% cover 32%;
    }

    .software-image > img {
      animation: project-arrival auto ease-out both;
      animation-timeline: --project-enter;
      animation-range: entry 0% cover 30%;
    }

    @media (max-width: 44rem), (max-height: 500px) {
      .cover-art { --cover-join-distance: clamp(1.5rem, 8svh, 4rem); }
    }

    @media (max-width: 360px) and (max-height: 620px) {
      .cover-art { --cover-join-distance: 1.75rem; }
    }

    @media (pointer: coarse) {
      .home-page .profile-cover { scroll-snap-align: none; }
    }
  }
}

/* Fit both separated plates inside the image frame before they overlap. */
@keyframes cover-frame {
  from { transform: scale(.82); }
  28% { transform: scale(.86); }
  76%, to { transform: scale(1); }
}

@keyframes cover-join {
  from { transform: translateX(var(--cover-offset)); }
  28% { transform: translateX(calc(var(--cover-offset) * .86)); }
  76%, to { transform: translateX(0); }
}

@keyframes cover-plates-out {
  0%, 76% { opacity: 1; }
  to { opacity: 0; }
}

@keyframes cover-original {
  0%, 76% { opacity: 0; }
  to { opacity: 1; }
}

@keyframes cover-halo-breathe {
  0%, 100% { opacity: .26; transform: translateY(-50%) scale(.90); }
  50% { opacity: .84; transform: translateY(-50%) scale(1.12); }
}

@keyframes cover-line-breathe {
  0%, 100% { opacity: .76; }
  50% { opacity: 1; }
}

@keyframes route-travel {
  from { stroke-dashoffset: .18; }
  to { stroke-dashoffset: -1; }
}

@keyframes cycle-accent {
  0%, 100% { background-color: transparent; text-shadow: none; }
  38% {
    background-color: color-mix(in srgb, var(--oxide) 14%, transparent);
    text-shadow: 0 0 .5rem color-mix(in srgb, var(--oxide) 28%, transparent);
  }
}

@keyframes project-arrival {
  from { transform: translateY(12px); opacity: .92; }
  to { transform: translateY(0); opacity: 1; }
}
