@mixin flexCenter {
  display: flex;
  justify-content: center;
  align-items: center;
}

* {
  box-sizing: border-box;
}


.flip-section {
  display: flex;
  align-items: center;
  gap: 36px;
  
  height: 100vh;
  padding: 24px 48px;
  
  view-timeline: --section; // ✨
  position: relative; // for setting z-index
  
  // 👇 use z-index to handle image order
  &:nth-child(1) {
    background-color: #d4e3d2;
    z-index: 4;
  }
  &:nth-child(2) {
    background-color: #efcbc5;
    z-index: 3;
  }
  &:nth-child(3) {
    background-color: #ebe1c6;
    z-index: 2;
  }
  &:nth-child(4) {
    background-color: #cbd0e2;
    z-index: 1;
  }
  
  --img-width: 35vmax;
  --img-height: calc(var(--img-width) * 3 / 4);
  
  .img-box {
    position: fixed;
    top: 0;
    bottom: 0;
    margin: auto;
    right: 48px;
    width: var(--img-width);
    height: var(--img-height);
  }
  
  img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    
    animation: wipe linear both; // clip-path animation
    animation-timeline: --section; // ✨
     
    --gap: calc((100% - var(--img-height)) / 2);
    animation-range: exit var(--gap) exit calc(100% - var(--gap)); // handle the spacing
  }
}
.content {
  padding-left: 10%;
  width: 50%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 24px;
  
  .title {
    font-size: 1.8em;
    font-weight: bold;
  }
  .desc {
    line-height: 1.7;
    text-wrap: balance;
  }
}

@keyframes wipe {
  0% {
    clip-path: inset(0 0 0 0);
  }
  100% {
    clip-path: inset(0 0 100% 0);
  }
}