/* hom — le site public, suite : le parcours (fil des chapitres), l'ouverture illustrée, la carte du cocoon,
   les wools et l'installation. S'appuie sur les variables et les composants de style.css. */

/* --- Le parcours : une barre qui avance, un fil de toits sur le côté, et « ensuite » en bas de chapitre --- */
.nav-progress {
  position: absolute; left: 0; bottom: 0; height: 2px; width: 100%; background: var(--amber);
  transform-origin: 0 50%; transform: scaleX(var(--p, 0)); opacity: 0; transition: opacity 0.3s;
}
.nav.scrolled .nav-progress { opacity: 0.9; }

.rail {
  position: fixed; right: 14px; top: 50%; transform: translateY(-50%); z-index: 40;
  display: none; flex-direction: column; gap: 2px; padding: 10px 6px; border-radius: 999px;
  background: rgba(31, 29, 26, 0.8); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: inset 0 0 0 1px rgba(244, 239, 230, 0.1);
}
@media (min-width: 1280px) { .rail { display: flex; } }
.rail a {
  position: relative; display: grid; justify-items: center; align-content: center; gap: 2px; width: 34px; height: 32px;
  color: rgba(244, 239, 230, 0.32); text-decoration: none; border-radius: 12px; transition: color 0.3s;
}
.rail a svg { width: 20px; height: 11px; }
.rail a i {
  width: 9px; height: 4.5px; border-radius: 5px 5px 0 0; background: var(--amber);
  opacity: 0; transform: translateY(4px) scale(0.5); transition: 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.rail a.seen { color: rgba(244, 239, 230, 0.7); }
.rail a.current, .rail a:hover { color: var(--cream); }
.rail a.current i { opacity: 1; transform: none; }
.rail a span {
  position: absolute; right: calc(100% + 12px); top: 50%; transform: translate(6px, -50%); white-space: nowrap;
  padding: 6px 12px; border-radius: 999px; background: rgba(31, 29, 26, 0.94); color: var(--cream);
  font-size: 13px; font-weight: 600; opacity: 0; pointer-events: none; transition: 0.2s;
  box-shadow: inset 0 0 0 1px rgba(244, 239, 230, 0.1);
}
.rail a:hover span, .rail a:focus-visible span { opacity: 1; transform: translate(0, -50%); }

.next {
  grid-column: 1 / -1; justify-self: start; width: fit-content;
  display: flex; align-items: center; gap: 14px; margin-top: clamp(44px, 6vw, 76px);
  padding: 10px 22px 10px 12px; border-radius: 999px; text-decoration: none;
  font: 650 17px/1.2 var(--text); box-shadow: inset 0 0 0 1.5px var(--stroke);
  transition: box-shadow 0.2s, transform 0.2s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.next:hover { box-shadow: inset 0 0 0 1.5px currentColor; transform: translateX(4px); }
.next .next-mark { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.next .next-mark svg { width: 26px; height: 26px; }
.next small { display: block; font-size: 12px; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.next > svg { width: 20px; height: 20px; }

/* --- Ouverture : le texte à gauche, le cocoon au soir dans sa fenêtre à droite --- */
.hero-inner { grid-template-columns: 1.08fr 0.92fr; align-items: center; gap: clamp(28px, 5vw, 72px); padding: calc(var(--nav-h) + 48px) 24px 96px; }
.hero-text { display: grid; gap: 26px; justify-items: start; }
.hero h1 { font-size: clamp(44px, 6.2vw, 80px); }
.hero .lead strong { color: var(--cream); font-weight: 650; }
.hero-facts { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.hero-facts li { padding: 7px 13px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--mute-on-dark); box-shadow: inset 0 0 0 1px rgba(244, 239, 230, 0.14); }
.hero-art { position: relative; width: min(100%, 470px); justify-self: end; }
.scene { width: 100%; height: auto; filter: drop-shadow(0 40px 50px rgba(0, 0, 0, 0.45)); }
.scene-roof { stroke-dasharray: 1; stroke-dashoffset: 0; }
.scene-wool { position: absolute; }
.scene-wool svg { width: 100%; height: auto; overflow: visible; }
.scene-wool.w1 { left: 4%; bottom: 0.5%; width: 44%; }
.scene-wool.w2 { right: 5%; bottom: 0; width: 38%; transform: scaleX(-1); }
/* La paupière des wools : repliée par défaut, elle ne descend que le temps d'un clignement. */
/* Alto accompagne la lecture : il trottine au bas de l'écran quand la page défile. */
.wool-walker { position: fixed; left: 0; bottom: 0; z-index: 30; width: clamp(60px, 6.5vw, 92px); pointer-events: none; transition: opacity 0.35s, translate 0.35s; }
.wool-walker.away { opacity: 0; translate: 0 40%; }
.wool-walker span { display: none; }
.wool-walker[data-face='calm'] [data-face='calm'], .wool-walker[data-face='content'] [data-face='content'], .wool-walker[data-face='sleepy'] [data-face='sleepy'] { display: block; }
.wool-walker svg { width: 100%; height: auto; overflow: visible; display: block; }
/* Dans la scène d'ouverture, leur tête suit le pointeur (site.js). */
.scene-wool .w-head { transform-box: fill-box; transform-origin: 55% 85%; transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1); }
.w-leg { transform-box: fill-box; transform-origin: 50% 0; }
.w-tail { transform-box: fill-box; transform-origin: 0 80%; }
.w-lid { transform-box: fill-box; transform-origin: 50% 0; transform: scaleY(0); }
@media (max-width: 900px) {
  .hero-inner { grid-template-columns: 1fr; padding-top: calc(var(--nav-h) + 28px); padding-bottom: 56px; }
  .hero-art { justify-self: center; width: min(76%, 340px); }
  .scroll-cue { display: none; }
  .hero .laine { opacity: 0.45; }
}

/* --- La carte du cocoon --- */
.cocoon { padding-top: clamp(48px, 7vw, 96px); }
.cocoon-grid { display: grid; grid-template-columns: 1fr 1.05fr; gap: clamp(32px, 6vw, 80px); align-items: center; }
.cocoon .chapter-head { margin-bottom: 32px; }
.cocoon-panel {
  display: grid; gap: 10px; justify-items: start; padding: 24px 26px; border-radius: var(--radius); min-height: 210px; align-content: start;
  background: var(--surface); box-shadow: inset 0 0 0 1px var(--line);
}
.cocoon-panel h3 { font-size: 24px; display: flex; align-items: center; gap: 10px; }
.cocoon-panel h3::before { content: ''; width: 18px; height: 9px; border-radius: 9px 9px 0 0; background: var(--amber); }
.cocoon-panel p { color: var(--muted); }
.cocoon-panel .btn { margin-top: 6px; }
.cocoon-panel.swap h3, .cocoon-panel.swap p { animation: swap 0.45s cubic-bezier(0.2, 0.8, 0.2, 1); }
@keyframes swap { from { opacity: 0; transform: translateY(8px); } }
.cocoon-map { position: relative; aspect-ratio: 1; width: min(100%, 560px); justify-self: center; color: var(--cream); }
.cocoon-lines { position: absolute; inset: 0; width: 100%; height: 100%; }
.spokes path { stroke-opacity: 0.16; stroke-dasharray: 0.4 2; transition: stroke 0.4s, stroke-opacity 0.4s; }
.spokes path.on { stroke: var(--amber); stroke-opacity: 1; }
.cocoon-core {
  position: absolute; left: 50%; top: 50%; width: 31%; aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%;
  background: radial-gradient(circle at 50% 72%, rgba(217, 152, 74, 0.3), transparent 62%), var(--ink-2);
  box-shadow: inset 0 0 0 1px rgba(244, 239, 230, 0.14), 0 0 90px -10px rgba(217, 152, 74, 0.4);
  display: grid; justify-items: center; align-content: center; gap: 2px;
}
.cocoon-core svg { width: 56%; height: auto; margin-top: -8%; }
.cocoon-core b { font: 700 clamp(11px, 1.5vw, 15px)/1 var(--round); }
.node {
  position: absolute; left: var(--x); top: var(--y); width: clamp(52px, 7vw, 72px); aspect-ratio: 1; transform: translate(-50%, -50%);
  color: var(--mute-on-dark); font: 650 clamp(12px, 1.4vw, 15px)/1.15 var(--text);
}
.node span {
  width: 100%; height: 100%; border-radius: 50%; display: grid; place-items: center; background: var(--ink-2);
  box-shadow: inset 0 0 0 1.5px rgba(244, 239, 230, 0.16); transition: 0.3s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.node svg { width: 44%; height: 44%; }
.node em { position: absolute; left: 50%; top: calc(100% + 8px); transform: translateX(-50%); font-style: normal; white-space: nowrap; transition: color 0.3s; }
.node[data-k='maison'] em { top: auto; bottom: calc(100% + 8px); }
.node:hover span { transform: scale(1.08); }
.node[aria-pressed='true'] { color: var(--cream); }
.node[aria-pressed='true'] span { background: var(--cream); color: var(--ink); box-shadow: 0 0 0 6px rgba(217, 152, 74, 0.25), 0 0 44px rgba(217, 152, 74, 0.45); }
@media (max-width: 900px) { .cocoon-grid { grid-template-columns: 1fr; } .cocoon-map { width: min(100%, 440px); } .cocoon-panel { min-height: 0; } }

/* --- Avec quoi ça marche --- */
.compat { margin-top: 30px; display: grid; gap: 10px; }
.compat-label { font-size: 13px; font-weight: 650; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.compat ul { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.compat li { padding: 7px 13px; border-radius: 999px; font-size: 14px; font-weight: 600; background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }

/* --- Chez toi, sur fond sombre --- */
.tone-dark .link-diagram { color: var(--cream); }

/* --- Les wools --- */
.wools { padding-bottom: 0; }
.wools-opt { margin-top: 24px; font-size: 15px; }
.wool-demo { display: grid; justify-items: center; gap: 16px; }
.wool-card {
  width: min(100%, 380px); padding: 22px 22px 0; overflow: hidden; border-radius: 190px 190px 34px 34px;
  background: linear-gradient(#efe7d8, #e3d8c2); box-shadow: inset 0 0 0 1px var(--line), 0 30px 60px -36px rgba(31, 29, 26, 0.5);
  transition: transform 0.25s cubic-bezier(0.3, 1.6, 0.5, 1);
}
.wool-card:hover { transform: translateY(-3px); }
.wool-card:active { transform: scale(0.97); }
.wool-face { display: block; }
.wool-face svg { width: 100%; height: auto; display: block; }
.wool-name b { font: 700 22px/1 var(--round); margin-right: 6px; }
.wool-name span { color: var(--muted); font-size: 15px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chips button { padding: 9px 16px; border-radius: 999px; font-size: 15px; font-weight: 600; color: var(--muted); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); }
.chips button[aria-pressed='true'] { background: var(--ink); color: var(--cream); box-shadow: none; }
.meadow { position: relative; margin-top: clamp(36px, 5vw, 64px); height: clamp(180px, 23vw, 280px); }
.meadow > svg { position: absolute; left: 0; bottom: 0; width: 100%; height: 64%; }
.herd { position: absolute; inset: 0; display: flex; justify-content: space-around; align-items: flex-end; padding: 0 3% 1.5%; }
.herd span { width: clamp(108px, 17vw, 236px); }
.herd span:nth-child(odd) { margin-bottom: 1.2%; }
.herd span svg { width: 100%; height: auto; overflow: visible; display: block; }
.herd .flip { transform: scaleX(-1); }
@media (max-width: 700px) { .herd span:nth-child(n + 4) { display: none; } }

/* --- Installer --- */
.how { list-style: none; padding: 0; counter-reset: h; display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: clamp(44px, 6vw, 72px); }
.how li {
  counter-increment: h; position: relative; display: grid; gap: 12px; align-content: start; padding: 16px 16px 24px;
  border-radius: var(--radius); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line);
}
.how li::before {
  content: counter(h); position: absolute; left: 28px; top: 28px; z-index: 1; width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; background: var(--ink); color: var(--cream); font: 700 17px var(--round);
}
.how h3, .how p { padding: 0 10px; }
.how p { color: var(--muted); font-size: 16px; }
.how-art { height: 190px; border-radius: 16px; display: grid; place-items: center; overflow: hidden; background: var(--cream-3); color: var(--ink); }
.how-art > svg { width: 60%; height: auto; }
.how-art .pairing { width: 100%; height: 100%; border-radius: 0; }
.how-art.found { align-content: center; justify-items: start; gap: 8px; padding-left: 30%; }
.found span { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px 6px 9px; border-radius: 999px; font-size: 13px; font-weight: 600; background: var(--cream-2); box-shadow: inset 0 0 0 1px var(--line); }
.found span::before { content: ''; width: 14px; height: 7px; border-radius: 7px 7px 0 0; background: var(--amber); }
.platforms { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.os { position: relative; }
.os-art { width: 116px; height: auto; }
.os .command { margin: 0; font-size: 12.5px; padding: 10px 10px 10px 14px; }
.os-go { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin-top: 4px; }
.more { font-size: 14px; font-weight: 600; color: var(--muted); }
.more:hover { color: inherit; }
.os.mine { box-shadow: inset 0 0 0 2px var(--ink); }
.os.mine::after {
  content: 'Ton appareil'; position: absolute; top: 20px; right: 20px; padding: 6px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 700; background: #f3dfc0; color: #6b4418;
}
.os.pi {
  grid-column: 1 / -1; grid-template-columns: minmax(180px, 320px) 1fr; align-items: center; gap: clamp(20px, 4vw, 56px);
  padding: clamp(24px, 4vw, 44px); background: var(--ink); color: var(--cream); box-shadow: none;
  --muted: var(--mute-on-dark); --stroke: rgba(244, 239, 230, 0.2); --line: rgba(244, 239, 230, 0.12);
}
.os.pi > div { display: grid; gap: 14px; justify-items: start; }
.os.pi h3 { font-size: clamp(26px, 3.4vw, 40px); letter-spacing: -0.02em; }
.os.pi p { font-size: 17px; max-width: 52ch; }
.os.pi .btn { background: var(--cream); color: var(--ink); }
.os.pi.mine { box-shadow: inset 0 0 0 2px var(--amber); }
.pi-art { width: 100%; height: auto; }
.tag { font: 600 13px/1 var(--text); letter-spacing: 0.08em; text-transform: uppercase; color: var(--amber); }
.everywhere {
  margin-top: 20px; display: grid; grid-template-columns: minmax(150px, 220px) 1fr auto; gap: clamp(18px, 3vw, 36px); align-items: center;
  padding: 26px 28px; border-radius: var(--radius); background: var(--surface); box-shadow: inset 0 0 0 1px var(--line);
}
.everywhere-devices svg { width: 100%; height: auto; }
.everywhere p { color: var(--muted); font-size: 16px; margin-top: 6px; }
@media (max-width: 900px) {
  .how, .platforms { grid-template-columns: 1fr; }
  .os.pi { grid-template-columns: 1fr; }
  .pi-art { max-width: 300px; }
  .everywhere { grid-template-columns: 1fr; }
  .everywhere-devices { max-width: 220px; }
}

/* --- Mouvements --- */
@media (prefers-reduced-motion: no-preference) {
  .scene-roof { stroke-dashoffset: 1; animation: draw 1.5s cubic-bezier(0.6, 0, 0.2, 1) 0.3s forwards; }
  .scene-sun { transform: translateY(90px); animation: sunrise 2.4s cubic-bezier(0.2, 0.8, 0.2, 1) 1s forwards; }
  .far-sun { animation: veille 14s ease-in-out infinite; }
  .scene-wool svg { animation: breathe 5s ease-in-out infinite; transform-origin: 50% 100%; }
  .scene-wool.w2 svg { animation-delay: -2.2s; }
  .herd span svg { animation: breathe 6s ease-in-out infinite; transform-origin: 50% 100%; }
  .herd span:nth-child(2n) svg { animation-delay: -2.6s; }
  .herd span:nth-child(3n) svg { animation-delay: -4.1s; }
  .cocoon-core { animation: glow 5s ease-in-out infinite; }
  .how li .found span { opacity: 0; transform: translateX(-10px); }
  .how li.seen .found span { animation: found 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) forwards; }
  .how li.seen .found span:nth-child(1) { animation-delay: 0.5s; }
  .how li.seen .found span:nth-child(2) { animation-delay: 0.9s; }
  .how li.seen .found span:nth-child(3) { animation-delay: 1.3s; }
  .how li.seen .found span:nth-child(4) { animation-delay: 1.7s; }
  .w-lid { animation: blink 5.2s infinite; }
  .walking .w-leg { animation: step 0.44s ease-in-out infinite; }
  .walking .w-leg.l1, .walking .w-leg.l2 { animation-delay: -0.22s; }
  .walking .w-tail { animation: wag 0.44s ease-in-out infinite; }
  .herd span.walking svg, .wool-walker.walking svg { animation: trot 0.44s ease-in-out infinite; }
  .herd span.hopping svg { animation: hop 0.5s cubic-bezier(0.3, 0, 0.5, 1) infinite; }  .wool-face.pop svg { animation: pop 0.45s cubic-bezier(0.3, 1.6, 0.5, 1); transform-origin: 50% 100%; }
}
@keyframes step { 0%, 100% { transform: rotate(26deg); } 50% { transform: rotate(-26deg); } }
@keyframes wag { 0%, 100% { transform: rotate(-14deg); } 50% { transform: rotate(14deg); } }
@keyframes trot { 0%, 100% { transform: none; } 50% { transform: translateY(-2.5%); } }
@keyframes hop { 0%, 100% { transform: none; } 15% { transform: scale(1.05, 0.92); } 50% { transform: translateY(-16%) scale(0.97, 1.04); } 85% { transform: scale(1.04, 0.94); } }
@keyframes blink { 0%, 95%, 100% { transform: scaleY(0); } 97.5% { transform: scaleY(1); } }
@keyframes sunrise { to { transform: none; } }
@keyframes breathe { 0%, 100% { transform: none; } 50% { transform: scale(1.012, 0.985); } }
@keyframes glow { 0%, 100% { box-shadow: inset 0 0 0 1px rgba(244, 239, 230, 0.14), 0 0 70px -14px rgba(217, 152, 74, 0.3); } 50% { box-shadow: inset 0 0 0 1px rgba(244, 239, 230, 0.14), 0 0 110px -6px rgba(217, 152, 74, 0.5); } }
@keyframes found { to { opacity: 1; transform: none; } }
@keyframes pop { from { transform: scale(0.94, 1.05); } }
