/* File: assets/css/home_hero.css
   Homepage top block: contained PR banner (16:9) + leaders slider.
   Markup lives in index.php, behaviour in assets/js/home_scripts.js (pvHeroCarousel).
   Visual contract: docs/mockups/HOME_HERO_LEADERS_MOCKUP.html section 1.
   Motion: horizontal slide via transform (compositor, Web Animations) that follows the pointer while dragging, exponential
   ease-out; prefers-reduced-motion shows the final state. */

.hh-hero {
    --hh-surface: #fff;
    --hh-surface-2: #f3f4f6;
    --hh-line: #d8dee7;
    --hh-ink: #1f2937;
    --hh-brand: var(--primary-color, #C00000);
    --hh-gold: var(--secondary-color, #D4AF37);
    --hh-ease: cubic-bezier(0.16, 1, 0.3, 1);
    padding: 1.25rem 0 0.5rem;
}

/* The public site has no theme switch yet; dark tokens follow the shared class convention (html.dark). */
html.dark .hh-hero,
body.dark-mode .hh-hero {
    --hh-surface: #182231;
    --hh-surface-2: #202d3e;
    --hh-line: #3b495c;
    --hh-ink: #edf2f8;
    --hh-brand: #ff8b91;
    --hh-gold: #e6c35a;
}

.hh-top {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 270px;
    gap: 16px;
    align-items: stretch;
}

/* One block only: it spans the full width. */
.hh-top--banner-only,
.hh-top--leaders-only {
    grid-template-columns: minmax(0, 1fr);
}

/* ---------- Banner ---------- */
.hh-banner {
    position: relative;
    border-radius: 12px;
    overflow: hidden;
    background: #222;
    aspect-ratio: 16 / 9;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
}

.hh-slide {
    position: absolute;
    inset: 0;
    display: block;
    visibility: hidden;
}

/* .on = current, .leaving = outgoing while sliding, .peek = neighbour shown while dragging.
   The slide itself is a transform animation driven by pvHeroCarousel. */
.hh-slide.on,
.hh-slide.leaving,
.hh-slide.peek {
    visibility: visible;
}

.hh-slide img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    user-select: none;
    -webkit-user-drag: none;
}

a.hh-slide {
    text-decoration: none;
    cursor: pointer;
}

a.hh-slide:focus-visible {
    outline: 3px solid #fff;
    outline-offset: -6px;
    box-shadow: inset 0 0 0 6px var(--hh-brand);
}

.hh-link-chip {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 15px;
    line-height: 1;
}

.hh-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 36px;
    height: 36px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    color: #fff;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s var(--hh-ease);
}

.hh-nav[hidden] {
    display: none;
}

.hh-prev { left: 10px; }
.hh-next { right: 10px; }

.hh-banner:hover .hh-nav,
.hh-nav:focus-visible {
    opacity: 1;
}

.hh-nav:focus-visible,
.hh-dot:focus-visible,
.hh-pg:focus-visible {
    outline: 2px solid var(--hh-brand);
    outline-offset: 2px;
}

/* Touch screens swipe instead of using arrows. */
@media (hover: none) {
    .hh-nav { display: none; }
}

/* ---------- Dots / counter (shared) ---------- */
.hh-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2px;
}

.hh-dots[hidden] {
    display: none;
}

.hh-banner .hh-dots {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 10px;
    pointer-events: none;
}

.hh-banner .hh-dots > * {
    pointer-events: auto;
}

.hh-dot {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    background: transparent;
    display: grid;
    place-items: center;
    cursor: pointer;
}

.hh-dot::after {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s var(--hh-ease), background-color 0.2s var(--hh-ease);
}

.hh-dot.on::after {
    background: #fff;
    transform: scale(1.35);
}

.hh-dots--compact {
    gap: 8px;
}

.hh-count {
    min-width: 64px;
    padding: 3px 10px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.hh-pg {
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

/* ---------- Leaders ---------- */
.hh-leaders {
    position: relative;
    min-height: 400px;
    border: 1px solid var(--hh-line);
    border-radius: 12px;
    background: var(--hh-surface);
    color: var(--hh-ink);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
}

/* Beside the banner the card takes the banner's height: the inner box is out of flow, so the photo
   shrinks to fit instead of stretching the row. */
.hh-leaders-inner {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
}

.hh-leaders-head {
    flex: 0 0 auto;
    padding: 8px 14px;
    border-bottom: 1px solid var(--hh-line);
    font-weight: 600;
    font-size: 14px;
    line-height: 1.5;
    color: var(--hh-brand);
}

.hh-stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

.hh-leader {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 12px 16px 8px;
    text-align: center;
    visibility: hidden;
}

.hh-leader.on,
.hh-leader.leaving,
.hh-leader.peek {
    visibility: visible;
}

.hh-portrait {
    flex: 1 1 0;
    min-height: 0;
    max-width: 100%;
    aspect-ratio: 3 / 4;
    border-radius: 10px;
    border: 2px solid var(--hh-gold);
    overflow: hidden;
    background: var(--hh-surface-2);
}

.hh-portrait img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    user-select: none;
    -webkit-user-drag: none;
}

/* Text block has a fixed height (2 lines name + 2 lines position) so the photo never changes size between leaders. */
.hh-leader-text {
    flex: 0 0 84px;
    width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.hh-leader-name {
    font-weight: 600;
    font-size: 16px;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
}

.hh-leader-pos {
    font-size: 13px;
    font-weight: 500;
    line-height: 1.45;
    color: var(--hh-brand);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
}

.hh-leaders .hh-dots {
    flex: 0 0 auto;
    padding-bottom: 6px;
}

.hh-leaders .hh-dot::after {
    background: var(--hh-line);
    box-shadow: none;
}

.hh-leaders .hh-dot.on::after {
    background: var(--hh-brand);
}

.hh-leaders .hh-count,
.hh-leaders .hh-pg {
    background: var(--hh-surface-2);
    color: var(--hh-ink);
    border: 1px solid var(--hh-line);
}

/* Leaders on their own row (alone, or stacked under the banner): normal flow with a fixed photo size. */
.hh-top--leaders-only .hh-leaders,
.hh-top--leaders-only .hh-leaders-inner {
    min-height: 0;
}

.hh-top--leaders-only .hh-leaders-inner {
    position: static;
}

.hh-top--leaders-only .hh-stage {
    flex: none;
    height: 465px;
}

.hh-top--leaders-only .hh-portrait {
    flex: 0 0 auto;
    width: min(260px, 100%);
}

@media (max-width: 760px) {
    .hh-hero {
        padding-top: 0.75rem;
    }

    .hh-top {
        grid-template-columns: minmax(0, 1fr);
        gap: 12px;
    }

    .hh-leaders {
        min-height: 0;
    }

    .hh-leaders-inner {
        position: static;
    }

    .hh-stage {
        flex: none;
        height: 420px;
    }

    .hh-portrait {
        flex: 0 0 auto;
        width: min(220px, 100%);
    }

    .hh-top--leaders-only .hh-stage {
        height: 420px;
    }

    .hh-top--leaders-only .hh-portrait {
        width: min(220px, 100%);
    }
}

/* ---------- Theme modes (site-wide switches in frontend_style.css) ----------
   Mourning and muted modes already override --primary-color / --secondary-color (used above) and
   grayscale every <img> and <button>, so banner photos, leader portraits and the arrows follow them.
   The rules below only cover what those global rules do not reach. */
body.mourning-mode .hh-banner {
    background-color: #555;
}

body.mourning-mode .hh-link-chip,
body.mourning-mode .hh-count,
body.mourning-mode .hh-leaders .hh-count {
    filter: grayscale(100%);
}

body.muted-mode .hh-link-chip {
    filter: grayscale(80%);
}

/* ---------- Reduced motion: show the final state, no transitions (JS also stops auto-advance and the slide) ---------- */
@media (prefers-reduced-motion: reduce) {
    .hh-nav,
    .hh-dot::after {
        transition: none;
    }
}
