@layer layout;

@layer layout {

  .scroll_section {
    position: relative;
    /* Creates section spacing variable for section-like elements */
    --section-spacing-multiplier: 1;
    --section-spacing: calc(
      var(--spacing, 1.5rem) * var(--section-spacing-multiplier)
    );

    @media (min-width: 40em) {
      --section-spacing-multiplier: 2;
    }

    @media (min-width: 60em) {
      --section-spacing-multiplier: 3;
    }

    @media (min-width: 80em) {
      --section-spacing-multiplier: 4;
    }

    @media (min-width: 100em) {
      --section-spacing-multiplier: 5;
    }
  }

}



.sectionscroll {
  counter-increment: sectiontotal;
  /* Creating a snapping rule on the section element */
  scroll-snap-align: start;
  scroll-snap-stop: always;

  /* Attach the timeline to the section element*/
  view-timeline: --section;

  /* Set each section to the full dynamic height of the viewport */
  height: 100vh;
}
.section_scroll {
    width: 100%;
    height: calc(100vh * counter(sectiontotal));
    scroll-snap-type: y mandatory;
  
    timeline-scope: --section, --main;
    position: relative;
}
.content_scroll {
  /* Fix the content, so it doesn't scroll with the section */
  overflow: hidden;
  position: fixed;
  inset: 0;

  /* Animate the content based on the section scrolling */
  --contrast: 4;
  --blur: 0.5rem;

  animation: blink ease-in-out both;
  animation-timeline: --section;
}

@keyframes blink {
  0%,
  100% {
    filter: blur(var(--blur)) contrast(var(--contrast));
    opacity: 0;
    visibility: hidden;
  }

  50% {
    filter: blur(0) contrast(1);
    opacity: 1;
    visibility: visible;
  }
}
.indicator{
    position: absolute;
    top: 0;
    right: 20px;
    bottom: 0;
    z-index: 99;
    list-style: none;
    padding: 0;
    margin: auto;
    display: grid;
    height: 160px;
}
.indicator li a{
    display: block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid #fff;
    position: relative;
}

/* And we're manually setting the colors because see: lazy comment above */
@keyframes indicate {
  0% {
    --color-indicator: var(--s);
    transform: translateY(0);
  }

  25% {
    --color-indicator: var(--s);
  }

  50% {
    --color-indicator: var(--s);
  }

  75% {
    --color-indicator: var(--s);
  }

  100% {
    --color-indicator: var(--s);
    transform: translateY(
      calc(var(--indicator-total-height) - var(--indicator-size))
    );
  }
}

.indicator li a::before {
    content: "";
    display: block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--color-indicator);
    transform: translateY(0);
    position: absolute;
    top: 0;
    left: 0;
    right: 0px;
    bottom: 0;
    margin: auto;
  animation: indicate linear both;
  animation-timeline: --section;
  animation-range: contain;
}

@keyframes fade-scroll {
  0% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

/* Change animation based on radio checked */
.scroll_section:has(.sr-only[value="horizontal-scroll"]:checked) .content_scroll {
  animation: horizontal-scroll ease-in-out both;
  animation-timeline: --section;
}

.scroll_section:has(.sr-only[value="backwards-scroll"]:checked) .content_scroll {
  animation: backwards-scroll ease-in-out both;
  animation-timeline: --section;
}

.scroll_section:has(.sr-only[value="zoom-scroll"]:checked) .content_scroll {
  animation: zoom-scroll ease-in-out both;
  animation-timeline: --section;
}

/* Alternative animations */
/* Very cool, try it */
@keyframes horizontal-scroll {
  0% {
    transform: translate3d(100%, 0%, 0);
  }

  50% {
    transform: none;
  }

  100% {
    transform: translate3d(-100%, 0%, 0);
  }
}

/* Befuddling, try it */
@keyframes backwards-scroll {
  0% {
    transform: translate3d(0%, -100%, 0);
  }

  50% {
    transform: none;
  }

  100% {
    transform: translate3d(0%, 100%, 0);
  }
}

/* WIP */
@keyframes zoom-scroll {
  0% {
    filter: blur(5rem);
    transform: scale(0);
    opacity: 0;
    visibility: hidden;
  }

  50% {
    filter: blur(0);
    transform: none;
    opacity: 1;
    visibility: visible;
  }

  100% {
    filter: blur(3rem);
    transform: scale(1.5);
    opacity: 0;
    visibility: hidden;
  }
}

/* 
  The actual page styling is in a different stylesheet to not clutter
  this pen with irrelevant or confusing code

  https://codepen.io/giana/pen/rNRzgRj
*/
