/* ─── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  background: #14110d;
  color: #efe9dc;
  font-family: "Poppins", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100%;
}
::selection { background: #e3b343; color: #1a1408; }
button { font-family: inherit; }
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-thumb { background: rgba(239,233,220,0.16); border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }

/* ─── Preloader ───────────────────────────────────────────── */
#preloader {
  position: fixed; inset: 0; z-index: 999;
  background: #14110d;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 28px;
  transition: opacity .5s ease, visibility .5s ease;
}
#preloader.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.pre-logo {
  width: 72px; height: 72px;
  animation: preLogoPulse 1.8s ease-in-out infinite;
}
@keyframes preLogoPulse {
  0%, 100% { opacity: 1;  transform: scale(1);   }
  50%       { opacity: .65; transform: scale(.93); }
}
.pre-wordmark {
  font-size: 13px; font-weight: 600; letter-spacing: .18em;
  text-transform: uppercase; color: #efe9dc; line-height: 1;
}
.pre-wordmark span { color: #e3b343; }
.pre-bar-track {
  width: 160px; height: 1px;
  background: rgba(239,233,220,.12); border-radius: 1px; overflow: hidden;
}
.pre-bar {
  height: 100%; width: 0%;
  background: #e3b343; border-radius: 1px;
  transition: width .08s linear;
}
.pre-pct {
  font-size: 10px; font-weight: 500; letter-spacing: .14em; color: #6a6457;
}

/* ─── Variables ──────────────────────────────────────────── */
:root {
  --bg:     #14110d;
  --fg:     #efe9dc;
  --muted:  #9b9585;
  --faint:  #6a6457;
  --line:   rgba(239,233,220,0.12);
  --accent: #e3b343;
  --ink:    #1a1408;
  --gap:    10px;
  --safe-t: env(safe-area-inset-top,    0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left,   0px);
  --safe-r: env(safe-area-inset-right,  0px);
}

/* ─── Topbar ─────────────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 60;
  padding: calc(12px + var(--safe-t)) clamp(14px, 3vw, 30px) 12px;
  background: linear-gradient(to bottom, rgba(20,17,13,0.96) 60%, transparent);
  display: flex; align-items: center; gap: 10px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }

.brand {
  display: flex; align-items: center; gap: 9px;
  text-decoration: none; flex-shrink: 0;
}
.brand-icon { width: 28px; height: 28px; flex-shrink: 0; display: grid; place-items: center; }
.brand-name {
  font-size: 14px; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
  color: #efe9dc; white-space: nowrap; line-height: 1;
}
.brand-name span { color: #e3b343; }

.topbar-space { flex: 1; }

.status-pill {
  display: flex; align-items: center; gap: 7px;
  font-size: 11px; color: var(--muted);
  white-space: nowrap; overflow: hidden; max-width: 260px;
  flex-shrink: 1; min-width: 0;
}
.status-pill .lbl {
  font-size: 9px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--faint); flex-shrink: 0;
}
.status-pill em { font-style: italic; font-size: 13px; color: var(--fg); overflow: hidden; text-overflow: ellipsis; }

.dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0;
  animation: blink 2.8s infinite;
}
@keyframes blink {
  0%   { box-shadow: 0 0 0 0   rgba(227,179,67,.55); }
  70%  { box-shadow: 0 0 0 6px rgba(227,179,67,0);   }
  100% { box-shadow: 0 0 0 0   rgba(227,179,67,0);   }
}

.year-badge {
  flex-shrink: 0;
  padding: 7px 13px; border-radius: 999px;
  background: var(--accent); color: var(--ink);
  font-size: 11px; font-weight: 700; letter-spacing: 0.08em;
  text-transform: uppercase; border: none; cursor: default;
}

/* ─── Category nav ───────────────────────────────────────── */
.catnav {
  position: fixed; top: 58px; left: 0; right: 0; z-index: 50;
  display: flex; justify-content: center;
  padding: 6px clamp(10px, 2vw, 24px);
  pointer-events: none;
}
.catnav-pill {
  pointer-events: auto;
  display: flex; align-items: center; gap: 3px;
  background: rgba(22,18,13,0.84); backdrop-filter: blur(16px) saturate(160%);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 6px;
  overflow-x: auto; scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}
.catnav-pill::-webkit-scrollbar { display: none; }

.chip {
  flex-shrink: 0;
  padding: 7px 14px; border-radius: 999px; border: 0;
  background: transparent; color: var(--muted); cursor: pointer;
  font-size: 11px; font-weight: 500; letter-spacing: 0.04em;
  text-transform: uppercase; white-space: nowrap; line-height: 1;
  transition: color .18s, background .18s;
  -webkit-tap-highlight-color: transparent;
}
.chip:hover  { color: var(--fg); }
.chip.on     { background: var(--accent); color: var(--ink); }
.chip .ct    { opacity: .5; margin-left: 4px; font-size: 9px; }
.chip.on .ct { opacity: .72; }

/* ─── Masonry wall ───────────────────────────────────────── */
.wall {
  padding-top: 120px;
  padding-bottom: 90px;
  padding-left:  clamp(8px, 1.6vw, 24px);
  padding-right: clamp(8px, 1.6vw, 24px);
  column-gap: var(--gap);
  max-width: 1680px; margin: 0 auto;
}

.tile {
  break-inside: avoid; margin-bottom: var(--gap);
  display: block; border: 0; padding: 0;
  background: none; cursor: pointer; width: 100%;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}

.frame {
  position: relative; width: 100%; overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.06), 0 6px 24px -12px rgba(0,0,0,.8);
  transition: transform .36s cubic-bezier(.2,.7,.2,1), box-shadow .3s;
}
.tile:hover .frame,
.tile:focus-visible .frame {
  transform: translateY(-3px);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.13), 0 20px 40px -18px rgba(0,0,0,.9);
}
.frame::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background:
    repeating-linear-gradient(48deg, transparent 0 11px, rgba(0,0,0,.07) 11px 12px),
    radial-gradient(120% 90% at 30% 18%, rgba(255,255,255,.08), transparent 60%);
  mix-blend-mode: soft-light;
}

.frame-pad { display: block; width: 100%; }

.frame-img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; display: block;
  transition: transform .48s cubic-bezier(.2,.7,.2,1);
  background: rgba(30,24,18,.6);
}
.tile:hover .frame-img { transform: scale(1.04); }

.ph-wrap {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 8px;
}
.ph-wrap svg { opacity: .2; }
.ph-ref {
  font-size: 9px; letter-spacing: .2em; text-transform: uppercase;
  color: rgba(255,255,255,.32); text-align: center; line-height: 1.6;
}

.cat-tag {
  position: absolute; top: 8px; left: 8px; z-index: 4;
  background: var(--fg); color: var(--bg);
  font-size: 9px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  padding: 3px 7px; border-radius: 3px; pointer-events: none; line-height: 1.4;
}

/* ─── Grid view (uniform tiles) ─────────────────────────── */
.pgrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--gap);
  padding-top: 120px;
  padding-bottom: 90px;
  padding-left:  clamp(8px, 1.6vw, 24px);
  padding-right: clamp(8px, 1.6vw, 24px);
  max-width: 1680px; margin: 0 auto;
}

/* En mode grille on force un ratio 4:3 uniforme */
.pgrid .tile { margin-bottom: 0; }
.pgrid .frame { padding-top: 0 !important; }
.pgrid .frame-pad { display: none; }
.pgrid .frame-img,
.pgrid .ph-wrap {
  position: relative; inset: auto;
  width: 100%; height: 240px;
}
.pgrid .frame { height: 240px; overflow: hidden; }

/* Hover sur grille : léger zoom sans lift vertical */
.pgrid .tile:hover .frame { transform: none; }
.pgrid .tile:hover .frame-img { transform: scale(1.06); }

/* ─── View toggle ────────────────────────────────────────── */
.viewtoggle {
  position: fixed;
  bottom: calc(14px + var(--safe-b));
  left: 50%; transform: translateX(-50%);
  z-index: 60;
  display: flex; align-items: center; gap: 3px;
  background: rgba(22,18,13,.9); backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: 999px; padding: 4px;
}
.vbtn {
  padding: 9px 18px; border-radius: 999px; border: 0;
  background: transparent; color: var(--muted); cursor: pointer;
  font-family: inherit; font-size: 11px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  display: inline-flex; align-items: center; gap: 5px;
  transition: color .16s, background .16s;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}
.vbtn.on             { background: var(--fg); color: var(--bg); }
.vbtn:not(.on):hover { color: var(--fg); }

/* Séparateur vertical dans la pillule */
.vtoggle-sep {
  width: 1px; height: 18px;
  background: var(--line); flex-shrink: 0; margin: 0 2px;
}

/* Contrôle densité mobile — intégré dans la pillule */
.vcols {
  display: none; /* visible uniquement sur mobile via media query */
  align-items: center; gap: 1px;
}
.vcols-count {
  font-size: 12px; font-weight: 600; color: var(--fg);
  min-width: 18px; text-align: center; line-height: 1;
}
.vcols-btn {
  width: 30px; height: 30px; border-radius: 50%; border: 0;
  background: transparent; color: var(--muted); cursor: pointer;
  font-size: 16px; font-weight: 300; display: grid; place-items: center;
  transition: color .15s, background .15s;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit; line-height: 1;
}
.vcols-btn:hover   { color: var(--fg); }
.vcols-btn:active  { background: rgba(239,233,220,.08); }

/* ─── Density rail ───────────────────────────────────────── */
.density {
  position: fixed;
  right: 14px; bottom: calc(86px + var(--safe-b));
  z-index: 60;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: rgba(22,18,13,.9); backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-radius: 999px; padding: 12px 8px;
}
.density input[type=range] {
  writing-mode: vertical-lr; direction: rtl;
  -webkit-appearance: slider-vertical;
  width: 5px; height: 110px; cursor: ns-resize;
  accent-color: var(--accent); background: transparent;
}
.d-lbl    { font-size: 9px; color: var(--faint); letter-spacing: .04em; font-weight: 500; }
.d-lbl.hi { color: var(--accent); }

/* ─── Anniversary badge ──────────────────────────────────── */
.ann {
  position: fixed;
  right: 14px; bottom: calc(14px + var(--safe-b));
  z-index: 60;
  display: flex; flex-direction: column; align-items: flex-end; gap: 5px;
}
.ann-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 15px; border-radius: 999px; border: 0;
  background: var(--accent); color: var(--ink);
  font-family: inherit; font-size: 12px; font-weight: 700;
  letter-spacing: .05em; cursor: default;
  box-shadow: 0 8px 26px -8px rgba(227,179,67,.6);
}
.ann-sub {
  font-size: 9px; color: var(--faint); font-weight: 500; letter-spacing: .08em;
  background: rgba(22,18,13,.78); backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 10px;
}

/* ─── Lightbox ───────────────────────────────────────────── */
.lb {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(6,4,2,.97);
  display: flex; align-items: center; justify-content: center;
  animation: lbIn .2s ease;
  touch-action: pan-y;
}
@keyframes lbIn { from { opacity: 0; } }

.lb-img-wrap {
  position: relative;
  max-width: 100vw; max-height: 100vh;
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
}
.lb-img-wrap img {
  max-width: 94vw; max-height: 92vh;
  width: auto; height: auto;
  object-fit: contain; display: block;
  border-radius: 2px;
  box-shadow: 0 32px 80px -20px rgba(0,0,0,.9);
  user-select: none; -webkit-user-drag: none;
}

.lb-ph {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  width: min(460px, 90vw); height: min(460px, 70vh);
  border: 1px solid var(--line); border-radius: 4px;
}
.lb-ph svg { opacity: .15; }
.lb-ph p   { font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: var(--faint); }

.lb-caption {
  position: fixed; bottom: 0; left: 0; right: 0;
  padding: 20px clamp(16px,4vw,48px) calc(14px + var(--safe-b));
  background: linear-gradient(to top, rgba(6,4,2,.9) 60%, transparent);
  display: flex; align-items: flex-end; justify-content: flex-end; gap: 12px;
  pointer-events: none;
}
.lb-count {
  font-size: 11px; color: var(--faint); font-weight: 500;
  letter-spacing: .06em; white-space: nowrap;
}

.lb-close {
  position: fixed; top: calc(16px + var(--safe-t)); right: 18px; z-index: 110;
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid rgba(239,233,220,.18);
  background: rgba(14,11,8,.72); color: var(--fg);
  font-size: 16px; cursor: pointer;
  display: grid; place-items: center;
  transition: background .16s;
  -webkit-tap-highlight-color: transparent;
}
.lb-close:hover { background: rgba(239,233,220,.12); }

.lb-arrow {
  position: fixed; top: 50%; transform: translateY(-50%);
  width: 48px; height: 48px; border-radius: 50%;
  border: 1px solid rgba(239,233,220,.18);
  background: rgba(14,11,8,.72); color: var(--fg);
  font-size: 20px; cursor: pointer;
  display: grid; place-items: center;
  transition: background .16s;
  z-index: 110;
  -webkit-tap-highlight-color: transparent;
}
.lb-arrow:hover  { background: rgba(239,233,220,.12); }
.lb-arrow.prev   { left: 14px; }
.lb-arrow.next   { right: 14px; }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 860px) {
  .status-pill { display: none; }
  .density     { display: none; }   /* curseur vertical masqué */
  .ann         { display: none; }
  .vcols       { display: flex; }   /* boutons − N + visibles */
  .wall        { padding-top: 114px; }
  .pgrid       { padding-top: 114px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .pgrid .frame,
  .pgrid .frame-img,
  .pgrid .ph-wrap { height: 180px; }
}

@media (max-width: 600px) {
  .topbar     { padding-top: calc(10px + var(--safe-t)); padding-bottom: 10px; }
  .brand-name { font-size: 13px; }
  .year-badge { font-size: 10px; padding: 6px 10px; }

  .catnav { top: 52px; padding: 0; justify-content: flex-start; }
  .catnav-pill {
    border-radius: 0; border-left: 0; border-right: 0;
    padding: 6px clamp(10px, 3vw, 16px);
    width: 100%; background: rgba(20,17,13,.96); backdrop-filter: blur(12px); gap: 4px;
  }
  .chip { font-size: 10px; padding: 6px 11px; }

  .wall  { padding-top: 108px; column-gap: 6px; }
  .pgrid { padding-top: 108px; gap: 6px; grid-template-columns: repeat(2, 1fr); }
  .pgrid .frame,
  .pgrid .frame-img,
  .pgrid .ph-wrap { height: 150px; }

  .lb-arrow        { width: 40px; height: 40px; font-size: 16px; }
  .lb-arrow.prev   { left: 8px; }
  .lb-arrow.next   { right: 8px; }

  .index-head, .irow { grid-template-columns: 1fr 50px; }
  .index-head :first-child, .irow-ref { display: none; }
  .irow-title { font-size: 14px; }

  .vbtn { padding: 8px 14px; font-size: 10px; }
}

@media (max-width: 400px) {
  .chip { padding: 5px 9px; font-size: 9px; }
  .wall { padding-top: 104px; }
}
