/* Interactions, animations et ajustements responsive (v3).
   Tout ce qui bouge dépend de body[data-scroll-motion="on"] : le bouton « Effets » coupe l’ensemble. */
html { overflow-x: clip; }
.ch, .w, .w > i, .lw { font-style: normal; }
.ch, .w, .w > i { display: inline-block; }
b[data-count] { font-weight: inherit; font-variant-numeric: tabular-nums; }

/* ---------- Fond : constellation ---------- */
.constellation { position: fixed; inset: 0; z-index: -1; width: 100%; height: 100%; pointer-events: none; opacity: 0; -webkit-mask-image: linear-gradient(90deg, transparent 22%, #000 62%); mask-image: linear-gradient(90deg, transparent 22%, #000 62%); }

/* ---------- Curseur ---------- */
.cursor { position: fixed; z-index: 20; top: 0; left: 0; width: 34px; height: 34px; margin: -17px 0 0 -17px; border: 1px solid #d6b9ffb0; border-radius: 50%; pointer-events: none; opacity: 0; transition: opacity .3s, scale .3s var(--glide), background .3s, border-color .3s; }
.cursor.is-visible { opacity: 1; }
.cursor.is-active { scale: 1.75; background: #d6b9ff1f; border-color: #d6b9ff50; }
.cursor.is-down { scale: .8; }
body:not([data-scroll-motion="on"]) .cursor { display: none; }

/* ---------- En-tête ---------- */
.site-header { transition: transform .45s var(--glide); }
.site-header.is-away:not(:focus-within) { transform: translateY(-101%); }
@media (min-width: 681px) { .chapter-nav { position: relative; } }
.nav-pill { position: absolute; top: 0; left: 0; z-index: 0; border-radius: inherit; background: #d6b9ff24; pointer-events: none; transition: transform .5s var(--glide), width .5s var(--glide), height .5s var(--glide); }
.chapter-nav.has-pill a { z-index: 1; }
.chapter-nav.has-pill a[aria-current] { background: none; }
.chapter-nav a .icon { transition: translate .3s var(--glide), color .3s; }
.chapter-nav a[aria-current] .icon { color: var(--accent); translate: 0 -1px; }
.brand-icon { transition: rotate .6s var(--glide), background .3s; }
.brand:hover .brand-icon { rotate: -8deg; background: #d6b9ff30; }

/* ---------- Boutons ---------- */
.button, .header-link, .to-top { translate: var(--tx, 0) var(--ty, 0); transition: background .25s, color .25s, border-color .25s, translate .35s var(--glide), box-shadow .3s; }
.button { position: relative; overflow: hidden; }
.button.primary::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 35%, #ffffffa6 50%, transparent 65%); translate: -110% 0; pointer-events: none; }
.button.primary:hover { box-shadow: 0 10px 34px #b98cf655; }
[data-scroll-motion="on"] .button.primary:hover::after { translate: 110% 0; transition: translate .75s var(--glide); }
.button:active { scale: .97; }

/* ---------- Accueil ---------- */
.hero-typed { display: flex; align-items: center; gap: 8px; min-height: 22px; margin-top: 12px; color: var(--muted); font: 12px/1.4 var(--mono); letter-spacing: .02em; white-space: nowrap; }
.hero-typed span { color: var(--accent); opacity: .8; }
.hero-typed b { font-weight: 400; color: var(--ink); }
.hero-typed i { width: 7px; height: 15px; margin-left: -5px; background: var(--accent); }
.hero-annotation i { position: relative; }
.hero-annotation i::after { content: ""; position: absolute; inset: -1px; border: 1px solid var(--accent); border-radius: 50%; opacity: 0; }

/* ---------- Chiffres ---------- */
.metrics dl > div { position: relative; transition: background .35s; }
.metrics dl > div::after { content: ""; position: absolute; inset: auto 0 0; height: 2px; background: linear-gradient(90deg, var(--accent), transparent); transform: scaleX(0); transform-origin: left; transition: transform .6s var(--glide); }
.metrics dd { transition: translate .4s var(--glide); }
@media (hover: hover) {
  .metrics dl > div:hover { background: #d6b9ff12; }
  .metrics dl > div:hover::after { transform: scaleX(1); }
  .metrics dl > div:hover dd { translate: 0 -3px; }
}

/* ---------- Bandeau défilant ---------- */
.marquee { display: grid; gap: clamp(8px, 1.4vw, 18px); overflow: hidden; padding-top: clamp(44px, 7vw, 96px); -webkit-mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent); mask-image: linear-gradient(90deg, transparent, #000 12%, #000 88%, transparent); }
.marquee-row { display: flex; width: max-content; translate: calc(var(--shift, 0px) * -1) 0; }
.marquee-row.reverse { translate: calc(var(--shift, 0px) - 30vw) 0; }
.marquee ul { display: flex; flex: none; align-items: center; list-style: none; }
.marquee li { display: flex; align-items: center; white-space: nowrap; font-size: clamp(38px, 7.6vw, 108px); font-weight: 730; letter-spacing: -.06em; line-height: 1.05; }
.marquee li:nth-child(even) { color: transparent; -webkit-text-stroke: 1px #d6b9ff8c; }
.marquee li::after { content: ""; width: .16em; height: .16em; margin-inline: .42em; border-radius: 50%; background: var(--accent); }
.marquee-row.reverse li { color: var(--muted); -webkit-text-stroke: 0; font: clamp(11px, 1.2vw, 14px)/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; padding: 9px 13px; margin-right: 8px; border: 1px solid var(--line); border-radius: 100px; background: #1b1426a6; }
.marquee-row.reverse li::after { display: none; }
[data-scroll-motion="on"] .marquee.is-looping ul { animation: marquee 38s linear infinite; }
[data-scroll-motion="on"] .marquee.is-looping .reverse ul { animation-duration: 52s; animation-direction: reverse; }
.marquee.is-paused ul { animation-play-state: paused !important; }

/* ---------- Titres et texte ---------- */
.w { overflow: hidden; vertical-align: top; padding: .12em .07em; margin: -.12em -.07em; }
.w > i { transition: translate .9s var(--glide); transition-delay: calc(var(--i, 0) * 70ms); }
[data-scroll-motion="on"] .split:not(.in) .w > i { translate: 0 112%; }
[data-scroll-motion="on"] .lw { opacity: calc(.26 + .74 * clamp(0, var(--p, 1) * (var(--n) + 3) - var(--i), 1)); }

/* ---------- Projets ---------- */
.project-tabs button { overflow: hidden; }
.project-tabs button > :not(.tab-progress) { position: relative; }
.tab-progress { position: absolute; inset: 0; background: linear-gradient(90deg, #d6b9ff05, #d6b9ff2e); transform: scaleX(0); transform-origin: left; pointer-events: none; }
[data-scroll-motion="on"] .project-explorer:not([data-autoplay="off"]) [aria-selected="true"] .tab-progress { animation: tab-fill 9s linear forwards; }
.project-explorer.is-offscreen .tab-progress, .project-explorer:hover .tab-progress, .project-explorer:focus-within .tab-progress { animation-play-state: paused !important; }
.project-tabs button .icon { transition: rotate .5s var(--glide); }
.project-tabs button[aria-selected="true"] .icon { rotate: 8deg; }

.js-tabs .project-stage { display: grid; }
.js-tabs .project-panel { grid-area: 1 / 1; margin-top: 0; transition: opacity .4s, visibility .4s; }
.js-tabs .project-panel:not(.is-active) { opacity: 0; visibility: hidden; pointer-events: none; }

.project-signal { position: relative; overflow: hidden; isolation: isolate; transform: perspective(1000px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); transition: transform .6s var(--glide), border-color .3s, box-shadow .4s; }
.project-signal.is-tilting { transition: transform .12s linear, border-color .3s, box-shadow .4s; border-color: #d6b9ff7a; box-shadow: 0 24px 60px #0a0510a6; }
.project-signal > * { position: relative; z-index: 1; }
.project-signal > .signal-media { position: absolute; z-index: -1; inset: -6%; width: 112%; height: 112%; max-width: none; object-fit: cover; filter: grayscale(1) contrast(1.15); mix-blend-mode: luminosity; opacity: .5; translate: calc((var(--mx, 50) - 50) * -.12%) calc((var(--my, 50) - 50) * -.12%); transition: translate .6s var(--glide), opacity .5s, scale 1.2s var(--glide); -webkit-mask-image: linear-gradient(200deg, #000 18%, transparent 78%); mask-image: linear-gradient(200deg, #000 18%, transparent 78%); }
.project-data .signal-media { object-position: 60% 45%; }
.project-signal.is-tilting > .signal-media { opacity: .72; scale: 1.05; transition: translate .12s linear, opacity .5s, scale 1.2s var(--glide); }
.project-signal::before { content: ""; position: absolute; z-index: 0; inset: 0; background: radial-gradient(360px circle at calc(var(--mx, 50) * 1%) calc(var(--my, 50) * 1%), #e3c8ff2e, transparent 65%); opacity: 0; transition: opacity .4s; pointer-events: none; }
.project-signal.is-tilting::before { opacity: 1; }
.flow li::after { background: linear-gradient(90deg, var(--tone), var(--tone)); }
.project-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: auto; }
.project-info .project-actions .button { margin-top: 0; }

/* ---------- Profil ---------- */
.terminal { margin-top: clamp(22px, 3.4vw, 44px); max-width: 420px; border: 1px solid var(--line); border-radius: 14px; background: #120c1ad9; box-shadow: 0 24px 60px #08050c80; overflow: hidden; }
.terminal-bar { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--muted); font: 10px var(--mono); letter-spacing: .08em; }
.terminal-bar i { width: 8px; height: 8px; border-radius: 50%; background: #d6b9ff40; }
.terminal-bar i:first-child { background: var(--accent); }
.terminal-bar span { margin-left: auto; }
.terminal pre { margin: 0; padding: 14px; font: 12px/1.75 var(--mono); color: var(--muted); overflow: hidden; }
.terminal pre > span { display: block; width: fit-content; max-width: 100%; white-space: pre; overflow: hidden; }
.terminal b { font-weight: 400; color: var(--accent); }
.terminal em { font-style: normal; color: var(--ink); }
.terminal pre > span:last-child::after { content: ""; display: inline-block; width: 7px; height: 13px; margin-left: 6px; vertical-align: -2px; background: var(--accent); }
[data-scroll-motion="on"] .terminal.is-ready:not(.in) pre > span { width: 0; }
.stack li { transition: translate .3s var(--glide), border-color .3s, background .3s, color .3s; }
.stack li:hover { translate: 0 -3px; border-color: var(--accent); background: #dec4ff2b; color: var(--accent); }

/* ---------- Contact ---------- */
.contact-panel { position: relative; }
.contact-panel::before, .contact-panel::after { content: ""; position: absolute; left: 0; width: 34%; height: 1px; background: linear-gradient(90deg, transparent, var(--accent), transparent); opacity: 0; pointer-events: none; }
.contact-panel::before { top: -1px; }
.contact-panel::after { bottom: -1px; }
.contact-row .button { padding: 16px 20px; font-size: 16px; border-radius: 13px; }

/* ---------- Pied de page ---------- */
.clock { display: flex; align-items: center; gap: 7px; font-variant-numeric: tabular-nums; }
.clock i { width: 6px; height: 6px; border-radius: 50%; background: #9df2b8; box-shadow: 0 0 8px #9df2b8; }
.footer-inner a .icon { transition: translate .3s var(--glide); }
.footer-inner a:hover { color: var(--ink); }
.footer-inner a:hover .icon { translate: 2px -2px; }
.to-top { position: fixed; z-index: 6; right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: #1c1427e6; color: var(--ink); opacity: 0; visibility: hidden; scale: .8; transition: opacity .35s, visibility .35s, scale .35s var(--glide), translate .35s var(--glide), background .25s; }
.to-top.is-visible { opacity: 1; visibility: visible; scale: 1; }
.to-top:hover { background: #2a1d3a; }
.to-top svg { width: 48px; height: 48px; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.to-top circle { stroke: var(--accent); stroke-width: 2; stroke-dasharray: 100; stroke-dashoffset: calc(100 - var(--progress, 0) * 100); transform: rotate(-90deg); transform-origin: center; }
.to-top path { stroke: currentColor; stroke-width: 1.8; }

/* ---------- Animations continues ---------- */
/* Actives par défaut ; html.motion-off (bouton « Effets ») les coupe. */
:where(html:not(.motion-off)) .hero-line > span { animation: none; }
:where(html:not(.motion-off)).js .hero-line .ch { animation: char-enter 1s var(--glide) backwards; animation-delay: calc(var(--i) * 55ms + 80ms); transform-origin: 50% 100%; }
html:not(.js):where(:not(.motion-off)) .hero-line > span { animation: title-enter .92s var(--glide) backwards; }
:where(html:not(.motion-off)) .hero-typed { animation: lift .8s var(--glide) .16s backwards; }
:where(html:not(.motion-off)) .site-header { animation: header-enter .8s var(--glide) backwards; }
@keyframes char-enter { from { translate: 0 112%; rotate: 9deg; } }
@keyframes header-enter { from { transform: translateY(-100%); } }
[data-scroll-motion="on"] .hero-typed i { animation: blink 1s steps(2, jump-none) infinite; }
[data-scroll-motion="on"] .terminal pre > span:last-child::after { animation: blink 1s steps(2, jump-none) infinite; }
[data-scroll-motion="on"] .scroll-cue .icon { animation: nudge 1.8s var(--glide) infinite; }
[data-scroll-motion="on"] .hero-annotation i::after { animation: ping 2.4s ease-out infinite; }
[data-scroll-motion="on"] .eyebrow > i { animation: glow 2.6s ease-in-out infinite; }
[data-scroll-motion="on"] .clock i { animation: glow 2s ease-in-out infinite; }
[data-scroll-motion="on"] .project-panel.is-active .flow li { animation: node .65s var(--glide) backwards, hop 3.6s ease-in-out infinite; }
[data-scroll-motion="on"] .project-panel.is-active .flow li:nth-child(2) { animation-delay: .12s, 1.2s; }
[data-scroll-motion="on"] .project-panel.is-active .flow li:nth-child(3) { animation-delay: .2s, 2.4s; }
[data-scroll-motion="on"] .project-panel.is-active .flow li::after { background: linear-gradient(90deg, transparent, var(--tone) 50%, transparent) 0 0 / 200% 100%, #dec4ff40; opacity: 1; animation: stream 1.2s linear infinite; }
[data-scroll-motion="on"] .terminal.in pre > span { animation: type calc(var(--n) * 26ms) steps(var(--n)) backwards; animation-delay: calc(var(--d) * 1ms); }
[data-scroll-motion="on"] .contact-panel::before { opacity: 1; animation: sweep 5s linear infinite; }
[data-scroll-motion="on"] .contact-panel::after { opacity: 1; animation: sweep 5s linear infinite reverse; }
@keyframes blink { 50% { opacity: 0; } }
@keyframes nudge { 0%, 100% { translate: 0 -3px; } 50% { translate: 0 4px; } }
@keyframes ping { from { scale: 1; opacity: .9; } to { scale: 3.4; opacity: 0; } }
@keyframes glow { 50% { box-shadow: 0 0 0 4px #d6b9ff26, 0 0 12px #d6b9ff; } }
@keyframes hop { 0%, 22%, 100% { border-color: #dec4ff50; box-shadow: none; background: #1e142a; } 8% { border-color: var(--tone); box-shadow: 0 0 18px -4px var(--tone); background: #2c1d3d; } }
@keyframes stream { from { background-position: 100% 0, 0 0; } to { background-position: -100% 0, 0 0; } }
@keyframes marquee { to { transform: translateX(-50%); } }
@keyframes tab-fill { to { transform: scaleX(1); } }
@keyframes type { from { width: 0; } to { width: calc(var(--n) * 1ch); } }
@keyframes sweep { from { left: -34%; } to { left: 100%; } }

/* ---------- Responsive ---------- */
@media (min-width: 1700px) {
  .shell { width: min(1480px, calc(100% - 2 * var(--gutter))); }
  .hero-description { font-size: 18px; }
}
@media (max-width: 1000px) {
  .header-link { padding-inline: 10px; }
  .about-inner { grid-template-columns: minmax(0, 1fr); }
  .terminal { max-width: 460px; }
}
@media (max-width: 860px) {
  .project-panel { grid-template-columns: minmax(0, 1fr); }
  .project-signal { min-height: 210px; }
  .project-number { font-size: clamp(42px, 9vw, 76px); }
  .contact-row { flex-direction: column; align-items: start; gap: 18px; }
}
@media (max-width: 680px) {
  .site-header, .site-header.is-away:not(:focus-within) { transform: none; animation: none; }
  .constellation { -webkit-mask-image: linear-gradient(0deg, transparent 38%, #000 82%); mask-image: linear-gradient(0deg, transparent 38%, #000 82%); }
  .hero-typed { font-size: 11px; margin-top: 9px; }
  .marquee { padding-top: 40px; }
  .to-top { display: none; }
  .terminal pre { font-size: 11.5px; padding: 12px; }
  .contact-row .button { width: 100%; }
  .footer-inner { flex-wrap: wrap; padding-block: 12px; }
}
@media (max-width: 360px) {
  .terminal pre { font-size: 10.5px; }
  .metrics dd { font-size: 25px; }
}
@media (hover: none) {
  .project-signal > .signal-media { opacity: .6; }
}
:where(html.motion-off) .site-header { transition: none; }

/* ---------- Liens GitHub / LinkedIn ---------- */
.header-links { display: flex; justify-self: end; align-items: center; gap: 8px; }
.header-links .header-link { justify-self: auto; }
.contact-actions { display: flex; flex-wrap: wrap; gap: 10px; flex: none; }
@media (max-width: 860px) { .contact-actions { width: 100%; } }
@media (max-width: 680px) {
  .contact-actions .button { width: 100%; }
  .header-links { gap: 6px; }
  .header-links .header-link:first-child span { display: none; }
  .header-links .header-link:first-child { padding-inline: 11px; }
}
