/**
 * PLGC Hero Widget — CSS
 *
 * Figma spec: 1440×698px full-width hero
 *   - Background fills edge-to-edge, image covers with object-fit:cover
 *   - Dark gradient overlay behind text (improves WCAG contrast)
 *   - Centered headline (H1 48px bold Libre Baskerville) + subhead (24px Open Sans)
 *   - Slideshow dots: top-right area of hero (matches Figma hero slider position)
 *   - Announcement pill: bottom-right, dark gradient rounded rectangle
 *   - Pause button: bottom-left corner of hero, 44×44px (WCAG SC 2.5.5)
 *
 * @package PLGC
 * @since   1.6.12
 */


/* ═══════════════════════════════════════════════════════════════════════════
   BASE
   ═══════════════════════════════════════════════════════════════════════════ */
.plgc-hero {
    position: relative;
    width: 100%;
    height: var(--plgc-hero-height, 698px);
    overflow: hidden;
    /* Dark green base: without this, Elementors default grey background bleeds
       through the semi-transparent mid-gradient, creating a visible grey band. */
    background-color: #233C26;
    /* No transform — transform + overflow:hidden on same element causes absolutely-
       positioned children (the background image) to go invisible on real iOS Safari.
       position:relative provides the stacking context; overflow:hidden clips the edges. */
}


/* ── 16:9 native ratio mode ───────────────────────────────────────────────
   Opt-in per widget instance via "Fit hero to video (16:9)" toggle.
   Overrides the fixed pixel/vh height with a true 16:9 aspect ratio.
   max-height:100vh prevents the hero going taller than the screen on very
   wide monitors. --plgc-hero-height is kept in sync via inline style so
   the YouTube contain mode max-width calc still works correctly.           */
.plgc-hero--ratio-16-9 {
    height: auto !important;
    aspect-ratio: 16 / 9;
    max-height: 100vh;
}



.plgc-hero__media {
    position: absolute;
    inset: 0;
}

.plgc-hero__bg-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Always centered — position control removed; crop focus is handled at upload time.
       Use the recommended 2880×1116px image size for best results across all breakpoints. */
    object-position: center center;
    -webkit-user-drag: none;
    user-drag: none;
    pointer-events: none;
}

/* Video — same as image, sits above fallback */
.plgc-hero__video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    pointer-events: none;
    /* Fallback image shows behind the video while it loads */
    z-index: 1;
}

.plgc-hero__video-fallback {
    z-index: 0;
}

/* ── YouTube background iframe ────────────────────────────────────────────
   YouTube iframes are 16:9 and can't use object-fit:cover directly.
   We use the classic oversize + center technique to fill any aspect ratio.

   Two fit modes:
     .is-cover   (default) — scales iframe to fill hero, crops top/bottom.
                             --plgc-yt-pos-y shifts the vertical crop point
                             (0% = show top, 50% = center, 100% = show bottom).
     .is-contain            — respects 16:9, no cropping, black letterbox bars.

   Pointer events:
     Default: none — hero acts as a clean background, custom pause btn handles WCAG.
     .is-interactive: pointer-events enabled so native YouTube controls are usable.
   ─────────────────────────────────────────────────────────────────────── */
.plgc-hero__yt-wrap {
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: hidden;
    /* Dark green base: without this, Elementors default grey background bleeds
       through the semi-transparent mid-gradient, creating a visible grey band. */
    background-color: #233C26;
    pointer-events: none;
}

/* ── Cover mode (default): oversize + center crop ── */
.plgc-hero__yt-wrap.is-cover .plgc-hero__yt-frame {
    position: absolute;
    top: var(--plgc-yt-pos-y, 50%);
    left: 50%;
    /* 16:9 oversized to always cover. Min 100% wide OR 177.8vh (16/9 * 100vh) */
    width: 100%;
    height: 56.25vw;        /* 9/16 of viewport width */
    min-width: 177.78vh;    /* 16/9 of viewport height */
    min-height: 100%;
    transform: translate(-50%, -50%);
    border: 0;
    pointer-events: none;
}

/* ── Contain mode: show full 16:9 video with black bars ── */
.plgc-hero__yt-wrap.is-contain {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

.plgc-hero__yt-wrap.is-contain .plgc-hero__yt-frame {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    /* Fill width; height is driven by 16:9 ratio. Capped at hero height. */
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    max-height: 100%;
    /* If 16:9 height exceeds hero height, constrain height and shrink width */
    max-width: calc(var(--plgc-hero-height, 698px) * 16 / 9);
    min-width: unset;
    min-height: unset;
    border: 0;
    pointer-events: none;
}

/* ── Interactive mode: allow pointer events through to native controls ── */
.plgc-hero__yt-wrap.is-interactive {
    pointer-events: auto;
}
.plgc-hero__yt-wrap.is-interactive .plgc-hero__yt-frame {
    pointer-events: auto;
}

/* Fallback image sits behind the iframe */
.plgc-hero__yt-wrap + .plgc-hero__yt-fallback,
.plgc-hero__yt-fallback {
    z-index: 0;
}

/* Legacy selector for backwards compat (no fit class on old embeds) */
.plgc-hero__yt-frame:not(.is-contain .plgc-hero__yt-frame) {
    /* Handled by .is-cover .plgc-hero__yt-frame above; this is a fallback */
}


/* ═══════════════════════════════════════════════════════════════════════════
   SLIDESHOW
   ═══════════════════════════════════════════════════════════════════════════ */
.plgc-hero__slides {
    position: absolute;
    inset: 0;
}

.plgc-hero__slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.7s ease-in-out;
}

.plgc-hero__slide.is-active {
    opacity: 1;
    z-index: 1;
}

/* Ken Burns: slow zoom on active slide.
   JS adds .is-ken-burns to the .plgc-hero__slides wrapper when enabled.
   prefers-reduced-motion: animation is removed by the media query below. */
.is-ken-burns .plgc-hero__slide.is-active .plgc-hero__bg-img {
    animation: plgc-hero-kb 8s ease-in-out forwards;
}

@keyframes plgc-hero-kb {
    from { transform: scale(1);    }
    to   { transform: scale(1.08); }
}

/* Progress bar */
.plgc-hero__progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: #FFAE40;
    z-index: 10;
}
.plgc-hero__progress.is-animating {
    transition: width linear;
}

/* Dots — top-right of hero (Figma positions them top-right of the slider card) */
.plgc-hero__dots {
    position: absolute;
    top: 18px;
    right: 18px;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0;
    z-index: 10;
}

.plgc-hero__dot {
    /* 44×44px touch target, 22px visible dot via ::before */
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 44px !important;
    height: 44px !important;
    flex-shrink: 0;
    cursor: pointer !important;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    margin: 0 -7px !important;
    -webkit-appearance: none !important;
    appearance: none !important;
    pointer-events: auto !important;
}
.plgc-hero__dot:first-child { margin-left: 0 !important; }
.plgc-hero__dot:last-child  { margin-right: 0 !important; }

.plgc-hero__dot::before {
    content: '';
    display: block;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(255,255,255,0.7);
    border: 2.5px solid transparent;
    box-sizing: border-box;
    pointer-events: none;
    transition: background 150ms ease, border-color 150ms ease;
}
.plgc-hero__dot.is-active::before,
.plgc-hero__dot[aria-pressed="true"]::before {
    background: #567915;
    border-color: #ffffff;
}
.plgc-hero__dot:hover:not(.is-active)::before { background: #ffffff; }
.plgc-hero__dot:focus-visible::before { box-shadow: 0 0 0 3px #FFAE40; }


/* ═══════════════════════════════════════════════════════════════════════════
   PAUSE / PLAY BUTTON  (WCAG SC 2.2.2)
   Bottom-left of hero, 44×44px
   ═══════════════════════════════════════════════════════════════════════════ */
.plgc-hero__pause {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    z-index: 10;
    width: 2.75rem;   /* 44px */
    height: 2.75rem;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.5);
    background: rgba(0,0,0,0.45);
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 150ms ease, border-color 150ms ease;
    backdrop-filter: blur(4px);
    pointer-events: auto;
}
.plgc-hero__pause:hover { background: rgba(0,0,0,0.7); border-color: #FFAE40; color: #FFAE40; }
.plgc-hero__pause:focus-visible { outline: 3px solid #FFAE40; outline-offset: 2px; }


/* ═══════════════════════════════════════════════════════════════════════════
   GRADIENT OVERLAY — improves text contrast (WCAG SC 1.4.3)
   Matches Figma: transparent top → Dark Green Tone (#233C26) at bottom.
   #233C26 = rgb(35, 60, 38)
   ═══════════════════════════════════════════════════════════════════════════ */
.plgc-hero__overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
    background: linear-gradient(
        to bottom,
        rgba(35,60,38,0)    0%,
        rgba(35,60,38,0.08) 45%,
        rgba(35,60,38,0.55) 68%,
        rgba(35,60,38,var(--plgc-hero-overlay, 0.92)) 100%
    );
    pointer-events: none;
}


/* ═══════════════════════════════════════════════════════════════════════════
   HERO TEXT CONTENT
   Centered in the lower half of the hero
   ═══════════════════════════════════════════════════════════════════════════ */
.plgc-hero__content {
    position: absolute;
    z-index: 3;
    /* Figma: text starts at y=635 of a 698px hero — about 60% down */
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0 120px 3rem;  /* 120px = Figma margin */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    text-align: center;
    color: #ffffff;
}

.plgc-hero__heading {
    /* Figma: 48px Libre Baskerville Bold, line-height 64px */
    font-family: 'Libre Baskerville', serif;
    font-size: 3rem;         /* 48px */
    font-weight: 700;
    line-height: 1.333;      /* 64/48 */
    color: #ffffff;
    margin: 0;
    text-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

.plgc-hero__subheading {
    /* Figma: 24px Open Sans Regular, line-height 36px */
    font-family: 'Open Sans', sans-serif;
    font-size: 1.5rem;       /* 24px */
    font-weight: 400;
    line-height: 1.5;
    color: rgba(255,255,255,0.92);
    margin: 0;
    max-width: 75rem;
    text-shadow: 0 1px 8px rgba(0,0,0,0.35);
}


/* ═══════════════════════════════════════════════════════════════════════════
   ANNOUNCEMENT PILL
   Figma: dark gradient rounded rectangle, bottom-right, above overlay
   ═══════════════════════════════════════════════════════════════════════════ */
.plgc-hero__announcement {
    position: absolute;
    z-index: 4;
    bottom: 7%;
    right: 0;
    /* Figma: rounded left corners only (pill attached to right edge) */
    border-radius: 10px 0 0 10px;
    background: linear-gradient(to bottom, #000000 12%, #454041 109%);
    padding: 1.25rem 2rem 1.25rem 2rem;
    max-width: 40rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    align-items: center;
    text-align: center;
}

.plgc-hero__ann-text {
    /* Figma: 24px Open Sans, white */
    font-family: 'Open Sans', sans-serif;
    font-size: 1.5rem;
    font-weight: 400;
    line-height: 1.5;
    color: #ffffff;
    margin: 0;
}

.plgc-hero__ann-link {
    /* Figma: 24px Open Sans, white, underline */
    font-family: 'Open Sans', sans-serif;
    font-size: 1.5rem;
    font-weight: 400;
    line-height: 1.75;
    color: #ffffff;
    text-decoration: underline;
}
.plgc-hero__ann-link:hover,
.plgc-hero__ann-link:focus-visible {
    color: #FFAE40;
    text-decoration: underline;
}
.plgc-hero__ann-link:focus-visible {
    outline: 3px solid #FFAE40;
    outline-offset: 2px;
    border-radius: 2px;
}


/* ═══════════════════════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
    /* At tablet widths the Elementor widget injects --plgc-hero-height:698px as
       an inline style, which makes the hero very tall relative to the viewport.
       Override with a viewport-proportional height so the image doesn't crop
       heavily on a landscape photo at portrait-ish screen sizes. */
    .plgc-hero {
        height: clamp(400px, 60vw, 680px);
    }
    .plgc-hero__content { padding: 0 2rem 2.5rem; }
    .plgc-hero__heading { font-size: 2.25rem; }
    .plgc-hero__subheading { font-size: 1.25rem; }
    .plgc-hero__announcement { max-width: 28rem; }
    .plgc-hero__ann-text,
    .plgc-hero__ann-link { font-size: 1.125rem; }
}

@media (max-width: 767px) {
    /* ── Stacked mobile layout ────────────────────────────────────────────────
       The hero becomes a flex column — image on top, solid green content block
       below. Equal padding on all sides = equal spacing, every time.

       !important is required on padding and margin because Elementor writes
       per-page CSS into /wp-content/uploads/elementor/css/post-N.css from
       the editor's spacing controls, and that file loads after theme CSS.
       Any section padding or widget container padding set in the editor will
       silently win over un-important rules, causing the unequal top spacing.  */

    /* Kill any Elementor-injected padding on the section/container wrapping
       the hero widget — this is the most common source of extra top space.  */
    .elementor-widget-plgc_hero,
    .elementor-widget-plgc_hero > .elementor-widget-container {
        padding: 0 !important;
        margin: 0 !important;
    }

    .plgc-hero {
        height: auto !important;
        min-height: 0 !important;
        display: flex;
        flex-direction: column;
        background-color: #233C26;
        overflow: hidden;
        padding: 0 !important;
    }

    /* Media block: fixed height in the flex flow */
    .plgc-hero__media {
        position: relative;
        width: 100%;
        height: 225px;
        flex-shrink: 0;
        overflow: hidden;
    }

    /* Gradient overlay not needed — solid colour block handles contrast */
    .plgc-hero__overlay {
        display: none !important;
    }

    /* Progress bar belongs below the image; hide it on mobile */
    .plgc-hero__progress {
        display: none;
    }

    /* Content block: equal padding top and bottom via !important so Elementor
       editor spacing settings cannot override and cause unequal appearance.  */
    .plgc-hero__content {
        position: relative !important;
        top: auto !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
        width: 100% !important;
        background-color: #233C26;
        padding: 2rem 1.5rem !important;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.625rem;
        text-align: center;
    }

    /* Explicitly zero margins on both elements so browser defaults and
       Elementor typography resets cannot add asymmetric space.         */
    .plgc-hero__heading {
        font-size: 1.625rem !important;
        line-height: 1.28 !important;
        margin: 0 !important;
        padding: 0 !important;
        text-shadow: none;
    }

    .plgc-hero__subheading {
        font-size: 0.9375rem !important;
        line-height: 1.55 !important;
        margin: 0 !important;
        padding: 0 !important;
        text-shadow: none;
    }

    /* Pause button sits over the image, top-left */
    .plgc-hero__pause {
        position: absolute;
        top: 0.625rem;
        left: 0.625rem;
        bottom: auto;
    }

    /* Dots stay over the image */
    .plgc-hero__dots {
        top: 10px;
        right: 10px;
    }

    /* Announcement pill: full width, square corners, below content block */
    .plgc-hero__announcement {
        position: relative;
        bottom: auto;
        right: auto;
        border-radius: 0;
        width: 100%;
        max-width: 100%;
        padding: 1rem 1.5rem;
    }

    .plgc-hero__ann-text,
    .plgc-hero__ann-link {
        font-size: 1rem;
    }
}


/* ═══════════════════════════════════════════════════════════════════════════
   REDUCED MOTION (WCAG SC 2.3.3 / 2.2.2)
   ═══════════════════════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
    .plgc-hero__slide { transition: none; }
    .plgc-hero__bg-img { animation: none !important; transform: none !important; }
    .plgc-hero__progress { transition: none; }
    /* JS will also check prefersReducedMotion and skip autoplay entirely */
}
