/* =====================================================================
   INOVATECH — Page Galerie (hero, compteurs, filtres, mosaïque, visionneuse)
   Chargé uniquement sur galerie.php. Réutilise les variables de style.css.
   ===================================================================== */

/* ---------- Hero : fond technologique ---------- */
.gal-hero { padding-bottom: 110px; }
.gal-hero h1 { font-size: clamp(2.2rem, 5vw, 3.6rem); letter-spacing: -.02em; }
.gal-hero .lead { font-size: 1.12rem; }
.gal-eyebrow { display: flex; width: fit-content; align-items: center; gap: .5rem; margin-top: 1.2rem; padding: .38rem .95rem; border-radius: 999px; font-size: .78rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--silver); background: rgba(255, 255, 255, .08); border: 1px solid rgba(255, 255, 255, .15); backdrop-filter: blur(6px); }
.gal-eyebrow i { color: var(--accent); }
.gal-hero-glow { position: absolute; border-radius: 50%; filter: blur(60px); opacity: .55; pointer-events: none; animation: gal-float 12s ease-in-out infinite; }
.gal-hero-glow.g1 { width: 320px; height: 320px; right: 6%; top: 10%; background: rgba(47, 140, 255, .45); }
.gal-hero-glow.g2 { width: 240px; height: 240px; left: 40%; bottom: -120px; background: rgba(21, 101, 224, .5); animation-delay: -6s; }
.gal-hero-lines { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.gal-hero-lines span { position: absolute; height: 1px; width: 220px; background: linear-gradient(90deg, transparent, rgba(124, 192, 255, .8), transparent); animation: gal-scan 7s linear infinite; opacity: 0; }
.gal-hero-lines span:nth-child(1) { top: 28%; animation-delay: 0s; }
.gal-hero-lines span:nth-child(2) { top: 58%; animation-delay: -2.4s; }
.gal-hero-lines span:nth-child(3) { top: 78%; animation-delay: -4.8s; }
@keyframes gal-float { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(-30px, 20px); } }
@keyframes gal-scan { 0% { left: -240px; opacity: 0; } 10% { opacity: 1; } 90% { opacity: 1; } 100% { left: 100%; opacity: 0; } }

/* ---------- Compteurs (carte flottante sous le hero) ---------- */
.gal-stats-wrap { position: relative; z-index: 3; margin-top: -58px; }
.gal-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .5rem; padding: 1rem; background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-lg); }
.gal-stat { display: flex; align-items: center; gap: .9rem; padding: .8rem 1rem; border-radius: 14px; transition: background .25s var(--ease); }
.gal-stat:hover { background: var(--brand-light); }
.gal-stat-icon { flex: 0 0 48px; height: 48px; display: grid; place-items: center; border-radius: 12px; color: #fff; font-size: 1.2rem; background: linear-gradient(135deg, var(--brand), var(--accent)); box-shadow: 0 8px 18px rgba(21, 101, 224, .28); }
.gal-stat strong { display: block; font-family: var(--font-head); font-weight: 800; font-size: 1.6rem; line-height: 1.1; color: var(--navy); }
.gal-stat small { display: block; color: var(--muted); font-size: .86rem; }

.gal-section { padding-top: 70px; }

/* ---------- Filtres ---------- */
.gal-filters { display: flex; flex-wrap: wrap; justify-content: center; gap: .55rem; margin: 0 auto 2.4rem; }
.gal-filter { display: inline-flex; align-items: center; gap: .5rem; padding: .62rem 1.15rem; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-weight: 600; font-size: .92rem; cursor: pointer; box-shadow: var(--shadow-sm); transition: color .25s var(--ease), background .25s var(--ease), border-color .25s var(--ease), transform .25s var(--ease), box-shadow .25s var(--ease); }
.gal-filter i { color: var(--brand); transition: color .25s; }
.gal-filter:hover { transform: translateY(-2px); border-color: rgba(21, 101, 224, .4); color: var(--brand); box-shadow: var(--shadow); }
.gal-filter:focus-visible { outline: 3px solid rgba(47, 140, 255, .45); outline-offset: 2px; }
.gal-filter.is-active { color: #fff; border-color: transparent; background: linear-gradient(135deg, var(--brand), var(--accent)); box-shadow: 0 8px 20px rgba(21, 101, 224, .32); }
.gal-filter.is-active i { color: #fff; }
.gal-count { min-width: 1.6rem; padding: .05rem .45rem; border-radius: 999px; font-size: .74rem; font-weight: 700; text-align: center; background: var(--brand-light); color: var(--brand); transition: background .25s, color .25s; }
.gal-filter.is-active .gal-count { background: rgba(255, 255, 255, .22); color: #fff; }

/* ---------- Grille mosaïque ---------- */
.gal-grid { position: relative; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-rows: 230px; grid-auto-flow: dense; gap: 1.1rem; transition: opacity .2s ease; }
.gal-grid.is-filtering { opacity: 0; }
.gal-item { position: relative; margin: 0; border-radius: var(--radius); overflow: hidden; background: linear-gradient(135deg, var(--navy), var(--brand-700)); box-shadow: var(--shadow-sm); transform: translateZ(0); transition: box-shadow .4s var(--ease), transform .4s var(--ease); }
.gal-item.is-tall { grid-row: span 2; }
.gal-item.is-wide { grid-column: span 2; }
.gal-item.is-featured { grid-column: span 2; grid-row: span 2; }
.gal-item.is-hidden { display: none; }
.gal-item:hover { box-shadow: var(--shadow-lg); transform: translateY(-4px); }

/* Apparition au scroll (IntersectionObserver dans gallery.js) et après un filtre */
.gal-item.will-reveal { opacity: 0; transform: translateY(28px) scale(.97); }
.gal-item.is-in { animation: gal-in .65s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms); }
.gal-item.is-refilter { animation: gal-in .5s var(--ease) both; animation-delay: calc(var(--n, 0) * 45ms); }
@keyframes gal-in { from { opacity: 0; transform: translateY(28px) scale(.97); } to { opacity: 1; transform: none; } }

.gal-open { position: absolute; inset: 0; display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.gal-open:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.gal-open img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .8s var(--ease), filter .5s var(--ease); }
.gal-item:hover .gal-open img, .gal-open:focus-visible img { transform: scale(1.07); filter: saturate(1.08); }
.gal-open::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, rgba(6, 20, 46, 0) 35%, rgba(6, 20, 46, .55) 65%, rgba(6, 20, 46, .92) 100%); transition: opacity .4s var(--ease); }
.gal-zoom { position: absolute; top: 14px; right: 14px; z-index: 2; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; color: var(--navy); background: rgba(255, 255, 255, .92); box-shadow: var(--shadow); opacity: 0; transform: scale(.7) rotate(-20deg); transition: opacity .35s var(--ease), transform .35s var(--ease); }
.gal-item:hover .gal-zoom, .gal-open:focus-visible .gal-zoom { opacity: 1; transform: none; }

.gal-caption { position: absolute; left: 0; right: 0; bottom: 0; z-index: 1; padding: 1.1rem 1.15rem 1.05rem; color: #fff; pointer-events: none; }
.gal-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem .7rem; margin-bottom: .45rem; font-size: .78rem; }
.gal-meta time { color: rgba(255, 255, 255, .82); }
.gal-badge { display: inline-block; padding: .22rem .65rem; border-radius: 999px; font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: #fff; background: rgba(47, 140, 255, .9); box-shadow: 0 4px 12px rgba(21, 101, 224, .35); }
.gal-caption h3 { margin: 0; color: #fff; font-size: 1.05rem; font-weight: 700; line-height: 1.3; text-shadow: 0 1px 8px rgba(0, 0, 0, .35); }
.gal-item.is-featured .gal-caption h3 { font-size: 1.4rem; }
.gal-caption p { margin: .4rem 0 0; color: rgba(255, 255, 255, .85); font-size: .88rem; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-height: 0; opacity: 0; transition: max-height .45s var(--ease), opacity .35s var(--ease); }
.gal-item:hover .gal-caption p, .gal-item:focus-within .gal-caption p, .gal-item.is-featured .gal-caption p { max-height: 3em; opacity: 1; }
.gal-caption .badge-demo { pointer-events: auto; }
@media (hover: none) {
    .gal-caption p { max-height: 3em; opacity: 1; }
    .gal-zoom { opacity: .9; transform: none; width: 36px; height: 36px; font-size: .85rem; }
}
.gal-empty { border: 1px dashed var(--line); border-radius: var(--radius); background: var(--bg); }

/* ---------- Vidéos tutoriels ---------- */
.gal-placeholder { position: absolute; inset: 0; display: grid; place-items: center; font-size: 2.6rem; color: rgba(255, 255, 255, .25); background: radial-gradient(circle at 30% 20%, rgba(47, 140, 255, .45), transparent 60%), linear-gradient(135deg, var(--navy-900), var(--brand-700)); }
.gal-play { position: absolute; top: 42%; left: 50%; z-index: 2; width: 66px; height: 66px; margin: -33px 0 0 -33px; display: grid; place-items: center; border-radius: 50%; color: var(--brand); font-size: 1.35rem; background: rgba(255, 255, 255, .95); box-shadow: 0 10px 30px rgba(6, 20, 46, .45), 0 0 0 0 rgba(255, 255, 255, .55); transition: transform .35s var(--ease), background .3s, color .3s; animation: gal-pulse 2.6s ease-out infinite; }
.gal-play i { margin-left: 4px; }
.gal-item:hover .gal-play, .gal-open:focus-visible .gal-play { transform: scale(1.12); background: var(--brand); color: #fff; }
.gal-item.is-video .gal-open { cursor: pointer; }
.gal-item.no-cover .gal-open { background: radial-gradient(circle at 30% 20%, rgba(47, 140, 255, .45), transparent 60%), linear-gradient(135deg, var(--navy-900), var(--brand-700)); }
@keyframes gal-pulse { 0% { box-shadow: 0 10px 30px rgba(6, 20, 46, .45), 0 0 0 0 rgba(255, 255, 255, .5); } 70% { box-shadow: 0 10px 30px rgba(6, 20, 46, .45), 0 0 0 16px rgba(255, 255, 255, 0); } 100% { box-shadow: 0 10px 30px rgba(6, 20, 46, .45), 0 0 0 0 rgba(255, 255, 255, 0); } }
.gal-badge-video { background: #e11d48; box-shadow: 0 4px 12px rgba(225, 29, 72, .35); }
.gal-filter-video i { color: #e11d48; }
.gal-filter-video.is-active { background: linear-gradient(135deg, #be123c, #e11d48); box-shadow: 0 8px 20px rgba(225, 29, 72, .3); }
.glb-video { width: min(1100px, calc((100vh - 230px) * 16 / 9), 100%); aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: #000; box-shadow: 0 30px 80px rgba(0, 0, 0, .55); }
.glb-video iframe, .glb-video video { display: block; width: 100%; height: 100%; border: 0; background: #000; }
.glb-figure.has-video { width: 100%; }
.glb-figure.has-video img { display: none; }
.glb-figure.slide-next .glb-video { animation: glb-from-right .4s var(--ease); }
.glb-figure.slide-prev .glb-video { animation: glb-from-left .4s var(--ease); }

/* ---------- CTA ---------- */
.gal-cta h2 { max-width: 760px; margin: 0 auto 1rem; font-size: clamp(1.4rem, 3vw, 2rem); }
.gal-cta p { max-width: 620px; margin-left: auto; margin-right: auto; }
.gal-btn-light { color: var(--brand); background: #fff; border: 0; }
.gal-btn-light:hover { color: var(--brand-700); background: #fff; transform: translateY(-2px); box-shadow: 0 10px 24px rgba(6, 20, 46, .25); }

/* ---------- Visionneuse (Lightbox) ---------- */
.gal-lightbox { position: fixed; inset: 0; z-index: 2100; display: flex; align-items: center; justify-content: center; }
.gal-lightbox[hidden] { display: none; }
.glb-backdrop { position: absolute; inset: 0; background: rgba(4, 12, 30, .9); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); opacity: 0; transition: opacity .3s ease; }
.glb-dialog { position: relative; width: min(1180px, 100%); height: 100%; max-height: 100vh; display: flex; flex-direction: column; padding: 14px 16px 18px; opacity: 0; transform: scale(.94) translateY(16px); transition: opacity .32s var(--ease), transform .38s var(--ease); pointer-events: none; }
.gal-lightbox.is-open .glb-backdrop { opacity: 1; }
.gal-lightbox.is-open .glb-dialog { opacity: 1; transform: none; }
.glb-dialog > * { pointer-events: auto; }
.glb-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; min-height: 48px; }
.glb-counter { color: rgba(255, 255, 255, .75); font-size: .9rem; font-weight: 600; letter-spacing: .08em; }
.glb-stage { position: relative; flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; gap: 1rem; }
.glb-figure { position: relative; margin: 0; max-width: 100%; max-height: 100%; display: flex; align-items: center; justify-content: center; min-width: 0; min-height: 0; }
.glb-figure img { display: block; max-width: 100%; max-height: calc(100vh - 230px); width: auto; height: auto; border-radius: 14px; box-shadow: 0 30px 80px rgba(0, 0, 0, .55); transition: opacity .28s ease, transform .35s var(--ease); }
.glb-figure.is-loading img { opacity: 0; transform: scale(.97); }
.glb-figure.slide-next img { animation: glb-from-right .4s var(--ease); }
.glb-figure.slide-prev img { animation: glb-from-left .4s var(--ease); }
@keyframes glb-from-right { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
@keyframes glb-from-left { from { opacity: 0; transform: translateX(-40px); } to { opacity: 1; transform: none; } }
.glb-loader { position: absolute; top: 50%; left: 50%; width: 38px; height: 38px; margin: -19px 0 0 -19px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .2); border-top-color: var(--accent); animation: glb-spin .8s linear infinite; opacity: 0; transition: opacity .2s; pointer-events: none; }
.glb-figure.is-loading .glb-loader { opacity: 1; }
@keyframes glb-spin { to { transform: rotate(360deg); } }
.glb-btn { flex: none; width: 50px; height: 50px; display: grid; place-items: center; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .2); background: rgba(255, 255, 255, .1); color: #fff; font-size: 1.1rem; cursor: pointer; backdrop-filter: blur(6px); transition: background .25s, transform .25s var(--ease), border-color .25s; }
.glb-btn:hover { background: var(--brand); border-color: var(--brand); transform: scale(1.06); }
.glb-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.glb-btn[disabled] { opacity: .3; pointer-events: none; }
.glb-info { flex: none; max-width: 820px; width: 100%; margin: 14px auto 0; text-align: center; color: #fff; }
.glb-meta { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .4rem .8rem; margin-bottom: .45rem; font-size: .82rem; color: rgba(255, 255, 255, .75); }
.glb-meta .gal-badge:empty, .glb-meta time:empty { display: none; }
.glb-info h2 { color: #fff; font-size: clamp(1.1rem, 2.4vw, 1.45rem); font-weight: 700; margin: 0 0 .35rem; }
.glb-info p { margin: 0; color: rgba(255, 255, 255, .8); font-size: .95rem; line-height: 1.55; max-height: 4.7em; overflow-y: auto; }
.glb-info p:empty { display: none; }
body.gal-locked { overflow: hidden; }

/* ---------- Responsive ---------- */
@media (max-width: 1199.98px) {
    .gal-grid { grid-auto-rows: 210px; }
}
@media (max-width: 991.98px) {
    .gal-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: 200px; gap: 1rem; }
}
@media (max-width: 767.98px) {
    .gal-hero { padding-bottom: 90px; }
    .gal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 190px; gap: .8rem; }
    .gal-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: .6rem; gap: .2rem; }
    .gal-stat { padding: .6rem; gap: .65rem; }
    .gal-stat-icon { flex-basis: 40px; height: 40px; font-size: 1rem; }
    .gal-stat strong { font-size: 1.3rem; }
    .gal-stat small { font-size: .78rem; }
    .gal-filters { flex-wrap: nowrap; justify-content: flex-start; overflow-x: auto; margin: 0 -12px 1.8rem; padding: 4px 12px 10px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
    .gal-filters::-webkit-scrollbar { display: none; }
    .gal-filter { flex: none; }
    .gal-item.is-featured .gal-caption h3 { font-size: 1.15rem; }
    .glb-prev, .glb-next { position: absolute; top: 50%; z-index: 2; width: 42px; height: 42px; margin-top: -21px; background: rgba(6, 20, 46, .55); }
    .glb-prev { left: 4px; }
    .glb-next { right: 4px; }
    .glb-figure img { max-height: calc(100vh - 250px); border-radius: 10px; }
    .glb-video { width: 100%; border-radius: 10px; }
    .gal-play { width: 52px; height: 52px; margin: -26px 0 0 -26px; font-size: 1.1rem; }
}
@media (max-width: 575.98px) {
    .gal-grid { grid-auto-rows: 160px; }
    .gal-caption { padding: .8rem .85rem .8rem; }
    .gal-caption h3 { font-size: .92rem; }
    .gal-item:not(.is-featured) .gal-caption p { display: none; }
    .gal-badge { font-size: .64rem; padding: .18rem .5rem; }
    .gal-meta time { font-size: .72rem; }
}
/* Très petits écrans : une seule colonne, chaque photo garde sa description */
@media (max-width: 379.98px) {
    .gal-grid { grid-template-columns: 1fr; grid-auto-rows: 240px; }
    .gal-item.is-wide, .gal-item.is-featured, .gal-item[style*="grid-column"] { grid-column: auto !important; }
    .gal-item.is-tall, .gal-item.is-featured { grid-row: span 1; }
    .gal-item:not(.is-featured) .gal-caption p { display: -webkit-box; }
    .gal-stats { grid-template-columns: 1fr 1fr; }
}

/* Animations réduites à la demande du visiteur */
@media (prefers-reduced-motion: reduce) {
    .gal-hero-glow, .gal-hero-lines span, .gal-play { animation: none; }
    .gal-item.will-reveal { opacity: 1; transform: none; }
    .gal-item.is-in, .gal-item.is-refilter, .glb-figure.slide-next img, .glb-figure.slide-prev img { animation: none; }
    .gal-open img, .gal-item, .glb-dialog, .glb-backdrop, .gal-grid { transition: none; }
}
