/* ============================================================
   Albums photo — esthétique « galerie éditoriale »
   Serif pour les titres, sans pour l'UI · palette ivoire/charbon/laiton
   Hairlines plutôt qu'ombres · mosaïque pour les photos
   Accessibilité conservée : contraste AA, cibles >=44px, focus visible, clavier
   ============================================================ */

:root {
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* Clair — papier ivoire */
  --bg: #f3efe7;
  --surface: #faf8f3;
  --surface-2: #ece6da;
  --ink: #211e18;
  --ink-soft: #6c6555;
  --line: #ddd5c6;
  --accent: #2a4a73;       /* bleu nuit / encre */
  --accent-ink: #fbf7f0;
  --danger: #a23a2c;
  --shadow: 0 1px 2px rgba(33, 30, 24, .05);
  --focus: #2a4a73;
}

:root[data-theme="dark"] {
  --bg: #15130f;
  --surface: #1c1a15;
  --surface-2: #262219;
  --ink: #ece6d8;
  --ink-soft: #9d957f;
  --line: #322d24;
  --accent: #86a9d6;
  --accent-ink: #0f1722;
  --danger: #e06a58;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --focus: #86a9d6;
}

* { box-sizing: border-box; }
html { font-size: 17px; }

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  transition: background-color .35s ease, color .35s ease;   /* bascule de thème douce */
  /* Footer collant : le contenu pousse le footer en bas même quand la page est courte. */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============================ Animations ============================ */
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes lbZoom { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }

main.container { animation: fadeUp .4s ease both; flex: 1 0 auto; }  /* occupe l'espace → footer en bas */
.album-card { animation: fadeUp .5s ease both; }
.tile { animation: fadeUp .5s ease both; }                     /* délai en cascade posé via JS */

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2;
  letter-spacing: .01em; margin: 0 0 .4em; }
h1 { font-size: 2.1rem; }
h2 { font-size: 1.6rem; }
a { color: var(--accent); text-underline-offset: 2px; }

.container { width: 100%; max-width: 1320px; margin: 0 auto; padding: 2rem clamp(1.1rem, 3.5vw, 3rem) 4rem; }

/* Icônes SVG inline */
.ic { width: 1.2em; height: 1.2em; display: inline-block; vertical-align: -.22em; flex: none; }

.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.skip-link { position: absolute; left: 8px; top: -48px; z-index: 100; background: var(--ink);
  color: var(--bg); padding: .6rem 1rem; transition: top .15s; }
.skip-link:focus { top: 8px; }

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

/* ============================ Barre supérieure ============================ */
.topbar { position: sticky; top: 0; z-index: 40; background: var(--surface);
  border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1320px; margin: 0 auto; display: flex; align-items: center;
  gap: 1.5rem; padding: .7rem clamp(1.1rem, 3.5vw, 3rem); flex-wrap: wrap; }

.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--ink); }
.brand-mark { color: var(--accent); display: inline-flex; }
.brand-mark .ic { width: 1.7rem; height: 1.7rem; }
.brand-name { font-family: var(--serif); font-size: 1.4rem; letter-spacing: .02em; }

.search { position: relative; flex: 1 1 260px; min-width: 180px; display: flex; align-items: center; }
.search-icon { position: absolute; left: .1rem; top: 50%; transform: translateY(-50%);
  color: var(--ink-soft); pointer-events: none; }
.search input { width: 100%; padding: .55rem .2rem .55rem 1.9rem; font-size: 1rem;
  font-family: inherit; color: var(--ink); background: transparent; border: 0;
  border-bottom: 1.5px solid var(--line); border-radius: 0; min-height: 44px; }
.search input::placeholder { color: var(--ink-soft); }
.search input:focus { outline: none; border-bottom-color: var(--accent); }

/* margin-left:auto garde les actions à droite même sans la barre de recherche. */
.topbar-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin-left: auto; }

/* ============================ Boutons ============================ */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 44px; padding: .55rem 1.05rem; font-size: .95rem; font-family: var(--sans);
  font-weight: 600; letter-spacing: .01em; border-radius: 3px; border: 1px solid transparent;
  cursor: pointer; text-decoration: none; transition: background .15s, color .15s, border-color .15s; }
.btn-primary { background: var(--ink); color: var(--bg); }
.btn-primary:hover { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--ink); }
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.inline-form { display: inline; margin: 0; }

@media (max-width: 760px) {
  .topbar-actions .btn-label { display: none; }
  .topbar-actions .btn { padding: .55rem .7rem; }
}

/* ============================ Messages ============================ */
.messages { max-width: 1320px; margin: 1rem auto 0; padding: 0 clamp(1.1rem, 3.5vw, 3rem);
  display: grid; gap: .5rem; }
.message { padding: .8rem 1.1rem; background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--accent); }
.message-error { border-left-color: var(--danger); }
.message-success { border-left-color: var(--accent); }

/* ============================ En-têtes de page ============================ */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem;
  flex-wrap: wrap; margin-bottom: 1.6rem; padding-bottom: 1.1rem; border-bottom: 1px solid var(--line); }
.page-head h1 { margin: 0; }
.page-head .actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.meta { color: var(--ink-soft); }
nav.meta { margin-bottom: .6rem; font-size: .9rem; letter-spacing: .02em; }

/* ============================ Grille d'albums (éditoriale) ============================ */
.grid { display: grid; gap: 2rem clamp(1.2rem, 2.5vw, 2.2rem);
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }

.album-card { display: flex; flex-direction: column; background: none; border: 0; box-shadow: none; }
.album-card a.cover { display: block; position: relative; aspect-ratio: 5 / 4; overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--line); text-decoration: none; }
.album-card .cover img { width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .5s ease; }
.album-card:hover .cover img, .album-card:focus-within .cover img { transform: scale(1.045); }
.album-card .cover .locked-overlay { position: absolute; inset: 0; display: grid; place-items: center;
  gap: .4rem; grid-auto-flow: row; background: rgba(20, 17, 12, .42); color: #f3efe7; }
.album-card .cover .locked-overlay .ic { width: 2rem; height: 2rem; }
.album-card .cover .locked-overlay span.lbl { font-size: .72rem; letter-spacing: .14em;
  text-transform: uppercase; }
.album-card .body { padding: .8rem .1rem 0; display: flex; flex-direction: column; gap: .25rem; }
.album-card .body h3 { font-size: 1.3rem; margin: 0; }
.album-card .meta-line { font-size: .76rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-soft); }
.badge.lock { color: var(--accent); }
.album-card .admin-row { display: flex; gap: .4rem; padding-top: .6rem; flex-wrap: wrap; }

.empty { text-align: center; color: var(--ink-soft); padding: 4rem 1rem; font-family: var(--serif);
  font-size: 1.2rem; }

/* ============================ Mosaïque de photos ============================ */
#photo-grid { column-width: 300px; column-gap: 1.25rem; }
.tile { position: relative; break-inside: avoid; margin: 0 0 1.25rem; width: 100%;
  display: inline-block; background: var(--surface); border: 1px solid var(--line); }
.tile .photo-btn { display: block; width: 100%; border: 0; padding: 0; cursor: zoom-in; background: none; }
.tile img { width: 100%; display: block; height: auto; }
.tile .caption { padding: .55rem .7rem; font-size: .9rem; color: var(--ink-soft); font-family: var(--serif);
  font-style: italic; }

.tile-controls { position: absolute; inset: 0; pointer-events: none; }
.tile-corner { position: absolute; top: .55rem; left: .55rem; pointer-events: auto;
  display: inline-flex; padding: 5px; border-radius: 3px; background: rgba(20, 17, 12, .55);
  backdrop-filter: blur(2px); opacity: 0; transition: opacity .15s; }
/* La case n'apparaît qu'au survol / focus, ou reste visible si elle est cochée. */
.tile:hover .tile-corner, .tile:focus-within .tile-corner, .tile.selected .tile-corner { opacity: 1; }
.sel-check { width: 22px; height: 22px; accent-color: var(--accent); cursor: pointer; display: block; margin: 0; }

.tile-bottom { position: absolute; bottom: .55rem; right: .55rem; display: flex; gap: .4rem;
  pointer-events: auto; }
.icon-btn { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 3px;
  border: 0; cursor: pointer; background: rgba(20, 17, 12, .62); color: #f6f2ea; opacity: 0;
  transition: opacity .15s, background .15s; backdrop-filter: blur(2px); }
.icon-btn .ic { width: 20px; height: 20px; }
.tile:hover .icon-btn, .tile:focus-within .icon-btn { opacity: 1; }
.icon-btn:hover { background: rgba(20, 17, 12, .85); }
.icon-btn.always { opacity: .9; }            /* « Options » : toujours visible (tactile / sans survol) */
.tile.is-hidden { outline: 2px dashed var(--danger); outline-offset: -2px; }

/* Menu d'options */
.menu { position: relative; }
.menu-panel { position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 20; min-width: 210px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: 0 8px 28px rgba(20,17,12,.18);
  padding: .35rem; display: none; }
.menu-panel.open { display: block; }
.menu-panel button, .menu-panel a { display: flex; width: 100%; align-items: center; gap: .65rem;
  padding: .6rem .7rem; min-height: 44px; border: 0; background: none; color: var(--ink);
  font: inherit; text-align: left; cursor: pointer; text-decoration: none; }
.menu-panel button:hover, .menu-panel a:hover { background: var(--surface-2); }
.menu-panel .ic { width: 18px; height: 18px; color: var(--ink-soft); }
.menu-panel .danger { color: var(--danger); }
.menu-panel .danger .ic { color: var(--danger); }

/* ============================ Sélection multiple ============================ */
.selbar { position: sticky; bottom: 1.2rem; margin-top: 1.5rem; display: none; align-items: center;
  gap: 1rem; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 8px 28px rgba(20,17,12,.16); padding: .7rem 1.1rem; }
.selbar.show { display: flex; }

/* ============================ Lightbox ============================ */
.lightbox { position: fixed; inset: 0; z-index: 80; background: rgba(12, 10, 8, .96);
  opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .25s ease, visibility .25s; }
.lightbox.open { opacity: 1; visibility: visible; pointer-events: auto; }
.lb-stage { position: absolute; inset: 0; display: grid; place-items: center; padding: 3rem; }
.lb-img { max-width: 90vw; max-height: 86vh; object-fit: contain;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  opacity: 0; transform: scale(.97); }     /* masquée par défaut (pendant le chargement) */
/* Révélée une seule fois, quand l'image est prête → fondu+zoom propre, sans clignotement. */
.lb-img.ready { opacity: 1; transform: none; transition: opacity .25s ease, transform .25s ease; }

.lb-zone { position: absolute; top: 0; bottom: 0; width: 28%; border: 0; cursor: pointer;
  background: linear-gradient(var(--dir), rgba(0,0,0,.4), rgba(0,0,0,0)); opacity: 0; transition: opacity .2s; }
.lb-zone.left { left: 0; --dir: to right; }
.lb-zone.right { right: 0; --dir: to left; }
.lightbox:hover .lb-zone { opacity: .18; }
.lb-zone:hover { opacity: .5 !important; }

.lb-arrow { position: absolute; top: 50%; transform: translateY(-50%); z-index: 2; width: 56px;
  height: 56px; display: grid; place-items: center; border-radius: 3px; border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.06); color: #f6f2ea; cursor: pointer; }
.lb-arrow .ic { width: 26px; height: 26px; }
.lb-arrow:hover { background: rgba(255,255,255,.16); }
.lb-arrow.prev { left: 1.4rem; }
.lb-arrow.next { right: 1.4rem; }

.lb-close { position: absolute; top: 1.1rem; right: 1.2rem; z-index: 3; display: inline-flex;
  align-items: center; gap: .5rem; min-height: 44px; padding: .5rem .9rem; border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.06); color: #f6f2ea; cursor: pointer; font: inherit; font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase; font-size: .8rem; }
.lb-close:hover { background: rgba(255,255,255,.16); }
.lb-counter { position: absolute; top: 1.3rem; left: 1.4rem; z-index: 2; color: #cfc7b8;
  font-size: .85rem; letter-spacing: .14em; }

.lb-info { position: absolute; left: 0; right: 0; bottom: 0; z-index: 2; padding: 2.4rem 1.6rem 1.4rem;
  color: #f3efe7; background: linear-gradient(to top, rgba(0,0,0,.82), rgba(0,0,0,0));
  transform: translateY(100%); transition: transform .25s; display: flex; flex-wrap: wrap;
  gap: .35rem 1.6rem; align-items: center; }
.lb-info.show { transform: translateY(0); }
.lb-info .lb-title { font-family: var(--serif); font-size: 1.2rem; width: 100%; margin-bottom: .2rem; }
.lb-info span { display: inline-flex; align-items: center; gap: .4rem; color: #d8d0c1; font-size: .92rem; }
.lb-info .lb-people { color: var(--accent); }
.lb-info .lb-dl { margin-left: auto; }

.no-download img { -webkit-user-select: none; user-select: none; -webkit-user-drag: none; }
.no-download { -webkit-touch-callout: none; }

/* ============================ Panneaux & formulaires ============================ */
.panel { max-width: 580px; margin: 2.5rem auto; background: var(--surface); border: 1px solid var(--line);
  padding: clamp(1.6rem, 4vw, 2.6rem); }
.panel.lock-panel { text-align: center; }
.panel .lock-emoji { color: var(--accent); }
.panel .lock-emoji .ic { width: 2.6rem; height: 2.6rem; }
.field { margin-bottom: 1.1rem; }
.field label { display: block; font-weight: 600; margin-bottom: .35rem; }
.field .help { color: var(--ink-soft); font-size: .9rem; margin-top: .3rem; }
.field input[type=text], .field input[type=password], .field input[type=search],
.field input[type=file], .field textarea, .field select {
  width: 100%; padding: .75rem .9rem; font-size: 1rem; font-family: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: 3px; min-height: 48px; }
.field input:focus, .field textarea:focus, .field select:focus { outline: none; border-color: var(--accent); }
.field textarea { min-height: 96px; }
.checkline { display: flex; align-items: center; gap: .7rem; padding: .5rem 0; }
.checkline input { width: 22px; height: 22px; accent-color: var(--accent); }
.form-actions { display: flex; gap: .7rem; flex-wrap: wrap; margin-top: 1.2rem; align-items: center; }
.errorlist { color: var(--danger); list-style: none; padding: 0; margin: .3rem 0 0; font-weight: 600; }

/* Assistant de nommage */
.subject-photo { display: grid; grid-template-columns: 240px 1fr; gap: 1.6rem; align-items: start;
  background: var(--surface); border: 1px solid var(--line); padding: 1.2rem; }
.subject-photo img { width: 100%; border: 1px solid var(--line); }
.subject-photo h3 { font-size: 1.05rem; }
.subject-row { display: flex; gap: .6rem; align-items: center; margin-bottom: .6rem; flex-wrap: wrap; }
.subject-row .label { font-weight: 600; min-width: 110px; letter-spacing: .03em; }
.subject-row input { flex: 1 1 200px; }
.subject-row .named { color: var(--accent); font-weight: 600; font-size: .85rem; letter-spacing: .04em; }
.progress { color: var(--ink-soft); margin-bottom: 1.2rem; font-family: var(--serif); font-size: 1.05rem; }

@media (max-width: 560px) { .subject-photo { grid-template-columns: 1fr; } }

.footer { text-align: center; color: var(--ink-soft); padding: 2.5rem 1rem 3rem;
  border-top: 1px solid var(--line); font-size: .9rem; letter-spacing: .02em; flex-shrink: 0; }

/* ============================ Résultats de recherche ============================ */
.search-results { position: absolute; left: 0; right: 0; top: calc(100% + 6px); background: var(--surface);
  border: 1px solid var(--line); box-shadow: 0 12px 34px rgba(20,17,12,.18); padding: .5rem;
  max-height: 70vh; overflow: auto; z-index: 50; min-width: 320px;
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: opacity .18s ease, transform .18s ease, visibility .18s; }
.search-results.open { opacity: 1; visibility: visible; transform: none; }
.search-results h4 { margin: .6rem .5rem .3rem; color: var(--ink-soft); font-family: var(--sans);
  font-size: .72rem; text-transform: uppercase; letter-spacing: .14em; }
.sr-item { display: flex; gap: .8rem; align-items: center; padding: .5rem; text-decoration: none;
  color: var(--ink); min-height: 56px; }
.sr-item:hover { background: var(--surface-2); }
.sr-item img { width: 46px; height: 46px; object-fit: cover; background: var(--surface-2);
  border: 1px solid var(--line); flex: none; }
.sr-item .sr-sub { color: var(--ink-soft); font-size: .85rem; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
