@layer components {
  html {
    --marquee-h: 5.5rem;
  }

  .home-screen {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    scroll-snap-align: start;
  }

  .home-slot {
    min-height: 14rem;
    border-radius: var(--radius-md);
    background: color-mix(in srgb, var(--color-black) 4%, transparent);
  }

  /* Clipped sideways only, so the can can hang up into the hero. */
  .home-balance {
    position: relative;
    z-index: 1;
    overflow-x: clip;
    padding-top: var(--space-10);
    padding-bottom: var(--space-5);
    background: var(--color-cream);
  }

  .home-balance__cana {
    position: absolute;
    z-index: 0;
    pointer-events: none;
    right: 0;
    top: 40px;
    width: 170px;
    rotate: 150deg;
    scale: 1 -1;
  }

  .home-balance__inner {
    position: relative;
    z-index: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: var(--space-7);
  }

  /* Holds the title up top and the can below it, tilted out of its way. */
  .home-balance__headline {
    position: relative;
    flex: 0 1 22rem;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: var(--space-5);
    text-align: center;
  }

  .home-balance__content {
    flex: 0 1 28rem;
  }

  /* Anchored to the title column but hanging out to the left and below it,
       so it clears the title and crosses the white arc. */
  .home-balance__can {
    position: absolute;
    left: 0;
    top: 0;
    width: auto;
    height: 34rem;
    translate: -88% 0;
    rotate: -36deg;
    filter: drop-shadow(0 30px 40px rgb(0 0 0 / 0.18));
  }

  /* The can waits beside the hero title and falls into its column on scroll. */
  @supports (animation-timeline: scroll()) {
    @media (prefers-reduced-motion: no-preference) and (min-width: 1025px) {
      .home-balance__can {
        --fall-x: -1vw;
        --fall-y: calc(-55dvh - 400px);

        /* can-drop uses transform so it stacks with can-fall's translate. */
        animation-name: can-fall, can-drop;
        animation-duration: auto, 1000ms;
        animation-timing-function: linear, var(--reveal-ease);
        animation-delay: 0s, 300ms;
        animation-fill-mode: both, both;
        animation-timeline: scroll(root), auto;
        animation-range:
          0 55vh,
          normal;
      }
    }
  }

  @keyframes can-fall {
    from {
      translate: calc(-88% + var(--fall-x)) var(--fall-y);
      rotate: 8deg;
    }
    to {
      translate: -88% 0;
      rotate: -36deg;
    }
  }

  @keyframes can-drop {
    from {
      opacity: 0;
      transform: translateY(-70vh);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  .home-balance__content,
  .home-balance__pitch {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-5);
  }

  .home-balance__content {
    gap: var(--space-7);
  }

  /* Both pitches share one cell, so swapping them never shifts the layout. */
  .home-balance__pitches {
    display: grid;
    align-self: stretch;
  }

  .home-balance__pitch {
    grid-area: 1 / 1;
    gap: var(--space-4);
    color: var(--color-gray-dark);
    transition: opacity 400ms var(--reveal-ease);
  }

  .home-balance__pitch:not(.is-active) {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }

  .home-balance__pitch-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-5);
    width: 100%;
  }

  .home-balance__dots {
    display: flex;
    gap: var(--space-1);
  }

  .home-balance__dot {
    width: 12px;
    height: 12px;
    padding: 0;
    border: 2px solid var(--color-brand-green);
    border-radius: var(--radius-full);
    background: transparent;
    cursor: pointer;
    transition: background 200ms ease;
  }

  .home-balance__dot.is-active {
    background: var(--color-brand-green);
  }

  .home-balance__script {
    font-family: var(--font-family-script);
    font-size: var(--font-size-3xl);
    line-height: 0.6;
    color: var(--color-brand-magenta);
  }

  .home-balance__title {
    display: grid;
    grid-template-columns: auto auto;
    align-items: center;
    justify-content: center;
    justify-items: center;
    column-gap: var(--space-2);
    font-size: var(--font-size-4xl);
    line-height: 0.9;
  }

  .home-balance__title-top,
  .home-balance__title-main {
    color: var(--color-brand-magenta);
  }

  .home-balance__title-top {
    grid-column: 1 / -1;
  }

  .home-balance__title-de {
    writing-mode: vertical-rl;
    rotate: 180deg;
    font-size: var(--font-size-2xl);
    color: var(--color-brand-magenta);
  }

  .home-balance__flavor {
    font-family: var(--font-family-display);
    font-size: var(--font-size-2xl);
    line-height: 1;
    color: var(--color-gray-dark);
  }

  .home-balance__flavor-lemon {
    color: var(--color-brand-green);
  }

  .home-balance__flavor-vodka {
    color: var(--color-brand-magenta);
  }

  /* The wave keeps its aspect ratio, otherwise the text on the path stretches. */
  .home-balance__band {
    position: relative;
    container-type: inline-size;
    margin-top: var(--space-4);
    margin-inline: calc(var(--space-4) * -1);
  }

  .home-balance__wave {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
  }

  .home-balance__wave-line {
    fill: none;
    stroke: var(--color-white);
    stroke-width: 46;
    stroke-linecap: round;
  }

  .home-balance__wave-text {
    font-family: var(--font-family-display);
    font-size: 30px;
    letter-spacing: 2px;
    text-transform: uppercase;
    fill: var(--color-brand-magenta);
  }

  .home-balance__stats {
    position: absolute;
    z-index: 2;
    inset: 0;
  }

  /* home.js reads --wave-pos off each bubble and writes back where that
       point of the curve falls. The defaults keep them in place without it.
       Sizes track the band so the gaps hold at any width, like the wave. */
  .home-balance__bubble {
    position: absolute;
    left: calc(var(--wave-x) * 1%);
    top: calc(var(--wave-y) * 1%);
    translate: -50% 0;
    width: calc(var(--size) * 1cqw);
    padding: 1.4cqw;
    font-size: calc(var(--size) * 0.16cqw);
    animation: bubble-bob var(--bob-dur, 3s) ease-in-out var(--bob-delay, 0s)
      infinite;
  }

  .home-balance__bubble--1 {
    --size: 7.2;
    --wave-x: 50;
    --wave-y: 27;
    --bob-dur: 3s;
  }

  .home-balance__bubble--2 {
    --size: 9.2;
    --wave-x: 59;
    --wave-y: 35;
    --bob-dur: 3.6s;
    --bob-delay: -1.2s;
  }

  .home-balance__bubble--3 {
    --size: 7.5;
    --wave-x: 69;
    --wave-y: 51;
    --bob-dur: 3.2s;
    --bob-delay: -2s;
  }

  @keyframes bubble-bob {
    50% {
      transform: translateY(-12px);
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .home-balance__bubble {
      animation: none;
    }
  }

  .home-link {
    font-weight: 600;
    color: var(--color-brand-magenta);
  }

  .home-marquee {
    display: grid;
    align-items: center;
    height: var(--marquee-h);
    overflow: hidden;
    background: var(--color-white);
  }

  .home-marquee__cans {
    display: block;
    width: 100%;
    height: auto;
    background-color: var(--color-cream);
  }

  .home-marquee .marquee__item,
  .home-marquee .marquee__sep {
    font-family: var(--font-family-display);
    font-size: var(--font-size-2xl);
    text-transform: uppercase;
  }

  .home-marquee .marquee__item {
    color: var(--color-brand-magenta);
  }

  .home-places {
    background: var(--color-brand-green-light);
  }

  .home-places__inner {
    display: flex;
    flex-direction: column;
    gap: var(--space-8);
  }

  .home-wall {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: var(--space-4) var(--space-3);
  }

  .home-photo {
    position: relative;
    margin: 0;
    width: clamp(140px, 18vw, 220px);
    padding: var(--space-2) var(--space-2) var(--space-3);
    background: var(--color-white);
    box-shadow: var(--shadow-soft);
  }

  .home-photo img {
    display: block;
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
  }

  .home-photo__caption {
    margin-top: var(--space-2);
    font-size: var(--font-size-md);
    font-weight: 500;
    line-height: 1;
    text-align: center;
    color: var(--color-gray-dark);
  }

  .home-photo:nth-child(1) {
    transform: rotate(-5deg) translateY(10px);
  }
  .home-photo:nth-child(2) {
    transform: rotate(3deg) translateY(-8px);
  }
  .home-photo:nth-child(3) {
    transform: rotate(-2deg) translateY(6px);
  }
  .home-photo:nth-child(4) {
    transform: rotate(5deg) translateY(-6px);
  }
  .home-photo:nth-child(5) {
    transform: rotate(-4deg) translateY(-10px);
  }
  .home-photo:nth-child(6) {
    transform: rotate(4deg) translateY(8px);
  }
  .home-photo:nth-child(7) {
    transform: rotate(-3deg) translateY(-6px);
  }
  .home-photo:nth-child(8) {
    transform: rotate(2deg) translateY(10px);
  }

  .home-photo:hover {
    transform: rotate(0) scale(1.06);
    box-shadow:
      var(--shadow-soft),
      0 20px 40px rgb(0 0 0 / 0.18);
    z-index: 2;
  }

  .home-places__who {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-5);
    text-align: center;
  }

  .home-places__who-title {
    font-family: var(--font-family-script);
    font-size: var(--font-size-4xl);
    color: var(--color-brand-magenta);
  }

  .home-creators {
    scroll-snap-align: center;
    background: var(--color-white);
  }

  .home-creators__inner {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--space-7);

    & > * {
      flex: 1 1 0;
      min-width: 0;
    }
  }

  .home-creators__body {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-5);
    color: var(--color-gray-dark);
  }

  .home-creators__title {
    font-size: var(--font-size-3xl);
  }

  .home-creators__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-5);
  }

  .home-creators__media {
    align-self: stretch;
    max-height: 40rem;
    margin: 0;
    border-radius: var(--radius-md);
    overflow: clip;
  }

  .home-creators__media img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  .home-buy {
    padding-block: var(--space-10);
    background-image:
      url(../../assets/images/waves.svg),
      linear-gradient(
        to bottom,
        var(--color-white) 0,
        var(--color-cream) var(--space-6),
        var(--color-cream) calc(100% - var(--space-6)),
        var(--color-brand-magenta) 100%
      );
    background-position:
      bottom center,
      top center;
    background-repeat: no-repeat, no-repeat;
    background-size:
      100% 45%,
      100% 100%;
  }

  .home-buy__panel {
    width: 100%;
  }

  @media (max-width: 1024px) {
    .home-balance {
      padding-bottom: var(--space-9);
    }

    .home-balance__cana {
      display: none;
    }

    .home-balance__inner {
      flex-direction: column;
      align-items: stretch;
    }

    .home-balance__headline {
      flex: initial;
      align-self: auto;
    }

    .home-balance__content {
      flex: initial;
    }

    .home-balance__can {
      position: static;
      display: block;
      width: auto;
      height: auto;
      max-height: 18rem;
      margin-inline: auto;
      translate: none;
    }

    .home-balance__title {
      font-size: 88px;
    }

    .home-balance__title-de,
    .home-balance__flavor {
      font-size: 44px;
    }

    /* The wave only reads as a divider next to the two-column layout. */
    .home-balance__band {
      margin-inline: 0;
    }

    .home-balance__wave {
      display: none;
    }

    .home-balance__stats {
      position: static;
      display: flex;
      justify-content: center;
      gap: var(--space-3);
      margin-block: var(--space-7);
    }

    .home-balance__bubble {
      position: static;
      width: 6rem;
      padding: var(--space-3);
      font-size: var(--font-size-md);
      translate: none;
    }

    .home-creators__title span {
      display: inline;
    }

    .home-creators__inner {
      flex-direction: column;
      align-items: stretch;

      & > * {
        flex: initial;
      }
    }
  }
}

@layer utilities {
  .home-wall .home-photo {
    transition:
      opacity var(--reveal-duration) var(--reveal-ease)
        calc(var(--i, 0) * var(--reveal-stagger)),
      translate var(--reveal-duration) var(--reveal-ease)
        calc(var(--i, 0) * var(--reveal-stagger)),
      scale var(--reveal-duration) var(--reveal-ease)
        calc(var(--i, 0) * var(--reveal-stagger)),
      transform 250ms ease,
      box-shadow 250ms ease;
  }
}
