/* ═══════════════════════════════════════
   QR Code Controller - PC Display
   Theme: Eau / Aquatique
   ═══════════════════════════════════════ */

/* Splash overlay — gate utilisateur pour débloquer l'audio (autoplay policy) */
.splash-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(4, 10, 18, 0.85), rgba(4, 10, 18, 0.98));
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}
.splash-overlay.active {
  opacity: 1;
  pointer-events: auto;
}
.splash-content { text-align: center; user-select: none; }
.splash-title {
  font-family: 'Playfair Display', serif;
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 700;
  color: #e8f0f8;
  letter-spacing: 0.02em;
  margin-bottom: 1rem;
  opacity: 0.95;
}
.splash-text {
  font-family: 'Inter', sans-serif;
  font-size: clamp(1rem, 1.5vw, 1.2rem);
  font-weight: 300;
  color: rgba(232, 240, 248, 0.7);
  letter-spacing: 0.06em;
  margin-bottom: 2.5rem;
}
.splash-pulse {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #4ecdc4;
  margin: 0 auto;
  box-shadow: 0 0 0 0 rgba(78, 205, 196, 0.7);
  animation: splashPulse 1.6s ease-out infinite;
}
@keyframes splashPulse {
  0% { box-shadow: 0 0 0 0 rgba(78, 205, 196, 0.6); transform: scale(1); }
  70% { box-shadow: 0 0 0 30px rgba(78, 205, 196, 0); transform: scale(1.05); }
  100% { box-shadow: 0 0 0 0 rgba(78, 205, 196, 0); transform: scale(1); }
}

:root {
  --black: #040a12;
  --cream: #e8f0f8;
  --accent: #4ecdc4;
  --accent-dim: rgba(78, 205, 196, 0.3);
  --deep-blue: #0077b6;
  --white-soft: rgba(232, 240, 248, 0.8);
}

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

body {
  background: var(--black);
  color: var(--cream);
  font-family: 'Inter', sans-serif;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  cursor: none;
}

/* Background canvas — v3 : il rend une vraie texture image (warp + ripples).
   Plus de filtre opacity à 0.5 : le shader gère sa propre vignette + mood tilt. */
#bg-canvas {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  opacity: 1;
  /* Fallback CSS si WebGL2 indispo (le canvas est tagué .fallback par webgl-fx.js) */
}
#bg-canvas.fallback {
  background: radial-gradient(ellipse at center,
    rgba(20, 30, 50, 1) 0%,
    rgba(4, 10, 18, 1) 80%);
}

/* Film grain -> water caustics feel */
#grain {
  position: fixed;
  top: -50%; left: -50%;
  width: 200%; height: 200%;
  z-index: 1;
  pointer-events: none;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.6' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
  animation: grain 0.8s steps(1) infinite;
}

@keyframes grain {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-5%, -10%); }
  20% { transform: translate(-15%, 5%); }
  30% { transform: translate(7%, -25%); }
  40% { transform: translate(-5%, 25%); }
  50% { transform: translate(-15%, 10%); }
  60% { transform: translate(15%, 0%); }
  70% { transform: translate(0%, 15%); }
  80% { transform: translate(3%, 35%); }
  90% { transform: translate(-10%, 10%); }
}

/* Screens */
.screen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
}

/* ── Screen 0: QR Code ── */
.qr-container {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.title {
  font-family: 'Playfair Display', serif;
  font-size: 3.5rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--cream);
}

.subtitle {
  font-size: 1.1rem;
  font-weight: 300;
  color: var(--white-soft);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

#qr-wrapper {
  position: relative;
  padding: 2rem;
  margin: 1rem 0;
}

#qr-wrapper::before {
  content: '';
  position: absolute;
  inset: 0;
  border: 1px solid var(--accent-dim);
  border-radius: 1rem;
  animation: qr-pulse 3s ease-in-out infinite;
}

@keyframes qr-pulse {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.02); }
}

#qr-image {
  width: 280px;
  height: 280px;
  border-radius: 0.5rem;
}

.hint {
  font-size: 0.8rem;
  color: rgba(232, 240, 248, 0.3);
  font-family: 'Inter', monospace;
  font-weight: 300;
}

/* ── Screen labels ── */
.screen-label {
  position: fixed;
  top: 2rem;
  left: 2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 300;
  color: var(--white-soft);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  z-index: 10;
}

.label-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  animation: dot-pulse 2s ease-in-out infinite;
}

@keyframes dot-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* ── Canvases v2 (désactivés en v3) ──
   Les écrans buttons et touch passent maintenant par le bg WebGL.
   Les canvases dédiés sont conservés en HTML pour back-compat mais cachés. */
#buttons-canvas,
#touch-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: none;
}

/* ── Screen 4: Gyro (v3 — hyperzoom gigapixel) ── */
#gyro-container {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}
#gyro-container.gyro-gigapixel {
  background: #040a12;
}
#gyro-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
}

/* Overlay info card (titre + auteur + hint d'inclinaison) */
#gyro-info-overlay {
  position: absolute;
  bottom: 6vh;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  opacity: 0;
  transition: opacity 0.8s ease;
  pointer-events: none;
}
#gyro-info-overlay.visible {
  opacity: 1;
}
.gyro-info-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 1rem 2rem;
  background: rgba(4, 10, 18, 0.65);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(232, 240, 248, 0.12);
  border-radius: 0.5rem;
  text-align: center;
}
.gyro-info-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem;
  color: var(--cream);
  letter-spacing: 0.03em;
}
.gyro-info-author {
  font-size: 0.85rem;
  color: rgba(232, 240, 248, 0.6);
  letter-spacing: 0.05em;
}
.gyro-info-hint {
  font-size: 0.75rem;
  font-weight: 300;
  color: var(--accent);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 0.3rem;
}

/* ── Screen 2 (v4): Galerie 3D ── */
#gallery-container {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
}
#gallery-container.gallery-active {
  background: #06080d;
}
#gallery-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.gallery-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(232, 240, 248, 0.5);
  font-size: 1.1rem;
}
#gallery-title-overlay {
  position: absolute;
  bottom: 5vh;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  z-index: 5;
  opacity: 0;
  transition: opacity 0.5s ease, transform 0.5s ease;
  pointer-events: none;
}
#gallery-title-overlay.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.gallery-title-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.9rem 2rem;
  background: rgba(4, 10, 18, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(232, 220, 180, 0.2);
  border-radius: 0.4rem;
  text-align: center;
  min-width: 320px;
}
.gallery-title-author {
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(232, 220, 180, 0.85);
}
.gallery-title-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.35rem;
  font-style: italic;
  color: var(--cream);
}
.gallery-title-year {
  font-size: 0.75rem;
  color: rgba(232, 240, 248, 0.55);
  letter-spacing: 0.1em;
}
#gallery-hint-overlay {
  position: absolute;
  top: 6vh;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  opacity: 0;
  transition: opacity 0.6s ease;
  pointer-events: none;
  padding: 0.55rem 1.2rem;
  background: rgba(4, 10, 18, 0.55);
  border: 1px solid rgba(78, 205, 196, 0.18);
  border-radius: 1.5rem;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  color: rgba(232, 240, 248, 0.7);
}
#gallery-hint-overlay.visible {
  opacity: 1;
}

/* ── Screen 3 (v4): Coloriage ── */
#coloring-container {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  background: #f5ecd8; /* fond crème (papier) */
}
#coloring-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
#coloring-info {
  position: absolute;
  bottom: 4vh;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  padding: 0.6rem 1.4rem;
  background: rgba(4, 10, 18, 0.7);
  backdrop-filter: blur(10px);
  border-radius: 0.35rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s ease;
}
#coloring-info.visible {
  opacity: 1;
}
.coloring-info-title {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  font-style: italic;
  color: var(--cream);
}
.coloring-info-author {
  font-size: 0.7rem;
  color: rgba(232, 220, 180, 0.7);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
#coloring-progress {
  position: absolute;
  top: 6vh;
  right: 4vw;
  z-index: 5;
  font-size: 0.85rem;
  color: rgba(232, 240, 248, 0.6);
  background: rgba(4, 10, 18, 0.4);
  padding: 0.4rem 0.9rem;
  border-radius: 1rem;
  letter-spacing: 0.1em;
  font-family: 'Inter', sans-serif;
}

/* ── Screen 4: Goodbye ── */
.goodbye-container {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

/* ── Ambient vignette ── */
body::after {
  content: '';
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(4,10,18,0.7) 100%);
  pointer-events: none;
  z-index: 1;
}

/* ═══════════════════════════════════════
   Responsive — host page utilisable depuis mobile
   (PC desktop reste intact ; tout passe par @media breakpoints)
   ═══════════════════════════════════════ */

/* Sur device sans hover (touch screens), restaurer le curseur */
@media (hover: none) and (pointer: coarse) {
  body { cursor: auto; }
}

/* Tablette + mobile portrait */
@media (max-width: 768px) {
  .qr-container { gap: 1rem; padding: 0 1rem; }
  .title { font-size: clamp(1.8rem, 8vw, 2.6rem); }
  .subtitle { font-size: clamp(0.85rem, 3vw, 1rem); letter-spacing: 0.1em; }
  #qr-wrapper { padding: 1rem; margin: 0.5rem 0; }
  #qr-image {
    width: clamp(200px, 65vw, 280px);
    height: clamp(200px, 65vw, 280px);
  }
  .hint { font-size: 0.7rem; word-break: break-all; max-width: 90vw; }

  .screen-label {
    top: 0.8rem;
    left: 0.8rem;
    font-size: 0.65rem;
  }

  /* Gallery overlay : la carte titre déborderait à 320px sur petit écran */
  .gallery-title-card {
    min-width: 0;
    max-width: 90vw;
    padding: 0.7rem 1.2rem;
  }
  .gallery-title-title { font-size: 1.05rem; }
  .gallery-title-author { font-size: 0.7rem; }
  #gallery-hint-overlay {
    top: 1.5vh;
    font-size: 0.7rem;
    padding: 0.4rem 0.9rem;
    max-width: 90vw;
    text-align: center;
  }

  /* Gyro overlay */
  .gyro-info-card { padding: 0.7rem 1.2rem; max-width: 90vw; }
  .gyro-info-title { font-size: 1.05rem; }
  .gyro-info-author { font-size: 0.75rem; }
  .gyro-info-hint { font-size: 0.65rem; }
  #gyro-info-overlay { bottom: 3vh; }

  /* Coloring overlays */
  #coloring-progress {
    top: 1rem;
    right: 1rem;
    font-size: 0.7rem;
    padding: 0.3rem 0.7rem;
  }
  #coloring-info { bottom: 2vh; padding: 0.5rem 1rem; }
  .coloring-info-title { font-size: 0.95rem; }
  .coloring-info-author { font-size: 0.6rem; }

  .goodbye-container { gap: 0.5rem; padding: 0 1rem; }
}

/* Mobile portrait étroit */
@media (max-width: 480px) {
  .splash-text { padding: 0 1rem; }
  #qr-image {
    width: clamp(180px, 70vw, 240px);
    height: clamp(180px, 70vw, 240px);
  }
  /* Sur très petit écran, le shader bg peut paraître délavé.
     On réduit son opacity pour augmenter le contraste avec le contenu. */
  #bg-canvas { opacity: 0.55; }
}

/* Mobile paysage (téléphone tourné) — viewports ~600-900 × ~330-450 */
@media (orientation: landscape) and (max-height: 500px) {
  .qr-container { gap: 0.4rem; padding: 0.5rem 1rem; }
  .title { font-size: clamp(1.2rem, 5vh, 1.8rem); }
  .subtitle { font-size: clamp(0.65rem, 2vh, 0.85rem); letter-spacing: 0.1em; }
  #qr-wrapper { padding: 0.4rem; margin: 0; }
  #qr-image {
    width: clamp(120px, 40vh, 180px);
    height: clamp(120px, 40vh, 180px);
  }
  .hint { font-size: 0.6rem; }
  .screen-label { font-size: 0.55rem; top: 0.5rem; left: 0.5rem; }
}
