/**
 * 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.
 */

/* ==========================================================================
   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. 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;
}

/**
 * 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.3;
    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 */
.ap-scale-effect .ap-acf-carousel-slide.is-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;
}

/* ==========================================================================
   7. 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;
}
