/* Page de lecture : mots, syllabes, images, aperçu, animations */
.bar {
  height: 10px;
  background: var(--line);
  border-radius: 9px;
  overflow: hidden;
  margin: 0 1rem;
}

.bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--ok);
  transition: width 0.4s;
}

.flow {
  display: flex;
  flex-wrap: wrap;
  gap: 1.6rem 0.9rem;
  line-height: 1.1;
}

.word {
  display: inline-flex;
  gap: 3px;
}

.word:not(.ghost) .t {
  animation: tin 0.5s ease-in-out;
}

.word:not(.ghost) .pad {
  animation: fade 0.5s ease-in-out;
}

.syl {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  min-width: 2.4rem;
}

.t {
  font-size: var(--fs, 2.6rem);
  text-align: center;
  padding: 0.1rem 0.25rem;
  border-radius: 10px;
  color: var(--ink);
  background: var(--chip);
  transition: background 0.7s ease;
}

.syl.done:nth-child(odd) .t {
  background: var(--a);
}

.syl.done:nth-child(even) .t {
  background: var(--b);
}

.pad {
  height: 2.2rem;
  border-radius: 10px;
  border: 3px solid var(--line);
  background: transparent;
  cursor: pointer;
  padding: 0;
  color: inherit;
}

.syl.done .pad {
  background: var(--ok);
  border-color: var(--ok);
  cursor: default;
}

.syl.next .pad {
  border-color: var(--btn);
  background: var(--btn);
  animation: pulse 1s infinite;
}

.syl.wait .pad {
  border-color: var(--line);
  cursor: not-allowed;
}

.syl.done .t {
  color: var(--ink);
}

.syl.shake {
  animation: shake 0.25s;
}

.punct {
  font-size: var(--fs, 2.6rem);
  align-self: flex-start;
  margin-left: -0.6rem;
  padding-top: 0.1rem;
}

@keyframes pulse {
  50% {
    transform: scale(1.07);
    box-shadow: 0 0 0 6px color-mix(in srgb, var(--btn) 30%, transparent);
  }
}

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

@keyframes tin {
  from {
    opacity: 0.55;
    color: var(--gh);
  }
}

@keyframes gfade {
  from {
    opacity: 0;
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.9);
  }
}

@keyframes shake {
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

.end {
  text-align: center;
  font-size: 1.6rem;
  margin-top: 2rem;
}

.end button {
  font: inherit;
  margin: 0.4rem;
  padding: 0.7rem 1.2rem;
  border-radius: 14px;
  border: 0;
  background: var(--btn);
  color: var(--btnink);
  cursor: pointer;
}

.stars {
  font-size: 3rem;
}

.word {
  transition:
    opacity 0.8s ease 0.6s,
    filter 0.8s ease 0.6s;
}

.word.read {
  opacity: 0.3;
  filter: grayscale(1);
}

.ghost {
  animation: gfade 0.6s ease-out;
}

.ghost .t {
  color: #7b5cd6;
  opacity: 0.55;
  background: none;
}

.ghost .pad {
  visibility: hidden;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ghost .t {
    color: #b9a6ff;
  }
}

:root[data-theme="dark"] .ghost .t {
  color: #b9a6ff;
}

.br {
  flex-basis: 100%;
  height: 0;
  margin-top: -1.6rem;
}

#msg {
  margin: 0.4rem 1rem 0;
  font-size: 0.95rem;
  color: var(--mute);
}

.pic {
  flex-basis: 100%;
  margin: 0.3rem 0;
  text-align: center;
  animation: pop 0.5s ease-out;
  transition:
    opacity 0.8s ease,
    filter 0.8s ease;
}

/* Aperçu « tout » : image pas encore atteinte */
.pic.future {
  opacity: 0.3;
  filter: grayscale(1);
}

.pic img {
  max-height: 200px;
  max-width: 100%;
  border-radius: 16px;
}

.pic.emo {
  font-size: 5rem;
  line-height: 1.1;
}

/* Menu : une ligne par histoire (bouton de lecture + bouton « écouter le titre ») */
.story-row {
  display: flex;
  gap: 0.5rem;
}
.story-row .go {
  flex: 1;
}
.story-row .say {
  background: var(--card);
  color: var(--ink);
  border-color: var(--btn);
}
