/*
 * Homepage banner.
 *
 * Self-contained on purpose: the themes' Tailwind build only scans app/design, so
 * utility classes written in this module's template would never be generated, and
 * cli/post_deploy does not run the frontend build at all. Everything here is scoped
 * under .hajtech-banner and uses no theme tokens, so it behaves the same in all four
 * NGD themes.
 */

.hajtech-banner {
    position: relative;
    overflow: hidden;
}

/* Alpine strips x-cloak once it has taken over. Hyvä declares this rule too; it is
   repeated here so the controls stay hidden even if that ever changes. */
.hajtech-banner [x-cloak] {
    display: none !important;
}

/*
 * All slides share one grid cell. The band is therefore as tall as the tallest slide
 * and never resizes while the slider runs — no absolute positioning, no fixed height.
 */
.hajtech-banner__viewport {
    display: grid;
}

.hajtech-banner__slide {
    grid-area: 1 / 1;
    min-width: 0;
}

.hajtech-banner__link {
    display: block;
}

.hajtech-banner__image {
    display: block;
    width: 100%;
    height: auto;
    /* Caps the height on wide viewports, where a 3:1 image would otherwise push the
       rest of the page below the fold. object-fit crops instead of distorting. */
    max-height: 24rem;
    object-fit: cover;
    object-position: center;
}

@media (min-width: 768px) {
    .hajtech-banner__image {
        max-height: 32rem;
    }
}

@media (min-width: 1024px) {
    .hajtech-banner__image {
        max-height: 40rem;
    }
}

/* Set by the template from the "Aspect Ratio" setting; absent means "keep the
   original proportions". */
.hajtech-banner--fixed-ratio .hajtech-banner__image {
    aspect-ratio: var(--hajtech-banner-ratio);
}

/*
 * Slider. Only the active slide is visible; `visibility` rather than `display` keeps
 * the grid cell — and with it the height of the band — filled by every slide, and it
 * also takes the hidden slides' links out of the tab order.
 */
.hajtech-banner--slider .hajtech-banner__slide {
    opacity: 0;
    visibility: hidden;
    transition: opacity 600ms ease-in-out, visibility 0s linear 600ms;
}

.hajtech-banner--slider .hajtech-banner__slide.is-active {
    opacity: 1;
    visibility: visible;
    transition: opacity 600ms ease-in-out, visibility 0s linear 0s;
}

.hajtech-banner__arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    border: 0;
    border-radius: 9999px;
    /* Neutral translucent white so the controls read on any brand palette. */
    background-color: rgba(255, 255, 255, 0.8);
    color: #1f2937;
    cursor: pointer;
    transition: background-color 150ms ease-in-out;
}

.hajtech-banner__arrow:hover {
    background-color: rgba(255, 255, 255, 0.95);
}

.hajtech-banner__arrow:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.hajtech-banner__arrow svg {
    width: 1.5rem;
    height: 1.5rem;
}

.hajtech-banner__arrow--prev {
    left: 0.75rem;
}

.hajtech-banner__arrow--next {
    right: 0.75rem;
}

.hajtech-banner__dots {
    position: absolute;
    left: 50%;
    bottom: 0.875rem;
    transform: translateX(-50%);
    display: flex;
    gap: 0.5rem;
}

.hajtech-banner__dot {
    width: 0.75rem;
    height: 0.75rem;
    padding: 0;
    border: 0;
    border-radius: 9999px;
    background-color: rgba(255, 255, 255, 0.55);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: background-color 150ms ease-in-out;
}

.hajtech-banner__dot.is-active {
    background-color: rgba(255, 255, 255, 1);
}

.hajtech-banner__dot:focus-visible {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

@media (max-width: 639px) {
    /* Arrows sit on top of the image and eat a lot of a phone screen; the dots alone
       are enough there, and swiping is not what this banner is for. */
    .hajtech-banner__arrow {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .hajtech-banner--slider .hajtech-banner__slide,
    .hajtech-banner--slider .hajtech-banner__slide.is-active {
        transition: none;
    }
}
