/* ICD Hero Block Styles */

.icd-block {
    position: relative;
    overflow: hidden;
    padding: 0;
    margin: 0;
}

.icd-block .icd-hero-inner {
    position: relative;
    z-index: 10;
    /* No horizontal padding or width cap: content may reach the block edges.
       Spacing is set with the block's own (native) padding controls or the
       width settings of the individual inner blocks. */
    padding: 120px 0;
    min-height: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

/* Explicit alignment chosen on a heading/paragraph block must always win
   over the container's default centring on the frontend. The align-self
   rules stop the flex container from re-centring the (shrink-to-fit)
   block itself when a specific alignment is chosen. */
.icd-block .icd-hero-inner > .has-text-align-left {
    text-align: left !important;
    align-self: flex-start;
}

.icd-block .icd-hero-inner > .has-text-align-center {
    text-align: center !important;
    align-self: center;
}

.icd-block .icd-hero-inner > .has-text-align-right {
    text-align: right !important;
    align-self: flex-end;
}

/* Button group: the justification chosen in the editor emits
   is-content-justification-* classes (which only set justify-content —
   meaningless on a shrink-to-fit flex child). align-self positions the
   whole group as chosen; the container default keeps it centred. */
.icd-block .icd-hero-inner > .wp-block-buttons.is-content-justification-left {
    align-self: flex-start;
}

.icd-block .icd-hero-inner > .wp-block-buttons.is-content-justification-center {
    align-self: center;
}

.icd-block .icd-hero-inner > .wp-block-buttons.is-content-justification-right {
    align-self: flex-end;
}

.icd-block .icd-parallax-bg {
    position: absolute;
    top: -25%;
    left: 0;
    width: 100%;
    height: 150%;
    background-size: cover !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
    z-index: 0;
    will-change: transform;
}

.icd-block .icd-parallax-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.icd-block .icd-overlay-opacity {
    opacity: 0.4;
}

/* Fallback framing for the background video (whole footage visible,
   full-width box, vertically centred on the block). The render callback
   emits the real sizing/anchoring inline, so this only covers the unlikely
   no-inline case. */
.icd-block .icd-parallax-video video {
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: calc(100% / 1.5);
    transform: translateY(-50%);
    object-fit: contain;
    object-position: center center;
}

.icd-block[data-align="full"] {
    width: 100%;
    max-width: 100%;
}

/* Mobile safety net: Astra's full-bleed rules size aligned blocks with
   100vw and calc(-50vw + 50%) side margins. That math only lands the panel
   exactly on the phone's viewport when the content column is perfectly
   centred in the layout viewport; with container paddings / narrow columns
   / browser UI it can push the panel's left edge off-screen, clipping the
   left of the hero on phones. Neutralise the breakout below WP's mobile
   breakpoint so the panel always spans its column exactly, and give the
   content a small side inset so text is never flush with the screen edge. */
@media (max-width: 782px) {
    .icd-block.alignfull,
    .icd-block.alignwide {
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .icd-block .icd-hero-inner {
        padding-left: 20px;
        padding-right: 20px;
    }
}

.icd-block .icd-parallax-elements-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
    /* Clip elements to the block, exactly like the editor preview does. */
    overflow: hidden;
}

.icd-block .icd-parallax-element {
    will-change: transform;
    transition: transform 0.05s linear;
}

/* Hide parallax elements on mobile when disabled */
@media (max-width: 768px) {
    .icd-block .icd-parallax-element.icd-hide-mobile {
        display: none;
    }
}

/* -------------------------------------------------------------------------
 * ICD Slider feed (nested block used by the ICD Slider variant)
 * ---------------------------------------------------------------------- */

.icd-slider {
    position: relative;
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    /* Breathing room before the CTA buttons below the slider. */
    margin: 0 0 40px;
}

.icd-slider-track {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    gap: 24px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-behavior: smooth;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.icd-slider-track::-webkit-scrollbar {
    display: none;
}

.icd-slider-slide {
    flex: 0 0 auto;
    scroll-snap-align: start;
}

.icd-slider-cols-3 .icd-slider-slide {
    width: calc((100% - 48px) / 3);
}

.icd-slider-cols-4 .icd-slider-slide {
    width: calc((100% - 72px) / 4);
}

.icd-slider-link {
    display: block;
    position: relative;
    /* Square-ish cards keep the slider visually consistent with the hero. */
    aspect-ratio: 1 / 1;
    border-radius: 10px;
    overflow: hidden;
    text-decoration: none;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.icd-slider-link:hover,
.icd-slider-link:focus-visible {
    /* Border colour = the block's fallback colour, injected per slider.
       An inset ring (rather than a border) is drawn inside the card, so it
       is never clipped by the track's overflow and every side (top, right,
       bottom, left) renders identically on every slide. */
    box-shadow: inset 0 0 0 3px var(--icd-slider-border, #475569);
    transform: scale(1.05);
}

.icd-slider-media {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
}

.icd-slider-media--fallback {
    background-color: #475569; /* overridden inline when an admin colour is set */
}

.icd-slider-gradient {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 55%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.78), rgba(0, 0, 0, 0));
    pointer-events: none;
}

.icd-slider-title {
    position: absolute;
    /* Generous inner padding keeps titles clear of the card edges and the
       hover ring, even while the card scales up slightly on hover. */
    left: 28px;
    right: 28px;
    bottom: 22px;
    display: block;
    margin: 0;
    color: #fff;
    /* Rendered as an <h3>, so it picks up the active theme's heading font
       face (e.g. Astra's customizer heading font). Size/weight are
       overridden here to fit the card. */
    font-weight: 600;
    font-size: 1rem;
    line-height: 1.25;
    text-align: left;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    /* Clamp long titles to 5 lines, cutting off with an ellipsis.
       -webkit-line-clamp is supported by all evergreen browsers. */
    display: -webkit-box;
    -webkit-line-clamp: 5;
    line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
    /* The clamp box must not exceed the card, and long unbroken words
       (e.g. URLs) must wrap rather than overflow horizontally. */
    max-height: calc(1.25em * 5);
    overflow-wrap: anywhere;
}

/* Square buttons; border-radius and other button chrome are inherited
   from the active theme's button styles (e.g. Astra's). Colours come from
   the theme's global palette (Astra exposes --ast-global-color-*), with
   neutral fallbacks for themes that don't define them. */
.icd-slider-btn {
    flex: 0 0 auto;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 0;
    background-color: var(--ast-global-color-0, #333333);
    color: var(--ast-global-color-5, #ffffff);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Hover uses the theme's secondary/global colour so it matches the
   theme's own button hover treatment. */
.icd-slider-btn:hover:not(:disabled),
.icd-slider-btn:focus-visible:not(:disabled) {
    background-color: var(--ast-global-color-1, #111111);
    color: var(--ast-global-color-5, #ffffff);
}

/* Arrows are desktop-only when every entry already fits the columns. */
@media (min-width: 721px) {
    .icd-slider--no-desktop-arrows .icd-slider-btn {
        display: none;
    }
}

.icd-slider-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.icd-slider-empty {
    padding: 40px;
    text-align: center;
    color: #666;
}

/* On small screens the slider collapses to a single, centred column, with
   the navigation arrows wrapped onto their own centred row underneath. */
@media (max-width: 720px) {
    .icd-slider {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }
    .icd-slider-track {
        order: 1;
        flex: 1 1 100%;
        min-width: 100%;
    }
    .icd-slider-btn {
        order: 2;
    }
    .icd-slider-slide {
        width: 100%;
        flex: 0 0 100%;
    }
    .icd-slider-title {
        left: 20px;
        right: 20px;
        bottom: 18px;
        text-align: center;
    }
}
