/* Грамофончето — surcouche par-dessus Bootstrap 5.
   Bootstrap gère la grille de contrôles, les cases à cocher et la modale ;
   ce fichier apporte le thème chaud et les jaquettes. */

:root {
  --bg:        #16130f;
  --bg-soft:   #1f1a14;
  --panel:     #241e17;
  --line:      #372e23;
  --ink:       #f4ece0;
  --ink-dim:   #b8a992;
  --ink-faint: #7d7161;
  --accent:    #e0a33e;   /* laiton / étiquette de disque */
  --accent-2:  #c8702f;
  --shadow:    0 10px 30px rgba(0,0,0,.45);
  --radius:    14px;
  --card-min:  168px;
}

/* Accent Bootstrap → laiton, pour switches, focus, etc. */
[data-bs-theme="dark"] {
  --bs-primary: var(--accent);
  --bs-primary-rgb: 224, 163, 62;
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--ink);
}

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia,
               "Times New Roman", serif;
  -webkit-font-smoothing: antialiased;
}
body {
  background:
    radial-gradient(1200px 600px at 50% -10%, #2a2117 0%, transparent 70%),
    var(--bg);
  min-height: 100vh;
}

/* ---------- Loader ---------- */

.loader {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background:
    radial-gradient(900px 500px at 50% 20%, #2a2117 0%, transparent 70%),
    var(--bg);
  z-index: 2000;
  transition: opacity .5s ease;
}
.loader.is-done { opacity: 0; pointer-events: none; }

.record { position: relative; width: 180px; height: 180px; }
.record__disc {
  position: absolute; inset: 0; border-radius: 50%;
  background: repeating-radial-gradient(circle at 50% 50%,
      #0c0a08 0px, #0c0a08 2px, #17130e 3px, #0c0a08 4px);
  box-shadow: var(--shadow), inset 0 0 40px rgba(0,0,0,.6);
  animation: spin 3.2s linear infinite;
}
.record__label {
  position: absolute; inset: 32%; border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, var(--accent), var(--accent-2));
  box-shadow: inset 0 0 12px rgba(0,0,0,.35);
}
.record__hole { position: absolute; inset: 47%; border-radius: 50%; background: var(--bg); }
.record__arm {
  position: absolute; top: -8px; right: 2px; width: 8px; height: 120px;
  background: linear-gradient(#d8cfc0, #8b8072); border-radius: 6px;
  transform-origin: top right; transform: rotate(24deg); box-shadow: var(--shadow);
}
.record__arm::after {
  content: ""; position: absolute; bottom: -6px; left: -6px;
  width: 20px; height: 14px; background: #d8cfc0; border-radius: 3px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loader__title { font-size: 2rem; letter-spacing: .06em; color: var(--ink); }
.loader__status { color: var(--ink-dim); font-size: .95rem; }
.loader__bar { width: 240px; height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
.loader__bar-fill {
  width: 0%; height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .25s ease;
}

/* ---------- Bandeau miroir / copyright ---------- */
.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: rgba(224,163,62,.10);
  border-bottom: 1px solid var(--line);
  color: var(--ink-dim);
  font-size: .85rem;
  line-height: 1.4;
}
.banner__text { flex: 1 1 auto; }
.banner__text a { color: var(--accent); }
.banner__close {
  flex: 0 0 auto;
  width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg-soft);
  color: var(--ink); cursor: pointer; font-size: .95rem; line-height: 1;
}
.banner__close:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Barre du haut (recherche + filtres), collée en haut ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  padding: 16px 0 12px;
  background: rgba(22,19,15,.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar__head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 12px;
}
.topbar__title { margin: 0; font-size: 1.6rem; letter-spacing: .04em; font-weight: 600; }
.topbar__sub { color: var(--ink-dim); font-size: .9rem; }

/* Barre d'onglets : navigation à gauche, lecteur détaché à droite */
.viewbar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.viewtabs { flex-wrap: wrap; }
.viewtab-player { margin-left: auto; display: inline-flex; align-items: center; justify-content: center; }
.vt-disc { width: 20px; height: 20px; display: block; }
.viewtab-player.active .vt-disc { animation: spin 3.2s linear infinite; }
.viewtabs .btn,
.viewtab-player {
  --bs-btn-color: var(--ink-dim);
  --bs-btn-border-color: var(--line);
  --bs-btn-hover-color: var(--ink);
  --bs-btn-hover-border-color: #4a3d2d;
  --bs-btn-hover-bg: var(--bg-soft);
}
.viewtabs .btn.active,
.viewtab-player.active {
  --bs-btn-active-bg: var(--panel);
  --bs-btn-active-border-color: var(--accent);
  --bs-btn-active-color: var(--accent);
  --bs-btn-color: var(--accent);
  --bs-btn-border-color: var(--accent);
  font-weight: 600;
}
/* Dans un btn-group les bordures se chevauchent (marges négatives) : on remonte
   le bouton survolé/actif pour que sa bordure ne soit pas mangée par le voisin. */
.viewtabs .btn:hover,
.viewtabs .btn:focus,
.viewtabs .btn.active { position: relative; z-index: 2; }

.searchwrap .input-group-text {
  background: var(--bg-soft);
  border-color: var(--line);
  color: var(--ink-faint);
}
.searchwrap .form-control {
  background: var(--bg-soft);
  border-color: var(--line);
  color: var(--ink);
  font-family: inherit;
}
.searchwrap .form-control::placeholder { color: var(--ink-faint); }
.searchwrap .form-control:focus {
  background: var(--bg-soft);
  color: var(--ink);
  box-shadow: 0 0 0 .25rem rgba(224,163,62,.2);
  border-color: var(--accent);
}
.searchwrap__icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
#search-count { min-width: 3ch; justify-content: center; }

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 20px;
  margin-top: 12px;
}
.filters .form-check-label { color: var(--ink-dim); cursor: pointer; }
.filters .form-check-input { cursor: pointer; }
.filters__viol { display: flex; align-items: center; gap: 8px; color: var(--ink-dim); }
.filters__viol .form-select {
  width: auto; background: var(--bg-soft); border-color: var(--line); color: var(--ink);
}

/* Chip de facette active (catégorie / auteur / corpus filtrant les histoires) */
.facet {
  border: 1px solid var(--accent);
  background: rgba(224,163,62,.14);
  color: var(--accent);
  border-radius: 999px;
  padding: 4px 14px;
  font-size: .9rem;
  cursor: pointer;
}
.facet:hover { background: rgba(224,163,62,.24); }

/* Sélecteur de langue */
.lang .btn { --bs-btn-color: var(--ink-dim); --bs-btn-border-color: var(--line); }
.lang .btn.active {
  --bs-btn-active-bg: var(--accent);
  --bs-btn-active-border-color: var(--accent);
  --bs-btn-active-color: #1a1509;
  font-weight: 600;
}

/* ---------- Grille de jaquettes ---------- */

.app-main { padding-top: 24px; padding-bottom: 60px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(var(--card-min), 1fr));
  gap: 18px;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: #4a3d2d; }

.card__cover {
  position: relative;
  aspect-ratio: 1 / 1;
  background: linear-gradient(145deg, #35302a, #262019);
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.card__cover img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Repli sans image : titre sur fond gris texturé */
.card__fallback {
  padding: 14px; text-align: center; font-size: 1rem; line-height: 1.3; color: var(--ink);
  background:
    repeating-linear-gradient(135deg, rgba(255,255,255,.02) 0 6px, transparent 6px 12px),
    linear-gradient(145deg, #3a342d, #24201a);
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center; overflow: hidden;
}
.card__fallback span {
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden;
}

.card__body { padding: 10px 12px 12px; }
.card__title {
  margin: 0; font-size: .98rem; line-height: 1.25; font-weight: 600;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card__authors {
  margin: 4px 0 0; font-size: .8rem; color: var(--ink-dim);
  display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}

.card__viol {
  position: absolute; top: 8px; right: 8px;
  font-size: .72rem; padding: 2px 7px; border-radius: 999px;
  background: rgba(0,0,0,.55); color: var(--ink); backdrop-filter: blur(2px);
}
.card__viol[data-v="0"] { color: #9fd08a; }
.card__viol[data-v="1"] { color: #d9c56a; }
.card__viol[data-v="2"] { color: #e0a33e; }
.card__viol[data-v="3"] { color: #e0663e; }

/* Pastille de compte sur les cartes de catalogue (catégorie/auteur/corpus) */
.card__count {
  position: absolute; top: 8px; right: 8px;
  font-size: .75rem; font-weight: 600; padding: 2px 9px; border-radius: 999px;
  background: rgba(224,163,62,.9); color: #1a1509;
}
.card--facet .card__fallback { font-weight: 600; }

/* Grille compacte, réutilisée dans la modale (histoires voisines) */
.grid--mini { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; margin-top: 10px; }
.grid--mini .card__title { font-size: .85rem; }
.grid--mini .card__fallback { font-size: .82rem; padding: 8px; }

.empty { text-align: center; color: var(--ink-dim); margin-top: 60px; font-size: 1.1rem; }

/* ---------- Modale détail ---------- */

.modal-content {
  background: var(--panel);
  border: 1px solid var(--line);
  max-height: 88vh;
  overflow-y: auto;          /* tout le contenu défile */
}
/* Quand le lecteur est ouvert, il occupe le bas : on rétrécit la modale et on
   la remonte pour qu'il ne mange pas sa fin. */
body.has-player .modal { padding-bottom: 96px; }
body.has-player .modal-content { max-height: calc(88vh - 96px); }
.modal__head {
  display: flex; gap: 18px; padding: 22px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0;   /* l'en-tête (et sa croix) reste visible */
  background: var(--panel);
  z-index: 2;
}
.modal__cover {
  flex: 0 0 160px; width: 160px; height: 160px; border-radius: 12px; overflow: hidden;
  background: linear-gradient(145deg, #3a342d, #24201a);
  display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 10px; font-size: .95rem;
}
.modal__cover img { width: 100%; height: 100%; object-fit: cover; }
.modal__title { margin: 0 0 6px; font-size: 1.5rem; }
.modal__meta { color: var(--ink-dim); font-size: .92rem; margin: 2px 0; }
.modal__body { padding: 22px; }
.modal__body p { line-height: 1.6; margin: 0 0 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.chip {
  font-size: .82rem; padding: 4px 12px; border-radius: 999px;
  background: var(--bg-soft); border: 1px solid var(--line); color: var(--ink-dim);
}
.chip--link { text-decoration: none; transition: color .15s, border-color .15s; }
.chip--link:hover { color: var(--accent); border-color: var(--accent); }

/* Surlignage des mots recherchés */
.modal__body mark, .modal__title mark {
  background: var(--accent); color: #1a1509; padding: 0 .12em; border-radius: 3px;
}

/* Liens (auteurs) façon IMDB */
.link { color: #6db3e6; text-decoration: none; }
.link:hover { text-decoration: underline; }

/* Bloc corpus (« famous-title ») */
.corpus { margin: 0 0 16px; }
.corpus__label { display: block; color: var(--ink-faint); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.corpus__link { color: var(--accent); text-decoration: none; font-size: 1.05rem; }
.corpus__link:hover { text-decoration: underline; }

/* Avertissement violence */
.warn {
  margin: 20px 0 0;
  padding: 12px 14px;
  border: 1px solid #6b4a2a;
  background: rgba(224,102,62,.08);
  border-radius: 10px;
}
.warn__label { display: block; color: #e0a33e; font-size: .85rem; margin-bottom: 8px; }
.warn__tags { display: flex; flex-wrap: wrap; gap: 8px; }
.warn__tag {
  font-size: .8rem; padding: 3px 10px; border-radius: 999px;
  background: rgba(224,102,62,.15); border: 1px solid #6b4a2a; color: #eab48f;
}

/* Titre de section dans la modale (histoires voisines) */
.modal__section {
  margin: 22px 0 0; padding-top: 16px; border-top: 1px solid var(--line);
  font-size: 1rem; color: var(--ink-dim); font-weight: 600;
}

/* ---------- Boutons d'écoute dans la fiche ---------- */
.play {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px 14px; margin: 0 0 18px;
}
.play__btn {
  --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent); --bs-btn-color: #1a1509;
  --bs-btn-hover-bg: #eab454; --bs-btn-hover-border-color: #eab454; --bs-btn-hover-color: #1a1509;
  font-weight: 600;
}
.play__restart { color: var(--ink-dim); background: none; border: 0; cursor: pointer; font: inherit; text-decoration: underline; }
.play__restart:hover { color: var(--accent); }
.play__count { color: var(--ink-faint); font-size: .9rem; }

/* ---------- Lecteur ancré en bas ---------- */
.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1500;
  background: rgba(28,23,17,.96); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); box-shadow: 0 -8px 24px rgba(0,0,0,.4);
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
}
.player__inner { display: flex; align-items: center; gap: 14px; }
.player__toggle {
  flex: 0 0 auto; width: 46px; height: 46px; border-radius: 50%;
  border: 0; background: var(--accent); color: #1a1509; font-size: 1.1rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.player__toggle:hover { background: #eab454; }
.player__cover { flex: 0 0 auto; width: 46px; height: 46px; border-radius: 8px; overflow: hidden;
  background: linear-gradient(145deg, #3a342d, #24201a); }
.player__cover img { width: 100%; height: 100%; object-fit: cover; }
.player__info { flex: 1 1 auto; min-width: 0; }
.player__title {
  font-size: .95rem; font-weight: 600; margin-bottom: 4px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.player__title:hover { color: var(--accent); }
.player__seekrow { display: flex; align-items: center; gap: 10px; }
.player__time { color: var(--ink-faint); font-size: .78rem; font-variant-numeric: tabular-nums; flex: 0 0 auto; }
.player__seek { flex: 1 1 auto; accent-color: var(--accent); cursor: pointer; }
.player__close { flex: 0 0 auto; border: 0; background: none; color: var(--ink-faint); font-size: 1.1rem; cursor: pointer; }
.player__close:hover { color: var(--ink); }
body.has-player .app-main { padding-bottom: 110px; }

/* ---------- Vue Lecteur : liste des dernières écoutes ---------- */
.recent { display: flex; flex-direction: column; gap: 10px; }
.recent__item {
  display: flex; align-items: center; gap: 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 14px; cursor: pointer; transition: border-color .15s;
}
.recent__item:hover { border-color: #4a3d2d; }
.recent__cover { flex: 0 0 auto; width: 54px; height: 54px; border-radius: 8px; overflow: hidden;
  background: linear-gradient(145deg, #3a342d, #24201a); display: flex; align-items: center; justify-content: center;
  text-align: center; font-size: .6rem; color: var(--ink-dim); padding: 4px; }
.recent__cover img { width: 100%; height: 100%; object-fit: cover; }
.recent__body { flex: 1 1 auto; min-width: 0; }
.recent__title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent__meta { color: var(--ink-faint); font-size: .8rem; margin: 2px 0 6px; }
.recent__bar { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
.recent__fill { height: 100%; background: var(--accent); }
.recent__btn { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--bg-soft); color: var(--ink); cursor: pointer; font-size: 1rem; }
.recent__btn:hover { border-color: var(--accent); color: var(--accent); }
.recent__del:hover { border-color: #e0663e; color: #e0663e; }

/* ---------- Mobile ---------- */
@media (max-width: 640px) {
  .topbar { padding: 12px 0 10px; }
  .topbar__head { gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
  .topbar__title { font-size: 1.3rem; }
  .topbar__sub { flex-basis: 100%; order: 3; }

  /* Onglets : compacts, défilables horizontalement si besoin */
  .viewbar { gap: 8px; flex-wrap: nowrap; }
  .viewtabs { flex: 1 1 auto; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .viewtabs .btn { font-size: .82rem; padding: .35rem .6rem; white-space: nowrap; }
  .viewtab-player { flex: 0 0 auto; }

  /* Recherche moins massive */
  .searchwrap .form-control { font-size: 1rem; padding-top: 10px; padding-bottom: 10px; }
  .searchwrap .input-group-text { padding: 0 12px; }

  .filters { gap: 8px 14px; font-size: .9rem; }

  /* Lecteur : plus compact */
  .player__toggle { width: 40px; height: 40px; }
  .player__cover { width: 40px; height: 40px; }
  .player__time { font-size: .72rem; }
  .player__close { align-self: flex-start; }
  body.has-player .app-main { padding-bottom: 130px; }

  .banner { font-size: .8rem; padding: 9px 12px; }
}

@media (max-width: 520px) {
  :root { --card-min: 140px; }
  .modal__head { flex-direction: column; align-items: center; text-align: center; }
  .modal__cover { flex-basis: 130px; width: 130px; height: 130px; }
  .modal__body, .modal__head { padding: 16px; }
  .grid { gap: 12px; }
}
