/* ============================================================
   ORIGINS — CORE STYLES
   Tous les styles partagés entre les énigmes.
   Pour personnaliser globalement le jeu, modifier les variables
   CSS ci-dessous dans :root.
   ============================================================ */

:root {
  /* ───── COULEURS DES VOIX ───── */
  --c-father: #ff5a2a;
  --c-mother: #ffcf40;
  --c-child:  #4db8e8;
  --c-mystery: #d43f8d;

  /* ───── COULEURS DE BASE ───── */
  --c-bg:    #050314;  /* fond cosmique */
  --c-cream: #f2e8d5;  /* texte clair */
  --c-black: #0a0510;  /* noir profond pour contours */
  --c-wood:  #6e4a1e;  /* bois de forge */
  --c-gold:  #ffcf40;  /* doré chaleureux */

  /* ───── TYPOGRAPHIE ───── */
  --font-title:  'Permanent Marker', cursive;
  --font-body:   'Special Elite', monospace;
  --font-vintage: 'VT323', monospace;

  /* ───── DIALOGUE OVERLAY ───── */
  --dialogue-bg:        rgba(5, 3, 20, 0.94);  /* fond du dialogue */
  --dialogue-blur:      6px;
  --dialogue-transition: 1s;

  /* ───── REVEAL DE LA FRESQUE ───── */
  --reveal-transition: 2.5s;             /* durée du fade-in de l'image */
  --reveal-fade-out:   1.8s;             /* durée du fade-out des éléments d'énigme */

  /* ───── LUMINOSITÉ DES PANNEAUX (HUB) ───── */
  /* État LOCKED : énigme non débloquée */
  --panel-locked-opacity:    0.05;
  --panel-locked-grayscale:  1;
  --panel-locked-brightness: 0.25;
  --panel-locked-blur:       4px;

  /* État AVAILABLE : débloquée mais pas faite */
  --panel-available-opacity:    0.12;
  --panel-available-grayscale:  0.85;
  --panel-available-brightness: 0.35;
  --panel-available-blur:       3px;

  /* État AVAILABLE NEXT : la prochaine à faire */
  --panel-next-opacity:    0.25;
  --panel-next-grayscale:  0.5;
  --panel-next-brightness: 0.5;
  --panel-next-blur:       2px;

  /* Cartouches mystères AVAILABLE */
  --cartouche-available-opacity:    0.18;
  --cartouche-available-grayscale:  0.8;
  --cartouche-available-brightness: 0.4;
  --cartouche-available-blur:       2.5px;
}

/* ============================================================
   RESET ET BASE
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  overflow: hidden;
  background: var(--c-bg);
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
body {
  width: 100vw;
  height: 100vh;
  position: relative;
  font-family: var(--font-body);
  color: var(--c-cream);
  cursor: default;
}

/* ============================================================
   RÉVÉLATION DE LA FRESQUE FINALE
   Chaque énigme définit l'URL exacte de son image via inline style :
   <div class="reveal-bg" style="background-image:url('bg-xxx.webp')"></div>
   ============================================================ */
.reveal-bg {
  position: fixed;
  inset: 0;
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  z-index: 1;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--reveal-transition) ease;
}
.reveal-bg.visible { opacity: 1; }

/* Vignette optionnelle — désactivée par défaut (ne s'assombrit pas) */
.reveal-vignette {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse 70% 50% at 50% 50%,
    rgba(5, 3, 20, 0.55) 0%,
    rgba(5, 3, 20, 0.25) 60%,
    rgba(5, 3, 20, 0.7) 100%);
  z-index: 28;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.2s ease;
}
.reveal-vignette.visible { opacity: 1; }

/* Masque tous les "final-display" centraux historiques (refonte révélation) */
.final-display, .final-display-reveal {
  display: none !important;
}

/* Pendant la phase reveal : tous les éléments hors fresque/dialogue
   reçoivent .reveal-fading et disparaissent en douceur */
.reveal-fading {
  transition: opacity var(--reveal-fade-out) ease,
              filter var(--reveal-fade-out) ease !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Quand body.revealing est ajouté : tous les enfants directs du body deviennent
   invisibles SAUF revealBg, dialogueOverlay, tapIndicator, grain, ou ceux
   marqués .keep-during-reveal */
body.revealing > *:not(#revealBg):not(#revealVignette):not(#dialogueOverlay):not(#tapIndicator):not(.grain):not(.keep-during-reveal):not(#devSkipBtn) {
  opacity: 0 !important;
  transition: opacity var(--reveal-fade-out) ease,
              filter var(--reveal-fade-out) ease !important;
  pointer-events: none !important;
}

/* ============================================================
   DIALOGUE OVERLAY
   ============================================================ */
.dialogue-overlay {
  position: fixed;
  inset: 0;
  background: var(--dialogue-bg);
  backdrop-filter: blur(var(--dialogue-blur));
  -webkit-backdrop-filter: blur(var(--dialogue-blur));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dialogue-transition) ease;
  z-index: 50;
  overflow-y: auto;
  /* Masque la scrollbar tout en gardant le défilement */
  scrollbar-width: none;        /* Firefox */
  -ms-overflow-style: none;     /* IE / Edge legacy */
}
.dialogue-overlay::-webkit-scrollbar { display: none; }  /* Chrome / Safari */
.dialogue-overlay.visible { opacity: 1; pointer-events: auto; cursor: default; }

.dialogue-container {
  width: 100%;
  max-width: 700px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: auto 0;
}

/* Une réplique de dialogue */
.line {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.line.visible { opacity: 1; transform: translateY(0); }
.line.father { flex-direction: row; }
.line.mother { flex-direction: row-reverse; }
.line.child  { flex-direction: row; padding-left: 30px; }

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid;
  flex-shrink: 0;
  background: rgba(10, 5, 16, 0.7);
}
.avatar.father { border-color: var(--c-father); }
.avatar.mother { border-color: var(--c-mother); }
.avatar.child  { border-color: var(--c-child); }

.bubble-msg {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  padding: 12px 16px;
  border-radius: 4px;
  background: rgba(20, 14, 30, 0.8);
  border-left: 3px solid;
  max-width: 80%;
}
.line.father .bubble-msg {
  border-left-color: var(--c-father);
  color: var(--c-cream);
}
.line.mother .bubble-msg {
  border-left: none;
  border-right: 3px solid var(--c-mother);
  color: var(--c-cream);
}
.line.child .bubble-msg {
  border-left-color: var(--c-child);
  color: #c8e0f0;
  font-style: italic;
}
.bubble-msg em {
  color: var(--c-gold);
  font-style: normal;
  font-weight: bold;
}
.line.father .bubble-msg em { color: #ff9a5a; }
.line.child  .bubble-msg em { color: #7dc8f0; }

/* Indicateur "tap pour continuer" */
.tap-indicator {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-title);
  font-size: 13px;
  color: rgba(242, 232, 213, 0.5);
  letter-spacing: 3px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
  z-index: 65;
}
.tap-indicator.visible { opacity: 1; }

/* ============================================================
   CARTE DE FIN (sources scientifiques + fragment)
   ============================================================ */
.end-card {
  background: rgba(20, 12, 8, 0.95);
  border: 4px solid var(--c-wood);
  border-radius: 4px;
  padding: 24px;
  margin-top: 20px;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.8s ease, transform 0.8s ease;
  text-align: center;
  position: relative;
  overflow: hidden;
}
/* le contenu reste au-dessus de la lueur de célébration */
.end-card > * { position: relative; z-index: 1; }
/* Micro-célébration : une lueur dorée éclot derrière la carte quand elle apparaît */
.end-card::before {
  content: ''; position: absolute; left: 50%; top: 38%; z-index: 0;
  width: 150%; height: 150%; transform: translate(-50%, -50%) scale(0.2);
  background: radial-gradient(circle, rgba(255,207,64,0.40) 0%, rgba(255,170,70,0.14) 34%, transparent 62%);
  opacity: 0; pointer-events: none;
}
.end-card.visible {
  opacity: 1;
  transform: translateY(0);
  animation: endGlow 1.9s ease-out 0.2s 1;
}
.end-card.visible::before { animation: endBloom 1.7s ease-out 0.2s both; }
@keyframes endBloom {
  0%   { opacity: 0; transform: translate(-50%,-50%) scale(0.2); }
  28%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%,-50%) scale(1.25); }
}
@keyframes endGlow {
  0%   { box-shadow: 0 0 0 0 rgba(255,207,64,0); }
  30%  { box-shadow: 0 0 34px 2px rgba(255,207,64,0.45); }
  100% { box-shadow: 0 0 0 0 rgba(255,207,64,0); }
}
@media (prefers-reduced-motion: reduce) {
  .end-card.visible, .end-card.visible::before { animation: none; }
}

/* Ancien badge « fragment/indice » : principe abandonné → masqué partout. */
.fragment-badge { display: none !important; }

/* ============================================================
   TRANSITIONS DE PAGE — fondu enchaîné natif entre pages de même
   origine (View Transitions). Amélioration progressive : ignorée
   par les navigateurs qui ne la gèrent pas, et ne se déclenche
   qu'entre deux pages qui l'activent toutes les deux.
   ============================================================ */
@view-transition { navigation: auto; }

.sources-title {
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 14px;
  color: #d4a85a;
  letter-spacing: 2px;
  margin-bottom: 10px;
}
.sources-title::first-letter { text-transform: uppercase; }

.sources-text {
  font-family: 'Poppins', sans-serif;
  font-size: 12.5px;
  color: rgba(242, 232, 213, 0.85);
  line-height: 1.65;
  text-align: left;
  margin-bottom: 20px;
}
.sources-text::first-letter { text-transform: uppercase; }
.sources-text em {
  color: var(--c-gold);
  font-style: normal;
  font-weight: bold;
}

.continue-btn {
  background: rgba(10, 5, 16, 0.8);
  color: #fff;
  border: 2px solid var(--c-gold);
  padding: 10px 22px;
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 2px;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s ease;
}
.continue-btn:hover {
  background: rgba(255, 207, 64, 0.15);
  transform: translateY(-2px);
}
.continue-btn:active { transform: translateY(0); }

/* ── BOUTON DEV SKIP (ajouté par Origins.addDevSkip) ── */
.origins-dev-skip {
  position: fixed;
  top: 8px; right: 8px;
  z-index: 9999;
  background: rgba(212, 63, 141, 0.85);
  color: #fff;
  border: 2px solid #fff;
  padding: 4px 10px;
  font-family: 'Permanent Marker', cursive;
  font-size: 11px;
  letter-spacing: 2px;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.6;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
}
.origins-dev-skip:hover { opacity: 0.9; }
