/* ============================================================
   FONTS
   ============================================================ */
@font-face {
  font-family: 'General Sans';
  src: url('https://cdn.breizhzion.com/fonts/general-sans/GeneralSans-Variable.woff2') format('woff2');
  font-weight: 200 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Fraunces';
  src: url('https://cdn.breizhzion.com/fonts/fraunces/Fraunces-Variable.woff2') format('woff2');
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Fraunces';
  src: url('https://cdn.breizhzion.com/fonts/fraunces/Fraunces-Italic-Variable.woff2') format('woff2');
  font-weight: 300 900;
  font-style: italic;
  font-display: swap;
}

/* ============================================================
   VARIABLES
   ============================================================ */
:root {
  --paper: #F5EFE0;
  --paper-2: #FFFDF7;
  --ink: #1C1A17;
  --ink-muted: #6B6255;
  --line: rgba(28, 26, 23, 0.10);
  --seal: #B7312C;
  --seal-soft: rgba(183, 49, 44, 0.12);
  --jade: #4A7C59;
  --jade-soft: rgba(74, 124, 89, 0.12);
  --warn: #A8752E;
  --warn-soft: rgba(168, 117, 46, 0.12);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --font-display: 'Fraunces', 'Iowan Old Style', Georgia, serif;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  font-family: 'General Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
}
a { color: inherit; }
.seal-mark { display: block; }

/* ============================================================
   BOUTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: 10px;
  border: none;
  background: var(--seal);
  color: #FFFDF7;
  font-weight: 700;
  font-size: 15px;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: transform 160ms var(--ease-out), box-shadow 160ms var(--ease-out);
  box-shadow: 0 6px 16px rgba(183, 49, 44, 0.25);
}
.btn:hover  { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(183, 49, 44, 0.3); }
.btn:active { transform: scale(0.97); }
.btn.secondary {
  background: var(--paper-2);
  color: var(--ink);
  border: 1px solid var(--line);
  box-shadow: none;
}
.btn.secondary:hover { box-shadow: 0 4px 12px rgba(28, 26, 23, 0.1); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; transform: none; }

/* ============================================================
   CARTE
   ============================================================ */
.card {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 16px;
}

/* ============================================================
   ANIMATIONS GLOBALES
   ============================================================ */
.fade-in {
  animation: fadeIn 220ms var(--ease-out) both;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   NAVIGATION PUBLIQUE
   ============================================================ */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 32px;
  background: rgba(245, 239, 224, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.site-nav .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}
.site-nav .brand img  { height: 30px; width: auto; }
.site-nav .brand span {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: -0.01em;
}

/* ============================================================
   FOOTER PUBLIC
   ============================================================ */
.site-footer {
  border-top: 1px solid var(--line);
  padding: 28px 32px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-muted);
}

/* ============================================================
   HOMEPAGE — fond + effet grain
   ============================================================ */
body.page-home {
  background-image:
    radial-gradient(ellipse 900px 500px at 15% -10%, rgba(183, 49, 44, 0.06), transparent 60%),
    radial-gradient(ellipse 700px 500px at 100% 10%, rgba(74, 124, 89, 0.05), transparent 55%);
}
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  opacity: 0.045;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
body.page-home main { position: relative; z-index: 2; }

/* Hero */
.hero {
  max-width: 1040px;
  margin: 0 auto;
  padding: 88px 32px 64px;
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 48px;
  align-items: center;
}
.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--seal);
  margin: 0 0 18px;
}
.hero-eyebrow::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--seal);
}
.hero h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(38px, 5.2vw, 60px);
  line-height: 1.04;
  letter-spacing: -0.015em;
  margin: 0 0 22px;
}
.hero h1 em { font-style: italic; font-weight: 600; color: var(--seal); }
.hero p.lede {
  font-size: 17px;
  line-height: 1.65;
  color: var(--ink-muted);
  max-width: 46ch;
  margin: 0 0 28px;
}
.hero-note { font-size: 13px; color: var(--ink-muted); }
.hero-note strong { color: var(--ink); }

.hero-stamp {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hero-stamp img {
  width: min(340px, 100%);
  transform: rotate(-6deg);
  filter: drop-shadow(0 24px 48px rgba(183, 49, 44, 0.18));
}
.hero-stamp::before {
  content: '';
  position: absolute;
  width: 320px; height: 320px;
  border: 1px solid var(--line);
  border-radius: 50%;
  z-index: -1;
}

/* Sections */
section.block {
  max-width: 1040px;
  margin: 0 auto;
  padding: 56px 32px;
}
section.block + section.block { border-top: 1px solid var(--line); }

.section-head { max-width: 640px; margin: 0 0 36px; }
.section-head .kicker {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-muted);
  margin: 0 0 10px;
}
.section-head h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(26px, 3.2vw, 34px);
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin: 0;
}

/* Histoire */
.history {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  align-items: start;
}
.history p { font-size: 15.5px; line-height: 1.75; color: var(--ink-muted); margin: 0 0 16px; }
.history p strong { color: var(--ink); font-weight: 600; }
.history-mark {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 20px;
  overflow: hidden;
  transition: transform 0.28s var(--ease-out), box-shadow 0.28s var(--ease-out);
}
.history-mark:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(28, 26, 23, 0.12);
}
.history-mark figure { margin: 0; }
.history-mark img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.history-mark figcaption { padding: 20px 24px 24px; text-align: center; }
.history-mark .hangul {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin: 0 0 6px;
}
.history-mark .caption-note { font-size: 13px; color: var(--ink-muted); margin: 0; }

/* Étapes */
.steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}
.step {
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px 20px;
  position: relative;
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s var(--ease-out), border-color 0.25s;
}
.step:hover {
  transform: translateY(-4px);
  box-shadow: 0 10px 28px rgba(28, 26, 23, 0.10);
  border-color: var(--seal-soft);
}
.step .num {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 30px;
  color: var(--seal);
  margin: 0 0 14px;
  line-height: 1;
}
.step h3 { font-size: 15px; font-weight: 700; margin: 0 0 8px; }
.step p   { font-size: 13.5px; line-height: 1.55; color: var(--ink-muted); margin: 0; }

/* Légal grid */
.legal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}
.legal-item {
  transition: box-shadow 0.2s ease;
}
.legal-item:hover {
  box-shadow: inset 3px 0 0 var(--seal);
}
.legal-item h3 {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.legal-item h3::before {
  content: '';
  width: 18px; height: 18px;
  background-size: contain;
  background-repeat: no-repeat;
  flex-shrink: 0;
}
.legal-item p { font-size: 13.5px; line-height: 1.65; color: var(--ink-muted); margin: 0; }

/* CTA */
.cta-strip {
  max-width: 1040px;
  margin: 0 auto;
  padding: 48px 32px 96px;
  text-align: center;
}
.cta-strip p { font-size: 14px; color: var(--ink-muted); margin: 0 0 20px; }

/* Reveal stagger homepage */
.reveal {
  opacity: 0;
  transform: translateY(14px);
  animation: reveal 560ms var(--ease-out) both;
}
.reveal.d1 { animation-delay: 60ms; }
.reveal.d2 { animation-delay: 130ms; }
.reveal.d3 { animation-delay: 200ms; }
@keyframes reveal { to { opacity: 1; transform: translateY(0); } }

/* ============================================================
   PAGES PROSE (cgu, mentions, confidentialité, sécurité)
   ============================================================ */
main.prose-page {
  max-width: 700px;
  margin: 0 auto;
  padding: 56px 32px 96px;
}
main.prose-page.prose-lg { max-width: 760px; }

.prose-page .back {
  display: inline-block;
  margin-bottom: 32px;
  font-size: 13.5px;
  color: var(--ink-muted);
  text-decoration: none;
  transition: color 0.15s;
}
.prose-page .back:hover { color: var(--seal); }
.prose-page h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(28px, 4vw, 38px);
  margin: 0 0 8px;
}
.prose-page .date { font-size: 13px; color: var(--ink-muted); margin: 0 0 32px; }
.prose-page .lede {
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink-muted);
  max-width: 60ch;
  margin: 0 0 40px;
}
.prose-page h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  margin: 32px 0 10px;
}
.prose-page.prose-lg h1 { font-size: clamp(30px, 4vw, 42px); margin-bottom: 12px; }
.prose-page.prose-lg h2 { font-size: 20px; margin: 40px 0 14px; }
.prose-page p,
.prose-page li   { font-size: 15px; line-height: 1.75; color: var(--ink-muted); }
.prose-page ul   { padding-left: 1.25rem; margin: 0 0 12px; }
.prose-page li   { margin-bottom: 6px; }
.prose-page strong { color: var(--ink); font-weight: 600; }
.prose-page a      { text-decoration: underline; }

/* Badges sécurité */
.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 24px 0 8px;
}
.badge-row .badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--jade-soft);
  color: var(--jade);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 700;
}
.badge-row .badge::before { content: '✓'; }

/* ============================================================
   PAGE SIGNATURE
   ============================================================ */
main.sign-page {
  max-width: 640px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}
.sign-page .header { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.sign-page .header .seal-mark { height: 34px; width: auto; }
.sign-page .header h1 { margin: 0; font-size: 18px; font-weight: 800; }
.sign-page .header p  { margin: 2px 0 0; font-size: 13px; color: var(--ink-muted); }
.pdf-viewer {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 12px;
  background: var(--paper-2);
  overflow: hidden;
}
.pdf-viewer canvas { display: block; width: 100%; height: auto; }
.pdf-viewer canvas + canvas { border-top: 1px solid var(--line); }
.pdf-viewer .pdf-loading { padding: 60px 20px; text-align: center; color: var(--ink-muted); font-size: 13px; }
.sign-page section { margin-bottom: 28px; }
.sign-page section h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  margin: 0 0 10px;
}
.otp-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
input[type=text] {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--paper-2);
  font-family: inherit;
  font-size: 16px;
  width: 140px;
}
input[type=text]:focus { outline: 2px solid var(--seal-soft); border-color: var(--seal); }
.status-chip {
  font-size: 12px;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn);
}
.status-chip.ok {
  background: var(--jade);
  color: #FFFDF7;
  animation: pop 260ms var(--ease-out) both;
}
@keyframes pop { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#pad {
  border: 1px dashed var(--ink-muted);
  border-radius: 12px;
  background: var(--paper-2);
  touch-action: none;
  width: 100%;
  max-width: 400px;
  height: 150px;
}
label.consent { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; color: var(--ink-muted); line-height: 1.5; }
#message { margin: 16px 0; font-size: 13px; font-weight: 700; min-height: 1.2em; }
.signed-box { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; padding: 40px 20px; }
.inline-error {
  display: inline-block;
  margin-top: 10px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--seal-soft);
  color: var(--seal);
  font-size: 12px;
  font-weight: 700;
  animation: pop 200ms var(--ease-out) both;
}
.inline-error[hidden] { display: none; }
input[type=text]:disabled, .btn:disabled { opacity: 0.55; }

/* ============================================================
   ADMIN (base_admin.html)
   ============================================================ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(245, 239, 224, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand .seal-mark { height: 22px; width: auto; }
.brand span { font-weight: 800; font-size: 16px; letter-spacing: -0.02em; }
.topbar nav { display: flex; gap: 4px; padding: 0 24px 14px; }
.topbar nav a {
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  color: var(--ink-muted);
  transition: background 0.15s, color 0.15s;
}
.topbar nav a:hover  { background: var(--seal-soft); color: var(--seal); }
.topbar nav a.active { background: var(--seal-soft); color: var(--seal); }
.topbar nav a.logout { margin-left: auto; color: var(--seal); }
.admin-main { max-width: 1100px; margin: 0 auto; padding: 28px 24px 64px; }
.empty { text-align: center; color: var(--ink-muted); font-size: 14px; margin: 60px 0; }
.table-scroll { overflow-x: auto; }
table { width: 100%; min-width: 720px; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--ink-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; }
tr:hover td { background: rgba(183, 49, 44, 0.03); box-shadow: inset 3px 0 0 var(--seal); }
.badge { display: inline-block; padding: 3px 12px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge.pending  { background: var(--warn-soft); color: var(--warn); }
.badge.signed   { background: var(--seal-soft); color: var(--seal); animation: stamp 420ms var(--ease-out) both; }
.badge.expired  { background: rgba(107, 98, 85, 0.12); color: var(--ink-muted); }
@keyframes stamp {
  0%   { transform: scale(0.7) rotate(-8deg); opacity: 0; }
  60%  { transform: scale(1.08) rotate(2deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}
.date-cell { color: var(--ink-muted); font-size: 12px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; padding-top: 56px; }
  .hero-stamp { order: -1; }
  .hero-stamp img { width: 180px; }
  .hero-stamp::before { width: 200px; height: 200px; }
  .history  { grid-template-columns: 1fr; }
  .steps    { grid-template-columns: repeat(2, 1fr); }
  .legal-grid { grid-template-columns: 1fr; }
  .site-nav { padding: 16px 20px; }
  main.prose-page { padding: 40px 20px 72px; }
}

/* ============================================================
   PREFERS-REDUCED-MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .reveal { opacity: 1; transform: none; }
  .btn:hover { transform: none; }
  .step:hover, .history-mark:hover { transform: none; }
}
