{{ work.title }}
{% if work.originalTitle and work.originalTitle != work.title %}
{{ work.originalTitle }}
{% endif %}
{% if work.genres|length > 0 or work.awards|length > 0 %}
{% if work.genres|length > 0 %}
{{ work.genres|length }}
{% for genre in work.genres %}
{{ genre.name }}
{% endfor %}
{% endif %}
{% if work.awards|length > 0 %}
{{ work.awards|length }}
{% for award in work.awards %}
{{ award }}
{% endfor %}
{% endif %}
{% endif %}
{% if authors_list|length > 0 %}
{{ authors_list|join(', ') }}
{% endif %}
{% set meta_parts = [] %}
{% if work.firstPublishedYear %}{% set meta_parts = meta_parts|merge([work.firstPublishedYear]) %}{% endif %}
{% if work.originalLanguage %}{% set meta_parts = meta_parts|merge([work.originalLanguage|upper]) %}{% endif %}
{# Méta éditions : on prend l'édition canonique élue
(publisher whitelist FR + cover + plus récente).
Fallback editions|first si pas encore élue. #}
{% set canonical_edition = work.canonicalEdition ?? (work.editions|first) %}
{% if canonical_edition and canonical_edition.pageCount %}{% set meta_parts = meta_parts|merge([canonical_edition.pageCount ~ ' p.']) %}{% endif %}
{% if canonical_edition and canonical_edition.publisher %}{% set meta_parts = meta_parts|merge([canonical_edition.publisher]) %}{% endif %}
{% for part in meta_parts %}
{{ part }}
{% if not loop.last %}·{% endif %}
{% endfor %}
{# Note moyenne — réponse directe à "ce livre est-il bien ?" #}
{% if work.ratingsCount > 0 %}
{{ work.ratingsAvg }}
· {{ work.ratingsCount }} lecteur{{ work.ratingsCount > 1 ? 's' : '' }}
{% else %}
{% endif %}
{# Synopsis dépliable, CHARGÉ EN DIFFÉRÉ. L'enrichissement de la
description (GB/OL, lent : jusqu'à ~10s) se fait dans le frame APRÈS
le rendu de la fiche. Contenu initial = displayDescription (fallback
méta), remplacé par la vraie description une fois enrichie. #}
{% include 'works/_synopsis_inner.html.twig' with { work: work } only %}
{# Widget de notation — centré, compact. Glisser à 0 = retirer la note. #}
{# Histogramme compact des notes des lecteurs #}
{% if work.ratingsCount > 0 %}
{% for i in 1..10 %}
{% set score = (i * 0.5)|number_format(1, '.', '') %}
{% set count = ratings_distribution[score] ?? 0 %}
{% set pct = work.ratingsCount > 0 ? (count / work.ratingsCount * 100) : 0 %}
{% endfor %}
0.55.0
{% endif %}
{# Critique — 2 modes :
- pas encore de critique → bloc discret ouvert (heading + textarea visible)
- critique présente → lien repliable (clic pour modifier)
#}
{% if user_review %}
Modifier ma critique
{% else %}
Écris ta critique
{% endif %}
{% if user_rating is null %}
Note ce livre d'abord, ensuite tu pourras y associer une critique.
{% endif %}
{% if user_review %}
{% endif %}
{# Critiques d'autres lecteurs. Section masquée si aucune (au lieu
d'afficher un message qui semble dire "le livre n'a aucune critique"
alors que le current user en a peut-être posté une — visible plus
haut dans le bloc "Ma critique"). #}
{% if other_reviews|length > 0 %}
Critiques d'autres lecteurs
{% for review in other_reviews %}
{% include 'works/_book_review_card.html.twig' with { review: review } only %}
{% endfor %}
{# Lien vers la page dédiée si plus de critiques que l'aperçu. #}
{% if other_reviews_count > other_reviews|length %}
Voir les {{ other_reviews_count }} critiques
{% endif %}
{% endif %}
{# Pub : entre la critique et les éditions #}
{% include 'components/_ad_slot.html.twig' with { slot: 'book-detail' } only %}
{# Éditions : section repliable, discrète, CHARGÉE EN DIFFÉRÉ (Turbo
frame). L'appel Open Library (lent, 20-44s) ne bloque plus le rendu
de la fiche : il se fait en arrière-plan après affichage. #}
Voir les éditions
Chargement des éditions…
{# Adaptations — disclosure juste après Éditions (même style, même rythme) #}
{% if work.adaptations|length > 0 %}
{{ work.adaptations|length }} adaptation{{ work.adaptations|length > 1 ? 's' : '' }} à l'écran
{% for adapt in work.adaptations|slice(0, 8) %}
-
{{ adapt.type ?? 'film' }}
{{ adapt.title }}
{% if adapt.year ?? false %}{{ adapt.year }}{% endif %}
{% endfor %}
{% endif %}
{# Bloc auteur — imposant, style « profil d'artiste » avec photo en bandeau #}
{% if main_author %}
{% set author_works_count = main_author.works|length %}
{% set author_bio_clean = main_author.bio|strip_markdown %}
{% endif %}
{# Du même auteur — vignettes scrollables sur mobile, grille sur desktop #}
{% if other_works_by_author|length > 0 %}
Du même auteur{% if main_author %} · {{ main_author.name }}{% endif %}
{% endif %}