/* =====================================================
   Etinion Blog Posts Widget — etbp-blog.css
   Prefix: etbp-
   ===================================================== */

/* ── Reset ── */
.etbp-wrapper { box-sizing: border-box; width: 100%; }
.etbp-wrapper *, .etbp-wrapper *::before, .etbp-wrapper *::after { box-sizing: inherit; }

/* ── Shadow Frame — breathing room so box-shadow is never clipped ── */
.etbp-shadow-frame {
    padding: 12px 0;
    box-sizing: border-box;
    width: 100%;
}

/* ── Grid ── */
.etbp-layout-grid .etbp-shadow-frame {
    /* Vertical breathing room for box-shadow — NO horizontal to keep grid full-width */
    padding: 12px 0;
}
.etbp-grid {
    display: grid;
    gap: 24px;
    grid-template-columns: repeat(3, 1fr);
}

/* ── Horizontal Scroll (Grid mode) ── */

/* Shared hscroll base: flex row, scroll, vertical-only shadow breathing */
.etbp-hscroll-desktop .etbp-grid,
.etbp-hscroll-mobile .etbp-grid {
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    padding: 12px 0;
    margin: -12px 0;
}

/* Cards inside hscroll must use auto height so align-items:stretch
   can equalise them to the tallest card */
.etbp-hscroll-desktop .etbp-grid > .etbp-card,
.etbp-hscroll-mobile .etbp-grid > .etbp-card {
    height: auto;
}

/* Desktop hscroll — card widths + scrollbar (outside MQ so Elementor editor also works) */
.etbp-hscroll-desktop .etbp-grid {
    gap: var(--etbp-gap-d, 24px);
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
}

.etbp-hscroll-desktop .etbp-grid:hover {
    scrollbar-color: rgba(148, 163, 184, 0.5) transparent;
}

.etbp-hscroll-desktop .etbp-grid::-webkit-scrollbar {
    height: 6px;
}

.etbp-hscroll-desktop .etbp-grid::-webkit-scrollbar-track {
    background: transparent;
    border-radius: 3px;
}

.etbp-hscroll-desktop .etbp-grid::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 3px;
    transition: background 0.2s ease;
}

.etbp-hscroll-desktop .etbp-grid:hover::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, 0.5);
}

.etbp-hscroll-desktop .etbp-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(148, 163, 184, 0.8);
}

.etbp-hscroll-desktop .etbp-grid > .etbp-card {
    flex: 0 0 var(--etbp-card-w-d, 32%);
    min-width: var(--etbp-card-w-d, 32%);
    scroll-snap-align: start;
}

/* Tablet horizontal scroll */
@media (min-width: 768px) and (max-width: 1024px) {
    .etbp-hscroll-mobile .etbp-grid {
        gap: var(--etbp-gap-t, 20px);
        scrollbar-width: thin;
        scrollbar-color: rgba(148, 163, 184, 0.3) transparent;
    }

    .etbp-hscroll-mobile .etbp-grid::-webkit-scrollbar {
        height: 4px;
    }

    .etbp-hscroll-mobile .etbp-grid::-webkit-scrollbar-track {
        background: transparent;
    }

    .etbp-hscroll-mobile .etbp-grid::-webkit-scrollbar-thumb {
        background: rgba(148, 163, 184, 0.3);
        border-radius: 2px;
    }

    .etbp-hscroll-mobile .etbp-grid > .etbp-card {
        flex: 0 0 var(--etbp-card-w-t, 48%);
        min-width: var(--etbp-card-w-t, 48%);
        scroll-snap-align: start;
    }
}

/* Mobile horizontal scroll */
@media (max-width: 767px) {
    .etbp-hscroll-mobile .etbp-grid {
        gap: var(--etbp-gap-m, 16px);
        scrollbar-width: none;
    }

    .etbp-hscroll-mobile .etbp-grid::-webkit-scrollbar {
        display: none;
    }

    .etbp-hscroll-mobile .etbp-grid > .etbp-card {
        flex: 0 0 var(--etbp-card-w-m, 100%);
        min-width: var(--etbp-card-w-m, 100%);
        scroll-snap-align: start;
    }
}

/* ═══════════════════════════════════════════
   CARD
═══════════════════════════════════════════ */
.etbp-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    border-radius: 16px;
    height: 100%;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

/* Variant: Shadow (matches Course New Carousel) */
.etbp-card--shadow {
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.08);
    border: 1px solid transparent;
}

/* Variant: Border */
.etbp-card--border {
    box-shadow: none;
    border: 1px solid rgba(15, 23, 42, 0.12);
}

/* Variant: Flat */
.etbp-card--flat {
    box-shadow: none;
    border: none;
}

/* Hover — only active when user explicitly enables via Elementor toggle */
.etbp-hover-enabled .etbp-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08), 0 12px 28px rgba(15, 23, 42, 0.12);
}
.etbp-hover-enabled .etbp-card--border:hover {
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
    border-color: rgba(15, 23, 42, 0.18);
}
.etbp-hover-enabled .etbp-card--flat:hover {
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.1);
}

/* ── Thumbnail ── */
.etbp-card__thumb {
    position: relative;
    overflow: hidden;
    height: 200px;
    background: #e2e8f0;
    flex-shrink: 0;
}

.etbp-card__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .5s cubic-bezier(.4,0,.2,1);
}

.etbp-zoom-enabled .etbp-card:hover .etbp-card__thumb img {
    transform: scale(1.06);
}

.etbp-card__placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #e0e7ff 0%, #c7d2fe 100%);
    color: #6366f1;
}
.etbp-card__placeholder svg {
    width: 48px;
    height: 48px;
    opacity: .4;
}

/* ── Badge ── */
.etbp-card__badge {
    position: absolute;
    top: 12px;
    left: 12px;
    display: inline-block;
    background: #6366f1;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
    letter-spacing: .3px;
    text-transform: uppercase;
    line-height: 1.4;
    z-index: 2;
}

/* ── Body ── */
.etbp-card__body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

/* ── Meta ── */
.etbp-card__meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 13px;
    color: #94a3b8;
    margin-bottom: 10px;
}
.etbp-card__meta-item {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.etbp-card__meta-item svg {
    flex-shrink: 0;
}
.etbp-card__meta-dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: currentColor;
    opacity: .5;
}

/* ── Title ── */
.etbp-card__title {
    font-size: 17px;
    font-weight: 700;
    color: #0f172a;
    margin: 0 0 8px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
    letter-spacing: -.2px;
}
.etbp-card__title a {
    color: inherit;
    text-decoration: none;
    transition: color .25s ease;
}
.etbp-card__title a:hover {
    color: #6366f1;
}

/* ── Excerpt ── */
.etbp-card__excerpt {
    font-size: 14px;
    color: #475569;
    line-height: 1.6;
    margin: 0 0 16px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}

/* ── Footer ── */
.etbp-card__footer {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid #f1f5f9;
}

.etbp-card__author {
    display: flex;
    align-items: center;
    gap: 8px;
}
.etbp-card__avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.etbp-card__author-name {
    font-size: 13px;
    font-weight: 600;
    color: #0f172a;
}

.etbp-card__read-link {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    font-weight: 600;
    color: #6366f1;
    text-decoration: none;
    transition: gap .25s ease;
    white-space: nowrap;
}
.etbp-card__read-link:hover {
    gap: 8px;
}
.etbp-card__read-link svg {
    flex-shrink: 0;
}

/* ═══════════════════════════════════════════
   CAROUSEL
═══════════════════════════════════════════ */

.etbp-track {
    display: flex;
    align-items: stretch;
    gap: var(--etbp-gap, 24px);
    transition: transform .45s cubic-bezier(.4,0,.2,1);
    will-change: transform;
}

.etbp-slide {
    flex: 0 0 auto;
    display: flex;
    height: auto;
    min-width: 0;
    /* CSS-only fallback sizing — PHP sets --etbp-slide-w on root.
       JS overrides flex, width & max-width with precise pixel values on init. */
    width: var(--etbp-slide-w, 33.333%);
    max-width: var(--etbp-slide-w, 33.333%);
}

.etbp-slide > * {
    flex: 1 1 auto;
    min-width: 0;
    width: 100%;
}

/* ── Arrows ── */
.etbp-layout-carousel {
    position: relative;
}

.etbp-nav {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 5;
}
.etbp-viewport {
    overflow: hidden;
    position: relative;
    width: 100%;
    /* Expand clip area left/right so box-shadow on first & last visible card is not clipped.
       Negative margin pulls viewport edges outward; matching padding pushes content back. */
    padding-left: 16px;
    padding-right: 16px;
    margin-left: -16px;
    margin-right: -16px;
    touch-action: pan-y pinch-zoom;
    -webkit-user-select: none;
    user-select: none;
}

/* Prevent native browser drag on images & links inside track */
.etbp-track img,
.etbp-track a {
    -webkit-user-drag: none;
    user-drag: none;
    -webkit-user-select: none;
    user-select: none;
    pointer-events: auto;
}

.etbp-track a img {
    pointer-events: none;
}
.etbp-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid #e2e8f0;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
    cursor: pointer;
    transition: all .25s ease;
    padding: 0;
    outline: none;
    z-index: 6;
}
.etbp-prev {
    left: -20px;
}
.etbp-next {
    right: -20px;
}
.etbp-arrow:hover {
    background: #6366f1;
    border-color: #6366f1;
}
.etbp-arrow:hover svg {
    stroke: #fff;
}
.etbp-arrow:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}
.etbp-arrow[disabled] {
    opacity: 0.3;
    pointer-events: none;
}
.etbp-arrow svg {
    width: 18px;
    height: 18px;
    stroke: #0f172a;
    transition: stroke .25s ease;
}

/* ── Dots ── */
.etbp-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding-top: 24px;
}
.etbp-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #cbd5e1;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: all .25s ease;
}
.etbp-dot.is-active {
    background: #6366f1;
    width: 24px;
    border-radius: 4px;
}

/* ── Empty ── */
.etbp-empty {
    text-align: center;
    padding: 40px 20px;
    color: #94a3b8;
    font-size: 15px;
}

/* ═══════════════════════════════════════════
   DRAG STATE
═══════════════════════════════════════════ */
.etbp-track.is-dragging {
    transition: none !important;
}

.etbp-layout-carousel.is-dragging .etbp-card {
    pointer-events: none;
    user-select: none;
}

.etbp-layout-carousel.is-dragging,
.etbp-layout-carousel.is-dragging .etbp-viewport,
.etbp-layout-carousel.is-dragging .etbp-card,
.etbp-layout-carousel.is-dragging .etbp-card a {
    cursor: grabbing !important;
}

/* ═══════════════════════════════════════════
   RESPONSIVE
═══════════════════════════════════════════ */
@media (max-width: 1024px) {
    .etbp-prev { left: -16px; }
    .etbp-next { right: -16px; }
}

@media (max-width: 768px) {
    /* Mobile: remove the negative margin trick, keep normal shadow padding */
    .etbp-viewport {
        padding-left: 0;
        padding-right: 0;
        margin-left: 0;
        margin-right: 0;
    }

    .etbp-shadow-frame {
        padding: 6px;
    }

    .etbp-arrow {
        width: 34px;
        height: 34px;
    }
    .etbp-arrow svg {
        width: 16px;
        height: 16px;
    }
    .etbp-prev { left: -10px; }
    .etbp-next { right: -10px; }
    .etbp-card__body { padding: 16px; }
}
