/* Reveal — style « film argentique » : papier crème, brun espresso, orange sécurité */
:root {
  --bg: #231810;
  --bg-2: #2e2016;
  --fg: #f6ead6;
  --fg-muted: #c4b19a;
  --card: #fbf3e4;
  --card-fg: #2b1d14;
  --card-muted: #6b5848;
  --field: #ffffff;
  --border: #e4d5bb;
  --border-strong: #8a7461;
  --primary: #c2410c;
  --primary-hover: #a3360a;
  --primary-fg: #ffffff;
  --link: #fdba74;
  --danger: #b91c1c;
  --danger-text: #fca5a5;
  --ring: #fdba74;
  --ring-on-card: #c2410c;
  --chip: #f1e3c8;

  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
  --space-5: 24px; --space-6: 32px; --space-7: 48px; --space-8: 64px;
  --radius-sm: 6px; --radius-md: 12px; --radius-lg: 20px; --radius-full: 9999px;
  --shadow-md: 0 6px 20px rgb(0 0 0 / .28);
  --shadow-lg: 0 14px 40px rgb(0 0 0 / .4);
  --font-display: "Playfair Display", Georgia, serif;
  --font-body: Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease-out: cubic-bezier(.2, .7, .2, 1);
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6ead6;
    --bg-2: #efe0c4;
    --fg: #2b1d14;
    --fg-muted: #6b5848;
    --card: #ffffff;
    --card-fg: #2b1d14;
    --card-muted: #6b5848;
    --field: #fffdf8;
    --border: #e4d5bb;
    --border-strong: #8a7461;
    --link: #9a3412;
    --danger-text: #b91c1c;
    --ring: #c2410c;
    --chip: #f6ead6;
    --shadow-md: 0 6px 20px rgb(60 30 10 / .12);
    --shadow-lg: 0 14px 40px rgb(60 30 10 / .18);
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh;
  background:
    radial-gradient(120% 60% at 50% -10%, var(--bg-2), transparent 70%),
    var(--bg);
  color: var(--fg);
  font: 400 1rem/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
/* grain léger façon pellicule */
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 1; opacity: .07; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}
#app {
  position: relative; z-index: 2; max-width: 480px; margin: 0 auto;
  padding: max(var(--space-5), env(safe-area-inset-top)) var(--space-4) calc(var(--space-8) + 56px + env(safe-area-inset-bottom));
  min-height: 100dvh; animation: view-in .4s var(--ease-out) both;
}
@keyframes view-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* Typo */
h1, h2 { font-family: var(--font-display); font-weight: 700; letter-spacing: -.01em; text-wrap: balance; }
h1 { font-size: clamp(2rem, 1.4rem + 3vw, 2.75rem); line-height: 1.1; margin: var(--space-5) 0 var(--space-3); }
h1 em { font-style: italic; font-weight: 600; color: var(--link); }
h2 { font-size: 1.5rem; line-height: 1.2; margin: 0 0 var(--space-4); }
p { margin: 0 0 var(--space-3); }
.lead { color: var(--fg-muted); font-size: 1.0625rem; margin-bottom: var(--space-5); max-width: 60ch; }
.muted { color: var(--fg-muted); font-size: .9rem; }
.card .muted { color: var(--card-muted); }
a { color: var(--link); text-underline-offset: 3px; }
.ic { width: 20px; height: 20px; flex: none; }
.ic-lg { width: 28px; height: 28px; }

/* Marque */
.brand { display: flex; align-items: center; gap: var(--space-2); font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; color: var(--fg); }
.brand .ic { color: var(--link); }
.userbar { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); margin: var(--space-3) 0 var(--space-5); flex-wrap: wrap; }

/* Cartes & formulaires */
.card {
  background: var(--card); color: var(--card-fg); border-radius: var(--radius-lg);
  padding: var(--space-5); margin-bottom: var(--space-4); box-shadow: var(--shadow-md);
}
label { display: block; font-weight: 600; font-size: .875rem; margin: var(--space-4) 0 var(--space-2); }
input {
  width: 100%; min-height: 48px; padding: 0 var(--space-4); border-radius: var(--radius-md);
  border: 1.5px solid var(--border-strong); background: var(--field); color: var(--card-fg);
  font: inherit; transition: border-color .15s, box-shadow .15s;
}
input::placeholder { color: #8a7a6b; }
input:hover { border-color: var(--card-fg); }
input:focus-visible { outline: none; border-color: var(--ring-on-card); box-shadow: 0 0 0 3px rgb(194 65 12 / .25); }
/* Safari iOS : le champ date ignore la largeur et centre son texte par défaut */
input[type="datetime-local"] {
  -webkit-appearance: none; appearance: none; display: block; min-width: 0; max-width: 100%;
  height: 48px; padding-top: 0; padding-bottom: 0; text-align: left; line-height: 48px;
}
input[type="datetime-local"]::-webkit-date-and-time-value { text-align: left; min-height: 1.5em; margin: 0; }
input[type="datetime-local"]::-webkit-calendar-picker-indicator { opacity: .7; }
.err { color: var(--danger); margin-top: var(--space-3); min-height: 1.4em; font-weight: 500; }
.card .err { color: var(--danger); }
#app > .err { color: var(--danger-text); }

/* Boutons — 6 états : default / hover / focus-visible / active / disabled */
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  width: 100%; min-height: 48px; margin-top: var(--space-4); padding: 0 var(--space-5);
  border: 1.5px solid transparent; border-radius: var(--radius-md);
  background: transparent; color: inherit; font: 600 1rem/1 var(--font-body); text-decoration: none; text-align: center; cursor: pointer;
  transition: background-color .18s, border-color .18s, transform .1s, color .18s;
  -webkit-tap-highlight-color: transparent;
}
button:active, .btn:active { transform: scale(.98); }
button:disabled { opacity: .5; cursor: not-allowed; transform: none; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 3px; }
.card :focus-visible, dialog.modal :focus-visible { outline-color: var(--ring-on-card); }
.primary { background: var(--primary); color: var(--primary-fg); }
.primary:hover:not(:disabled) { background: var(--primary-hover); }
.ghost { border-color: var(--border-strong); color: var(--fg); }
.ghost:hover { background: rgb(255 255 255 / .06); border-color: var(--fg-muted); }
.ghost-dark { border-color: var(--border-strong); color: var(--card-fg); }
.ghost-dark:hover { background: var(--chip); }
.danger { border-color: var(--danger-text); color: var(--danger-text); }
.danger:hover { background: rgb(185 28 28 / .12); }
.btn-text { width: auto; min-height: 44px; margin: 0; padding: 0 var(--space-3); color: var(--link); font-weight: 500; font-size: .9rem; }
.btn-text:hover { text-decoration: underline; }
.btn + .btn, .btn + button, button + .btn { margin-top: var(--space-3); }

/* Interrupteur */
.switch { display: flex; align-items: flex-start; gap: var(--space-3); margin: var(--space-5) 0 0; cursor: pointer; font-weight: 400; position: relative; }
.switch input { position: absolute; opacity: 0; width: 52px; height: 32px; min-height: 0; margin: 0; cursor: pointer; }
.switch .track { flex: none; width: 52px; height: 32px; border-radius: var(--radius-full); background: var(--border-strong); position: relative; transition: background-color .2s; }
.switch .track::after { content: ""; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgb(0 0 0 / .3); transition: transform .2s var(--ease-out); }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch input:focus-visible + .track { outline: 2px solid var(--ring-on-card); outline-offset: 3px; }
.switch-text { display: flex; flex-direction: column; gap: 2px; min-height: 32px; justify-content: center; }
.switch-text b { font-weight: 600; font-size: .9375rem; }
.switch-text small { color: var(--card-muted); font-size: .8125rem; line-height: 1.4; }

/* QR & stats */
.qr { width: 232px; max-width: 100%; height: auto; aspect-ratio: 1; display: block; margin: var(--space-2) auto var(--space-4); border-radius: var(--radius-md); border: 6px solid #fbf3e4; box-shadow: 0 0 0 1.5px var(--border); }
.linkbox { word-break: break-all; font-size: .8125rem; background: var(--chip); color: var(--card-fg); padding: var(--space-3); border-radius: var(--radius-md); text-align: left; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); margin-top: var(--space-4); }
.stats div { display: flex; flex-direction: column; align-items: center; gap: 2px; background: var(--chip); border-radius: var(--radius-md); padding: var(--space-3) var(--space-2); font-size: .8125rem; color: var(--card-muted); }
.stats .ic { color: var(--primary); }
.stats b { font: 700 1.5rem/1.1 var(--font-display); color: var(--card-fg); font-variant-numeric: tabular-nums; }
.when { display: flex; align-items: center; gap: var(--space-2); font-weight: 600; }
.when .ic { color: var(--primary); }

/* Listes */
.row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-bottom: 1px solid var(--border); }
.row:last-of-type { border-bottom: 0; }
.row > a { flex: 1; min-width: 0; color: var(--card-fg); text-decoration: none; padding: var(--space-1) 0; }
.row > a b { display: block; font-size: 1.0625rem; overflow-wrap: anywhere; }
.row > a .muted { display: block; margin-top: 2px; }
.row > a:hover b { color: var(--primary); }
.row .del { flex: none; width: 48px; min-height: 48px; margin: 0; padding: 0; color: var(--card-muted); }
.row .del:hover { color: var(--danger); background: rgb(185 28 28 / .08); }
.empty, .locked { text-align: center; padding: var(--space-5) var(--space-3); color: var(--card-muted); }
.empty .ic, .locked .ic { color: var(--primary); margin-bottom: var(--space-2); }

/* Invités (vue hôte) */
.guest { border-bottom: 1px solid var(--border); }
.guest:last-of-type { border-bottom: 0; }
.g-row { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "name count" "bar bar"; gap: var(--space-2) var(--space-3); align-items: center; padding: var(--space-3) 0; min-height: 48px; }
.g-name { grid-area: name; display: flex; align-items: center; gap: var(--space-2); font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.g-name .ic { color: var(--primary); }
.g-count { grid-area: count; font-variant-numeric: tabular-nums; color: var(--card-muted); font-size: .9rem; }
.g-bar { grid-area: bar; height: 6px; border-radius: var(--radius-full); background: var(--chip); overflow: hidden; }
.g-bar i { display: block; height: 100%; background: var(--primary); border-radius: inherit; }
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); padding: 0 0 var(--space-4); }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chip { width: auto; min-height: 44px; margin: 0; padding: 0 var(--space-4); border: 1.5px solid var(--border-strong); border-radius: var(--radius-full); color: var(--card-fg); font-weight: 500; font-size: .9375rem; gap: var(--space-2); }
.chip b { font-variant-numeric: tabular-nums; color: var(--card-muted); font-weight: 600; }
.chip:hover { background: var(--chip); }
.chip[aria-pressed="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip[aria-pressed="true"] b { color: #fff; opacity: .9; }
select { width: 100%; min-height: 48px; padding: 0 var(--space-4); border-radius: var(--radius-md); border: 1.5px solid var(--border-strong); background: var(--field); color: var(--card-fg); font: inherit; cursor: pointer; }
select:focus-visible { outline: none; border-color: var(--ring-on-card); box-shadow: 0 0 0 3px rgb(194 65 12 / .25); }
.thumbs-lg { margin-top: var(--space-4); padding-bottom: 0; }
.thumb { position: relative; margin: 0; padding: 0; min-height: 0; width: 100%; border-radius: var(--radius-sm); overflow: hidden; background: var(--chip); aspect-ratio: 3 / 4; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .25s var(--ease-out); }
.thumb:hover img { transform: scale(1.06); }
.thumb-name { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 6px 5px; background: linear-gradient(transparent, rgb(0 0 0 / .7)); color: #fff; font: 600 .75rem/1.2 var(--font-body); text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Appareil photo */
.hello { margin: var(--space-4) 0 var(--space-3); color: var(--fg-muted); }
.hello b { color: var(--fg); }
.countdown { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
.countdown b { font: 600 1.375rem/1 var(--font-body); font-variant-numeric: tabular-nums; color: var(--link); letter-spacing: .02em; }
.cam { position: relative; border-radius: var(--radius-lg); overflow: hidden; background: #000; aspect-ratio: 3 / 4; box-shadow: var(--shadow-lg); border: 3px solid #0e0a07; }
.cam video { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam::after { /* repères de cadrage */
  content: ""; position: absolute; inset: 16px; pointer-events: none; border-radius: 6px;
  background:
    linear-gradient(#fff,#fff) 0 0 / 22px 2px, linear-gradient(#fff,#fff) 0 0 / 2px 22px,
    linear-gradient(#fff,#fff) 100% 0 / 22px 2px, linear-gradient(#fff,#fff) 100% 0 / 2px 22px,
    linear-gradient(#fff,#fff) 0 100% / 22px 2px, linear-gradient(#fff,#fff) 0 100% / 2px 22px,
    linear-gradient(#fff,#fff) 100% 100% / 22px 2px, linear-gradient(#fff,#fff) 100% 100% / 2px 22px;
  background-repeat: no-repeat; opacity: .75;
}
.cam .counter { position: absolute; top: 14px; right: 14px; z-index: 2; background: rgb(0 0 0 / .65); color: #ffd9a8; padding: 6px 12px; border-radius: var(--radius-full); font: 600 .9375rem/1.2 var(--font-body); font-variant-numeric: tabular-nums; }
.cam .flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; transition: opacity .35s; }
.cam .flash.on { opacity: .9; transition: none; }
.shutter {
  width: 80px; height: 80px; min-height: 0; margin: var(--space-5) auto 0; padding: 0; border-radius: 50%;
  background: transparent; border: 4px solid var(--fg); display: flex;
}
.shutter span { width: 60px; height: 60px; border-radius: 50%; background: var(--fg); transition: transform .12s, background-color .12s; }
.shutter:hover:not(:disabled) span { background: var(--link); }
.shutter:active:not(:disabled) span { transform: scale(.88); }

/* Galerie */
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4) var(--space-3); padding-top: var(--space-2); }
.polaroid {
  display: block; background: #fbf3e4; padding: 8px 8px 12px; border-radius: 3px; text-decoration: none;
  box-shadow: var(--shadow-md); transition: transform .25s var(--ease-out), box-shadow .25s;
  animation: develop 1.6s ease-out both;
}
.polaroid:nth-child(odd) { transform: rotate(-1.4deg); }
.polaroid:nth-child(even) { transform: rotate(1.2deg); }
.polaroid:hover { transform: rotate(0) scale(1.03); box-shadow: var(--shadow-lg); }
.polaroid img { width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block; background: #d9cdb8; }
.polaroid span { display: block; color: #2b1d14; font: 600 1rem/1.2 var(--font-display); font-style: italic; margin-top: 8px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes develop { from { filter: brightness(0) sepia(1) blur(6px); opacity: .2; } to { filter: none; opacity: 1; } }

/* Fenêtres modales */
dialog.modal {
  width: min(92vw, 420px); padding: 0; border: 0; border-radius: var(--radius-lg);
  background: var(--card); color: var(--card-fg); box-shadow: var(--shadow-lg);
  animation: modal-in .22s var(--ease-out) both;
}
dialog.modal::backdrop { background: rgb(14 9 6 / .7); backdrop-filter: blur(3px); animation: lb-in .2s both; }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
.modal-body { padding: var(--space-5); }
.modal-body h2 { font-size: 1.375rem; margin: 0 0 var(--space-3); }
.modal-body p { color: var(--card-muted); margin: 0; overflow-wrap: anywhere; }
.modal-actions { display: flex; gap: var(--space-3); margin-top: var(--space-5); }
.modal-actions button { margin: 0; flex: 1; }
.danger-solid { background: var(--danger); color: #fff; }
.danger-solid:hover { background: #991b1b; }
#toast {
  position: fixed; left: 50%; bottom: calc(var(--space-6) + env(safe-area-inset-bottom)); z-index: 50;
  translate: -50% 16px; opacity: 0; pointer-events: none; max-width: min(90vw, 360px);
  background: var(--fg); color: var(--bg); padding: var(--space-3) var(--space-5); border-radius: var(--radius-full);
  font-weight: 600; box-shadow: var(--shadow-lg); transition: opacity .2s, translate .2s var(--ease-out);
}
#toast.show { opacity: 1; translate: -50% 0; }

/* Visionneuse */
.no-scroll { overflow: hidden; }
.lightbox {
  position: fixed; inset: 0; z-index: 40; display: flex; flex-direction: column;
  background: rgb(14 9 6 / .96); color: #f6ead6; animation: lb-in .2s var(--ease-out) both;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
@keyframes lb-in { from { opacity: 0; } to { opacity: 1; } }
.lb-close { position: absolute; top: max(var(--space-3), env(safe-area-inset-top)); right: var(--space-3); z-index: 2; width: 48px; margin: 0; padding: 0; border-radius: 50%; background: rgb(255 255 255 / .1); color: #f6ead6; }
.lb-close:hover { background: rgb(255 255 255 / .2); }
.lb-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; gap: var(--space-2); padding: var(--space-7) var(--space-3) var(--space-3); }
.lb-fig { margin: 0; min-width: 0; min-height: 0; max-width: 100%; max-height: 100%; display: flex; flex-direction: column; align-items: center; gap: var(--space-3); }
.lb-img { display: block; max-width: 100%; max-height: calc(100dvh - 220px); object-fit: contain; border-radius: 4px; background: #000; box-shadow: var(--shadow-lg); }
.lb-cap { font: italic 600 1.125rem/1.2 var(--font-display); }
.lb-nav { flex: none; width: 48px; margin: 0; padding: 0; border-radius: 50%; background: rgb(255 255 255 / .1); color: #f6ead6; }
.lb-nav:hover { background: rgb(255 255 255 / .2); }
.lb-nav[hidden] { display: none; }
.lb-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: var(--space-2) var(--space-3); padding: var(--space-3) var(--space-4) var(--space-5); }
.lb-count { flex-basis: 100%; text-align: center; font-variant-numeric: tabular-nums; color: #c4b19a; font-size: .9rem; }
.lb-dl, .lb-del { width: auto; margin: 0; flex: 1 1 0; max-width: 220px; padding: 0 var(--space-4); }
.lb-del { color: #fca5a5; border-color: #7f3a3a; }
.lb-del:hover { background: rgb(185 28 28 / .25); }
@media (max-width: 520px) {
  .lb-nav { position: absolute; top: 50%; translate: 0 -50%; z-index: 2; width: 44px; background: rgb(0 0 0 / .45); }
  .lb-prev { left: var(--space-2); } .lb-next { right: var(--space-2); }
  .lb-stage { padding-inline: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
