/* Fallback CSS (si Tailwind CDN ne charge pas) + petits extras */

:root {
  --bg1: #fff1f2;
  --bg2: #fdf2f8;
  --bg3: #fff7ed;
  --text: #0f172a;
  --muted: #475569;
  --card: rgba(255, 255, 255, 0.72);
  --border: rgba(15, 23, 42, 0.12);
}

/* Important: Tailwind fournit `.hidden`. Sans Tailwind, il faut le ré-implémenter
   sinon le “Mode lien” ne cache rien. */
.hidden {
  display: none !important;
}

/* Tailwind fournit souvent ce genre d’ombre via utilitaires; on ajoute un fallback. */
.shadow-soft {
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji",
    "Segoe UI Emoji";
  background: linear-gradient(135deg, var(--bg1), var(--bg2) 45%, var(--bg3));
}

header,
main,
footer {
  max-width: 1024px;
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}

header {
  padding-top: 40px;
  padding-bottom: 24px;
}

main {
  padding-bottom: 48px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
}

@media (min-width: 1024px) {
  main {
    grid-template-columns: 1fr 1fr;
  }
}

section {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  backdrop-filter: blur(10px);
}

h1 {
  margin: 6px 0 0;
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  margin: 0;
  font-size: 18px;
}

p {
  margin: 0;
}

form {
  margin-top: 18px;
}

label > span {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  color: #334155;
}

input,
textarea,
select {
  width: 100%;
  box-sizing: border-box;
  margin-top: 6px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  background: #fff;
  color: var(--text);
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(225, 29, 72, 0.45);
  box-shadow: 0 0 0 4px rgba(251, 113, 133, 0.25);
}

button,
a {
  font-family: inherit;
}

button {
  cursor: pointer;
  border: 0;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

/* Boutons principaux (fallback sur ids) */
#btn-generate {
  background: #e11d48;
  color: #fff;
  border-radius: 14px;
  padding: 11px 14px;
  font-weight: 800;
}

#btn-generate:hover {
  background: #be123c;
}

#btn-random {
  background: #fff;
  color: #0f172a;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 14px;
  padding: 11px 14px;
  font-weight: 800;
}

#btn-copy {
  background: #0f172a;
  color: #fff;
  border-radius: 12px;
  padding: 8px 12px;
  font-weight: 800;
}

#btn-whatsapp {
  background: #059669;
  color: #fff;
  border-radius: 18px;
  padding: 12px 14px;
  font-weight: 800;
}

#btn-open {
  background: #fff;
  color: #0f172a;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 18px;
  padding: 12px 14px;
  font-weight: 800;
}

#share-url {
  background: #f8fafc;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Carte (fallback complet) --- */
#card {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  padding: 24px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  color: #fff;
}

#card-kicker {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.85;
}

#card-title {
  margin-top: 8px;
  font-size: 28px;
  line-height: 1.15;
  font-weight: 900;
}

#card-to {
  margin-top: 6px;
  opacity: 0.92;
}

#card-message-wrap {
  margin-top: 18px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 14px 16px;
}

#card-message {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.6;
  font-size: 14px;
  opacity: 0.98;
}

/* Utility for long unbroken strings (links, random chars, etc.) */
.break-anywhere {
  overflow-wrap: anywhere;
  word-break: break-word;
}

#card-date {
  font-size: 12px;
  opacity: 0.8;
}

#card-from {
  margin-top: 6px;
  font-weight: 800;
}

#card-signature {
  font-weight: 800;
  opacity: 0.98;
}

.card-theme-rose {
  background: radial-gradient(1200px circle at 20% 10%, rgba(255, 255, 255, 0.35), transparent 45%),
    linear-gradient(135deg, #fb7185, #f43f5e 40%, #be123c);
}

.card-theme-sunset {
  background: radial-gradient(1200px circle at 20% 10%, rgba(255, 255, 255, 0.35), transparent 45%),
    linear-gradient(135deg, #fb7185, #f97316 45%, #7c2d12);
}

.card-theme-night {
  background: radial-gradient(1200px circle at 20% 10%, rgba(255, 255, 255, 0.25), transparent 45%),
    linear-gradient(135deg, #0f172a, #1f2937 45%, #111827);
}

.card-theme-mint {
  background: radial-gradient(1200px circle at 20% 10%, rgba(255, 255, 255, 0.35), transparent 45%),
    linear-gradient(135deg, #10b981, #06b6d4 55%, #0f766e);
}

.card-style-classic #card-message-wrap {
  border-radius: 16px;
}

.card-style-modern #card-message-wrap {
  border-radius: 18px;
  backdrop-filter: blur(10px);
}

.card-style-letter #card-message {
  font-family: ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;
  font-size: 0.95rem;
}

/* ---------------- Romantic UI (enhancements) ---------------- */

.romantic-ui {
  position: relative;
}

.romantic-bg,
.romantic-particles {
  position: fixed;
  inset: -40px;
  pointer-events: none;
  z-index: 0;
}

/* Keep app content above effects */
header,
main,
footer {
  position: relative;
  z-index: 1;
}

/* Animated soft aurora background */
.romantic-bg {
  background: radial-gradient(900px circle at 10% 20%, rgba(255, 255, 255, 0.65), transparent 50%),
    radial-gradient(800px circle at 85% 15%, rgba(251, 113, 133, 0.22), transparent 55%),
    radial-gradient(900px circle at 70% 90%, rgba(244, 63, 94, 0.18), transparent 60%),
    radial-gradient(700px circle at 20% 85%, rgba(236, 72, 153, 0.14), transparent 55%);
  filter: blur(10px) saturate(1.2);
  opacity: 0.9;
  transform: translateZ(0);
  animation: romanticFloat 16s ease-in-out infinite alternate;
}

@keyframes romanticFloat {
  0% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  50% {
    transform: translate3d(-10px, 8px, 0) scale(1.03);
  }
  100% {
    transform: translate3d(14px, -12px, 0) scale(1.02);
  }
}

/* Subtle sparkles */
.romantic-particles {
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.9) 0 1px, transparent 2px),
    radial-gradient(circle, rgba(255, 255, 255, 0.65) 0 1px, transparent 2px),
    radial-gradient(circle, rgba(255, 255, 255, 0.55) 0 1px, transparent 2px);
  background-size: 180px 180px, 240px 240px, 320px 320px;
  background-position: 0 0, 60px 80px, 120px 40px;
  opacity: 0.35;
  animation: sparkleDrift 22s linear infinite;
  mask-image: radial-gradient(closest-side, rgba(0, 0, 0, 1), rgba(0, 0, 0, 0.1));
}

@keyframes sparkleDrift {
  0% {
    transform: translate3d(0, 0, 0);
  }
  100% {
    transform: translate3d(-120px, 160px, 0);
  }
}

/* Nicer glass cards + hover */
section {
  transition: transform 220ms ease, box-shadow 220ms ease, border-color 220ms ease;
}

section:hover {
  border-color: rgba(225, 29, 72, 0.25);
  box-shadow: 0 22px 70px rgba(244, 63, 94, 0.12);
  transform: translateY(-2px);
}

/* Card micro-interaction */
#card {
  transition: transform 260ms ease, box-shadow 260ms ease;
}

#card:hover {
  transform: translateY(-3px) rotate(-0.15deg);
  box-shadow: 0 28px 80px rgba(15, 23, 42, 0.18);
}

/* Romantic glow for primary actions */
#btn-generate,
#btn-whatsapp,
#btn-share,
#btn-telegram,
#btn-x,
#btn-messenger {
  box-shadow: 0 12px 35px rgba(244, 63, 94, 0.16);
  transition: transform 180ms ease, box-shadow 180ms ease, filter 180ms ease;
}

#btn-generate:hover,
#btn-whatsapp:hover,
#btn-share:hover,
#btn-telegram:hover,
#btn-x:hover,
#btn-messenger:hover {
  transform: translateY(-1px);
  filter: saturate(1.05);
  box-shadow: 0 18px 45px rgba(244, 63, 94, 0.22);
}

/* Focus ring upgrade */
input:focus,
textarea:focus,
select:focus {
  border-color: rgba(244, 63, 94, 0.45);
  box-shadow: 0 0 0 5px rgba(244, 63, 94, 0.18);
}

/* Reduce motion accessibility */
@media (prefers-reduced-motion: reduce) {
  .romantic-bg,
  .romantic-particles,
  section,
  #card,
  #btn-generate,
  #btn-whatsapp,
  #btn-share,
  #btn-telegram,
  #btn-x,
  #btn-messenger {
    animation: none !important;
    transition: none !important;
  }
}

/* Floating hearts (DOM-injected) */
.floating-heart {
  position: absolute;
  width: 18px;
  height: 18px;
  left: 0;
  top: 0;
  transform-origin: center;
  animation-name: floatHeart;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  filter: drop-shadow(0 8px 20px rgba(244, 63, 94, 0.16));
}

.floating-heart::before {
  content: "♥";
  display: block;
  font-size: 18px;
  line-height: 18px;
  color: rgba(244, 63, 94, 0.55);
  text-shadow: 0 10px 26px rgba(244, 63, 94, 0.18);
}

@keyframes floatHeart {
  0% {
    transform: translate3d(0, 0, 0) rotate(-6deg);
  }
  50% {
    transform: translate3d(10px, -16px, 0) rotate(8deg);
  }
  100% {
    transform: translate3d(-8px, 10px, 0) rotate(-4deg);
  }
}

/* Effects reduced (manual toggle) */
body.effects-reduced .romantic-bg,
body.effects-reduced .romantic-particles {
  display: none !important;
}

body.effects-reduced section,
body.effects-reduced #card {
  transition: none !important;
}

/* Sparkle burst */
.sparkle-overlay {
  position: fixed;
  z-index: 60;
  pointer-events: none;
}

.sparkle {
  position: absolute;
  width: 10px;
  height: 10px;
  transform: translate3d(0, 0, 0) scale(var(--sc, 1));
  animation: sparklePop 700ms cubic-bezier(0.2, 0.9, 0.2, 1) forwards;
  filter: drop-shadow(0 10px 18px rgba(244, 63, 94, 0.22));
}

.sparkle::before,
.sparkle::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0) 65%),
    radial-gradient(circle at 30% 35%, rgba(244, 63, 94, 0.85), rgba(244, 63, 94, 0) 65%);
  border-radius: 999px;
}

.sparkle::after {
  transform: rotate(45deg);
  opacity: 0.75;
}

@keyframes sparklePop {
  0% {
    opacity: 0;
    transform: translate3d(0, 0, 0) scale(0.6);
  }
  30% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--dx, 0px), var(--dy, -40px), 0) rotate(var(--rot, 0deg)) scale(0.2);
  }
}

/* Heart confetti (celebration) */
.confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 70;
}

.confetti-heart {
  position: absolute;
  top: -20px;
  transform: translate3d(0, 0, 0);
  animation: confettiFall linear forwards;
  filter: drop-shadow(0 12px 26px rgba(244, 63, 94, 0.18));
}

.confetti-heart::before {
  content: "♥";
  color: rgba(244, 63, 94, 0.85);
  text-shadow: 0 14px 30px rgba(244, 63, 94, 0.22);
}

@keyframes confettiFall {
  0% {
    transform: translate3d(0, 0, 0) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  100% {
    transform: translate3d(var(--drift, 0px), 110vh, 0) rotate(var(--rot, 120deg));
    opacity: 0;
  }
}

/* Ensure reduced mode disables burst/confetti */
body.effects-reduced .sparkle-overlay,
body.effects-reduced .confetti-layer {
  display: none !important;
}

