/* ============================================================
   Atlas BOX Maroc — pile 3D des modules + schéma de convergence
   (js/ab-modules.js, js/ab-flow.js). Contenu en HTML statique ;
   le CSS/JS ne fait que le mettre en scène.
   ============================================================ */

/* ── Pile 3D ───────────────────────────────────────────────── */
.ab-modules-sticky { padding: clamp(72px, 9vw, 130px) 0 var(--s8); }
.ab-modules.is-scrolly { height: calc(100vh + var(--n, 15) * 24vh); padding: 0; }
.ab-modules.is-scrolly .ab-modules-sticky {
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  display: flex; flex-direction: column; padding: 118px 0 16px; overflow: hidden;
}
.ab-modules.is-scrolly .section-header { margin-bottom: var(--s2); row-gap: 8px; }
.ab-modules.is-scrolly .section-title { font-size: clamp(1.9rem, 3.2vw, 3rem); }
.ab-modules.is-scrolly .section-desc { font-size: 0.92rem; line-height: 1.55; }
.ab-modules.is-scrolly .section-tag { margin-bottom: 0; }

.ab-modules-stage { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: var(--s6); align-items: center; }
.ab-modules.is-scrolly .ab-modules-stage { flex: 1; min-height: 0; }

.stack-scene { perspective: 1900px; display: grid; place-items: center; height: clamp(300px, 56vh, 560px); }
.ab-modules.is-scrolly .stack-scene { height: 100%; }
.stack {
  position: relative; width: clamp(230px, 35vh, 380px); aspect-ratio: 1;
  transform-style: preserve-3d; transform: rotateX(58deg) rotateZ(-38deg);
}
.layer { position: absolute; inset: 0; transform-style: preserve-3d; transition: transform .55s var(--ease), opacity .4s ease; cursor: pointer; }
.layer svg { width: 100%; height: 100%; overflow: visible; }
.layer .slab { fill: rgba(0, 0, 0, 0.74); stroke: var(--c); stroke-opacity: .5; stroke-width: 1.2; transition: fill .4s ease, stroke-opacity .4s ease; }
.layer .art * { fill: none; stroke: var(--c); stroke-width: 1.3; stroke-linecap: round; stroke-linejoin: round; }
.layer .art .fill { fill: var(--c); }
.layer .tag { font: 500 10px var(--font-mono); letter-spacing: 0.14em; fill: var(--c); }
.layer.dim { opacity: .42; }
.layer.on { opacity: 1; }
.layer.on .slab { stroke-opacity: 1; fill: color-mix(in srgb, var(--c) 14%, rgba(0, 0, 0, 0.8)); }

.module-panel { display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
.module-families { display: flex; flex-wrap: wrap; gap: 8px; }
.module-families button {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: var(--r-full);
  border: 1px solid var(--ky-border); color: var(--ky-muted);
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.module-families button i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.module-families button:hover { color: var(--ky-text); border-color: var(--ky-border-2); }
.module-families button[aria-selected="true"] { color: var(--ky-text); border-color: var(--c); }

.module-detail { min-height: 300px; }
.module-detail > * { animation: mdIn .6s var(--ease) both; }
@keyframes mdIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.md-count { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.14em; color: var(--ky-muted); margin-bottom: 10px; }
.md-count span { color: var(--c); }
.module-detail h3 { font-weight: 400; font-size: clamp(1.8rem, 3vw, 2.7rem); letter-spacing: -0.035em; line-height: 1.05; margin-bottom: 10px; }
.module-detail .tagline, .module-detail-static .tagline { color: var(--ky-text-2); font-size: 1.02rem; line-height: 1.6; margin-bottom: var(--s3); max-width: 52ch; }
.module-detail .obt, .bd-kicker { display: block; font-size: 11.5px; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--spark); margin-bottom: 8px; }
.dash-list { border-top: 1px solid var(--ky-border); }
.dash-list li { position: relative; padding: 9px 0 9px 22px; border-bottom: 1px solid var(--ky-border); font-size: 0.93rem; line-height: 1.5; color: var(--ky-text-2); }
.dash-list li::before { content: ''; position: absolute; left: 0; top: 1.05em; width: 10px; height: 1px; background: var(--c, var(--accent-text)); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: var(--s3); }
.chips span { font-family: var(--font-mono); font-size: 11.5px; padding: 6px 12px; border-radius: var(--r-full); border: 1px solid color-mix(in srgb, var(--c, var(--accent)) 55%, transparent); color: var(--ky-text); }

.module-index { display: flex; flex-wrap: wrap; gap: 6px; }
.module-index button {
  width: 38px; height: 30px; border-radius: 8px; border: 1px solid var(--ky-border);
  font-family: var(--font-mono); font-size: 11px; color: var(--ky-muted);
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast);
}
.module-index button:hover { color: var(--ky-text); border-color: var(--c); }
.module-index button[aria-selected="true"] { color: #000; background: var(--c); border-color: var(--c); }

/* Repli statique (sans JavaScript) */
#modulesFallback { padding-block: var(--s6); }
.module-detail-static { padding: var(--s5) 0; border-top: 1px solid var(--ky-border); }
.module-detail-static h3 { font-weight: 400; font-size: 1.8rem; letter-spacing: -0.03em; margin-bottom: 8px; }
.module-detail-static .dash-list li::before { background: var(--accent-text); }
.module-detail-static .chips span { border-color: var(--ky-border-2); }

@media (max-height: 820px) and (min-width: 901px) {
  .module-detail { min-height: 0; }
  .module-detail h3 { font-size: 2rem; }
  .dash-list li { padding-block: 6px; font-size: 0.86rem; }
  .module-detail .tagline { margin-bottom: var(--s2); font-size: .95rem; }
  .chips { margin-top: var(--s2); }
  .ab-modules.is-scrolly .ab-modules-sticky { padding-top: 112px; }
}
@media (max-width: 900px) {
  .ab-modules-stage { grid-template-columns: 1fr; gap: var(--s3); }
  .stack-scene { height: 320px; }
  .stack { width: 240px; }
  .module-detail { min-height: 0; }
  .module-index { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
  .module-index button { flex: 0 0 auto; }
}

/* ── Schéma de convergence ─────────────────────────────────── */
.flow-schema { position: relative; display: grid; grid-template-columns: minmax(0, 1.55fr) 170px minmax(0, 1fr); gap: var(--s6); align-items: center; }
.flow-lines { position: absolute; left: 0; top: 0; pointer-events: none; z-index: 0; overflow: visible; }
.flow-col { position: relative; z-index: 1; min-width: 0; }
.flow-col-label { font-family: var(--font-mono); font-weight: 400; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--spark); margin-bottom: var(--s2); }
.source-cluster { display: flex; flex-direction: column; gap: 8px; }
.source-group { display: flex; align-items: center; gap: var(--s2); padding: 10px 14px; border: 1px solid var(--ky-border); border-radius: var(--r-md); background: rgba(0, 0, 0, 0.78); transition: border-color var(--t-fast), background var(--t-fast); }
.source-group:hover { border-color: var(--tint-line); background: var(--tint); }
.source-group-label { flex: 0 0 140px; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ky-muted); }
.source-group-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.source-pill { position: relative; font-size: 12.5px; padding: 5px 12px; border-radius: var(--r-full); border: 1px solid var(--tint-line); color: var(--ky-text); background: transparent; transition: border-color var(--t-fast), background var(--t-fast); }
.source-pill:hover, .source-pill:focus-visible { border-color: var(--accent-text); background: var(--tint); }
.pill-tip {
  position: absolute; bottom: calc(100% + 10px); left: 50%; transform: translateX(-50%) translateY(4px); z-index: 5;
  width: max-content; max-width: 250px; padding: 8px 12px; border-radius: var(--r-sm);
  background: #101015; border: 1px solid var(--ky-border-2);
  font-size: 12px; line-height: 1.45; text-align: left; font-weight: 300; color: var(--ky-text-2);
  opacity: 0; pointer-events: none; transition: opacity var(--t-fast), transform var(--t-fast);
}
.source-pill:hover .pill-tip, .source-pill:focus-visible .pill-tip { opacity: 1; transform: translateX(-50%); }

.flow-core { display: flex; justify-content: center; }
.core-node {
  position: relative; width: 150px; height: 150px; border-radius: 50%;
  display: grid; place-items: center; text-align: center;
  background: #000; border: 1px solid var(--accent); outline-offset: 10px;
}
.core-node::before, .core-node::after { content: ''; position: absolute; inset: -14px; border-radius: 50%; border: 1px solid var(--accent); opacity: .35; animation: coreRing 3.2s ease-out infinite; }
.core-node::after { animation-delay: 1.6s; }
@keyframes coreRing { from { transform: scale(.9); opacity: .55; } to { transform: scale(1.35); opacity: 0; } }
.core-node-label { font-size: 1.15rem; font-weight: 400; line-height: 1.15; letter-spacing: -0.02em; }

.output-pills { display: flex; flex-direction: column; gap: 8px; }
.output-pill { display: flex; align-items: flex-start; gap: 14px; padding: 14px 16px; border: 1px solid var(--ky-border); border-radius: var(--r-md); background: rgba(0, 0, 0, 0.78); font-size: 0.95rem; line-height: 1.35; transition: border-color var(--t-fast), background var(--t-fast); }
.output-pill:hover, .output-pill:focus-visible { border-color: var(--d-amber); background: rgba(255, 184, 41, 0.06); }
.output-pill svg { flex-shrink: 0; margin-top: 2px; color: var(--d-amber); }
.output-pill small { display: block; margin-top: 4px; font-size: 0.8rem; color: var(--ky-muted); }

.flow-path { fill: none; stroke: var(--accent); stroke-opacity: .4; stroke-width: 1.1; transition: stroke-opacity var(--t-fast), stroke-width var(--t-fast); }
.flow-path.is-out { stroke: var(--d-amber); stroke-opacity: .45; }
.flow-path.is-hot { stroke-opacity: 1; stroke-width: 1.8; }
.flow-dot { fill: #fff; }

@media (max-width: 900px) {
  .flow-schema { grid-template-columns: 1fr; gap: var(--s5); }
  .flow-lines { display: none; }
  .flow-core { order: 2; }
  .flow-outputs { order: 3; }
  .source-group { flex-direction: column; align-items: flex-start; gap: 8px; }
  .source-group-label { flex: none; }
  /* pas de bulle flottante en colonne étroite (elle déborderait de l'écran) : le nom de la source suffit */
  .pill-tip { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .core-node::before, .core-node::after { animation: none; opacity: .25; }
  .module-detail > * { animation: none; }
  .layer { transition: none; }
}
