/* ────────────────────────────────────────────────────────────────────
   Notre Histoire — design system
   Charte issue du brief §6 (Fraunces + Geist + creme chaud)
   ──────────────────────────────────────────────────────────────────── */

:root {
  --bg:           #FAF8F4;
  --bg-card:      #FFFFFF;
  --ink:          #1C1A17;
  --ink-soft:     #3D3A35;
  --muted:        #6B6963;
  --whisper:      #A39C92;
  --accent:       #A8503D;
  --border:       rgba(28, 26, 23, 0.06);
  --border-strong:rgba(28, 26, 23, 0.12);
  --error-bg:     #FBEBE6;
  --error-ink:    #7E2A1A;
  --ok-bg:        #E8EFE3;
  --ok-ink:       #2F5A2A;

  --font-display: 'Fraunces', 'Times New Roman', serif;
  --font-ui:      'Geist', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  --r-xs: 6px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-weight: 400;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

input, button, select, textarea { font-family: inherit; }

a { color: var(--ink); text-decoration: none; }
a:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }

/* ── Typo systeme ─────────────────────────────────────────────────── */
.display {
  font-family: var(--font-display);
  font-weight: 300;
  font-style: italic;
  font-variation-settings: "opsz" 144, "SOFT" 100;
  font-size: clamp(34px, 7vw, 64px);
  line-height: 1.05;
  letter-spacing: -0.01em;
  margin: 0 0 24px;
  color: var(--ink);
}

.kicker {
  font-family: var(--font-ui);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 24px;
}

.lead {
  color: var(--ink-soft);
  font-size: 17px;
  line-height: 1.6;
  margin: 0 0 32px;
  max-width: 56ch;
}

/* ── Boutons ──────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  text-decoration: none;
  transition: transform .12s ease, background .2s ease, color .2s ease;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.98); }

.btn-primary { background: var(--ink); color: var(--bg); }
.btn-primary:hover { background: #2a2620; }

.btn-secondary {
  background: transparent;
  color: var(--ink);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: rgba(28,26,23,0.04); }

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
}
.btn-ghost:hover { color: var(--ink); }

.btn-block { width: 100%; }

/* ── Cards & layouts ──────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 32px;
  box-shadow: 0 1px 2px rgba(28,26,23,0.02);
}

.page { padding: 32px 20px; max-width: 720px; margin: 0 auto; }

.hero { padding: 32px 0; }

/* ── Top bar ──────────────────────────────────────────────────────── */
.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky; top: 0; z-index: 10;
  backdrop-filter: saturate(120%) blur(8px);
}
.topbar-inner {
  max-width: 720px; margin: 0 auto;
  padding: 16px 20px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
}
.brand {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 18px;
  letter-spacing: -0.01em;
}
.topbar-nav { display: flex; gap: 18px; }
.topbar-nav .link {
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}
.topbar-nav .link:hover { color: var(--ink); text-decoration: none; }

.cta-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px; }

/* ── Hello (Etape 0) ──────────────────────────────────────────────── */
.hello-wrap {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 32px 20px;
}
.hello-card { max-width: 640px; text-align: left; }
.hello-status {
  display: inline-flex; align-items: center; gap: 10px;
  margin-top: 16px;
  font-weight: 500; font-size: 11px;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--whisper);
}
.hello-status .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .4; transform: scale(0.8); }
}

/* ── Auth (login / onboarding / invite) ───────────────────────────── */
.auth-wrap {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px 20px 60px;
}
.auth-card {
  width: 100%; max-width: 480px;
}
.auth-tabs {
  display: flex; gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  margin: 0 0 24px;
  width: max-content;
}
.auth-tab {
  border: 0; background: transparent;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px; font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: background .2s, color .2s;
}
.auth-tab.active { background: var(--ink); color: var(--bg); }
.auth-tab:hover:not(.active) { color: var(--ink); }

.form { display: flex; flex-direction: column; gap: 16px; margin-top: 8px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field .label {
  font-size: 11px; font-weight: 500;
  letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--muted);
}
.field input {
  padding: 14px 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--bg-card);
  color: var(--ink);
  font-size: 15px;
  transition: border .2s, box-shadow .2s;
}
.field input:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 4px rgba(28,26,23,0.06);
}
.field .hint {
  font-size: 12px; color: var(--whisper);
}

.auth-after { margin-top: 20px; text-align: center; }

/* ── Invite share ─────────────────────────────────────────────────── */
.invite-card {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 24px;
  margin-top: 8px;
}
.invite-qr {
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  border-radius: var(--r-md);
  padding: 18px;
}
.invite-qr svg {
  width: 200px; height: 200px;
  display: block;
}
.invite-link { display: flex; flex-direction: column; gap: 8px; }
.link-readonly {
  padding: 12px 14px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-sm);
  background: var(--bg);
  color: var(--ink-soft);
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  width: 100%;
}
.link-readonly:focus { outline: none; border-color: var(--ink); }

@media (min-width: 560px) {
  .invite-card { grid-template-columns: auto 1fr; align-items: center; }
}

/* ── Flash messages ───────────────────────────────────────────────── */
.flash-zone {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 100; width: max-content; max-width: 92vw;
  display: flex; flex-direction: column; gap: 8px;
}
.flash {
  padding: 10px 16px;
  border-radius: var(--r-sm);
  font-size: 13px;
  box-shadow: 0 4px 16px rgba(28,26,23,0.08);
  animation: fadeIn .2s ease;
}
.flash-err { background: var(--error-bg); color: var(--error-ink); }
.flash-ok  { background: var(--ok-bg);    color: var(--ok-ink); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

/* ── Filter row + chips ───────────────────────────────────────────── */
.filter-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  margin-bottom: 24px;
}
.chips {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.chip {
  display: inline-flex; align-items: center;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background .2s, color .2s, border-color .2s;
}
.chip:hover { color: var(--ink); border-color: var(--border-strong); text-decoration: none; }
.chip-active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip-active:hover { color: var(--bg); }

/* ── Liste de carnets ─────────────────────────────────────────────── */
.carnet-list {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 14px;
}
.carnet-card {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 16px;
  padding: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  text-decoration: none;
  transition: border-color .2s, transform .12s;
}
.carnet-card:hover { border-color: var(--border-strong); text-decoration: none; }
.carnet-card:active { transform: scale(.99); }

.carnet-cover {
  width: 96px; height: 96px;
  border-radius: var(--r-sm);
  background: linear-gradient(135deg, #EFE7DD 0%, #E2D5C5 100%);
  display: flex; align-items: flex-end; justify-content: flex-start;
  padding: 8px;
}
.carnet-type {
  font-size: 10px; font-weight: 500;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--ink-soft);
  background: rgba(255,255,255,0.7);
  padding: 3px 7px;
  border-radius: 4px;
}

.carnet-meta { display: flex; flex-direction: column; justify-content: center; gap: 4px; min-width: 0; }
.carnet-title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 22px;
  line-height: 1.15;
  margin: 0;
  color: var(--ink);
  letter-spacing: -0.005em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.carnet-sub {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── Empty state ──────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 24px;
  background: var(--bg-card);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
}
.empty-display {
  font-family: var(--font-display);
  font-style: italic; font-weight: 300;
  font-variation-settings: "opsz" 144, "SOFT" 100;
  font-size: clamp(24px, 5vw, 36px);
  line-height: 1.1;
  margin: 0 0 12px;
  color: var(--ink);
}
.empty-lead {
  color: var(--ink-soft);
  margin: 0 auto 24px;
  max-width: 38ch;
  font-size: 15px;
}

/* ── Form wide (carnet) ───────────────────────────────────────────── */
.form-wide { max-width: 560px; }
.field-row {
  display: grid; grid-template-columns: 1fr;
  gap: 16px;
}
@media (min-width: 560px) {
  .field-row { grid-template-columns: 1fr 1fr; }
}

/* Segmented control */
.segmented {
  display: inline-flex;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 4px;
  gap: 2px;
  flex-wrap: wrap;
}
.seg {
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13px; font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  transition: background .2s, color .2s;
}
.seg:hover { color: var(--ink); }
.seg-active { background: var(--ink); color: var(--bg); }
.seg-active:hover { color: var(--bg); }

.form-actions {
  display: flex; gap: 12px; justify-content: flex-end;
  margin-top: 8px;
  flex-wrap: wrap;
}

/* ── Danger zone ──────────────────────────────────────────────────── */
.danger-zone {
  margin-top: 60px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end;
}
.btn-danger {
  background: transparent;
  color: var(--error-ink);
  border: 1px solid var(--error-ink);
}
.btn-danger:hover { background: var(--error-bg); }

/* ══════════════════════════════════════════════════════════════════
   ALBUM (v1.2)
   ══════════════════════════════════════════════════════════════════ */

.album-page { padding-bottom: 120px; } /* place pour le footer flottant */

.album-head { padding: 24px 0 8px; }

.save-indicator {
  margin-left: 12px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--whisper);
  transition: opacity .2s;
}
.save-indicator.saving { color: var(--muted); }
.save-indicator.saved  { color: #2F5A2A; }
.save-indicator.error  { color: var(--error-ink); }

.pages-list {
  list-style: none; padding: 0; margin: 24px 0;
  display: flex; flex-direction: column; gap: 32px;
}
.page-item {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px;
  transition: border-color .2s;
}
.page-item:hover { border-color: var(--border-strong); }
.page-item:hover .page-delete { opacity: 1; }

.page-photo {
  display: block;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--bg);
  cursor: zoom-in;
}
.page-photo img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 70vh;
  object-fit: contain;
  background: #f0eee9;
}

.page-caption-wrap { padding: 10px 4px 2px; }
.page-caption {
  width: 100%;
  border: 0;
  background: transparent;
  resize: none;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 17px;
  line-height: 1.4;
  color: var(--ink-soft);
  padding: 4px 0;
  outline: none;
}
.page-caption:focus { color: var(--ink); }
.page-caption::placeholder { color: var(--whisper); }

.page-text {
  width: 100%;
  border: 0;
  background: transparent;
  resize: none;
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 300;
  font-variation-settings: "opsz" 144, "SOFT" 50;
  font-size: 22px;
  line-height: 1.45;
  color: var(--ink);
  padding: 8px 4px;
  outline: none;
}
.page-text:focus { color: var(--ink); }
.page-text::placeholder { color: var(--whisper); }

.page-delete {
  position: absolute;
  top: 8px; right: 8px;
  width: 32px; height: 32px;
  border-radius: 50%;
  border: 0;
  background: rgba(28,26,23,0.55);
  color: white;
  font-size: 14px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .2s, background .2s;
  z-index: 2;
}
.page-delete:hover { background: var(--error-ink); }

@media (max-width: 480px) {
  .page-delete { opacity: 1; } /* toujours visible sur mobile */
  .page-photo img { max-height: 80vh; }
}

/* ── Footer flottant (FAB) ────────────────────────────────────────── */
.album-footer {
  position: fixed;
  bottom: 16px; left: 50%;
  transform: translateX(-50%);
  display: flex; gap: 8px;
  padding: 10px;
  background: var(--ink);
  color: var(--bg);
  border-radius: 999px;
  box-shadow: 0 12px 36px rgba(28,26,23,0.25);
  z-index: 50;
  max-width: calc(100vw - 24px);
}
.fab-btn {
  display: inline-flex; align-items: center; gap: 8px;
  border: 0; background: transparent;
  color: var(--bg);
  font-family: var(--font-ui);
  font-size: 13px; font-weight: 500;
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .2s;
  white-space: nowrap;
}
.fab-btn:hover { background: rgba(255,255,255,0.10); }
.fab-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  background: rgba(255,255,255,0.14);
  border-radius: 50%;
  font-size: 13px;
}

@media (max-width: 480px) {
  .fab-btn { padding: 10px 12px; font-size: 12px; }
  .fab-icon { width: 20px; height: 20px; font-size: 12px; }
}

/* ── Photo viewer plein ecran ─────────────────────────────────────── */
.photo-viewer {
  position: fixed; inset: 0;
  background: rgba(20, 18, 15, 0.96);
  z-index: 200;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.photo-viewer[hidden] { display: none !important; }

.viewer-stage {
  flex: 1;
  width: 100%;
  display: flex; align-items: center; justify-content: center;
  padding: 60px 60px 0;
  overflow: hidden;
}
.viewer-stage img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}
.viewer-caption {
  width: 100%;
  text-align: center;
  padding: 16px 24px 28px;
  color: rgba(255,255,255,0.78);
  font-family: var(--font-display);
  font-style: italic;
  font-size: 16px;
  line-height: 1.4;
  min-height: 60px;
}
.viewer-close, .viewer-prev, .viewer-next {
  position: absolute;
  background: rgba(255,255,255,0.10);
  color: white;
  border: 0;
  cursor: pointer;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .2s;
}
.viewer-close { top: 16px; right: 16px; width: 44px; height: 44px; font-size: 16px; }
.viewer-prev, .viewer-next { top: 50%; transform: translateY(-50%); width: 52px; height: 52px; font-size: 28px; line-height: 1; }
.viewer-prev { left: 16px; }
.viewer-next { right: 16px; }
.viewer-close:hover, .viewer-prev:hover, .viewer-next:hover { background: rgba(255,255,255,0.22); }

@media (max-width: 480px) {
  .viewer-stage { padding: 40px 12px 0; }
  .viewer-prev, .viewer-next { width: 40px; height: 40px; font-size: 22px; }
  .viewer-close { width: 36px; height: 36px; font-size: 14px; }
}

/* Ancien placeholder garde pour compat */
.album-placeholder {
  margin-top: 32px;
  padding: 60px 24px;
  background: var(--bg-card);
  border: 1px dashed var(--border-strong);
  border-radius: var(--r-lg);
  text-align: center;
}

/* ── Mobile ───────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .card { padding: 24px; border-radius: var(--r-md); }
  .auth-card { max-width: 100%; }
  .topbar-inner { padding: 12px 16px; }
  .topbar-nav { gap: 14px; }
  .filter-row { flex-direction: column; align-items: stretch; }
  .filter-row .btn { width: 100%; }
  .carnet-card { grid-template-columns: 72px 1fr; }
  .carnet-cover { width: 72px; height: 72px; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }
}
