/*
Theme Name: For Purpose
Theme URI: https://forpourpose.com.au/
Author: the New Best Friend
Author URI: https://newbestfriend.com.au
Requires at least: 6.7.2
Tested up to: 6.7.2
Requires PHP: 8.0
Version: 1.0
Text Domain: fp-blocks
*/

footer {
  margin-top: 0 !important;
}

html {
  scroll-behavior: smooth;
}

img {
  display: block;
}

.hide-on-mobile {
  @media (max-width: 781px) {
    & {
      display: none !important;
    }
  }
}
.hide-on-tablet {
  @media (min-width: 782px) and (max-width: 1009px) {
    & {
      display: none !important;
    }
  }
}
.hide-on-desktop {
  @media (min-width: 1010px) {
    & {
      display: none !important;
    }
  }
}
.d-none {
  display: none !important;
}
.d-block {
  display: block !important;
}

/*
 * CHANGE CONTENT ORDER
 */
.order-1 {
  order: 1;
}
.order-2 {
  order: 2;
}
.order-3 {
  order: 3;
}
@media (max-width: 781px) {
  .order-mobile-1 {
    order: 1;
  }
  .order-mobile-2 {
    order: 2;
  }
  .order-mobile-3 {
    order: 3;
  }
}

.w-100 {
  width: 100%;
}

.float-right a:after {
  float: right;
}


iframe {
  width: 100%;
  max-width: unset !important;
  aspect-ratio: 16 / 9;
  height: auto;  
}


/* Fix rotated text for mobile */
@media (max-width: 785px) {
  *.has-text-align-right[style*=writing-mode]:where([style*=vertical-rl]) {
    rotate: 0deg !important;
    text-align: left !important;
    writing-mode: initial !important;
  }
}

.marquee {
  display: flex;
  overflow: hidden;
  white-space: nowrap;
  rotate: -1deg;
  margin-block: var(--wp--preset--spacing--40);  
}

.marquee-inner {
    display: flex;
    gap: 2rem;
    animation: marquee-scroll 20s linear infinite;
    width: max-content;
}


@keyframes marquee-scroll {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(-50%);
    }
}

/* Hide duplicated elements from screen readers */
.marquee-item[aria-hidden="true"] {
    visibility: visible;
}

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Apply scroll-driven animation */
:is(.fade-in, img) {
  &;:not(.no-fade) {
    view-timeline-name: --img;
    view-timeline-axis: block;
    animation-timeline: --img;
    animation-name: fade-in-up;
    animation-range: entry 20% cover 50%;
    animation-fill-mode: both;
  }
}

@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Target direct children of .fade-in */
.fade-in-children > * {
  view-timeline-axis: block;
  animation-name: fade-in-up;
  animation-timeline: inherit;
  animation-fill-mode: both;
}

/* Assign unique timelines for staggering */
.fade-in-children > *:nth-child(1) {
  view-timeline-name: --fade1;
  animation-timeline: --fade1;
  animation-range: entry 0% cover 30%;
}

.fade-in-children > *:nth-child(2) {
  view-timeline-name: --fade2;
  animation-timeline: --fade2;
  animation-range: entry 20% cover 50%;
}

.fade-in-children > *:nth-child(3) {
  view-timeline-name: --fade3;
  animation-timeline: --fade3;
  animation-range: entry 30% cover 60%;
}

.fade-in-children > *:nth-child(4) {
  view-timeline-name: --fade4;
  animation-timeline: --fade4;
  animation-range: entry 40% cover 70%;
}

.fade-in-children > *:nth-child(5) {
  view-timeline-name: --fade5;
  animation-timeline: --fade5;
  animation-range: entry 50% cover 80%;
}


.slots {
  overflow: hidden;
  position: relative;
  -webkit-mask-image: -webkit-gradient(
    linear, center top, center bottom, 
    color-stop(0.00,  rgba(0,0,0,0)),
    color-stop(0.35,  rgba(0,0,0,1)),
    color-stop(0.50,  rgba(0,0,0,1)),
    color-stop(0.65,  rgba(0,0,0,1)),
    color-stop(1.00,  rgba(0,0,0,0)));  
}

/* The inner container holds the original set duplicated for seamless looping */
.slots-inner {
  will-change: transform;
  /* The animation is defined below in CSS */
  animation: scrollAnimation linear infinite;
  > * {
    margin: 0;    
  }
}

/* 
  This keyframes example is for a 3-word list.
  The inner container has two copies of the set (i.e. 6 items total),
  but we only scroll one set’s height (50% of the inner container’s height).
  Each word’s “step” is 1/3 of that 50% (≈16.67%).
  
  The timeline for each word segment is divided as follows:
  - Hold for 80% of the segment, then transition (ease‑out) over the remaining 20%.
  
  For example, the first word is held from 0% to 26.67% of the animation,
  then transitions by 33.33% (which is 1/3 of the cycle) to –16.67%.
*/
@keyframes scrollAnimation {
  0% {
    transform: translateY(0);
  }
  26.67% {
    transform: translateY(0);
  }
  33.33% {
    transform: translateY(-16.67%);
  }
  60% {
    transform: translateY(-16.67%);
  }
  66.67% {
    transform: translateY(-33.33%);
  }
  93.33% {
    transform: translateY(-33.33%);
  }
  100% {
    transform: translateY(-50%);
  }
}

.wp-block-navigation__container {
  &:has(*:hover) {
    .wp-block-navigation-item {
      opacity: 0.5;
    }
  }  
  > .wp-block-navigation-item {
    transition: 0.3s ease-out;
    a {
      text-decoration: none !important;
    }
    &:hover, &:focus {
      opacity: 1 !important;
      transition: 0.1s ease;
    }
  }

  &:has(.current-menu-item) > .wp-block-navigation-item {
    opacity: 0.5;
    &.current-menu-item {
      opacity: 1;
    }
  }

}