/* ==========================================================================
   HERO - bento layout: intro + image slider + floating glass cards
   Entrance is pure CSS keyframes (no JS, no flash). Mouse parallax sets
   --mx / --my on .hero__visual (JS), floats move by their --depth.
   ========================================================================== */

.hero {
  padding-block: var(--space-2) var(--space-8);

  &__grid {
    display: grid;
    gap: var(--space-5);

    /* Grid items must be allowed to shrink, or the slider's wide track blows them out */
    > * {
      min-width: 0;
    }
  }

  /* ---------- Intro ---------- */
  &__intro {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;

    > * {
      animation: rise var(--transition-slower) var(--ease-out) both;
    }

    > :nth-child(2) { animation-delay: 0.1s; }
    > :nth-child(3) { animation-delay: 0.2s; }
    > :nth-child(4) { animation-delay: 0.3s; }
    > :nth-child(5) { animation-delay: 0.4s; }
  }

  /* Headline moves but never starts invisible: it is the LCP element */
  &__intro > &__title {
    animation-name: rise-y;
  }

  &__title {
    font-size: var(--font-size-display);
    line-height: 1;
    letter-spacing: -0.025em;
    margin-bottom: var(--space-3);
  }

  &__highlight {
    position: relative;
    display: inline-block;
    white-space: nowrap;
  }

  /* Hand-drawn underline, drawn with stroke-dashoffset */
  &__underline {
    position: absolute;
    left: 0;
    bottom: -0.12em;
    width: 100%;
    height: 0.28em;
    fill: none;
    stroke: currentColor;
    stroke-width: 3;
    stroke-linecap: round;

    path {
      stroke-dasharray: 320;
      animation: draw 1.2s var(--ease-out) 0.7s both;
    }
  }

  &__text {
    max-width: 30rem;
    margin-bottom: var(--space-4);
    font-size: var(--font-size-md);
    color: var(--color-text-muted);
  }

  /* Phones: full-width stacked buttons; side by side from sm */
  &__actions {
    display: grid;
    gap: var(--space-1-5);
    align-self: stretch;
  }

  &__proof {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-top: var(--space-5);
  }

  &__proof-text {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);

    strong {
      color: var(--color-text);
    }
  }

  /* ---------- Visual ---------- */
  &__visual {
    --mx: 0;
    --my: 0;
    position: relative;
  }

  &__media {
    position: relative;
    aspect-ratio: 4 / 5;
    border-radius: var(--radius-2xl);
    overflow: hidden;
    background-color: var(--color-accent-soft);
    animation: mask-in 1.2s var(--ease-out) 0.15s both;
  }

  &__slider,
  &__slide {
    height: 100%;
  }

  &__image {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  /* Slow zoom-out on the active slide */
  &__slider.swiper-initialized &__image {
    transform: scale(1.08);
    transition: transform 6s linear;
  }

  &__slider.swiper-initialized .swiper-slide-active &__image {
    transform: scale(1);
  }

  /* ---------- Counter + progress ---------- */
  &__counter {
    position: absolute;
    top: var(--space-2);
    left: var(--space-2);
    z-index: 2;
    display: flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-0-5);
    border-radius: var(--radius-pill);
    font-size: var(--font-size-xs);
    font-weight: var(--fw-semibold);
  }

  &__counter-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 0;
    border-radius: var(--radius-round);
    background-color: transparent;
    color: var(--color-text);
    transition: background-color var(--transition-fast), color var(--transition-fast);

    .icon {
      width: var(--icon-sm);
      height: var(--icon-sm);
    }

    &:hover {
      background-color: var(--color-primary);
      color: var(--color-white);
    }
  }

  &__counter-text {
    font-variant-numeric: tabular-nums;
  }

  &__progress {
    position: relative;
    width: 3rem;
    height: 0.1875rem;
    border-radius: var(--radius-pill);
    background-color: var(--color-border);
    overflow: hidden;
  }

  &__progress-bar {
    position: absolute;
    inset: 0;
    background-color: var(--color-secondary);
    transform: scaleX(0);
    transform-origin: left;

    &.is-running {
      animation: progress-grow 5.8s linear forwards;
    }
  }

  /* ---------- Floating cards ---------- */
  &__float {
    position: absolute;
    z-index: 3;
    transform: translate3d(calc(var(--mx) * var(--depth, 1) * 0.75rem), calc(var(--my) * var(--depth, 1) * 0.75rem), 0);
    transition: transform 0.6s var(--ease-out);

    &--stat {
      --depth: -1;
      top: var(--space-3);
      right: var(--space-3);
      display: none;
    }

    &--product {
      --depth: 1.2;
      left: var(--space-2);
      right: var(--space-2);
      bottom: var(--space-2);
    }
  }

  &__float-card {
    border-radius: var(--radius-xl);
    padding: var(--space-1-5);
    animation: pop-in 0.8s var(--ease-spring) 0.9s both, bob 6s ease-in-out 1.8s infinite;
  }

  &__float--stat &__float-card {
    display: flex;
    flex-direction: column;
    max-width: 10rem;
    padding: var(--space-2);
    animation-delay: 1.1s, 2.4s;
  }

  &__float-spark {
    width: var(--icon-sm);
    height: var(--icon-sm);
    margin-bottom: var(--space-1);
    color: var(--color-secondary);
    animation: spin 10s linear infinite;
  }

  &__stat-value {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    line-height: 1;
    color: var(--color-primary);
  }

  &__stat-label {
    margin-top: var(--space-0-5);
    font-size: var(--font-size-xs);
    line-height: var(--lh-snug);
    color: var(--color-text-muted);
  }
}

/* ===== Mini product (floating card) ===== */
.mini-product {
  display: flex;
  align-items: center;
  gap: var(--space-1-5);

  &__image {
    width: 3.5rem;
    height: 3.5rem;
    border-radius: var(--radius-md);
    object-fit: cover;
  }

  &__info {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
  }

  &__name {
    overflow: hidden;
    font-size: var(--font-size-sm);
    font-weight: var(--fw-semibold);
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  &__price {
    font-size: var(--font-size-sm);
    color: var(--color-sale);

    s {
      margin-left: var(--space-0-5);
      color: var(--color-text-muted);
    }
  }
}

/* ===== Hero keyframes ===== */
@keyframes rise {
  from { opacity: 0; transform: translate3d(0, 2rem, 0); }
  to   { opacity: 1; transform: none; }
}

@keyframes rise-y {
  from { transform: translate3d(0, 1.5rem, 0); }
  to   { transform: none; }
}

@keyframes mask-in {
  from { clip-path: inset(100% 0 0 0 round var(--radius-2xl)); }
  to   { clip-path: inset(0 0 0 0 round var(--radius-2xl)); }
}

@keyframes draw {
  from { stroke-dashoffset: 320; }
  to   { stroke-dashoffset: 0; }
}

/* Uses individual scale / translate so the parallax transform stays free */
@keyframes pop-in {
  from { opacity: 0; scale: 0.8; }
  to   { opacity: 1; scale: 1; }
}

@keyframes bob {
  0%, 100% { translate: 0 0; }
  50%      { translate: 0 -0.5rem; }
}
