/* ═══════════════════════════════════════════════
   MILLE MERCIS — Style joyeux, lumineux, chaleureux
   ═══════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,400;0,700;1,400;1,600&family=Nunito:wght@400;500;600;700&family=Dancing+Script:wght@600&display=swap');

/* ── Variables ──────────────────────────────── */
:root {
  --bg:           #fffbf5;
  --bg-card:      #ffffff;
  --bg-soft:      #fff4e6;
  --border:       #f0e0c8;
  --border-soft:  #f8ede0;

  --text:         #3a2a1a;
  --text-muted:   #9a7a5a;
  --text-dim:     #c4a882;

  /* Palette joyeuse */
  --rose:         #f4808a;
  --rose-soft:    #fde8ea;
  --amber:        #f5a623;
  --amber-soft:   #fef3d8;
  --teal:         #4db6ac;
  --teal-soft:    #e0f5f3;
  --lavender:     #9b7fd4;
  --lavender-soft:#f0eafb;
  --mint:         #66bb9a;
  --mint-soft:    #e6f7f0;

  --accent:       #f4808a;   /* rose principal */
  --accent-dark:  #e05a68;
  --accent-soft:  #fde8ea;

  --radius:       10px;
  --radius-lg:    16px;
  --radius-xl:    24px;
  --shadow-sm:    0 2px 8px rgba(180,120,80,0.08);
  --shadow:       0 4px 20px rgba(180,120,80,0.12);
  --shadow-lg:    0 12px 40px rgba(180,120,80,0.18);
  --transition:   0.22s cubic-bezier(0.4,0,0.2,1);

  --font-display: 'Playfair Display', Georgia, serif;
  --font-script:  'Dancing Script', cursive;
  --font-body:    'Nunito', sans-serif;
}

/* ── Reset ──────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* Confettis décoratifs en fond */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 15% 20%, rgba(244,128,138,0.06) 0%, transparent 40%),
    radial-gradient(circle at 85% 10%, rgba(155,127,212,0.07) 0%, transparent 35%),
    radial-gradient(circle at 70% 80%, rgba(77,182,172,0.06) 0%, transparent 40%),
    radial-gradient(circle at 10% 85%, rgba(245,166,35,0.06) 0%, transparent 35%);
  pointer-events: none;
  z-index: 0;
}

/* ── Layout ─────────────────────────────────── */
.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
  position: relative;
  z-index: 1;
}

/* ── Header ─────────────────────────────────── */
.site-header {
  background: rgba(255, 251, 245, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 2px solid var(--border);
  padding: 14px 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.site-logo {
  font-family: var(--font-script);
  font-size: 1.8rem;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.02em;
  line-height: 1;
}

.site-logo span {
  font-family: var(--font-body);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  display: block;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 2px;
}

/* ── Navigation ─────────────────────────────── */
nav { display: flex; gap: 6px; flex-wrap: wrap; }

.nav-btn {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: 2px solid transparent;
  padding: 7px 18px;
  border-radius: 50px;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.nav-btn:hover {
  color: var(--accent);
  background: var(--accent-soft);
}

.nav-btn.active {
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-color: var(--rose);
}

/* ── Main ───────────────────────────────────── */
main { padding: 40px 0 80px; }

.tab-section { display: none; }
.tab-section.active { display: block; }

/* ── Section header ─────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 32px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
}

.section-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 10px;
  border-radius: 50px;
}

/* ── Hero ───────────────────────────────────── */
.home-hero {
  text-align: center;
  padding: 56px 20px 48px;
  position: relative;
}

.home-hero::before {
  content: '💛';
  position: absolute;
  top: 20px; left: 10%;
  font-size: 2rem;
  opacity: 0.4;
  animation: float 4s ease-in-out infinite;
}
.home-hero::after {
  content: '🌸';
  position: absolute;
  top: 30px; right: 12%;
  font-size: 1.8rem;
  opacity: 0.4;
  animation: float 5s ease-in-out infinite reverse;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-10px); }
}

.home-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 6vw, 3.8rem);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 14px;
  color: var(--text);
}

.home-hero h1 em {
  font-style: italic;
  color: var(--accent);
}

.home-hero .subtitle {
  font-size: 1rem;
  color: var(--text-muted);
  max-width: 480px;
  margin: 0 auto 28px;
}

/* Boutons héro */
.hero-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* Compteur contributions */
.dedication {
  max-width: 580px;
  margin: 0 auto 28px;
  background: var(--amber-soft);
  border: 2px solid rgba(245,166,35,0.25);
  border-radius: var(--radius-lg);
  padding: 18px 24px;
  font-size: 0.95rem;
  color: #7a5010;
  line-height: 1.75;
  font-style: italic;
}

.contribution-banner {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--amber-soft);
  border: 2px solid rgba(245,166,35,0.3);
  border-radius: 50px;
  padding: 8px 20px;
  font-weight: 700;
  color: #a06010;
  font-size: 14px;
  margin-bottom: 32px;
}

/* ── Create form ────────────────────────────── */
.create-form {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px 32px;
  margin-bottom: 36px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.create-form:focus-within {
  border-color: var(--rose);
  box-shadow: var(--shadow), 0 0 0 4px rgba(244,128,138,0.08);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}

@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  background: var(--bg-soft);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  transition: border-color var(--transition), background var(--transition);
}

.form-input:focus {
  border-color: var(--rose);
  background: #fff;
}

.form-input::placeholder { color: var(--text-dim); }

.form-textarea {
  font-size: 15px;
  line-height: 1.7;
  resize: vertical;
  min-height: 130px;
  margin-bottom: 18px;
  font-family: var(--font-body);
}

.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.char-count {
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
}

/* ── Buttons ────────────────────────────────── */
.btn {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 700;
  border: none;
  border-radius: 50px;
  padding: 10px 24px;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 4px 14px rgba(244,128,138,0.35);
}
.btn-primary:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(244,128,138,0.4);
}
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

.btn-ghost {
  background: var(--bg-soft);
  color: var(--text-muted);
  border: 2px solid var(--border);
}
.btn-ghost:hover { border-color: var(--rose); color: var(--accent); background: var(--accent-soft); }

.btn-teal {
  background: var(--teal);
  color: #fff;
  box-shadow: 0 4px 14px rgba(77,182,172,0.3);
}
.btn-teal:hover { background: #3da99f; transform: translateY(-1px); }

.btn-danger {
  background: transparent;
  color: #e05a68;
  border: 1.5px solid rgba(240,100,110,0.3);
  padding: 5px 12px;
  font-size: 12px;
  border-radius: 50px;
}
.btn-danger:hover { background: var(--rose-soft); border-color: var(--rose); }

/* ── Poems grid ─────────────────────────────── */
.poems-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Poem card ──────────────────────────────── */
/* Rotation légère pour effet "post-it sur un mur" */
.poem-card:nth-child(3n+1) { --tilt: -0.8deg; }
.poem-card:nth-child(3n+2) { --tilt: 0.5deg; }
.poem-card:nth-child(3n)   { --tilt: -0.4deg; }

.poem-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  position: relative;
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  animation: fadeUp 0.4s cubic-bezier(0.4,0,0.2,1) both;
  transform: rotate(var(--tilt, 0deg));
}

.poem-card:hover {
  transform: rotate(0deg) translateY(-4px) scale(1.01);
  box-shadow: var(--shadow-lg);
  border-color: var(--rose);
  z-index: 2;
}

/* Couleur de fond douce alternée */
.poem-card:nth-child(4n+1) { background: #fff9f0; }
.poem-card:nth-child(4n+2) { background: #f8f4ff; }
.poem-card:nth-child(4n+3) { background: #f0fbf8; }
.poem-card:nth-child(4n)   { background: #fff5f5; }

/* Petite épingle décorative pour l'auteur connecté */
.poem-card.is-mine::before {
  content: '📌';
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1.2rem;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

.poem-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-style: italic;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
  line-height: 1.3;
}

.poem-body {
  font-size: 14px;
  line-height: 1.85;
  color: #5a4030;
  white-space: pre-wrap;
  max-height: 200px;
  overflow: hidden;
  mask-image: linear-gradient(to bottom, black 65%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 65%, transparent 100%);
}

.poem-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--border-soft);
  gap: 8px;
  flex-wrap: wrap;
}

.poem-author {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-dark);
}

.poem-date {
  font-size: 11px;
  color: var(--text-dim);
}

/* ── Canvas ─────────────────────────────────── */
.canvas-workspace {
  display: grid;
  grid-template-columns: 1fr 230px;
  gap: 24px;
  align-items: start;
}
@media (max-width: 760px) { .canvas-workspace { grid-template-columns: 1fr; } }

.canvas-container {
  background: #fff;
  border: 2px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow);
}

#drawing-canvas {
  display: block;
  width: 100%;
  cursor: crosshair;
  touch-action: none;
}

.canvas-toolbar {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: var(--shadow-sm);
}

.tool-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* Color swatches */
.color-swatches {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
}

.swatch {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}
.swatch:hover, .swatch.active {
  border-color: var(--text);
  transform: scale(1.15);
  box-shadow: var(--shadow);
}

#custom-color {
  width: 100%;
  height: 34px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--bg-soft);
  cursor: pointer;
}

.size-slider {
  width: 100%;
  appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}
.size-slider::-webkit-slider-thumb {
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(244,128,138,0.4);
}

.size-preview {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 36px;
}

.size-dot {
  border-radius: 50%;
  transition: var(--transition);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.tool-row { display: flex; gap: 6px; }
.tool-btn {
  flex: 1;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  padding: 8px 6px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}
.tool-btn:hover, .tool-btn.active {
  background: var(--accent-soft);
  color: var(--accent-dark);
  border-color: var(--rose);
}

/* ── Drawings gallery ───────────────────────── */
.drawings-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
  margin-top: 44px;
  padding-top: 28px;
  border-top: 2px dashed var(--border);
}

.gallery-title {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 4px;
  grid-column: 1 / -1;
}

.drawing-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: var(--transition);
  position: relative;
  animation: fadeUp 0.4s cubic-bezier(0.4,0,0.2,1) both;
  box-shadow: var(--shadow-sm);
}
.drawing-card:hover {
  border-color: var(--teal);
  box-shadow: var(--shadow);
  transform: translateY(-3px) scale(1.01);
}
.drawing-card img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
}
.drawing-meta {
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  border-top: 1px solid var(--border-soft);
}
.drawing-author { font-size: 12px; font-weight: 700; color: var(--teal); }
.drawing-date   { font-size: 11px; color: var(--text-dim); }

/* ── Home feed ──────────────────────────────── */
.home-feed {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
}
@media (max-width: 700px) { .home-feed { grid-template-columns: 1fr; gap: 28px; } }

.feed-column-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-style: italic;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.feed-poem {
  padding: 14px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border-soft);
  margin-bottom: 10px;
  background: var(--bg-card);
  transition: var(--transition);
}
.feed-poem:hover { border-color: var(--rose); box-shadow: var(--shadow-sm); }

.feed-poem-author {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 3px;
}
.feed-poem-title {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-style: italic;
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text);
}
.feed-poem-excerpt {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.7;
  white-space: pre-wrap;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.feed-drawing {
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 10px;
  border: 2px solid var(--border);
  transition: var(--transition);
}
.feed-drawing:hover { border-color: var(--teal); }
.feed-drawing img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }

/* ── Toast ──────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--bg-card);
  border: 2px solid var(--border);
  color: var(--text);
  padding: 13px 22px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.4,0,0.2,1);
  max-width: 300px;
}
#toast.show  { transform: translateY(0); opacity: 1; }
#toast.success { border-color: var(--mint); color: #2a7a5a; background: var(--mint-soft); }
#toast.error   { border-color: var(--rose); color: var(--accent-dark); background: var(--rose-soft); }

/* ── Saving overlay ─────────────────────────── */
.saving-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,251,245,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--accent);
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.saving-overlay.show { opacity: 1; pointer-events: all; }

/* ── Skeleton ───────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-soft) 25%, var(--border-soft) 50%, var(--bg-soft) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius);
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-dim);
  font-size: 1rem;
  grid-column: 1/-1;
}

/* ── Scrollbar ──────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--rose); }

/* ── Responsive ─────────────────────────────── */
@media (max-width: 600px) {
  .create-form { padding: 18px; }
  .poems-grid  { grid-template-columns: 1fr; }
  .poem-card   { transform: none !important; }
  #toast       { left: 16px; right: 16px; }
  .section-title { font-size: 1.5rem; }
}