/* Jetable — direction visuelle « faire-part » (brief 2026-09).
 * Papier chaud, encre anthracite, une couleur d'accent par événement.
 * Titres Cormorant Garamond, UI Nunito. Icônes Phosphor Light.
 */

/* ---------- Fonts self-hosted ---------- */
@font-face {
  font-family: "Cormorant Garamond";
  font-style: normal; font-weight: 500; font-display: swap;
  src: url("/static/fonts/CormorantGaramond-Medium.woff2") format("woff2");
}
@font-face {
  font-family: "Cormorant Garamond";
  font-style: italic; font-weight: 500; font-display: swap;
  src: url("/static/fonts/CormorantGaramond-Italic.woff2") format("woff2");
}
@font-face {
  font-family: "Nunito";
  font-style: normal; font-weight: 400; font-display: swap;
  src: url("/static/fonts/Nunito-Regular.woff2") format("woff2");
}
@font-face {
  font-family: "Nunito";
  font-style: normal; font-weight: 600; font-display: swap;
  src: url("/static/fonts/Nunito-SemiBold.woff2") format("woff2");
}
@font-face {
  font-family: "Nunito";
  font-style: normal; font-weight: 700; font-display: swap;
  src: url("/static/fonts/Nunito-Bold.woff2") format("woff2");
}

/* ---------- Tokens du brief ---------- */
:root {
  /* Fonds & encres */
  --paper: #FAF7F2;
  --ink: #2B2B2B;
  --muted: #6B6560;
  --line: #E6DFD4;
  --border: #9A9082;

  /* Fond pellicule (bande sombre signature) */
  --film: #3A3530;

  /* Palette « sauge » par défaut (l'organisateur choisit l'accent).
   * --accent : couleur d'accent visible (chips, badges, filet livre d'or)
   * --deep   : plus sombre pour les boutons pleins, contraste 4.5:1 sur --paper
   * --soft   : très clair pour les fonds de blocs (info, hints, sélections)
   * --ink-on : couleur du texte quand il est posé sur --deep
   */
  --accent: #7C8F76;
  --deep: #566850;
  --soft: #E9EEE6;
  --ink-on: #FFFFFF;

  /* Danger, uniquement l'admin est autorisé au rouge saturé */
  --danger: #B4413C;

  /* Typos */
  --serif: "Cormorant Garamond", Georgia, "Playfair Display", serif;
  --sans: "Nunito", -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
}

/* ---------- Reset doux ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.4;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---------- Utilitaires ---------- */
.view { display: none; position: fixed; inset: 0; }
.view.active { display: block; }
.center { display: none; align-items: center; justify-content: center; flex-direction: column; padding: 24px; text-align: center; }
.center.active { display: flex; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.serif { font-family: var(--serif); font-weight: 500; letter-spacing: .3px; }

/* ---------- Boutons ---------- */
button, .primary.big {
  font-family: inherit; cursor: pointer; border: none;
  color: var(--ink); background: #fff; border-radius: 14px;
}
.primary {
  background: var(--deep); color: var(--ink-on); font-weight: 700;
}
.primary:hover { filter: brightness(1.05); }
.danger {
  background: transparent; border: 1px solid var(--danger); color: var(--danger);
}
.big { font-size: 17px; padding: 0 20px; min-height: 52px; border-radius: 14px; font-weight: 700; }
.round { width: 54px; height: 54px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 22px; background: rgba(255,255,255,.10); color: var(--paper); }

/* ---------- Chargement ---------- */
.spinner { width: 40px; height: 40px; border: 3px solid rgba(0,0,0,.08); border-top-color: var(--deep); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Onboarding invité (landing minimale intégrée à l'app) ---------- */
.onboard { max-width: 360px; width: 100%; }
.onboard h1 { font-family: var(--serif); font-weight: 500; font-size: 34px; margin: 0 0 6px; letter-spacing: .3px; }
#ob-form { display: flex; flex-direction: column; gap: 12px; margin-top: 22px; }
input[type=text] {
  background: #fff; color: var(--ink); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px; font-size: 17px; text-align: center; font-family: inherit;
}
.hint { font-size: 13px; color: var(--muted); margin-top: 16px; line-height: 1.5; }
.countdown { font-family: var(--serif); font-weight: 500; font-size: 30px; color: var(--deep); font-variant-numeric: tabular-nums; margin: 10px 0; }

/* ---------- Viseur & compteur pellicule (SIGNATURE) ---------- */
#view-camera { background: #14120F; }
#cam { width: 100%; height: 100%; object-fit: cover; }
.hud { position: absolute; left: 0; right: 0; display: flex; align-items: center; padding: env(safe-area-inset-top) 16px 0; z-index: 4; }
.hud.top { top: 16px; justify-content: space-between; gap: 10px; }
.hud.bottom { bottom: calc(24px + env(safe-area-inset-bottom)); justify-content: space-around; }

/* La pellicule : bande sombre horizontale + N mini-vignettes + chiffre serif à côté.
 * L'objet le plus reconnaissable de l'app.
 */
.reel {
  display: flex; align-items: center; gap: 10px; flex: 1;
  background: rgba(0,0,0,.35); border-radius: 10px; padding: 6px 10px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.reel-cells {
  flex: 1; min-width: 0;
  display: grid; gap: 3px; padding: 5px 6px;
  background: var(--film); border-radius: 6px;
}
.reel-cell {
  aspect-ratio: 1 / 1.25;
  background: rgba(255,255,255,.10);
  border-radius: 1.5px;
}
.reel-cell.filled { background: var(--accent); }
.reel-cell.pending { background: rgba(255,255,255,.55); }
.reel-cell.next { background: rgba(255,255,255,.28); animation: reel-blink 1.4s infinite; }
@keyframes reel-blink { 50% { opacity: .35; } }
.reel-num {
  flex: none; font-family: var(--serif); font-weight: 500;
  font-size: 26px; line-height: 1; color: #fff;
  text-align: right; letter-spacing: .5px;
}
.reel-num small {
  display: block; font-family: var(--sans); font-size: 11px;
  color: rgba(255,255,255,.75); font-weight: 700; margin-top: 2px;
}

/* Pastille pending / offline */
.pending {
  background: rgba(0,0,0,.5); color: #fff; font-size: 12px;
  padding: 6px 10px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 6px;
}
.pending::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: #E0C08A;
}

/* Déclencheur, style « bouton d'appareil photo » du brief */
.shutter {
  width: 78px; height: 78px; border-radius: 50%; background: #fff;
  border: 6px solid var(--deep); box-shadow: 0 4px 14px rgba(0,0,0,.15);
  transition: transform .12s;
}
.shutter:disabled { background: #C9C1B5; border-color: rgba(255,255,255,.4); }
.shutter:active:not(:disabled) { transform: scale(.92); }

.flash-overlay { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 5; }
.flash-overlay.on { opacity: 1; transition: opacity .12s; }

.btn-import { cursor: pointer; }

/* Fallback caméra : couvre le viseur mais pas le HUD bas */
.fallback {
  position: absolute; top: 0; left: 0; right: 0; bottom: 130px;
  background: #14120F; display: flex; flex-direction: column; gap: 16px;
  align-items: center; justify-content: center; padding: 24px; text-align: center;
  color: #fff; z-index: 2;
}

/* ---------- Carte défi (au-dessus du viseur) ---------- */
.challenge-card {
  position: absolute; left: 16px; right: 16px; top: calc(80px + env(safe-area-inset-top));
  background: rgba(0,0,0,.55); color: #fff;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 12px; padding: 10px 14px; z-index: 3;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.challenge-label { font-family: var(--serif); font-style: italic; font-size: 18px; }
.challenge-countdown { font-size: 12px; color: rgba(255,255,255,.7); margin-top: 2px; font-variant-numeric: tabular-nums; font-weight: 700; }

/* ---------- Ma pellicule (album) ---------- */
.bar {
  display: flex; align-items: center; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: var(--paper); position: sticky; top: 0; z-index: 3;
  border-bottom: 1px solid var(--line);
}
.bar h2 { font-family: var(--serif); font-weight: 500; font-size: 22px; margin: 0; flex: 1; }
.bar .round {
  background: transparent; color: var(--ink); width: 44px; height: 44px;
  border: 0; font-size: 22px; display: grid; place-items: center;
}
#view-pellicule, #view-gallery { background: var(--paper); overflow-y: auto; color: var(--ink); }

.pel-tabs {
  display: flex; gap: 8px; padding: 8px 16px 4px;
  background: var(--paper); position: sticky; top: 60px; z-index: 2;
}
.pel-tab {
  background: transparent; color: var(--muted); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 700;
}
.pel-tab.active { background: var(--deep); color: var(--ink-on); border-color: var(--deep); }

#pel-grid { padding: 0 0 16px; }
.pel-info {
  display: flex; align-items: center; gap: 12px;
  margin: 10px 16px 4px; padding: 10px 14px;
  background: var(--soft); border-radius: 12px;
  color: var(--ink); font-size: 14px; line-height: 1.35;
}
.pel-info-num {
  flex: none; font-family: var(--serif); font-weight: 500;
  font-size: 28px; line-height: 1; color: var(--ink);
}
.pel-empty {
  padding: 40px 24px 0; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.pel-empty .ph-light { font-size: 40px; color: var(--deep); }
.pel-empty h3 { font-family: var(--serif); font-weight: 500; font-size: 22px; margin: 0; font-style: italic; }
.pel-empty p { font-size: 15px; color: var(--muted); margin: 0; max-width: 30ch; }
.pel-empty .primary.big { margin-top: 8px; padding: 0 24px; }

.pel-group { margin: 12px 0 0; }
.pel-group > header {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 8px; padding: 6px 16px 4px;
}
.pel-group > header h3 {
  font-family: var(--serif); font-weight: 500; font-size: 20px;
  margin: 0; color: var(--ink);
}
.pel-group-count { font-size: 13px; color: var(--muted); font-weight: 600; }

.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; padding: 3px; }
.grid .cell { position: relative; aspect-ratio: 1; background: #ECE5D8; overflow: hidden; border-radius: 5px; }
.grid .cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.grid .cell.pending::after {
  content: ""; position: absolute; inset: 0;
  background: rgba(250,247,242,.6);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='28' height='28' viewBox='0 0 256 256'%3E%3Cpath fill='%232B2B2B' d='M200 40h-8V32a8 8 0 0 0-16 0v8H80v-8a8 8 0 0 0-16 0v8h-8a24 24 0 0 0-24 24v152a24 24 0 0 0 24 24h144a24 24 0 0 0 24-24V64a24 24 0 0 0-24-24m8 176a8 8 0 0 1-8 8H56a8 8 0 0 1-8-8V64a8 8 0 0 1 8-8h8v8a8 8 0 0 0 16 0v-8h96v8a8 8 0 0 0 16 0v-8h8a8 8 0 0 1 8 8Z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: center;
}
.grid .cell.hasch { outline: 2px solid var(--accent); outline-offset: -2px; }
.grid .cell .ch-label {
  position: absolute; top: 4px; left: 4px; right: 40px;
  background: rgba(0,0,0,.65); color: #fff; font-size: 10px;
  padding: 3px 6px; border-radius: 6px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.grid .cell .del {
  position: absolute; top: 4px; right: 4px; width: 30px; height: 30px;
  border-radius: 50%; background: rgba(255,255,255,.85); color: var(--ink);
  font-size: 16px; border: 0; cursor: pointer;
  display: grid; place-items: center;
}
.grid .cell .author {
  position: absolute; bottom: 0; left: 0; right: 0;
  font-size: 11px; padding: 2px 5px; color: #fff; font-weight: 700;
  background: linear-gradient(transparent, rgba(0,0,0,.7));
}

/* Bande d'annulation (60 s alignée sur la fenêtre serveur) */
.undo {
  position: fixed; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; display: flex; justify-content: space-between; align-items: center;
  box-shadow: 0 8px 24px rgba(43,43,43,.12);
  font-family: var(--serif); font-style: italic; font-size: 17px;
}
.undo button {
  background: var(--ink); color: #fff; border-radius: 999px;
  padding: 0 14px; min-height: 36px; font-size: 13px; font-weight: 700;
  font-family: var(--sans); font-style: normal;
}

/* ---------- Galerie ---------- */
.locked h3 { font-family: var(--serif); font-weight: 500; font-size: 26px; }

/* ---------- Livre d'or : mots d'abord, formulaire en pied de page ---------- */
#view-guestbook { background: var(--paper); overflow: hidden; color: var(--ink); flex-direction: column; }
#view-guestbook.active { display: flex; }
#view-guestbook .bar { flex: none; }
.gb-wrap {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
  padding: 0 22px;
}
.gb-list {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; gap: 18px;
  padding: 14px 0 10px; min-height: 0;
}
.gb-msg {
  border-left: 2px solid var(--accent);
  padding: 2px 0 2px 14px;
}
.gb-msg .gb-body {
  font-family: var(--serif); font-style: italic; font-size: 20px; line-height: 1.38;
  margin: 0; white-space: pre-wrap;
}
.gb-msg .gb-author {
  display: block; margin-top: 6px;
  font-family: var(--sans); font-weight: 700; font-size: 13px; color: var(--muted);
}
.gb-msg .gb-date { display: none; }

.gb-empty {
  text-align: center; padding: 40px 10px 0;
  display: flex; flex-direction: column; gap: 10px; align-items: center;
}
.gb-empty h3 {
  font-family: var(--serif); font-style: italic; font-weight: 500;
  font-size: 21px; margin: 0;
}
.gb-empty p { font-size: 15px; color: var(--muted); margin: 0; max-width: 30ch; }

.gb-form {
  flex: none;
  display: flex; flex-direction: column; gap: 8px;
  padding: 10px 0 calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--paper);
}
.gb-form textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 12px;
  padding: 11px 13px; font-size: 16px; background: #fff;
  resize: none; line-height: 1.4; color: var(--ink); font-family: inherit;
}
.gb-form textarea::placeholder { color: #8A8178; }
.gb-form .primary { min-height: 50px; padding: 0; font-size: 16px; }
.gb-meta {
  display: flex; justify-content: space-between; align-items: center;
  font-size: 14px; color: var(--muted); min-height: 32px;
}
.gb-meta b { color: var(--ink); font-weight: 700; }
.gb-edit-name {
  border: 0; background: none; padding: 6px 0 6px 6px;
  color: var(--deep); font-weight: 700; font-size: 14px; cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
  font-family: inherit;
}
.gb-meta input {
  border: 1px solid var(--border); border-radius: 10px; padding: 0 10px;
  min-height: 36px; font-size: 15px; width: 160px; background: #fff;
  color: var(--ink); font-family: inherit;
}
.gb-status { font-size: 13px; color: var(--muted); margin: 0; min-height: 18px; }
.gb-status.ok { color: var(--deep); }
.gb-status.err { color: var(--danger); }

/* ---------- Message vocal ---------- */
#view-voice { background: var(--paper); overflow-y: auto; color: var(--ink); }
.voice-wrap { padding: 20px; display: flex; flex-direction: column; gap: 18px; align-items: center; text-align: center; }
.voice-intro { max-width: 320px; font-family: var(--serif); font-style: italic; font-size: 17px; }
.voice-level { width: 240px; height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.voice-level-bar { height: 100%; width: 0%; background: var(--accent); transition: width .06s linear; }
.voice-countdown { font-family: var(--serif); font-weight: 500; font-size: 44px; color: var(--deep); font-variant-numeric: tabular-nums; letter-spacing: 2px; }
.voice-actions { display: flex; gap: 20px; }
.voice-actions .round.big { width: 80px; height: 80px; font-size: 26px; background: var(--deep); color: var(--ink-on); }
.voice-preview { width: 280px; max-width: 100%; }
.voice-status { font-size: 13px; color: var(--muted); min-height: 18px; margin: 0; }
.voice-status.ok { color: var(--deep); }
.voice-status.err { color: var(--danger); }
.voice-existing { display: flex; flex-direction: column; gap: 8px; align-items: center; padding-top: 16px; border-top: 1px solid var(--line); width: 100%; max-width: 320px; }
.voice-note { font-size: 12px; color: var(--muted); }

/* ---------- Le lendemain (import différé) ---------- */
#view-late { background: var(--paper); overflow: hidden; color: var(--ink); flex-direction: column; }
#view-late.active { display: flex; }
#view-late .bar { flex: none; }
.late-wrap {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 12px 22px calc(20px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px;
}
.late-info {
  display: flex; align-items: center; gap: 12px;
  background: var(--soft); border-radius: 12px;
  padding: 10px 14px; font-size: 14px; line-height: 1.35;
}
.late-info b {
  flex: none; font-family: var(--serif); font-weight: 500;
  font-size: 28px; line-height: 1;
}
.late-pick {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border); border-radius: 12px;
  padding: 0 16px; min-height: 48px;
  background: #fff; color: var(--ink);
  font-size: 15px; font-weight: 700; cursor: pointer;
  font-family: inherit;
}
.late-groups { display: flex; flex-direction: column; gap: 14px; }
.late-group h4 {
  font-family: var(--serif); font-weight: 500; font-size: 20px;
  margin: 0 0 6px;
}
.late-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.late-cell {
  aspect-ratio: 1; background: #ECE5D8; border-radius: 5px;
  overflow: hidden; position: relative; cursor: pointer;
  border: 0; padding: 0;
}
.late-cell img { width: 100%; height: 100%; object-fit: cover; display: block; }
.late-cell .ph-check-circle {
  position: absolute; top: 5px; right: 5px; font-size: 22px;
  color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.5);
}
.late-cell.on::after {
  content: ""; position: absolute; inset: 0;
  outline: 3px solid var(--deep); outline-offset: -3px;
}
.late-cell .late-time {
  position: absolute; left: 6px; bottom: 4px;
  color: #fff; font-size: 11px; font-weight: 700;
  text-shadow: 0 1px 3px rgba(0,0,0,.6);
}

/* ---------- Bandeau d'alerte « photos en attente » ---------- */
.pending-warning {
  position: fixed; top: calc(env(safe-area-inset-top) + 8px);
  left: 12px; right: 12px;
  background: var(--soft); color: var(--ink);
  border: 1px solid var(--accent);
  font-size: 13px; line-height: 1.4;
  padding: 10px 14px; border-radius: 10px;
  box-shadow: 0 4px 16px rgba(43,43,43,.10);
  z-index: 2;
  animation: slide-in .3s ease-out;
}
/* Sur les vues avec en-tête (livre d'or, pellicule, galerie, ajout tardif, vocal),
   pousse le bandeau sous la barre pour ne pas masquer le bouton retour. */
body:has(#view-guestbook.active, #view-pellicule.active, #view-gallery.active,
        #view-late.active, #view-voice.active) .pending-warning {
  top: calc(env(safe-area-inset-top) + 68px);
}
@keyframes slide-in {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ---------- Couple photo (dans l'onboard) ---------- */
.couple-photo-small {
  width: 136px; height: 136px; border-radius: 50%; object-fit: cover;
  margin: 0 auto 16px; display: block;
  background: #ECE5D8;
}

/* ---------- Clôture ---------- */
#view-closed { background: var(--paper); color: var(--ink); padding: 0 30px 40px; }
#view-closed.active { display: flex; }
.closed-card {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  max-width: 360px; width: 100%; padding-top: 40px;
}
.closed-photo {
  width: 104px; height: 104px; border-radius: 50%; object-fit: cover;
  margin-bottom: 16px; background: #ECE5D8;
}
.closed-photo-empty {
  width: 104px; height: 104px; border-radius: 50%;
  margin-bottom: 16px; background: #ECE5D8;
  display: flex; align-items: center; justify-content: center;
  color: #9A9082;
}
.closed-photo-empty .ph-light { font-size: 30px; }
#closed-title {
  font-family: var(--serif); font-weight: 500;
  font-size: 40px; line-height: 1; margin: 0;
}
.closed-sub {
  font-family: var(--serif); font-style: italic;
  font-size: 21px; line-height: 1.4; margin: 16px 0 0;
  text-wrap: pretty;
}
.closed-hint {
  font-size: 15px; color: var(--muted); margin: 24px 0 0; line-height: 1.55;
}

/* ---------- prefers-reduced-motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}
