/* ANIMATIONS PAGE
------------------------------------*/

/* Animations page hero */
.animations-page header::before {
  background-image: url("../images/site-assets/bg-hero-animations.jpg");
  background-position: center 55%;
  background-size: cover;
  filter: saturate(60%);
}
/* Wider animation showcase */
.animations-page .project-wrapper {
  inline-size: min(95vw, 110rem);
  margin-inline-start: 50%;
  transform: translateX(-50%);
}

/* ANIMATION 1: VICTORIAN VILLAGE
------------------------------------*/
.cat-stage {
  inline-size: 100%;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  position: relative;
  container-type: inline-size;

  /* Village background */
  &::before {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url("../images/village-night.png");
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    filter: brightness(85%) saturate(70%);
    z-index: 0;
  }
  /* Grass foreground */
  &::after {
    content: "";
    position: absolute;
    inset-block-end: -1rem;
    inset-inline-start: 0;
    inline-size: 100%;
    block-size: 6rem;
    background-image: url("../images/grass-foreground.png");
    mix-blend-mode: exclusion;
    background-repeat: repeat-x;
    background-position: bottom;
    background-size: auto 175%;
    z-index: 2;
    pointer-events: none;
  }
}
/* TWINKLING STARS
------------------------------------*/
.twinkle-star {
  position: absolute;
  inline-size: 0.25rem;
  block-size: 0.25rem;
  border-radius: 50%;
  background-color: var(--colour-neutral-50);
  box-shadow: 0 0 0.5rem 0.15rem
    oklch(from var(--colour-neutral-50) l c h / 0.9);
  opacity: 1;
  z-index: 1;
  animation: starGlow 5s ease-in-out infinite;
}
/* Star glow animation */
@keyframes starGlow {
  0%,
  100% {
    opacity: 0;
    transform: scale(0.5);
  }

  15%,
  25% {
    opacity: 1;
    transform: scale(0.3);
  }

  40% {
    opacity: 0;
    transform: scale(0.5);
  }
}
/* Star positions */
.star-one {
  inset-block-start: 15%;
  inset-inline-start: 25%;
  animation-delay: 0.5s;
}
.star-two {
  inset-block-start: 20%;
  inset-inline-start: 75%;
  animation-delay: -2.4s;
}
.star-three {
  inset-block-start: 8%;
  inset-inline-start: 20%;
  animation-delay: -1s;
}

.star-four {
  inset-block-start: 50%;
  inset-inline-start: 65%;
}

.star-five {
  inset-block-start: 30%;
  inset-inline-start: 9%;
  animation-delay: -0.2s;
}

/* SHOOTING STARS
------------------------------------*/
.shooting-star {
  position: absolute;
  inline-size: 0.125rem;
  block-size: 0.125rem;
  border-radius: 50%;
  background-color: var(--colour-neutral-50);
  box-shadow: 0 0 0.75rem 0.2rem
    oklch(from var(--colour-neutral-50) l c h / 0.3);
  opacity: 0;
  z-index: 1;

  /* Shooting star trail */
  &::after {
    content: "";
    position: absolute;
    inset-block-start: 50%;
    inset-inline-end: 50%;
    inline-size: 3rem;
    block-size: 0.125rem;
    background: linear-gradient(to left, var(--colour-neutral-50), transparent);
    transform: translateY(-50%);
    border-radius: 50%;
  }
}

/* First shooting star position */
.shooting-one {
  inset-block-start: 27%;
  inset-inline-start: 25%;
  offset-path: path("M 0 0 L 150 -35");
  offset-rotate: -10deg;
  animation: shootingFlight 8s ease-in-out infinite;
}

/* Shooting star flight */
@keyframes shootingFlight {
  0% {
    offset-distance: 0%;
    opacity: 0;
  }

  3% {
    opacity: 1;
  }

  30%,
  100% {
    offset-distance: 100%;
    opacity: 0;
  }
}
.cat-sprite {
  position: absolute;
  inset-block-end: 9.5rem;
  inset-inline-start: 3rem;
  inline-size: 70px;
  block-size: 67.5px;
  background-image: url("../images/cat-animation/cat-walk-sprite-sheet.png");
  background-repeat: no-repeat;
  background-size: 5880px 67.5px;
  z-index: 2;
  animation:
    catWalk 8s steps(84) 2s infinite backwards,
    catTravel 8s linear 2s infinite backwards;
}
@keyframes catWalk {
  from {
    background-position-x: 0;
  }

  to {
    background-position-x: -5880px;
  }
}
/* Cat movement */
@keyframes catTravel {
  0% {
    transform: translateX(0);
  }

  35% {
    transform: translateX(20px);
  }

  /* Pause while sitting */
  65% {
    transform: translateX(20px);
  }

  /* Continue walking */
  100% {
    transform: translateX(60px);
  }
}
/* Victorian streetlight */
.streetlight {
  position: absolute;
  inset-inline-start: -1rem;
  inset-block-end: calc(clamp(5rem, 66cqw, 10rem) - 1.25rem);
  block-size: 38%;
  inline-size: auto;
  transform: scaleX(-1);
  z-index: 3;
  pointer-events: none;
}
/* Stationary car container */
.car-wrapper {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
/* Vintage car */
.vintage-car {
  position: absolute;
  inset-inline-start: 37%;
  inset-block-end: 8%;
  inline-size: 70%;
  block-size: auto;
  z-index: 3;
}

/* ANIMATION 2: MORPHING ADVENTURE CARDS
------------------------------------*/

.morph-stage {
  position: relative;
  inline-size: 100%;
  block-size: 40rem;
  overflow: hidden;
  display: grid;
  place-items: center;

  /* Holberg beach background */
  background-image: url("../images/holberg-beach(16x9).png");
  filter: saturate(90%) contrast(105%);
  background-size: cover;
  background-repeat: no-repeat;

  background-position: center 30%;
}

.morph-card {
  display: grid;
  grid-template-areas: "card";
  inline-size: 87%;
  block-size: 24rem;
  border-radius: 1.5rem;
  overflow: hidden;
  animation: cardMorph 10s ease-in-out infinite;

  /* Frosted glass effect */
  background: oklch(from var(--colour-neutral-50) l c h / 0.2);
  backdrop-filter: blur(12px);
  border: 1px solid oklch(from var(--colour-neutral-50) l c h / 0.4);
  box-shadow: 0 8px 32px oklch(from var(--colour-neutral-900) l c h / 0.12);
}

/* Adventure card content */
.morph-content {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  grid-area: card;
  gap: 1rem;
  align-items: center;
  inline-size: 100%;
  block-size: 100%;
  padding: 1rem;
  text-align: center;
}
/* Show Adventure content during the first half */
.morph-content-adventure {
  animation: adventureSwap 10s linear infinite;
}

/* Reveal Wilderness Skills during the second half */
.morph-content-gear {
  opacity: 0;
  animation: gearSwap 10s linear infinite;
  z-index: 1;
}
/* Adventure feature */
.morph-feature {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-inline-size: 0;
}

/* Adventure feature text */
.morph-feature h4,
.morph-feature p {
  margin: 0;
}
.morph-feature h4 {
  margin-block-start: 1rem;
}
/* Main adventure illustration */
.morph-feature-icon {
  inline-size: 90%;
  max-inline-size: 16rem;
  margin-block-end: -2.5rem;
  block-size: auto;
}
/* Category headings */

.morph-category h5 {
  line-height: 1.1;
}
/* Adventure categories */
.morph-categories {
  display: grid;
  align-content: center;
  gap: 1rem;
  min-inline-size: 0;
}

/* Individual category cards */
.morph-category {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  justify-items: center;
  text-align: center;
  gap: 0.5rem;
  padding: 0.5rem;
  min-inline-size: 0;
  background: oklch(from var(--colour-neutral-50) l c h / 0.08);
  border: 1px solid oklch(from var(--colour-neutral-50) l c h / 0.25);
  border-radius: 0.75rem;
}

/* Center mini card text */
.morph-category > div {
  text-align: center;
  min-inline-size: 0;
  inline-size: 100%;
}
.morph-category h5 {
  margin: 0;
}

/* Layer Water Adventures icons */
.morph-category-icons {
  position: relative;
  inline-size: 4rem;
  block-size: 4rem;
  flex-shrink: 0;
}
.survival-icon {
  inset-block-start: 50%;
  inset-inline-start: 50%;
  transform: translate(-50%, -50%);
}

.morph-category-icons img {
  position: absolute;
  inline-size: 100%;
  block-size: 100%;
  object-fit: contain;
}

/* Position category icons */
.kayak-icon {
  inset: 0;
}

/* Enlarge kayak illustration */
.kayak-icon {
  transform: scale(1.15);
}
/* Temporarily hide category illustrations */
.morph-category > img,
.morph-category-icons {
  display: none;
}
/* Show Discover and Road Trip icons */
.morph-category:nth-child(-n + 2) > img {
  display: block;
  inline-size: 3.5rem;
  block-size: 3.5rem;
  object-fit: contain;
}
/* Show Water Adventures kayak */
.morph-category:nth-child(3) .morph-category-icons {
  display: block;
}

/* Hide Explore before the first circle */
@keyframes adventureSwap {
  0%,
  28% {
    opacity: 1;
  }

  35%,
  92% {
    opacity: 0;
  }

  100% {
    opacity: 1;
  }
}
/* Show Wilderness Skills between transformations */
@keyframes gearSwap {
  0%,
  40% {
    opacity: 0;
  }

  50%,
  78% {
    opacity: 1;
  }

  85%,
  100% {
    opacity: 0;
  }
}
/* Morph and spin between adventure categories */
@keyframes cardMorph {
  0%,
  28% {
    inline-size: 87%;
    block-size: 24rem;
    border-radius: 1.5rem;
    rotate: 0deg;
  }

  37%,
  42% {
    inline-size: 5rem;
    block-size: 5rem;
    border-radius: 50%;
    rotate: 180deg;
  }

  52%,
  78% {
    inline-size: 87%;
    block-size: 24rem;
    border-radius: 1.5rem;
    rotate: 360deg;
  }

  87%,
  92% {
    inline-size: 5rem;
    block-size: 5rem;
    border-radius: 50%;
    rotate: 540deg;
  }

  100% {
    inline-size: 87%;
    block-size: 24rem;
    border-radius: 1.5rem;
    rotate: 720deg;
  }
}
/* ANIMATION 3: IMAGE REVEAL
------------------------------------*/

.animation-stage {
  inline-size: 100%;
  aspect-ratio: 9 / 16;
  overflow: hidden;
  background-color: var(--colour-neutral-50);
}
.reveal-image {
  position: relative;
  inline-size: 100%;
  block-size: 100%;
  overflow: hidden;
  animation: exploreImage 10s ease-in-out infinite;

  /* Soft green background behind logo */
  &::after {
    content: "";
    position: absolute;
    inset-block-start: 42%;
    inset-inline-start: 50%;
    inline-size: 85%;
    block-size: 22%;
    background: oklch(from var(--colour-green) 25% c h / 0.65);
    border-radius: 50%;
    filter: blur(1.5rem);
    transform: translate(-50%, -50%);
    z-index: 1;
    pointer-events: none;
  }
}

/* Forest background */
.forest-background {
  position: relative;
  z-index: 0;
  inline-size: 100%;
  block-size: 100%;
  object-fit: cover;
  object-position: center;
  transform: translateY(5%) scale(1.2);
  transform-origin: center;
}
/* OutdoorZE logo overlay */
.forest-logo {
  position: absolute;
  inset-block-start: 42%;
  inset-inline-start: 50%;
  inline-size: 75%;
  block-size: auto;
  transform: translate(-50%, -50%);
  z-index: 2;

  animation: logoFade 10s cubic-bezier(0.35, 0, 0.25, 1) infinite;
}

@keyframes logoFade {
  0%,
  25% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.4);
  }

  45% {
    opacity: 1;
  }

  80%,
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.15);
  }
}

@keyframes exploreImage {
  /* Circle appears */
  0% {
    clip-path: circle(0% at 80% 80%);
    filter: grayscale(100%) brightness(85%);
  }

  3.6% {
    clip-path: circle(10% at 80% 80%);
  }

  /* First bounce */
  6.4% {
    clip-path: circle(10% at 80% 55%);
  }

  10.7% {
    clip-path: circle(14% at 80% 80%);
  }

  /* Second bounce */
  12.9% {
    clip-path: circle(14% at 80% 68%);
  }

  15.7% {
    clip-path: circle(18% at 80% 80%);
  }

  /* Short pause */
  17.9% {
    clip-path: circle(18% at 80% 80%);
  }

  /* Final landing */
  21.4% {
    clip-path: circle(24% at 80% 80%);
    filter: grayscale(100%) brightness(85%);
  }

  /* Expand in black and white */
  42.9% {
    clip-path: circle(150% at 80% 80%);
    filter: grayscale(100%) brightness(85%);
  }

  /* Reveal colour */
  57.1% {
    clip-path: circle(150% at 80% 80%);
    filter: grayscale(0%) brightness(100%);
  }

  /* Hold the full photograph */
  100% {
    clip-path: circle(150% at 80% 80%);
    filter: grayscale(0%) brightness(100%);
  }
}

/* RESPONSIVE STYLES
------------------------------------*/

/* Increase morph card typography on large screens */
@media (min-width: 90.01rem) {
  .morph-feature h4 {
    font-size: 1.5rem;
    text-transform: uppercase;
  }

  .morph-feature p {
    font-size: 1rem;
  }

  .morph-category h5 {
    font-size: 1.125rem;
    text-transform: uppercase;
  }
}

/* Simplify morph cards on medium screens */
@media (min-width: 68rem) and (max-width: 90rem) {
  /* Reduce main illustration */
  .morph-feature-icon {
    inline-size: 75%;
  }
  /* Reduce main heading */
  .morph-feature h4 {
    font-size: 0.9rem;
  }
  /* Reduce main description */
  .morph-feature p {
    font-size: 0.75rem;
  }
  /* Reduce category illustrations */
  .morph-category:nth-child(-n + 2) > img {
    inline-size: 2.75rem;
    block-size: 2.75rem;
  }
  .morph-category-icons {
    inline-size: 2.75rem;
    block-size: 2.75rem;
  }
}

/* Three-column layout on larger screens */
@media (min-width: 68rem) {
  .animations-page .project-wrapper {
    grid-template-columns: 1fr 2fr 1fr;
  }
}
/* Stack animation cards on smaller screens */
@media (max-width: 67.999rem) {
  .cat-sprite {
    inset-inline-start: 4.7rem;
  }
  .animations-page .project-wrapper {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .animations-page .animation-item {
    inline-size: 100%;
    max-inline-size: 30rem;
  }
  .animations-page .animation-item:nth-child(2) {
    max-inline-size: 36rem;
  }
}

/* Adjust cat position on smaller screens */
@media (max-width: 91.25rem) {
  .cat-sprite {
    inset-block-end: clamp(4rem, 20cqh, 12rem);
  }
}
/* Adjust cat travel on intermediate screens */
@media (min-width: 48.01rem) and (max-width: 91.25rem) {
  .cat-sprite {
    inset-inline-start: 0rem;
  }
}

/* Simplify morph cards on smaller screens */
@media (max-width: 36.4375rem) {
  /* Reduce mini card headings */
  .morph-category h5 {
    font-size: 0.75rem;
  }

  /* Reduce main feature heading */
  .morph-feature h4 {
    font-size: 1rem;
  }

  /* Reduce main feature description */
  .morph-feature p {
    font-size: 0.875rem;
    line-height: 1.3;
  }
}
/* Adjust morph cards on mobile */
@media (max-width: 31.25rem) {
  .morph-feature-icon {
    inline-size: 80%;
    max-inline-size: 6rem;
    margin-block-end: 0;
  }
  .morph-feature h4 {
    font-size: 0.9375rem;
  }
  .morph-content {
    grid-template-columns: 0.8fr 1.2fr;
  }
  .morph-category {
    gap: 0.25rem;
    padding: 0.25rem;
  }

  .morph-category-icons {
    inline-size: 2.5rem;
    block-size: 2.5rem;
  }

  .morph-category h5 {
    font-size: 0.6875rem;
  }
}
