/* La Soundbox — feuille de style unique, mobile d'abord.
   Palette reprise de la version 2021 : rouges profonds, police Assistant. */

:root {
  --red-darkest: #6e161a;
  --red-dark:    #8a1a1e;
  --red:         #a02126;
  --red-light:   #b81d23;
  --red-bright:  #c5141b;
  --ink:         #fff;
  --ink-dim:     rgba(255, 255, 255, .78);
  --gap:         2px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--red-darkest);
  color: var(--ink);
  font-family: 'Assistant', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-weight: 300;
  -webkit-text-size-adjust: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

a { color: inherit; text-decoration: none; }

/* ---------- En-tête ---------- */

#site-header {
  padding: 14px 16px;
  background: var(--red-dark);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
  position: sticky;
  top: 0;
  z-index: 50;
}

#logo { height: 34px; width: auto; display: block; }

/* ---------- Conteneur ---------- */

main {
  flex: 1;
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

.state {
  text-align: center;
  padding: 48px 16px;
  color: var(--ink-dim);
}

/* ---------- Accueil : grille des soundbox ---------- */

#bundle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.bundle-card {
  position: relative;
  display: block;
  aspect-ratio: 16 / 10;
  border-radius: 8px;
  overflow: hidden;
  background: var(--red-dark);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .35);
  transition: transform .15s ease;
}

.bundle-card:hover,
.bundle-card:focus-visible { transform: translateY(-2px); outline: none; }

.bundle-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.bundle-card .label {
  position: absolute;
  inset: auto 0 0 0;
  padding: 18px 10px 8px;
  font-size: 15px;
  font-weight: 600;
  background: linear-gradient(to top, rgba(0, 0, 0, .82), transparent);
  text-shadow: 0 1px 3px rgba(0, 0, 0, .8);
}

/* ---------- Barre de la vue détaillée ---------- */

#detail-bar { margin-bottom: 14px; }

.detail-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.back {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--red);
  font-size: 18px;
  line-height: 1;
}

h1 {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#search {
  width: 100%;
  padding: 10px 14px;
  font: inherit;
  font-size: 16px; /* < 16px déclenche un zoom automatique sur iOS */
  color: var(--ink);
  background: var(--red-dark);
  border: 1px solid var(--red);
  border-radius: 20px;
}

#search::placeholder { color: rgba(255, 255, 255, .5); }
#search:focus { outline: 2px solid var(--red-bright); outline-offset: 1px; }

/* ---------- Filtres personnages ---------- */

#characters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 2px 4px;
  scrollbar-width: none;
}

#characters::-webkit-scrollbar { display: none; }

.chip {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px 4px 4px;
  border-radius: 18px;
  background: var(--red-dark);
  border: 1px solid transparent;
  font-size: 13px;
  cursor: pointer;
  color: inherit;
  font-family: inherit;
  white-space: nowrap;
}

.chip.no-avatar { padding-left: 12px; }
.chip[aria-pressed="true"] { background: var(--red-bright); border-color: #fff; }

.chip img {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--red);
}

/* ---------- Grille des sons ---------- */

#sound-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: var(--gap);
}

/* La tuile et son bouton d'info sont deux boutons FRÈRES dans ce conteneur :
   imbriquer un <button> dans un <button> est invalide en HTML. */
.tile-wrap {
  position: relative;
  aspect-ratio: 1;
}

.tile {
  position: absolute;
  inset: 0;
  cursor: pointer;
  overflow: hidden;
  border: 0;
  padding: 0;
  background: var(--red-dark);
  color: inherit;
  font-family: inherit;
  display: block;
  width: 100%;
}

.info {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 5;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .55);
  color: #fff;
  font: 600 13px/1 'Assistant', sans-serif;
  font-style: italic;
  cursor: pointer;
  opacity: .75;
  transition: opacity .15s, background .15s;
}

.info:hover,
.info:focus-visible { opacity: 1; background: var(--red-bright); }

.tile img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Pendant la lecture, tout s'assombrit sauf la tuile jouée — repris de la v1 */
.tile::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  opacity: 0;
  transition: opacity .2s;
  z-index: 2;
}

#sound-grid.playing .tile::before { opacity: 1; }
#sound-grid.playing .tile.active::before { opacity: 0; }

.tile .title {
  position: absolute;
  inset: auto 0 0 0;
  z-index: 3;
  padding: 16px 6px 5px;
  font-size: 12px;
  line-height: 1.25;
  background: linear-gradient(to top, rgba(0, 0, 0, .85), transparent);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .9);
}

.tile .bar {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 100%;
  z-index: 4;
  background: var(--red-bright);
  transform: scaleX(0);
  transform-origin: left;
}

.tile.running .bar { animation: progress linear forwards; }

@keyframes progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }

@media (prefers-reduced-motion: reduce) {
  .tile.running .bar { animation: none; transform: scaleX(1); }
  .bundle-card { transition: none; }
}

/* ---------- Fiche détaillée d'un son ---------- */

body.locked { overflow: hidden; }

.sheet {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0, 0, 0, .72);
  animation: fade .15s ease;
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.sheet-card {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 18px;
  border-radius: 12px;
  background: var(--red-dark);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .55);
}

.sheet-card .close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, .45);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.sheet-card .close:hover { background: var(--red-bright); }

.sheet-card .shot {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 8px;
  display: block;
  background: var(--red);
}

.sheet-card h2 {
  margin: 14px 0 6px;
  font-size: 19px;
  font-weight: 600;
}

.sheet-card .quote {
  margin: 0 0 14px;
  padding-left: 12px;
  border-left: 3px solid var(--red-bright);
  color: var(--ink-dim);
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-line; /* les répliques à deux voix contiennent des \n */
}

.sheet-card .meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  margin: 0 0 16px;
  font-size: 14px;
}

.sheet-card .meta dt { color: rgba(255, 255, 255, .55); }
.sheet-card .meta dd { margin: 0; }

.sheet-card .actions {
  display: flex;
  gap: 8px;
}

.sheet-card .actions button {
  flex: 1;
  padding: 11px;
  border: 0;
  border-radius: 22px;
  color: #fff;
  font: 600 15px 'Assistant', sans-serif;
  cursor: pointer;
}

.sheet-card .listen { background: var(--red-bright); }
.sheet-card .listen:hover { background: #d8232a; }

.sheet-card .send {
  background: transparent;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .45);
}

.sheet-card .send:hover { background: rgba(255, 255, 255, .12); }
.sheet-card .send:disabled { opacity: .7; cursor: default; }

/* ---------- Pied de page ---------- */

#site-footer {
  padding: 20px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--ink-dim);
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

#site-footer a:hover { text-decoration: underline; }

/* ---------- Page de contenu (politique de confidentialité) ---------- */

.prose { max-width: 720px; line-height: 1.6; }
.prose h2 { font-weight: 600; }
.prose a { text-decoration: underline; }
