/* Polices auto-hébergées (sous-ensemble latin, fichiers de @fontsource) */
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/cormorant-garamond-500.woff2') format('woff2');
}
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/cormorant-garamond-500-italic.woff2') format('woff2');
}
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: italic;
  font-weight: 600;
  font-display: swap;
  src: url('/fonts/cormorant-garamond-600-italic.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/fonts/inter-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('/fonts/inter-500.woff2') format('woff2');
}

:root {
  --ar: 1.395;
  --ink: #2e2622;
  --muted: #7b6e63;
  --line: #cfc3b4;
}
* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
}
body {
  min-height: 100svh;
  background: radial-gradient(120% 80% at 20% 0%, #f7f4ef 0%, #ede8e1 60%, #e6e0d7 100%);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-x: hidden;
}
main {
  width: 100%;
  max-width: 1240px;
  padding: 16px 16px 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
#defsHost {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}
.scene-wrap {
  position: relative;
  width: min(100%, calc((100svh - 130px) * var(--ar)));
  min-width: min(100%, 300px);
  aspect-ratio: var(--ar);
  border-radius: 6px;
  overflow: hidden;
  box-shadow:
    0 40px 70px -40px rgba(46, 38, 34, 0.45),
    0 2px 10px rgba(46, 38, 34, 0.08);
  background: #e9e3da;
}
#scene {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#scene:focus {
  outline: none;
}
.pick,
.vstem {
  cursor: pointer;
}
.pick {
  transition: filter 0.2s;
}
.bucket:hover .pick {
  filter: brightness(1.05) saturate(1.04);
}
.bucket:focus {
  outline: none;
}
.bucket:focus-visible .pick {
  filter: drop-shadow(0 0 3px #fff) drop-shadow(0 0 6px rgba(255, 255, 255, 0.8));
}
.vstem.sel {
  filter: drop-shadow(0 0 2px #fff) drop-shadow(0 0 6px rgba(255, 255, 255, 0.85));
}
svg.dragging,
svg.dragging * {
  cursor: grabbing !important;
}
.settle,
.insert {
  transform-box: view-box;
}
.settle {
  animation: settle 1s cubic-bezier(0.3, 0.7, 0.4, 1);
}
.insert {
  animation: insert 0.6s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
@keyframes settle {
  0% {
    transform: rotate(5deg);
  }
  25% {
    transform: rotate(-3.2deg);
  }
  48% {
    transform: rotate(1.8deg);
  }
  70% {
    transform: rotate(-0.8deg);
  }
  100% {
    transform: rotate(0);
  }
}
@keyframes insert {
  0% {
    transform: translate(0px, -80px);
    opacity: 0;
  }
  35% {
    opacity: 1;
  }
  100% {
    transform: translate(0px, 0px);
    opacity: 1;
  }
}

/* compteur, bulle de sélection et message, posés sur la scène */
.count {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  margin: 0;
  padding: 0.25em 0.8em;
  border-radius: 999px;
  font:
    italic 500 1rem/1.2 'Cormorant Garamond',
    Georgia,
    serif;
  color: #f7f2ea;
  background: rgba(46, 38, 34, 0.42);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  pointer-events: none;
  white-space: nowrap;
}
.bubble {
  position: absolute;
  transform: translate(-50%, calc(-100% - 10px));
  z-index: 3;
}
.bubble[hidden] {
  display: none;
}
.bubble button {
  padding: 0.7em 1.1em;
  background: var(--ink);
  color: #f7f2ea;
  border-color: var(--ink);
  box-shadow: 0 6px 18px -6px rgba(46, 38, 34, 0.6);
}
.bubble button:hover {
  background: #46392f;
}
.bubble::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: -5px;
  width: 10px;
  height: 10px;
  background: var(--ink);
  transform: translateX(-50%) rotate(45deg);
  border-radius: 2px;
}
.toast {
  position: absolute;
  left: 50%;
  top: 14px;
  transform: translate(-50%, -6px);
  margin: 0;
  padding: 0.55em 1em;
  border-radius: 999px;
  font-size: 0.8rem;
  color: #f7f2ea;
  background: rgba(138, 42, 62, 0.92);
  opacity: 0;
  transition:
    opacity 0.3s,
    transform 0.3s;
  pointer-events: none;
  max-width: calc(100% - 32px);
  text-align: center;
}
.toast.on {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* repère d'accueil : un point qui va de la source jusqu'au vase */
.coach {
  position: fixed;
  left: var(--x0);
  top: var(--y0);
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 5;
}
.coach[hidden] {
  display: none;
}
.coach span {
  position: absolute;
  left: -15px;
  top: -15px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(46, 38, 34, 0.42);
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow:
    0 4px 14px rgba(46, 38, 34, 0.35),
    0 0 0 8px rgba(46, 38, 34, 0.12);
  animation: coach 2.8s ease-in-out infinite;
}
@keyframes coach {
  0% {
    transform: translate(0, 0) scale(0.5);
    opacity: 0;
  }
  12% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  22% {
    transform: translate(0, 0) scale(0.82);
    opacity: 1;
  }
  72% {
    transform: translate(var(--dx), var(--dy)) scale(0.82);
    opacity: 1;
  }
  86% {
    transform: translate(var(--dx), var(--dy)) scale(1.25);
    opacity: 0;
  }
  100% {
    opacity: 0;
  }
}

.bar {
  width: min(100%, 1000px);
  display: flex;
  justify-content: center;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}
button {
  font:
    500 0.74rem/1 'Inter',
    system-ui,
    sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  gap: 0.7em;
  padding: 1.05em 1.5em;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.5);
  color: var(--ink);
  cursor: pointer;
  transition:
    background 0.2s,
    border-color 0.2s,
    color 0.2s,
    opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
}
button svg {
  width: 1.4em;
  height: 1.4em;
  flex: none;
}
button:hover {
  background: #fff;
  border-color: #a99683;
}
button:active {
  background: #f4efe8;
}
button:focus-visible {
  outline: 2px solid #8e7a66;
  outline-offset: 3px;
}
button[aria-pressed='true'] {
  border-color: #9a3348;
  color: #8a2a3e;
  background: #fbf2f3;
}
button.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #f7f2ea;
}
button.primary:hover {
  background: #46392f;
  border-color: #46392f;
}
button.confirm {
  border-color: #9a3348;
  background: #9a3348;
  color: #fff;
}
button:disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}
button.busy {
  opacity: 0.6;
  cursor: progress;
}

/* plateau de fleurs (mobile) */
.tray {
  display: none;
}
.card {
  flex: none;
  width: 82px;
  height: 98px;
  padding: 6px 4px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  border-radius: 16px;
  border: 1px solid rgba(207, 195, 180, 0.8);
  background: linear-gradient(#fffdf9, #f3eee7);
  box-shadow: 0 6px 14px -10px rgba(46, 38, 34, 0.5);
  font:
    500 0.66rem/1.1 'Inter',
    system-ui,
    sans-serif;
  letter-spacing: 0.02em;
  text-transform: none;
  scroll-snap-align: start;
  touch-action: pan-x;
  user-select: none;
  -webkit-user-select: none;
}
.card svg {
  width: 62px;
  height: 62px;
  pointer-events: none;
}
.card span {
  pointer-events: none;
  white-space: nowrap;
}
.card:active {
  background: #f1ebe2;
}

footer {
  margin-top: auto;
  padding: 6px 16px 14px;
}
footer a {
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  color: #8e8276;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
footer a:hover,
footer a:focus-visible {
  color: var(--ink);
  border-bottom-color: currentColor;
}

@media (max-width: 700px) {
  body {
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }
  main {
    flex: 1 1 auto;
    min-height: 0;
    max-width: none;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
    gap: 0;
  }
  .scene-wrap {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    min-width: 0;
    aspect-ratio: auto;
    border-radius: 0;
    box-shadow: none;
  }
  .bar {
    order: 2;
    padding: 8px 10px 4px;
    background: #f1ece5;
    border-top: 1px solid rgba(207, 195, 180, 0.6);
  }
  .actions {
    flex-wrap: nowrap;
    gap: 6px;
    width: 100%;
  }
  .actions button {
    flex: 1 1 0;
    min-width: 0;
    min-height: 52px;
    padding: 0.55em 0.3em;
    flex-direction: column;
    gap: 0.4em;
    border-radius: 14px;
    font-size: 0.6rem;
    letter-spacing: 0.08em;
  }
  .actions button.primary {
    flex-grow: 1.25;
    letter-spacing: 0.04em;
  }
  .tray {
    order: 3;
    display: flex;
    gap: 8px;
    width: 100%;
    padding: 6px 12px calc(8px + env(safe-area-inset-bottom));
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-padding: 0 12px;
    background: #f1ece5;
    scrollbar-width: none;
  }
  .tray::-webkit-scrollbar {
    display: none;
  }
  .tray {
    padding-bottom: 4px;
  }
  footer {
    order: 4;
    width: 100%;
    text-align: center;
    padding: 0 0 calc(4px + env(safe-area-inset-bottom));
    background: #f1ece5;
  }
  footer a {
    font-size: 0.62rem;
  }
  .count {
    font-size: 0.95rem;
    bottom: 8px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .settle,
  .insert {
    animation: none;
  }
  .pick,
  button,
  .toast {
    transition: none;
  }
  .coach span {
    animation: none;
    opacity: 0.9;
  }
}

/* mentions légales et confidentialité */
.legal {
  width: min(640px, calc(100% - 32px));
  max-height: min(86dvh, 780px);
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: #fbf8f3;
  color: var(--ink);
  box-shadow:
    0 30px 80px -30px rgba(46, 38, 34, 0.6),
    0 2px 10px rgba(46, 38, 34, 0.12);
  overscroll-behavior: contain;
}
.legal::backdrop {
  background: rgba(46, 38, 34, 0.42);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.legal-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px 12px 24px;
  background: #fbf8f3;
  border-bottom: 1px solid rgba(207, 195, 180, 0.7);
}
.legal-lang {
  display: flex;
  gap: 6px;
}
.legal-lang button {
  padding: 0.7em 1em;
  font-size: 0.66rem;
}
.legal-close {
  padding: 0.65em;
}
.legal-text {
  padding: 6px 24px 26px;
}
.legal-text h2 {
  margin: 0.5em 0 0.1em;
  font:
    italic 500 2rem/1.15 'Cormorant Garamond',
    Georgia,
    serif;
  color: #3b2826;
}
.legal-text h3 {
  margin: 1.3em 0 0.35em;
  font:
    500 1.3rem/1.2 'Cormorant Garamond',
    Georgia,
    serif;
  color: #3b2826;
}
.legal-text p,
.legal-text li {
  margin: 0 0 0.6em;
  font-size: 0.86rem;
  line-height: 1.6;
  color: #4a3f38;
}
.legal-text ul {
  margin: 0 0 0.6em;
  padding-left: 1.2em;
}
.legal-text a {
  color: #8a2a3e;
  text-underline-offset: 2px;
}

/* page introuvable */
.lost {
  flex: 1 1 auto;
  justify-content: center;
  gap: 0;
  padding: 32px 16px;
  text-align: center;
}
.lost img {
  width: 72px;
  height: 72px;
  margin-bottom: 18px;
}
.lost h1 {
  margin: 0 0 0.25em;
  font:
    italic 500 3rem/1.1 'Cormorant Garamond',
    Georgia,
    serif;
  color: #3b2826;
}
.lost p {
  margin: 0 0 1.8em;
  color: var(--muted);
}
.lost a {
  display: inline-flex;
  align-items: center;
  padding: 1.05em 1.5em;
  border-radius: 999px;
  font:
    500 0.74rem/1 'Inter',
    system-ui,
    sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-decoration: none;
  background: var(--ink);
  color: #f7f2ea;
  transition: background 0.2s;
}
.lost a:hover {
  background: #46392f;
}
.lost a:focus-visible {
  outline: 2px solid #8e7a66;
  outline-offset: 3px;
}
@media (max-width: 700px) {
  .legal-text {
    padding: 4px 18px 22px;
  }
  .legal-head {
    padding-left: 18px;
  }
  .lost {
    padding: 32px 16px;
  }
}
