/* ============================================================
   AUDE — 18  ·  mode LIVE (grand écran)
   Photos plein écran, Ken Burns, fondu, messages overlay.
   ============================================================ */

:root {
  --paper: #f2ede4;
  --paper-shade: #ebe3d3;
  --ink: #1a1814;
  --ink-soft: #3a342c;
  --sepia: #7a6a55;
  --rust: #a8451f;
  --gold: #c9a35f;

  --serif: "Fraunces", "EB Garamond", Georgia, serif;
  --script: "Caveat", "Bradley Hand", cursive;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --xfade: 1400ms;
  --pan: 9500ms;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #000;
  color: var(--paper);
  font-family: var(--serif);
  overflow: hidden;
  cursor: none; /* présentation : pas de curseur */
}

body.live {
  position: fixed;
  inset: 0;
}

.stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  isolation: isolate;
}

/* --- frames qui se croisent --------------------------------- */

.frame {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity var(--xfade) var(--ease);
  will-change: opacity;
  overflow: hidden;
}
.frame.is-on { opacity: 1; }

.inner {
  position: absolute;
  inset: 0;
  will-change: transform;
  background-color: #0d0c0a;
  overflow: hidden;
}

/* Photo : halo flouté en fond + image contenue au premier plan (aucun crop) */
.inner--photo .inner__blur {
  position: absolute;
  inset: -8%;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  /* blur(24px) ≈ 3× moins cher que 38px à composer chaque frame avec Ken Burns */
  filter: blur(24px) saturate(0.85) brightness(0.55);
  transform: scale(1.12) translate3d(0,0,0);
  z-index: 0;
}
.inner--photo .inner__fg {
  position: absolute;
  inset: 0;
  background-position: center;
  background-size: contain;
  background-repeat: no-repeat;
  z-index: 1;
}

/* Vidéo : on garde object-fit contain pour ne rien rogner non plus */
.inner--video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #0d0c0a;
}

.frame.is-on .inner { animation: kb1 var(--pan) linear both; }
.frame.is-on .inner.kb-1 { animation-name: kb1; }
.frame.is-on .inner.kb-2 { animation-name: kb2; }
.frame.is-on .inner.kb-3 { animation-name: kb3; }
.frame.is-on .inner.kb-4 { animation-name: kb4; }

/* Vignette douce pour faire ressortir l'overlay messages */
.stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 30%, transparent 40%, rgba(0,0,0,0.35) 100%),
    linear-gradient(to bottom, transparent 55%, rgba(0,0,0,0.55) 100%);
  z-index: 2;
}

/* --- bandeau / titre marque -------------------------------- */

.brand {
  position: absolute;
  top: clamp(1rem, 2.5vw, 2rem);
  left: clamp(1rem, 2.5vw, 2.4rem);
  z-index: 6;
  display: flex;
  align-items: baseline;
  gap: 0.5em;
  color: var(--paper);
  text-shadow: 0 1px 8px rgba(0,0,0,0.5);
}
.brand__name {
  font-style: italic;
  font-variation-settings: "opsz" 144;
  font-size: clamp(1.6rem, 2.6vw, 2.4rem);
  font-weight: 400;
  letter-spacing: 0.02em;
}
.brand__num {
  font-style: italic;
  font-variation-settings: "opsz" 144;
  font-size: clamp(1.6rem, 2.6vw, 2.4rem);
  font-weight: 300;
  color: var(--gold);
  opacity: 0.9;
}
.brand::after {
  content: "·";
  margin-left: 0.5em;
  color: var(--gold);
  font-size: 0.7em;
  opacity: 0.7;
}

.sound {
  position: absolute;
  top: clamp(1rem, 2.5vw, 2rem);
  right: clamp(1rem, 2.5vw, 2.4rem);
  z-index: 6;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 50%;
  color: var(--paper);
  font-size: 1.4rem;
  cursor: pointer;
  border: none;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: background 0.2s var(--ease), transform 0.15s var(--ease);
}
.sound:hover, .sound:focus-visible { background: rgba(0, 0, 0, 0.55); }
.sound:active { transform: scale(0.94); }
.sound.is-on { background: rgba(168, 69, 31, 0.85); }

/* --- carte messages ---------------------------------------- */

.board {
  position: absolute;
  right: clamp(1rem, 2.5vw, 2.4rem);
  bottom: clamp(1rem, 3vw, 2.4rem);
  z-index: 5;
  width: clamp(22rem, 38vw, 36rem);
  background: rgba(242, 237, 228, 0.94);
  color: var(--ink);
  padding: clamp(1.3rem, 2.2vw, 2rem) clamp(1.5rem, 2.5vw, 2.4rem);
  border-radius: 2px;
  box-shadow:
    0 30px 60px -20px rgba(0,0,0,0.55),
    0 1px 0 rgba(255,255,255,0.4) inset;
  transition:
    transform 0.55s var(--ease),
    opacity 0.45s var(--ease),
    box-shadow 0.6s var(--ease);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transform-origin: bottom right;
  will-change: transform, opacity;
}

.board.is-hidden {
  transform: translateY(70px) scale(0.94);
  opacity: 0;
  pointer-events: none;
}

.board.is-new {
  animation: boardPulse 1.4s var(--ease);
}

.board.is-shout {
  background: rgba(26, 24, 20, 0.94);
  color: var(--paper);
  border-left: 4px solid var(--rust);
}
.board.is-shout .board__head { border-bottom-color: rgba(242, 237, 228, 0.22); }
.board.is-shout .board__eyebrow { color: var(--gold); }
.board.is-shout .board__text { color: var(--paper); font-size: clamp(1.9rem, 2.9vw, 3rem); }
.board.is-shout .board__sign { color: var(--gold); }
.board.is-shout .board__count { color: rgba(242, 237, 228, 0.55); border-top-color: rgba(242, 237, 228, 0.18); }

.board__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  border-bottom: 1px solid rgba(26,24,20,0.18);
  padding-bottom: 0.6rem;
  margin-bottom: 1rem;
}
.board__eyebrow {
  font-variation-settings: "opsz" 10;
  font-size: 0.78rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--sepia);
  font-variant-numeric: tabular-nums;
}
.board__pulse {
  font-variation-settings: "opsz" 10;
  font-size: 0.78rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--paper);
  background: var(--rust);
  padding: 3px 10px;
  border-radius: 1px;
  animation: dotPulse 1.4s var(--ease) infinite;
}

.board__text {
  font-family: var(--script);
  font-size: clamp(1.6rem, 2.4vw, 2.4rem);
  line-height: 1.25;
  color: var(--ink-soft);
  margin: 0 0 1rem;
  min-height: 3em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.board__sign {
  font-family: var(--script);
  font-size: clamp(1.4rem, 2vw, 2rem);
  color: var(--rust);
  margin: 0;
  line-height: 1;
}
.board__sign:empty { display: none; }
.board__sign::before {
  content: "— ";
  color: var(--sepia);
}

.board__count {
  margin: 1.2rem 0 0;
  padding-top: 0.8rem;
  border-top: 1px solid rgba(26,24,20,0.18);
  font-variation-settings: "opsz" 10;
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--sepia);
  font-variant-numeric: tabular-nums;
}

/* --- QR code (en bas à gauche) ----------------------------- */

.qr {
  position: absolute;
  left: clamp(1rem, 2.5vw, 2.4rem);
  bottom: clamp(1rem, 3vw, 2.4rem);
  z-index: 5;
  background: rgba(242, 237, 228, 0.92);
  color: var(--ink);
  padding: clamp(0.8rem, 1.3vw, 1.1rem);
  border-radius: 2px;
  box-shadow: 0 18px 40px -18px rgba(0,0,0,0.5);
  text-align: center;
}
.qr__inner { display: grid; gap: 0.4rem; place-items: center; }
.qr__label {
  font-family: var(--script);
  font-size: clamp(1.2rem, 1.8vw, 1.6rem);
  color: var(--rust);
  margin: 0;
  line-height: 1;
}
.qr img {
  display: block;
  width: clamp(110px, 11vw, 160px);
  height: auto;
  background: white;
}
.qr__url {
  font-variation-settings: "opsz" 10;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--sepia);
  margin: 0;
}
.qr__pass {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(0.85rem, 1.1vw, 1rem);
  color: var(--ink);
  margin: 0.4rem 0 0;
  padding-top: 0.4rem;
  border-top: 1px solid rgba(26, 24, 20, 0.18);
}
.qr__pass strong {
  font-family: var(--serif);
  font-weight: 600;
  font-style: normal;
  letter-spacing: 0.02em;
  color: var(--rust);
}

/* --- status (chargement) ----------------------------------- */

.status {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  color: var(--paper);
  font-family: var(--script);
  font-size: 1.2rem;
  text-shadow: 0 1px 6px rgba(0,0,0,0.6);
  margin: 0;
  opacity: 0;
  transition: opacity 0.3s var(--ease);
}
.status.is-visible { opacity: 1; }

/* ============================================================
   FONTAINE — emoji reactions live (source en haut à droite)
   ============================================================ */

.rain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
  overflow: hidden;
}

.rain__source {
  position: absolute;
  top: 6vh;
  right: 6vw;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, rgba(255, 220, 180, 0.9), rgba(168, 69, 31, 0.55) 50%, transparent 75%);
  box-shadow:
    0 0 30px 6px rgba(255, 200, 150, 0.35),
    0 0 60px 12px rgba(168, 69, 31, 0.2);
  z-index: 3;
}
.rain__source.is-emitting {
  animation: sourcePulse 360ms ease-out;
}
@keyframes sourcePulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.6); box-shadow: 0 0 50px 12px rgba(255, 200, 150, 0.6), 0 0 90px 20px rgba(168, 69, 31, 0.35); }
  100% { transform: scale(1); }
}

.rain__drop {
  position: absolute;
  font-size: clamp(2.6rem, 4.5vw, 4.8rem);
  /* text-shadow est ~5x moins cher que filter: drop-shadow */
  text-shadow:
    0 2px 6px rgba(0, 0, 0, 0.6),
    0 6px 14px rgba(0, 0, 0, 0.4);
  will-change: transform, opacity;
  user-select: none;
  pointer-events: none;
  line-height: 1;
  top: 0;
  left: 0;
  /* Force une couche compositée GPU pour éviter les re-paints */
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
}

.rain__flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9;
  background: radial-gradient(ellipse at 92% 8%,
    rgba(255, 220, 180, calc(0.45 * var(--intensity, 1))) 0%,
    rgba(168, 69, 31, calc(0.2 * var(--intensity, 1))) 30%,
    transparent 70%);
  animation: rainFlash 700ms ease-out forwards;
  mix-blend-mode: screen;
}
@keyframes rainFlash {
  0%   { opacity: 0; }
  20%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ============================================================
   Animations
   ============================================================ */

@keyframes kb1 {
  from { transform: scale(1.04) translate(-1%, -1%); }
  to   { transform: scale(1.16) translate(2%, 2%); }
}
@keyframes kb2 {
  from { transform: scale(1.16) translate(2%, -1%); }
  to   { transform: scale(1.04) translate(-2%, 2%); }
}
@keyframes kb3 {
  from { transform: scale(1.05) translate(2%, 1%); }
  to   { transform: scale(1.15) translate(-2%, -1%); }
}
@keyframes kb4 {
  from { transform: scale(1.14) translate(-1%, 2%); }
  to   { transform: scale(1.05) translate(1%, -2%); }
}

@keyframes boardPulse {
  0%   { box-shadow: 0 30px 60px -20px rgba(0,0,0,0.55); }
  30%  { box-shadow: 0 50px 90px -30px rgba(168,69,31,0.55), 0 0 0 4px rgba(168,69,31,0.18); }
  100% { box-shadow: 0 30px 60px -20px rgba(0,0,0,0.55); }
}

@keyframes dotPulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* Très petits écrans (mode preview / mobile) : on garde un layout lisible */
@media (max-width: 700px) {
  .board { width: calc(100% - 2rem); right: 1rem; left: 1rem; }
  .qr { display: none; }
}
