@font-face {
  font-family: 'Roboto';
  src: url('assets/fonts/Roboto-Regular.ttf') format('truetype');
  font-weight: 400;
}
@font-face {
  font-family: 'Roboto';
  src: url('assets/fonts/Roboto-Bold.ttf') format('truetype');
  font-weight: 700;
}

:root {
  --bg: #333333;
  --primary: #d4a373;
  --primary-dark: #b98a5e;
  --secondary: #8a6846;
  --text: #f4f1ec;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Roboto Condensed', 'Roboto', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.app {
  position: relative;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  overflow: hidden;
}

/* Header */
header {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60px;
  padding-top: env(safe-area-inset-top);
  background: transparent;
  position: relative;
  z-index: 1;
}
header .back {
  position: absolute;
  left: 0.75rem;
  bottom: 10px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(212, 163, 115, 0.12);
  color: var(--primary);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}
header .back[hidden] { display: none; }
header .back:active { transform: scale(0.92); background: rgba(212, 163, 115, 0.25); }
header .back svg { width: 22px; height: 22px; display: block; }
header .logo {
  width: 32px;
  height: 32px;
  margin-right: 0.5rem;
  border-radius: 8px;
  object-fit: contain;
}
header h1 {
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--primary);
  letter-spacing: 0.3px;
}

/* Contenu */
main {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1.5rem 110px;
  text-align: center;
  overflow-y: auto;
}
main, .text { transition: opacity 0.22s ease; }
main.leaving, .text.leaving { opacity: 0; }

.photo {
  position: relative;
  width: 100%;
  max-width: 360px;
  aspect-ratio: 1.3;
  border-radius: 16px;
  overflow: hidden;
  background: #2a2a2a;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  margin-bottom: 1.75rem;
}
.photo.missing img { display: none; }
.photo.missing::after {
  content: attr(data-missing);
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  border: 2px dashed rgba(212, 163, 115, 0.45);
  border-radius: 16px;
  color: var(--primary);
  font-size: 1rem;
  line-height: 1.35;
}
.photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: object-position var(--pan, 1200ms) cubic-bezier(0.45, 0, 0.25, 1);
}
.photo img.no-pan { transition: none; }
@media (prefers-reduced-motion: reduce) {
  .photo img { transition: none; }
}

.text {
  font-size: 1.45rem;
  line-height: 1.35;
  max-width: 360px;
  margin-bottom: 1.75rem;
}

/* Bouton suivant (icône play-forward de l'app) */
.next {
  display: grid;
  place-items: center;
  width: 5.5rem;
  height: 4rem;
  border: none;
  background: none;
  color: var(--secondary);
  cursor: pointer;
  transition: transform 0.15s ease, color 0.15s ease;
}
.next:active { transform: scale(0.9); color: var(--primary); }
.next svg { width: 100%; height: 100%; display: block; }

/* Bouton final */
.cta {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1rem 2rem;
  border: none;
  border-radius: 40px;
  cursor: pointer;
  background: var(--primary-dark);
  color: #fff8ef;
  font-family: inherit;
  font-size: 1.3rem;
  font-weight: 500;
  text-transform: uppercase;
  text-decoration: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  transition: transform 0.15s ease;
}
.cta:active { transform: scale(0.96); }
.cta svg { width: 22px; height: 22px; }

/* Onde audio en bas (fines barres verticales) */
.bars {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 64px;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 3;
  pointer-events: none;
}
.bars svg { width: 100%; height: 100%; display: block; overflow: visible; }
.bars rect {
  fill: var(--primary);
  opacity: 0.35;
  transform-box: fill-box;
  transform-origin: center bottom;
}
/* Égaliseur : animé uniquement pendant l'histoire (statique sur l'étape 0) */
.bars.playing rect {
  animation: eq var(--d, 1s) ease-in-out var(--delay, 0s) infinite alternate;
}
@keyframes eq {
  0% { transform: scaleY(1); }
  50% { transform: scaleY(var(--lo, 0.4)); }
  100% { transform: scaleY(var(--hi, 1.2)); }
}
@media (prefers-reduced-motion: reduce) {
  .bars.playing rect { animation: none; }
}

/* Écran d'accueil (étape 0) */
.intro {
  position: absolute;
  top: calc(60px + env(safe-area-inset-top));
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem 1.5rem 110px;
  text-align: center;
  background: var(--bg);
  overflow-y: auto;
  transition: opacity var(--intro-fade, 600ms) ease;
}
.intro.hidden { opacity: 0; pointer-events: none; }
.intro[hidden] { display: none; }

.wave { color: var(--primary); margin-bottom: 1.25rem; }
.wave svg { width: 48px; height: 40px; display: block; }

.book {
  position: relative;
  width: 62%;
  max-width: 240px;
  margin: 0.5rem auto 2rem;
}
.book::before {
  content: '';
  position: absolute;
  inset: -22%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(212, 163, 115, 0.35) 0%, rgba(212, 163, 115, 0) 65%);
  animation: pulse 3s ease-in-out infinite;
}
.book img {
  position: relative;
  width: 100%;
  display: block;
  border-radius: 3px 8px 8px 3px;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.35),
    0 12px 24px rgba(0, 0, 0, 0.45),
    0 30px 60px rgba(0, 0, 0, 0.55),
    inset 4px 0 6px rgba(255, 255, 255, 0.18);
  transform: perspective(900px) rotateY(-8deg);
  animation: float 4s ease-in-out infinite;
}
/* Ombre au sol, diffuse */
.book::after {
  content: '';
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -18px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  filter: blur(12px);
  z-index: -1;
}
.sparkle {
  position: absolute;
  color: #ffd98a;
  font-size: 14px;
  line-height: 1;
  animation: twinkle 2.2s ease-in-out infinite;
}
@keyframes float { 50% { transform: perspective(900px) rotateY(-8deg) translateY(-6px); } }
@keyframes pulse { 50% { opacity: 0.6; transform: scale(0.94); } }
@keyframes twinkle { 0%, 100% { opacity: 0.2; transform: scale(0.7); } 50% { opacity: 1; transform: scale(1.1); } }

.intro-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 340px;
  margin: 0.75rem 0 1.75rem;
  text-wrap: balance;
}
.speaker { color: var(--primary); opacity: 0.75; margin-bottom: 0.6rem; }
.speaker svg { width: 22px; height: 28px; display: block; }
.intro-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 0.4rem;
}
.intro-sub {
  font-size: 1.1rem;
  font-weight: 300;
  line-height: 1.4;
  color: rgba(244, 241, 236, 0.85);
}
.hint {
  margin-top: 0.8rem;
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.45);
  letter-spacing: 0.2px;
}
