/* ===========================================================================
   Ebooks Listing element (fame/ebooks-list)

   Layout: a left filter rail + a single column of wide rows, per the approved
   design. Everything is scoped under .fame-ebooks-list so the element can sit
   on any page without leaking styles into the theme.

   Rows are a 3-part grid — cover | body | aside — collapsing to a stack on
   narrow screens. The aside holds the price/access line and the two buttons.
   =========================================================================== */

.fame-ebooks-list {
  --feb-ink: #10224b;
  --feb-muted: #6b7a99;
  --feb-line: #e6ebf5;
  --feb-primary: #0566e3;
  --feb-price: #df4b59;
  --feb-radius: 14px;
  color: var(--feb-ink);
  font-size: 14px;
}
.fame-ebooks-list *, .fame-ebooks-list *::before, .fame-ebooks-list *::after { box-sizing: border-box; }

/* ---- quick "Brows by Exams" bar ---- */
.feb-quickbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: #fff; border: 1px solid var(--feb-line); border-radius: var(--feb-radius);
  padding: 12px 16px; margin-bottom: 18px;
}
.feb-quickbar-label { font-weight: 600; font-size: 13px; flex: 0 0 auto; }
.feb-quickbar-pills { display: flex; gap: 8px; flex-wrap: wrap; flex: 1 1 auto; }
/* Search sits at the far right of the same bar, per the design. */
.feb-quickbar .feb-search { margin-left: auto; flex: 0 0 auto; }
.feb-quick {
  border: 1px solid var(--feb-line); background: #fff; color: var(--feb-ink);
  border-radius: 8px; padding: 7px 16px; font: inherit; font-size: 13px; cursor: pointer;
}
.feb-quick:hover { border-color: #c7d5ee; }
.feb-quick.is-active { background: var(--feb-primary); border-color: var(--feb-primary); color: #fff; }

/* ---- two-column shell ---- */
.feb-layout { display: grid; grid-template-columns: 258px 1fr; gap: 20px; align-items: start; }

/* ---- filter rail ---- */
.feb-rail { background: #fff; border: 1px solid var(--feb-line); border-radius: var(--feb-radius); padding: 18px 16px; }
.feb-rail-head { display: flex; align-items: center; justify-content: space-between; padding-bottom: 12px; border-bottom: 1px solid var(--feb-line); }
.feb-rail-title { margin: 0; font-size: 16px; font-weight: 700; }
.feb-reset {
  display: inline-flex; align-items: center; gap: 5px;
  border: 0; background: none; color: #e2545b; font: inherit; font-size: 12px; cursor: pointer; padding: 0;
}
.feb-reset:hover { text-decoration: underline; }

.feb-facet { padding: 14px 0 4px; }
.feb-facet-head {
  width: 100%; display: flex; align-items: center; gap: 9px;
  border: 0; background: none; padding: 0 0 10px; font: inherit; font-size: 12.5px;
  font-weight: 700; letter-spacing: .04em; color: var(--feb-ink); cursor: pointer; text-align: left;
}
.feb-facet-ico { flex: 0 0 auto; color: var(--feb-muted); }
.feb-facet-head > span:not(.feb-facet-sign) { flex: 1 1 auto; }
/* +/- drawn in CSS so the markup carries no state-specific icon. */
.feb-facet-sign { position: relative; width: 12px; height: 12px; flex: 0 0 auto; }
.feb-facet-sign::before, .feb-facet-sign::after {
  content: ""; position: absolute; background: var(--feb-muted); transition: opacity .15s ease;
}
.feb-facet-sign::before { left: 0; top: 5px; width: 12px; height: 2px; }
.feb-facet-sign::after { left: 5px; top: 0; width: 2px; height: 12px; opacity: 0; }
.feb-facet.is-closed .feb-facet-sign::after { opacity: 1; }
.feb-facet.is-closed .feb-facet-body { display: none; }

.feb-check { display: flex; align-items: center; gap: 9px; padding: 6px 0; cursor: pointer; font-size: 13px; }
.feb-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.feb-check-box {
  flex: 0 0 auto; width: 17px; height: 17px; border: 1.5px solid #c7d0e2;
  border-radius: 5px; background: #fff; position: relative;
}
.feb-check input:checked + .feb-check-box { background: var(--feb-primary); border-color: var(--feb-primary); }
.feb-check input:checked + .feb-check-box::after {
  content: ""; position: absolute; left: 5px; top: 1px; width: 5px; height: 10px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.feb-check input:focus-visible + .feb-check-box { outline: 2px solid var(--feb-primary); outline-offset: 2px; }
.feb-check-label { flex: 1 1 auto; }
.feb-check-count { color: var(--feb-muted); font-size: 12px; }

/* ---- toolbar ---- */
.feb-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.feb-resultcount { margin: 0; color: var(--feb-muted); font-size: 13px; }
.feb-resultcount strong { color: var(--feb-ink); }
/* Search: field + live match count + a solid blue button, as one control. */
.feb-search {
  position: relative; display: flex; align-items: center; gap: 8px;
  min-width: 320px; border: 1px solid var(--feb-line); border-radius: 10px;
  background: #fff; padding: 4px 4px 4px 14px;
}
.feb-search:focus-within { border-color: var(--feb-primary); }
.feb-search-input {
  flex: 1 1 auto; min-width: 0; border: 0; background: none;
  padding: 7px 0; font: inherit; font-size: 13px; color: var(--feb-ink);
}
.feb-search-input:focus { outline: none; }
.feb-search-count { flex: 0 0 auto; color: var(--feb-muted); font-size: 12.5px; }
.feb-search-btn {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 8px;
  background: var(--feb-primary); color: #fff;
}
.feb-search-spinner { flex: 0 0 auto; width: 14px; height: 14px; display: none; }
.feb-search-spinner.is-visible {
  display: block; border: 2px solid var(--feb-line); border-top-color: var(--feb-primary);
  border-radius: 50%; animation: feb-spin .7s linear infinite;
}
@keyframes feb-spin { to { transform: rotate(360deg); } }

/* Sort dropdown — native <select>, restyled; the chevron is ours. */
.feb-sort { position: relative; display: inline-flex; align-items: center; }
.feb-sort select {
  appearance: none; -webkit-appearance: none;
  border: 1px solid var(--feb-line); border-radius: 10px; background: #fff;
  color: var(--feb-ink); font: inherit; font-size: 13px;
  padding: 9px 34px 9px 14px; cursor: pointer;
}
.feb-sort select:focus { outline: none; border-color: var(--feb-primary); }
.feb-sort-chev { position: absolute; right: 12px; color: var(--feb-muted); pointer-events: none; }
.screen-reader-text {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ---- rows ---- */
.feb-grid { display: flex; flex-direction: column; gap: 16px; }
.feb-card {
  display: grid; grid-template-columns: 132px 1fr 210px; gap: 18px;
  background: #fff; border: 1px solid var(--feb-line); border-radius: var(--feb-radius);
  padding: 16px; align-items: stretch;
}
.feb-card[hidden] { display: none; }

.feb-cover { display: block; border-radius: 10px; overflow: hidden; background: #f3f6fc; align-self: start; }
.feb-cover img { display: block; width: 100%; height: auto; object-fit: cover; }
.feb-cover-initial {
  display: flex; align-items: center; justify-content: center;
  width: 100%; aspect-ratio: 132 / 172; font-size: 40px; font-weight: 700; color: #fff;
}
.feb-tone-1 { background: #4c78e8; } .feb-tone-2 { background: #2aab8c; }
.feb-tone-3 { background: #f28b22; } .feb-tone-4 { background: #d4568a; }
.feb-tone-5 { background: #7c5ce8; } .feb-tone-6 { background: #0f9bd7; }

/* text-align is set explicitly: the element can sit inside a theme section
   that centres its text, and the card's left column must always read left. */
.feb-body { min-width: 0; display: flex; flex-direction: column; text-align: left; }
.feb-title, .feb-desc, .feb-counts { text-align: left; }
.feb-body-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.feb-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.feb-pill { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.feb-pill-1 { background: #ffeaea; color: #d64545; }
.feb-pill-2 { background: #e6f7f2; color: #1c8f74; }
.feb-pill-3 { background: #e7f0fd; color: #0566e3; }
.feb-pill-4 { background: #fff2e5; color: #c9731a; }

.feb-heart {
  flex: 0 0 auto; width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--feb-line); border-radius: 50%; background: #fff; cursor: pointer;
  color: #b9c4d8; transition: color .15s ease, border-color .15s ease;
}
.feb-heart svg { fill: none; stroke: currentColor; stroke-width: 1.9; }
.feb-heart:hover { color: #e2545b; border-color: #f3c9cc; }
.feb-heart.is-saved { color: #e2545b; border-color: #f3c9cc; }
.feb-heart.is-saved svg { fill: currentColor; }
.feb-heart[disabled] { opacity: .6; cursor: default; }

.feb-title { margin: 10px 0 0; font-size: 17px; line-height: 1.35; font-weight: 700; }
.feb-title a { color: inherit; text-decoration: none; }
.feb-title a:hover { color: var(--feb-primary); }
.feb-desc { margin: 7px 0 0; color: var(--feb-muted); font-size: 13px; line-height: 1.55; }

.feb-counts {
  list-style: none; margin: auto 0 0; padding: 12px 0 0; display: flex; flex-wrap: wrap;
  gap: 8px 18px; border-top: 1px solid var(--feb-line); margin-top: 14px;
}
.feb-counts li { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--feb-muted); }
.feb-count-topics svg { color: #2aab8c; }
.feb-count-mcqs svg { color: #e2545b; }
.feb-count-mocks svg { color: #f0a23a; }
.feb-count-pages svg { color: #7c5ce8; }

/* ---- price / actions ---- */
.feb-aside {
  display: flex; flex-direction: column; gap: 10px; justify-content: center;
  border-left: 1px solid var(--feb-line); padding-left: 18px;
}
/* Red, sampled from the design (#df4b59) — not the body ink. */
.feb-price { margin: 0; font-size: 14px; font-weight: 700; text-align: center; color: var(--feb-price); }
.feb-price-dash { color: var(--feb-muted); font-weight: 400; margin: 0 2px; }
.feb-owned {
  margin: 0; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: #e6f7f2; color: #1c8f74; border-radius: 8px; padding: 8px 10px;
  font-size: 12.5px; font-weight: 600; text-align: center;
}
.feb-actions { display: flex; flex-direction: column; gap: 8px; }
.feb-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border-radius: 9px; padding: 10px 14px; font-size: 13px; font-weight: 600;
  text-decoration: none; cursor: pointer; border: 1px solid transparent;
}
.feb-btn-ghost { background: #fff; border-color: var(--feb-line); color: var(--feb-ink); }
.feb-btn-ghost:hover { border-color: #c7d5ee; color: var(--feb-primary); }
.feb-btn-primary { background: var(--feb-primary); color: #fff; }
.feb-btn-primary:hover { background: #0450b4; color: #fff; }

/* ---- empty / load more ---- */
.feb-empty { margin: 26px 0; text-align: center; color: var(--feb-muted); }
.feb-loadmore-wrap { display: flex; justify-content: center; margin-top: 20px; }
.feb-loadmore {
  display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--feb-line);
  background: #fff; color: var(--feb-ink); border-radius: 10px; padding: 10px 22px;
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
}
.feb-loadmore:hover { border-color: var(--feb-primary); color: var(--feb-primary); }

/* ---- responsive ---- */
@media (max-width: 1000px) {
  .feb-layout { grid-template-columns: 1fr; }
  .feb-rail { order: -1; }
}
@media (max-width: 720px) {
  .feb-card { grid-template-columns: 96px 1fr; }
  .feb-aside {
    grid-column: 1 / -1; border-left: 0; padding-left: 0;
    border-top: 1px solid var(--feb-line); padding-top: 14px;
    flex-direction: row; align-items: center; justify-content: space-between; flex-wrap: wrap;
  }
  .feb-actions { flex-direction: row; }
  .feb-search, .feb-quickbar .feb-search { min-width: 100%; margin-left: 0; }
  .feb-sort, .feb-sort select { width: 100%; }
}
