/* Motion supports the research narrative; every effect has a static fallback. */

.reading-progress {
  position: absolute;
  inset: auto 0 -1px;
  height: 2px;
  pointer-events: none;
  background: linear-gradient(90deg, #315df4, #138b9e);
  transform: scaleX(var(--reading-progress, 0));
  transform-origin: left center;
}

.walkthrough-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 13px;
  margin-top: 13px;
}

.walkthrough-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 7px 12px;
  border: 1px solid #3b5678;
  border-radius: 5px;
  background: #1b2e48;
  color: #d4e3f7;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.5;
}

.walkthrough-toggle .icon {
  width: 13px;
  height: 13px;
}

.walkthrough-hint {
  flex: 1 1 145px;
  color: #a4b6ce;
  font-size: 0.75rem;
  line-height: 1.65;
}

.scenario-controls button {
  position: relative;
  overflow: hidden;
}

.attack-halo,
.defense-halo {
  fill: none;
  stroke-width: 1.5px;
  opacity: 0;
  pointer-events: none;
  transform-box: fill-box;
  transform-origin: center;
}

.attack-halo {
  stroke: #e98770;
}

.defense-halo {
  stroke: #74dfc1;
}

/* Offscreen schematics do not need to keep drawing attention or consuming work. */
.lab-panel:not(.is-in-view) *,
.lab-panel:not(.is-in-view) *::before,
.lab-panel:not(.is-in-view) *::after {
  animation-play-state: paused !important;
}

@media (prefers-reduced-motion: no-preference) {
  html.motion-ready:not(.motion-paused) .hero-copy > .identity,
  html.motion-ready:not(.motion-paused) .hero-copy > .hero-eyebrow,
  html.motion-ready:not(.motion-paused) .hero-copy > h1,
  html.motion-ready:not(.motion-paused) .hero-copy > .hero-description,
  html.motion-ready:not(.motion-paused) .hero-copy > .hero-actions,
  html.motion-ready:not(.motion-paused) .hero-copy > .hero-affiliation {
    animation: hero-arrive 700ms cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  html.motion-ready:not(.motion-paused) .hero-copy > .identity {
    animation-delay: 30ms;
  }

  html.motion-ready:not(.motion-paused) .hero-copy > .hero-eyebrow {
    animation-delay: 100ms;
  }

  html.motion-ready:not(.motion-paused) .hero-copy > h1 {
    animation-delay: 170ms;
    animation-duration: 850ms;
  }

  html.motion-ready:not(.motion-paused) .hero-copy > .hero-description {
    animation-delay: 260ms;
  }

  html.motion-ready:not(.motion-paused) .hero-copy > .hero-actions {
    animation-delay: 330ms;
  }

  html.motion-ready:not(.motion-paused) .hero-copy > .hero-affiliation {
    animation-delay: 390ms;
  }

  html.motion-ready:not(.motion-paused) .hero > .lab-panel {
    animation: lab-arrive 900ms 360ms cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  .reveal-enabled .current-grid > .current-card:nth-child(2) {
    transition-delay: 80ms;
  }

  .reveal-enabled .current-grid > .current-card:nth-child(3) {
    transition-delay: 160ms;
  }

  .lab-panel[data-scenario="attack"] .attack-halo {
    animation: warning-ring 2.4s ease-out infinite;
  }

  .lab-panel[data-scenario="defense"] .defense-halo {
    animation: protection-ring 3.3s ease-out infinite;
  }

  .lab-panel[data-story-playing="true"]
    .scenario-controls
    button[data-story-active="true"]::after {
    position: absolute;
    right: 6px;
    bottom: 2px;
    left: 6px;
    height: 2px;
    border-radius: 2px;
    background: #8cddd7;
    content: "";
    transform-origin: left center;
    animation: story-step var(--story-step-duration, 4500ms) linear both;
  }

  .diagram-dialog[open] {
    animation: dialog-arrive 240ms cubic-bezier(0.22, 1, 0.36, 1) both;
  }

  .project-links a .icon,
  .text-link .icon {
    transition: transform 180ms ease;
  }

  .project-links a:hover .icon,
  .project-links a:focus-visible .icon,
  .text-link:hover .icon,
  .text-link:focus-visible .icon {
    transform: translateY(-2px);
  }

  .walkthrough-toggle {
    transition:
      background-color 180ms ease,
      border-color 180ms ease;
  }

  .walkthrough-toggle:hover {
    border-color: #7090b9;
    background: #243e61;
  }

  @media (hover: hover) and (pointer: fine) and (min-width: 701px) {
    .research-visual,
    .lab-panel {
      isolation: isolate;
    }

    .research-visual > *,
    .lab-panel > * {
      position: relative;
      z-index: 1;
    }

    .research-visual::before,
    .lab-panel::before {
      position: absolute;
      z-index: 0;
      inset: 0;
      border-radius: inherit;
      opacity: 0;
      pointer-events: none;
      content: "";
      transition: opacity 300ms ease;
    }

    .research-visual::before {
      background: radial-gradient(
        240px circle at var(--spotlight-x, 50%) var(--spotlight-y, 50%),
        rgb(49 93 244 / 8%),
        transparent 78%
      );
    }

    .lab-panel::before {
      background: radial-gradient(
        290px circle at var(--spotlight-x, 50%) var(--spotlight-y, 50%),
        rgb(119 177 255 / 12%),
        transparent 78%
      );
    }

    .research-visual[data-spotlight-active="true"]::before,
    .lab-panel[data-spotlight-active="true"]::before {
      opacity: 1;
    }
  }
}

@keyframes hero-arrive {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes lab-arrive {
  from {
    opacity: 0;
    transform: translateY(22px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes warning-ring {
  0% {
    opacity: 0;
    transform: scale(0.7);
  }
  18% {
    opacity: 0.6;
  }
  85%,
  100% {
    opacity: 0;
    transform: scale(1.7);
  }
}

@keyframes protection-ring {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  22% {
    opacity: 0.5;
  }
  90%,
  100% {
    opacity: 0;
    transform: scale(1.55);
  }
}

@keyframes story-step {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

@keyframes dialog-arrive {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* Pausing an entrance must expose its content immediately. */
html.motion-paused .hero-copy > *,
html.motion-paused .hero > .lab-panel {
  animation: none !important;
  opacity: 1 !important;
  transform: none !important;
}

html.motion-paused *,
html.motion-paused *::before,
html.motion-paused *::after {
  transition: none !important;
}

html.motion-paused .reading-progress {
  visibility: hidden;
}

html.motion-paused .research-visual::before,
html.motion-paused .lab-panel::before {
  opacity: 0;
}

html.motion-paused .button:hover,
html.motion-paused .current-card:hover,
html.motion-paused .project-links a .icon,
html.motion-paused .text-link .icon {
  transform: none !important;
}

@media (prefers-reduced-motion: reduce) {
  .reading-progress {
    display: none;
  }

  .hero-copy > *,
  .hero > .lab-panel,
  .diagram-dialog[open] {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }

  .button:hover,
  .current-card:hover {
    transform: none !important;
  }
}

@media print {
  .reading-progress,
  .walkthrough-controls {
    display: none !important;
  }

  .hero-copy > *,
  .hero > .lab-panel {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}
