/* ==========================================================
   GALERIE 3D — STRUCTURAL WORK CI
   Concept : plan d'ingénieur (blueprint) + vues 3D + teardown
========================================================== */
:root {
  --primary: #ff7a1a;
  --primary-hover: #ff9442;
  --bg-dark: #070b14;
  --card-bg: #0e1626;
  --card-border: #1f2c45;
  --text-main: #eaf1ff;
  --text-muted: #8a9bb8;
  --input-bg: #0a111f;
  --cyan: #4de1ff;
  --grid: rgba(77, 225, 255, .07);
  --ease: cubic-bezier(.2, .8, .2, 1);
}

.g-page { font-family: "Inter", sans-serif; color: var(--text-main); background: var(--bg-dark); overflow-x: clip; }
.g-page * { box-sizing: border-box; }
.g-wrap { width: min(1240px, 92%); margin: 0 auto; }

/* ---------- HERO ---------- */
.g-hero {
  position: relative; padding: 90px 0 50px;
  background:
    radial-gradient(60% 60% at 75% 40%, rgba(77,225,255,.12), transparent 70%),
    radial-gradient(40% 50% at 10% 0%, rgba(255,122,26,.14), transparent 70%),
    var(--bg-dark);
}
.g-hero-inner { display: grid; grid-template-columns: 1.05fr .95fr; gap: 40px; align-items: center; }
.g-hero h1 {
  font-family: "Space Grotesk", sans-serif; font-weight: 700; color: #fff;
  font-size: clamp(2.2rem, 5vw, 4rem); line-height: 1.05; letter-spacing: -.03em; margin: 0 0 18px;
}
.g-hero p { color: var(--text-muted); max-width: 520px; line-height: 1.7; margin: 0 0 28px; }
.g-hint { display: inline-flex; gap: 10px; align-items: center; color: var(--cyan); font-size: .82rem; }
.g-hint i { animation: bob 2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(5px); } }

/* Structure 3D éclatée (teardown du hero) */
.rig-scene { perspective: 1100px; height: 420px; display: grid; place-items: center; cursor: grab; }
.rig {
  position: relative; width: 240px; height: 240px; transform-style: preserve-3d;
  transform: rotateX(62deg) rotateZ(-35deg); transition: transform .15s linear;
}
.slab {
  position: absolute; inset: 0; border-radius: 6px; border: 1.5px solid var(--cyan);
  background: linear-gradient(135deg, rgba(77,225,255,.14), rgba(77,225,255,.03));
  box-shadow: 0 0 30px rgba(77,225,255,.15), inset 0 0 30px rgba(77,225,255,.08);
  transform: translateZ(calc(var(--i) * var(--gap, 46px)));
  transition: transform .8s var(--ease);
  display: grid; place-items: center;
}
.slab::before { /* trame de plan */
  content: ""; position: absolute; inset: 14px; border: 1px dashed rgba(255,255,255,.18);
  background:
    linear-gradient(rgba(255,255,255,.08) 1px, transparent 1px) 0 0 / 30px 30px,
    linear-gradient(90deg, rgba(255,255,255,.08) 1px, transparent 1px) 0 0 / 30px 30px;
}
.slab span {
  position: absolute; left: 100%; top: 50%; margin-left: 18px; white-space: nowrap;
  transform: rotateZ(35deg) rotateX(-62deg) translateX(8px); transform-origin: left;
  font-size: .72rem; font-weight: 600; color: #fff; background: rgba(7,11,20,.8);
  padding: 4px 10px; border-radius: 6px; border-left: 2px solid var(--primary);
}
.slab:nth-child(4) { border-color: var(--primary); background: linear-gradient(135deg, rgba(255,122,26,.28), rgba(255,122,26,.05)); box-shadow: 0 0 40px rgba(255,122,26,.3); }
.rig-scene:hover .rig { --gap: 80px; }
.rig-scene:hover .slab { --gap: 80px; }

/* ---------- STATS ---------- */
.g-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 50px; }
.stat-card {
  display: flex; align-items: center; gap: 14px; padding: 16px 18px; border-radius: 4px 18px 4px 18px;
  background: rgba(14,22,38,.7); border: 1px solid var(--card-border); backdrop-filter: blur(8px);
}
.stat-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 10px; color: var(--primary); background: rgba(255,122,26,.12); }
.stat-number { font-family: "Space Grotesk", sans-serif; font-size: 1.5rem; font-weight: 700; color: #fff; }
.stat-label { font-size: .75rem; color: var(--text-muted); }

/* ---------- CONTRÔLES ---------- */
.g-main { padding: 40px 0 80px; }
.controls-bar {
  position: sticky; top: 12px; z-index: 20; display: flex; justify-content: space-between; align-items: center;
  gap: 16px; flex-wrap: wrap; padding: 12px 16px; margin-bottom: 18px; border-radius: 16px;
  background: rgba(10,17,31,.8); border: 1px solid var(--card-border); backdrop-filter: blur(14px);
}
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-btn {
  border: 1px solid var(--card-border); background: transparent; color: var(--text-muted);
  padding: 9px 16px; border-radius: 10px; font: 600 .82rem "Inter", sans-serif; cursor: pointer; transition: .25s;
}
.filter-btn:hover { color: #fff; border-color: var(--cyan); }
.filter-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 6px 22px rgba(255,122,26,.35); }
.search-box { position: relative; min-width: 260px; }
.search-box input {
  width: 100%; background: var(--input-bg); border: 1px solid var(--card-border); color: #fff;
  border-radius: 10px; padding: 10px 14px 10px 38px; font-size: .85rem; outline: none; transition: .25s;
}
.search-box input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(77,225,255,.15); }
.search-box i { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: .85rem; }
.sw-result-count { font-size: .85rem; color: var(--text-muted); margin: 0 0 22px; }

/* ---------- GRILLE 3D ---------- */
.projects-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; perspective: 1400px; min-height: 300px; }
.project-card {
  position: relative; cursor: pointer; border-radius: 6px 24px 6px 24px; overflow: hidden;
  background: var(--card-bg); border: 1px solid var(--card-border);
  transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)) translateZ(0);
  transition: transform .25s var(--ease), border-color .3s, box-shadow .3s;
  animation: cardIn .7s var(--ease) both; animation-delay: calc(var(--n, 0) * 50ms);
}
@keyframes cardIn { from { opacity: 0; transform: rotateX(25deg) translateY(40px); } }
.project-card.hide { display: none; }
.project-card:hover, .project-card:focus-visible {
  border-color: var(--primary); outline: none;
  box-shadow: 0 30px 60px rgba(0,0,0,.55), 0 0 0 1px rgba(255,122,26,.4), 0 0 40px rgba(255,122,26,.15);
}
.project-image { position: relative; height: 250px; overflow: hidden; }
.project-image img { width: 100%; height: 100%; object-fit: cover; transform: scale(1.05); transition: transform .6s var(--ease); }
.project-card:hover .project-image img { transform: scale(1.14); }
.project-image::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, var(--card-bg) 2%, transparent 55%); }
.glare { position: absolute; inset: 0; z-index: 3; pointer-events: none; opacity: 0; transition: opacity .3s;
  background: radial-gradient(260px circle at var(--mx, 50%) var(--my, 50%), rgba(255,255,255,.18), transparent 60%); }
.project-card:hover .glare { opacity: 1; }
.badge-cat {
  position: absolute; top: 14px; left: 14px; z-index: 2; padding: 5px 12px; border-radius: 6px;
  background: var(--primary); color: #fff; font-size: .72rem; font-weight: 700; transform: translateZ(40px);
}
.badge-td {
  position: absolute; top: 14px; right: 14px; z-index: 2; padding: 5px 10px; border-radius: 6px; font-size: .72rem; font-weight: 600;
  color: var(--cyan); background: rgba(7,11,20,.8); border: 1px solid rgba(77,225,255,.35); transform: translateZ(40px);
}
.project-body { padding: 8px 22px 22px; transform: translateZ(25px); }
.project-body h3 { margin: 0 0 10px; font: 600 1.05rem/1.4 "Space Grotesk", sans-serif; color: #fff; }
.project-body p { margin: 0; font-size: .82rem; color: var(--text-muted); line-height: 1.6; }
.gallery-empty { grid-column: 1 / -1; text-align: center; padding: 80px 20px; color: var(--text-muted); }

/* ---------- LIGHTBOX + TEARDOWN ---------- */
.lightbox-modal {
  position: fixed; inset: 0; z-index: 1000; display: grid; place-items: center; padding: 20px;
  background: rgba(4,7,13,.94); backdrop-filter: blur(12px);
  opacity: 0; pointer-events: none; transition: opacity .3s;
}
.lightbox-modal.active { opacity: 1; pointer-events: auto; }
.lightbox-content {
  position: relative; width: min(1100px, 100%); max-height: 94vh; overflow: auto; display: grid; grid-template-columns: 1.1fr .9fr;
  border-radius: 8px 28px 8px 28px; background: var(--card-bg); border: 1px solid var(--card-border);
  transform: perspective(1200px) rotateX(8deg) scale(.94); transition: transform .5s var(--ease);
}
.lightbox-modal.active .lightbox-content { transform: none; }
.lb-left img { width: 100%; height: 100%; min-height: 320px; max-height: 620px; object-fit: cover; display: block; }
.lb-right { padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.lb-right h3 { margin: 0; font: 700 1.3rem/1.3 "Space Grotesk", sans-serif; color: #fff; }
.lb-cat { color: var(--primary); font-size: .8rem; font-weight: 700; }
.td-title { display: flex; justify-content: space-between; align-items: center; color: var(--cyan); font-weight: 600; font-size: .9rem; }
.td-toggle { border: 1px solid var(--cyan); background: transparent; color: var(--cyan); padding: 6px 12px; border-radius: 8px; cursor: pointer; font-size: .78rem; font-weight: 600; transition: .25s; }
.td-toggle:hover { background: var(--cyan); color: #04101a; }
.td-scene { perspective: 900px; height: 230px; display: grid; place-items: center; }
.td-stack { position: relative; width: 150px; height: 150px; transform-style: preserve-3d; transform: rotateX(62deg) rotateZ(-35deg); }
.td-layer {
  position: absolute; inset: 0; border-radius: 4px; border: 1.5px solid var(--cyan);
  background: linear-gradient(135deg, rgba(77,225,255,.18), rgba(77,225,255,.03));
  transform: translateZ(calc(var(--i) * var(--g, 8px))); transition: transform .7s var(--ease), border-color .3s, background .3s;
}
.td-stack.open { --g: 42px; }
.td-layer.on { border-color: var(--primary); background: linear-gradient(135deg, rgba(255,122,26,.4), rgba(255,122,26,.08)); }
.td-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.td-list li {
  padding: 10px 12px; border-radius: 10px; border: 1px solid var(--card-border); font-size: .8rem; color: var(--text-muted); cursor: default; transition: .25s;
}
.td-list li b { display: block; color: #fff; font-size: .85rem; margin-bottom: 2px; }
.td-list li.on { border-color: var(--primary); background: rgba(255,122,26,.08); }
.lb-actions { display: flex; gap: 10px; margin-top: auto; }
.lb-actions a { flex: 1; text-align: center; padding: 12px; border-radius: 10px; background: var(--primary); color: #fff; font-weight: 700; font-size: .85rem; text-decoration: none; }
.lb-actions a i { margin-right: 6px; }
.lightbox-close, .lb-nav {
  position: absolute; z-index: 5; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--card-border);
  background: rgba(7,11,20,.85); color: #fff; cursor: pointer; transition: .25s;
}
.lightbox-close { top: 14px; right: 14px; }
.lb-nav { bottom: 14px; }
.lb-nav.prev { left: 14px; } .lb-nav.next { left: 62px; }
.lightbox-close:hover, .lb-nav:hover { background: var(--primary); border-color: var(--primary); }

/* ---------- CTA ---------- */
.g-cta { padding: 70px 0; text-align: center; border-top: 1px solid var(--card-border);
  background: radial-gradient(50% 120% at 50% 0%, rgba(255,122,26,.14), transparent 70%), var(--bg-dark); }
.g-cta h2 { font: 700 2rem "Space Grotesk", sans-serif; color: #fff; margin: 0 0 12px; }
.g-cta p { color: var(--text-muted); max-width: 560px; margin: 0 auto 26px; line-height: 1.7; }
.g-cta a { display: inline-flex; gap: 10px; align-items: center; padding: 14px 30px; border-radius: 12px; background: var(--primary); color: #fff; font-weight: 700; text-decoration: none; box-shadow: 0 10px 30px rgba(255,122,26,.35); transition: .25s; }
.g-cta a:hover { background: var(--primary-hover); transform: translateY(-3px); }

:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1024px) {
  .projects-grid { grid-template-columns: repeat(2, 1fr); }
  .g-stats { grid-template-columns: repeat(2, 1fr); }
  .g-hero-inner { grid-template-columns: 1fr; }
  .rig-scene { height: 340px; }
}
@media (max-width: 760px) {
  .lightbox-content { grid-template-columns: 1fr; }
  .lb-left img { max-height: 260px; min-height: 200px; }
}
@media (max-width: 650px) {
  .projects-grid { grid-template-columns: 1fr; }
  .controls-bar { flex-direction: column; align-items: stretch; position: static; }
  .search-box { min-width: 100%; }
  .g-stats { grid-template-columns: 1fr; }
  .slab span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; }
}

/* Sécurité : cartes et images toujours visibles (même si un ancien CSS les masque) */
.project-card, .project-card.in-view { opacity: 1 !important; visibility: visible !important; }
.project-image { background: #111b2e; }
.project-image img { display: block; position: relative; opacity: 1 !important; }
.img-fail { height: 100%; display: grid; place-items: center; padding: 16px; text-align: center; font-size: .78rem; color: var(--text-muted); border-bottom: 1px dashed var(--card-border); }

/* ---------- TEARDOWN 3D DE LA PORTE ---------- */
.lightbox-modal [hidden] { display: none !important; }
.td-generic, .door-box { display: flex; flex-direction: column; gap: 14px; }
.lightbox-content.door-mode { grid-template-columns: .55fr 1.45fr; width: min(1200px, 100%); }
.door-mode .lb-left img { max-height: none; height: 100%; }
.d3-stage {
  height: 400px; border-radius: 12px; border: 1px solid var(--card-border); overflow: hidden;
  background: radial-gradient(70% 70% at 50% 40%, rgba(77,225,255,.12), transparent 70%), #080e1b;
}
.d3-slide { display: flex; align-items: center; gap: 14px; font-size: .82rem; font-weight: 600; color: var(--cyan); }
.d3-slide input { flex: 1; accent-color: var(--primary); }
.d3-help, .d3-note { margin: 0; font-size: .76rem; line-height: 1.55; color: var(--text-muted); }
.d3-note { border-left: 2px solid var(--primary); padding-left: 10px; }
.d3-list { max-height: 210px; overflow: auto; grid-template-columns: repeat(2, 1fr); padding-right: 4px; }
.d3-list li { cursor: pointer; }
.d3-list li:hover { border-color: var(--cyan); }
@media (max-width: 760px) {
  .lightbox-content.door-mode { grid-template-columns: 1fr; }
  .door-mode .lb-left img { max-height: 200px; }
  .d3-stage { height: 320px; }
  .d3-list { grid-template-columns: 1fr; }
}

/* ---------- HERO : LOGO 3D ÉCLATÉ ---------- */
.logo-stage { position: relative; height: 460px; cursor: pointer; }
.l3-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.l3-labels span {
  position: absolute; left: 0; top: 0; white-space: nowrap; font-size: .72rem; font-weight: 600; color: #fff;
  padding: 4px 10px; border-radius: 6px; border-left: 2px solid var(--primary); background: rgba(7,11,20,.82);
}
@media (max-width: 1024px) { .logo-stage { height: 380px; } }
@media (max-width: 650px) { .l3-labels { display: none; } .logo-stage { height: 320px; } }

/* ==========================================================
   ANIMATIONS GLOBALES
========================================================== */
/* Barre de progression de lecture */
.g-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 2000; transform: scaleX(0); transform-origin: 0 50%;
  background: linear-gradient(90deg, var(--primary), var(--cyan)); box-shadow: 0 0 12px rgba(255,122,26,.6); }

/* Hero : grille qui dérive + halo qui suit la souris */
.g-hero { overflow: hidden; }
.g-hero > .g-wrap { position: relative; z-index: 1; }
.g-hero::before {
  content: ""; position: absolute; inset: -48px; pointer-events: none;
  background: linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 48px 48px, linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 48px 48px;
  -webkit-mask-image: linear-gradient(to bottom, #000 40%, transparent); mask-image: linear-gradient(to bottom, #000 40%, transparent);
  animation: gridDrift 10s linear infinite;
}
.g-hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(420px circle at var(--gx, 70%) var(--gy, 40%), rgba(255,122,26,.14), transparent 60%);
}
@keyframes gridDrift { to { transform: translate(48px, 48px); } }

/* Titre du hero : mots qui montent un par un */
.js-anim .g-hero h1 .w { display: inline-block; overflow: hidden; vertical-align: bottom; padding-bottom: .08em; margin-bottom: -.08em; }
.js-anim .g-hero h1 .w > span { display: inline-block; transform: translateY(115%); animation: wordUp .9s var(--ease) forwards; animation-delay: calc(var(--i) * 90ms + 150ms); }
@keyframes wordUp { to { transform: none; } }

/* Apparition au défilement (la classe est retirée ensuite pour rendre la main aux survols) */
.js-anim .rv { opacity: 0; transform: translateY(32px); transition: opacity .8s var(--ease), transform .8s var(--ease); transition-delay: var(--d, 0ms); }
.js-anim .rv.in { opacity: 1; transform: none; }

/* Statistiques */
.stat-icon { animation: ringPulse 3.2s ease-out infinite; }
.stat-card:nth-child(2) .stat-icon { animation-delay: .5s; } .stat-card:nth-child(3) .stat-icon { animation-delay: 1s; } .stat-card:nth-child(4) .stat-icon { animation-delay: 1.5s; }
@keyframes ringPulse { 0% { box-shadow: 0 0 0 0 rgba(255,122,26,.45); } 70%, 100% { box-shadow: 0 0 0 14px rgba(255,122,26,0); } }

/* Barre de contrôles : filet lumineux qui balaie */
.controls-bar { overflow: hidden; }
.controls-bar::after { content: ""; position: absolute; left: -30%; bottom: 0; width: 30%; height: 2px; background: linear-gradient(90deg, transparent, var(--cyan), transparent); animation: sweep 4.5s linear infinite; }
@keyframes sweep { to { left: 100%; } }

/* Cartes : reflet qui traverse la photo au survol, cube flottant */
.project-image::before { content: ""; position: absolute; top: 0; left: -70%; width: 40%; height: 100%; z-index: 3; pointer-events: none;
  background: linear-gradient(100deg, transparent, rgba(255,255,255,.22), transparent); transform: skewX(-20deg); }
.project-card:hover .project-image::before { animation: shine .9s var(--ease); }
@keyframes shine { to { left: 130%; } }
.badge-td i { display: inline-block; animation: cubeFloat 2.6s ease-in-out infinite; }
@keyframes cubeFloat { 50% { transform: translateY(-2px) rotate(20deg); } }
.project-card:hover h3 { color: var(--primary-hover); transition: color .3s; }

/* Teardown : lignes de la liste qui arrivent en cascade */
.td-generic .td-list li { animation: liIn .5s var(--ease) both; }
.td-generic .td-list li:nth-child(2) { animation-delay: .07s; } .td-generic .td-list li:nth-child(3) { animation-delay: .14s; } .td-generic .td-list li:nth-child(4) { animation-delay: .21s; }
@keyframes liIn { from { opacity: 0; transform: translateX(16px); } }
.lightbox-modal.active .lb-left img { animation: imgIn .8s var(--ease) both; }
@keyframes imgIn { from { opacity: 0; transform: scale(1.08); } }
.d3-stage { animation: stageGlow 4s ease-in-out infinite; }
@keyframes stageGlow { 50% { box-shadow: 0 0 30px rgba(77,225,255,.18); } }

/* Appel à l'action : reflet + onde */
.g-cta a { position: relative; overflow: hidden; animation: ctaRing 2.8s ease-out infinite; }
.g-cta a::after { content: ""; position: absolute; top: 0; left: -60%; width: 40%; height: 100%; background: linear-gradient(100deg, transparent, rgba(255,255,255,.35), transparent); transform: skewX(-20deg); animation: shine 3.2s ease-in-out infinite; }
@keyframes ctaRing { 0% { box-shadow: 0 10px 30px rgba(255,122,26,.35), 0 0 0 0 rgba(255,122,26,.5); } 70%, 100% { box-shadow: 0 10px 30px rgba(255,122,26,.35), 0 0 0 18px rgba(255,122,26,0); } }

/* Bouton WhatsApp flottant */
.whatsapp-float { animation: waPulse 2.6s ease-out infinite; }
@keyframes waPulse { 0% { box-shadow: 0 0 0 0 rgba(37,211,102,.55); } 70%, 100% { box-shadow: 0 0 0 16px rgba(37,211,102,0); } }

/* Compteur de résultats qui s'actualise */
.sw-result-count.bump { animation: bump .45s var(--ease); }
@keyframes bump { 40% { transform: translateY(-4px); color: var(--primary); } }