/* ==========================================================================
   Accueil — vidéo plein cadre, format d’origine préservé (aucun recadrage)
   ========================================================================== */
.site { position: relative; z-index: 1; }

.welcome {
  --controls-h: 64px;
  position: relative;
  min-height: var(--vh);
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(120% 70% at 50% 45%, #fde8d0 0%, var(--video-backdrop) 55%, #f6d6b6 120%);
  overflow: hidden;
}
/* grain léger assorti au papier de la vidéo */
.welcome::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--grain);
  background-size: 220px 220px;
  opacity: 0.6;
  pointer-events: none;
}

.welcome__stage {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-top) + 12px) 12px 0;
  transform-origin: 50% 45%;
  will-change: transform;
}

.welcome__frame {
  position: relative;
  aspect-ratio: var(--video-ratio, 16 / 9);
  /* le plus grand rectangle 16:9 qui tient entièrement à l’écran */
  width: min(100%, calc((var(--vh) - var(--controls-h) - var(--safe-bottom) - 24px) * 16 / 9));
  max-height: calc(var(--vh) - var(--controls-h) - var(--safe-bottom) - 24px);
  border-radius: 3px;
  overflow: hidden;
  background: var(--video-backdrop);
  box-shadow:
    0 1px 2px rgba(110, 60, 30, 0.12),
    0 14px 40px -12px rgba(110, 60, 30, 0.3);
}

.welcome__video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain; /* jamais de recadrage */
  background: var(--video-backdrop);
}

/* Bouton de lecture si l’autoplay est bloqué */
.welcome__play {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 74px;
  height: 74px;
  margin: -37px 0 0 -37px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(253, 246, 236, 0.78);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: 0 0 0 1px rgba(158, 58, 50, 0.35), 0 10px 30px -8px rgba(110, 50, 30, 0.45);
  color: var(--accent);
  transition: transform 0.3s ease, background 0.3s ease;
  animation: soft-in 0.6s ease both;
}
.welcome__play svg { width: 34px; height: 34px; fill: currentColor; margin-left: 4px; }
.welcome__play:hover { transform: scale(1.05); background: rgba(253, 246, 236, 0.92); }

/* Barre de commandes discrète */
.welcome__controls {
  position: relative;
  height: calc(var(--controls-h) + var(--safe-bottom));
  padding: 0 16px var(--safe-bottom);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: opacity 0.8s ease 0.2s;
}
html.is-sealed .welcome__controls,
html.is-opening .welcome__controls { opacity: 0; pointer-events: none; }

.welcome__buttons { display: flex; gap: 10px; }

.ctrl {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1rem;
  letter-spacing: 0.02em;
  color: var(--accent);
  background: rgba(255, 249, 240, 0.55);
  box-shadow: inset 0 0 0 1px rgba(158, 58, 50, 0.28);
  transition: background 0.25s ease, box-shadow 0.25s ease;
}
.ctrl:hover { background: rgba(255, 249, 240, 0.9); box-shadow: inset 0 0 0 1px rgba(158, 58, 50, 0.5); }
.ctrl--icon {
  width: 40px;
  padding: 0;
  display: grid;
  place-items: center;
}
.ctrl svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.ctrl__on, .ctrl__off { display: grid; place-items: center; }
.ctrl[aria-pressed='true'] .ctrl__off,
.ctrl[aria-pressed='false'] .ctrl__on { display: none; }
.ctrl.is-ended { animation: nudge 2.4s ease-in-out infinite; }

@keyframes soft-in { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }
@keyframes nudge {
  0%, 100% { box-shadow: inset 0 0 0 1px rgba(158, 58, 50, 0.28); }
  50% { box-shadow: inset 0 0 0 1px rgba(158, 58, 50, 0.7), 0 0 0 4px rgba(158, 58, 50, 0.08); }
}

/* Ordinateur : un peu plus d’air autour de la vidéo */
@media (min-width: 900px) {
  .welcome { --controls-h: 76px; }
  .welcome__stage { padding: calc(var(--safe-top) + 28px) 40px 0; }
  .welcome__frame {
    width: min(100%, 1280px, calc((var(--vh) - var(--controls-h) - 56px) * 16 / 9));
    max-height: calc(var(--vh) - var(--controls-h) - 56px);
  }
  .welcome__controls { padding: 0 32px; }
}

/* Téléphone à l’horizontale : la vidéo prend toute la hauteur */
@media (max-height: 500px) and (orientation: landscape) {
  .welcome { --controls-h: 0px; }
  .welcome__stage { padding: 6px 64px; }
  .welcome__controls {
    position: absolute;
    inset: 0;
    height: auto;
    padding: 10px;
    pointer-events: none;
    flex-direction: column;
    align-items: flex-end;
    justify-content: space-between;
  }
  .welcome__controls > * { pointer-events: auto; }
  .welcome__buttons { flex-direction: column; }
  .ctrl[data-replay-envelope] { font-size: 0.85rem; padding: 0 10px; }
}

/* ==========================================================================
   Fondu de fin de vidéo → site (harmonisation avec l’ivoire)
   ========================================================================== */
/* Dégradé de raccord en bas de l’accueil : pêche de la vidéo → ivoire du site */
.welcome::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 22%;
  background: linear-gradient(to bottom, rgba(250, 246, 238, 0), var(--ivory));
  pointer-events: none;
}
/* Voile ivoire qui recouvre progressivement la scène à la fin de la vidéo */
.welcome__veil {
  position: absolute;
  inset: 0;
  z-index: 2;
  background:
    radial-gradient(70% 55% at 50% 45%, rgba(250, 246, 238, 0.82), var(--ivory) 75%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.6s ease;
}
.welcome__frame,
.welcome__stage { transition: transform 1.8s var(--ease-out, ease), filter 1.6s ease, opacity 1.6s ease; }
.welcome.is-ended .welcome__veil { opacity: 1; }
.welcome.is-ended .welcome__frame { transform: scale(0.985); filter: saturate(0.85); }
/* Les commandes restent accessibles au-dessus du voile (« Rejouer ») */
.welcome__controls { z-index: 3; }
.welcome.is-ended .welcome__controls .ctrl { background: rgba(255, 253, 248, 0.9); }
/* Indication discrète pour défiler, après le fondu */
.welcome__scroll {
  position: absolute;
  left: 50%;
  bottom: calc(var(--controls-h) + var(--safe-bottom) + 10px);
  z-index: 3;
  transform: translate(-50%, 8px);
  display: grid;
  justify-items: center;
  gap: 6px;
  color: var(--olive);
  text-decoration: none;
  font-size: 0.7rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.9s ease 0.6s, transform 0.9s ease 0.6s;
}
.welcome__scroll svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.4; animation: scroll-hint 2s ease-in-out infinite; }
.welcome.is-ended .welcome__scroll { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
@keyframes scroll-hint { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(4px); } }
@media (max-height: 500px) and (orientation: landscape) {
  .welcome__scroll { bottom: 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .welcome__veil, .welcome__frame, .welcome__stage { transition-duration: 0.01s; }
  .welcome__scroll svg { animation: none; }
}

/* Tant que l’enveloppe n’a pas déposé la carte, la vidéo reste invisible :
   la carte (même image) prend sa place puis lui passe le relais. */
html.is-sealed .welcome__stage,
html.is-opening:not(.is-landed) .welcome__stage { visibility: hidden; }
