/* ============================================================
   Mariage Stéphanie & Alexandre — papeterie numérique
   Ivoire · sauge · eucalyptus · champagne — mobile-first
============================================================ */

:root {
  --cream:      #F1EBDD;   /* fond page (ivoire chaud) */
  --paper:      #FBF8F1;   /* fond carte (papier crème) */
  --paper-2:    #F5EFE3;   /* fond input / zones */
  --ink:        #3E3A31;   /* texte principal (charbon chaud) */
  --ink-soft:   #6E6A5C;   /* texte secondaire */
  --ink-mute:   #A79F8C;   /* placeholders / méta */
  --sage:       #5E6B4E;   /* titres / prénoms (vert sauge profond) */
  --sage-soft:  #8A9578;   /* feuillage / accents doux */
  --gold:       #B29A63;   /* champagne / doré discret */
  --rose:       #C08A72;   /* filet terracotta discret */
  --border:     #E2DAC8;   /* bordures fines */
  --border-str: #D3C8AE;
  --error:      #A5583F;
  --shadow:     0 18px 40px -24px rgba(94, 84, 55, 0.55);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body {
  min-height: 100%;
  width: 100%;
  color: var(--ink);
  background-color: var(--cream);
  font-family: 'EB Garamond', Georgia, 'Times New Roman', serif;
  font-size: 17px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body {
  position: relative;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 28px 18px calc(28px + env(safe-area-inset-bottom));
  background-image:
    radial-gradient(1200px 700px at 85% -10%, rgba(138, 149, 120, 0.10), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(178, 154, 99, 0.10), transparent 60%);
  background-attachment: fixed;
}

/* Décors eucalyptus (fondu multiply -> le blanc disparaît) */
.botanic {
  position: fixed;
  z-index: 0;
  pointer-events: none;
  background-repeat: no-repeat;
  background-image: url('/static/assets/eucalyptus_branch.jpg');
  mix-blend-mode: multiply;
  opacity: 0.5;
}
.botanic-top {
  top: -40px; right: -70px;
  width: 240px; height: 360px;
  background-size: contain;
  transform: scaleX(-1) rotate(6deg);
}
.botanic-bottom {
  bottom: -60px; left: -80px;
  width: 240px; height: 360px;
  background-size: contain;
  transform: rotate(8deg);
  opacity: 0.4;
}
@media (max-width: 600px) {
  .botanic-top { width: 160px; height: 240px; top: -24px; right: -50px; }
  .botanic-bottom { width: 160px; height: 240px; bottom: -40px; left: -56px; }
}

/* ============================================================
   SCREENS
============================================================ */
.screen {
  position: relative;
  z-index: 1;
  display: none;
  flex: 1;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}
.screen.active { display: flex; animation: rise 500ms ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ============================================================
   CARD
============================================================ */
.card {
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 40px 30px;
  text-align: center;
  box-shadow: var(--shadow);
  position: relative;
}
/* Filet doré intérieur, façon faire-part */
.card::after {
  content: "";
  position: absolute;
  inset: 9px;
  border: 1px solid var(--border-str);
  border-radius: 3px;
  pointer-events: none;
}
.card > * { position: relative; z-index: 1; }

/* ============================================================
   TYPO IDENTITÉ
============================================================ */
.couple {
  font-family: 'Cormorant Garamond', serif;
  color: var(--sage);
  font-weight: 500;
  font-size: 40px;
  line-height: 1.08;
  letter-spacing: 0.01em;
}
.couple .amp {
  font-style: italic;
  font-weight: 500;
  color: var(--gold);
  padding: 0 2px;
}
.couple-sm { font-size: 30px; }

.event-date {
  margin-top: 10px;
  font-variant: small-caps;
  letter-spacing: 0.22em;
  text-transform: lowercase;
  font-size: 14px;
  color: var(--ink-soft);
}

.script-accent {
  font-family: 'Petit Formal Script', cursive;
  color: var(--sage);
  font-size: 26px;
  line-height: 1;
}

.lead {
  margin: 16px auto 0;
  max-width: 34ch;
  color: var(--ink-soft);
  font-size: 16px;
  font-style: italic;
}

/* Séparateur feuillage + cœur doré */
.divider {
  height: 44px;
  margin: 18px auto 4px;
  background: url('/static/assets/leaf_divider.jpg') center / contain no-repeat;
  mix-blend-mode: multiply;
  opacity: 0.92;
}

/* Emblème couronne */
.wreath {
  width: 190px;
  height: 190px;
  margin: 0 auto 6px;
  background: url('/static/assets/botanical_wreath.jpg') center / contain no-repeat;
  mix-blend-mode: multiply;
  display: flex;
  align-items: center;
  justify-content: center;
}
.wreath-inner { display: flex; align-items: center; justify-content: center; }

/* ============================================================
   ACCESS FORM
============================================================ */
.access-form {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.field-label {
  font-variant: small-caps;
  letter-spacing: 0.2em;
  font-size: 13px;
  color: var(--ink-soft);
}
#access-input {
  width: 100%;
  text-align: center;
  font-family: 'Cormorant Garamond', serif;
  font-size: 26px;
  letter-spacing: 0.5em;
  font-weight: 600;
  color: var(--sage);
  padding: 15px 12px;
  border: 1px solid var(--border-str);
  border-radius: 4px;
  background: var(--paper-2);
  outline: none;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}
#access-input::placeholder { color: var(--ink-mute); letter-spacing: 0.35em; font-weight: 400; }
#access-input:focus { border-color: var(--sage-soft); box-shadow: 0 0 0 3px rgba(138, 149, 120, 0.18); }
#access-input.shake { animation: shake 420ms ease; border-color: var(--error); }
@keyframes shake { 10%,90%{transform:translateX(-1px);} 30%,70%{transform:translateX(-4px);} 50%{transform:translateX(4px);} }

.error-msg {
  min-height: 18px;
  color: var(--error);
  font-size: 14px;
  font-style: italic;
  opacity: 0;
  transition: opacity 180ms ease;
}
.error-msg.visible { opacity: 1; }

/* ============================================================
   BUTTONS
============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: 'Cormorant Garamond', serif;
  font-weight: 600;
  font-size: 19px;
  letter-spacing: 0.06em;
  padding: 13px 26px;
  border-radius: 4px;
  min-height: 50px;
  text-decoration: none;
  transition: background-color 220ms ease, color 220ms ease, border-color 220ms ease, transform 120ms ease;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--sage);
  color: #F6F3EA;
  border-color: var(--sage);
}
.btn-primary:hover { background: #556046; }
.btn-ghost {
  background: transparent;
  color: var(--sage);
  border: 1px solid var(--border-str);
}
.btn-ghost:hover { background: var(--paper-2); }

.btn-back-home { width: 100%; margin-top: 6px; }
.btn-ghost { width: 100%; margin-top: 14px; font-size: 16px; }

.icon-btn {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  background: var(--paper);
  color: var(--sage);
  border: 1px solid var(--border);
  border-radius: 50%;
  transition: background-color 200ms ease;
}
.icon-btn:hover { background: var(--paper-2); }

/* ============================================================
   HOME / DROPZONE
============================================================ */
.home-head { display: flex; flex-direction: column; align-items: center; }

.dropzone {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 34px 20px;
  cursor: pointer;
  background: var(--paper-2);
  border: 1.5px dashed var(--border-str);
  border-radius: 6px;
  color: var(--sage);
  transition: border-color 220ms ease, background-color 220ms ease, transform 160ms ease;
}
.dropzone:hover { border-color: var(--sage-soft); background: #F0E9DB; }
.dropzone:active { transform: scale(0.99); }
.dropzone-mark {
  width: 64px; height: 64px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--sage);
  background: var(--paper);
  border: 1px solid var(--border-str);
}
.dropzone-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 23px;
  font-weight: 600;
  color: var(--sage);
}
.dropzone-hint { font-size: 14px; color: var(--ink-mute); font-style: italic; }

/* ============================================================
   PREVIEW
============================================================ */
#screen-preview {
  max-width: 720px;
  align-items: stretch;
  justify-content: flex-start;
  gap: 14px;
}
.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 2px;
}
.preview-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--sage);
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 4px 0 110px;
}
@media (min-width: 640px) { .preview-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 900px) { .preview-grid { grid-template-columns: repeat(5, 1fr); } }

.thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 4px;
  overflow: hidden;
  background: var(--paper-2);
  border: 1px solid var(--border);
  animation: fadein 400ms ease both;
}
@keyframes fadein { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.tile-fallback {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 6px; padding: 8px; text-align: center;
  color: var(--sage);
  background: var(--paper-2);
}
.tile-fallback svg { opacity: 0.8; }
.tile-name { font-size: 11px; color: var(--ink-soft); word-break: break-word; line-height: 1.2; }
.tile-badge {
  position: absolute;
  bottom: 5px; left: 5px;
  display: inline-flex; align-items: center; gap: 3px;
  background: rgba(62, 58, 49, 0.72);
  color: #F6F3EA;
  font-size: 10px;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 999px;
}

.thumb-remove {
  position: absolute;
  top: 5px; right: 5px;
  width: 26px; height: 26px;
  border: none;
  cursor: pointer;
  background: rgba(251, 248, 241, 0.95);
  color: var(--ink);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(62, 58, 49, 0.25);
}

.preview-footer {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 14px 18px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--cream) 72%, transparent);
  z-index: 5;
}
.preview-footer .btn-send {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}
.btn-send[disabled] { opacity: 0.6; cursor: default; }

/* ============================================================
   SUCCESS
============================================================ */
.card-success { padding-top: 44px; }
.heart-mark {
  width: 84px; height: 84px;
  margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--sage);
  background: var(--paper-2);
  border: 1px solid var(--border-str);
  animation: pop 520ms cubic-bezier(.2,.8,.2,1) both;
}
@keyframes pop { 0% { transform: scale(0.6); opacity: 0; } 60% { transform: scale(1.06); } 100% { transform: scale(1); opacity: 1; } }
.success-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 30px;
  font-weight: 600;
  color: var(--sage);
}
.success-text { margin-top: 8px; color: var(--ink-soft); font-style: italic; }

/* ============================================================
   LOADING OVERLAY
============================================================ */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(62, 58, 49, 0.42);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}
.loading-card {
  background: var(--paper);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 30px 26px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  box-shadow: var(--shadow);
}
.loading-leaf {
  width: 64px; height: 40px;
  margin: 0 auto 6px;
  background: url('/static/assets/leaf_divider.jpg') center / contain no-repeat;
  mix-blend-mode: multiply;
}
.loading-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 21px;
  font-weight: 600;
  color: var(--sage);
}
.loading-meta { margin-top: 10px; color: var(--ink-soft); font-size: 14px; }
.progress-bar {
  margin-top: 14px;
  height: 6px;
  background: var(--paper-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--sage-soft), var(--sage));
  border-radius: 999px;
  transition: width 260ms ease;
}

/* ============================================================
   TOAST
============================================================ */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(8px);
  background: var(--ink);
  color: #F6F3EA;
  font-size: 15px;
  padding: 12px 20px;
  border-radius: 4px;
  box-shadow: var(--shadow);
  z-index: 100;
  max-width: calc(100vw - 32px);
  opacity: 0;
  transition: opacity 260ms ease, transform 260ms ease;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--error); }

/* ============================================================
   LOCKED / accueil réduit
============================================================ */
.wreath-sm { width: 132px; height: 132px; margin: 0 auto 2px; }
.wreath-sm .script-accent { font-size: 20px; }
.locked-mark {
  width: 72px; height: 72px;
  margin: 8px auto 4px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: var(--sage);
  background: var(--paper-2);
  border: 1px solid var(--border-str);
}
