/* --- Reset et base --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: system-ui, sans-serif;
  background: #f5f5f5;
}

/* --- Menu --- */
.menu {
  background: #333;
  color: white;
  padding: 10px;
  text-align: center;
}
.menu a {
  color: white;
  text-decoration: none;
}

.menu a:hover {
  color: #aaaaaa;
}

/* --- Container principal (le "chat") --- */
.container {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end; /* le bouton reste en bas */
  align-items: stretch;
  height: calc(100vh - 50px);
  min-height: 300px;
  margin: 0 auto;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  transition: width 0.3s ease;
}

/* largeur responsive */
@media (max-width: 768px) {
  .container { width: 100%; }
}
@media (min-width: 769px) {
  .container { width: 50%; }
}

/* --- Zone des bulles --- */
#bubbleContainer {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  background: #fafafa;
}

/* --- Zone des options --- */
#actionOptions {
  display: flex;
  flex-direction: column;    /* boutons verticaux */
  align-items: stretch;
  gap: 10px;
  padding: 10px;
  background: #f0f0f0;

  /* la zone s’affiche au-dessus du bouton principal */
  max-height: 50%;           /* limite à 50% du container */
  overflow-y: auto;
  position: relative;
}

/* --- BOUTONS GÉNÉRIQUES --- */
button {
  background: #0078ff;
  color: white;
  font-size: 16px;
  padding: 6px 8px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.2s;
}

button:hover {
  background: #005fcc;
}

/* --- Boutons d'options --- */
#actionOptions button,
#actionButton {
  width: 100%;
  height: 50px;
  transition: background 0.2s;
}

/* --- Bouton principal --- */
#actionButton {
  flex-shrink: 0;
}

/* --- Conteneur des bulles --- */
#bubbleContainer {
  flex: 1;
  overflow-y: auto;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fafafa;
}

/* --- Structure d'une bulle avec acteur --- */
.bubbleContainer {
  display: flex;
  flex-direction: column;     /* empile le nom et la bulle */
  width: 100%;
  margin: 8px 0;
}

/* --- Nom de l’acteur (au-dessus de la bulle) --- */
.bubbleContainer .actor {
  font-size: 13px;
  font-weight: 500;
  color: #555;
  margin-left: 12px;          /* léger retrait vers la droite */
  margin-bottom: 3px;         /* espace avant la bulle */
  opacity: 0.8;
  align-self: flex-start;
}

/* --- Bulles selon le type (détection automatique) --- */
.bubbleContainer .bubble {
  position: relative;
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 14px;
  line-height: 1.4;
  font-size: 16px;
  word-wrap: break-word;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* --- Si l’acteur a du texte → bulle à gauche --- */
.bubbleContainer:has(.actor:not(:empty)) .bubble {
  background: #e0e0e0;
  color: #333;
  border-bottom-left-radius: 0;
  align-self: flex-start;
}

.bubbleContainer:has(.actor:not(:empty)) .bubble::after {
  content: "";
  position: absolute;
  left: -6px;
  bottom: 0;
  width: 0;
  height: 0;
  border: 8px solid transparent;
  border-right-color: #e0e0e0;
  border-bottom: 0;
}

/* --- Si l’acteur est vide → bulle à droite (joueur) --- */
.bubbleContainer:has(.actor:empty) .bubble {
  background: #0078ff;
  color: white;
  border-bottom-right-radius: 0;
  align-self: flex-end;
}

.bubbleContainer:has(.actor:empty) .bubble::after {
  content: "";
  position: absolute;
  right: -6px;
  bottom: 0;
  width: 0;
  height: 0;
  border: 8px solid transparent;
  border-left-color: #0078ff;
  border-bottom: 0;
}

/* --- Bulle de choix (bubbleChoice) --- */
.bubbleChoice {
  align-self: flex-end;
  background: #ffffff;
  color: #0078ff;
  border: 2px solid #0078ff;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  max-width: 70%;
  text-align: center;
  transition: background 0.2s, color 0.2s;
}
.bubbleChoice:hover {
  background: #0078ff;
  color: #fff;
}

/* --- Animation de changement de couleur --- */
@keyframes colorPulse {
  0%   { background-color: #0078ff; }
  50%  { background-color: #00b7ff; }
  100% { background-color: #0078ff; }
}

/* Classe d'animation avant le premier clic */
#actionButton.attention {
  animation: colorPulse 1.5s ease-in-out infinite;
  transition: background-color 0.3s ease;
}

#storyData{
    margin-left: 20px;
}

.illustration{
    max-height: 200px;
}

#openPreviewBtn {
    margin: 5px;
    border: none;
  }

  /* Overlay */
  .modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: none;
    justify-content: center;
    align-items: center;
  }

  /* Fenêtre modale */
  .modal {
    background: white;
    border-radius: 12px;
    width: 400px;
    max-width: 90%;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    animation: fadeIn 0.3s ease;
  }

  @keyframes fadeIn {
    from {opacity: 0; transform: translateY(-10px);}
    to {opacity: 1; transform: translateY(0);}
  }

  .modal-header {
    padding: 12px 16px;
    border-bottom: 1px solid #ddd;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  /* Menu */
  .modal-menu {
    display: flex;
    justify-content: space-around;
    padding: 12px;
    width: 100%;
  }

  .modal-menu button {
    display: flex;
    justify-content: space-around;
    padding: 12px;
  }


  /* Contenu preview */
  .modal-content {
    padding: 16px;
    text-align: center;
  }

  .modal-content img {
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: 8px;
    object-fit: cover;
    background: #f0f0f0;
  }

  .modal-content h2 {
    margin: 12px 0 4px;
    font-size: 18px;
  }

  .modal-content h3 {
    margin: 0 0 10px;
    color: #666;
    font-size: 14px;
    font-weight: normal;
  }

  .modal-content p {
    text-align: justify;
    font-size: 14px;
    color: #333;
    border: gray solid 1px;
    border-radius: 6px;
    padding: 2px;
    font-weight: bolder;
  }

  #previewAuthor::before {
    content: "@";
    margin-right: 5px; 
  }

  #menuPlayer{
    display: inline-flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid black;
  }

  #menuPlayer a{
    text-decoration: none;
    margin: 5px;
    font-size: 25px;
    font-weight: 500;
  }
  #menuPlayer a:hover{
    color: #0078ff;
  }

  #menuPlayer h2{
    margin: 5px;
  }