/* Magical animations for the laboratory */

@keyframes float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-12px);
  }
}

@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 20px rgba(125, 211, 252, 0.4), 0 0 40px rgba(167, 139, 250, 0.2);
  }
  50% {
    box-shadow: 0 0 30px rgba(125, 211, 252, 0.6), 0 0 60px rgba(167, 139, 250, 0.4);
  }
}

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

@keyframes slideInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.planet {
  animation: float 3s ease-in-out infinite, glow 3s ease-in-out infinite;
}

.orb {
  animation: float 4s ease-in-out infinite;
}

.orb-two {
  animation-duration: 5s;
}

.hero-copy {
  animation: slideInLeft 0.8s ease-out;
}

.hero-visual {
  animation: slideInRight 0.8s ease-out;
}

.category-card {
  animation: slideInUp 0.6s ease-out both;
}

.category-card:nth-child(1) { animation-delay: 0.1s; }
.category-card:nth-child(2) { animation-delay: 0.2s; }
.category-card:nth-child(3) { animation-delay: 0.3s; }
.category-card:nth-child(4) { animation-delay: 0.4s; }

.note {
  animation: scaleIn 0.5s ease-out both;
}

.note:nth-child(1) { animation-delay: 0.1s; }
.note:nth-child(2) { animation-delay: 0.2s; }
.note:nth-child(3) { animation-delay: 0.3s; }

.gallery-item {
  animation: scaleIn 0.5s ease-out both;
}

.gallery-item:nth-child(1) { animation-delay: 0.1s; }
.gallery-item:nth-child(2) { animation-delay: 0.2s; }
.gallery-item:nth-child(3) { animation-delay: 0.3s; }

.feature-card {
  animation: slideInUp 0.7s ease-out;
}

/* Section emoji behind page titles, and the method orbs */
.page-mark {
  animation: float 6s ease-in-out infinite;
}

.note-orb {
  animation: pulse 2.4s ease-in-out infinite;
}

.note.try .note-orb {
  animation-delay: 0.8s;
}

.note.create .note-orb {
  animation-delay: 1.6s;
}

.empty-orb {
  animation: float 4s ease-in-out infinite, glow 3s ease-in-out infinite;
}

/* Author chip and About page */
.author-avatar {
  animation: glow 3s ease-in-out infinite;
}

.profile-photo {
  animation: slideInLeft 0.8s ease-out;
}

.profile-intro {
  animation: slideInRight 0.8s ease-out;
}

.journey {
  animation: slideInUp 0.7s ease-out 0.2s both;
}

.photo-frame {
  animation: glow 3s ease-in-out infinite;
}

.timeline li::before {
  animation: pulse 2.4s ease-in-out infinite;
}

.timeline li:nth-child(2n)::before {
  animation-delay: 1.2s;
}

.button {
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.gallery-visual {
  transition: transform 0.3s ease, filter 0.3s ease;
}

/* Hover effects only for mouse users; on touch screens they stick after a tap */
@media (hover: hover) {
  .button:hover {
    transform: translateY(-3px) scale(1.02);
  }

  .button.primary:hover {
    box-shadow: 0 24px 48px rgba(125, 211, 252, 0.42);
  }

  .category-card:hover .icon {
    animation: float 1s ease-in-out infinite;
  }

  .gallery-item:hover .gallery-visual {
    transform: scale(1.1) rotate(5deg);
    filter: brightness(1.2);
  }
}

/* Phones and tablets: slide in from below, so nothing pokes out sideways */
@media (max-width: 899.98px) {
  .hero-copy,
  .hero-visual,
  .profile-photo,
  .profile-intro {
    animation-name: slideInUp;
  }
}

/* Book reading page: progress line and pictures that appear while scrolling */
@keyframes reading-progress {
  to {
    transform: scaleX(1);
  }
}

@supports (animation-timeline: scroll()) {
  .reading-progress {
    animation: reading-progress linear both;
    animation-timeline: scroll(root);
  }

  .story-figure {
    animation: scaleIn linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 60%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .story-figure {
    animation: none !important;
  }
}
