/* =============================================
   Homepage hero carousel (managed from /panel/hero/)
   Uses the site tokens from main.css: green #1a302a, gold #c4a265,
   Amiri headings, Tajawal body.
   ============================================= */

.hero-carousel {
    --hero-speed: 900ms;
    --hero-interval: 6s;
    position: relative;
    flex: 1 1 auto;
    width: 100%;
    min-height: clamp(420px, 62vh, 760px);
    overflow: hidden;
    background-color: var(--color-bg-slot);
    isolation: isolate;
}

/* Desktop homepage fills the screen below the header (see body.page-home). */
body.page-home .hero-carousel {
    min-height: 420px;
}

.hero-carousel__viewport {
    position: absolute;
    inset: 0;
    touch-action: pan-y;
}

.hero-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    visibility: hidden;
    transition:
        opacity var(--hero-speed) cubic-bezier(0.4, 0, 0.2, 1),
        visibility 0s linear var(--hero-speed),
        transform var(--hero-speed) cubic-bezier(0.4, 0, 0.2, 1);
}

.hero-slide.is-active {
    opacity: 1;
    visibility: visible;
    transition:
        opacity var(--hero-speed) cubic-bezier(0.4, 0, 0.2, 1),
        visibility 0s,
        transform var(--hero-speed) cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
}

.hero-slide__media,
.hero-slide__img {
    display: block;
    width: 100%;
    height: 100%;
}

.hero-slide__img {
    object-fit: cover;
    object-position: center;
    background-color: var(--color-bg-slot);
}

/* Fade + gentle zoom ("Ken Burns") */
.hero-carousel--zoom .hero-slide__img {
    transform: scale(1.06);
    transition: transform calc(var(--hero-interval) + var(--hero-speed)) ease-out;
}

.hero-carousel--zoom .hero-slide.is-active .hero-slide__img {
    transform: scale(1);
}

/* Slide: transforms are set by hero-carousel.js; keep both slides visible */
.hero-carousel--slide .hero-slide {
    opacity: 1;
}

.hero-carousel--slide .hero-slide:not(.is-active):not(.is-leaving) {
    visibility: hidden;
}

.hero-carousel--slide .hero-slide.is-leaving {
    visibility: visible;
    z-index: 1;
}

/* Legibility shade for text, darker on the text side (right in RTL). */
.hero-slide__shade {
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        linear-gradient(270deg, rgba(18, 32, 24, 0.72) 0%, rgba(18, 32, 24, 0.38) 38%, rgba(18, 32, 24, 0) 66%),
        linear-gradient(0deg, rgba(18, 32, 24, 0.35) 0%, rgba(18, 32, 24, 0) 30%);
}

.hero-slide__content {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    padding-block: 48px 72px;
    pointer-events: none;
}

.hero-slide__content > * {
    max-width: 520px;
    pointer-events: auto;
}

/* The whole slide is one link (above the picture and the text, below arrows and dots). */
.hero-slide__link {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: block;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.hero-slide__link:focus-visible {
    outline: 2px solid #fff;
    outline-offset: -8px;
}

.hero-slide__title {
    font-family: var(--font-heading);
    font-size: clamp(2rem, 3.6vw, 3.1rem);
    font-weight: 700;
    line-height: 1.3;
    color: #fff;
    margin: 0 0 14px;
    text-shadow: 0 2px 18px rgba(0, 0, 0, 0.18);
}

.hero-slide__desc {
    font-size: clamp(0.92rem, 1.2vw, 1.05rem);
    line-height: 1.85;
    color: rgba(255, 255, 255, 0.9);
    margin: 0 0 26px;
}

.hero-slide__btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 13px 24px;
    border-radius: var(--radius-md);
    background-color: var(--color-gold);
    color: var(--color-primary-dark);
    font-weight: 700;
    border: 1px solid transparent;
    transition: background-color var(--transition), transform var(--transition);
}

.hero-slide__btn:hover,
.hero-slide__btn:focus-visible {
    background-color: var(--color-gold-light);
    transform: translateY(-1px);
}

.hero-slide__btn:focus-visible,
.hero-carousel__arrow:focus-visible,
.hero-carousel__dot:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
}

/* Text entrance: a short rise once the slide is shown */
.hero-slide.has-text .hero-slide__content > * {
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.7s ease, transform 0.7s ease;
}

.hero-slide.is-active.has-text .hero-slide__content > * {
    opacity: 1;
    transform: none;
}

.hero-slide.is-active.has-text .hero-slide__content > :nth-child(2) { transition-delay: 0.12s; }
.hero-slide.is-active.has-text .hero-slide__content > :nth-child(3) { transition-delay: 0.24s; }

/* Arrows */
.hero-carousel__arrow {
    position: absolute;
    top: 50%;
    z-index: 3;
    width: 48px;
    height: 48px;
    margin-top: -24px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 50%;
    background: rgba(18, 32, 24, 0.28);
    color: #fff;
    cursor: pointer;
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    opacity: 0.85;
    transition: background-color var(--transition), opacity var(--transition);
}

.hero-carousel__arrow:hover {
    background: rgba(18, 32, 24, 0.55);
    opacity: 1;
}

/* RTL: previous on the right, next on the left */
.hero-carousel__arrow--prev { inset-inline-start: 20px; }
.hero-carousel__arrow--next { inset-inline-end: 20px; }

/* Indicators: thin bars with a progress fill for the active slide */
.hero-carousel__dots {
    position: absolute;
    bottom: 24px;
    left: 50%;
    z-index: 3;
    display: flex;
    gap: 8px;
    transform: translateX(-50%);
}

.hero-carousel__dot {
    position: relative;
    width: 34px;
    height: 14px;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
}

.hero-carousel__dot span {
    position: absolute;
    inset: 5px 0;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.4);
    overflow: hidden;
}

.hero-carousel__dot span::after {
    content: "";
    position: absolute;
    inset: 0;
    background: #fff;
    transform: scaleX(0);
    transform-origin: right center;
}

.hero-carousel__dot.is-active span::after {
    transform: scaleX(1);
}

.hero-carousel.is-playing .hero-carousel__dot.is-active span::after {
    animation: hero-progress var(--hero-interval) linear forwards;
}

.hero-carousel.is-paused .hero-carousel__dot.is-active span::after {
    animation-play-state: paused;
}

@keyframes hero-progress {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

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

/* ---- Tablet ---- */
@media (max-width: 1024px) {
    .hero-slide__content > * { max-width: 440px; }
}

/* ---- Mobile ---- */
@media (max-width: 768px) {
    .hero-carousel,
    body.page-home .hero-carousel {
        flex: 0 0 auto;
        min-height: 0;
        aspect-ratio: 4 / 5;
        max-height: 82svh;
        margin: 0 14px 16px;
        width: auto;
        border-radius: 20px;
    }

    .hero-slide__shade {
        background: linear-gradient(0deg, rgba(18, 32, 24, 0.78) 0%, rgba(18, 32, 24, 0.35) 45%, rgba(18, 32, 24, 0) 70%);
    }

    .hero-slide__content {
        justify-content: flex-end;
        padding: 20px 18px 46px;
    }

    .hero-slide__content > * { max-width: none; }

    .hero-slide__title {
        font-size: clamp(1.7rem, 7vw, 2.2rem);
        margin-bottom: 10px;
    }

    .hero-slide__desc {
        font-size: 0.88rem;
        line-height: 1.7;
        margin-bottom: 16px;
    }

    .hero-slide__btn {
        width: 100%;
        justify-content: center;
        border-radius: 12px;
    }

    /* Swipe on phones; arrows would cover the image */
    .hero-carousel__arrow { display: none; }

    .hero-carousel__dots { bottom: 16px; }
}

@media (prefers-reduced-motion: reduce) {
    .hero-carousel { --hero-speed: 200ms; }

    .hero-carousel--zoom .hero-slide__img,
    .hero-carousel--zoom .hero-slide.is-active .hero-slide__img {
        transform: none;
        transition: none;
    }

    .hero-slide.has-text .hero-slide__content > * {
        transition: none;
        transform: none;
    }

    .hero-carousel.is-playing .hero-carousel__dot.is-active span::after {
        animation: none;
    }
}
