/* Thème « Cocon » : papier crème, vert sauge, terracotta */
:root {
  --bg: #f5efe4;
  --surface: #fffaf1;
  --surface-2: #efe6d6;
  --line: #e3d7c2;
  --text: #2d3a2e;
  --muted: #6c7565;
  --sage: #6f9a74;
  --sage-soft: #dbe7d6;
  --forest: #3f6447;
  --terra: #d0744c;
  --terra-soft: #f6dccd;
  --sun: #e9b44c;
  --sky: #cfe3e4;
  --on-accent: #fffaf1;
  --shadow: 0 1px 0 rgba(45, 58, 46, 0.04), 0 12px 32px -18px rgba(63, 100, 71, 0.35);
  --radius: 28px;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0.2 0 0 0 0 0.2 0 0 0 0 0.15 0 0 0 .06 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171d18;
    --surface: #1f2720;
    --surface-2: #273127;
    --line: #334033;
    --text: #ece5d6;
    --muted: #a5ad9c;
    --sage: #8fb893;
    --sage-soft: #2c3b2d;
    --forest: #b6d3b6;
    --terra: #e48c63;
    --terra-soft: #4a3226;
    --sun: #e6b85c;
    --sky: #26363a;
    --on-accent: #1b1410;
    --shadow: 0 12px 32px -18px rgba(0, 0, 0, 0.6);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }

body {
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg) var(--grain);
  min-height: 100vh;
  line-height: 1.6;
  overflow-x: hidden;
}

h1, h2, h3, .logo, .quote, .breath-circle { font-family: "Fraunces", Georgia, serif; font-weight: 600; }
a { color: inherit; }

.eyebrow {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--terra);
  margin-bottom: 6px;
}
.small { color: var(--muted); font-size: 0.95rem; }

/* Navigation */
.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px clamp(16px, 4vw, 40px);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.logo { font-size: 1.35rem; text-decoration: none; display: flex; align-items: center; gap: 8px; }
.logo-mark {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: 50% 50% 50% 12px;
  background: var(--sage-soft);
  font-size: 1rem;
}
.nav nav { display: flex; gap: 2px; flex-wrap: wrap; }
.nav nav a {
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 10px;
  font-weight: 500;
  color: var(--muted);
  transition: color 0.2s, background 0.2s;
}
.nav nav a:hover { color: var(--text); background: var(--surface-2); }
.nav nav a.nav-help { color: var(--terra); }

main { max-width: 960px; margin: 0 auto; padding: 0 16px 40px; }

/* Hero */
.hero {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  align-items: center;
  gap: 24px;
  padding: 64px 0 40px;
}
.hero h1 { font-size: clamp(2.2rem, 5.5vw, 3.6rem); line-height: 1.08; letter-spacing: -0.02em; margin-bottom: 16px; }
.hero h1 em { font-style: italic; color: var(--sage); }
.subtitle { color: var(--muted); font-size: 1.12rem; max-width: 480px; }

.hero-art { width: 100%; max-width: 340px; justify-self: center; }
.art-sun { fill: var(--sun); opacity: 0.85; animation: breathe 9s ease-in-out infinite; transform-origin: 210px 110px; }
.art-hill2 { fill: var(--sage-soft); }
.art-hill1 { fill: var(--sage); }
.art-leaf path { fill: var(--forest); }
.art-leaf .art-vein { fill: none; stroke: var(--sage-soft); stroke-width: 2; }
.art-leaf { animation: sway 6s ease-in-out infinite; transform-origin: 70px 250px; }
.art-leaf.small { transform-origin: 250px 268px; animation-delay: -2s; }
@keyframes breathe { 50% { transform: scale(1.06); } }
@keyframes sway { 50% { transform: rotate(-5deg); } }

.mood { margin-top: 32px; }
.mood-q { font-weight: 700; }
.mood-buttons { display: flex; gap: 8px; margin: 12px 0; flex-wrap: wrap; }
.mood-buttons button {
  font-size: 1.7rem;
  width: 56px; height: 56px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, background 0.2s;
}
.mood-buttons button:hover { transform: translateY(-3px); border-color: var(--sage); }
.mood-buttons button.selected { background: var(--sage-soft); border-color: var(--sage); }
.mood-answer { min-height: 1.6em; font-weight: 500; max-width: 520px; }
.mood-help {
  margin-top: 14px;
  padding: 16px;
  border-radius: 20px;
  background: var(--terra-soft);
  max-width: 560px;
}
.mood-help p { font-weight: 500; margin-bottom: 10px; }

/* Blocs */
.block {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(28px, 5vw, 44px) clamp(18px, 4vw, 40px);
  margin: 28px 0;
  text-align: center;
}
.block h2 { font-size: clamp(1.6rem, 4vw, 2.1rem); letter-spacing: -0.01em; margin-bottom: 8px; }
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }

.btn {
  display: inline-block;
  border: none;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  font-size: 0.98rem;
  padding: 12px 22px;
  border-radius: 14px;
  color: var(--on-accent);
  background: var(--terra);
  text-decoration: none;
  transition: transform 0.15s, background 0.2s, box-shadow 0.2s;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.ghost:hover { box-shadow: inset 0 0 0 1.5px var(--sage); }
.btn:focus-visible, .tab:focus-visible, .mood-buttons button:focus-visible, a:focus-visible {
  outline: 3px solid var(--sun);
  outline-offset: 2px;
}

/* Phrases */
.quote-card {
  position: relative;
  margin: 22px auto 0;
  padding: 40px 28px 34px;
  border-radius: 24px;
  background: var(--sage-soft);
  max-width: 660px;
}
.quote-card::before {
  content: "“";
  position: absolute;
  top: -18px; left: 22px;
  font-family: "Fraunces", serif;
  font-size: 5rem;
  line-height: 1;
  color: var(--terra);
}
.quote { font-size: clamp(1.25rem, 3.4vw, 1.75rem); font-weight: 400; font-style: italic; line-height: 1.35; }
.fade { animation: fadeUp 0.6s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } }

/* Onglets */
.tabs {
  display: inline-flex;
  gap: 4px;
  flex-wrap: wrap;
  justify-content: center;
  margin: 22px 0;
  padding: 5px;
  border-radius: 18px;
  background: var(--surface-2);
}
.tab {
  border: none;
  cursor: pointer;
  padding: 9px 14px;
  border-radius: 13px;
  font: inherit;
  font-weight: 500;
  font-size: 0.93rem;
  background: transparent;
  color: var(--muted);
  transition: background 0.2s, color 0.2s;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--text); box-shadow: 0 2px 8px -4px rgba(0, 0, 0, 0.25); }

.game { display: none; }
.game.active { display: block; animation: fadeUp 0.4s ease; }
.game-bar {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  color: var(--muted);
}
.game-bar span { padding: 4px 12px; border-radius: 999px; background: var(--surface-2); }
.game-bar b { color: var(--text); margin-left: 4px; }

/* Attrape les cœurs */
.playfield {
  position: relative;
  height: 380px;
  border-radius: 22px;
  overflow: hidden;
  background: linear-gradient(180deg, var(--sky), var(--terra-soft));
  touch-action: manipulation;
  user-select: none;
}
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px;
  font-weight: 500;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  backdrop-filter: blur(3px);
  z-index: 2;
}
.floater {
  position: absolute;
  bottom: -60px;
  border: none;
  background: none;
  cursor: pointer;
  line-height: 1;
  animation: floatUp linear forwards;
}
@keyframes floatUp {
  0% { transform: translate(0, 0); }
  25% { transform: translate(14px, -120px); }
  50% { transform: translate(-14px, -240px); }
  75% { transform: translate(14px, -360px); }
  100% { transform: translate(0, -470px); }
}

/* Memory */
.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  max-width: 400px;
  margin: 0 auto;
}
.mcard { position: relative; aspect-ratio: 1; border: none; background: none; cursor: pointer; perspective: 600px; }
.mcard span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: 16px;
  font-size: 2rem;
  backface-visibility: hidden;
  transition: transform 0.45s;
}
.mcard .back {
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.18) 0 18%, transparent 19%),
    var(--sage);
  font-size: 1.4rem;
}
.mcard .front { background: var(--surface-2); border: 1px solid var(--line); transform: rotateY(180deg); }
.mcard.flipped .back { transform: rotateY(-180deg); }
.mcard.flipped .front { transform: rotateY(0); }
.mcard.matched .front { background: var(--sage-soft); border-color: var(--sage); animation: bounce 0.5s; }
@keyframes bounce { 50% { transform: scale(1.1); } }

/* Papier bulle */
.bubble-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  max-width: 440px;
  margin: 0 auto;
  padding: 14px;
  border-radius: 20px;
  background: var(--surface-2);
}
.bubble {
  aspect-ratio: 1;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  background: radial-gradient(circle at 32% 30%, rgba(255, 255, 255, 0.95) 0 14%, var(--sky) 45%, var(--sage-soft) 100%);
  box-shadow: inset -2px -3px 5px rgba(0, 0, 0, 0.08), 0 2px 5px rgba(0, 0, 0, 0.08);
  transition: transform 0.12s;
  touch-action: manipulation;
}
.bubble:hover { transform: scale(1.06); }
.bubble.popped { transform: scale(0.72); background: var(--line); box-shadow: none; cursor: default; }
.bubble-msg { margin-top: 16px; font-weight: 700; min-height: 1.6em; }
.bubble-msg.pop { animation: bounce 0.4s; color: var(--terra); }

/* Jardin */
.garden {
  position: relative;
  height: 340px;
  border-radius: 22px;
  overflow: hidden;
  cursor: crosshair;
  background:
    radial-gradient(circle at 82% 22%, var(--sun) 0 34px, transparent 35px),
    linear-gradient(180deg, var(--sky) 0%, var(--sky) 55%, var(--sage) 55.5%, var(--forest) 130%);
}
.garden-hint {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  font-weight: 700;
  pointer-events: none;
}
.flower {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: grow 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes grow { from { transform: translate(-50%, -50%) scale(0); } }
.butterfly {
  position: absolute;
  top: 20%;
  left: 0;
  font-size: 1.6rem;
  pointer-events: none;
  animation: flutter 8s ease-in-out infinite;
}
@keyframes flutter {
  0% { left: -5%; top: 30%; }
  25% { top: 10%; }
  50% { left: 50%; top: 35%; }
  75% { top: 15%; }
  100% { left: 105%; top: 25%; }
}

/* Respiration */
.breath-wrap { display: grid; place-items: center; height: 280px; }
.breath-circle {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--on-accent);
  font-size: 1.1rem;
  font-style: italic;
  background: var(--sage);
  box-shadow: 0 0 0 16px var(--sage-soft), 0 0 0 34px color-mix(in srgb, var(--sage-soft) 45%, transparent);
  transition: transform 800ms ease-in-out;
}
.breath-circle.grow { transform: scale(1.75); }

/* Bocal */
.jar-form { display: flex; gap: 8px; max-width: 520px; margin: 18px auto 0; }
.jar-form input {
  flex: 1;
  min-width: 0;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  outline: none;
}
.jar-form input:focus { border-color: var(--sage); }
.jar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  align-content: flex-start;
  min-height: 150px;
  max-width: 600px;
  margin: 20px auto 0;
  padding: 24px 20px;
  border-radius: 26px 26px 60px 60px;
  border: 2px dashed var(--line);
  background: var(--bg);
}
.note {
  padding: 8px 14px;
  border-radius: 6px;
  background: #f7e3a8;
  color: #4a3b1d;
  font-weight: 500;
  font-size: 0.95rem;
  rotate: var(--r);
  box-shadow: 0 4px 10px -4px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  animation: pop 0.4s ease;
}
.note:nth-child(3n) { background: #f4cdb8; }
.note:nth-child(3n+1) { background: #cfe2c9; }
.note:hover { text-decoration: line-through; }
@keyframes pop { from { scale: 0; } }
.jar-empty { color: var(--muted); align-self: center; }
.jar-picked { margin-top: 14px; font-weight: 700; min-height: 1.6em; }

/* Aide */
.help-block { background: var(--surface); border-color: var(--terra-soft); }
.help-group { margin-top: 26px; text-align: left; }
.help-group h3 { font-size: 1.15rem; margin-bottom: 10px; }
.help-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.help-grid.compact { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); text-align: left; }
.line {
  display: grid;
  gap: 2px;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: var(--bg);
  text-decoration: none;
  transition: border-color 0.2s, transform 0.15s;
}
.line:hover { border-color: var(--sage); transform: translateY(-2px); }
.line.main { background: var(--terra-soft); border-color: transparent; }
.line-num { font-family: "Fraunces", serif; font-size: 1.45rem; font-weight: 600; color: var(--terra); line-height: 1.2; }
.line-name { font-weight: 700; }
.line-info { font-size: 0.86rem; color: var(--muted); }
.help-note { margin-top: 20px; }

.help-fab {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.35);
  transition: transform 0.2s;
}
.help-fab:hover { transform: translateY(-2px); }

.help-dialog {
  margin: auto;
  width: min(520px, calc(100% - 32px));
  padding: 30px 24px 24px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--surface);
  color: var(--text);
  text-align: center;
  box-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.45);
}
.help-dialog::backdrop { background: rgba(23, 29, 24, 0.45); backdrop-filter: blur(3px); }
.help-dialog h2 { font-size: 1.6rem; margin-bottom: 4px; }
.help-dialog .help-grid { margin: 18px 0; }
.dialog-close {
  position: absolute;
  top: 12px; right: 14px;
  width: 36px; height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.4rem;
  cursor: pointer;
}

.help-banner {
  position: fixed;
  left: 50%;
  top: 76px;
  transform: translateX(-50%);
  z-index: 45;
  width: min(560px, calc(100% - 32px));
  padding: 16px 18px;
  border-radius: 20px;
  background: var(--forest);
  color: var(--bg);
  box-shadow: 0 20px 40px -18px rgba(0, 0, 0, 0.5);
  animation: slideDown 0.4s ease;
}
.help-banner p { font-weight: 500; }
.help-banner-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.help-banner .btn.ghost { color: var(--bg); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--bg) 40%, transparent); }
.small-btn { padding: 8px 14px; font-size: 0.9rem; }
.link-btn { border: none; background: none; color: inherit; opacity: 0.75; font: inherit; font-size: 0.85rem; text-decoration: underline; cursor: pointer; }
@keyframes slideDown { from { opacity: 0; transform: translate(-50%, -12px); } }

/* Footer */
footer { text-align: center; padding: 30px 16px 90px; }

/* Toast & confettis */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 120px);
  padding: 12px 22px;
  border-radius: 16px;
  background: var(--text);
  color: var(--bg);
  font-weight: 700;
  transition: transform 0.35s ease;
  z-index: 50;
  max-width: calc(100% - 32px);
  text-align: center;
}
.toast.show { transform: translate(-50%, 0); }

.confetti {
  position: fixed;
  pointer-events: none;
  z-index: 60;
  font-size: 1.2rem;
  animation: burst 1s ease-out forwards;
}
@keyframes burst { to { transform: translate(var(--dx), var(--dy)) scale(0.4); opacity: 0; } }

@media (max-width: 720px) {
  .hero { grid-template-columns: 1fr; padding-top: 40px; text-align: left; }
  .hero-art { max-width: 220px; grid-row: 1; justify-self: start; }
}

@media (max-width: 560px) {
  .nav { justify-content: center; }
  .bubble-grid { gap: 6px; padding: 10px; }
  .playfield { height: 340px; }
  .mcard span { font-size: 1.6rem; }
  .help-fab span { display: none; }
  .help-fab { padding: 14px; }
}

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