/* ============================================================
BOOKS CATALOG PAGE — Layout & styles
============================================================ */
.books-catalog-page {
  background: #fff;
  min-height: 100vh;
  padding: var(--space-6) 0;
}

.books-catalog-shell {
    max-width: 1520px;
    margin: 0 auto;
    padding: 0 var(--space-6);
}

/* Hero */
.books-catalog-hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-5);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}

.books-catalog-hero h1 {
  margin: var(--space-2) 0 var(--space-2);
  font-size: var(--text-h1);
  font-weight: 900;
  color: var(--landing-ink);
}

.books-catalog-hero p {
  margin: 0;
  color: var(--gray-600);
  font-size: var(--text-body-sm);
}

.books-catalog-search {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  background: #fff;
  border: 1.5px solid rgba(124, 88, 253, 0.15);
  border-radius: var(--radius-md);
  padding: 0 var(--space-3);
  min-width: 320px;
  transition: all var(--duration-page) var(--ease-standard);
}

.books-catalog-search:focus-within {
  border-color: var(--landing-purple);
  box-shadow: 0 0 0 4px rgba(124, 88, 253, 0.10);
}

.books-catalog-search input {
  flex: 1;
  border: 0;
  background: transparent;
  padding: var(--space-3) 0;
  font-size: var(--text-body-sm);
  outline: none;
}

.books-catalog-search button {
  border: 0;
  background: transparent;
  color: var(--landing-purple);
  cursor: pointer;
  padding: var(--space-2);
}

/* Layout */
.books-catalog-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: var(--space-6);
    align-items: start;
    max-width: 1520px;
    margin: 0 auto;
}

/* Sidebar */
.books-catalog-sidebar {
  /* Keep filters at the catalog inline-end: left in RTL, right in LTR. */
  order: 2;
  /* Opaque white filter surface on both desktop and mobile. */
  background: #fff;
  border: 1px solid rgba(124, 88, 253, 0.12);
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(35, 25, 70, 0.065);
  padding: var(--space-5);
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.books-catalog-sidebar-head {
  display: none;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid rgba(124, 88, 253, 0.10);
}

.books-catalog-sidebar-close {
  border: 0;
  background: rgba(124, 88, 253, 0.06);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 18px;
  color: var(--landing-ink);
}

/* Chips */
.books-catalog-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.books-catalog-chips-scroll {
  max-height: 240px;
  overflow-y: auto;
  padding-right: var(--space-2);
}

.books-catalog-chips .chip {
  font-size: var(--text-caption);
  padding: var(--space-1) var(--space-3);
}

.books-catalog-clear-filters {
  display: block;
  text-align: center;
  padding: var(--space-2);
  color: var(--color-error);
  font-size: var(--text-body-sm);
  font-weight: 700;
  text-decoration: none;
  border: 1.5px dashed var(--color-error-border);
  border-radius: var(--radius-sm);
  transition: all var(--duration-page) var(--ease-standard);
}

.books-catalog-clear-filters:hover {
  background: var(--color-error-light);
}

/* Keep the full-width reset action visible at the bottom of a scrolling
   sidebar/bottom sheet without affecting its independent filter controls. */
.catalog-filter-clear-footer {
  position: sticky;
  bottom: calc(-1 * var(--space-5));
  margin-top: var(--space-4);
  padding: var(--space-3) 0 max(var(--space-2), env(safe-area-inset-bottom));
  background: #fff;
  z-index: 1;
}
.catalog-filter-clear-footer form { margin: 0; }
.catalog-filter-clear-footer .books-catalog-clear-filters {
  width: 100%;
  font: inherit;
  cursor: pointer;
  background: #fff;
}
.catalog-filter-clear-footer .books-catalog-clear-filters:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Main Content */
.books-catalog-main {
  min-width: 0;
  order: 1;
}

.books-catalog-mobile-filter-btn {
  display: none;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-3);
  border: 1.5px solid rgba(124, 88, 253, 0.15);
  border-radius: var(--radius-md);
  background: #fff;
  font-size: var(--text-body-sm);
  font-weight: 700;
  color: var(--landing-purple);
  cursor: pointer;
  margin-bottom: var(--space-4);
}

.books-catalog-results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.books-catalog-results-head p {
  margin: 0;
  font-size: var(--text-body-sm);
  color: var(--gray-600);
}

.books-catalog-results-head { gap: 12px; flex-wrap: wrap; }
.books-catalog-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.books-catalog-controls .books-catalog-sort {
  width: 178px;
  max-width: 100%;
}
@media (max-width: 480px) {
  .books-catalog-controls { width: 100%; }
  .books-catalog-controls .books-catalog-sort { flex: 1; min-width: 148px; }
}

/* ============================================================
DROPDOWNS (Sort & Size) - Unified Styling
============================================================ */
.books-catalog-sort,
.books-catalog-size-select {
  /* FIX 1: عرض ثابت و مناسب */
  width: 140px; /* برای Sort کمی عریض‌تر تا متن‌هایی مثل "پرخواننده‌ترین" جا شوند */
  min-height: 36px;
  
  padding: var(--space-2) 36px var(--space-2) var(--space-3);
  border: 1.5px solid rgba(124, 88, 253, 0.15);
  border-radius: var(--radius-sm);
  
  /* FIX 2: اعمال صریح فونت وزیرمتن (و فونت انگلیسی) */
  font-family: var(--font-body-fa), var(--font-body-en), sans-serif;
  font-size: var(--text-body-sm);
  font-weight: 700;
  color: var(--landing-ink);
  
  /* FIX 3: پس‌زمینه سفید صریح برای جلوگیری از شفاف یا زشت شدن در حالت باز */
  background-color: #ffffff;
  
  cursor: pointer;
  outline: none;
  appearance: none; /* حذف استایل پیش‌فرض زشت مرورگر */
  
  /* آیکون فلش سفارشی */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%237c58fd' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  
  transition: all var(--duration-page) var(--ease-standard);
}

.books-catalog-sort{
  width:100%;
}
/* عرض اختصاصی برای دراپ‌داون سایز (کمی جمع‌وجورتر) */
.books-catalog-size-select {
  width: 120px;
}

/* تنظیمات اختصاصی برای حالت راست‌چین (RTL) */
html[dir="rtl"] .books-catalog-sort,
html[dir="rtl"] .books-catalog-size-select {
  padding: var(--space-2) var(--space-3) var(--space-2) 36px;
  background-position: left 12px center;
}

/* حالت‌های Hover و Focus */
.books-catalog-sort:hover,
.books-catalog-size-select:hover {
  border-color: rgba(124, 88, 253, 0.4);
}

.books-catalog-sort:focus,
.books-catalog-size-select:focus {
  border-color: var(--landing-purple);
  box-shadow: 0 0 0 3px rgba(124, 88, 253, 0.08);
}

/* ============================================================
FIX 4: استایل‌دهی به گزینه‌های داخل دراپ‌داون (هنگام باز شدن)
اگرچه مرورگرها محدودیت دارند، اما این خطوط در کروم و فایرفاکس 
فونت و رنگ پس‌زمینه لیست باز شده را اصلاح می‌کنند.
============================================================ */
.books-catalog-sort option,
.books-catalog-size-select option {
  font-family: var(--font-body-fa), var(--font-body-en), sans-serif !important;
  background-color: #ffffff !important;
  color: var(--landing-ink) !important;
  padding: 8px 12px;
  font-size: var(--text-body-sm);
}

.books-catalog-size-toggle a.active {
  background: var(--landing-purple);
  border-color: var(--landing-purple);
  color: #fff;
}

/* Grid */
.books-catalog-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 280px));
    justify-content: start;
    gap: var(--space-5);
    max-width: 1200px;
}

.books-catalog-card {
  background: #fff;
  border: 1px solid rgba(124, 88, 253, 0.10);
  border-radius: var(--radius-md);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: all var(--duration-page) var(--ease-standard);
}

.books-catalog-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(124, 88, 253, 0.15);
}

.books-catalog-card-cover {
  position: relative;
  aspect-ratio: 3/4;
  background: var(--gray-100);
  overflow: hidden;
}

.books-catalog-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}


.books-catalog-card-meta {
    padding: var(--space-3) var(--space-4);
}

.books-catalog-card-meta h3 {
    margin: 0 0 var(--space-2);
    font-size: var(--text-body);
    font-weight: 700;
    color: var(--landing-ink);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.books-catalog-card-subtitle {
    margin: 0 0 var(--space-2);
    font-size: var(--text-body-sm);
    color: var(--gray-500);
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.books-catalog-card-author {
    margin: 0 0 var(--space-1);
    font-size: var(--text-caption);
    color: var(--landing-purple);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: var(--space-1);
    flex-wrap: wrap;
}

.books-catalog-card-author .author-label {
    font-size: 10px;
    font-weight: 800;
    color: var(--gray-500);
    background: rgba(124, 88, 253, 0.06);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}
.books-catalog-card-rating {
    display: inline-block;
    font-size: var(--text-body-sm);
    font-weight: 700;
    color: var(--landing-purple);
    margin-top: var(--space-1);
}

.books-catalog-card-meta h3 {
  margin: 0 0 var(--space-1);
  font-size: var(--text-body-sm);
  font-weight: 700;
  color: var(--landing-ink);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.books-catalog-card-subtitle {
  margin: 0 0 var(--space-1);
  font-size: var(--text-caption);
  color: var(--gray-500);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.books-catalog-card-author {
  margin: 0 0 var(--space-1);
  font-size: var(--text-caption);
  color: var(--gray-600);
}

.books-catalog-card-rating {
  display: inline-block;
  font-size: var(--text-caption);
  font-weight: 700;
  color: var(--landing-purple);
}

/* Empty State */
.books-catalog-empty {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  border: 1.5px dashed rgba(124, 88, 253, 0.25);
  border-radius: var(--radius-lg);
  background: rgba(124, 88, 253, 0.03);
}

.books-catalog-empty img {
  width: 64px;
  height: 64px;
  opacity: 0.5;
  margin-bottom: var(--space-3);
}

.books-catalog-empty p {
  margin: 0;
  color: var(--gray-600);
  font-size: var(--text-body-sm);
}

/* Backdrop */
.books-catalog-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 998;
  background: rgba(26, 16, 40, 0.35);
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-complex) var(--ease-standard);
}

.books-catalog-sidebar-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

/* Responsive */
@media (max-width: 1024px) {
  .books-catalog-layout {
      grid-template-columns: 1fr;
      max-width: 100%;
  }
  
  .books-catalog-grid {
      max-width: 100%;
      grid-template-columns: repeat(auto-fill, minmax(240px, 280px));
      justify-content: center;
  }

  .books-catalog-sidebar {
    position: fixed;
    z-index: 999;
    top: 0;
    inset-inline-start: 0;
    width: min(85vw, 340px);
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    background: #fff;
    border-color: rgba(124, 88, 253, 0.14);
    box-shadow: 0 0 42px rgba(35, 25, 70, 0.20);
    padding-top: max(var(--space-5), env(safe-area-inset-top));
    padding-bottom: max(var(--space-5), env(safe-area-inset-bottom));
    transform: translateX(-100%);
    transition: transform var(--duration-complex) var(--ease-standard);
  }
  
  html[dir="rtl"] .books-catalog-sidebar {
    transform: translateX(100%);
  }
  
  .books-catalog-sidebar.open,
  html[dir="rtl"] .books-catalog-sidebar.open {
    transform: translateX(0);
  }
  
  .books-catalog-sidebar-head {
    display: flex;
  }
  
  .books-catalog-mobile-filter-btn {
    display: flex;
  }
  
  .books-catalog-sidebar-backdrop {
    display: block;
  }
}

@media (max-width: 760px) {
  .books-catalog-hero {
    flex-direction: column;
    align-items: stretch;
  }
  
  .books-catalog-search {
    min-width: 0;
    width: 100%;
  }
  .books-catalog-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-4);
  }
}

@media (max-width: 480px) {
    .books-catalog-shell {
        padding: 0 var(--space-4);
    }
    
    .books-catalog-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-3);
    }
    
    .books-catalog-card-meta {
        padding: var(--space-2) var(--space-3);
    }
    
    .books-catalog-card-meta h3 {
        font-size: var(--text-body-sm);
    }
}

/* ============================================================
FILTER ACCORDION (Digikala-style)
============================================================ */
.filter-accordion {
  border-bottom: 1px solid rgba(124, 88, 253, 0.10);
  padding-bottom: var(--space-4);
  margin-bottom: var(--space-4);
}

.filter-accordion-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 800;
  font-size: var(--text-body-sm);
  color: var(--landing-ink);
  padding: var(--space-2) 0;
  transition: color var(--duration-page) var(--ease-standard);
}

.filter-accordion-header:hover {
  color: var(--landing-purple);
}

.filter-accordion-header .chevron {
  transition: transform var(--duration-page) var(--ease-standard);
  color: var(--gray-500);
}

.filter-accordion-header[aria-expanded="true"] .chevron {
  transform: rotate(180deg);
  color: var(--landing-purple);
}

.filter-accordion-body {
  padding-top: var(--space-2);
  animation: fadeIn var(--duration-page) var(--ease-standard);
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Search inside accordion */
.filter-search-wrap {
  position: relative;
  margin-bottom: var(--space-3);
}

.filter-search-input {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  padding-inline-end: 32px; /* Space for clear button */
  border: 1px solid rgba(124, 88, 253, 0.15);
  border-radius: var(--radius-sm);
  font-size: var(--text-caption);
  background: #fff;
  outline: none;
  transition: all var(--duration-page) var(--ease-standard);
}

.filter-search-input:focus {
  border-color: var(--landing-purple);
  box-shadow: 0 0 0 3px rgba(124, 88, 253, 0.08);
}

.filter-search-clear {
  position: absolute;
  inset-inline-end: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-500);
  font-size: 14px;
  padding: 4px;
  display: grid;
  place-items: center;
}

.filter-search-clear:hover {
  color: var(--color-error);
}

/* Checkbox List (Max 5 items visible) */
.filter-checkbox-list {
  max-height: 200px; /* ~40px per item * 5 = 200px */
  overflow-y: auto;
  padding-inline-end: var(--space-2);
}

/* Custom Scrollbar for the list */
.filter-checkbox-list::-webkit-scrollbar {
  width: 4px;
}
.filter-checkbox-list::-webkit-scrollbar-track {
  background: transparent;
}
.filter-checkbox-list::-webkit-scrollbar-thumb {
  background: var(--gray-300);
  border-radius: 4px;
}
.filter-checkbox-list::-webkit-scrollbar-thumb:hover {
  background: var(--gray-400);
}

/* Checkbox Item */
.filter-checkbox-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) 0;
  cursor: pointer;
  font-size: var(--text-body-sm);
  color: var(--gray-700);
  transition: color var(--duration-page) var(--ease-standard);
  user-select: none;
}

.filter-checkbox-item:hover {
  color: var(--landing-purple);
}

/* Hide native checkbox */
.filter-checkbox-item input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

/* Custom checkbox box */
.checkbox-custom {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--gray-300);
  border-radius: 4px;
  display: grid;
  place-items: center;
  transition: all var(--duration-page) var(--ease-standard);
  flex-shrink: 0;
  background: #fff;
}

.filter-checkbox-item:hover .checkbox-custom {
  border-color: var(--landing-purple);
}

.filter-checkbox-item input[type="checkbox"]:checked + .checkbox-custom {
  background: var(--landing-purple);
  border-color: var(--landing-purple);
}

/* Checkmark icon */
.checkbox-custom::after {
  content: "";
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) scale(0);
  transition: transform var(--duration-page) var(--ease-standard);
  margin-bottom: 2px;
}

.filter-checkbox-item input[type="checkbox"]:checked + .checkbox-custom::after {
  transform: rotate(45deg) scale(1);
}

/* Hide items during search */
.filter-checkbox-item.hidden-by-search {
  display: none !important;
}


/* ============================================================
MOBILE CATALOG — compact breadcrumb + horizontal book rows
============================================================ */
.books-catalog-breadcrumb {
  display: none;
}

/* Preserve the hidden attribute when mobile styles enable the breadcrumb. */
.books-catalog-breadcrumb[hidden] {
  display: none;
}

@media (max-width: 760px) {
  .books-catalog-page {
    padding-top: var(--space-4);
  }

  .books-catalog-intro {
    display: none;
  }

  .books-catalog-hero {
    margin-bottom: var(--space-3);
  }

  .books-catalog-breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    margin: 0 0 var(--space-4);
    padding: var(--space-1) 0 var(--space-2);
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    font-size: var(--text-caption);
    line-height: 1.6;
  }

  .books-catalog-breadcrumb::-webkit-scrollbar {
    display: none;
  }

  .books-catalog-breadcrumb a,
  .books-catalog-breadcrumb span {
    flex: 0 0 auto;
  }

  .books-catalog-breadcrumb a {
    color: var(--gray-500);
    text-decoration: none;
  }

  .books-catalog-breadcrumb .is-current {
    color: var(--landing-ink);
    font-weight: 800;
  }

  .books-catalog-breadcrumb-separator {
    color: var(--gray-400);
    user-select: none;
  }

  .books-catalog-grid {
    display: block;
    max-width: none;
  }

  .books-catalog-card {
    display: flex;
    align-items: flex-start;
    gap: var(--space-4);
    width: 100%;
    padding: var(--space-4) 0;
    border: 0;
    border-bottom: 1px solid var(--gray-200);
    border-radius: 0;
    overflow: visible;
    background: transparent;
  }

  .books-catalog-card:first-child {
    padding-top: var(--space-2);
  }

  .books-catalog-card:last-child {
    border-bottom: 0;
  }

  .books-catalog-card:hover {
    transform: none;
    box-shadow: none;
  }

  .books-catalog-card-cover {
    flex: 0 0 88px;
    width: 88px;
    aspect-ratio: 2 / 3;
    border-radius: var(--radius-sm);
    box-shadow: 0 3px 10px rgba(26, 16, 40, 0.08);
  }


  .books-catalog-card-meta {
    flex: 1 1 auto;
    min-width: 0;
    padding: var(--space-1) 0 0;
  }

  .books-catalog-card-meta h3 {
    margin-bottom: var(--space-2);
    font-size: var(--text-body-sm);
    line-height: 1.65;
    -webkit-line-clamp: 2;
  }

  .books-catalog-card-subtitle {
    margin-bottom: var(--space-2);
    line-height: 1.55;
    -webkit-line-clamp: 2;
  }

  .books-catalog-card-author {
    margin-bottom: var(--space-2);
    line-height: 1.5;
  }

  .books-catalog-card-rating {
    margin-top: 0;
  }
}

/* Authenticated app shell owns viewport height and outer spacing. */
.app-content > .books-catalog-page {
  min-height: 0;
  padding-top: 0;
  padding-bottom: 0;
}

/* Authenticated app shell has less horizontal room because the primary app
   navigation remains visible. Switch the catalog filters to the existing
   drawer pattern earlier there, while keeping the wider public catalog
   unchanged. */
@media (min-width: 1025px) and (max-width: 1400px) {
  .app-content .books-catalog-layout {
    grid-template-columns: 1fr;
    max-width: 100%;
  }

  .app-content .books-catalog-grid {
    max-width: 100%;
    grid-template-columns: repeat(auto-fill, minmax(220px, 280px));
    justify-content: center;
  }

  .app-content .books-catalog-sidebar {
    position: fixed;
    z-index: 999;
    top: 0;
    inset-inline-start: 0;
    width: min(85vw, 340px);
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    background: #fff;
    border-color: rgba(124, 88, 253, 0.14);
    box-shadow: 0 0 42px rgba(35, 25, 70, 0.20);
    padding-top: max(var(--space-5), env(safe-area-inset-top));
    padding-bottom: max(var(--space-5), env(safe-area-inset-bottom));
    transform: translateX(-100%);
    transition: transform var(--duration-complex) var(--ease-standard);
  }

  html[dir="rtl"] .app-content .books-catalog-sidebar {
    transform: translateX(100%);
  }

  .app-content .books-catalog-sidebar.open,
  html[dir="rtl"] .app-content .books-catalog-sidebar.open {
    transform: translateX(0);
  }

  .app-content .books-catalog-sidebar-head,
  .app-content .books-catalog-mobile-filter-btn {
    display: flex;
  }

  .app-content ~ .books-catalog-sidebar-backdrop,
  .app-shell .books-catalog-sidebar-backdrop {
    display: block;
  }
}

/* On phones the same filter surface becomes a bottom sheet instead of a
   narrow side drawer. Filters still apply immediately through the existing
   AJAX flow. */
@media (max-width: 760px) {
  .books-catalog-sidebar {
    top: auto;
    bottom: 0;
    inset-inline: 0;
    width: 100%;
    height: min(78vh, 680px);
    height: min(78dvh, 680px);
    max-height: calc(100vh - env(safe-area-inset-top) - 16px);
    max-height: calc(100dvh - env(safe-area-inset-top) - 16px);
    border-radius: 22px 22px 0 0;
    padding-top: calc(var(--space-5) + 8px);
    transform: translateY(105%);
  }

  html[dir="rtl"] .books-catalog-sidebar {
    transform: translateY(105%);
  }

  .books-catalog-sidebar.open,
  html[dir="rtl"] .books-catalog-sidebar.open {
    transform: translateY(0);
  }

  .books-catalog-sidebar::before {
    content: "";
    position: absolute;
    top: 9px;
    left: 50%;
    width: 42px;
    height: 4px;
    border-radius: 999px;
    background: rgba(106, 85, 244, 0.22);
    transform: translateX(-50%);
  }
}
