/* ===========================
   Biblioteca Gnóstica — Público
   =========================== */

:root {
  --bg-purple:     #534AB7;
  --bg-purple-lt:  #EEEDFE;
  --bg-purple-dk:  #3C3489;
  --bg-teal:       #1D9E75;
  --bg-teal-lt:    #E1F5EE;
  --bg-coral-lt:   #FAECE7;
  --bg-amber-lt:   #FAEEDA;
  --bg-gray-lt:    #F1EFE8;
  --bg-border:     rgba(0,0,0,.12);
  --bg-radius:     12px;
  --bg-radius-sm:  8px;
  --bg-text:       #1a1a1a;
  --bg-text-muted: #6b6b6b;
  --bg-text-hint:  #9b9b9b;
  --bg-surface:    #fff;
  --bg-page:       #f7f7f5;
  --bg-shadow:     0 1px 3px rgba(0,0,0,.08);
}

.bg-biblioteca { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--bg-text); }

/* Hero */
.bg-hero { display: flex; align-items: flex-start; justify-content: space-between; gap: 1.5rem; padding: 2rem 0 1.25rem; flex-wrap: wrap; }
.bg-hero__title { font-size: 26px; font-weight: 600; margin: 0 0 .4rem; color: var(--bg-text); }
.bg-hero__desc  { font-size: 14px; color: var(--bg-text-muted); line-height: 1.6; max-width: 500px; margin: 0; }
.bg-hero__stats { display: flex; gap: 1.5rem; flex-shrink: 0; }
.bg-stat { text-align: center; }
.bg-stat__num { display: block; font-size: 22px; font-weight: 600; color: var(--bg-text); }
.bg-stat__lbl { display: block; font-size: 11px; color: var(--bg-text-hint); text-transform: uppercase; letter-spacing: .06em; }

/* Toolbar */
.bg-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: .75rem; flex-wrap: wrap; }
.bg-search-wrap { position: relative; flex: 1; min-width: 200px; max-width: 460px; }
.bg-search-icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--bg-text-hint); pointer-events: none; }
.bg-search { width: 100%; padding: 9px 12px 9px 34px; font-size: 14px; border: 1px solid var(--bg-border); border-radius: var(--bg-radius-sm); background: var(--bg-surface); color: var(--bg-text); outline: none; }
.bg-search:focus { border-color: var(--bg-purple); }
.bg-select { padding: 8px 12px; font-size: 13px; border: 1px solid var(--bg-border); border-radius: var(--bg-radius-sm); background: var(--bg-surface); color: var(--bg-text); cursor: pointer; outline: none; }

/* Tabs */
.bg-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--bg-border); margin-bottom: .75rem; flex-wrap: wrap; }
.bg-tab { font-size: 13px; padding: 8px 16px; background: none; border: none; border-bottom: 2px solid transparent; color: var(--bg-text-muted); cursor: pointer; margin-bottom: -1px; transition: color .15s, border-color .15s; }
.bg-tab:hover { color: var(--bg-text); }
.bg-tab--active { color: var(--bg-purple); border-bottom-color: var(--bg-purple); font-weight: 500; }

/* Chips */
.bg-chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 1.25rem; }
.bg-chip { font-size: 12px; padding: 4px 13px; border-radius: 99px; border: 1px solid var(--bg-border); color: var(--bg-text-muted); background: var(--bg-surface); cursor: pointer; transition: all .12s; white-space: nowrap; }
.bg-chip:hover { border-color: var(--bg-purple); color: var(--bg-purple-dk); }
.bg-chip--active { background: var(--bg-purple-lt); color: var(--bg-purple-dk); border-color: #AFA9EC; }

/* Grid */
.bg-grid { display: grid; gap: 16px; }
.bg-grid--4 { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.bg-grid--3 { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.bg-grid--2 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

/* Card */
.bg-card { background: var(--bg-surface); border: 1px solid var(--bg-border); border-radius: var(--bg-radius); overflow: hidden; transition: box-shadow .15s, transform .15s; display: flex; flex-direction: column; }
.bg-card:hover { box-shadow: var(--bg-shadow); transform: translateY(-2px); }
.bg-card--destacado { border-color: #AFA9EC; }
.bg-card--hidden { display: none !important; }

/* La cubierta es un bloque con altura fija, nunca crece */
.bg-card__cover { position: relative; height: 140px; flex-shrink: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.bg-card__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.bg-card__icon { position: relative; width: 72px; height: 72px; opacity: .55; z-index: 1; }
.bg-card__icon svg { width: 72px; height: 72px; color: var(--bg-purple); }

.bg-card__badge { position: absolute; top: 8px; right: 8px; font-size: 10px; font-weight: 600; padding: 3px 8px; border-radius: 99px; background: rgba(255,255,255,.88); color: var(--bg-purple-dk); z-index: 2; }
.bg-card__badge--dest { top: 8px; left: 8px; right: auto; background: var(--bg-purple); color: #fff; }

/* El body ocupa el resto y nunca se solapa con la imagen */
.bg-card__body { padding: 14px 14px 16px; flex: 1; display: flex; flex-direction: column; gap: 0; }
.bg-card__title { font-size: 13px; font-weight: 600; color: var(--bg-text); margin: 0 0 5px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bg-card__meta  { font-size: 11px; color: var(--bg-text-hint); margin: 0 0 6px; }
.bg-card__desc  { font-size: 12px; color: var(--bg-text-muted); margin: 0 0 10px; line-height: 1.6; }

.bg-card__actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Botones */
.bg-btn { display: inline-block; font-size: 12px; padding: 5px 12px; border-radius: var(--bg-radius-sm); border: 1px solid var(--bg-border); color: var(--bg-text-muted); background: none; text-decoration: none; cursor: pointer; transition: background .12s, border-color .12s; }
.bg-btn:hover { background: var(--bg-gray-lt); border-color: #ccc; color: var(--bg-text); }
.bg-btn--primary { background: var(--bg-purple-lt); color: var(--bg-purple-dk); border-color: #AFA9EC; }
.bg-btn--primary:hover { background: #CECBF6; }
.bg-btn-external { display: inline-block; padding: 10px 20px; background: var(--bg-purple-lt); color: var(--bg-purple-dk); border-radius: var(--bg-radius-sm); text-decoration: none; font-size: 14px; border: 1px solid #AFA9EC; }

/* Sin resultados */
.bg-empty, .bg-no-results { padding: 2.5rem; text-align: center; color: var(--bg-text-hint); font-size: 14px; }

/* Embeds */
.bg-embed { width: 100%; border-radius: var(--bg-radius-sm); overflow: hidden; margin: 1.25rem 0; }
.bg-embed--video iframe { width: 100%; aspect-ratio: 16/9; display: block; }
.bg-embed--audio iframe { width: 100%; height: 166px; display: block; }
.bg-embed--audio-sm iframe { width: 100%; height: 232px; display: block; }
.bg-embed--doc iframe { width: 100%; height: 600px; display: block; border: 1px solid var(--bg-border); border-radius: var(--bg-radius-sm); }

/* Reproductor audio nativo */
.bg-audio-player { margin: 1.25rem 0; padding: 1rem; background: var(--bg-gray-lt); border-radius: var(--bg-radius); }
.bg-audio-player audio { width: 100%; }

/* Página individual */
.bg-single { margin-bottom: 2rem; }

.bg-single__ficha {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
  align-items: flex-start;
}

.bg-single__portada {
  border-radius: var(--bg-radius);
  overflow: hidden;
  aspect-ratio: 3/4;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.bg-single__portada img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bg-single__portada-icon { width: 80px; height: 80px; opacity: .5; }
.bg-single__portada-icon svg { width: 80px; height: 80px; color: var(--bg-purple); }

.bg-single__tipo {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
  background: var(--bg-purple-lt);
  color: var(--bg-purple-dk);
  margin-bottom: .75rem;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.bg-single__desc-breve {
  font-size: 15px;
  color: var(--bg-text-muted);
  line-height: 1.65;
  margin: 0 0 1.25rem;
}

.bg-single__tabla { width: 100%; border-collapse: collapse; margin-bottom: 1.5rem; }
.bg-single__tabla th,
.bg-single__tabla td { font-size: 13px; padding: 7px 0; border-bottom: 1px solid var(--bg-border); text-align: left; vertical-align: top; }
.bg-single__tabla th { color: var(--bg-text-hint); font-weight: 500; width: 90px; padding-right: 12px; }
.bg-single__tabla td { color: var(--bg-text); }

.bg-single__btns { display: flex; gap: 10px; flex-wrap: wrap; }
.bg-btn--lg { font-size: 13px; padding: 9px 20px; }

/* Sección descripción ampliada */
.bg-single__descripcion {
  border-top: 1px solid var(--bg-border);
  padding-top: 1.5rem;
  margin-bottom: 2rem;
}
.bg-single__sec-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--bg-text);
  margin: 0 0 1rem;
}
.bg-single__desc-texto {
  font-size: 15px;
  color: var(--bg-text-muted);
  line-height: 1.75;
  max-width: 720px;
}
.bg-single__desc-texto p { margin: 0 0 1rem; }
.bg-single__desc-texto p:last-child { margin-bottom: 0; }

/* Sección reproductor */
.bg-single__reproductor {
  border-top: 1px solid var(--bg-border);
  padding-top: 1.5rem;
}

@media (max-width: 600px) {
  .bg-single__ficha { grid-template-columns: 1fr; }
  .bg-single__portada { aspect-ratio: 16/9; max-height: 220px; }
}

/* Responsive */
@media (max-width: 600px) {
  .bg-hero { flex-direction: column; }
  .bg-grid--4, .bg-grid--3 { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .bg-toolbar { flex-direction: column; align-items: stretch; }
}
