/* Le Sacré Oui — palette du faire-part */
:root {
  --foret: #26493f;
  --foret-2: #1d3a32;
  --foret-3: #2f564b;
  --soleil: #f6ce1f;
  --creme: #f4e7cd;
  --sauge: #a7ae98;
  --sauge-fonce: #8f9a85;
  --encre: #f4e7cd;
  --muted: rgba(244, 231, 205, .68);
  --line: rgba(244, 231, 205, .16);
  --danger: #e8836b;
  --ok: #9fc28a;
  --radius: 14px;
  --display: "League Spartan", "Arial Black", system-ui, sans-serif;
  --script: "Cedarville Cursive", "Brush Script MT", cursive;
  --body: "League Spartan", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--foret);
  color: var(--encre);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.45;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--soleil); }
button { font-family: inherit; cursor: pointer; }
.hidden { display: none !important; }

.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px; }

/* ---------- Titres façon affiche ---------- */
.affiche-titre {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(40px, 12vw, 72px);
  line-height: 1;
  letter-spacing: .01em;
  text-transform: uppercase;
  display: flex; align-items: baseline; justify-content: center; gap: .18em;
  flex-wrap: nowrap;
}
.affiche-titre em {
  font-family: var(--script);
  font-style: normal; font-weight: 400;
  text-transform: none;
  font-size: 1.05em;
  transform: translateY(.06em) rotate(-3deg);
  display: inline-block;
}
.script { font-family: var(--script); font-weight: 400; }
.couple { font-family: var(--script); color: var(--soleil); font-size: clamp(30px, 9vw, 46px); }

/* ---------- Écran code d'accès ---------- */
#gate {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 22px;
  padding: 32px 20px; text-align: center;
}
#gate img { width: min(260px, 64vw); border-radius: 8px; }
#gate form { display: flex; gap: 8px; width: min(340px, 100%); }
#gate input {
  flex: 1; min-width: 0; height: 52px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--foret-2); color: var(--encre); padding: 0 16px;
  font: 600 20px var(--body); letter-spacing: .12em; text-transform: uppercase; text-align: center;
}
#gate button, .btn {
  height: 52px; padding: 0 20px; border-radius: 12px; border: 0;
  background: var(--soleil); color: var(--foret-2); font-weight: 700; font-size: 17px;
}
#gate .hint { color: var(--muted); font-size: 15px; max-width: 22em; }
#gate .err { color: var(--danger); min-height: 1.4em; font-size: 15px; }

/* ---------- Bandeau annonce ---------- */
#annonce {
  position: sticky; top: 0; z-index: 30;
  background: var(--soleil); color: var(--foret-2);
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
  display: flex; gap: 12px; align-items: flex-start;
  box-shadow: 0 4px 18px rgba(0,0,0,.25);
  animation: tombe .45s ease;
}
#annonce .txt { flex: 1; font-weight: 600; font-size: 16px; }
#annonce .txt small { display: block; font-weight: 500; opacity: .7; font-size: 13px; }
#annonce button { background: none; border: 0; font-size: 22px; line-height: 1; color: inherit; padding: 2px 4px; }
@keyframes tombe { from { transform: translateY(-100%); } to { transform: none; } }

/* ---------- Accueil ---------- */
.hero { text-align: center; padding: calc(env(safe-area-inset-top) + 36px) 0 8px; }
.hero .date { font-family: var(--script); font-size: clamp(22px, 6.5vw, 30px); margin-top: 10px; }
.hero .couple { margin-top: 14px; }
.hero img { display: block; width: 100%; max-width: 520px; margin: 18px auto 0; }

/* ---------- Programme ---------- */
section { padding: 28px 0 8px; }
.section-titre {
  font-family: var(--display); font-weight: 800; text-transform: uppercase;
  font-size: 20px; letter-spacing: .06em; text-align: center;
  background: var(--sauge-fonce); color: var(--creme);
  border-radius: var(--radius) var(--radius) 0 0; padding: 12px 16px 9px;
}
.carte {
  background: var(--creme); color: var(--foret-2);
  border: 6px solid var(--sauge-fonce); border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 8px 18px 14px;
}
/* QR de partage (fin du programme) */
.partage { text-align: center; padding: 18px 18px 16px; }
.partage .qr { width: min(220px, 62vw); aspect-ratio: 1; display: block; margin: 0 auto 10px; }
.partage p { font-size: 15px; line-height: 1.4; }

.jour { font-family: var(--script); font-size: 26px; margin: 14px 0 4px; }
.etapes { list-style: none; }
.etape {
  display: grid; grid-template-columns: 62px 1fr; gap: 12px;
  padding: 11px 0; border-bottom: 1px dashed rgba(29,58,50,.18);
}
.etape:last-child { border-bottom: 0; }
.etape .h { font-weight: 800; font-size: 18px; font-variant-numeric: tabular-nums; }
.etape .t { font-weight: 700; font-size: 18px; line-height: 1.2; }
.etape .n { font-size: 15px; opacity: .78; margin-top: 2px; }
.etape .l { font-size: 14px; margin-top: 3px; }
.etape .l a { color: var(--foret-3); }
.etape.passee { opacity: .45; }
.etape.encours { background: rgba(246,206,31,.35); margin: 0 -10px; padding: 11px 10px; border-radius: 10px; border-bottom-color: transparent; }
.etape.encours .t::after {
  content: "en ce moment"; margin-left: 8px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; background: var(--foret-2); color: var(--soleil);
  padding: 2px 6px 1px; border-radius: 6px; vertical-align: 2px;
}

.lieu { padding: 12px 0; border-bottom: 1px dashed rgba(29,58,50,.18); }
.lieu:last-child { border-bottom: 0; }
.lieu b { display: block; font-size: 18px; }
.lieu .adr { font-family: var(--script); font-size: 19px; }
.lieu a { font-size: 14px; color: var(--foret-3); }

footer { text-align: center; color: var(--muted); font-size: 13px; padding: 28px 16px calc(env(safe-area-inset-bottom) + 28px); }
#dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); margin-right: 6px; vertical-align: 1px; }
#dot.ok { background: var(--ok); }

/* ---------- Scène plein écran (teasing / discours) ---------- */
#scene {
  position: fixed; inset: 0; z-index: 50; background: #0f1e1a;
  display: flex; align-items: center; justify-content: center;
}
#scene.carton-on { background: var(--foret); }
#scene .photos img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: contain; opacity: 0; transition: opacity .7s ease;
  /* --z : zoom par défaut ; --u, --x, --y : loupe de l'invité (invites.js) */
  transform: translate(var(--x, 0px), var(--y, 0px)) scale(calc(var(--z, 1) * var(--u, 1)));
}
#scene .photos { position: absolute; inset: 0; overflow: hidden; touch-action: none; }
#scene .photos img.on { opacity: 1; }
#scene.teasing .photos img.on { animation: zoom 9s ease-out forwards; }
@keyframes zoom { from { transform: scale(var(--z, 1)); } to { transform: scale(calc(var(--z, 1) * 1.06)); } }

/* commandes masquées quand on ne touche plus l'écran (l'annonce reste visible) */
#scene .fermer { transition: opacity .5s; }
#scene.calme .fermer { opacity: 0; pointer-events: none; }

#scene .carton {
  position: relative; z-index: 2; text-align: center; padding: 24px; max-width: 30em;
  transition: opacity .6s;
}
#scene .carton img { width: min(230px, 56vw); opacity: .9; }
#scene .carton .k { font-family: var(--display); font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--sauge); font-size: 14px; margin-top: 18px; }
#scene .carton .titre { font-family: var(--script); font-size: clamp(32px, 9vw, 52px); line-height: 1.15; margin-top: 6px; }
#scene .carton .qui { color: var(--soleil); font-size: 18px; margin-top: 8px; font-weight: 600; }
#scene .carton .prep { color: var(--muted); font-size: 14px; margin-top: 20px; }

#scene .bandeau-teasing {
  position: absolute; z-index: 3; left: 0; right: 0; bottom: 0;
  padding: 40px 20px calc(env(safe-area-inset-bottom) + 22px);
  background: linear-gradient(transparent, rgba(15,30,26,.92));
  text-align: center;
}
#scene .bandeau-teasing { display: flex; align-items: center; justify-content: center; gap: 16px; }
#scene .bandeau-teasing .qr { width: 104px; aspect-ratio: 1; border-radius: 8px; flex: none; }
#scene .bandeau-teasing .script { font-size: 30px; }
#scene .bandeau-teasing small { display: block; color: var(--muted); font-size: 14px; margin-top: 4px; }

#scene .fermer {
  position: absolute; z-index: 4; top: calc(env(safe-area-inset-top) + 10px); left: 12px;
  background: rgba(15,30,26,.6); color: var(--creme); border: 1px solid var(--line);
  border-radius: 20px; padding: 7px 12px 5px; font-size: 13px; font-weight: 600;
}
#scene .annonce-mini {
  position: absolute; z-index: 4; top: calc(env(safe-area-inset-top) + 10px); right: 12px; left: 136px;
  background: var(--soleil); color: var(--foret-2); border-radius: 12px; padding: 7px 12px 5px;
  font-size: 13px; font-weight: 600; text-align: right;
}
/* paysage sur téléphone : carton titre à l'horizontale pour tenir en hauteur */
@media (orientation: landscape) and (max-height: 500px) {
  #scene .carton { display: grid; grid-template-columns: auto 1fr; column-gap: 24px; align-items: center; text-align: left; max-width: 44em; }
  #scene .carton img { grid-row: 1 / 5; width: min(160px, 26vw); }
  #scene .carton .k { margin-top: 0; }
  #scene .carton .titre { font-size: clamp(28px, 6vh, 44px); }
  #scene .bandeau-teasing { padding: 24px 20px calc(env(safe-area-inset-bottom) + 12px); }
  #scene .bandeau-teasing .script { font-size: 24px; }
  #scene .bandeau-teasing .qr { width: 84px; }
}

#retour-scene {
  position: fixed; z-index: 40; left: 50%; transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom) + 16px);
  background: var(--soleil); color: var(--foret-2); border: 0; border-radius: 26px;
  padding: 13px 22px 11px; font-weight: 700; font-size: 16px; box-shadow: 0 6px 24px rgba(0,0,0,.35);
}

/* ---------- Télécommande (orateur / régie) ---------- */
.panel { background: var(--foret-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-top: 14px; }
.panel h2 { font-family: var(--display); font-size: 15px; text-transform: uppercase; letter-spacing: .08em; color: var(--sauge); margin-bottom: 10px; }
.apercu { position: relative; aspect-ratio: 3 / 2; background: #0f1e1a; border-radius: 10px; overflow: hidden; display: flex; align-items: center; justify-content: center; text-align: center; color: var(--muted); font-size: 15px; padding: 12px; }
.apercu img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.strip { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0 2px; scrollbar-width: none; }
.strip::-webkit-scrollbar { display: none; }
.strip button { flex: 0 0 auto; width: 54px; height: 54px; border-radius: 8px; border: 2px solid transparent; background: #0f1e1a center/cover; color: var(--muted); font-size: 11px; font-weight: 600; }
.strip button.cur { border-color: var(--soleil); }
.strip button.attente { width: 68px; }
.nav { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; margin-top: 12px; }
.nav button { height: 76px; border-radius: 16px; border: 1px solid var(--line); background: var(--foret-3); color: var(--creme); font-size: 30px; }
.nav button.suiv { background: var(--soleil); color: var(--foret-2); border: 0; }
.nav button:disabled { opacity: .35; }
.meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 14px; margin-top: 10px; }
.meta b { color: var(--creme); }
.msg { margin-top: 10px; font-size: 14px; color: var(--danger); min-height: 1.2em; }

.phases { display: grid; gap: 8px; }
.phases button {
  min-height: 52px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--foret-3); color: var(--creme); font-size: 16px; font-weight: 600;
  text-align: left; padding: 10px 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.phases button small { color: var(--muted); font-weight: 500; font-size: 13px; }
.phases button.actif { background: var(--soleil); color: var(--foret-2); border-color: transparent; }
.phases button.actif small { color: var(--foret-2); opacity: .7; }

textarea, .champ {
  width: 100%; border-radius: 10px; border: 1px solid var(--line); background: #0f1e1a; color: var(--creme);
  font: 16px var(--body); padding: 10px 12px;
}
textarea { min-height: 76px; resize: vertical; }
.ligne { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.btn.sec { background: var(--foret-3); color: var(--creme); border: 1px solid var(--line); }
.btn.petit { height: 40px; padding: 0 14px; font-size: 15px; border-radius: 10px; }

.edit-jour { margin-top: 14px; }
.edit-jour h3 { font-family: var(--script); font-weight: 400; font-size: 24px; }
.edit-etape { display: grid; grid-template-columns: 78px 1fr; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.edit-etape .champ { padding: 8px 10px; font-size: 15px; }
.edit-etape .actions { grid-column: 1 / -1; display: flex; gap: 6px; flex-wrap: wrap; }
.edit-etape .actions button { height: 34px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--foret-3); color: var(--creme); font-size: 13px; }
.etat-edit { font-size: 14px; color: var(--muted); margin-top: 8px; }
.etat-edit.dirty { color: var(--soleil); }
