/* ===========================================================================
   IBS-Studio · Documentation technique — layout sidebar + contenu de référence.
   =========================================================================== */

:root, :root[data-theme="dark"] {
  --bg: #0c0d12; --sidebar: #0e0f15; --surface: #14161f; --well: #0a0b10;
  --border: rgba(255,255,255,0.09); --border-strong: rgba(255,255,255,0.16);
  --text: #e9ebf1; --text-dim: #9aa0b2; --text-faint: #6a7085;
  --accent: #818cf8; --accent-ink: #6366f1; --accent-soft: rgba(99,102,241,0.14);
  --radius: 12px;
}
:root[data-theme="light"] {
  --bg: #ffffff; --sidebar: #f8f9fc; --surface: #f6f7fb; --well: #f0f1f7;
  --border: rgba(20,22,40,0.10); --border-strong: rgba(20,22,40,0.18);
  --text: #1b1e2b; --text-dim: #565c72; --text-faint: #8a90a4;
  --accent: #5457e6; --accent-ink: #5457e6; --accent-soft: rgba(84,87,230,0.10);
  --radius: 12px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px; line-height: 1.65; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.8em;
  background: var(--well); color: var(--text-dim); border: 1px solid var(--border);
  border-bottom-width: 2px; border-radius: 5px; padding: 1px 6px; white-space: nowrap;
}
.skip-link { position: fixed; top: -100px; left: 12px; z-index: 200; background: var(--accent-ink); color: #fff; padding: 10px 16px; border-radius: 10px; }
.skip-link:focus { top: 12px; }

.brand-mark { width: 20px; height: 20px; border-radius: 6px; background: linear-gradient(135deg, #6366f1, #a855f7); flex: none; }

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: 286px; z-index: 50;
  background: var(--sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 14px; overflow: hidden;
}
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 0 6px 4px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; color: var(--text); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-text { display: flex; align-items: baseline; gap: 6px; letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 1px 7px; border-radius: 999px; }
.menu-close { display: none; background: none; border: none; color: var(--text-dim); font-size: 18px; cursor: pointer; }

.search-trigger {
  display: flex; align-items: center; gap: 9px; width: 100%; margin: 14px 0; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-faint);
  padding: 9px 11px; border-radius: 10px; font-size: 13.5px; transition: border-color 0.15s;
}
.search-trigger:hover { border-color: var(--border-strong); }
.search-trigger span { flex: 1; text-align: left; }

.side-nav { flex: 1; overflow-y: auto; padding-right: 4px; margin: 0 -4px; }
.side-nav::-webkit-scrollbar { width: 8px; }
.side-nav::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
.nav-cat { margin: 2px 0 4px; }
.nav-cat-label {
  display: flex; align-items: center; gap: 7px; padding: 12px 8px 5px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-faint);
}
.nav-link {
  display: block; padding: 6px 10px; border-radius: 8px; font-size: 14px; color: var(--text-dim);
  border-left: 2px solid transparent; transition: color 0.12s, background 0.12s;
}
.nav-link:hover { color: var(--text); background: var(--surface); text-decoration: none; }
.nav-link.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }

/* ---------- Zone principale ---------- */
.doc-main { margin-left: 286px; min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: 56px; display: flex; align-items: center; gap: 14px;
  padding: 0 28px; background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(160%) blur(12px); border-bottom: 1px solid var(--border);
}
.topbar-back { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; font-weight: 600; color: var(--text-dim); background: var(--surface); border: 1px solid var(--border); padding: 7px 13px; border-radius: 9px; }
.topbar-back:hover { color: var(--text); border-color: var(--border-strong); text-decoration: none; }
.topbar-back svg { flex: none; }
.topbar-title { font-size: 13.5px; color: var(--text-faint); font-weight: 500; padding-left: 4px; border-left: 1px solid var(--border); margin-left: 4px; padding-left: 14px; }
@media (max-width: 720px) { .topbar-title { display: none; } }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.theme-toggle { background: var(--surface); border: 1px solid var(--border); color: var(--text); width: 36px; height: 34px; border-radius: 9px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.theme-toggle:hover { border-color: var(--border-strong); }
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="light"] .icon-moon { display: none; }
.btn-app { display: inline-flex; align-items: center; gap: 6px; background: var(--accent-ink); color: #fff; font-weight: 600; font-size: 13px; padding: 7px 13px; border-radius: 9px; }
.btn-app:hover { text-decoration: none; opacity: 0.92; }
.menu-toggle { display: none; flex-direction: column; gap: 4px; background: none; border: none; cursor: pointer; padding: 6px; }
.menu-toggle span { width: 18px; height: 2px; background: var(--text); border-radius: 2px; }

main { flex: 1; }
.content { max-width: 1140px; margin: 0 auto; padding: 38px 36px 40px; }
.loading { color: var(--text-faint); padding: 40px 0; }
/* Le texte reste à largeur de lecture ; les écrans animés s'élargissent. */
.doc-intro, .mod-head, .mod-intro, .feat-list, .kbd-table, .mod-sub { max-width: 780px; }

.doc-intro { padding-bottom: 14px; border-bottom: 1px solid var(--border); margin-bottom: 10px; }
.doc-intro h1 { font-size: 2.1rem; font-weight: 800; letter-spacing: -0.02em; margin: 0 0 12px; }
.doc-intro p { color: var(--text-dim); font-size: 1.02rem; max-width: 680px; }

/* ---------- Section module ---------- */
.cat-band {
  margin: 40px 0 4px; padding-top: 18px; font-size: 12px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--accent); display: flex; align-items: center; gap: 9px;
}
.cat-band::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.module { padding: 30px 0; border-bottom: 1px solid var(--border); scroll-margin-top: 76px; }
.module:last-child { border-bottom: none; }
.mod-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.mod-ico { font-size: 22px; line-height: 1; }
.mod-head h2 { font-size: 1.55rem; font-weight: 750; letter-spacing: -0.015em; margin: 0; scroll-margin-top: 76px; }
.mod-anchor { color: var(--text-faint); opacity: 0; font-weight: 400; margin-left: 4px; text-decoration: none; }
.mod-head:hover .mod-anchor { opacity: 1; }
.mod-cat { font-size: 11.5px; font-weight: 600; color: var(--text-faint); background: var(--well); border: 1px solid var(--border); padding: 2px 9px; border-radius: 999px; }
.mod-intro { color: var(--text-dim); font-size: 1.02rem; margin: 8px 0 18px; }

/* Démo vidéo — déborde la colonne de lecture (breakout centré) */
.mod-demo { position: relative; left: 50%; transform: translateX(-50%); width: min(1480px, calc(100vw - 48px)); margin: 4px auto 30px; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--well); box-shadow: 0 22px 60px -26px rgba(0,0,0,0.6); }
.mod-demo video { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; background: var(--well); }
.mod-demo figcaption { font-size: 13.5px; color: var(--text-faint); padding: 11px 18px; border-top: 1px solid var(--border); background: var(--surface); }

/* Fonctions — cartes illustrées d'un motif animé */
.mod-sub { font-size: 0.82rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--text-faint); margin: 22px 0 12px; }
.feat-list { display: flex; flex-direction: column; gap: 9px; margin: 0; }
.feat-item { display: grid; grid-template-columns: 44px 1fr; gap: 14px; align-items: start; padding: 13px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); transition: border-color 0.15s; }
.feat-item:hover { border-color: var(--border-strong); }
.feat-item.no-ico { grid-template-columns: 1fr; }
.feat-body dt { font-weight: 650; font-size: 1rem; margin-bottom: 3px; }
.feat-body dd { margin: 0; color: var(--text-dim); font-size: 0.95rem; }
.feat-ico { width: 44px; height: 44px; border-radius: 11px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; flex: none; }
.feat-ico svg { width: 24px; height: 24px; display: block; }

/* Bandeau RICHE — grande scène démonstrative (capacités phares) */
.feat-item.rich { display: block; padding: 0; overflow: hidden; }
.feat-banner { display: block; width: 100%; height: 150px; background: var(--well); border-bottom: 1px solid var(--border); color: var(--accent); }
.feat-banner svg { width: 100%; height: 100%; display: block; padding: 16px 22px; }
.feat-banner.vid { height: auto; line-height: 0; }
.feat-banner.vid video { width: 100%; height: auto; display: block; }
.feat-item.rich .feat-body { padding: 13px 17px 15px; }

/* Scènes RICH — animations de transformation (jouées si .playing) */
.feat-banner svg [class*="s-"] { transform-box: fill-box; transform-origin: center; }
.feat-banner .s-line { stroke-dasharray: 92; }
.feat-banner .s-fill { stroke-dasharray: 100; }
.feat-banner.playing .s-scan { animation: sScan 3.4s ease-in-out infinite; }
.feat-banner.playing .s-fly { animation: sFly 3.4s ease-in-out infinite; }
.feat-banner.playing .s-row { animation: sRow 3.4s ease-in-out infinite; }
.feat-banner.playing .s-pulse { animation: sPulse 3s ease-in-out infinite; }
.feat-banner.playing .s-glow { animation: sGlow 3s ease-in-out infinite; }
.feat-banner.playing .s-line { animation: sLine 3.6s ease-in-out infinite; }
.feat-banner.playing .s-out { animation: sOut 3.6s ease-in-out infinite; }
.feat-banner.playing .s-fill { animation: sLine 3.8s ease-in-out infinite; }
.feat-banner.playing .s-wand { animation: sWand 3.2s ease-in-out infinite; }
.feat-banner.playing .s-spark2 { animation: sSpark 2.6s ease-in-out infinite 0.5s; }
.feat-banner.playing .s-node { animation: sNode 3.4s ease-in-out infinite; }
.feat-banner.playing .s-token { animation: sToken 3.4s ease-in-out infinite; }
.feat-banner .s-fly.c2, .feat-banner .s-row.r2, .feat-banner .s-line.l2, .feat-banner .s-out.o2, .feat-banner .s-fill.q2, .feat-banner .s-node.n2 { animation-delay: 0.3s; }
.feat-banner .s-fly.c3, .feat-banner .s-row.r3, .feat-banner .s-line.l3, .feat-banner .s-out.o3, .feat-banner .s-fill.q3, .feat-banner .s-node.n3 { animation-delay: 0.6s; }
.feat-banner .s-line.l4, .feat-banner .s-out.o4, .feat-banner .s-fill.q4, .feat-banner .s-node.n4 { animation-delay: 0.9s; }
.feat-banner .s-node.n5 { animation-delay: 1.2s; }
@keyframes sScan { 0% { transform: translateY(0); opacity: 0.12; } 40% { opacity: 0.5; } 80%,100% { transform: translateY(16px); opacity: 0.12; } }
@keyframes sFly { 0%,15% { transform: translateX(0); opacity: 0; } 30% { opacity: 1; } 68% { transform: translateX(40px); opacity: 1; } 82%,100% { transform: translateX(44px); opacity: 0; } }
@keyframes sRow { 0%,35% { opacity: 0; } 52% { opacity: 0.16; } 80%,100% { opacity: 0; } }
@keyframes sPulse { 0%,100% { opacity: 0.5; } 50% { opacity: 1; } }
@keyframes sGlow { 0%,100% { opacity: 0.4; } 50% { opacity: 1; } }
@keyframes sLine { 0%,12% { stroke-dashoffset: 100; } 52%,75% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: 0; } }
@keyframes sOut { 0%,18% { transform: scale(0.3); opacity: 0; } 42% { transform: scale(1.1); opacity: 1; } 58%,90% { transform: scale(1); opacity: 1; } 100% { opacity: 0.82; } }
@keyframes sWand { 0%,100% { transform: translateX(-14px) scale(0.7); opacity: 0.3; } 50% { transform: translateX(2px) scale(1); opacity: 1; } }
@keyframes sSpark { 0%,100% { transform: scale(0.4); opacity: 0.2; } 50% { transform: scale(1); opacity: 1; } }
@keyframes sNode { 0%,100% { opacity: 0.4; } 45%,70% { opacity: 1; } }
@keyframes sToken { 0% { transform: translateX(0); } 92%,100% { transform: translateX(131px); } }

/* Motifs animés (joués seulement quand .playing — cf. IntersectionObserver) */
.feat-ico svg [class*="m-"] { transform-box: fill-box; transform-origin: center; }
.feat-ico .m-bar { transform-origin: bottom; }
.feat-ico .m-draw, .feat-ico .m-fan, .feat-ico .m-tick { stroke-dasharray: 64; }
.feat-ico.playing .m-pulse { animation: mPulse 2.4s ease-in-out infinite; }
.feat-ico.playing .m-twinkle { animation: mTwinkle 2s ease-in-out infinite; }
.feat-ico.playing .m-scan { animation: mScan 2.4s ease-in-out infinite; }
.feat-ico.playing .m-dot { animation: mBlink 1.6s ease-in-out infinite; }
.feat-ico.playing .m-cell { animation: mBlink 2.2s ease-in-out infinite; }
.feat-ico.playing .m-draw { animation: mDraw 3.2s ease-in-out infinite; }
.feat-ico.playing .m-float { animation: mFloat 2.8s ease-in-out infinite; }
.feat-ico.playing .m-drop { animation: mDrop 1.9s ease-in-out infinite; }
.feat-ico.playing .m-rise { animation: mRise 3s ease-in-out infinite; }
.feat-ico.playing .m-pop { animation: mPop 1.4s ease-in-out infinite; }
.feat-ico.playing .m-travel { animation: mTravel 2s ease-in-out infinite; }
.feat-ico.playing .m-jiggle { animation: mJiggle 2.6s ease-in-out infinite; }
.feat-ico.playing .m-orbit { animation: mOrbit 3s ease-in-out infinite; }
.feat-ico.playing .m-bar { animation: mBar 2s ease-in-out infinite; }
.feat-ico.playing .m-ring { animation: mRing 2.4s ease-in-out infinite; }
.feat-ico.playing .m-ripple { animation: mRipple 2s ease-out infinite; }
.feat-ico.playing .m-fly { animation: mFly 2.4s ease-in-out infinite; }
.feat-ico.playing .m-cross { animation: mCross 3s ease-in-out infinite; }
.feat-ico.playing .m-fan { animation: mDraw 3s ease-in-out infinite; }
.feat-ico.playing .m-tick { animation: mDraw 3s ease-in-out infinite; }
.feat-ico .m-pop.d2 { animation-delay: 0.18s; }
.feat-ico .m-pop.d3 { animation-delay: 0.36s; }
.feat-ico .m-fan.f2 { animation-delay: 0.25s; }
.feat-ico .m-fan.f3 { animation-delay: 0.5s; }
.feat-ico .m-bar.b2 { animation-delay: 0.2s; }
.feat-ico .m-bar.b3 { animation-delay: 0.4s; }
.feat-ico .m-cross.c2 { animation-delay: 1.5s; }
@keyframes mPulse { 0%,100% { transform: scale(0.92); opacity: 0.7; } 50% { transform: scale(1.12); opacity: 1; } }
@keyframes mTwinkle { 0%,100% { opacity: 0; } 50% { opacity: 1; } }
@keyframes mScan { 0% { transform: translateY(-2.5px); opacity: 0.25; } 50% { opacity: 1; } 100% { transform: translateY(5px); opacity: 0.25; } }
@keyframes mBlink { 0%,100% { opacity: 0.25; } 50% { opacity: 1; } }
@keyframes mDraw { 0% { stroke-dashoffset: 64; } 45%,60% { stroke-dashoffset: 0; } 100% { stroke-dashoffset: -64; } }
@keyframes mFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-2.5px); } }
@keyframes mDrop { 0%,100% { transform: translateY(0); opacity: 0.55; } 50% { transform: translateY(3px); opacity: 1; } }
@keyframes mRise { 0%,100% { transform: translateY(2px); } 50% { transform: translateY(-1px); } }
@keyframes mPop { 0%,100% { transform: scale(0.5); opacity: 0.3; } 50% { transform: scale(1); opacity: 1; } }
@keyframes mTravel { 0% { transform: translateX(0); opacity: 0; } 15% { opacity: 1; } 85% { opacity: 1; } 100% { transform: translateX(8px); opacity: 0; } }
@keyframes mJiggle { 0%,100% { transform: rotate(-7deg); } 50% { transform: rotate(7deg); } }
@keyframes mOrbit { 0%,100% { transform: translate(0,0); } 25% { transform: translate(1.5px,1px); } 75% { transform: translate(-1.5px,-1px); } }
@keyframes mBar { 0%,100% { transform: scaleY(0.6); } 50% { transform: scaleY(1); } }
@keyframes mRing { 0%,100% { transform: rotate(-9deg); } 50% { transform: rotate(9deg); } }
@keyframes mRipple { 0% { transform: scale(0.4); opacity: 0.7; } 100% { transform: scale(2.2); opacity: 0; } }
@keyframes mFly { 0%,100% { transform: translate(0,0); } 50% { transform: translate(2px,-1.5px); } }
@keyframes mCross { 0%,100% { opacity: 1; } 50% { opacity: 0; } }

/* Raccourcis (table) */
.kbd-table { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 0.92rem; }
.kbd-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.kbd-table tr:last-child td { border-bottom: none; }
.kbd-table td:first-child { width: 1%; white-space: nowrap; }
.kbd-keys { display: inline-flex; gap: 4px; }

.doc-footer { max-width: 1140px; margin: 0 auto; padding: 26px 36px 50px; color: var(--text-faint); font-size: 13.5px; border-top: 1px solid var(--border); }

/* ---------- Recherche ---------- */
.search-overlay { position: fixed; inset: 0; z-index: 300; background: rgba(0,0,0,0.5); display: flex; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px; backdrop-filter: blur(4px); }
.search-overlay[hidden] { display: none; }
.search-box { width: 100%; max-width: 560px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: 0 24px 60px -20px rgba(0,0,0,0.6); overflow: hidden; }
.search-field { display: flex; align-items: center; gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--border); color: var(--text-faint); }
#searchInput { flex: 1; background: none; border: none; outline: none; color: var(--text); font: inherit; font-size: 16px; }
.search-results { list-style: none; margin: 0; padding: 8px; max-height: 54vh; overflow-y: auto; }
.search-results li { padding: 10px 14px; border-radius: 9px; cursor: pointer; display: flex; align-items: center; gap: 12px; }
.search-results li .sr-ico { font-size: 17px; }
.search-results li .sr-sub { color: var(--text-faint); font-size: 12.5px; margin-left: auto; }
.search-results li.active { background: var(--accent-soft); }
.search-empty { padding: 22px; text-align: center; color: var(--text-faint); }

/* ---------- To-top ---------- */
.to-top { position: fixed; bottom: 22px; right: 22px; z-index: 40; width: 42px; height: 42px; border-radius: 50%; background: var(--surface); border: 1px solid var(--border-strong); color: var(--text); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 10px 26px -12px rgba(0,0,0,0.5); opacity: 0; transform: translateY(8px); transition: opacity 0.2s, transform 0.2s; }
.to-top.show { opacity: 1; transform: none; }
.to-top[hidden] { display: none; }

/* ---------- Responsive ---------- */
.sidebar-scrim { position: fixed; inset: 0; z-index: 45; background: rgba(0,0,0,0.5); }
.sidebar-scrim[hidden] { display: none; }
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.25s ease; width: 300px; }
  .sidebar.open { transform: translateX(0); }
  .menu-close { display: block; }
  .doc-main { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } .feat-ico [class*="m-"], .feat-banner [class*="s-"] { animation: none !important; } }
