/* ==========================================================================
   Home page hero  (views/partials/slider.hbs, behaviour in js/script.js)

   Full-bleed photo. A navy caption tab with an angled edge is attached to the
   bottom-left (only on slides that have text); photo thumbnails on the
   bottom-right switch slides, and the active thumbnail's gold bar is the
   autoplay timer. A small pointed arch rises from the page below into the
   photo, and each new photo opens outward from it.

   Phones: the photo stays full-width, and caption + thumbnails sit below it
   so no text ever covers the picture.
   ========================================================================== */

.hero {
    --navy: #111d42;
    --navy-deep: #0b1332;
    --gold: #d1a24f;
    --hero-h: clamp(480px, calc(100vh - 170px), 680px);
    --hero-delay: 7s;           /* time each slide stays */
    --reveal: 1.25s;            /* length of the photo-opening transition */

    position: relative;
    color: #fff;
    background: var(--navy-deep);
    font-family: 'Raleway', 'PT Sans', Arial, sans-serif;
}

.hero h2,
.hero p {
    margin: 0;
}


/* --------------------------------------------------------------------------
   Photos
   -------------------------------------------------------------------------- */

.hero__slides {
    position: relative;
    height: var(--hero-h);
    overflow: hidden;
    background: var(--navy-deep);
}

/* soft shade at the foot of the photo, behind the tab and thumbnails */
.hero__slides::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3;
    height: 34%;
    background: linear-gradient(to top, rgba(11, 19, 50, .5), transparent);
    pointer-events: none;
}

/* The outgoing slide stays visible until the incoming one has finished opening. */
.hero__slide {
    position: absolute;
    inset: 0;
    z-index: 1;
    visibility: hidden;
    transition: visibility 0s linear var(--reveal);
}

.hero__slide.is-active {
    z-index: 2;
    visibility: visible;
    transition: none;
}

.hero__slide img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 50% 30%;
}

/* New photo opens outward from the arch at the bottom centre. */
.hero__slide.is-entering {
    animation: hero-open var(--reveal) cubic-bezier(.65, 0, .25, 1) both;
}

@keyframes hero-open {
    from { clip-path: circle(0% at 50% 100%); }
    to   { clip-path: circle(125% at 50% 100%); }
}

/* slow settle after each change */
.hero.is-ready .hero__slide.is-active img {
    animation: hero-settle 9s ease-out both;
}

@keyframes hero-settle {
    from { transform: scale(1.07); }
    to   { transform: none; }
}

.hero__slides:has(.hero__slide--fallback)::after {
    display: none;              /* the foot shade would only muddy the light fallback panel */
}

/* no photo from the CMS (e.g. API down): crest on a light panel, as the logo is made for light backgrounds */
.hero__slide--fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 50% 45%, #fffdf8, #efe5d0 85%);
}

.hero__slide--fallback img {
    width: auto;
    height: 55%;
    max-height: 300px;
    object-fit: contain;
}

/* pointed arch: the colour of the section below (white on desktop) */
.hero__notch {
    position: absolute;
    left: 0;
    bottom: -1px;
    z-index: 4;
    width: 100%;
    height: 64px;
    pointer-events: none;
}

.hero__notch path {
    fill: #fff;
}


/* --------------------------------------------------------------------------
   Caption tab + thumbnails
   -------------------------------------------------------------------------- */

.hero__overlay {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    pointer-events: none;       /* let clicks reach the photo area; controls re-enable it */
}

.hero__overlay-inner {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
}

/* All caption tabs share one grid cell, anchored to the bottom. */
.hero__texts {
    display: grid;
    grid-template-columns: minmax(0, 1fr);   /* so a long title wraps instead of widening the tab */
    align-items: end;
    flex: 0 1 500px;
    min-width: 0;
    counter-reset: slide;
    pointer-events: auto;
}

.hero__text {
    grid-area: 1 / 1;
    align-self: end;
    counter-increment: slide;
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px);
    transition: opacity .35s ease, transform .35s ease, visibility 0s linear .35s;
}

.hero__text.is-active {
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: opacity .6s ease .55s, transform .6s ease .55s;
}

.hero__plate {
    position: relative;
    width: max-content;
    max-width: 100%;
    padding: 24px 58px 30px 30px;
    background: var(--navy);
    border-top: 4px solid var(--gold);
    -webkit-clip-path: polygon(0 0, 100% 0, calc(100% - 32px) 100%, 0 100%);
    clip-path: polygon(0 0, 100% 0, calc(100% - 32px) 100%, 0 100%);
}

.hero__plate:empty {
    display: none;              /* photo-only slide: no tab */
}

/* Institute-name stand-in for photo-only slides; used on phones only (see below). */
.hero__plate--default {
    display: none;
}

/* slide number */
.hero__plate::before {
    content: counter(slide, decimal-leading-zero);
    display: block;
    margin-bottom: 10px;
    font-size: 14px;
    font-weight: 800;
    letter-spacing: .1em;
    color: var(--gold);
}

.hero:not(.is-ready) .hero__plate::before {
    display: none;              /* no counter when there is only one slide */
}

.hero__title {
    font-family: 'Playfair Display', Georgia, 'Times New Roman', serif;
    font-size: clamp(24px, 2.4vw, 34px);
    font-weight: 700;
    line-height: 1.2;
    color: #fff;
    text-transform: none;
    text-wrap: balance;         /* even line lengths, no lonely last word */
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    overflow: hidden;
}

.hero__lead {
    margin-top: 10px;
    font-size: 15px;
    line-height: 1.6;
    color: rgba(255, 255, 255, .8);
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    overflow: hidden;
}

.hero__cta {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-top: 16px;
    padding: 9px 20px;
    border-radius: 999px;
    background: var(--gold);
    color: var(--navy-deep);
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
    text-decoration: none;
    transition: background-color .2s ease, color .2s ease;
}

.hero__cta:hover,
.hero__cta:focus {
    background: #fff;
    color: var(--navy-deep);
    text-decoration: none;
}

.hero a:focus-visible,
.hero button:focus-visible {
    outline: 2px solid var(--gold);
    outline-offset: 3px;
}

/* Rail: only useful once JS is running with 2+ slides. */
.hero__rail {
    display: none;
    align-items: center;
    gap: 10px;
    flex: none;
    padding-bottom: 30px;
    pointer-events: auto;
}

.hero.is-ready .hero__rail {
    display: flex;
}

.hero__arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .55);
    border-radius: 50%;
    background: rgba(11, 19, 50, .55);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: background-color .2s ease, color .2s ease, border-color .2s ease;
}

.hero__arrow:hover,
.hero__arrow:focus {
    background: var(--gold);
    border-color: var(--gold);
    color: var(--navy-deep);
}

.hero__thumb {
    position: relative;
    flex: none;
    width: 112px;
    height: 70px;
    padding: 0;
    border: 2px solid rgba(255, 255, 255, .6);
    border-radius: 8px;
    overflow: hidden;
    background: var(--navy-deep);
    opacity: .8;
    cursor: pointer;
    transition: opacity .2s ease, border-color .2s ease;
}

.hero__thumb:hover {
    opacity: 1;
}

.hero__thumb.is-active {
    border-color: var(--gold);
    opacity: 1;
}

.hero__thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: 50% 30%;
}

/* gold bar along the foot of the active thumbnail = autoplay timer */
.hero__fill {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 4px;
    background: var(--gold);
    transform: scaleX(0);
    transform-origin: left;
}

.hero.is-ready .hero__thumb.is-active .hero__fill {
    animation: hero-fill var(--hero-delay) linear forwards;
}

@keyframes hero-fill {
    to { transform: scaleX(1); }
}

/* Pause the timer while focus is inside the hero or the pointer is over it. */
.hero:focus-within .hero__thumb.is-active .hero__fill {
    animation-play-state: paused;
}

@media (hover: hover) {
    .hero:hover .hero__thumb.is-active .hero__fill {
        animation-play-state: paused;
    }
}


/* --------------------------------------------------------------------------
   The page continues below the arch
   -------------------------------------------------------------------------- */

/* The Mission / Vision / Values band that follows is cream (pillars.css), so the
   arch takes its colour. On phones the arch is navy instead, see below. */
@media (min-width: 768px) {
    .hero:has(+ .pillars) .hero__notch path {
        fill: #f6f1e6;
    }
}


/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

/* Smaller thumbnails keep the controls clear of the arch in the middle. */
@media (max-width: 1199px) {
    .hero__thumb {
        width: 88px;
        height: 56px;
    }
}

@media (max-width: 991px) {
    .hero {
        --hero-h: clamp(420px, 62vw, 560px);
    }

    .hero__texts {
        flex-basis: 52%;
    }

    .hero__plate {
        padding: 20px 50px 24px 24px;
    }

    .hero__thumb {
        width: 72px;
        height: 48px;
    }

    .hero__arrow {
        width: 38px;
        height: 38px;
        font-size: 20px;
    }

    .hero__notch {
        height: 52px;
    }
}

/* Phones: photo on top; caption and thumbnails in a navy band underneath. */
@media (max-width: 767px) {
    .hero {
        background: var(--navy);
    }

    .hero__slides {
        height: auto;
        aspect-ratio: 16 / 10;
    }

    .hero__notch {
        height: 34px;
    }

    .hero__notch path {
        fill: var(--navy);      /* the band below is navy here */
    }

    .hero__overlay {
        position: static;
    }

    .hero__overlay-inner {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        padding-bottom: 28px;
    }

    /* Thumbnails above the caption: the caption cell is as tall as the longest
       slide, so on shorter slides the spare height is just quiet space at the end. */
    .hero__rail {
        order: -1;
        padding: 18px 0 0;
    }

    .hero__texts {
        flex: none;
        align-items: start;
    }

    .hero__text {
        align-self: start;
    }

    .hero__plate {
        width: auto;
        padding: 22px 0 0;
        background: none;
        border-top: 0;
        -webkit-clip-path: none;
        clip-path: none;
    }

    .hero__plate:empty + .hero__plate--default {
        display: block;         /* photo-only slide: show the institute name in the band */
    }

    .hero__thumb {
        flex: 1;
        width: auto;
        height: 52px;
    }

    .hero__arrow {
        width: 40px;
        height: 40px;
        font-size: 22px;
    }

    .hero__lead {
        font-size: 15px;
    }
}

@media (max-width: 479px) {
    .hero__title {
        font-size: 22px;
    }

    .hero__rail {
        gap: 8px;
    }
}

/* Reduced motion: no opening transition, settle zoom or autoplay timer. */
@media (prefers-reduced-motion: reduce) {
    .hero__slide.is-entering,
    .hero.is-ready .hero__slide.is-active img {
        animation: none;
    }

    .hero.is-ready .hero__thumb.is-active .hero__fill {
        animation: none;
        transform: scaleX(1);
    }

    .hero__slide,
    .hero__text,
    .hero__text.is-active {
        transition-duration: .01s;
        transition-delay: 0s;
    }
}
