/**
 * AP ACF Repeater – Front-end Styles
 *
 * Provides the base layout for both the Grid and Carousel display modes.
 * All colours and typography can be overridden through Elementor's Style tab
 * or your theme's CSS without touching this file.
 */

/* ==========================================================================
   0a. ACF: Background Image widget
   ========================================================================== */

/* The widget and its Elementor wrapper fill the parent column/section height. */
.elementor-widget-ap-acf-bg,
.elementor-widget-ap-acf-bg > .elementor-widget-container {
    height: 100%;
}

.ap-acf-bg {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 50px;
    background-size:     cover;
    background-position: center center;
    background-repeat:   no-repeat;
}

/* Optional dark overlay — controlled by the "Overlay Opacity" style control. */
.ap-acf-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background-color: #000;
    opacity: 0;
    pointer-events: none;
}

/* Editor placeholder when no sub-field is configured. */
.ap-acf-bg-placeholder {
    min-height: 80px;
    background-color: #f0f0f0;
    border: 2px dashed #bbb;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    font-style: italic;
    font-size: 13px;
    padding: 12px;
    text-align: center;
}

/* ==========================================================================
   0b. Slide background image (applied as inline style by the widget)
   ========================================================================== */

/* When the widget applies a background image directly on the slide wrapper
   (via the "Background Image Sub-Field" setting), these defaults ensure it
   renders as a full cover without extra CSS from the user. */
.ap-acf-item[style*="background-image"] {
    background-size:     cover;
    background-position: center center;
    background-repeat:   no-repeat;
}

/* ==========================================================================
   1. Grid
   ========================================================================== */

.ap-acf-grid {
    display: grid;
    grid-template-columns: repeat( var( --ap-cols, 3 ), 1fr );
    /* column-gap and row-gap are driven by Elementor's responsive slider controls */
}

/* Tablet: Elementor's default breakpoint ≤ 1024 px */
@media ( max-width: 1024px ) {
    .ap-acf-grid {
        grid-template-columns: repeat( var( --ap-cols-tablet, 2 ), 1fr );
    }
}

/* Mobile: ≤ 767 px */
@media ( max-width: 767px ) {
    .ap-acf-grid {
        grid-template-columns: repeat( var( --ap-cols-mobile, 1 ), 1fr );
    }
}

/* ==========================================================================
   2. Flex
   ========================================================================== */

/* Base display — all other flex properties (direction, justify-content,
   align-items, column-gap, row-gap, flex-wrap) are injected by Elementor's
   responsive controls via {{WRAPPER}} .ap-acf-flex selectors. */
.ap-acf-flex {
    display: flex;
}

/* ==========================================================================
   3. Carousel
   ========================================================================== */

/* Outer wrapper — always present, controls arrow layout */
.ap-carousel-wrapper {
    position: relative;
}

/* Outside arrows: absolutely positioned relative to the wrapper.
   Negative left/right values (set via Elementor controls) push them
   outside the carousel boundaries. The section needs enough padding
   to show them without clipping. */
.ap-carousel-wrapper.ap-arrows-outside {
    overflow: visible;
}

.ap-carousel-wrapper.ap-arrows-outside .ap-carousel-btn {
    position: absolute;
    top: 50%;           /* overridden by arrow_v_position control */
    transform: translateY( -50% );
}

.ap-carousel-wrapper.ap-arrows-outside .ap-carousel-prev { left:  -24px; }
.ap-carousel-wrapper.ap-arrows-outside .ap-carousel-next { right: -24px; }

/* Inside arrows are absolute over the slides (default behaviour) */
.ap-carousel-wrapper.ap-arrows-inside .ap-carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY( -50% );
}

.ap-carousel-wrapper.ap-arrows-inside .ap-carousel-prev { left:  12px; }
.ap-carousel-wrapper.ap-arrows-inside .ap-carousel-next { right: 12px; }

.ap-acf-carousel {
    position: relative;
    overflow: hidden;
}

.ap-acf-carousel-track {
    display: flex;
    /* transition is set dynamically by JS */
    gap: var( --ap-space-between, 20px );
    will-change: transform;
    user-select: none;
}

/**
 * Each slide width:
 *   ( 100% - ( N - 1 ) × gap ) / N
 * where N = --ap-slides-per-view, set as an inline CSS variable by JS.
 */
.ap-acf-carousel-slide {
    flex: 0 0 calc(
        ( 100% - ( var( --ap-slides-per-view, 3 ) - 1 ) * var( --ap-space-between, 20px ) )
        / var( --ap-slides-per-view, 3 )
    );
    min-width: 0; /* prevents flex children from overflowing */
}

/* ==========================================================================
   3. Navigation arrows
   ========================================================================== */

.ap-carousel-btn {
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    font-size: 26px;
    line-height: 1;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    background-color: rgba( 0, 0, 0, 0.45 );
    color: #fff;
    transition: background-color 0.2s ease, opacity 0.2s ease;
    /* Prevent text selection on rapid clicks */
    user-select: none;
}

.ap-carousel-btn:hover {
    background-color: rgba( 0, 0, 0, 0.7 );
}

.ap-carousel-btn:disabled {
    opacity: 0;
    cursor: default;
    pointer-events: none;
}

/* Legacy fallback — positions handled by .ap-arrows-inside / .ap-arrows-outside */

/* ==========================================================================
   4. Pagination dots
   ========================================================================== */

.ap-carousel-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.ap-carousel-dot {
    display: block;
    width: 10px;
    height: 10px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background-color: #ccc;
    cursor: pointer;
    transition: background-color 0.25s ease, transform 0.25s ease;
}

.ap-carousel-dot.is-active {
    background-color: #333;
    transform: scale( 1.3 );
}

/* ==========================================================================
   5. Card / Item
   ========================================================================== */

.ap-acf-item {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: background-color 0.25s ease;
}

/* --- Image --- */

.ap-item-image-link {
    display: block;
    overflow: hidden;
}

.ap-item-image {
    overflow: hidden;
    height: 200px; /* overridden by Elementor slider control */
}

.ap-item-image img,
.ap-item-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.ap-acf-item:hover .ap-item-img {
    transform: scale( 1.03 );
}

/* --- Text content --- */

.ap-item-content {
    flex: 1;
    padding: 16px;
    display: flex;
    flex-direction: column;
}

.ap-item-extra {
    display: block;
    font-size: 0.8em;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 6px;
    color: #888;
}

.ap-item-title {
    margin: 0 0 10px;
}

.ap-item-title a {
    color: inherit;
    text-decoration: none;
}

.ap-item-title a:hover {
    text-decoration: underline;
}

.ap-item-body {
    flex: 1;
    margin-bottom: 14px;
}

/* --- Button --- */

.ap-item-button {
    display: inline-block;
    align-self: flex-start;
    padding: 8px 20px;
    background-color: #333;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.9em;
    font-weight: 500;
    transition: background-color 0.25s ease, color 0.25s ease;
}

.ap-item-button:hover {
    background-color: #555;
    color: #fff;
}

/* Overflow visible — slides at edges peek outside the container.
   Enable via "Show Slides at Edges" toggle in widget settings. */
.ap-acf-carousel.ap-carousel-overflow-visible {
    overflow: visible;
}

/* ==========================================================================
   6. Scale Effect
   ========================================================================== */

/* Base state for all slides when scale effect is on */
.ap-scale-effect .ap-acf-carousel-slide {
    transform: scale( 0.9 );
    /* transition is set via the Elementor style control (scale_duration) */
}

/* Active (first visible) slide — expands rightward from its left edge
   so it never clips against the container's left boundary. */
.ap-scale-effect .ap-acf-carousel-slide.is-center {
    transform-origin: left center;
    transform: scale( 1.15 );
}

/* ==========================================================================
   7. Taxonomy Filter Bar (AP Posts Filter widget)
   ========================================================================== */

.ap-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 24px;
}

.ap-filter-btn {
    display: inline-block;
    padding: 8px 18px;
    background-color: transparent;
    color: inherit;
    border: 1px solid currentColor;
    border-radius: 4px;
    font-size: inherit;
    font-family: inherit;
    line-height: 1.4;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    user-select: none;
}

.ap-filter-btn:hover {
    opacity: 0.8;
}

.ap-filter-btn.is-active {
    cursor: default;
}

/* Loading state: dims the items while AJAX is in flight */
.ap-filter-items {
    transition: opacity 0.2s ease;
}

.ap-filter-items.is-loading {
    opacity: 0.4;
    pointer-events: none;
}

/* "No posts found" message */
.ap-no-posts {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

/* ==========================================================================
   8. AP Spotlight Carousel
   ========================================================================== */

/* CSS custom-property defaults — overridden by inline style set in PHP render(). */
.ap-spotlight {
    --spotlight-featured-w: 40%;
    --spotlight-h: 480px;
    --spotlight-gap: 12px;
    display: flex;
    gap: var( --spotlight-gap );
    height: var( --spotlight-h );
    user-select: none;
}

/* ---- Two-column layout ---------------------------------------------------- */

/* Left column: featured card, full height */
.ap-spotlight-featured-col {
    flex: 0 0 var( --spotlight-featured-w );
    min-width: 0;
    height: 100%;
}

.ap-spotlight-card--featured {
    height: 100%;
    cursor: grab;
}

.ap-spotlight-card--featured:active {
    cursor: grabbing;
}

/* Right column: header (heading + nav) stacked above thumbnails */
.ap-spotlight-right-col {
    flex: 1 1 0;
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 16px; /* overridden by Elementor heading_gap control */
}

/* ---- Header row: heading text + nav arrows ------------------------------- */

.ap-spotlight-header {
    flex: 0 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.ap-spotlight-heading-wrap {
    flex: 1 1 auto;
    min-width: 0;
}

.ap-spotlight-heading {
    margin: 0 0 6px;
    line-height: 1.25;
}

.ap-spotlight-subtext {
    margin: 0;
    line-height: 1.5;
}

.ap-spotlight-heading-btn {
    display: inline-block;
    margin-top: 16px;
    padding: 10px 24px;
    background-color: #333;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-size: inherit;
    font-family: inherit;
    line-height: 1.4;
    transition: background-color 0.2s ease, color 0.2s ease;
    user-select: none;
}

.ap-spotlight-heading-btn:hover {
    background-color: #555;
    color: #fff;
}

/* Nav arrows group — aligned to the top-right */
.ap-spotlight-nav {
    flex: 0 0 auto;
    display: flex;
    gap: 8px;
    align-items: flex-start;
    padding-top: 2px;
}

/* Override base .ap-carousel-btn colours for the nav context */
.ap-spotlight-nav .ap-carousel-btn {
    background-color: transparent;
    color: #333;
}

.ap-spotlight-nav .ap-carousel-btn:hover {
    background-color: rgba( 0, 0, 0, 0.08 );
}

/* ---- Thumbnails strip ---------------------------------------------------- */

.ap-spotlight-thumbs-outer {
    flex: 1 1 0;
    min-height: 0;
    overflow: hidden;
}

.ap-spotlight-thumbs-track {
    display: flex;
    height: 100%;
    gap: var( --spotlight-gap );
}

/* Thumb card: equal-width flex children — no translateX in content-swap arch */
.ap-spotlight-card--thumb {
    flex: 1 1 0;
    height: 100%;
    min-width: 0;
    cursor: pointer;
}

/* ---- Individual card base styles ----------------------------------------- */

.ap-spotlight-card {
    position: relative;
    overflow: hidden;
}

/* Full-card link overlay — transparent, sits above everything, makes the
   entire card a single clickable target. Drag suppression fires first
   (capture phase in JS) so drags never trigger navigation. */
.ap-spotlight-card-link {
    position: absolute;
    inset: 0;
    z-index: 5;
}

/* Background image */
.ap-spotlight-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    transition: transform 0.8s ease, opacity 0.25s ease;
}

.ap-spotlight-card:hover .ap-spotlight-bg {
    transform: scale( 1.04 );
}

/* Gradient overlay */
.ap-spotlight-card::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to top,
        rgba( 0, 0, 0, 0.65 ) 0%,
        rgba( 0, 0, 0, 0.1 ) 55%,
        transparent 100%
    );
    z-index: 1;
    pointer-events: none;
}

/* Dark hover overlay — sits above the gradient, below the content */
.ap-spotlight-card::before {
    content: '';
    position: absolute;
    inset: 0;
    background-color: rgba( 0, 0, 0, 0 );
    transition: background-color 0.35s ease;
    z-index: 2;
    pointer-events: none;
}

.ap-spotlight-card:hover::before {
    background-color: rgba( 0, 0, 0, 0.3 );
}

/* ---- Content overlay (bottom) -------------------------------------------- */

.ap-spotlight-content {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    z-index: 6; /* above .ap-spotlight-card-link (5) so text and buttons are clickable */
    transition: opacity 0.2s ease;
}

/* Taxonomy label */
.ap-spotlight-label {
    display: block;
    font-size: 0.72em;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba( 255, 255, 255, 0.7 );
    margin-bottom: 5px;
}

/* Title */
.ap-spotlight-title {
    margin: 0;
    line-height: 1.3;
}

.ap-spotlight-title a {
    color: #fff;
    text-decoration: none;
    position: relative;
    display: inline;
}

/* Animated underline — grows left-to-right on hover */
.ap-spotlight-title a::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 0;
    height: 1px;
    background-color: currentColor;
    transition: width 0.4s ease;
}

.ap-spotlight-card:hover .ap-spotlight-title a::after {
    width: 100%;
}

/* ↗ arrow icon — inline after the title text */
.ap-spotlight-arrow-icon {
    display: inline-flex;
    align-items: center;
    margin-left: 5px;
    opacity: 0;
    transform: translate( -3px, 3px );
    transition: opacity 0.4s ease, transform 0.4s ease;
    text-decoration: none;
    vertical-align: middle;
}

/* Arrow: visible only on hover */
.ap-spotlight-card:hover .ap-spotlight-arrow-icon {
    opacity: 1;
    transform: translate( 0, 0 );
}

/* Excerpt */
.ap-spotlight-excerpt {
    margin-top: 10px;
    font-size: 0.875em;
    line-height: 1.55;
    color: rgba( 255, 255, 255, 0.88 );
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transition: max-height 0.6s ease, opacity 0.5s ease;
}

/* Featured card always shows excerpt; thumbs only on hover */
.ap-spotlight-card--featured .ap-spotlight-excerpt,
.ap-spotlight-card:hover .ap-spotlight-excerpt {
    max-height: 200px;
    opacity: 1;
}

/* Card CTA button */
.ap-spotlight-card-btn {
    display: inline-block;
    margin-top: 14px;
    padding: 8px 18px;
    background-color: rgba( 255, 255, 255, 0.15 );
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 500;
    line-height: 1.4;
    transition: background-color 0.2s ease, color 0.2s ease;
    position: relative; /* ensures z-index works above card-link */
    z-index: 1;
}

.ap-spotlight-card-btn:hover {
    background-color: rgba( 255, 255, 255, 0.3 );
    color: #fff;
}

/* ---- Mobile: stack vertically, single card at a time -------------------- */

@media ( max-width: 767px ) {
    .ap-spotlight {
        flex-direction: column;
        height: auto;
    }

    .ap-spotlight-featured-col,
    .ap-spotlight-right-col {
        width: 100%;
        height: auto;
    }

    .ap-spotlight-card--featured {
        height: var( --spotlight-h );
    }

    .ap-spotlight-thumbs-outer {
        height: 160px;
    }
}

/* ==========================================================================
   9. ACF Gallery Carousel
   ========================================================================== */

/* ---- Slide ---------------------------------------------------------------- */

.ap-gallery-slide {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    height: 340px; /* overridden by Elementor slider control */
    display: block;
}

.ap-gallery-img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
    pointer-events: none; /* prevent browser drag on image */
}

.ap-gallery-slide:hover .ap-gallery-img {
    transform: scale( 1.05 );
}

/* ---- Hover overlay -------------------------------------------------------- */

.ap-gallery-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    padding: 20px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ap-gallery-slide:hover .ap-gallery-overlay,
.ap-gallery-slide:focus  .ap-gallery-overlay {
    opacity: 1;
}

.ap-gallery-overlay-inner {
    width: 100%;
}

.ap-gallery-title {
    margin: 0 0 5px;
    font-weight: 600;
    line-height: 1.3;
}

.ap-gallery-caption {
    margin: 0;
    font-size: 0.875em;
    line-height: 1.4;
}

/* ---- Lightbox ------------------------------------------------------------- */

.ap-gallery-lightbox {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.ap-gallery-lightbox.is-open {
    opacity: 1;
    pointer-events: all;
}

.ap-gl-backdrop {
    position: absolute;
    inset: 0;
    background-color: rgba( 0, 0, 0, 0.92 );
}

.ap-gl-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    max-width: 90vw;
    max-height: 90vh;
}

.ap-gl-img-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    max-height: 75vh;
}

.ap-gl-img {
    display: block;
    max-width: 90vw;
    max-height: 75vh;
    object-fit: contain;
    transition: opacity 0.2s ease;
}

.ap-gl-info {
    text-align: center;
    max-width: 640px;
    padding: 0 16px;
}

.ap-gl-title {
    margin: 0 0 6px;
    color: #fff;
    font-weight: 700;
    font-size: 1.05em;
    line-height: 1.3;
}

.ap-gl-caption {
    margin: 0 0 10px;
    color: rgba( 255, 255, 255, 0.72 );
    font-size: 0.9em;
}

.ap-gl-description {
    margin: 0;
    color: rgba( 255, 255, 255, 0.55 );
    font-size: 0.85em;
    line-height: 1.55;
}

.ap-gl-close {
    position: fixed;
    top: 18px;
    right: 22px;
    background: none;
    border: none;
    color: rgba( 255, 255, 255, 0.8 );
    font-size: 38px;
    line-height: 1;
    cursor: pointer;
    z-index: 2;
    padding: 4px 8px;
    transition: color 0.2s ease;
}

.ap-gl-close:hover {
    color: #fff;
}

.ap-gl-prev,
.ap-gl-next {
    position: fixed;
    top: 50%;
    transform: translateY( -50% );
    z-index: 2;
    background: rgba( 255, 255, 255, 0.12 );
    border: none;
    color: #fff;
    font-size: 34px;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    transition: background 0.2s ease;
}

.ap-gl-prev { left:  16px; }
.ap-gl-next { right: 16px; }

.ap-gl-prev:hover,
.ap-gl-next:hover {
    background: rgba( 255, 255, 255, 0.28 );
}

@media ( max-width: 767px ) {
    .ap-gl-prev { left:  6px; }
    .ap-gl-next { right: 6px; }
}

/* ==========================================================================
   10. Editor placeholder (visible only inside Elementor's editor)
   ========================================================================== */

.ap-acf-placeholder {
    padding: 24px 20px;
    text-align: center;
    background-color: #f8f8f8;
    color: #aaa;
    border: 2px dashed #ddd;
    border-radius: 4px;
    font-size: 0.9em;
    line-height: 1.5;
}
