/* ===== SYLVARIS — Bibliothèque ===== */

/* ---- Hero ---- */
.livres-hero {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  padding: var(--space-md) 0 var(--space-lg);
  margin-bottom: var(--space-lg);
  border-bottom: 1px solid var(--border);
  /* Le bandeau porte jusqu'à trois éléments à droite du titre : sans repli, le
     titre se ferait écraser sur écran étroit au lieu de leur céder une ligne. */
  flex-wrap: wrap;
}
/* Filtre et bouton d'ajout voyagent ensemble, et passent à la ligne ensemble */
.livres-hero__actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  flex-shrink: 0;
  margin-left: auto;
}
/* En CSS et non en style en ligne : c'est la seule façon de pouvoir l'élargir
   sur mobile, un attribut style l'emportant sur toute règle de feuille. */
.livres-hero__filtre {
  max-width: 220px;
  font-size: var(--fz-sm);
}
.livres-hero__icon {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  fill: none;
  stroke: var(--clr-sage);
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.livres-hero__title {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 4vw, 2.6rem);
  color: var(--text-primary);
  font-weight: 700;
  line-height: 1.1;
  margin-bottom: 6px;
}
.livres-hero__title em {
  font-style: italic;
  color: var(--clr-bark);
}
.livres-hero__sub {
  font-size: var(--fz-sm);
  color: var(--text-muted);
}

/* ---- Note d'attente sur les avis ----
   Un filet vertical et un fond très pâle, sans cadre ni couleur d'alerte : ce
   n'est pas un avertissement, juste une phrase de l'auteur du site. Elle doit
   se remarquer une fois puis se laisser oublier. */
.livres-note {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-xl);
  padding: var(--space-md);
  background: var(--clr-sage-pale);
  border-left: 3px solid var(--clr-bark);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-size: var(--fz-sm);
  font-style: italic;
  color: var(--text-secondary);
}
.livres-note svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  fill: none;
  stroke: var(--clr-bark);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---- Section par catégorie ---- */
.livres-section {
  margin-bottom: var(--space-2xl);
}
.livres-section__title {
  font-family: var(--font-display);
  font-size: var(--fz-lg);
  font-weight: 700;
  color: var(--text-primary);
  padding-bottom: var(--space-sm);
  margin-bottom: var(--space-lg);
  border-bottom: 2px solid var(--border);
  display: flex;
  /* Alignement sur la ligne d'écriture et non sur le milieu des boîtes : le
     compte est écrit plus petit que le nom de la catégorie, et deux boîtes de
     hauteurs différentes centrées l'une sur l'autre donnent un chiffre qui
     flotte. Les lettres, elles, doivent poser sur la même ligne. */
  align-items: baseline;
  gap: var(--space-sm);
}
.livres-section__title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 1.1em;
  background: var(--clr-bark);
  border-radius: 2px;
  flex-shrink: 0;
  /* Le filet n'a pas de ligne d'écriture : il se centre sur la hauteur. */
  align-self: center;
}

/* Compte de la catégorie, posé contre son nom (le titre est déjà en flex avec
   un écart : rien à ajouter pour l'espacement). Taille et couleurs viennent de
   .results-count (filters.css), partagée avec le total de la page ; ne reste
   ici que la police du corps — le titre est en Playfair, pas ce chiffre — et
   les parenthèses. Celles-ci sont posées en CSS : c'est une ponctuation
   d'affichage, et le script n'a ainsi qu'un nombre à réécrire. */
.livres-section__count {
  flex-shrink: 0;
  font-family: var(--font-body);
  font-weight: 400;
}
.livres-section__count::before { content: '('; }
.livres-section__count::after  { content: ')'; }

/* ---- Grille livres ---- */
.livres-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-xl) var(--space-lg);
  padding-bottom: var(--space-2xl);
}

/* ---- Carte livre ---- */
.livre-card {
  display: flex;
  flex-direction: column;
  cursor: pointer;
  outline: none;
  border-radius: var(--radius-lg);
  transition: transform var(--tr-normal);
}
.livre-card:hover  { transform: translateY(-4px); }
.livre-card:focus-visible .livre-card__cover { outline: 3px solid var(--accent); }

.livre-card__cover-wrap {
  position: relative;
  margin-bottom: var(--space-md);
}

.livre-card__cover {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: var(--radius-md);
  box-shadow: 4px 6px 20px rgba(45,74,45,.22), -2px 0 0 rgba(0,0,0,.08);
  display: block;
}
.livre-card__cover--empty {
  background: var(--clr-sage-pale);
  display: flex;
  align-items: center;
  justify-content: center;
}
.livre-card__cover--empty svg {
  width: 36px;
  height: 36px;
  fill: none;
  stroke: var(--clr-sage);
  stroke-width: 1.5;
}

/* Badge note sur la couverture */
.livre-card__badge-note {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: var(--clr-bark);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  gap: 2px;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.livre-card__badge-note span { font-size: 13px; }

/* Corps */
.livre-card__body { display: flex; flex-direction: column; gap: var(--space-xs); flex: 1; }
.livre-card__titre {
  font-family: var(--font-display);
  font-size: var(--fz-md);
  color: var(--text-primary);
  font-weight: 600;
  line-height: 1.3;
}
.livre-card__auteur {
  font-size: var(--fz-sm);
  color: var(--text-secondary);
  font-style: italic;
}
.livre-card__stars {
  display: flex;
  gap: 1px;
  font-size: 16px;
}
.star--lit { color: var(--clr-bark); }
.star--dim { color: var(--clr-sage-light); }

.livre-card__extrait {
  font-size: var(--fz-sm);
  color: var(--text-muted);
  line-height: 1.5;
  margin-top: 4px;
}
.livre-card__avis-label {
  font-weight: 700;
  font-style: italic;
  color: var(--clr-bark);
  font-size: var(--fz-xs);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.livre-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  margin-top: var(--space-xs);
  font-size: var(--fz-xs);
  color: var(--text-muted);
}
.livre-card__meta span::before {
  content: '·';
  margin-right: 4px;
  opacity: .5;
}
.livre-card__meta span:first-child::before { display: none; }

/* ---- Overlay / modal ---- */
.livre-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-md);
  backdrop-filter: blur(3px);
}
.livre-overlay[hidden] { display: none; }

.livre-overlay__panel {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  max-width: 740px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-modal);
  animation: slideUp .25s ease;
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.livre-overlay__close {
  position: sticky;
  top: 0;
  float: right;
  margin: var(--space-md) var(--space-md) 0 0;
  background: var(--clr-sage-pale);
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  transition: background var(--tr-fast);
}
.livre-overlay__close:hover { background: var(--border); }

/* ---- Détail dans la modal ---- */
.livre-detail {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: var(--space-xl);
  padding: var(--space-xl);
  padding-top: 0;
  clear: both;
}
.livre-detail__cover {
  width: 100%;
  border-radius: var(--radius-md);
  box-shadow: 4px 6px 20px rgba(45,74,45,.22);
}
.livre-detail__titre {
  font-family: var(--font-display);
  font-size: var(--fz-xl);
  color: var(--text-primary);
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 8px;
}
.livre-detail__stars { font-size: 22px; margin-bottom: var(--space-md); }
.livre-detail__meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--space-lg);
  font-size: var(--fz-sm);
}
.livre-detail__meta div { display: flex; gap: 8px; }
.livre-detail__meta dt { color: var(--text-muted); min-width: 60px; }
.livre-detail__meta dd { color: var(--text-primary); font-weight: 600; }

.livre-detail__avis {
  background: var(--clr-sage-pale);
  border-left: 3px solid var(--clr-sage);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  padding: var(--space-md) var(--space-lg);
  margin-top: var(--space-md);
}
.livre-detail__avis h3 {
  font-family: var(--font-display);
  font-size: var(--fz-md);
  color: var(--text-primary);
  margin-bottom: 8px;
  font-style: italic;
}
.livre-detail__avis p {
  font-size: var(--fz-sm);
  color: var(--text-secondary);
  line-height: 1.7;
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
  .livres-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--space-lg) var(--space-md); }
  .livre-detail { grid-template-columns: 1fr; }
  .livre-detail__cover-col { display: flex; justify-content: center; }
  .livre-detail__cover { max-width: 160px; }
  /* Sur téléphone, les trois blocs alignés se disputaient une largeur qu'ils
     n'avaient pas : le filtre gardait ses 220 px, ce qui laissait une centaine
     de pixels au texte — d'où un titre coupé en deux et un sous-titre étalé sur
     cinq lignes, pour un bandeau qui mangeait le tiers de l'écran.
     En grille : l'icône et le texte se partagent la première rangée, le filtre
     et le bouton prennent toute la largeur en dessous. */
  .livres-hero {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: var(--space-sm) var(--space-md);
    padding: var(--space-sm) 0 var(--space-md);
    margin-bottom: var(--space-md);
  }
  .livres-hero__icon { width: 34px; height: 34px; }
  .livres-hero__actions {
    grid-column: 1 / -1;   /* sous l'icône comme sous le texte */
    margin-left: 0;
    gap: var(--space-sm);
  }
  /* Le filtre occupe la place laissée par le bouton, au lieu d'un bloc de
     220 px suivi de vide */
  .livres-hero__filtre { flex: 1; max-width: none; }
  .livres-hero__title { font-size: 1.6rem; }
  .livres-hero__sub   { line-height: 1.45; }
}
@media (max-width: 380px) {
  .livres-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---- Recherche dans la bibliothèque ---- */
.livres-hero__recherche { min-width: 200px; max-width: 260px; }
.livres-hero__recherche .form-control { font-size: var(--fz-sm); padding-left: 34px; }

/* L'attribut `hidden` ne suffit pas à masquer une carte : la règle du
   navigateur qui l'applique vaut `display: none`, et toute déclaration
   `display` de la feuille l'emporte sur elle. .livre-card étant en flex,
   masquer une carte n'aurait rien fait sans ces deux lignes. */
.livre-card[hidden],
.livres-section[hidden] { display: none; }

.livres-vide {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: var(--fz-lg);
}
.livres-vide[hidden] { display: none; }

/* Le compte des livres, posé sous le sous-titre de l'en-tête. La couleur et le
   corps viennent de .results-count (filters.css), partagée avec la page des
   fiches : les deux pages annoncent la même chose, elles doivent l'annoncer
   pareil. Ne reste ici que le léger décollement d'avec le sous-titre. */
.livres-count { margin-top: 6px; }

@media (max-width: 560px) {
  /* Dans une barre qui se replie, un champ de 200 px pousse le menu déroulant
     à la ligne suivante et laisse un vide : à cette largeur, chacun prend
     toute la place disponible. */
  .livres-hero__recherche { max-width: none; flex: 1 1 100%; }
}
