/* ─────────────────────────────────────────────────────────────────
 * Dialogue Engine — visual styles
 * Vibe : visual novel cinematic premium (Detroit / Life is Strange)
 * ─────────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:wght@400;600;700;800&family=Hanken+Grotesk:wght@400;500;600;700&family=Space+Mono:wght@400;700&display=swap');

.dialogue-stage {
  position: relative;
  width: 100%;
  min-height: 100vh;
  background: #17151f;
  font-family: 'Hanken Grotesk', system-ui, sans-serif;
  color: #fbf2dd;
  overflow: hidden;
  user-select: none;
  cursor: pointer;
}

/* Background scene */
.dialogue-bg {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  background-color: #0a0610;
  opacity: 0;
  transition: opacity 1.2s cubic-bezier(.2,.8,.2,1), transform 8s linear;
  transform: scale(1.05);
  filter: brightness(.85) saturate(1.1);
}
.dialogue-bg.loaded {
  opacity: 1;
  /* Ken Burns continu : zoom/pan très lent pour que la scène « respire » */
  animation: dlgKenBurns 46s ease-in-out infinite alternate;
}
@keyframes dlgKenBurns {
  0%   { transform: scale(1)     translate(0, 0); }
  100% { transform: scale(1.055) translate(-0.7%, -0.5%); }
}
@media (prefers-reduced-motion: reduce) {
  .dialogue-bg.loaded { animation: none; transform: scale(1); }
}
/* Mobile : favorise le tiers supérieur (souvent là où est le sujet en plan large) */
@media (max-width: 700px) {
  .dialogue-bg {
    background-position: center 25%;
    background-size: cover;
  }
}
.dialogue-bg-overlay {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse at 50% 100%, rgba(23,21,31,.78) 0%, transparent 60%),
    linear-gradient(180deg, rgba(23,21,31,.30) 0%, transparent 30%, transparent 60%, rgba(23,21,31,.55) 100%);
  pointer-events: none;
}

/* Portraits (cinematic side-by-side) */
.dialogue-portraits {
  position: absolute; inset: 0;
  pointer-events: none;
}
.portrait {
  position: absolute;
  bottom: 220px;
  width: 280px; height: 420px;
  background-size: cover; background-position: center top;
  border-radius: 16px;
  border: 2px solid transparent;
  background-color: rgba(0,0,0,.4);
  opacity: 0;
  transform: translateY(40px) scale(.92);
  transition: all .4s cubic-bezier(.2,.8,.2,1);
}
.portrait.active {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.portrait-left {
  left: 6%;
  transform-origin: left bottom;
}
.portrait-left.active {
  transform: translateY(0) scale(1) rotate(-2deg);
}
.portrait-right {
  right: 6%;
  transform-origin: right bottom;
}
.portrait-right.active {
  transform: translateY(0) scale(1) rotate(2deg);
}
.portrait.has-image::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 50%, rgba(0,0,0,.85));
  border-radius: 14px;
}
.portrait-emoji {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 100px;
  filter: drop-shadow(0 10px 30px rgba(0,0,0,.6));
}

@media (max-width: 900px) {
  .portrait { width: 180px; height: 270px; bottom: 240px; }
  .portrait-left { left: 4%; }
  .portrait-right { right: 4%; }
}
@media (max-width: 600px) {
  .portrait { width: 130px; height: 180px; bottom: 290px; }
}

/* Dialogue box (bottom) */
.dialogue-box {
  position: absolute;
  left: 6%; right: 6%; bottom: 30px;
  background: #241f33;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 18px;
  padding: 22px 28px 24px;

  box-shadow: 0 -8px 40px rgba(0,0,0,.5);
  min-height: 140px;
  z-index: 10;
}
.dialogue-box::before {
  content: ""; position: absolute;
  top: 0; left: 30px; right: 30px; height: 2px;
  background: linear-gradient(90deg, transparent, #ff5da2, transparent);
  border-radius: 0 0 2px 2px;
}
.dialogue-box.narration {
  background: #241f33;
  border-color: rgba(255,255,255,.06);
}
/* Entrée de carte : la boîte monte et s'éclaircit (une « respiration » par carte) */
.dialogue-box.card-enter {
  animation: cardEnter .46s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes cardEnter {
  0%   { opacity: 0; transform: translateY(16px); }
  100% { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
  .dialogue-box.card-enter { animation: none; }
}
.dialogue-box.narration::before {
  background: linear-gradient(90deg, transparent, rgba(185,179,201,.4), transparent);
}

.dialogue-temporal-intertitle {
  position: absolute;
  left: 6%;
  bottom: 205px;
  z-index: 11;
  padding: 6px 10px;
  border: 1px solid rgba(255, 215, 77, .6);
  border-radius: 4px;
  background: rgba(23, 21, 31, .92);
  color: #ffd74d;
  font-family: 'Space Mono', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  line-height: 1.3;
  text-transform: uppercase;
  pointer-events: none;
}

@media (min-width: 901px) {
  .dialogue-temporal-intertitle {
    top: calc(50% - 150px);
    bottom: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .dialogue-temporal-intertitle {
    animation: none;
    transition: none;
  }
}

.dialogue-speaker {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 900; font-size: 16px;
  letter-spacing: .04em; text-transform: uppercase;
  margin-bottom: 8px;
  display: inline-block;
  color: #ff5da2;
}
.dialogue-speaker small {
  display: inline; margin-left: 8px;
  font-family: 'Space Mono', monospace;
  font-weight: 400; font-size: 11px;
  color: #8a7d99;
  letter-spacing: .08em; text-transform: uppercase;
}

.dialogue-text {
  font-size: 17px; line-height: 1.6;
  color: #fbf2dd;
  min-height: 60px;
  font-family: 'Hanken Grotesk', sans-serif;
}
.dialogue-box.narration .dialogue-text {
  color: #b9b3c9; font-style: italic;
  font-size: 16px;
}

.dialogue-arrow {
  position: absolute; bottom: 14px; right: 22px;
  font-size: 16px; color: #ff5da2;
  opacity: 0; transition: opacity .3s;
}
.dialogue-arrow.bounce {
  animation: arrowBounce 1.2s ease-in-out infinite;
}
@keyframes arrowBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(4px); }
}

/* Choices */
.dialogue-choices {
  display: grid; gap: 10px;
  margin-top: 14px;
}
.dialogue-choice-btn {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  background: rgba(255,255,255,.04);
  border: 1.5px solid rgba(255,255,255,.10);
  border-radius: 12px;
  color: #fbf2dd;
  font-family: 'Hanken Grotesk', sans-serif;
  font-size: 14.5px; font-weight: 500;
  text-align: left; line-height: 1.45;
  cursor: pointer;
  transition: all .2s;
  animation: choiceIn .5s cubic-bezier(.2,.8,.2,1) both;
}
.dialogue-choice-btn:hover {
  background: rgba(255,93,162,.10);
  border-color: rgba(255,93,162,.40);
  transform: translateX(3px);
}
.dialogue-choice-btn.selected.picked {
  background: rgba(22,192,138,.20);
  border-color: #5fffd8;
  box-shadow: 0 0 0 1px #5fffd8, 0 6px 20px rgba(95,255,216,.25);
  /* « impression » du choix : petit punch d'échelle puis stabilise (le choix se grave) */
  animation: choicePicked .42s cubic-bezier(.34,1.56,.64,1) both;
}
@keyframes choicePicked {
  0%   { transform: translateX(6px) scale(1); }
  35%  { transform: translateX(6px) scale(1.035); }
  100% { transform: translateX(6px) scale(1); }
}
/* coche qui s'imprime à gauche du choix retenu */
.dialogue-choice-btn.picked .choice-num {
  background: #5fffd8; color: #07241c;
  transition: background .2s, color .2s;
}
.dialogue-choice-btn.picked .choice-num::after {
  content: '✓'; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; animation: choiceCheck .3s .08s ease-out both;
}
@keyframes choiceCheck { from { opacity: 0; transform: scale(.4); } to { opacity: 1; transform: scale(1); } }
.dialogue-choice-btn.faded {
  opacity: .25;
  transform: translateX(0);
  pointer-events: none;
  filter: grayscale(.7);
}

/* Choix verrouillé par stats */
.dialogue-choice-btn.locked {
  opacity: .5;
  cursor: not-allowed;
  filter: grayscale(.4);
  position: relative;
  flex-wrap: wrap;
}
.dialogue-choice-btn.locked .choice-label {
  text-decoration: line-through;
  color: #8a7d99;
}
.dialogue-choice-btn .choice-lock-icon {
  position: absolute;
  top: 8px; right: 12px;
  font-size: 14px;
  opacity: .9;
}
.dialogue-choice-btn .choice-lock-text {
  flex-basis: 100%;
  font-size: 11px;
  color: #ff8da0;
  font-style: italic;
  font-family: 'Space Mono', monospace;
  margin-top: 4px;
  padding-left: 38px;
  letter-spacing: .02em;
}
.dialogue-choice-btn.shake {
  animation: shakeLocked .35s ease-in-out;
}
@keyframes shakeLocked {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-4px); }
}

/* Banner conséquence (langage humain) */
.dialogue-consequence {
  position: absolute;
  bottom: 220px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #ffd23f;
  color: #17151f;
  padding: 14px 24px;
  border-radius: 12px;
  max-width: 80%;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 15px;
  font-style: italic;
  font-weight: 600;
  text-align: center;
  box-shadow: 0 12px 32px rgba(255,210,63,.35);
  opacity: 0;
  pointer-events: none;
  z-index: 30;
  transition: opacity .35s, transform .35s;
}
.dialogue-consequence.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
@media (max-width: 640px) {
  .dialogue-consequence { font-size: 13px; padding: 10px 16px; max-width: 90%; bottom: 280px; }
}
.dialogue-choice-btn .choice-num {
  position: relative;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: rgba(255,93,162,.20);
  color: #ff5da2;
  display: grid; place-items: center;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 800; font-size: 12px;
  flex-shrink: 0;
}
.dialogue-choice-btn.picked .choice-num { color: transparent; } /* le numéro s'efface sous la coche */
@keyframes choiceIn {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ─── Animation changement d'émotion : pulse + badge éphémère ─── */
.portrait.emotion-pulse {
  animation: portrait-emotion-pulse 0.65s cubic-bezier(.2,.8,.2,1);
}
@keyframes portrait-emotion-pulse {
  0%   { transform: scale(1) rotate(var(--rot, 0deg)); }
  35%  { transform: scale(1.08) rotate(var(--rot, 0deg)); filter: brightness(1.15) saturate(1.2); }
  100% { transform: scale(1) rotate(var(--rot, 0deg)); }
}
.portrait .emotion-badge {
  position: absolute;
  bottom: -14px; left: 50%;
  transform: translateX(-50%) translateY(8px);
  padding: 4px 12px;
  background: rgba(20,15,30,.95);
  color: #fff;
  font-family: 'Bricolage Grotesque', 'Hanken Grotesk', sans-serif;
  font-weight: 700; font-size: 11px;
  letter-spacing: .08em;
  border-radius: 999px;
  border: 1.5px solid rgba(255,93,162,.6);
  box-shadow: 0 6px 18px rgba(0,0,0,.5), 0 0 0 1px rgba(255,255,255,.05);
  white-space: nowrap;
  opacity: 0;
  transition: opacity .25s, transform .35s cubic-bezier(.2,.8,.2,1);
  pointer-events: none;
  z-index: 5;
}
.portrait .emotion-badge.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
/* Couleur du badge selon l'émotion (s'aligne sur les filtres existants) */
.portrait[data-emotion="colere"] .emotion-badge { border-color: #e63946; color: #ffd1d8; }
.portrait[data-emotion="joyeux"] .emotion-badge { border-color: #5fffd8; color: #c4fff0; }
.portrait[data-emotion="triste"] .emotion-badge { border-color: #6e7a8a; color: #d8dde5; }
@media (max-width: 640px) {
  .portrait .emotion-badge { font-size: 9.5px; padding: 3px 9px; bottom: -10px; }
}
