/* ── DESIGN TOKENS ── */
:root {
  --font-display: 'Clash Display', Georgia, serif;
  --font-body: 'Satoshi', 'Helvetica Neue', sans-serif;

  --text-xs:   clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm:   clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg:   clamp(1.125rem, 1rem + 0.75vw, 1.5rem);
  --text-xl:   clamp(1.5rem, 1.2rem + 1.25vw, 2.25rem);
  --text-2xl:  clamp(2rem, 1.2rem + 2.5vw, 3.5rem);
  --text-3xl:  clamp(2.5rem, 1rem + 4vw, 5rem);

  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem;
  --space-4: 1rem;    --space-5: 1.25rem; --space-6: 1.5rem;
  --space-8: 2rem;    --space-10: 2.5rem; --space-12: 3rem;
  --space-16: 4rem;

  --radius-sm: 0.375rem; --radius-md: 0.5rem;
  --radius-lg: 0.75rem;  --radius-xl: 1rem;
  --radius-2xl: 1.5rem;  --radius-full: 9999px;

  --transition: 200ms cubic-bezier(0.16, 1, 0.3, 1);

  /* Palette: Champagne gold & ivory pour un mariage */
  --color-bg:        #0d0b0a;
  --color-surface:   #16120f;
  --color-surface-2: #1e1912;
  --color-surface-3: #261f17;
  --color-border:    oklch(0.7 0.05 60 / 0.15);
  --color-divider:   oklch(0.7 0.05 60 / 0.1);

  --color-text:       #f5eed8;
  --color-text-muted: #b8a98a;
  --color-text-faint: #6e5f45;

  --color-gold:       #d4a843;
  --color-gold-light: #f0cc7a;
  --color-gold-dark:  #9a7520;
  --color-rose:       #e8849a;
  --color-rose-light: #f5b8c8;

  --shadow-sm: 0 1px 3px oklch(0 0 0 / 0.3);
  --shadow-md: 0 4px 16px oklch(0 0 0 / 0.4);
  --shadow-lg: 0 12px 40px oklch(0 0 0 / 0.5);
  --shadow-gold: 0 0 40px oklch(0.7 0.15 60 / 0.25);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }

body {
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-bg);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

img, video, canvas { display: block; max-width: 100%; }
button { cursor: pointer; background: none; border: none; font: inherit; color: inherit; }
button:active { transform: scale(0.97); }

/* ── SCREENS ── */
.screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}
.screen.active {
  opacity: 1; pointer-events: all;
}
.screen.slide-out {
  opacity: 0; pointer-events: none;
}

/* ── BACKGROUND PARTICLES ── */
.bg-particles {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  overflow: hidden;
}
.particle {
  position: absolute;
  border-radius: 50%;
  animation: float linear infinite;
}
@keyframes float {
  0% { transform: translateY(110vh) rotate(0deg); opacity: 0; }
  10% { opacity: 0.6; }
  90% { opacity: 0.3; }
  100% { transform: translateY(-10vh) rotate(360deg); opacity: 0; }
}

/* ── LOGO / TITLE ── */
.wedding-title {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 600;
  background: linear-gradient(135deg, var(--color-gold-light), var(--color-gold), var(--color-rose-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-align: center;
  letter-spacing: -0.02em;
  line-height: 1.1;
  text-shadow: none;
  filter: drop-shadow(0 0 30px oklch(0.7 0.15 55 / 0.4));
}
.subtitle {
  font-size: var(--text-lg);
  color: var(--color-text-muted);
  text-align: center;
  margin-top: var(--space-3);
  letter-spacing: 0.08em;
  font-weight: 400;
}

/* ── WELCOME SCREEN ── */
#screen-welcome {
  background: radial-gradient(ellipse at 50% 40%, oklch(0.3 0.08 55 / 0.3), transparent 70%),
              radial-gradient(ellipse at 80% 80%, oklch(0.4 0.1 340 / 0.2), transparent 50%),
              var(--color-bg);
  gap: var(--space-10);
  z-index: 1;
  padding: var(--space-8);
}

.welcome-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2xl);
  padding: var(--space-8) var(--space-10);
  max-width: 600px;
  width: 100%;
  box-shadow: var(--shadow-lg), var(--shadow-gold);
  text-align: center;
  position: relative;
  overflow: hidden;
}
.welcome-card::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, oklch(0.7 0.15 55 / 0.05), transparent 50%, oklch(0.6 0.15 340 / 0.05));
  pointer-events: none;
}

.welcome-desc {
  color: var(--color-text-muted);
  font-size: var(--text-base);
  margin-top: var(--space-4);
  line-height: 1.7;
}

.btn-start {
  margin-top: var(--space-8);
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  background: linear-gradient(135deg, var(--color-gold-dark), var(--color-gold), var(--color-gold-light));
  color: #1a1000;
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  padding: var(--space-5) var(--space-10);
  border-radius: var(--radius-full);
  box-shadow: 0 0 0 0 oklch(0.7 0.15 55 / 0.4);
  animation: pulse-gold 2.5s ease-in-out infinite;
  letter-spacing: 0.02em;
  min-height: 72px;
  min-width: 280px;
  justify-content: center;
  transition: transform var(--transition), box-shadow var(--transition);
  z-index: 5;
}
.btn-start:active {
  transform: scale(0.96);
  box-shadow: 0 0 0 8px oklch(0.7 0.15 55 / 0.2);
}
@keyframes pulse-gold {
  0%, 100% { box-shadow: 0 0 0 0 oklch(0.7 0.15 55 / 0.5), var(--shadow-md); }
  50% { box-shadow: 0 0 0 16px oklch(0.7 0.15 55 / 0), var(--shadow-md); }
}

.hearts-deco {
  font-size: 2rem;
  position: absolute;
  animation: float-hearts 4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes float-hearts {
  0%, 100% { transform: translateY(0) rotate(-10deg); }
  50% { transform: translateY(-12px) rotate(10deg); }
}

/* ── CHOOSE MODE SCREEN ── */
#screen-mode {
  gap: var(--space-8);
  padding: var(--space-8);
  z-index: 1;
  background: var(--color-bg);
}
.mode-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 600;
  text-align: center;
  color: var(--color-gold-light);
}
.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-5);
  max-width: 780px;
  width: 100%;
}
.mode-card {
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-8) var(--space-6);
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition), background var(--transition);
  display: flex; flex-direction: column; align-items: center; gap: var(--space-4);
  min-height: 200px;
  justify-content: center;
}
.mode-card:hover, .mode-card:focus-visible {
  border-color: var(--color-gold);
  box-shadow: 0 0 0 1px var(--color-gold), var(--shadow-gold);
  background: var(--color-surface-2);
  transform: translateY(-2px);
}
.mode-card:active { transform: scale(0.97); }
.mode-icon {
  font-size: 3rem;
  filter: drop-shadow(0 0 10px oklch(0.7 0.15 55 / 0.4));
}
.mode-label {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--color-text);
}
.mode-desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.5;
}
.btn-back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text-muted);
  font-size: var(--text-base); /* au lieu de text-sm */
  padding: var(--space-4) var(--space-6);
  border-radius: var(--radius-full);
  border: 2px solid var(--color-border);
  min-height: 52px;
}
.btn-back:hover { color: var(--color-text); border-color: var(--color-gold); }
.btn-back-large {
  font-size: var(--text-lg);
  padding: var(--space-4) var(--space-8);
  border-width: 2px;
}

/* ── CAMERA SCREEN ── */
#screen-camera {
  z-index: 1;
  padding: 0;
  background: #000;
}

.camera-layout {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
  width: 100%;
}

.camera-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-4) var(--space-6);
  background: linear-gradient(to bottom, rgba(0,0,0,0.8), transparent);
  position: absolute; top: 0; left: 0; right: 0;
  z-index: 10;
}

.camera-wrapper {
  position: relative;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
}
#video-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1); /* Mirror effect */
}

/* Viewfinder overlay */
.viewfinder {
  position: absolute; inset: 0; pointer-events: none;
  display: flex; align-items: center; justify-content: center;
}
.viewfinder-frame {
  width: min(480px, 90vw);
  height: min(480px, 90vw);
  position: relative;
}
.viewfinder-corner {
  position: absolute;
  width: 40px; height: 40px;
  border-color: var(--color-gold);
  border-style: solid;
  opacity: 0.8;
}
.viewfinder-corner.tl { top: 0; left: 0; border-width: 3px 0 0 3px; border-radius: 6px 0 0 0; }
.viewfinder-corner.tr { top: 0; right: 0; border-width: 3px 3px 0 0; border-radius: 0 6px 0 0; }
.viewfinder-corner.bl { bottom: 0; left: 0; border-width: 0 0 3px 3px; border-radius: 0 0 0 6px; }
.viewfinder-corner.br { bottom: 0; right: 0; border-width: 0 3px 3px 0; border-radius: 0 0 6px 0; }

/* Mode indicator */
.mode-badge {
  background: oklch(0 0 0 / 0.6);
  backdrop-filter: blur(12px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-gold-light);
  font-weight: 500;
}

/* Bottom controls */
.camera-controls {
  position: absolute; bottom: -20px; left: 0; right: 0;
  display: flex; align-items: center; justify-content: center;
  gap: var(--space-8);
  padding: var(--space-6) var(--space-8) var(--space-10);
  background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
  z-index: 10;
}

/* Strip thumbnails */
.strip-preview {
  display: flex; gap: var(--space-2);
  align-items: center; justify-content: center;
}
.strip-thumb {
  width: 52px; height: 52px;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  object-fit: cover;
  transition: border-color var(--transition), transform var(--transition);
  background: var(--color-surface-2);
}
.strip-thumb.taken {
  border-color: var(--color-gold);
  animation: pop-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes pop-in {
  from { transform: scale(0.7) rotate(-5deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* Shutter button */
.btn-shutter {
  width: 88px; height: 88px;
  border-radius: 50%;
  background: #fff;
  border: 5px solid rgba(255,255,255,0.3);
  box-shadow: 0 0 0 0 rgba(255,255,255,0.4), var(--shadow-lg);
  transition: transform var(--transition), box-shadow var(--transition);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.btn-shutter:active {
  transform: scale(0.9);
  box-shadow: 0 0 0 12px rgba(255,255,255,0.15), var(--shadow-md);
}
.btn-shutter.countdown-active {
  background: var(--color-gold);
  animation: shutter-pulse 1s ease-in-out;
}
.btn-shutter-inner {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: #f0f0f0;
  transition: background var(--transition);
}
.btn-shutter:active .btn-shutter-inner { background: #ddd; }

/* Flash overlay */
#flash-overlay {
  position: fixed; inset: 0;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 100;
  transition: opacity 0.05s ease-in;
}
#flash-overlay.flash {
  animation: camera-flash 0.35s ease-out forwards;
}
@keyframes camera-flash {
  0%  { opacity: 1; }
  100%{ opacity: 0; }
}

/* Countdown overlay */
#countdown-overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
  z-index: 50;
}
.countdown-number {
  font-family: var(--font-display);
  font-size: clamp(8rem, 20vw, 16rem);
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 60px rgba(255,255,255,0.5), 0 4px 20px rgba(0,0,0,0.5);
  opacity: 0;
  transform: scale(1.5);
  transition: none;
  line-height: 1;
}
.countdown-number.show {
  animation: count-appear 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes count-appear {
  0%   { opacity: 0; transform: scale(1.8); }
  20%  { opacity: 1; transform: scale(1); }
  80%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.5); }
}

/* Filters */
.filters-row {
  position: absolute; bottom: 120px; left: 0; right: 0;
  display: flex; gap: var(--space-3);
  padding: 0 var(--space-4);
  overflow-x: auto;
  scrollbar-width: none;
  z-index: 10;
  justify-content: center;
}
.filters-row::-webkit-scrollbar { display: none; }
.filter-btn {
  flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-lg);
  border: 2px solid transparent;
  background: oklch(0 0 0 / 0.5);
  backdrop-filter: blur(8px);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  transition: border-color var(--transition), color var(--transition);
  min-width: 60px;
}
.filter-btn.active {
  border-color: var(--color-gold);
  color: var(--color-gold-light);
}
.filter-preview {
  width: 44px; height: 32px;
  border-radius: var(--radius-sm);
  background: #888;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}

/* ── RESULT SCREEN ── */
#screen-result {
  z-index: 1;
  padding: var(--space-6);
  gap: var(--space-6);
  background: radial-gradient(ellipse at center, oklch(0.25 0.06 55 / 0.4), transparent 70%),
              var(--color-bg);
  overflow-y: auto;
}

.result-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  color: var(--color-gold-light);
  text-align: center;
}

.strip-container {
  position: relative;
  background: #f5eed8;
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-4) var(--space-6);
  box-shadow: var(--shadow-lg), 0 0 60px oklch(0.7 0.15 55 / 0.2);
  width: 100%;
  max-width: 480px;
  overflow: hidden; /* important : pas de scroll interne */
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.strip-container::after {
  content: '';
  position: absolute;
  top: 8px; bottom: 8px; left: -4px; right: -4px;
  background: #e8dfc5;
  z-index: -1;
  border-radius: var(--radius-lg);
  transform: rotate(-1deg);
}

.strip-photo {
  width: 100%;
  object-fit: cover; /* on va contrôler la hauteur en JS */
  background: #ddd;
}

.strip-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding-top: var(--space-2);
}
.strip-date {
  font-size: var(--text-xs);
  color: #8a7a5a;
  font-family: var(--font-body);
  letter-spacing: 0.05em;
}
.strip-heart {
  font-size: 1.2rem;
  animation: heartbeat 1.5s ease-in-out infinite;
}
@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  30% { transform: scale(1.25); }
  60% { transform: scale(1.1); }
}

.result-actions {
  display: flex; gap: var(--space-3);
  flex-wrap: wrap; justify-content: center;
  max-width: 400px;
}
.btn-action {
  display: inline-flex; align-items: center; gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
  border-radius: var(--radius-full);
  font-size: var(--text-base);
  font-weight: 600;
  transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition);
  min-height: 56px;
  min-width: 180px;
  justify-content: center;
}
.btn-action:active { transform: scale(0.96); }
.btn-download {
  background: linear-gradient(135deg, var(--color-gold-dark), var(--color-gold));
  color: #1a1000;
  box-shadow: 0 4px 20px oklch(0.6 0.15 55 / 0.35);
}
.btn-retry {
  background: var(--color-surface-2);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}
.btn-home {
  background: var(--color-surface);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  font-size: var(--text-sm);
  min-width: 140px;
  min-height: 48px;
}

/* ── GALLERY SCREEN ── */
#screen-gallery {
  z-index: 1;
  padding: var(--space-6);
  gap: var(--space-6);
  background: var(--color-bg);
  overflow-y: auto;
  align-items: flex-start;
}

.gallery-header {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; max-width: var(--content-wide, 1200px);
}
.gallery-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  background: linear-gradient(135deg, var(--color-gold-light), var(--color-rose-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-3);
  width: 100%;
  max-width: 1200px;
}
.gallery-item {
  aspect-ratio: 4/3;
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  border: 2px solid transparent;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  background: var(--color-surface);
}
.gallery-item:hover { border-color: var(--color-gold); transform: scale(1.02); box-shadow: var(--shadow-gold); }
.gallery-item img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform var(--transition);
}
.gallery-item:hover img { transform: scale(1.05); }
.gallery-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--space-16);
  color: var(--color-text-muted);
}
.gallery-empty-icon { font-size: 4rem; margin-bottom: var(--space-4); }

/* Confetti canvas */
#confetti-canvas {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 200;
}

/* Toast */
.toast {
  position: fixed; bottom: var(--space-8); left: 50%; transform: translateX(-50%);
  background: var(--color-surface-2);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-sm);
  color: var(--color-text);
  box-shadow: var(--shadow-lg);
  z-index: 300;
  opacity: 0;
  transform: translateX(-50%) translateY(10px);
  transition: opacity var(--transition), transform var(--transition);
  white-space: nowrap;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Sticker overlay on strip */
.sticker-row {
  display: flex; gap: var(--space-2); justify-content: center;
  flex-wrap: wrap;
}
.sticker-btn {
  font-size: 1.8rem;
  padding: var(--space-2);
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  background: var(--color-surface-2);
  transition: border-color var(--transition), transform var(--transition);
  min-width: 52px; min-height: 52px;
  display: flex; align-items: center; justify-content: center;
}
.sticker-btn:active { border-color: var(--color-gold); transform: scale(1.1); }


.result-shell {
  display: grid;
  grid-template-columns: minmax(320px, 500px) minmax(260px, 320px);
  gap: var(--space-5);
  align-items: stretch;   /* au lieu de center/start → la colonne occupe toute la hauteur */
  width: min(96vw, 900px);
}
.result-side {
  display:flex;
  flex-direction:column;
  gap: var(--space-3);
  align-items:center;
  justify-content:center;
}
.result-actions {
  display: flex; flex-direction: row; gap: var(--space-3); flex-wrap: wrap; justify-content: center;
  max-width: 760px;
}
.persist-panel {
  display:flex; gap: var(--space-3); flex-wrap: wrap; justify-content:center; margin-top: 0;
}
#screen-result {
  justify-content: center;
  align-items: center;
}
#screen-result.compact {
  overflow: hidden;
}
.qr-box canvas, .qr-box img { max-width: 180px; max-height: 180px; }
@media (max-width: 820px) {
  #screen-result { overflow-y: auto; }
  .result-shell { grid-template-columns: 1fr; width: min(96vw, 420px); }
  .result-actions { flex-direction: row; }
}