/* ============================================================
   cultural-library — frontend/books
   Adopte design system v0 (assistant-conventions/design-system/).
   Posters portrait 2:3 (covers Google Books), image fit pattern blur bg.
   ============================================================ */

:root {
  /* Surcharges DS — palette books (vert profond bibliothèque) */
  --surface-color-text:        #1a1a1a;
  --surface-color-bg:          #f5f3ec;  /* crème papier */
  --surface-color-card-bg:     #ffffff;
  --surface-color-muted:       #555;
  --surface-color-rule:        #c8c4b3;
  --surface-color-link:        #2f5d3a;  /* vert bibliothèque */
  --surface-color-link-hover:  #20422a;
  --surface-color-focus:       #2f5d3a;
  --surface-color-primary:     #2f5d3a;
  --surface-color-header-bg:   transparent;
  --surface-color-footer-bg:   transparent;

  /* Aliases legacy */
  --fg: var(--surface-color-text);
  --fg-soft: var(--surface-color-muted);
  --fg-muted: #888;
  --bg: var(--surface-color-bg);
  --surface: var(--surface-color-card-bg);
  --accent: var(--surface-color-primary);
  --accent-soft: #e2eee5;
  --border: var(--surface-color-rule);
  --border-soft: #e6e2d5;
  --shadow-card: var(--ds-shadow-sm);
  --shadow-card-hover: var(--ds-shadow-lg);

  /* Color bands rating (réutilise palette boardgame, sens identique 0-10) */
  --r-low:    #f7d7d4;
  --r-mid:    #fce6cf;
  --r-good:   #fff2c2;
  --r-high:   #d9efc8;
  --r-top:    #aedea7;

  /* Anticipation bands (réutilise hype boardgame) */
  --h-cold:   #ecf0f3;
  --h-warm:   #ffe5b4;
  --h-hot:    #ffcca0;
  --h-fire:   #ffaf80;
}

html, body { font-size: 14px; }

/* ───── Layout sidebar + main (refactor nav 2026-05-10) ───── */
body.lib-layout {
  margin: 0;
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}
.lib-sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1em 0.9em;
  display: flex; flex-direction: column;
  gap: 0.9em;
  position: sticky; top: 0;
  max-height: 100vh; overflow-y: auto;
  font-size: 0.92em;
}
.lib-brand {
  font-size: 1.3em; font-weight: 700;
  text-decoration: none; color: var(--fg);
  padding: 0.2em 0.4em;
  border-radius: 5px;
  display: block;
}
.lib-brand:hover { background: var(--accent-soft, #e8f0fa); color: var(--accent); text-decoration: none; }

.lib-nav { display: flex; flex-direction: column; gap: 0.15em; }
.lib-nav a {
  padding: 0.45em 0.6em;
  text-decoration: none;
  color: var(--fg-soft);
  border-radius: 5px;
  font-size: 0.95em;
}
.lib-nav a:hover { background: #f4f4f4; color: var(--fg); text-decoration: none; }
.lib-nav a.active {
  background: var(--accent-soft, #e8f0fa);
  color: var(--accent);
  font-weight: 600;
}

.lib-section { display: flex; flex-direction: column; gap: 0.4em; }
.lib-section-title {
  margin: 0.5em 0 0.1em;
  font-size: 0.72em; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--fg-muted, #888);
}
.lib-link-btn {
  padding: 0.45em 0.7em; font-size: 0.92em;
  border: 1px solid var(--border); background: white;
  border-radius: 5px; cursor: pointer;
  text-decoration: none; color: var(--fg);
  text-align: center;
  display: inline-block;
}
.lib-link-btn:hover { background: #f0f0f0; text-decoration: none; }

/* Sort buttons (no dropdown) */
.sort-buttons { display: flex; flex-direction: column; gap: 0.18em; }
.sort-btn {
  padding: 0.4em 0.7em; font-size: 0.92em;
  border: 1px solid var(--border); background: white;
  border-radius: 5px; cursor: pointer;
  text-align: left; color: var(--fg-soft);
  display: flex; justify-content: space-between; align-items: center;
  gap: 0.4em;
}
.sort-btn:hover { background: #f4f4f4; color: var(--fg); }
.sort-btn.active {
  background: var(--accent); color: white;
  border-color: var(--accent);
}
.sort-btn .sort-dir { font-weight: 700; min-width: 1em; text-align: right; }

/* Filtres */
.lib-filter {
  display: flex; align-items: center; gap: 0.4em;
  font-size: 0.92em; color: var(--fg-soft);
}
.lib-filter span { flex: 1; }
.lib-filter input[type=number] {
  width: 4em;
  padding: 0.3em 0.4em; font-size: 0.92em;
  border: 1px solid var(--border); border-radius: 4px;
}
.lib-filter-label {
  margin: 0.5em 0 0.1em;
  font-size: 0.85em; font-weight: 600; color: var(--fg-soft);
}
.chips-wrap { display: flex; flex-wrap: wrap; gap: 0.3em; align-items: center; }
.lib-reset-btn {
  margin-top: 0.6em;
  padding: 0.45em 0.7em; font-size: 0.9em;
  border: 1px solid var(--border); background: white;
  border-radius: 5px; cursor: pointer;
  color: var(--fg-soft);
}
.lib-reset-btn:hover { background: #f0f0f0; }

/* Main pane */
.lib-main { min-width: 0; padding: 1.3em 1.5em 2em; }
.lib-main-header {
  padding-bottom: 1em;
  margin-bottom: 0.8em;
  border-bottom: 1px solid var(--border);
}
.lib-main-header h1 {
  margin: 0 0 0.3em; font-size: 1.6em; font-weight: 600;
  font-family: Georgia, "Times New Roman", serif;
}
.lib-main-header p { margin: 0 0 0.7em; color: var(--fg-soft); font-size: 0.95em; }
.lib-search {
  width: 100%; max-width: 480px;
  padding: 0.55em 0.85em; font-size: 1em;
  border: 1px solid var(--border); border-radius: 5px;
}

@media (max-width: 768px) {
  body.lib-layout { grid-template-columns: 1fr; }
  .lib-sidebar {
    position: static;
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .lib-main { padding: 1em; }
}

.segmented {
  display: inline-flex !important;
  border: 1px solid var(--border);
  border-radius: 5px;
  overflow: hidden;
  gap: 0 !important;
}
.seg-btn {
  padding: 0.55em 1em;
  background: white; border: none; cursor: pointer;
  font-size: 0.95em;
  color: var(--fg-soft);
}
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn:hover { background: #f0e8d8; }
.seg-btn.active { background: var(--accent); color: white; }

.chip {
  padding: 0.35em 0.85em;
  border: 1px solid var(--border); background: white;
  border-radius: 16px; font-size: 0.92em;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 0.35em;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.chip:hover { background: #f0e8d8; }
.chip[data-state="incl"] {
  background: #2a7a3a; color: white; border-color: #2a7a3a;
}
.chip[data-state="incl"]:hover { background: #226130; }
.chip[data-state="excl"] {
  background: #fce4e4; color: #b03030; border-color: #e9a9a9;
  text-decoration: line-through;
}
.chip[data-state="excl"]:hover { background: #f9d6d6; }

main { padding: 0.5em 1em 2em; }

/* ───── Cards (poster portrait 2:3) ───── */
#cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.2em;
  padding-top: 0.8em;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  display: flex; flex-direction: column;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}
.card-link { display: flex; flex-direction: column; flex: 1; text-decoration: none; color: inherit; }

.card-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;  /* poster portrait TMDB */
  background: #ececec;
  overflow: hidden;
}
/* Background blurred du même image pour combler les bords sans cropper.
   --bg-img injecté en style inline depuis cardHtml() — pattern initialement
   livré sur boardgame, généralisé aux univers à images de ratio variable. */
.card-img-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--bg-img);
  background-size: cover;
  background-position: center;
  filter: blur(18px) saturate(1.05);
  transform: scale(1.15);
  pointer-events: none;
}
.card-img {
  position: relative;
  z-index: 1;
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
}

.overlay-badge {
  position: absolute;
  top: 0.5em; right: 0.5em;
  padding: 0.18em 0.55em;
  border-radius: 10px;
  font-size: 0.75em; font-weight: 600;
  background: rgba(255,255,255,0.95);
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.overlay-badge.warn { color: #8a6500; background: #fff3cd; }
.overlay-badge.miss { color: #555; background: rgba(240,240,240,0.95); }

.card-body {
  padding: 0.6em 0.7em 0.7em;
  display: flex; flex-direction: column; gap: 0.4em;
  flex: 1;
}
.card-title {
  margin: 0;
  font-size: 0.95em;
  font-weight: 600;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.4em;
}
.card-stats {
  display: flex; gap: 0.3em; flex-wrap: wrap;
}
.card-meta {
  font-size: 0.8em;
  color: var(--fg-soft);
  margin-top: auto;
}
.card-meta-status { color: var(--accent); font-weight: 500; }

.card.pending { border-color: #ffd986; }
.card.missing { opacity: 0.78; }
.card.missing .card-title { color: #888; }

.cell-tag {
  display: inline-block;
  min-width: 2.2em; text-align: center;
  padding: 0.15em 0.45em;
  border-radius: 4px;
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  font-size: 0.88em;
}
.cell-tag.r-low    { background: var(--r-low); }
.cell-tag.r-mid    { background: var(--r-mid); }
.cell-tag.r-good   { background: var(--r-good); }
.cell-tag.r-high   { background: var(--r-high); }
.cell-tag.r-top    { background: var(--r-top); color: #15521a; }
.cell-tag.h-cold   { background: var(--h-cold); color: #999; }
.cell-tag.h-warm   { background: var(--h-warm); }
.cell-tag.h-hot    { background: var(--h-hot); }
.cell-tag.h-fire   { background: var(--h-fire); color: #6b2200; }
.cell-tag.big {
  font-size: 1.1em;
  padding: 0.2em 0.6em;
  min-width: 3em;
}

.pill {
  display: inline-block; padding: 0.1em 0.5em;
  border-radius: 10px; font-size: 0.85em; line-height: 1.4;
}
.pill.warn { background: #fff3cd; color: #8a6500; }
.pill.miss { background: #f0f0f0; color: #777; }

.empty-state {
  text-align: center; color: var(--fg-muted);
  padding: 3em 1em; font-size: 1em;
}

/* ───── Detail view ───── */
.detail-view {
  max-width: 1000px;
  margin: 0 auto;
  padding: 1em 0;
}
.detail-back {
  display: inline-block;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.95em;
  margin: 0 1em 1em;
}
.detail-back:hover { text-decoration: underline; }

.detail-hero {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 360px;
  overflow: hidden;
  border-radius: 0;
  margin-bottom: 1em;
  background: #1a1a1a;
}
.detail-backdrop {
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0.5;
}
.detail-hero::after {
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(248,245,240,0) 50%, rgba(248,245,240,1) 100%);
  pointer-events: none;
}

.detail-body {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.6em;
  padding: 0 1em;
  position: relative;
  z-index: 1;
  margin-top: -8em;
}
.detail-poster-wrap {
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-soft);
  box-shadow: var(--ds-shadow-md);
}
.detail-poster {
  width: 100%; height: 100%;
  object-fit: cover;
}
.detail-info {
  display: flex; flex-direction: column;
  padding-top: 8em;  /* push under hero gradient */
}
.detail-title {
  margin: 0;
  font-size: 1.9em;
  font-weight: 700;
  font-family: Georgia, serif;
  line-height: 1.15;
}
.detail-original {
  margin: 0.2em 0 0;
  color: var(--fg-soft);
  font-style: italic;
  font-size: 0.95em;
}
.detail-subtitle {
  margin: 0.4em 0 1em;
  color: var(--fg-soft);
  font-size: 0.95em;
}
.detail-stats {
  display: flex; flex-wrap: wrap; gap: 0.8em 1.4em;
  margin-bottom: 1.2em;
}
.stat-block {
  display: flex; flex-direction: column; gap: 0.2em;
}
.stat-label {
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--fg-muted);
  font-weight: 600;
}
.genres-list { font-size: 0.95em; }

.detail-overview {
  margin: 1em 0;
  padding: 0.8em 0;
  font-size: 0.95em;
  line-height: 1.6;
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
}

.detail-platforms {
  margin: 1em 0;
}
.detail-platforms h4 {
  margin: 0 0 0.5em;
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--fg-muted);
  font-weight: 600;
}
.platform-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-wrap: wrap; gap: 0.4em;
}
.platform-list li {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0.3em 0.7em;
  border-radius: 14px;
  font-size: 0.9em;
}

.detail-notes-display {
  margin: 0.8em 0;
  padding: 0.7em 0.9em;
  background: #f5e6e3;
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  white-space: pre-wrap;
  font-size: 0.92em;
}

.detail-links {
  margin: 1em 0;
  font-size: 0.92em;
}
.detail-links a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}
.detail-links a:hover { text-decoration: underline; }

footer {
  padding: 1em; text-align: center; color: var(--fg-soft); font-size: 0.8em;
  border-top: 1px solid var(--border-soft);
}

@media (max-width: 700px) {
  .detail-body {
    grid-template-columns: 1fr;
    margin-top: -4em;
  }
  .detail-poster-wrap { max-width: 200px; }
  .detail-info { padding-top: 0; }
  .detail-title { font-size: 1.5em; }
  #cards { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.7em; }
}

/* Books-specific : ligne auteur sous le titre, italique muted */
.card-authors {
  margin: 0;
  font-size: 0.8em;
  color: var(--fg-soft);
  font-style: italic;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* Books detail : pas de hero backdrop (Google Books n'en a pas) — on
   restaure un layout plus simple sans negative margin-top. */
.detail-body { margin-top: 0 !important; }
.detail-info { padding-top: 0 !important; }
