
/* ——— Bibliothèque PDF ——— */
.library-hero-row {
  max-width: var(--max);
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.25rem;
}

.library-hero-row h1,
.library-hero-row p {
  max-width: none;
  margin-left: 0;
  margin-right: 0;
}

.catalog-updated {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

.lang-switch {
  display: flex;
  gap: 0.35rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.25rem;
}

.lang-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
}

.lang-btn[aria-pressed="true"] {
  background: var(--primary);
  color: #fff;
}

.library-section {
  padding-top: 1.5rem;
}

.library-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.library-search-wrap {
  flex: 1;
  min-width: min(100%, 280px);
}

.library-search {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 1rem;
}

.library-count {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.library-sort-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 148px;
}

.library-sort-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.library-sort {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

html[dir="rtl"] .library-sort {
  font-family: "Segoe UI", Tahoma, "Noto Sans Arabic", sans-serif;
}

.library-knx-gift {
  margin: 0 0 1rem;
  padding: 0;
}

.library-knx-title-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.12rem;
  width: 100%;
  line-height: 1.2;
}

.library-knx-title-block__main {
  display: block;
  width: 100%;
  font-weight: 800;
  color: inherit;
  line-height: 1.2;
}

.library-knx-title-block--chip .library-knx-title-block__main {
  font-size: 0.82rem;
  font-weight: 700;
}

.library-knx-title-block--heading .library-knx-title-block__main {
  font-size: 1.1rem;
  color: #fff;
}

.library-knx-title-block--section .library-knx-title-block__main,
.library-knx-title-block--banner .library-knx-title-block__main {
  font-size: 2rem;
  color: #fff;
}

.library-knx-sign {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  font-size: 0.5rem;
  font-weight: 400;
  font-style: italic;
  color: #64748b;
  letter-spacing: 0;
  line-height: 1.25;
  white-space: normal;
}

.library-knx-title-block--chip .library-knx-sign {
  font-size: 0.46rem;
  line-height: 1.2;
}

.library-knx-title-block--heading .library-knx-sign {
  font-size: 0.5rem;
}

.library-knx-title-block--section .library-knx-sign,
.library-knx-title-block--banner .library-knx-sign {
  font-size: 0.52rem;
}

.book-collection--active .library-knx-sign {
  color: rgba(15, 23, 42, 0.55);
}

.library-knx-section-head {
  display: block;
}

.library-collection-heading__label-wrap {
  display: block;
  flex: 1 1 auto;
  min-width: min(100%, 12rem);
}

.book-collection__label {
  display: block;
}

.library-collection-heading__label {
  display: inline;
}

.library-knx-gift__inner {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  border: 1px solid rgba(250, 204, 21, 0.35);
  background: linear-gradient(135deg, rgba(250, 204, 21, 0.12), rgba(79, 70, 229, 0.08));
}

.library-knx-gift--inline {
  margin: 0.65rem 0 1rem;
}

.library-knx-gift__icon {
  font-size: 1.5rem;
  line-height: 1;
  flex-shrink: 0;
}

.library-knx-gift__from {
  margin: 0 0 0.35rem;
  font-size: 0.78rem;
  font-weight: 800;
  color: #facc15;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.library-knx-gift__text {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.45;
}

.book-collections-scroll,
.book-filters-scroll {
  overflow: visible;
  margin-bottom: 1rem;
  padding-bottom: 0;
}

.book-collections {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 0.5rem;
}

.book-collection {
  border: 2px solid var(--border);
  background: rgba(250, 204, 21, 0.08);
  color: var(--text);
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.25;
  cursor: pointer;
  white-space: normal;
  text-align: center;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
}

.book-collection__count {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}

.book-collection--active .book-collection__count {
  color: rgba(15, 23, 42, 0.75);
}

.book-collection:not(.book-collection--active):hover {
  border-color: rgba(250, 204, 21, 0.45);
  transform: translateY(-1px);
}

.book-collection--active {
  background: var(--primary);
  border-color: var(--primary);
  color: #0f172a;
}

.book-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.book-filter {
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 0.45rem 0.9rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.book-filter--active {
  background: var(--primary);
  border-color: var(--accent);
  color: #fff;
}

.library-books-root {
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
  margin-bottom: 1.5rem;
}

.library-group {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.library-collection-heading {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.35rem 0.75rem;
  margin: 0;
  padding: 0.65rem 0.85rem;
  font-size: 1.1rem;
  font-weight: 800;
  color: #fff;
  background: rgba(250, 204, 21, 0.1);
  border: 1px solid rgba(250, 204, 21, 0.28);
  border-radius: 10px;
}

.library-collection-heading__count {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--primary);
}

.library-collections-panel {
  margin-bottom: 1.25rem;
}

.library-collections-panel__title {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
}

.library-filters-panel__title {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
}

.book-grid,
.book-grid--section {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.85rem;
  width: 100%;
  margin-bottom: 0;
}

@media (min-width: 640px) {
  .book-collections {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }

  .book-grid,
  .book-grid--section {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
}

.book-grid {
  margin-bottom: 1.5rem;
}

.book-card-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s;
}

.book-card-inner:hover {
  border-color: rgba(59, 130, 246, 0.5);
  transform: translateY(-2px);
}

.book-cover {
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  background: #0f172a;
}

.book-cover--preview {
  height: 220px;
  background: #f1f5f9;
}

.book-cover--preview .book-cover-img {
  object-fit: contain;
  object-position: center;
}

.book-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
}

.book-cover-icon {
  font-size: 2.5rem;
}

.book-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.book-collection-tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 0.35rem;
  letter-spacing: 0.02em;
}

.book-category {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  margin-bottom: 0.35rem;
}

.book-title {
  font-size: 1.05rem;
  margin: 0 0 0.5rem;
  line-height: 1.3;
}

.book-desc {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
  flex: 1;
}

.book-extra {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
}

.book-stats {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
}

.book-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.btn-fav {
  border: 1px solid rgba(250, 204, 21, 0.45);
  background: rgba(250, 204, 21, 0.08);
  color: #facc15;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-fav--on {
  background: rgba(250, 204, 21, 0.25);
  color: #fde047;
}

.btn-sm {
  padding: 0.45rem 0.85rem;
  font-size: 0.85rem;
}

.btn-download {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  text-decoration: none;
  border-radius: 8px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
}

.btn-download:hover {
  border-color: rgba(250, 204, 21, 0.45);
  color: #facc15;
}

.book-soon {
  font-size: 0.85rem;
  color: #fbbf24;
  font-weight: 600;
}

.library-empty,
.book-error {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

html[dir="rtl"] .book-actions {
  flex-direction: row-reverse;
}

/* ——— Ouvrages protégés par mot de passe ——— */
.book-card--locked .book-cover::after {
  content: "🔒";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  background: rgba(15, 23, 42, 0.72);
  pointer-events: none;
}

.book-card--locked .book-cover {
  position: relative;
}

.book-lock-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fbbf24;
  margin-bottom: 0.35rem;
}

.lib-lock-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(2, 6, 23, 0.88);
  backdrop-filter: blur(6px);
}

.lib-lock-overlay[hidden] {
  display: none !important;
}

.lib-lock-dialog {
  width: min(100%, 400px);
  background: var(--bg-card, #1e293b);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 1.5rem;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
}

.lib-lock-title {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
}

.lib-lock-hint {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.lib-lock-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.lib-lock-input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.65rem 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.25);
  color: inherit;
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.lib-lock-error {
  color: #f87171;
  font-size: 0.85rem;
  margin: 0 0 0.75rem;
}

.lib-lock-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  margin-top: 0.75rem;
}

.lib-lock-cancel,
.lib-lock-submit {
  border: none;
  border-radius: 8px;
  padding: 0.55rem 1rem;
  font-weight: 700;
  cursor: pointer;
  font-size: 0.9rem;
}

.lib-lock-cancel {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.lib-lock-submit {
  background: var(--primary, #2563eb);
  color: #fff;
}
