/* =============================================================
   ON PARLE — lecteur de conversations interactives
   Structure d'une étape (générée par js/player.js) :

     .player-bar      barre du haut + .progress (barre de lecture)
     .step            grille deux colonnes sur ordinateur
       .step-visual     la case dessinée (reste visible en défilant)
         .transcript    « Lire le dialogue en texte »
       .step-content    la colonne de lecture
         .echo          rappel de la réplique choisie (bulle bleue)
         .step-text     le texte explicatif (champ `info` des trames)
         .chart         le graphique
         .sources       « Pour aller plus loin »
         .replies       les répliques au choix (.reply)
         .end-card      bilan de fin d'épisode (étape F)
     .opening         écran d'ouverture (étape S)
     .map-dialog      plan de la conversation (schéma)
   ============================================================= */
.player-page { --bar-h: 64px; background: var(--paper); }

/* ---------- Barre du lecteur ---------- */
.player-bar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255,255,255,.96); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--concrete-2);
}
.player-bar .inner { display: flex; align-items: center; gap: 1rem; height: var(--bar-h); max-width: 1360px; margin: 0 auto; padding: 0 var(--gutter); }
.player-bar .brand img { height: 46px; }
.player-title { min-width: 0; display: flex; flex-direction: column; line-height: 1.25; padding-left: 1rem; border-left: 1px solid var(--concrete-2); }
.player-title small { font-size: .82rem; color: var(--blue); font-weight: 600; }
.player-title strong { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-tools { margin-left: auto; display: flex; align-items: center; gap: .5rem; flex: none; }
.player-tools .btn { min-height: 44px; padding: .45em 1em; }
.progress { height: 4px; background: var(--concrete); }
.progress span { display: block; height: 100%; width: 0; background: var(--blue); transition: width .5s var(--ease); }
@media (max-width: 640px) {
  .player-page { --bar-h: 58px; }
  .player-bar .inner { gap: .6rem; }
  .player-bar .brand img { height: 38px; }
  .player-title { padding-left: .6rem; }
  .player-title strong { font-size: .9rem; }
  .player-tools .btn span { display: none; }
  .player-tools .btn { width: 44px; padding: 0; }
  .player-tools #btn-restart { display: none; }
}

/* ---------- Scène ---------- */
.scene { transition: opacity .22s ease, transform .22s var(--ease); }
.scene.is-leaving { opacity: 0; transform: translateY(6px); }
.scene.is-entering { opacity: 0; transform: translateY(-4px); transition: none; }

.step {
  display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  gap: clamp(1.5rem, 3.5vw, 3.5rem);
  max-width: 1360px; margin: 0 auto;
  padding: clamp(1.25rem, 3vw, 2.25rem) var(--gutter) 5rem;
}
.step-visual { position: sticky; top: calc(var(--bar-h) + 1.5rem); align-self: start; }
.step-visual .case { position: relative; }
.step-visual .case img { width: 100%; aspect-ratio: 1200 / 730; object-fit: cover; background: var(--concrete); }
.zoom-hint {
  position: absolute; right: .75rem; bottom: .75rem;
  display: inline-flex; align-items: center; gap: .35rem;
  font: 600 .85rem/1 var(--font); color: var(--ink);
  background: var(--paper); border: 2px solid var(--ink); border-radius: 999px; padding: .45rem .75rem;
  cursor: zoom-in;
}
.zoom-hint svg { width: 1em; height: 1em; }
.swipe-hint { display: none; }

/* Transcription du dialogue (optionnelle, champ `dialogue` des trames) */
.transcript { margin-top: 1rem; }
.transcript summary { cursor: pointer; font-weight: 600; font-size: .95rem; color: var(--blue); display: inline-flex; gap: .4rem; align-items: center; list-style: none; padding: .3rem 0; }
.transcript summary::-webkit-details-marker { display: none; }
.transcript summary svg { width: 1.1em; height: 1.1em; }
.transcript ol { list-style: none; padding: .75rem 0 0; margin: 0; display: flex; flex-direction: column; gap: .6rem; }
.transcript li { margin: 0; max-width: 85%; padding: .55rem .9rem; border: 2px solid var(--ink); border-radius: 1.1rem 1.1rem 1.1rem .3rem; background: var(--paper); font-size: .98rem; line-height: 1.4; }
.transcript li.alt { align-self: flex-end; border-radius: 1.1rem 1.1rem .3rem 1.1rem; background: var(--concrete); }
.transcript li b { display: block; font-size: .8rem; color: var(--blue); }

/* ---------- Colonne de lecture ---------- */
.step-content { min-width: 0; max-width: 62ch; }
.echo { display: flex; justify-content: flex-end; margin-bottom: 1.4rem; }
.echo .bubble { background: var(--blue); font-weight: 600; font-size: .98rem; line-height: 1.35; max-width: 34ch; }
.echo .bubble::after { left: auto; right: 1.6em; clip-path: polygon(0 0, 100% 0, 85% 100%); }
.step-title { font-size: clamp(1.75rem, 2.8vw, 2.4rem); color: var(--ink); margin-bottom: .7em; }
.step-text { font-size: 1.075rem; line-height: 1.68; }
.step-text ul { margin: 0 0 1em; }
.step-text li { margin-bottom: .55em; }
.step-text li::marker { color: var(--blue); }

.chart { margin: 1.75rem 0 0; }
.chart button { display: block; width: 100%; padding: 0; border: var(--stroke) solid var(--ink); border-radius: var(--radius-case); overflow: hidden; background: var(--paper); cursor: zoom-in; position: relative; }
.chart img { width: 100%; aspect-ratio: 1; object-fit: contain; }
.chart button .zoom-hint { pointer-events: none; bottom: auto; top: .75rem; }

.sources { margin-top: 1.5rem; padding: 1rem 1.15rem; background: var(--concrete); border-radius: var(--radius-case); font-size: .95rem; line-height: 1.5; }
.sources h2 { font: 700 .95rem/1.3 var(--font); color: var(--ink); margin: 0 0 .35rem; letter-spacing: 0; display: flex; gap: .4rem; align-items: center; }
.sources h2 svg { width: 1.05em; height: 1.05em; color: var(--blue); }
.sources em { display: none; } /* libellé « Ressources » déjà porté par le titre */
.sources em + br { display: none; }

/* ---------- Répliques ---------- */
.replies { margin-top: 2.5rem; padding-top: 1.75rem; border-top: var(--stroke) solid var(--ink); }
.replies h2 { font-size: 1.35rem; color: var(--ink); margin-bottom: 1.1rem; }
.reply-list { display: flex; flex-direction: column; gap: 1.15rem; }
.reply {
  position: relative; display: flex; align-items: flex-start; gap: .8rem; width: 100%;
  text-align: left; font: 600 1.05rem/1.4 var(--font); color: var(--ink);
  background: var(--paper); border: var(--stroke) solid var(--ink); border-radius: var(--radius-bubble);
  padding: .95rem 1.15rem; cursor: pointer;
  transition: background-color .15s, transform .15s var(--ease);
}
.reply::after { /* queue de bulle, côté lecteur */
  content: ""; position: absolute; right: 1.6rem; bottom: -12px;
  width: 18px; height: 12px; background: var(--ink);
  clip-path: polygon(0 0, 100% 0, 80% 100%);
}
.reply::before {
  content: ""; position: absolute; right: calc(1.6rem + 3px); bottom: -7px; z-index: 1;
  width: 12px; height: 8px; background: var(--reply-bg, var(--paper));
  clip-path: polygon(0 0, 100% 0, 80% 100%);
  transition: background-color .15s;
}
.reply:hover, .reply:focus-visible { --reply-bg: var(--yellow); background: var(--yellow); transform: translateX(-3px); }
.reply .key {
  flex: none; display: grid; place-items: center; width: 1.7rem; height: 1.7rem; margin-top: -.05rem;
  border: 2px solid currentColor; border-radius: 6px; font-size: .85rem; font-weight: 700;
}
.reply .txt { flex: 1; }
.reply .tag { display: inline-block; margin-left: .4rem; font-size: .78rem; font-weight: 700; padding: .12rem .5rem; border-radius: 999px; background: var(--ink); color: #fff; vertical-align: .1em; white-space: nowrap; }
.reply .seen { flex: none; display: inline-flex; align-items: center; gap: .25rem; font-size: .8rem; color: var(--ink-soft); font-weight: 600; margin-top: .15rem; }
.reply .seen svg { width: 1em; height: 1em; }
.reply.is-seen { border-color: #8b8f96; color: var(--ink-soft); }
.reply.is-seen::after { background: #8b8f96; }
.reply.is-seen:hover { color: var(--ink); border-color: var(--ink); }
.reply.is-seen:hover::after { background: var(--ink); }
.keys-hint { margin-top: 1.5rem; font-size: .85rem; color: var(--ink-soft); }
.keys-hint kbd { font: 700 .8rem var(--font); border: 1.5px solid var(--ink-soft); border-radius: 4px; padding: 0 .35em; }
@media (hover: none) { .keys-hint, .reply .key { display: none; } }

/* Bouton flottant vers les répliques */
.to-replies {
  position: fixed; left: 50%; bottom: max(1rem, env(safe-area-inset-bottom)); z-index: 20;
  transform: translate(-50%, 140%); transition: transform .25s var(--ease);
  box-shadow: 0 6px 0 -2px var(--ink);
}
.to-replies.is-visible { transform: translate(-50%, 0); }
@media (min-width: 1001px) {
  .to-replies { left: auto; right: max(var(--gutter), calc((100vw - 1360px) / 2 + var(--gutter))); transform: translateY(160%); }
  .to-replies.is-visible { transform: none; }
}

/* ---------- Ouverture ---------- */
.opening {
  display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 4rem); align-items: center;
  max-width: 1360px; margin: 0 auto; padding: clamp(1.5rem, 4vw, 3.5rem) var(--gutter) 4rem;
}
.opening h1 { font-size: clamp(2.1rem, 4vw, 3.4rem); color: var(--ink); }
.opening .ep-num { font-weight: 600; color: var(--blue); margin-bottom: .5rem; }
.opening .hero-facts { margin: 1.25rem 0 2rem; }
.opening .resume-note { margin-top: 1rem; font-size: .92rem; color: var(--ink-soft); }

/* ---------- Fin d'épisode ---------- */
.end-card { margin-top: 2.5rem; padding: clamp(1.25rem, 3vw, 1.75rem); border: var(--stroke) solid var(--ink); border-radius: var(--radius-case); background: var(--yellow); }
.end-card h2 { color: var(--ink); font-size: 1.6rem; margin-bottom: .4rem; }
.end-card .dots { display: flex; flex-wrap: wrap; gap: 6px; margin: .9rem 0 1.25rem; }
.end-card .dots i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); background: var(--paper); }
.end-card .dots i.on { background: var(--ink); }
.end-card .btn-row { gap: .6rem; }
.end-card .btn--ghost:hover { --bg: rgba(255,255,255,.6); }
.next-ep { display: flex; gap: 1rem; align-items: center; margin-top: 1.25rem; padding: .9rem; background: var(--paper); border: var(--stroke) solid var(--ink); border-radius: var(--radius-case); color: var(--ink); text-decoration: none; }
.next-ep:hover { color: var(--ink); background: var(--yellow-soft); }
.next-ep img { width: 110px; flex: none; }
.next-ep small { display: block; color: var(--blue); font-weight: 600; font-size: .85rem; }
.next-ep strong { font-family: var(--font-display); font-size: 1.15rem; line-height: 1.2; }
.next-ep > svg { width: 24px; height: 24px; margin-left: auto; flex: none; }

/* ---------- Plan de la conversation ---------- */
.map-dialog {
  width: min(1100px, 94vw); max-height: 90vh; padding: 0;
  border: var(--stroke) solid var(--ink); border-radius: 10px; background: var(--paper); color: var(--ink);
}
.map-dialog::backdrop { background: rgba(20, 22, 26, .6); }
.map-head { display: flex; align-items: flex-start; gap: 1rem; padding: 1.25rem 1.5rem 1rem; border-bottom: 1px solid var(--concrete-2); position: sticky; top: 0; background: var(--paper); z-index: 2; }
.map-head h2 { font-size: 1.5rem; color: var(--ink); margin: 0 0 .25rem; }
.map-head p { margin: 0; color: var(--ink-soft); font-size: .95rem; }
.map-head .icon-btn { margin-left: auto; }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1.1rem; padding: .75rem 1.5rem 0; font-size: .85rem; color: var(--ink-soft); }
.legend span { display: inline-flex; align-items: center; gap: .4rem; }
.legend i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); display: inline-block; }
.legend i.read { background: var(--ink); }
.legend i.here { background: var(--yellow); }
.legend i.unread { border-style: dashed; border-color: #8b8f96; }

.graph { position: relative; display: flex; gap: clamp(1.5rem, 4vw, 3.5rem); padding: 1.5rem; overflow-x: auto; }
.graph svg.edges { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.graph svg path { fill: none; stroke: var(--concrete-2); stroke-width: 2; }
.graph svg path.on { stroke: var(--ink); }
.col { position: relative; z-index: 1; display: flex; flex-direction: column; justify-content: center; gap: 1rem; flex: 1 1 0; min-width: 150px; }
.node {
  display: flex; align-items: flex-start; gap: .55rem; text-align: left;
  font: 600 .9rem/1.3 var(--font); color: var(--ink-soft);
  background: var(--paper); border: 2px dashed #8b8f96; border-radius: 1rem;
  padding: .65rem .8rem; cursor: pointer; transition: background-color .15s;
}
.node:hover { background: var(--yellow-soft); color: var(--ink); }
.node .dot { flex: none; width: 12px; height: 12px; margin-top: .2rem; border-radius: 50%; border: 2px dashed #8b8f96; }
.node.is-read { border-style: solid; border-color: var(--ink); color: var(--ink); }
.node.is-read .dot { background: var(--ink); border: 2px solid var(--ink); }
.node.is-here { background: var(--yellow); border-style: solid; border-color: var(--ink); color: var(--ink); }
.node.is-here .dot { background: var(--paper); border: 2px solid var(--ink); }
.node.is-end { border-radius: 1rem 1rem 1rem .3rem; }
@media (max-width: 760px) {
  .graph { flex-direction: column; gap: 1.6rem; padding: 1.25rem; overflow: visible; }
  .col { flex-direction: row; flex-wrap: wrap; justify-content: center; min-width: 0; gap: .6rem; }
  .node { flex: 1 1 140px; max-width: 260px; }
}

/* ---------- Réactif ---------- */
@media (max-width: 1000px) {
  .step { grid-template-columns: minmax(0, 1fr); }
  .step-visual { position: static; max-width: 900px; min-width: 0; }
  .step-content { max-width: 68ch; }
  .opening { grid-template-columns: minmax(0, 1fr); }
}
/* Petits écrans : la case se lit en panoramique, les bulles restent lisibles */
@media (max-width: 640px) {
  .step { padding-top: .75rem; gap: 1.25rem; }
  .step-visual { margin: 0 calc(var(--gutter) * -1); }
  .step-visual .case { border-width: var(--stroke) 0; border-radius: 0; overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: none; }
  .step-visual .case::-webkit-scrollbar { display: none; }
  .step-visual .case img { width: auto; max-width: none; height: min(58vh, 400px); aspect-ratio: 1200 / 730; }
  .zoom-hint { display: none; }
  .swipe-hint {
    display: flex; align-items: center; justify-content: center; gap: .4rem;
    font-size: .82rem; color: var(--ink-soft); padding: .5rem var(--gutter) 0; transition: opacity .3s;
  }
  .swipe-hint svg { width: 1.1em; height: 1.1em; }
  .swipe-hint.is-done { opacity: 0; }
  .transcript { padding: 0 var(--gutter); }
  .opening { padding-top: 1rem; }
  .opening .case { margin: 0 calc(var(--gutter) * -1); border-width: var(--stroke) 0; border-radius: 0; }
  .reply { font-size: 1rem; }
  .next-ep img { width: 80px; }
}
