:root {
  --cream: #f7ecd8;
  --paper: #fffaf1;
  --caramel: #c7772a;
  --caramel-dark: #8b4712;
  --caramel-light: #f2b86a;
  --choco: #3a1f0b;
  --ink: #3a2412;
  --muted: #7a5a3e;
  --radius: 28px;
  --display: "Fraunces", Georgia, serif;
  --sans: "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* Le "scroller" : un seul conteneur qu'on peut retourner de 180° */
#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background:
    radial-gradient(120% 60% at 50% 0%, #fdf4e3 0%, transparent 60%),
    var(--cream);
}
body.is-open #app {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#app.is-rotated { transform: rotate(180deg); }

#content { position: relative; min-height: 100%; }

/* ---------- Fil de caramel ---------- */
.thread {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: visible;
  opacity: 0;
  transition: opacity .3s;
}
body.is-open .thread { opacity: 1; }
.thread-path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.thread-main { stroke: var(--caramel); stroke-width: 10; }
.thread-shine { stroke: var(--caramel-light); stroke-width: 3; transform: translateX(-2px); opacity: .8; }
.thread-head { fill: var(--caramel); opacity: 0; }

/* ---------- Hero ---------- */
.hero {
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  text-align: center;
}
.hero > * { position: relative; z-index: 1; }

.kicker {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--caramel-dark);
}
.brand h1 {
  margin: 6px 0 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(40px, 11vw, 84px);
  line-height: .95;
  letter-spacing: -.02em;
  color: var(--choco);
}

/* ---------- Tube ---------- */
.tube {
  all: unset;
  cursor: pointer;
  height: 50vh;
  height: 50svh;
  max-height: 460px;
  aspect-ratio: 200 / 420;
  filter: drop-shadow(0 18px 24px rgba(90, 45, 10, .25));
}
body.is-open .tube { cursor: default; }
.tube:focus-visible { outline: 3px solid var(--caramel); outline-offset: 8px; border-radius: 12px; }

.tube-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
  transition: transform 1.1s cubic-bezier(.65, 0, .25, 1);
}
body:not(.is-open) .tube:hover .tube-svg { transform: rotate(-6deg); transition-duration: .4s; }
body.is-open .tube-svg { transform: rotate(180deg); }

.tube-label {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 1.1s cubic-bezier(.65, 0, .25, 1);
}
body.is-open .tube-label { transform: rotate(180deg); }

.lbl-big { font: 800 26px var(--display); fill: var(--choco); letter-spacing: .04em; }
.lbl-mid { font: 800 19px var(--display); fill: var(--choco); letter-spacing: .06em; }
.lbl-it  { font: italic 500 15px var(--display); fill: var(--caramel-dark); }
.lbl-sm  { font: 500 10px var(--sans); fill: var(--muted); letter-spacing: .12em; text-transform: uppercase; }

.tube-cap {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform .7s cubic-bezier(.3, 0, .6, 1) .9s, opacity .5s ease .9s;
}
body.is-open .tube-cap { transform: translate(36px, -90px) rotate(55deg); opacity: 0; }

/* Ouverture déclenchée par le téléphone : le tube ne bouge pas par rapport à l'écran */
body.instant-flip .tube-svg,
body.instant-flip .tube-label { transition: none; }
body.instant-flip .tube-cap { transition-delay: .25s, .25s; }

/* ---------- Indications ---------- */
.hints { min-height: 112px; display: flex; align-items: center; justify-content: center; }
.hint { display: none; flex-direction: column; align-items: center; gap: 10px; }
.hint p { margin: 0; font-family: var(--display); font-size: 20px; line-height: 1.2; }
.hint small { font-family: var(--sans); font-size: 13px; color: var(--muted); }

.btn-motion { display: none; }
body.needs-tap .btn-motion { display: inline-block; }

body[data-mode="sensor"]:not(.is-open) .hint-sensor,
body[data-mode="desktop"]:not(.is-open) .hint-desktop,
body.is-open .hint-scroll { display: flex; }

.hint-scroll {
  background: var(--paper);
  padding: 10px 22px 8px;
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(90, 45, 10, .12);
  animation: fadeUp .6s ease 2.2s both;
}
.hint-scroll p { font-size: 17px; font-style: italic; }
.arrow { font-size: 20px; color: var(--caramel); animation: bob 1.4s ease-in-out infinite; }

.phone {
  width: 26px; height: 44px;
  border: 3px solid var(--choco);
  border-radius: 7px;
  position: relative;
  animation: flip 2.6s cubic-bezier(.65, 0, .25, 1) infinite;
}
.phone::after {
  content: "";
  position: absolute;
  top: 3px; left: 50%;
  width: 8px; height: 3px;
  margin-left: -4px;
  border-radius: 2px;
  background: var(--choco);
}

.btn {
  font: 700 15px var(--sans);
  color: var(--paper);
  background: var(--choco);
  border: 0;
  border-radius: 999px;
  padding: 14px 24px;
  cursor: pointer;
  transition: transform .15s, background .2s;
}
.btn:hover { background: var(--caramel-dark); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .6; cursor: wait; }

.link {
  font: 500 13px var(--sans);
  color: var(--muted);
  background: none;
  border: 0;
  padding: 4px;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

/* ---------- Sections ---------- */
.sections {
  max-width: 680px;
  margin: 0 auto;
  padding: 18vh 16px 0;
  display: flex;
  flex-direction: column;
  gap: 22vh;
}
.card {
  position: relative;
  z-index: 1;
  background: var(--paper);
  border-radius: var(--radius);
  padding: clamp(24px, 5vw, 40px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .8) inset, 0 20px 50px -20px rgba(90, 45, 10, .25);
}
.card h2 {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(28px, 6vw, 40px);
  line-height: 1.05;
  letter-spacing: -.01em;
  margin: 10px 0 16px;
  color: var(--choco);
}
.card p { line-height: 1.65; margin: 0 0 12px; color: var(--ink); }
.card p:last-child { margin-bottom: 0; }

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}
.features .card { padding: 24px; }
.features h3 { font-family: var(--display); font-size: 22px; margin: 8px 0; color: var(--choco); }
.num { font: 800 14px var(--display); color: var(--caramel); }

.quote { text-align: center; background: var(--choco); color: var(--paper); }
.quote blockquote {
  margin: 0 0 12px;
  font-family: var(--display);
  font-style: italic;
  font-size: clamp(22px, 5vw, 30px);
  line-height: 1.25;
}
.quote cite { font-style: normal; font-size: 14px; color: var(--caramel-light); }

/* Le fil "nourrit" le formulaire quand il l'atteint */
.join { overflow: visible; }
.join::before {
  content: "";
  position: absolute;
  top: -2px; left: 50%;
  width: 70px; height: 26px;
  margin-left: -35px;
  background: var(--caramel);
  border-radius: 0 0 35px 35px;
  transform: scaleY(0);
  transform-origin: top;
  transition: transform .6s cubic-bezier(.3, 1.4, .5, 1);
}
.join.is-fed::before { transform: scaleY(1); }

.join-form { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.join-form input {
  flex: 1 1 220px;
  min-width: 0;
  font: 16px var(--sans);
  color: var(--ink);
  background: var(--cream);
  border: 2px solid transparent;
  border-radius: 999px;
  padding: 14px 20px;
  outline: none;
  transition: border-color .2s;
}
.join-form input:focus { border-color: var(--caramel); }
.join-form input[aria-invalid="true"] { border-color: #b3261e; }
.join-form .btn { flex: 0 0 auto; }
.form-msg { min-height: 1.4em; margin-top: 12px !important; font-size: 14px; }
.form-msg.is-error { color: #b3261e; }
.form-msg.is-success { color: #2e6b2f; }

.footer {
  position: relative;
  z-index: 1;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  padding: 20vh 16px max(32px, env(safe-area-inset-bottom));
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

@keyframes flip {
  0%, 20% { transform: rotate(0); }
  50%, 70% { transform: rotate(180deg); }
  100% { transform: rotate(360deg); }
}
@keyframes bob { 50% { transform: translateY(5px); } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; transition-delay: 0s !important; }
}
