/**
 * EBA eBook Library Widget — Reference: emotionalacademy.vercel.app/ebooks
 * Sticky filter bar + 3D-tilt book covers + white cards.
 */

.eba-wrapper.eba-ebook {
    padding: 64px 0 80px;
    background-color: #f8f6f1;
    font-family: 'Inter', system-ui, sans-serif;
    overflow-x: clip; /* prevent any child overflow from causing horizontal page scroll */
}
.eba-wrapper.eba-ebook .eba-container {
    max-width: 1280px;
    margin: 0 auto;
    padding-left: 24px;
    padding-right: 24px;
}

.eba-ebook__header {
    text-align: center;
    max-width: 720px;
    margin: 0 auto 32px;
}
.eba-ebook__title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 36px;
    font-weight: 700;
    color: #0f1729;
    margin: 0 0 12px;
    line-height: 1.2;
    letter-spacing: -0.01em;
}
.eba-ebook__subtitle {
    color: #525e7a;
    font-size: 16px;
    line-height: 1.6;
    margin: 0;
}

/* ============================================================
 * FILTER BAR (Sticky)
 * ============================================================ */
.eba-ebook__filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 16px 24px;
    margin-bottom: 32px;
    background: transparent;
    border-radius: 12px;
    transition: background 0.25s, box-shadow 0.25s, padding 0.25s, border-radius 0.25s;
    z-index: 50;
}
/* Sticky behavior — only when wrapper opts in */
.eba-wrapper.eba-ebook.has-sticky-filter .eba-ebook__filters.is-sticky {
    position: sticky;
    top: 80px;
}
/* Stuck state — JS adds .is-stuck */
.eba-wrapper.eba-ebook .eba-ebook__filters.is-stuck {
    background: #ffffff;
    box-shadow: 0 4px 16px rgba(15, 23, 41, 0.08);
    border-radius: 0;
    margin-left: -24px;
    margin-right: -24px;
    padding-left: 24px;
    padding-right: 24px;
}

.eba-ebook__search {
    position: relative;
    display: flex;
    align-items: center;
    background: #ffffff;
    border: 1px solid #e7e2d3;
    border-radius: 9999px;
    padding: 0 14px 0 38px;
    width: 240px;
    height: 40px;
    flex-shrink: 0;
}
.eba-ebook__search svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    pointer-events: none;
}
.eba-ebook__search input {
    width: 100%;
    height: 100%;
    border: 0;
    background: transparent;
    color: #0f1729;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    outline: none;
}
.eba-ebook__search input::placeholder { color: #94a3b8; }

/* Wrapper that holds prev button + scrolling pills + next button */
.eba-ebook__pills-wrap {
    position: relative;
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.eba-ebook__filter-pills {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    flex: 1;
    min-width: 0; /* allow shrink in flex parent so overflow works */
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    scrollbar-width: none; /* Firefox */
    -ms-overflow-style: none; /* IE/Edge */
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
}
.eba-ebook__filter-pills::-webkit-scrollbar { display: none; } /* Chrome/Safari */

/* Scroll arrows (desktop) — round white buttons with gold arrows */
.eba-wrapper.eba-ebook .eba-ebook__scroll-btn,
.eba-wrapper.eba-ebook button.eba-ebook__scroll-btn {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #ffffff;
    background-image: none;
    border: 1px solid #e7e2d3;
    color: #0f1729;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.2s;
    padding: 0;
    box-shadow: 0 2px 8px rgba(15, 23, 41, 0.06);
    text-shadow: none;
}
.eba-wrapper.eba-ebook .eba-ebook__scroll-btn:hover:not([disabled]),
.eba-wrapper.eba-ebook button.eba-ebook__scroll-btn:hover:not([disabled]) {
    background: #ddab2c;
    color: #ffffff;
    border-color: #ddab2c;
}
.eba-wrapper.eba-ebook .eba-ebook__scroll-btn[disabled],
.eba-wrapper.eba-ebook button.eba-ebook__scroll-btn[disabled] {
    opacity: 0.35;
    cursor: default;
    pointer-events: none;
}
.eba-ebook__scroll-btn svg { color: inherit; }

.eba-wrapper.eba-ebook .eba-ebook__filter,
.eba-wrapper.eba-ebook button.eba-ebook__filter {
    padding: 8px 16px;
    background: #f1ede8;
    background-image: none;
    border: 1px solid transparent;
    border-radius: 9999px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: #0f1729;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    text-shadow: none;
    box-shadow: none;
    line-height: 1.4;
    white-space: nowrap;
    flex-shrink: 0; /* don't squeeze pills — let row scroll instead */
}
.eba-wrapper.eba-ebook .eba-ebook__filter:hover,
.eba-wrapper.eba-ebook button.eba-ebook__filter:hover {
    background: #ebe4d5;
    color: #0f1729;
}
.eba-wrapper.eba-ebook .eba-ebook__filter.is-active,
.eba-wrapper.eba-ebook button.eba-ebook__filter.is-active {
    background: #ddab2c;
    background-image: none;
    color: #0f1729;
    border-color: #ddab2c;
    font-weight: 600;
}

.eba-wrapper.eba-ebook .eba-ebook__filter:focus,
.eba-wrapper.eba-ebook button.eba-ebook__filter:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(221, 171, 44, 0.25);
}

/* ============================================================
 * GRID + CARD
 * ============================================================ */
.eba-ebook__grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 24px;
}

@media (max-width: 1200px) { .eba-ebook__grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 980px)  { .eba-ebook__grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 700px)  { .eba-ebook__grid { grid-template-columns: repeat(2, 1fr); gap: 16px; } }
@media (max-width: 480px)  { .eba-ebook__grid { grid-template-columns: 1fr; } }

.eba-ebook__card {
    background: #ffffff;
    border: 1px solid #eee9df;
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}
.eba-ebook__card:hover {
    border-color: #ddab2c;
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(15, 23, 41, 0.1);
}

/* ============================================================
 * COVER — 3D TILT EFFECT (cursor-following)
 * --tilt-y/--tilt-x set by JS on mousemove. CSS provides resting + hover defaults.
 * ============================================================ */
.eba-ebook__cover {
    position: relative;
    height: 320px;
    padding: 24px;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible; /* allow tilt shadow */
    perspective: 1000px;
}
.eba-ebook__cover img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94), filter 0.3s;
    transform-style: preserve-3d;
    backface-visibility: hidden;
    will-change: transform;
}

/* 3D tilt — resting state (uses CSS vars JS can override) */
.eba-ebook__cover.has-tilt {
    /* JS sets these on mousemove; CSS vars provide defaults */
}
.eba-ebook__cover.has-tilt img {
    --tilt-y: -10deg;
    --tilt-x: 2deg;
    --tilt-lift: 0px;
    transform: perspective(900px)
               rotateY(var(--tilt-y))
               rotateX(var(--tilt-x))
               translateY(var(--tilt-lift));
    filter: drop-shadow(8px 12px 18px rgba(15, 23, 41, 0.25));
}

/* Card hover — lift up + accentuate shadow. JS overrides --tilt-y/x on mousemove. */
.eba-ebook__card:hover .eba-ebook__cover.has-tilt img {
    --tilt-lift: -4px;
    filter: drop-shadow(12px 18px 24px rgba(15, 23, 41, 0.32));
}

/* While JS is actively tracking cursor, kill the transition so movement is 1:1 */
.eba-ebook__cover.has-tilt.is-tracking img {
    transition: filter 0.2s;
}

.eba-ebook__cover-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #d4cab8;
}

/* ============================================================
 * BADGES (Featured / Owned)
 * ============================================================ */
.eba-ebook__featured-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 5;
    padding: 4px 10px;
    background: #ddab2c;
    color: #0f1729;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 600;
    border-radius: 9999px;
    line-height: 1.4;
}

.eba-ebook__owned-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 5;
    padding: 4px 10px;
    background: #16a34a;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 9999px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    line-height: 1.4;
}

/* ============================================================
 * BODY
 * ============================================================ */
.eba-ebook__body {
    padding: 18px 22px 22px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
    text-align: center;
}

.eba-ebook__cat {
    display: inline-block;
    align-self: center;
    padding: 3px 12px;
    background: #f1ede8;
    color: #0f1729;
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 600;
    border-radius: 9999px;
    line-height: 1.4;
    margin-bottom: 6px;
}

.eba-ebook__book-title {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 20px;
    font-weight: 600;
    color: #0f1729;
    line-height: 1.25;
    margin: 0;
    letter-spacing: -0.005em;
}

.eba-ebook__excerpt {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    line-height: 1.55;
    color: #525e7a;
    margin: 0;
    flex: 1;
}

.eba-ebook__price {
    display: block;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 24px;
    font-weight: 700;
    color: #ddab2c;
    line-height: 1;
    margin-top: 8px;
}

.eba-ebook__buy {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 18px;
    background: transparent;
    background-image: none;
    color: #ddab2c;
    border: 1.5px solid #ddab2c;
    border-radius: 8px;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    text-shadow: none;
    margin-top: 12px;
    cursor: pointer;
    line-height: 1;
    white-space: nowrap;
}
.eba-ebook__buy span,
.eba-ebook__buy svg { color: inherit; line-height: 1; }
.eba-ebook__buy:hover {
    background: #ddab2c;
    background-image: none;
    color: #ffffff;
    border-color: #ddab2c;
}

.eba-ebook__no-results {
    text-align: center;
    color: #94a3b8;
    padding: 48px 0;
    font-size: 14px;
}

@media (max-width: 700px) {
    .eba-wrapper.eba-ebook .eba-container { padding-left: 16px; padding-right: 16px; }
    .eba-ebook__filters {
        flex-direction: column;
        align-items: stretch;
        padding: 12px 16px;
    }
    .eba-ebook__search { width: 100%; }
    .eba-ebook__pills-wrap {
        flex: 0 0 auto;
        width: 100%;
    }
    .eba-ebook__filter-pills {
        flex: 1;
        width: auto;
        max-width: 100%;
        padding: 4px 0 6px;
    }
    .eba-ebook__filter { flex-shrink: 0; }
    /* Hide scroll arrows on mobile — swipe handles it */
    .eba-ebook__scroll-btn { display: none !important; }
    .eba-ebook__cover { height: 240px; padding: 18px; }
}
