/* ============================================================
   braunbenjamin.com — feuille de style
   Ambiance : mémorial, sobre, douce, respectueuse.
   ============================================================ */

:root {
  --bg:      #f5f3ef;
  --surface: #ffffff;
  --ink:     #2e2a26;
  --muted:   #7c736a;
  --accent:  #6b7f8c;
  --accent-d:#54646f;
  --line:    #e4ded4;
  --danger:  #b4553f;
  --ok:      #5c7a55;
  --shadow:  0 1px 3px rgba(46,42,38,.08), 0 8px 24px rgba(46,42,38,.06);
  --radius:  10px;
  --serif:   Georgia, "Times New Roman", "Noto Serif", serif;
  --sans:    system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: var(--accent-d); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; color: var(--ink); }

img { max-width: 100%; height: auto; display: block; }

/* ---------- Structure ---------- */
.wrap { width: 100%; max-width: 1040px; margin: 0 auto; padding: 0 20px; }

.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.site-header .wrap {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding-top: 10px; padding-bottom: 10px;
}
.brand { font-family: var(--serif); font-size: 1.3rem; color: var(--ink); }
.brand small { display: block; font-size: .72rem; color: var(--muted); letter-spacing: .12em; text-transform: uppercase; font-family: var(--sans); }
.nav a { margin-left: 22px; color: var(--muted); font-size: .95rem; }
.nav a:hover, .nav a.active { color: var(--accent-d); text-decoration: none; }

main { flex: 1 0 auto; padding: 20px 0 16px; }

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: .82rem;
  text-align: center;
  padding: 11px 0;
  background: var(--surface);
}

/* ---------- Accueil ---------- */
.hero { text-align: center; padding: 30px 0 10px; }
.hero .portrait {
  width: 240px; height: 300px; object-fit: cover; object-position: center top;
  padding: 10px; background: #fff; border: 1px solid var(--line);
  border-radius: 6px; box-shadow: 0 8px 28px rgba(46,42,38,.18);
  margin: 0 auto 26px;
}
.hero .dates {
  font-family: var(--serif); font-weight: 600; color: var(--ink);
  font-size: 1.9rem; letter-spacing: .04em; margin: 0 0 22px;
}
.hero p.intro { max-width: 620px; margin: 0 auto 34px; color: #4a443d; }

.actions { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; }
.btn {
  display: inline-block; padding: 14px 30px; border-radius: var(--radius);
  font-size: 1.02rem; font-family: var(--serif); cursor: pointer; border: 1px solid transparent;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-d); text-decoration: none; }
.btn-ghost { background: var(--surface); color: var(--accent-d); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--accent); text-decoration: none; }

/* ---------- Titres de page ---------- */
.page-head { text-align: center; margin-bottom: 22px; }
.page-head h1 { font-size: 1.9rem; margin: 0 0 6px; }
.page-head p { color: var(--muted); margin: 0; }

/* ---------- Grille d'albums ---------- */
.album-grid, .photo-grid {
  display: grid; gap: 20px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); transition: transform .15s ease;
}
.card:hover { transform: translateY(-3px); text-decoration: none; }
.card .thumb { aspect-ratio: 4/3; overflow: hidden; background: #ece7df; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.card .meta { padding: 12px 14px; }
.card .meta h3 { font-size: 1.05rem; margin: 0 0 3px; }
.card .meta span { color: var(--muted); font-size: .85rem; }

/* ---------- Grille de photos ---------- */
.photo-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.photo-grid figure { margin: 0; }
.photo-grid button.ph {
  display: block; width: 100%; padding: 0; border: 1px solid var(--line); background: #ece7df;
  border-radius: var(--radius); overflow: hidden; cursor: zoom-in; aspect-ratio: 1/1;
}
.photo-grid button.ph img { width: 100%; height: 100%; object-fit: cover; }
.photo-grid figcaption { font-size: .82rem; color: var(--muted); padding: 6px 2px 0; text-align: center; }

.back-link { display: inline-block; margin-bottom: 20px; color: var(--muted); }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed; inset: 0; background: rgba(30,26,22,.92);
  display: none; align-items: center; justify-content: center; z-index: 50; padding: 30px;
}
.lightbox.open { display: flex; }
.lightbox img { max-width: 92vw; max-height: 82vh; border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
.lightbox .lb-cap { position: absolute; bottom: 24px; left: 0; right: 0; text-align: center; color: #f2ede5; font-size: .95rem; }
.lightbox button {
  position: absolute; background: rgba(255,255,255,.12); color: #fff; border: none;
  width: 46px; height: 46px; border-radius: 50%; font-size: 1.4rem; cursor: pointer;
}
.lb-close { top: 20px; right: 20px; }
.lb-prev { left: 18px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 18px; top: 50%; transform: translateY(-50%); }
.lightbox button:hover { background: rgba(255,255,255,.24); }

/* ---------- Pensées ---------- */
/* Mur de pensées : colonnes façon masonry, hauteurs variables gérées nativement */
.thoughts-wall { columns: 2; column-gap: 18px; margin-bottom: 6px; }
@media (max-width: 640px) { .thoughts-wall { columns: 1; } }

.thought {
  background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: var(--radius); padding: 14px 18px; box-shadow: var(--shadow);
  break-inside: avoid; -webkit-column-break-inside: avoid; page-break-inside: avoid;
  margin: 0 0 18px; width: 100%;
}
.thought .msg { white-space: normal; margin: 0 0 8px; color: #3b352e; font-size: .96rem; line-height: 1.55; }
/* Repli des messages longs à 6 lignes (déplié en JS via le bouton « Lire la suite ») */
.thought .msg.clamp {
  display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 70%, transparent 100%);
          mask-image: linear-gradient(to bottom, #000 70%, transparent 100%);
}
.thought .more {
  background: none; border: none; padding: 0 0 6px; cursor: pointer;
  color: var(--accent-d); font: inherit; font-size: .85rem;
}
.thought .more:hover { text-decoration: underline; }
.thought .sig { font-size: .84rem; color: var(--muted); }
.thought .sig strong { color: var(--ink); font-weight: 600; }

/* ---------- Formulaires ---------- */
.form-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 26px; box-shadow: var(--shadow); margin-top: 40px;
}
.form-card h2 { margin-top: 0; font-size: 1.35rem; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: .9rem; color: var(--muted); margin-bottom: 5px; }
.field input, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-family: inherit; font-size: 1rem; color: var(--ink); background: #fcfbf9;
}
.field input:focus, .field textarea:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
.field textarea { min-height: 130px; resize: vertical; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.alert { border-radius: 8px; padding: 12px 16px; margin-bottom: 18px; font-size: .95rem; }
.alert-ok { background: #eef3ec; color: var(--ok); border: 1px solid #cfe0c9; }
.alert-err { background: #f7ece9; color: var(--danger); border: 1px solid #e8cfc7; }
.alert-err ul { margin: 6px 0 0; padding-left: 18px; }

.empty { text-align: center; color: var(--muted); padding: 40px 0; }

/* ---------- Pagination ---------- */
.pager { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 30px; }
.pager .pg {
  display: inline-block; padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--accent-d); font-size: .92rem;
}
.pager a.pg:hover { border-color: var(--accent); text-decoration: none; }
.pager .pg.disabled { color: #c3bcb1; background: transparent; border-color: transparent; }
.pager .pg-nums { display: inline-flex; gap: 6px; }
.pager .pg.num { min-width: 40px; text-align: center; padding: 8px 10px; }
.pager .pg.num.current { background: var(--accent); color: #fff; border-color: var(--accent); cursor: default; }
.pager-info { text-align: center; color: var(--muted); font-size: .82rem; margin-top: 12px; }

@media (max-width: 560px) {
  .pager .pg-nums { order: 3; width: 100%; justify-content: center; margin-top: 8px; }
}

/* ---------- Haut du recueil : titre centré + bouton à droite ---------- */
.thoughts-top { position: relative; margin-bottom: 12px; }
.thoughts-top .page-head { margin-bottom: 0; }
.leave-btn { position: absolute; right: 0; top: 50%; transform: translateY(-50%); }
.form-panel { margin: 0 0 18px; }
.form-panel[hidden] { display: none; }
.form-panel .form-card { margin-top: 0; }

@media (max-width: 720px) {
  .thoughts-top { text-align: center; }
  .leave-btn { position: static; transform: none; display: inline-block; margin: 14px auto 0; }
}

/* ---------- Recueil façon livre ---------- */
.book { margin-top: 6px; }
.book-book { position: relative; perspective: 2200px; }
.spread {
  display: flex; border-radius: 12px; overflow: hidden; background: #fdfbf7;
  box-shadow: 0 12px 44px rgba(46,42,38,.16); transition: opacity .28s ease;
  /* Le livre ne dépasse jamais la hauteur de la fenêtre, mais prend tout le reste */
  height: clamp(360px, calc(100vh - 338px), 800px);
}
.spread.swapping { opacity: 0; }
.page {
  flex: 1 1 50%; min-width: 0; min-height: 0; padding: 20px 32px;
  background: linear-gradient(160deg, #fdfbf7, #f6f1e7);
  display: flex; flex-direction: column; overflow: hidden; /* pas de barre : le texte s'ajuste (JS) */
}
.page:first-child:not(:only-child) { box-shadow: inset -16px 0 28px -22px rgba(46,42,38,.42); }
.page:last-child:not(:only-child)  { border-left: 1px solid #e8e0d0; box-shadow: inset 16px 0 28px -22px rgba(46,42,38,.42); }

/* Une pensée par page : centrée verticalement (margin auto), pleine largeur de page.
   La taille de base est ici ; book.js la réduit seulement si la pensée est trop longue. */
.page .thought {
  background: transparent; border: none; box-shadow: none; border-radius: 0;
  padding: 0; margin: auto; max-width: none; width: 100%; font-size: .97rem;
}
.page .msg { font-size: 1em; line-height: 1.62; color: #3b352e; }
.page .sig { margin-top: 16px; text-align: right; font-style: italic; font-size: .86em; }
.page .sig strong { font-style: normal; }

/* Feuille qui se retourne */
.leaf {
  position: absolute; top: 0; bottom: 0; width: 50%; z-index: 3;
  background: linear-gradient(160deg, #fdfbf7, #f1ebdd);
  opacity: 0; pointer-events: none;
  backface-visibility: hidden; transform-style: preserve-3d;
  box-shadow: 0 0 34px rgba(46,42,38,.28);
}
.leaf.from-right { left: 50%; transform-origin: left center;  transform: rotateY(0deg); }
.leaf.from-left  { left: 0;   transform-origin: right center; transform: rotateY(0deg); }
.leaf.turning { transition: transform .6s ease, opacity .6s ease; }
.leaf.from-right.turning { transform: rotateY(-168deg); opacity: 1; }
.leaf.from-left.turning  { transform: rotateY(168deg);  opacity: 1; }

.book-nav { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 12px; }
.book-nav .pg {
  min-width: 128px; padding: 10px 18px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--accent-d); font: inherit; font-size: .95rem; cursor: pointer;
}
.book-nav .pg:hover:not([disabled]) { border-color: var(--accent); }
.book-nav .pg[disabled] { opacity: .38; cursor: default; }
.book-count { color: var(--muted); font-size: .9rem; min-width: 110px; text-align: center; }

.book-extra { text-align: center; margin-top: 8px; min-height: 22px; }
.book-restart {
  background: none; border: none; cursor: pointer; font: inherit; font-size: .85rem;
  color: var(--muted); padding: 4px 8px;
}
.book-restart:hover { color: var(--accent-d); text-decoration: underline; }

@media (max-width: 640px) {
  .page { min-height: 62vh; padding: 20px 18px; }
  .leaf { width: 100%; }
  .leaf.from-right { left: 0; }
  .book-nav { gap: 10px; }
  .book-nav .pg { min-width: 0; flex: 1; }
}

/* ---------- Admin ---------- */
.admin-body { background: #eef0f1; }
.admin-bar { background: var(--ink); color: #f3efe8; }
.admin-bar .wrap { display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; }
.admin-bar a { color: #d8d2c8; margin-left: 18px; font-size: .92rem; }
.admin-bar a:hover { color: #fff; }
.admin-bar .logout { display: inline; }
.admin-bar button.link { background: none; border: none; color: #d8d2c8; cursor: pointer; font: inherit; }

.stat-row { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 30px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 26px; flex: 1; min-width: 150px; }
.stat .n { font-size: 2rem; font-family: var(--serif); }
.stat .l { color: var(--muted); font-size: .85rem; }
.stat.warn .n { color: var(--danger); }

table.admin { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table.admin th, table.admin td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: .93rem; }
table.admin th { background: #f6f4f0; color: var(--muted); font-weight: 600; }
.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: .78rem; }
.pill-pending { background: #f6efe0; color: #9a7b30; }
.pill-published { background: #eaf1e8; color: var(--ok); }

.inline-form { display: inline; }
.btn-sm { padding: 6px 12px; font-size: .84rem; border-radius: 6px; font-family: var(--sans); }
.btn-ok { background: var(--ok); color: #fff; border: none; cursor: pointer; }
.btn-warn { background: var(--danger); color: #fff; border: none; cursor: pointer; }
.btn-neutral { background: #e7e2da; color: var(--ink); border: none; cursor: pointer; }

.login-wrap { max-width: 360px; margin: 60px auto; }

@media (max-width: 560px) {
  body { font-size: 16px; }
  .site-header .wrap { flex-direction: column; align-items: flex-start; gap: 8px; }
  .nav a { margin-left: 0; margin-right: 18px; }
  .hero h1 { font-size: 1.7rem; }
}
