/* Galerie CGC Morocco 2026 — charte : violet #8E2398 → #B14FD0 → #D49BEE, Saira Condensed + Sora (Tajawal pour l'arabe) */
:root {
  --night: #0d0615;
  --plum: #1b0f2b;
  --plum-2: #24153a;
  --line: rgba(212, 155, 238, .16);
  --ink: #f5eefb;
  --mute: #a493b8;
  --v1: #8e2398;
  --v2: #b14fd0;
  --v3: #d49bee;
  --grad: linear-gradient(135deg, #8e2398 0%, #b14fd0 60%, #d49bee 100%);
  --radius: 14px;
  --font-head: "Saira Condensed", "Tajawal", system-ui, sans-serif;
  --font-body: "Sora", "Tajawal", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1000px 520px at 50% -140px, rgba(142, 35, 152, .38), transparent 70%),
    var(--night);
  background-repeat: no-repeat;
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
[lang="ar"] body { line-height: 1.7; }
a { color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--v3); outline-offset: 3px; }

/* ---------- En-tête ---------- */
.topbar {
  display: flex; justify-content: flex-end;
  padding: max(14px, env(safe-area-inset-top)) clamp(16px, 4vw, 40px) 0;
}
.lang { display: flex; gap: 2px; }
.lang a {
  padding: 8px 10px; font-size: .78rem; font-weight: 500; letter-spacing: .04em;
  color: var(--mute); text-decoration: none; border-bottom: 2px solid transparent;
  transition: color .2s;
}
.lang a:hover { color: var(--ink); }
.lang a.on { color: var(--ink); border-bottom-color: var(--v2); }

.hero { text-align: center; padding: clamp(8px, 2vw, 20px) 20px clamp(28px, 5vw, 52px); }
.logo {
  display: block; margin: 0 auto;
  height: clamp(150px, 24vw, 236px); width: auto; max-width: 80%;
  filter: drop-shadow(0 10px 40px rgba(142, 35, 152, .45));
}
.hero h1 {
  margin: clamp(14px, 2.4vw, 24px) 0 0;
  font-family: var(--font-head); font-weight: 600;
  font-size: clamp(2.1rem, 5.4vw, 3.6rem); line-height: 1.05; letter-spacing: .01em;
}
[lang="ar"] .hero h1 { font-weight: 700; line-height: 1.3; }
.event { margin: .55rem 0 0; color: var(--v3); font-weight: 500; font-size: clamp(.9rem, 1.6vw, 1.02rem); letter-spacing: .04em; }
.stats { display: flex; justify-content: center; margin: 1.1rem 0 0; padding: 0; color: var(--mute); font-size: .9rem; }
.stats span { padding: 0 16px; }
.stats span + span { border-inline-start: 1px solid var(--line); }

/* ---------- Barre filtres ---------- */
.wrap { max-width: 1480px; margin: 0 auto; padding: 0 clamp(14px, 3.4vw, 44px) 72px; }
.bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px;
  padding: 12px 0; margin-bottom: 18px;
  scroll-margin-top: 0;
}
@media (min-width: 720px) {
  .bar {
    position: sticky; top: 0; z-index: 20;
    margin-inline: calc(clamp(14px, 3.4vw, 44px) * -1); padding-inline: clamp(14px, 3.4vw, 44px);
    background: rgba(13, 6, 21, .82); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--line);
  }
}
.seg {
  display: inline-flex; gap: 4px; padding: 4px;
  background: var(--plum); border: 1px solid var(--line); border-radius: 999px;
}
.seg a {
  padding: 7px 15px; border-radius: 999px; font-size: .86rem; font-weight: 500;
  color: var(--mute); text-decoration: none; white-space: nowrap; transition: color .2s, background-color .2s;
}
.seg a:hover { color: var(--ink); }
.seg a.on { background: var(--grad); color: #fff; }
.seg b { margin-inline-start: 6px; font-weight: 500; opacity: .7; font-size: .8rem; }
.per { display: flex; align-items: center; gap: 10px; color: var(--mute); font-size: .84rem; }

/* ---------- Grille façon Drive ---------- */
.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 18px 16px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.grid > li { min-width: 0; }
.card {
  display: block; overflow: hidden; text-decoration: none;
  background: var(--plum); border: 1px solid var(--line); border-radius: var(--radius);
  transition: border-color .2s, transform .2s;
}
@media (hover: hover) { .card:hover { border-color: rgba(177, 79, 208, .7); transform: translateY(-2px); } }
.thumb { position: relative; display: block; aspect-ratio: 4 / 3; background: var(--plum-2); overflow: hidden; }
.thumb img, .thumb video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block;
  transition: opacity .4s ease, transform .5s ease;
}
.js .thumb img, .js .thumb video { opacity: 0; animation: reveal .01s linear 4s forwards; }
.js .thumb .loaded { opacity: 1; animation: none; }
@keyframes reveal { to { opacity: 1; } }
@media (hover: hover) { .card:hover .thumb img, .card:hover .thumb video { transform: scale(1.035); } }
.is-video .thumb { background: linear-gradient(135deg, #2a1245, #3b1a5a); }
.play {
  position: absolute; inset: 0; margin: auto; width: 46px; height: 46px; display: grid; place-items: center;
  border-radius: 50%; background: rgba(13, 6, 21, .58); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, .22); color: #fff;
}
.play svg { width: 20px; height: 20px; fill: currentColor; stroke: none; margin-inline-start: 2px; }
.meta { display: flex; align-items: center; gap: 9px; padding: 10px 12px 11px; min-width: 0; }
.meta > svg { flex: none; width: 18px; height: 18px; color: var(--v3); }
.name { min-width: 0; font-size: .82rem; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; unicode-bidi: plaintext; text-align: start; }

.empty { text-align: center; color: var(--mute); padding: 64px 16px; }
.empty svg { width: 48px; height: 48px; color: var(--v2); }
.empty p { max-width: 42ch; margin: 14px auto 0; }

/* ---------- Pagination ---------- */
.pager { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 44px; }
.nums { display: flex; align-items: center; gap: 6px; }
.pg {
  display: inline-grid; place-items: center; min-width: 40px; height: 40px; padding: 0 6px;
  background: var(--plum); border: 1px solid var(--line); border-radius: 12px;
  color: var(--ink); font-size: .9rem; font-weight: 500; text-decoration: none; transition: border-color .2s, background-color .2s;
}
a.pg:hover { border-color: rgba(177, 79, 208, .7); }
.pg.on { background: var(--grad); border-color: transparent; color: #fff; }
.pg.off { opacity: .32; }
.pg svg { width: 20px; height: 20px; display: block; }
.flip { display: inline-grid; }
.flip.next { transform: scaleX(-1); }
[dir="rtl"] .flip { transform: scaleX(-1); }
[dir="rtl"] .flip.next { transform: none; }
.gap { color: var(--mute); padding: 0 2px; }
.pgtxt { display: none; margin: 0 14px; color: var(--mute); font-size: .88rem; }

/* ---------- Visionneuse ---------- */
.lb {
  position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center;
  background: rgba(8, 3, 14, .985); opacity: 0; transition: opacity .25s ease;
  touch-action: pan-y pinch-zoom; overscroll-behavior: contain;
}
.lb[hidden] { display: none; }
.lb.show { opacity: 1; }
html.lb-open { overflow: hidden; }
.lb-stage {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: calc(72px + env(safe-area-inset-top)) clamp(8px, 7vw, 100px) calc(28px + env(safe-area-inset-bottom));
}
.lb-media {
  max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; background: #000;
  opacity: 0; transform: scale(.985); transition: opacity .25s ease, transform .25s ease;
  user-select: none; -webkit-user-drag: none;
}
.lb-media.ready { opacity: 1; transform: none; }
video.lb-media { width: 100%; max-width: min(100%, 1280px); }
.lb-top {
  position: absolute; top: 0; inset-inline: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) clamp(12px, 2.4vw, 24px) 24px;
  background: linear-gradient(to bottom, rgba(8, 3, 14, .85), transparent);
  pointer-events: none;
}
.lb-top > * { pointer-events: auto; }
.lb-info { min-width: 0; }
.lb-name { display: block; font-size: .92rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; unicode-bidi: plaintext; text-align: start; }
.lb-sub { display: block; font-size: .78rem; color: var(--mute); }
.lb-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.lb-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid rgba(255, 255, 255, .1); border-radius: 50%;
  background: rgba(255, 255, 255, .08); color: #fff; cursor: pointer; text-decoration: none; font: inherit;
  transition: background-color .2s;
}
.lb-btn:hover { background: rgba(177, 79, 208, .4); }
.lb-btn svg { width: 22px; height: 22px; }
.lb-dl { display: inline-flex; align-items: center; gap: 8px; width: auto; padding: 0 14px; border-radius: 999px; font-size: .85rem; height: 44px; }
.lb-dl svg { width: 20px; height: 20px; }
.lb-dl span { display: none; }
.lb-nav { position: absolute; top: 50%; z-index: 3; margin-top: -22px; }
.lb-prev { inset-inline-start: clamp(8px, 1.6vw, 22px); }
.lb-next { inset-inline-end: clamp(8px, 1.6vw, 22px); }
.lb-nav .flip svg { width: 22px; height: 22px; }
.lb.single .lb-nav { display: none; }
.lb-spin {
  position: absolute; top: 50%; left: 50%; width: 36px; height: 36px; margin: -18px 0 0 -18px; z-index: 2;
  border: 3px solid rgba(212, 155, 238, .25); border-top-color: var(--v3); border-radius: 50%;
  opacity: 0; pointer-events: none; animation: spin .8s linear infinite;
}
.lb-spin.on { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Mobile ---------- */
@media (min-width: 720px) { .lb-dl span { display: inline; } }
@media (max-width: 719px) {
  .per { margin-inline-start: auto; }
}
@media (max-width: 640px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 10px; }
  .card { border-radius: 12px; }
  .meta { padding: 8px 9px 9px; gap: 7px; }
  .meta > svg { width: 16px; height: 16px; }
  .name { font-size: .75rem; }
  .play { width: 40px; height: 40px; }
  .nums { display: none; }
  .pgtxt { display: inline; }
  .lb-stage { padding-inline: 0; }
  .lb-nav { width: 40px; height: 40px; margin-top: -20px; background: rgba(13, 6, 21, .55); }
  .stats span { padding: 0 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: .01ms !important; scroll-behavior: auto !important; }
}
