/* ================= Momento Scanner ================= */
@font-face { font-family: 'Great Vibes'; src: url(../fonts/greatvibes.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Playfair Display'; font-weight: 400; src: url(../fonts/playfair-display-latin-400-normal.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Playfair Display'; font-weight: 600; src: url(../fonts/playfair-display-latin-600-normal.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Cormorant Garamond'; font-weight: 400; src: url(../fonts/cormorant-garamond-latin-400-normal.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Cormorant Garamond'; font-weight: 600; src: url(../fonts/cormorant-garamond-latin-600-normal.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Montserrat'; font-weight: 400; src: url(../fonts/montserrat-latin-400-normal.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Montserrat'; font-weight: 500; src: url(../fonts/montserrat-latin-500-normal.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Montserrat'; font-weight: 600; src: url(../fonts/montserrat-latin-600-normal.woff2) format('woff2'); font-display: swap; }
@font-face { font-family: 'Montserrat'; font-weight: 700; src: url(../fonts/montserrat-latin-700-normal.woff2) format('woff2'); font-display: swap; }

:root {
  --choco: #2a1910;
  --choco-2: #3d2618;
  --cream: #f7ede2;
  --cream-dim: rgba(247, 237, 226, .72);
  --accent: #c9925f;
  --ok: #3fae6a;
  --danger: #e0473c;
  --warn: #e8932f;
  --glass: rgba(255, 248, 240, .14);
  --glass-strong: rgba(255, 248, 240, .22);
  --glass-border: rgba(255, 240, 225, .32);
  --radius: 20px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Montserrat', system-ui, sans-serif; color: var(--cream);
  background: var(--choco); overflow: hidden; -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
input { font: inherit; }
[hidden] { display: none !important; }

/* ---------- Fond (photo de l'administrateur) ---------- */
.bg {
  position: fixed; inset: 0; background: radial-gradient(120% 80% at 50% 0%, #5a3a26 0%, var(--choco) 70%);
  background-size: cover; background-position: center; transform: scale(1.02);
}
.bg::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(20, 11, 6, .30) 0%, rgba(20, 11, 6, .45) 45%, rgba(20, 11, 6, .78) 100%);
}

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .22), inset 0 1px 0 rgba(255, 255, 255, .18);
}

/* ---------- Animation d'ouverture ---------- */
#splash {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  background: radial-gradient(90% 60% at 50% 45%, #4a2e1d 0%, #1e110a 75%);
  transition: opacity .55s ease, visibility .55s;
}
#splash.out { opacity: 0; visibility: hidden; }
.splash-logo { position: relative; width: min(56vw, 240px); aspect-ratio: 1; border-radius: 50%;
  animation: logoIn 1s cubic-bezier(.2, .9, .25, 1.15) both; box-shadow: 0 20px 60px rgba(0, 0, 0, .55); overflow: hidden; }
.splash-logo img { width: 100%; height: 100%; display: block; }
.splash-logo::after {
  content: ''; position: absolute; inset: -20%;
  background: linear-gradient(115deg, transparent 35%, rgba(255, 228, 190, .65) 50%, transparent 65%);
  transform: translateX(-120%); animation: shine 1s .75s ease-in-out forwards; mix-blend-mode: overlay;
}
.splash-glow { position: absolute; width: min(70vw, 320px); aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle, rgba(214, 150, 95, .35), transparent 65%); animation: glow 1.8s ease-out both; }
#splash.out .splash-logo { transform: translateY(-30vh) scale(.35); transition: transform .55s ease-in; }
@keyframes logoIn { from { opacity: 0; transform: scale(.55) rotate(-8deg); filter: blur(6px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes shine { to { transform: translateX(120%); } }
@keyframes glow { 0% { opacity: 0; transform: scale(.6); } 60% { opacity: 1; } 100% { opacity: .7; transform: scale(1.1); } }

/* ---------- Accueil ---------- */
#home { position: fixed; inset: 0; display: flex; flex-direction: column; padding: calc(18px + var(--safe-t)) 18px calc(12px + var(--safe-b)); }
.top { display: flex; align-items: center; gap: 12px; }
.top .mini-logo { width: 42px; height: 42px; border-radius: 50%; box-shadow: 0 4px 14px rgba(0, 0, 0, .4); }
.top .titles { flex: 1; min-width: 0; }
.top h1 { margin: 0; font-family: 'Playfair Display', serif; font-weight: 600; font-size: 1.15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .date { font-size: .95rem; line-height: 1.2; opacity: .95; }
.icon-btn { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; }

.hero { flex: 0 0 auto; display: flex; flex-direction: column; gap: 14px; margin-top: auto; padding-top: 18px; transition: margin .3s ease; }
#home.searching .hero { margin-top: 18px; }
#home.searching .wedding-logo-home { display: none; }
.wedding-logo-home { width: min(44vw, 190px); align-self: center; margin-bottom: auto; filter: drop-shadow(0 8px 24px rgba(0,0,0,.45)); }
.center-wrap { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; min-height: 0; }
#home.searching .center-wrap { display: none; }

.btn-scan {
  display: flex; align-items: center; justify-content: center; gap: 14px; width: 100%;
  padding: 22px 18px; font-size: 1.15rem; font-weight: 600; letter-spacing: .02em;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 55%, transparent), rgba(255, 248, 240, .12));
}
.btn-scan svg { width: 30px; height: 30px; }
.btn-scan:active { transform: scale(.98); }

.search { display: flex; align-items: center; gap: 10px; padding: 0 16px; height: 58px; }
.search svg { width: 22px; height: 22px; flex: 0 0 auto; opacity: .85; }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--cream); font-size: 1.05rem; height: 100%; }
.search input::-webkit-search-cancel-button { display: none; -webkit-appearance: none; }
.search input::placeholder { color: var(--cream-dim); }
.search .clear { width: 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,.18); font-size: 1rem; }

.results { flex: 1 1 auto; overflow-y: auto; margin-top: 12px; padding: 4px; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.results:empty { display: none; }
.res { display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-align: left; border-radius: 16px; }
.res .who { flex: 1; min-width: 0; }
.res .n { font-weight: 600; font-size: 1.02rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res .s { font-size: .8rem; color: var(--cream-dim); margin-top: 2px; }
.badge { font-size: .72rem; font-weight: 700; padding: 5px 9px; border-radius: 999px; white-space: nowrap; }
.badge.ok { background: rgba(63, 174, 106, .9); color: #fff; }
.badge.wait { background: rgba(255, 255, 255, .2); }
.empty { text-align: center; padding: 18px; color: var(--cream-dim); font-size: .95rem; }

.statusbar { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding: 10px 14px; font-size: .8rem; border-radius: 14px; }
.statusbar .dev { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.statusbar .net { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(63, 174, 106, .25); }
.dot.off { background: var(--warn); box-shadow: 0 0 0 3px rgba(232, 147, 47, .25); }
.count { font-weight: 700; padding-left: 10px; border-left: 1px solid var(--glass-border); }

/* ---------- Scanner caméra ---------- */
#scanner { position: fixed; inset: 0; z-index: 20; background: #000; }
#scanner video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.frame { position: absolute; left: 50%; top: 46%; width: min(72vw, 330px); aspect-ratio: 1; transform: translate(-50%, -50%);
  border-radius: 28px; box-shadow: 0 0 0 100vmax rgba(10, 5, 2, .55); }
.frame::before { content: ''; position: absolute; inset: 0; border-radius: 28px; border: 3px solid var(--accent); opacity: .9; }
.laser { position: absolute; left: 8%; right: 8%; height: 2px; top: 10%; background: linear-gradient(90deg, transparent, var(--accent), transparent);
  box-shadow: 0 0 12px var(--accent); animation: laser 2s ease-in-out infinite alternate; }
@keyframes laser { to { top: 90%; } }
.scan-top { position: absolute; top: calc(14px + var(--safe-t)); left: 14px; right: 14px; display: flex; justify-content: space-between; align-items: center; z-index: 2; }
.scan-hint { position: absolute; left: 0; right: 0; bottom: calc(110px + var(--safe-b)); text-align: center; font-size: .95rem; color: var(--cream); text-shadow: 0 2px 8px #000; }
.scan-bottom { position: absolute; left: 16px; right: 16px; bottom: calc(22px + var(--safe-b)); display: flex; gap: 10px; }
.scan-bottom button { flex: 1; padding: 16px; font-weight: 600; }
.cam-error { position: absolute; inset: 0; display: grid; place-items: center; padding: 30px; text-align: center; }

/* ---------- Fiche invité / alertes ---------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 40; display: flex; align-items: stretch; justify-content: center; }
.sheet-wrap .bg { z-index: -1; }
.card { position: relative; margin: auto 16px; width: 100%; max-width: 460px; padding: 26px 22px 22px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 6px; animation: pop .35s cubic-bezier(.2, .9, .3, 1.2) both; }
@keyframes pop { from { opacity: 0; transform: translateY(30px) scale(.94); } to { opacity: 1; transform: none; } }
.card .wlogo { width: min(42vw, 170px); max-height: 170px; object-fit: contain; margin-bottom: 4px; filter: drop-shadow(0 6px 18px rgba(0,0,0,.35)); }
.card .date { margin-bottom: 10px; line-height: 1.15; }
.card .inv { font-size: .78rem; letter-spacing: .16em; text-transform: uppercase; color: var(--cream-dim); }
.card .inv b { color: var(--cream); letter-spacing: .08em; }
.card .name { font-family: 'Playfair Display', serif; font-weight: 600; font-size: clamp(1.7rem, 8vw, 2.4rem); line-height: 1.12; margin: 6px 0 10px; word-break: break-word; }
.card .table-box { width: 100%; padding: 14px; border-radius: 16px; background: rgba(0, 0, 0, .22); border: 1px solid var(--glass-border); }
.card .table-box small { display: block; font-size: .72rem; letter-spacing: .2em; text-transform: uppercase; color: var(--cream-dim); }
.card .table-box strong { display: block; font-size: clamp(1.5rem, 7vw, 2rem); color: var(--accent); letter-spacing: .06em; margin-top: 2px; filter: brightness(1.25); }
.card .meta { font-size: .8rem; color: var(--cream-dim); margin: 10px 0 4px; display: flex; align-items: center; gap: 6px; justify-content: center; flex-wrap: wrap; }
.check { width: 22px; height: 22px; border-radius: 50%; background: var(--ok); display: inline-grid; place-items: center; color: #fff; font-size: .8rem; }
.btn-main { width: 100%; margin-top: 12px; padding: 17px; border-radius: 16px; font-weight: 700; font-size: 1.08rem; position: relative; overflow: hidden;
  background: var(--accent); color: #fff; box-shadow: 0 8px 24px rgba(0, 0, 0, .3); }
.btn-main .prog { position: absolute; left: 0; bottom: 0; height: 4px; background: rgba(255, 255, 255, .75); width: 100%; transform-origin: left; }
.btn-ghost { width: 100%; padding: 14px; border-radius: 16px; font-weight: 600; margin-top: 8px; background: rgba(255, 255, 255, .12); border: 1px solid var(--glass-border); }

.alert { border-color: rgba(255, 120, 110, .6); background: rgba(120, 20, 14, .55); }
.alert.warn { border-color: rgba(255, 190, 120, .6); background: rgba(120, 66, 10, .55); }
.alert .ico { width: 74px; height: 74px; border-radius: 50%; display: grid; place-items: center; font-size: 2.3rem; font-weight: 800;
  background: var(--danger); color: #fff; box-shadow: 0 0 0 10px rgba(224, 71, 60, .25); margin-bottom: 10px; animation: shake .5s .1s; }
.alert.warn .ico { background: var(--warn); box-shadow: 0 0 0 10px rgba(232, 147, 47, .25); }
.alert h2 { margin: 0; font-size: 1.5rem; text-transform: uppercase; letter-spacing: .06em; }
.alert .first { margin-top: 10px; padding: 12px; width: 100%; border-radius: 14px; background: rgba(0, 0, 0, .28); font-size: .95rem; line-height: 1.5; }
.alert .first b { font-size: 1.15rem; }
.alert .btn-main { background: #fff; color: #7a1a12; }
.alert.warn .btn-main { color: #7a4310; }
@keyframes shake { 0%, 100% { transform: none; } 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.flash-red { position: fixed; inset: 0; z-index: 39; background: rgba(224, 71, 60, .35); animation: fadeOut .6s forwards; pointer-events: none; }
@keyframes fadeOut { to { opacity: 0; } }

/* ---------- Modale / toasts ---------- */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; background: rgba(10, 5, 2, .6); }
.modal .box { width: 100%; max-width: 400px; padding: 24px; background: rgba(61, 38, 24, .92); }
.modal h3 { margin: 0 0 6px; font-family: 'Playfair Display', serif; }
.modal p { margin: 0 0 14px; color: var(--cream-dim); font-size: .9rem; }
.modal input { width: 100%; padding: 14px; border-radius: 12px; border: 1px solid var(--glass-border); background: rgba(0,0,0,.25); color: var(--cream); font-size: 1.05rem; outline: 0; }
.toasts { position: fixed; left: 12px; right: 12px; top: calc(12px + var(--safe-t)); z-index: 90; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { padding: 12px 14px; border-radius: 14px; font-size: .88rem; background: rgba(30, 17, 10, .92); border: 1px solid var(--glass-border); box-shadow: 0 8px 24px rgba(0,0,0,.4); animation: pop .3s both; }
.toast.err { border-color: var(--danger); }
.fatal { position: fixed; inset: 0; display: grid; place-items: center; padding: 30px; text-align: center; z-index: 50; }
.fatal .box { max-width: 420px; padding: 26px; }
.demo-tag { pointer-events: none; position: fixed; left: 50%; transform: translateX(-50%); top: calc(4px + var(--safe-t)); z-index: 30; font-size: .65rem; font-weight: 700; letter-spacing: .1em; padding: 4px 8px; border-radius: 999px; background: rgba(0,0,0,.45); }
