/* Espace galeries — Jonathan Zafine. Même univers que le site : sombre, ivoire, terracotta. */

@font-face {
  font-family: 'Outfit';
  src: url('/fonts/outfit-latin.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0000-00FF, U+2013-2014, U+2018-201A, U+201C-201E, U+2026;
}
@font-face {
  font-family: 'Outfit';
  src: url('/fonts/outfit-latin-ext.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
  unicode-range: U+0100-024F, U+0259, U+1E00-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0;
}

:root {
  --ink: #131315;
  --ink-2: #1B1B1E;
  --ink-3: #232327;
  --line: #2E2E33;
  --ivory: #F4F4F2;
  --muted: #9C9CA3;
  --terra: #C4553C;
  --terra-hover: #D4664C;
  --terra-soft: #E8B0A2;
  --ok: #7FB069;
  --danger: #D4664C;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--ink);
  color: var(--ivory);
  font-family: 'Outfit', system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ---- structure ---- */
.screen { min-height: 100vh; }
.center { display: flex; align-items: center; justify-content: center; padding: 24px; }
.container { max-width: 1080px; margin: 0 auto; padding: 8px 24px 80px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: color-mix(in srgb, var(--ink) 88%, transparent);
  backdrop-filter: blur(10px); z-index: 5;
}
.topnav { display: flex; gap: 10px; }

.wordmark {
  font-size: 26px; font-weight: 600; letter-spacing: 0.04em; margin: 0;
}
.wordmark.small { font-size: 18px; }
.tagline {
  color: var(--terra-soft); letter-spacing: 0.22em; text-transform: uppercase;
  font-size: 12px; margin: 6px 0 26px;
}

.page-head { margin: 34px 0 22px; }
.page-head h1 { font-size: 30px; font-weight: 600; margin: 0 0 4px; letter-spacing: 0.01em; }
.page-head .muted { margin: 0; font-size: 14px; }

/* ---- cartes / formulaires ---- */
.card {
  background: var(--ink-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 34px;
}
.auth-card { width: 100%; max-width: 400px; text-align: center; }
.auth-card .field { text-align: left; }

.field { display: block; margin: 0 0 16px; }
.field span {
  display: block; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 7px;
}
.field input {
  width: 100%; padding: 13px 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--ink); color: var(--ivory);
  font: inherit; outline: none; transition: border-color .2s;
}
.field input:focus { border-color: var(--terra); }

.rules { list-style: none; padding: 0; margin: -4px 0 16px; text-align: left; }
.rules li {
  font-size: 13.5px; color: var(--muted); padding: 3px 0 3px 26px; position: relative;
  transition: color .2s;
}
.rules li::before {
  content: ''; position: absolute; left: 4px; top: 9px; width: 12px; height: 12px;
  border: 1.5px solid var(--muted); border-radius: 50%; transition: all .2s;
}
.rules li.ok { color: var(--ok); }
.rules li.ok::before {
  border-color: var(--ok); background: var(--ok);
  clip-path: none;
}

.form-error {
  color: var(--danger); font-size: 14px; margin: 2px 0 14px;
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border-radius: 8px; padding: 10px 12px;
}
.hint-inline {
  color: var(--terra-soft); font-size: 13.5px; text-align: left; margin: -8px 0 14px;
}

/* Repères clavier visibles partout. */
:focus-visible { outline: 2px solid var(--terra); outline-offset: 2px; border-radius: 6px; }
.ph .del:focus-visible, .ph .movers button:focus-visible { opacity: 1; }
.ph:focus-within .del, .ph:focus-within .movers { opacity: 1; }
.ph .movers button:disabled { opacity: 0.35; cursor: default; }
.ph .movers button:disabled:hover { background: rgba(19,19,21,0.72); }

/* ---- boutons ---- */
.btn {
  font: inherit; font-weight: 500; cursor: pointer; border-radius: 999px;
  padding: 11px 22px; border: 1px solid transparent; transition: all .2s;
  color: var(--ivory); background: transparent;
}
.btn-primary { background: var(--terra); }
.btn-primary:hover:not(:disabled) { background: var(--terra-hover); }
.btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-ghost { border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { border-color: var(--muted); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger); color: var(--ivory); }
.btn-block { width: 100%; margin-top: 6px; }
/* Un bouton désactivé ne réagit plus et n'invite plus au clic. */
.btn:disabled { opacity: 0.45; cursor: default; }

/* ---- bandeau publication ---- */
.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  background: color-mix(in srgb, var(--terra) 14%, var(--ink-2));
  border: 1px solid color-mix(in srgb, var(--terra) 45%, var(--line));
  border-radius: var(--radius); padding: 16px 20px; margin-bottom: 26px;
  flex-wrap: wrap;
}
.banner p { margin: 0; }
.banner-actions { display: flex; gap: 10px; }

/* ---- cartes de galeries ---- */
.cards {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}
.gallery-card {
  position: relative; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--line); background: var(--ink-2);
  cursor: pointer; padding: 0; text-align: left; color: inherit; font: inherit;
  transition: transform .25s, border-color .25s;
}
.gallery-card:hover { transform: translateY(-3px); border-color: var(--muted); }
.gallery-card .cover {
  aspect-ratio: 3 / 2; background: var(--ink-3); width: 100%;
  object-fit: cover; display: block;
}
.gallery-card .cover.empty {
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 14px;
}
.gallery-card .meta { padding: 14px 16px 16px; }
.gallery-card .meta h2 { font-size: 18px; font-weight: 600; margin: 0; }
.gallery-card .meta p { margin: 2px 0 0; font-size: 13.5px; color: var(--muted); }
.badge {
  position: absolute; top: 12px; right: 12px;
  background: var(--terra); color: var(--ivory);
  font-size: 12px; font-weight: 600; letter-spacing: 0.04em;
  border-radius: 999px; padding: 4px 12px;
}

/* ---- historique ---- */
.history { margin-top: 44px; border-top: 1px solid var(--line); padding-top: 20px; }
.history summary {
  cursor: pointer; font-weight: 500; color: var(--muted); list-style: none;
}
.history summary::before { content: '›  '; color: var(--terra-soft); }
.history[open] summary::before { content: '⌄  '; }
.history .muted { font-size: 13.5px; }
.history ul { list-style: none; padding: 0; margin: 10px 0 0; }
.history li {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14.5px;
}
.history li:last-child { border-bottom: none; }
.history li .btn { padding: 7px 16px; font-size: 13.5px; }

/* ---- zone d'ajout ---- */
.dropzone {
  display: block; text-align: center; cursor: pointer;
  border: 1.5px dashed var(--line); border-radius: var(--radius);
  padding: 30px 20px; margin-bottom: 12px; transition: all .2s;
}
.dropzone:hover, .dropzone.over, .dropzone:focus-visible { border-color: var(--terra); background: color-mix(in srgb, var(--terra) 6%, transparent); }
.dropzone:focus-visible { outline: 2px solid var(--terra); outline-offset: 3px; }
.dropzone.busy { opacity: 0.5; pointer-events: none; }

/* Pendant un envoi, la grille est figée : rien ne peut être déplacé ni retiré. */
#photo-grid.locked { opacity: 0.55; pointer-events: none; }
.gallery-card:disabled { opacity: 0.45; cursor: default; }
.dropzone strong { display: block; font-size: 17px; font-weight: 600; margin-bottom: 4px; }
.dropzone span { font-size: 13.5px; color: var(--muted); }

.progress {
  position: relative; height: 34px; border-radius: 999px; overflow: hidden;
  background: var(--ink-2); border: 1px solid var(--line); margin-bottom: 12px;
}
.progress div {
  position: absolute; inset: 0; width: 0%; background: var(--terra);
  transition: width .3s;
}
.progress span {
  position: relative; display: flex; align-items: center; justify-content: center;
  height: 100%; font-size: 13.5px; font-weight: 500;
}

.hint { font-size: 13px; margin: 18px 0 10px; }

/* ---- grille de photos ---- */
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.ph {
  position: relative; border-radius: 10px; overflow: hidden;
  background: var(--ink-2); border: 1px solid var(--line);
  aspect-ratio: 3 / 3.2; cursor: grab;
}
.ph:active { cursor: grabbing; }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.ph.dragging { opacity: 0.35; }
.ph.drop-target { outline: 2px solid var(--terra); outline-offset: -2px; }
.ph .num {
  position: absolute; top: 8px; left: 8px; background: rgba(19,19,21,0.72);
  border-radius: 999px; font-size: 12px; padding: 2px 9px; backdrop-filter: blur(4px);
}
.ph .del {
  position: absolute; top: 6px; right: 6px; width: 30px; height: 30px;
  border-radius: 50%; border: none; cursor: pointer;
  background: rgba(19,19,21,0.72); color: var(--ivory); font-size: 15px;
  opacity: 0; transition: opacity .2s; backdrop-filter: blur(4px);
}
.ph:hover .del { opacity: 1; }
.ph .movers {
  position: absolute; bottom: 6px; right: 6px; display: flex; gap: 4px;
  opacity: 0; transition: opacity .2s;
}
.ph:hover .movers { opacity: 1; }
.ph .movers button {
  width: 30px; height: 30px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(19,19,21,0.72); color: var(--ivory); font-size: 14px;
  backdrop-filter: blur(4px);
}
.ph .movers button:hover, .ph .del:hover { background: var(--terra); }

/* ---- modale / toast ---- */
.overlay {
  position: fixed; inset: 0; background: rgba(10,10,12,0.7);
  display: flex; align-items: center; justify-content: center; z-index: 20;
  backdrop-filter: blur(3px); padding: 24px;
}
.modal { max-width: 430px; width: 100%; }
.modal h2 { margin: 0 0 8px; font-size: 20px; }
.modal p { margin: 0 0 22px; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* Un message d'erreur reste affiché jusqu'à ce qu'on le ferme : c'est parfois
   la seule trace d'un échec de publication. */
.toast-close {
  background: none; border: 0; color: inherit; cursor: pointer;
  font-size: 15px; line-height: 1; padding: 2px 0 2px 14px; opacity: 0.75;
}
.toast-close:hover { opacity: 1; }
.toast.err { display: flex; align-items: flex-start; gap: 4px; text-align: left; }

.toast {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  background: var(--ink-3); border: 1px solid var(--line); color: var(--ivory);
  border-radius: 20px; padding: 12px 22px; font-size: 14.5px; z-index: 30;
  box-shadow: 0 8px 30px rgba(0,0,0,0.45);
  max-width: min(560px, calc(100vw - 32px)); text-align: center; line-height: 1.45;
}
.toast.ok { border-color: var(--ok); }
.toast.err { border-color: var(--danger); }

/* ---- mobile ---- */
@media (pointer: coarse) {
  .ph .del, .ph .movers { opacity: 1; }
}
.topnav .btn { white-space: nowrap; }

@media (max-width: 640px) {
  .banner { flex-direction: column; align-items: stretch; }
  .banner-actions { justify-content: stretch; }
  .banner-actions .btn { flex: 1; }
  .topbar { padding: 12px 16px; gap: 10px; }
  .topbar .wordmark { font-size: 15px; white-space: nowrap; }
  .topnav { gap: 6px; }
  .topnav .btn { padding: 8px 13px; font-size: 13px; }
  .container { padding: 4px 16px 60px; }
  .page-head h1 { font-size: 24px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}
