:root {
  --transition-duration: 1750ms;
  --ingredient-exit-duration: 620ms;
  --ingredient-enter-duration: 780ms;
  --ingredient-handoff-delay: 620ms;
  --product-exit-duration: 620ms;
  --product-enter-duration: 1080ms;
  --product-handoff-delay: 620ms;
  --ease-wipe: cubic-bezier(0.76, 0, 0.24, 1);
  --ease-enter: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-exit: cubic-bezier(0.55, 0, 1, 0.45);
  --ease-title: cubic-bezier(0.77, 0, 0.18, 1);
  --ink: #352606;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: #f8e89e;
  color: var(--ink);
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
}

button,
img {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

.hero {
  position: relative;
  isolation: isolate;
  width: 100%;
  min-height: 100svh;
  overflow: hidden;
  touch-action: pan-y;
}

.background-stack,
.background-layer {
  position: absolute;
  inset: 0;
}

.background-stack {
  z-index: -5;
}

.background-layer {
  --background: #f8e89e;
  --shape: #efcf57;
  --panel: rgba(255, 255, 255, 0.16);
  overflow: hidden;
  background: var(--background);
}

.background-layer::before,
.background-layer::after {
  content: "";
  position: absolute;
  width: 66vw;
  height: 66vw;
  border-radius: 50%;
  background: var(--shape);
}

.background-layer::before {
  bottom: -43vw;
  left: -22vw;
}

.background-layer::after {
  right: -22vw;
  bottom: -34vw;
}

.background-layer .central-panel {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: min(27vw, 430px);
  transform: translateX(-50%);
  background: var(--panel);
}

.background-layer--incoming {
  z-index: 2;
  clip-path: inset(0 0 0 100%);
  will-change: clip-path;
}

.background-layer--incoming.is-wiping {
  animation: backgroundWipe var(--transition-duration) var(--ease-wipe) forwards;
}

.title-stage {
  position: absolute;
  z-index: 0;
  top: clamp(58px, 5.7vh, 82px);
  right: 0;
  left: 0;
  height: min(33vh, 295px);
  overflow: visible;
  pointer-events: none;
  user-select: none;
}

.flavour-title {
  position: absolute;
  top: 0;
  left: 50%;
  display: block;
  width: max-content;
  max-width: none;
  color: var(--title-color, rgba(90, 68, 0, 0.21));
  font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
  font-size: clamp(7.5rem, 18.6vw, 20rem);
  font-weight: 900;
  line-height: 0.78;
  letter-spacing: -0.045em;
  text-transform: uppercase;
  white-space: nowrap;
  transform: translate3d(-50%, 0, 0);
  backface-visibility: hidden;
  will-change: transform, opacity;
}

.flavour-title--next {
  opacity: 0;
  transform: translate3d(calc(-50% + 72vw), 0, 0);
}

.title-stage.is-transitioning .flavour-title--current {
  animation: titleExit calc(var(--transition-duration) * 0.92) var(--ease-title) forwards;
}

.title-stage.is-transitioning .flavour-title--next {
  animation: titleEnter var(--transition-duration) var(--ease-title) forwards;
}

.product-stage {
  position: absolute;
  z-index: 4;
  top: 56%;
  left: 50%;
  width: min(43vw, 670px);
  aspect-ratio: 1;
  pointer-events: none;
  transform: translate3d(-50%, -50%, 0);
  animation: productStageHover 5.4s ease-in-out infinite;
  will-change: transform;
}

.product {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 29px 25px rgba(39, 24, 0, 0.22));
  transform-origin: 50% 60%;
  backface-visibility: hidden;
  will-change: transform, opacity;
}

.product--current {
  z-index: 2;
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
}

.product--next {
  z-index: 3;
  opacity: 0;
  transform: translate3d(0, 2.8%, 0) scale(0.045);
}

.product-stage.is-transitioning .product--current {
  animation: productExit var(--product-exit-duration) var(--ease-exit) forwards;
}

.product-stage.is-transitioning .product--next {
  animation: productEnter var(--product-enter-duration) var(--ease-enter) var(--product-handoff-delay) forwards;
}

.product-shadow {
  position: absolute;
  z-index: 0;
  bottom: 4.5%;
  left: 50%;
  width: 58%;
  height: 7.5%;
  border-radius: 50%;
  background: rgba(63, 42, 6, 0.2);
  filter: blur(13px);
  transform: translate3d(-50%, 0, 0) scaleX(1);
  will-change: transform, opacity;
}

.product-stage.is-transitioning .product-shadow {
  animation: shadowHandoff calc(var(--product-exit-duration) + var(--product-enter-duration)) var(--ease-enter) forwards;
}

.ingredient-stage {
  position: absolute;
  z-index: 3;
  inset: 0;
  pointer-events: none;
}

.ingredient {
  position: absolute;
  display: block;
  opacity: 1;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
  will-change: transform, opacity;
}

.ingredient__visual {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 17px 16px rgba(31, 24, 3, 0.18));
  transform: translate3d(0, 0, 0) rotate(var(--custom-rotate, 0deg)) scale(var(--custom-scale, 1));
  transform-origin: center;
  backface-visibility: hidden;
  will-change: transform;
}

.ingredient[data-slot="left"] {
  top: 24%;
  left: 5vw;
  width: clamp(145px, 18.5vw, 305px);
}

.ingredient[data-slot="right"] {
  top: 25%;
  right: 12vw;
  width: clamp(140px, 17.5vw, 290px);
}

.ingredient[data-slot="lower"] {
  bottom: 4vh;
  left: 27vw;
  width: clamp(90px, 11vw, 180px);
}

.ingredient--static .ingredient__visual {
  animation: ingredientHover var(--hover-duration, 5.2s) ease-in-out var(--hover-delay, 0s) infinite;
}

.ingredient[data-slot="left"].ingredient--exit {
  animation: ingredientExitLeft var(--ingredient-exit-duration) var(--ease-exit) forwards;
}

.ingredient[data-slot="right"].ingredient--exit {
  animation: ingredientExitRight var(--ingredient-exit-duration) var(--ease-exit) forwards;
}

.ingredient[data-slot="lower"].ingredient--exit {
  animation: ingredientExitDown var(--ingredient-exit-duration) var(--ease-exit) forwards;
}

.ingredient[data-slot="left"].ingredient--enter {
  opacity: 0;
  transform: translate3d(-19vw, 0, 0);
  animation: ingredientEnterLeft var(--ingredient-enter-duration) var(--ease-enter) var(--ingredient-handoff-delay) forwards;
}

.ingredient[data-slot="right"].ingredient--enter {
  opacity: 0;
  transform: translate3d(19vw, 0, 0);
  animation: ingredientEnterRight var(--ingredient-enter-duration) var(--ease-enter) var(--ingredient-handoff-delay) forwards;
}

.ingredient[data-slot="lower"].ingredient--enter {
  opacity: 0;
  transform: translate3d(0, 16vh, 0);
  animation: ingredientEnterLower var(--ingredient-enter-duration) var(--ease-enter) var(--ingredient-handoff-delay) forwards;
}

.flavour-nav {
  position: absolute;
  z-index: 12;
  top: 50%;
  right: clamp(16px, 3.1vw, 56px);
  transform: translateY(-50%);
}

.flavour-nav__track {
  display: flex;
  flex-direction: column;
  gap: clamp(9px, 1.2vh, 14px);
}

.flavour-option {
  display: grid;
  grid-template-columns: clamp(48px, 4.6vw, 64px);
  align-items: center;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--nav-color, #3d310b);
  cursor: pointer;
}

.flavour-option__thumb {
  position: relative;
  display: grid;
  place-items: center;
  width: clamp(48px, 4.6vw, 64px);
  aspect-ratio: 1;
  border: 1px solid rgba(49, 40, 8, 0.24);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.42);
  transition: transform 260ms ease-out, border-color 260ms ease-out, box-shadow 260ms ease-out;
}

.flavour-option__thumb img {
  width: 78%;
  height: 78%;
  object-fit: contain;
}

.flavour-option__label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.flavour-option:hover .flavour-option__thumb,
.flavour-option:focus-visible .flavour-option__thumb,
.flavour-option[aria-current="true"] .flavour-option__thumb {
  border-color: currentColor;
  box-shadow: 0 0 0 2px currentColor;
  transform: scale(1.08);
}

.flavour-option:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 6px;
  border-radius: 50%;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

@keyframes backgroundWipe {
  from {
    clip-path: inset(0 0 0 100%);
  }
  to {
    clip-path: inset(0);
  }
}

@keyframes titleExit {
  0% {
    opacity: 1;
    transform: translate3d(-50%, 0, 0);
  }
  72% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(calc(-50% - 70vw), 0, 0);
  }
}

@keyframes titleEnter {
  0% {
    opacity: 1;
    transform: translate3d(calc(-50% + 72vw), 0, 0);
  }
  100% {
    opacity: 1;
    transform: translate3d(-50%, 0, 0);
  }
}

@keyframes productExit {
  0% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
  82% {
    opacity: 1;
    transform: translate3d(0, 1.4%, 0) scale(0.18);
  }
  100% {
    opacity: 0;
    transform: translate3d(0, 2%, 0) scale(0.055);
  }
}

@keyframes productEnter {
  0% {
    opacity: 0;
    transform: translate3d(0, 2.8%, 0) scale(0.045);
  }
  22% {
    opacity: 0.28;
  }
  48% {
    opacity: 0.82;
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}

@keyframes productStageHover {
  0%,
  100% {
    transform: translate3d(-50%, calc(-50% + 6px), 0);
  }
  50% {
    transform: translate3d(-50%, calc(-50% - 11px), 0);
  }
}

@keyframes shadowHandoff {
  0%,
  100% {
    opacity: 1;
    transform: translate3d(-50%, 0, 0) scaleX(1);
  }
  46% {
    opacity: 0.1;
    transform: translate3d(-50%, 0, 0) scaleX(0.1);
  }
  52% {
    opacity: 0.1;
    transform: translate3d(-50%, 0, 0) scaleX(0.1);
  }
}

@keyframes ingredientExitLeft {
  0% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
  78% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(-19vw, 0, 0);
  }
}

@keyframes ingredientExitRight {
  0% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
  78% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(19vw, 0, 0);
  }
}

@keyframes ingredientExitDown {
  0% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
  78% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(0, 16vh, 0);
  }
}

@keyframes ingredientEnterLeft {
  0% {
    opacity: 0;
    transform: translate3d(-19vw, 0, 0);
  }
  10% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes ingredientEnterRight {
  0% {
    opacity: 0;
    transform: translate3d(19vw, 0, 0);
  }
  10% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes ingredientEnterLower {
  0% {
    opacity: 0;
    transform: translate3d(0, 16vh, 0);
  }
  10% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes ingredientHover {
  0%,
  100% {
    transform: translate3d(0, 0, 0) rotate(var(--custom-rotate, 0deg)) scale(var(--custom-scale, 1));
  }
  28% {
    transform: translate3d(var(--hover-x-start, -4px), -10px, 0) rotate(calc(var(--custom-rotate, 0deg) - var(--hover-rotate, 2.8deg))) scale(var(--custom-scale, 1));
  }
  58% {
    transform: translate3d(var(--hover-x-end, 6px), var(--hover-distance, -23px), 0) rotate(calc(var(--custom-rotate, 0deg) + var(--hover-rotate, 2.8deg))) scale(var(--custom-scale, 1));
  }
  82% {
    transform: translate3d(2px, -9px, 0) rotate(calc(var(--custom-rotate, 0deg) + 0.7deg)) scale(var(--custom-scale, 1));
  }
}

@media (max-width: 900px) {
  .title-stage {
    top: max(76px, 8vh);
  }

  .flavour-title {
    font-size: clamp(6.8rem, 29vw, 12.5rem);
  }

  .product-stage {
    top: 55%;
    width: min(76vw, 560px);
  }

  .ingredient[data-slot="left"] {
    top: 24%;
    left: -2vw;
    width: clamp(112px, 29vw, 220px);
  }

  .ingredient[data-slot="right"] {
    top: 26%;
    right: 8vw;
    width: clamp(108px, 27vw, 210px);
  }

  .ingredient[data-slot="lower"] {
    bottom: 10vh;
    left: 9vw;
    width: clamp(78px, 19vw, 145px);
  }

  .flavour-nav {
    right: 12px;
  }

  .flavour-nav__track {
    gap: 9px;
  }

  .flavour-option,
  .flavour-option__thumb {
    width: 42px;
  }

  .flavour-option {
    grid-template-columns: 42px;
  }

  .background-layer::before,
  .background-layer::after {
    width: 82vw;
    height: 82vw;
  }

  .background-layer::before {
    bottom: -50vw;
    left: -38vw;
  }

  .background-layer::after {
    right: -40vw;
    bottom: -39vw;
  }

  .background-layer .central-panel {
    width: 42vw;
  }
}

@media (max-width: 560px) {
  .title-stage {
    top: max(88px, 10vh);
  }

  .flavour-title {
    font-size: clamp(5.6rem, 31vw, 9.6rem);
    line-height: 0.82;
  }

  .product-stage {
    top: 56.5%;
    left: 48%;
    width: min(91vw, 510px);
  }

  .ingredient[data-slot="left"] {
    top: 25%;
    left: -9vw;
    width: clamp(104px, 33vw, 180px);
  }

  .ingredient[data-slot="right"] {
    top: 28%;
    right: 7vw;
    width: clamp(92px, 29vw, 165px);
  }

  .ingredient[data-slot="lower"] {
    bottom: 9vh;
    left: 5vw;
  }

  .flavour-nav {
    top: auto;
    right: max(10px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
    left: max(10px, env(safe-area-inset-left));
    transform: none;
  }

  .flavour-nav__track {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 5px;
    padding: 7px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.36);
    backdrop-filter: blur(10px);
  }

  .flavour-option,
  .flavour-option__thumb {
    width: 100%;
  }

  .flavour-option {
    display: block;
    min-width: 0;
  }

  .flavour-option__thumb {
    max-width: 47px;
    margin: 0 auto;
  }

  .ingredient--static .ingredient__visual {
    --hover-distance: -18px;
  }
}
