/* ════════════════════════════════════════════════════════════════════════════
   Le Corbeau de Tulle — Feuille de style
   Palette : noir chaud · parchemin · rouge encre · or vieilli
   ════════════════════════════════════════════════════════════════════════════ */

/* ── Polices ────────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;0,900;1,400;1,700&family=EB+Garamond:ital,wght@0,400;0,500;1,400&family=Special+Elite&display=swap');

/* ── Reset & base ────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --noir:      #080705;
  --noir-chaud:#110e0a;
  --parchemin: #e8d5b0;
  --parchemin-fonce: #c9b98a;
  --rouge:     #8b1a1a;
  --rouge-vif: #b02020;
  --or:        #c4902a;
  --gris:      #3d3830;
  --gris-clair:#6b5f52;

  --serif:      'Playfair Display', Georgia, serif;
  --garamond:   'EB Garamond', Georgia, serif;
  --typewriter: 'Special Elite', 'Courier New', monospace;

  --transition: 600ms cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--noir);
  color: var(--parchemin);
  font-family: var(--garamond);
  font-size: 18px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

/* ── Grain cinématique ──────────────────────────────────────────────────────── */
body::after {
  content: '';
  position: fixed; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  background-size: 256px 256px;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.35;
  mix-blend-mode: overlay;
}

/* ════════════════════════════════════════════════════════════════════════════
   LANDING
   ════════════════════════════════════════════════════════════════════════════ */

#landing {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--noir);
  z-index: 100;
  transition: opacity 800ms ease;
}

#landing.fade-out { opacity: 0; pointer-events: none; }

.landing-inner {
  text-align: center;
  padding: 2rem;
  max-width: 700px;
}

/* Vignette landing */
#landing::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 60% 60% at 50% 50%,
    transparent 40%, rgba(0,0,0,0.85) 100%);
  pointer-events: none;
}

.landing-year {
  font-family: var(--typewriter);
  font-size: 0.8rem;
  letter-spacing: 0.4em;
  color: var(--gris-clair);
  text-transform: uppercase;
  margin-bottom: 2rem;
  animation: fadeSlideUp 1s ease 0.3s both;
}

.landing-title {
  font-family: var(--serif);
  font-size: clamp(4rem, 12vw, 9rem);
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: -0.02em;
  color: var(--parchemin);
  text-shadow: 0 0 60px rgba(196, 144, 42, 0.15);
  animation: fadeSlideUp 1s ease 0.5s both;
}

.landing-subtitle {
  font-family: var(--serif);
  font-size: clamp(1rem, 3vw, 1.4rem);
  font-weight: 400;
  font-style: italic;
  color: var(--parchemin-fonce);
  letter-spacing: 0.1em;
  margin: 1.5rem 0 0.5rem;
  animation: fadeSlideUp 1s ease 0.7s both;
}

.landing-location {
  font-family: var(--typewriter);
  font-size: 0.75rem;
  letter-spacing: 0.3em;
  color: var(--rouge);
  text-transform: uppercase;
  margin-bottom: 3rem;
  animation: fadeSlideUp 1s ease 0.9s both;
}

.landing-divider {
  width: 60px; height: 1px;
  background: var(--or);
  margin: 0 auto 2.5rem;
  opacity: 0.5;
  animation: scaleX 1s ease 1.1s both;
}

.landing-desc {
  font-family: var(--garamond);
  font-size: 0.95rem;
  line-height: 1.8;
  color: var(--gris-clair);
  max-width: 400px;
  margin: 0 auto 3rem;
  animation: fadeSlideUp 1s ease 1.2s both;
}

#enter-btn {
  font-family: var(--typewriter);
  font-size: 0.75rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--parchemin);
  background: transparent;
  border: 1px solid rgba(232, 213, 176, 0.3);
  padding: 1rem 2.5rem;
  cursor: pointer;
  transition: all 400ms ease;
  animation: fadeSlideUp 1s ease 1.4s both;
  position: relative;
  overflow: hidden;
}

#enter-btn::before {
  content: '';
  position: absolute; inset: 0;
  background: var(--rouge);
  transform: translateX(-100%);
  transition: transform 400ms ease;
}

#enter-btn:hover {
  border-color: var(--rouge);
  color: var(--parchemin);
}

#enter-btn:hover::before { transform: translateX(0); }
#enter-btn span { position: relative; z-index: 1; }

/* Silhouette corbeau */
.crow-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 2rem;
  opacity: 0.4;
  animation: fadeSlideUp 1s ease 0.2s both, float 4s ease-in-out 2s infinite;
  filter: drop-shadow(0 0 20px rgba(139,26,26,0.4));
}

/* ════════════════════════════════════════════════════════════════════════════
   EXPERIENCE
   ════════════════════════════════════════════════════════════════════════════ */

#experience {
  position: fixed; inset: 0;
  display: none;
}

#experience.visible { display: block; }

/* Canvas 3D */
#splat-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  cursor: grab;
}

#splat-canvas:active { cursor: grabbing; }

/* Vignette permanente sur le viewer */
#vignette {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 80% 75% at 50% 50%,
    transparent 30%, rgba(8,7,5,0.7) 100%);
  pointer-events: none;
  z-index: 2;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */

#main-header {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.5rem 2.5rem;
  z-index: 10;
  background: linear-gradient(to bottom, rgba(8,7,5,0.8) 0%, transparent 100%);
}

.header-logo {
  font-family: var(--serif);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  color: var(--parchemin);
  opacity: 0.7;
  text-transform: uppercase;
}

.header-logo em {
  font-style: italic;
  color: var(--or);
  font-weight: 400;
}

/* ── Panneau narration ───────────────────────────────────────────────────────── */

#narration-panel {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  z-index: 10;
  padding: 0 2.5rem 2.5rem;
  background: linear-gradient(to top,
    rgba(8,7,5,0.95) 0%,
    rgba(8,7,5,0.7)  60%,
    transparent      100%);
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 0;
}

/* Indicateur de chapitre */
#chapter-indicator {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

#chapter-num {
  font-family: var(--typewriter);
  font-size: 0.65rem;
  letter-spacing: 0.3em;
  color: var(--rouge);
  opacity: 0.8;
}

#chapter-date {
  font-family: var(--typewriter);
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  color: var(--gris-clair);
  margin-left: auto;
}

#chapter-title {
  font-family: var(--serif);
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  font-weight: 700;
  color: var(--parchemin);
  line-height: 1.2;
  margin-bottom: 0.75rem;
  transition: opacity 400ms ease;
}

#narration-text {
  font-family: var(--garamond);
  font-size: clamp(0.9rem, 1.8vw, 1.05rem);
  line-height: 1.75;
  color: var(--parchemin-fonce);
  max-width: 700px;
  min-height: 4.5em;
  transition: opacity 400ms ease;
}

#narration-text em {
  color: var(--parchemin);
  font-style: italic;
}

/* ── Navigation ─────────────────────────────────────────────────────────────── */

#navigation {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.nav-btn {
  font-family: var(--typewriter);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--parchemin);
  background: transparent;
  border: 1px solid rgba(232, 213, 176, 0.2);
  padding: 0.6rem 1.2rem;
  cursor: pointer;
  transition: all 300ms ease;
  flex-shrink: 0;
}

.nav-btn:hover:not(:disabled) {
  border-color: var(--or);
  color: var(--or);
}

.nav-btn:disabled {
  opacity: 0.2;
  cursor: default;
}

#progress-dots {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(232, 213, 176, 0.25);
  border: none;
  cursor: pointer;
  padding: 0;
  transition: all 300ms ease;
}

.dot.active {
  background: var(--or);
  width: 20px;
  border-radius: 3px;
}

.dot:hover:not(.active) {
  background: rgba(232, 213, 176, 0.5);
}

/* ── Hint ────────────────────────────────────────────────────────────────────── */

#hint {
  position: absolute;
  bottom: 180px; left: 50%; transform: translateX(-50%);
  font-family: var(--typewriter);
  font-size: 0.65rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--gris-clair);
  opacity: 0.5;
  text-align: center;
  pointer-events: none;
  z-index: 10;
  transition: opacity 600ms ease;
  white-space: nowrap;
}

/* ── Loading overlay ─────────────────────────────────────────────────────────── */

#loading-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--noir);
  z-index: 50;
  transition: opacity 600ms ease;
}

#loading-overlay.fade-out { opacity: 0; pointer-events: none; }

.loading-inner {
  text-align: center;
  padding: 2rem;
}

.loading-crow {
  font-size: 3rem;
  display: block;
  margin-bottom: 2rem;
  opacity: 0.3;
  animation: float 3s ease-in-out infinite;
}

.loading-title {
  font-family: var(--serif);
  font-size: 1.1rem;
  letter-spacing: 0.15em;
  color: var(--parchemin);
  margin-bottom: 0.4rem;
}

.loading-sub {
  font-family: var(--typewriter);
  font-size: 0.7rem;
  letter-spacing: 0.25em;
  color: var(--gris-clair);
  text-transform: uppercase;
  margin-bottom: 2rem;
}

.loading-error {
  font-family: var(--serif);
  font-size: 1.1rem;
  color: var(--rouge-vif);
  margin-bottom: 0.5rem;
}

.loading-sub code {
  font-family: var(--typewriter);
  background: rgba(255,255,255,0.05);
  padding: 0.1em 0.4em;
  border-radius: 3px;
  color: var(--or);
}

#loading-bar-track {
  width: 280px;
  height: 1px;
  background: rgba(232, 213, 176, 0.1);
  margin: 0 auto 0.75rem;
  position: relative;
}

#loading-bar {
  height: 100%;
  width: 0%;
  background: var(--or);
  transition: width 200ms ease;
  box-shadow: 0 0 8px rgba(196, 144, 42, 0.6);
}

#loading-pct {
  font-family: var(--typewriter);
  font-size: 0.65rem;
  letter-spacing: 0.3em;
  color: var(--or);
  opacity: 0.7;
}

/* ════════════════════════════════════════════════════════════════════════════
   ANIMATIONS
   ════════════════════════════════════════════════════════════════════════════ */

@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes scaleX {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}

.fade-out { opacity: 0 !important; transition: opacity 400ms ease !important; }
.fade-in  { opacity: 1 !important; transition: opacity 400ms ease !important; }
.hidden   { display: none !important; }

/* ── Scrollbar ──────────────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: var(--noir); }
::-webkit-scrollbar-thumb { background: var(--gris); border-radius: 2px; }

/* ── Responsive ─────────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  #narration-panel { padding: 0 1.2rem 1.5rem; }
  #main-header { padding: 1rem 1.2rem; }
  .landing-title { font-size: clamp(3rem, 18vw, 5rem); }
  #narration-text { font-size: 0.9rem; }
  #hint { display: none; }
}

@media (min-width: 1024px) {
  /* Sur grands écrans, narration dans le coin bas-gauche */
  #narration-panel {
    left: 0; right: auto;
    max-width: 520px;
    padding: 0 2.5rem 3rem;
    background: linear-gradient(to top right,
      rgba(8,7,5,0.97) 0%,
      rgba(8,7,5,0.6)  70%,
      transparent      100%);
  }
}
