/* ---------------------------------
 * Home Hero
 * --------------------------------- */

.home-hero {
    --hero-ease-out: cubic-bezier(0.23, 1, 0.32, 1);

    display: grid;
    align-items: center;
    gap: 4rem;
    padding-block: clamp(3rem, 8vw, 6.5rem);
    overflow-x: clip;
}

.home-hero-title {
    font-size: clamp(2.75rem, 6vw, 5rem);
    line-height: 0.95;
    letter-spacing: -0.045em;
    margin-bottom: 1.5rem;
    text-wrap: balance;
}

[dir='rtl'] .home-hero-title {
    line-height: 1.3;
    letter-spacing: normal;
}

.home-hero-lead {
    max-width: 34rem;
    color: var(--tblr-secondary);
    font-size: 1.25rem;
    line-height: 1.6;
    margin-bottom: 0;
}

.home-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 2.25rem;
}

.home-hero-markets {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    margin-top: 2.5rem;
    color: var(--tblr-secondary);
}

.home-hero-markets ul {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0;
    margin: 0;
    list-style: none;
}

.home-hero-markets .chip {
    padding: 0.375rem 0.75rem;
}

/* The receipt stack: the coupon and price alert that produced the receipt's savings.
   Desktop only: stacked under the copy, it pushes the real offers further down */
.home-hero-visual {
    --visual-shadow: var(--tblr-body-color);

    position: relative;
    isolation: isolate;
    display: none;
    width: 100%;
    max-width: 24rem;
    margin-block: 1.5rem;
}

[data-bs-theme='dark'] .home-hero-visual {
    --visual-shadow: #000;
}

/* The logo's double slash, oversized behind the stack */
.home-hero-slashes::before,
.home-hero-slashes::after {
    content: '';
    position: absolute;
    z-index: -1;
    top: -12%;
    bottom: -12%;
    width: 3.5rem;
    border-radius: 3rem;
    background-color: color-mix(in srgb, var(--tblr-primary) 9%, transparent);
    transform: skewX(-18deg);
}

.home-hero-slashes::before {
    inset-inline-start: 30%;
}

.home-hero-slashes::after {
    inset-inline-start: 58%;
}

.home-hero-coupon {
    --coupon-tilt: 9deg;
    --coupon-from: -40%;

    position: absolute;
    z-index: 2;
    top: -2.25rem;
    inset-inline-end: 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.875rem 1.75rem;
    border-radius: 0.5rem;
    background-color: var(--tblr-primary);
    color: #fff;
    transform: rotate(var(--coupon-tilt));
    /* Ticket notches on both sides */
    mask:
        radial-gradient(circle 0.5rem at 0 50%, #0000 98%, #000) 0 0 / 51% 100% no-repeat,
        radial-gradient(circle 0.5rem at 100% 50%, #0000 98%, #000) 100% 0 / 51% 100% no-repeat;
}

[dir='rtl'] .home-hero-coupon {
    --coupon-tilt: -9deg;
    --coupon-from: 40%;
}

.home-hero-coupon strong {
    font-family: var(--app-font-display);
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1.1;
}

.home-hero-coupon span {
    font-size: 0.875rem;
}

.home-hero-alert {
    position: absolute;
    z-index: 2;
    bottom: -1.75rem;
    inset-inline-start: -0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.125rem 0.75rem 0.75rem;
    border: 1px solid var(--tblr-border-color);
    border-radius: 0.875rem;
    background-color: var(--tblr-bg-surface);
    box-shadow: 0 0.75rem 1.5rem color-mix(in srgb, var(--visual-shadow) 12%, transparent);
    transform: rotate(-3deg);
}

[dir='rtl'] .home-hero-alert {
    padding: 0.75rem 0.75rem 0.75rem 1.125rem;
    transform: rotate(3deg);
}

.home-hero-alert-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    background-color: color-mix(in srgb, var(--tblr-primary) 12%, transparent);
    color: var(--tblr-primary);
    font-size: 1.25rem;
}

.home-hero-alert strong,
.home-hero-alert small {
    display: block;
}

.home-hero-alert small {
    color: var(--tblr-secondary);
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
}

/* An example receipt where a red dash strikes the listed price */
.home-hero-receipt {
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 1.5rem 2rem color-mix(in srgb, var(--visual-shadow) 14%, transparent))
        drop-shadow(0 2px 3px color-mix(in srgb, var(--visual-shadow) 8%, transparent));
    font-variant-numeric: tabular-nums;
}

@media (min-width: 992px) {
    .home-hero {
        grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
        gap: 4rem;
    }

    .home-hero-visual {
        display: block;
        justify-self: end;
        margin-inline-end: 2.5rem;
    }

    .home-hero-coupon {
        inset-inline-end: -2.75rem;
    }

    .home-hero-alert {
        inset-inline-start: -3rem;
    }
}

@media (max-width: 575.98px) {
    .home-hero {
        padding-block: 2.5rem;
    }

    .home-hero-lead {
        font-size: 1.125rem;
    }

    .home-hero-actions {
        margin-top: 1.75rem;
    }

    .home-hero-actions .btn {
        flex: 1 1 auto;
    }

    .home-hero-markets {
        margin-top: 2rem;
    }
}

/* One load sequence: the receipt lands, prints its lines, then the price gets struck */
.home-hero-receipt {
    animation: receipt-land 700ms var(--hero-ease-out) both;
}

.home-hero-alert {
    animation: alert-pop 450ms var(--hero-ease-out) 380ms backwards;
}

.home-hero-coupon {
    animation: coupon-slide 600ms var(--hero-ease-out) 450ms backwards;
}

@keyframes receipt-land {
    from {
        transform: translateY(1.5rem);
    }
}

@keyframes alert-pop {
    from {
        opacity: 0;
        transform: translateY(0.75rem) scale(0.95);
    }
}

/* Slides out from behind the receipt */
@keyframes coupon-slide {
    from {
        opacity: 0;
        transform: translate(var(--coupon-from), 60%) rotate(0deg);
    }
}

@keyframes receipt-fade {
    from {
        opacity: 0;
    }
}

/* Trace each saving to its source: hovering a coupon, alert, or receipt line lights up its pair and quiets the rest */
@media (hover: hover) and (pointer: fine) {
    .home-hero-visual :is(.receipt-line, .home-hero-alert > *) {
        transition: opacity 200ms ease;
    }

    .home-hero-visual :is(.home-hero-coupon, .home-hero-alert) {
        transition:
            opacity 200ms ease,
            translate 250ms var(--hero-ease-out);
    }

    .receipt-line::before {
        transition: opacity 200ms ease;
    }

    /* The alert keeps its surface solid and dims only its content, so the receipt doesn't show through */
    .home-hero-visual:has([data-hero-source='price-drop']:hover)
        :is(.receipt-line, .home-hero-coupon):not([data-hero-source='price-drop']),
    .home-hero-visual:has([data-hero-source='coupon']:hover)
        :is(.receipt-line, .home-hero-coupon):not([data-hero-source='coupon']),
    .home-hero-visual:has([data-hero-source='coupon']:hover) .home-hero-alert > *,
    .home-hero-visual:has([data-hero-source='offer']:hover)
        :is(.receipt-line, .home-hero-coupon):not([data-hero-source='offer']),
    .home-hero-visual:has([data-hero-source='offer']:hover) .home-hero-alert > * {
        opacity: 0.4;
    }

    .home-hero-visual:has([data-hero-source='price-drop']:hover) .receipt-line[data-hero-source='price-drop']::before,
    .home-hero-visual:has([data-hero-source='coupon']:hover) .receipt-line[data-hero-source='coupon']::before,
    .home-hero-visual:has([data-hero-source='offer']:hover) .receipt-line[data-hero-source='offer']::before {
        opacity: 1;
    }
}

/* Movement on top of the highlight, dropped for reduced motion */
@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
    .home-hero-visual:has([data-hero-source='price-drop']:hover) .home-hero-alert {
        translate: 0 -0.375rem;
    }

    .home-hero-visual:has([data-hero-source='coupon']:hover) .home-hero-coupon {
        translate: 0 -0.375rem;
    }

    .home-hero-alert-icon .ti {
        transform-origin: 50% 10%;
    }

    .home-hero-visual:has([data-hero-source='price-drop']:hover) .home-hero-alert-icon .ti {
        animation: alert-ring 600ms var(--hero-ease-out);
    }
}

/* A single swing that decays, pivoting from the bell's top */
@keyframes alert-ring {
    20% {
        transform: rotate(14deg);
    }

    40% {
        transform: rotate(-10deg);
    }

    60% {
        transform: rotate(6deg);
    }

    80% {
        transform: rotate(-3deg);
    }
}

@media (prefers-reduced-motion: no-preference) {
    html:has(.home-hero) {
        scroll-behavior: smooth;
    }
}

@media (prefers-reduced-motion: reduce) {
    .home-hero-visual {
        animation: receipt-fade 300ms ease both;
    }

    .home-hero-visual *,
    .home-hero-visual *::before,
    .home-hero-visual *::after {
        animation: none;
    }
}
