/* « Encre » : an administrative document. Black, white and grey, plus one
   stamp-ink accent (--ink) used only for progress, scans, the valid seal,
   the selected mairie and focus. */
:root {
  --black: #000000;
  --black-hover: #262626;
  --text-2: #4D4D4D;
  --text-3: #666666;
  --faint: #6B6B6B;
  --rule: #D6D6D6;
  --rule-light: #E6E6E6;
  --panel: #F5F5F5;
  --dashed: #BDBDBD;
  --ink: #34338A;
  --ink-bg: #EEEEF6;
  --error: #A4161A;
  --flag-red: #CE1126;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh; display: flex; flex-direction: column;
  background: #FFFFFF; color: var(--black);
  font-family: 'Google Sans Flex', 'Google Sans', Roboto, Arial, sans-serif;
  font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
a { color: var(--black); }
button, input { font-family: inherit; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- which view and which state is shown ---------- */
.view { display: none; }
body[data-view="choose"] .view-choose,
body[data-view="chef"] .view-chef,
body[data-view="citizen"] .view-citizen { display: flex; }
.role-bar { display: none; }
body:not([data-view="choose"]) .role-bar { display: flex; }

.only-editing, .only-generated, .only-signing, .only-signed, .not-editing { display: none !important; }
body[data-chef="editing"] .only-editing { display: flex !important; }
body[data-chef="generated"] .only-generated,
body[data-chef="signing"] .only-signing,
body[data-chef="signed"] .only-signed { display: flex !important; }
body:not([data-chef="editing"]) .not-editing { display: flex !important; }
.chef-form .pill.only-editing, .chef-form .pill.only-generated { display: none !important; }
body[data-chef="editing"] .chef-form .pill.only-editing,
body[data-chef="generated"] .chef-form .pill.only-generated { display: inline-flex !important; }

.only-cit-empty, .only-cit-reading, .only-cit-result, .not-cit-empty, .not-result { display: none !important; }
body[data-cit="empty"] .only-cit-empty,
body[data-cit="reading"] .only-cit-reading,
body[data-cit="result"] .only-cit-result,
body:not([data-cit="empty"]) .not-cit-empty,
body:not([data-cit="result"]) .not-result { display: flex !important; }

/* ---------- header ---------- */
.top { width: 100%; max-width: 1200px; margin: 0 auto; padding: 22px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; min-height: 44px; text-decoration: none; font-weight: 600; letter-spacing: -0.01em; }
.logo { width: 22px; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1px; }
.logo i { aspect-ratio: 1; background: var(--rule); }
.logo i.on { background: var(--black); }
.role-bar { align-items: center; gap: 6px; }
.role-name { font-size: 14px; color: var(--text-3); }

/* ---------- buttons: square-ish, black ---------- */
.pill { min-height: 48px; padding: 0 22px; border: 0; border-radius: 4px; font-size: 15px; font-weight: 500; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; transition: background-color 150ms, opacity 150ms; }
.pill-sm { min-height: 40px; padding: 0 14px; font-size: 14px; }
.pill-primary { background: var(--black); color: #FFFFFF; }
.pill-primary:hover { background: var(--black-hover); color: #FFFFFF; }
.pill-primary:disabled { opacity: .4; cursor: progress; }
.pill-busy { background: #333333; color: #FFFFFF; cursor: progress; }
.pill-ghost { background: transparent; color: var(--black); padding: 0 16px; }
.pill-ghost:hover { background: #EFEFEF; }
.pill-white { background: #FFFFFF; color: var(--black); padding: 0 18px; }
.pill-white:hover { background: #EFEFEF; }
.pull-left { margin-left: -16px; align-self: flex-start; }

/* ---------- role choice: poster tiles (from the Demo board) ----------
   The tiles keep their own tints and the near-black #111111; the Encre
   palette starts after the role choice. */
.view-choose { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 8px 24px 32px; flex-wrap: wrap; align-items: stretch; gap: 20px; }
.tile {
  flex: 1 1 320px; min-height: 560px; padding: 32px; border-radius: 32px; text-decoration: none; color: #111111;
  display: flex; flex-direction: column; position: relative; overflow: hidden;
  transition: transform 200ms ease-out, box-shadow 200ms ease-out;
}
.tile:hover { transform: translateY(-4px); box-shadow: 0 24px 48px -28px rgba(17,17,17,.35); color: #111111; }
.tile-chef { background: #FDF1F3; }
.tile-citizen { background: #EEF7F1; }
.tile-tag { align-self: flex-start; min-height: 30px; padding: 0 12px; border-radius: 999px; background: #FFFFFF; font-size: 13px; font-weight: 600; display: flex; align-items: center; }
.tile-chef .tile-tag { color: #B0102A; }
.tile-citizen .tile-tag { color: #0B7A4B; }
.tile-art { flex: 1; min-height: 240px; position: relative; display: block; }
.mini-doc {
  position: absolute; width: 150px; aspect-ratio: 210 / 297; left: 50%; top: 50%; background: #FFFFFF; border-radius: 6px;
  box-shadow: 0 24px 40px -24px rgba(17,17,17,.35); padding: 16px 14px; display: flex; flex-direction: column; gap: 6px;
}
.mini-doc b { font-size: 7px; font-weight: 700; letter-spacing: .06em; text-align: center; margin-bottom: 4px; }
.mini-doc i { display: block; height: 4px; border-radius: 2px; background: #E4E4E7; }
.mini-doc i:nth-of-type(1) { width: 70%; } .mini-doc i:nth-of-type(2) { width: 90%; } .mini-doc i:nth-of-type(3) { width: 55%; }
.mini-doc i:nth-of-type(4) { width: 80%; } .mini-doc i:nth-of-type(5) { width: 62%; }
.mini-doc.back { transform: translate(-62%, -50%) rotate(-6deg); opacity: .7; }
.mini-doc.front { transform: translate(-42%, -46%) rotate(3deg); }
.mini-doc.center { transform: translate(-50%, -50%); }
.mini-seal { width: 34px; height: 34px; margin-top: auto; align-self: flex-end; image-rendering: pixelated; }
.mini-seal-ring { margin-top: auto; align-self: flex-end; padding: 3px; border-radius: 4px; box-shadow: 0 0 0 2px #009460; display: flex; }
.mini-seal-ring .mini-seal { margin: 0; }
.art-badge { position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; border-radius: 999px; display: flex; align-items: center; justify-content: center; }
.art-badge.dark { background: #111111; transform: translate(70%, 40%); box-shadow: 0 12px 24px -10px rgba(17,17,17,.5); }
.art-badge.green { background: #009460; transform: translate(60%, 70%); box-shadow: 0 12px 24px -10px rgba(0,148,96,.6); }
.tile-text { display: flex; flex-direction: column; gap: 12px; }
.tile-title { font-size: 40px; line-height: 1.05; font-weight: 600; letter-spacing: -0.03em; }
.tile-desc { font-size: 17px; color: #555555; max-width: 24em; text-wrap: pretty; }
.tile-go { align-self: flex-start; margin-top: 12px; min-height: 48px; padding: 0 22px; border-radius: 999px; background: #FFFFFF; font-size: 15px; font-weight: 500; display: flex; align-items: center; transition: background-color 150ms, color 150ms; }
.tile:hover .tile-go, .tile:focus-visible .tile-go { background: #111111; color: #FFFFFF; }

/* ---------- two-column flows ---------- */
.view-chef, .view-citizen { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 8px 24px 40px; flex-wrap: wrap; gap: 40px; align-items: stretch; }
.side { flex: 1 1 340px; min-width: 0; max-width: 440px; display: flex; flex-direction: column; justify-content: center; gap: 24px; padding: 16px 0; animation: rise 360ms ease-out; }
/* Slide only, no fade: content must never sit invisible if the animation is paused. */
@keyframes rise { from { transform: translateY(10px); } }
.intro { display: flex; flex-direction: column; gap: 10px; }
.intro h1, .verdict h1 { margin: 0; font-size: 40px; line-height: 1.08; font-weight: 600; letter-spacing: -0.03em; }
.intro p, .verdict p { margin: 0; font-size: 16px; color: var(--text-2); }
.panel { flex: 1.4 1 460px; min-width: 0; min-height: 700px; position: relative; border-radius: 6px; background: var(--panel); overflow: hidden; display: flex; }

/* chef form */
.chef-form { display: flex; flex-direction: column; gap: 18px; }
.fields { border: 0; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 12px; min-width: 0; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field input:not([type="radio"]) { width: 100%; min-height: 44px; padding: 0 14px; border: 1px solid var(--rule); border-radius: 4px; background: #FFFFFF; font-size: 15px; color: var(--black); }
.field input:not([type="radio"]):focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px rgba(52,51,138,.12); }
.field input:disabled { background: var(--panel); color: var(--text-2); }
.field input.is-invalid { border-color: var(--error); }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }
.choice { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice span { min-height: 40px; padding: 0 14px; border-radius: 4px; font-size: 14px; font-weight: 500; display: flex; align-items: center; border: 1px solid var(--rule); background: #FFFFFF; color: var(--black); cursor: pointer; transition: background-color 150ms, color 150ms, border-color 150ms, box-shadow 150ms; }
/* Neutral selection (sexe) and ink selection (mairie). */
.choice input:checked + span { border-color: var(--black); box-shadow: inset 0 0 0 1px var(--black); }
.choices-ink .choice input:checked + span { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); background: var(--ink-bg); color: var(--ink); }
.choice input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 3px; }
.choice input:disabled, .choice input:disabled + span { cursor: default; }
.choice input:disabled:not(:checked) + span { opacity: .5; }
.form-error { margin: 0; font-size: 14px; font-weight: 500; color: var(--error); }
.form-error:empty { display: none; }
.chef-form > .pill { align-self: flex-start; }

/* chef preview panel */
.chef-panel { flex-direction: column; align-items: center; justify-content: center; gap: 22px; padding: 36px 24px; }
.placeholder { width: min(320px, 100%); aspect-ratio: 210 / 297; border: 1.5px dashed var(--dashed); border-radius: 8px; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px; text-align: center; font-size: 15px; color: var(--text-3); }
.placeholder svg { stroke: #8C8C8C; }
.doc { position: relative; width: min(360px, 100%); aspect-ratio: 210 / 297; background: #FFFFFF; border-radius: 8px; box-shadow: 0 30px 60px -30px rgba(0,0,0,.25); overflow: hidden; animation: rise 360ms ease-out; }
.doc canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.pdf-after { opacity: 0; transition: opacity 500ms ease-out; }
.pdf-after.is-ready { opacity: 1; }
.stamp { position: absolute; display: none; opacity: 0; transform: scale(1.6); image-rendering: pixelated; }
.stamp.is-shown { display: block; }
.stamp.is-in { opacity: 1; transform: scale(1); transition: opacity 300ms ease-out, transform 420ms cubic-bezier(.3, 1.5, .5, 1); }
.scan { position: absolute; left: 14px; right: 14px; top: 6%; height: 2px; background: var(--ink); box-shadow: 0 0 14px 3px rgba(52,51,138,.22); opacity: 0; z-index: 2; }
body[data-chef="signing"] .chef-doc .scan { animation: scan 2.6s linear forwards; }
body[data-cit="reading"] .cit-doc .scan.is-active { animation: scan 1.05s linear forwards; }
@keyframes scan { 0% { top: 6%; opacity: 1; } 95% { top: 94%; opacity: 1; } 100% { top: 94%; opacity: 0; } }
.doc-actions { width: min(360px, 100%); flex-direction: column; gap: 12px; }
.doc-actions .pill { width: 100%; }
.doc-actions .row { gap: 10px; flex-wrap: wrap; }
.doc-actions .row .pill { width: auto; flex: 1 1 auto; white-space: nowrap; }
.grow { flex: 1; }
.bar { height: 2px; border-radius: 2px; background: var(--rule); overflow: hidden; }
.filebox .bar { background: var(--rule-light); }
.doc-actions .bar { opacity: 0; transition: opacity 200ms; }
body[data-chef="signing"] .doc-actions .bar { opacity: 1; }
.bar-fill { height: 100%; width: 0; background: var(--ink); }
.status { margin: 0; min-height: 22px; font-size: 14px; color: var(--text-3); }
.status.center { text-align: center; }
.status.is-error { color: var(--error); font-weight: 500; }

/* citizen */
.cit-intro { flex-direction: column; gap: 24px; }
.pick { flex-wrap: wrap; align-items: center; gap: 14px; }
.hint { font-size: 14px; color: var(--text-3); }
.filebox { flex-direction: column; gap: 10px; }
.filerow { display: flex; align-items: center; gap: 12px; }
.file-icon { width: 36px; height: 44px; flex: none; border-radius: 4px; background: var(--panel); display: flex; align-items: flex-end; justify-content: center; padding-bottom: 5px; font-size: 9px; font-weight: 700; color: var(--flag-red); }
.file-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-name { font-weight: 500; overflow-wrap: anywhere; }
.file-meta { font-size: 14px; color: var(--text-3); }
.result { flex-direction: column; gap: 22px; animation: rise 360ms ease-out; }
.verdict { display: flex; flex-direction: column; gap: 12px; }
.verdict h1 { font-size: 36px; line-height: 1.1; }
/* Verdict "badge": coloured text only, no fill. */
.badge { align-self: flex-start; min-height: 32px; padding: 0; display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; }
.badge svg { display: none; }
.badge.is-ok { color: var(--ink); }
.badge.is-ko { color: var(--error); }
.badge.is-warn { color: var(--text-2); }
.badge.is-none { color: var(--text-3); }
.badge.is-ok .icon-ok, .badge.is-ko .icon-ko, .badge.is-warn .icon-warn, .badge.is-none .icon-warn { display: block; }
.seal-table { display: flex; flex-direction: column; }
.seal-table[hidden] { display: none; }
.table-title { font-size: 14px; font-weight: 500; padding-bottom: 8px; }
.seal-table dl { margin: 0; display: grid; grid-template-columns: 150px 1fr; border-top: 1px solid var(--rule-light); }
.seal-table dt, .seal-table dd { margin: 0; padding: 9px 0; border-bottom: 1px solid var(--rule-light); font-size: 14px; }
.seal-table dt { color: var(--text-3); padding-right: 10px; }
.seal-table dt.is-diff { color: var(--error); }
.seal-table dd { font-weight: 500; overflow-wrap: anywhere; }
.seal-table dd.is-diff { color: var(--error); }
.seal-table .diff-value { text-decoration: underline wavy var(--error); text-underline-offset: 3px; }
.seal-table dd.is-diff small { display: block; font-weight: 400; font-size: 13px; color: var(--text-2); }

/* drop zone: dashed box, ink icon, underlined link text */
.drop {
  flex: 1; margin: 24px; border: 1.5px dashed var(--dashed); border-radius: 6px; position: relative;
  flex-direction: column; align-items: center; justify-content: center; gap: 14px; cursor: pointer; padding: 32px; text-align: center;
  transition: border-color 150ms, background-color 150ms;
}
.drop:hover, .drop.is-over { border-color: var(--ink); background: #FAFAFA; }
.drop:focus-within { border-color: var(--ink); }
.drop:focus-within .drop-cta { outline: 2px solid var(--ink); outline-offset: 3px; }
.drop-title { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; }
.drop-cta { font-size: 15px; color: var(--black); text-decoration: underline; text-underline-offset: 4px; }

.doc-wrap { flex: 1; align-items: center; justify-content: center; padding: 40px 24px; }
.cit-doc { width: min(380px, 100%); overflow: visible; }
.cit-doc canvas.pdf-before { border-radius: 8px; }
.marks { position: absolute; inset: 0; pointer-events: none; }
/* Red wavy underline under printed text that differs from the seal. The mark
   box covers the text (top of glyphs to just below the baseline); the wave is
   drawn right under it so it never crosses the letters. */
.mark { position: absolute; }
.mark::after {
  content: ''; position: absolute; left: 0; right: 0; top: calc(100% - 1px); height: 4px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='6' height='4' viewBox='0 0 6 4'%3E%3Cpath d='M0 3 Q1.5 0 3 3 T6 3' fill='none' stroke='%23A4161A' stroke-width='1.2'/%3E%3C/svg%3E") left top / 6px 4px repeat-x;
}
.seal-focus {
  position: absolute; display: none; background: #FFFFFF; border-radius: 6px; z-index: 3;
  transform-origin: 100% 100%; transition: transform 380ms cubic-bezier(.3, 1.3, .5, 1), box-shadow 300ms ease-out;
}
.seal-focus canvas { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 6px; }
.seal-focus.is-shown { display: block; }
.seal-focus.is-zoom { transform: scale(1.35); box-shadow: 0 0 0 2px var(--black), 0 16px 30px -12px rgba(0,0,0,.4); }
.seal-focus.is-ok { box-shadow: 0 0 0 3px var(--ink); }
.seal-focus.is-ko { box-shadow: 0 0 0 3px var(--error); }
.seal-focus.is-warn { box-shadow: 0 0 0 3px var(--text-2); }
.seal-scan { position: absolute; left: 0; right: 0; top: 4%; height: 2px; background: var(--ink); box-shadow: 0 0 10px 2px rgba(52,51,138,.35); opacity: 0; }
.seal-focus.is-zoom .seal-scan { animation: seal-scan 0.95s linear forwards; }
@keyframes seal-scan { 0% { top: 4%; opacity: 1; } 95% { top: 96%; opacity: 1; } 100% { opacity: 0; } }

.foot { width: 100%; max-width: 1200px; margin: 0 auto; padding: 20px 24px 28px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--faint); }

@media (max-width: 600px) {
  .top { padding: 16px; }
  .view-choose, .view-chef, .view-citizen { padding: 0 16px 24px; gap: 24px; }
  .tile { min-height: 460px; padding: 24px; border-radius: 26px; }
  .tile-title { font-size: 34px; }
  .intro h1 { font-size: 34px; }
  .verdict h1 { font-size: 30px; }
  .side { padding: 8px 0 0; }
  .panel { min-height: 520px; }
  .drop { margin: 16px; }
  .chef-panel { padding: 28px 18px; }
  .seal-table dl { grid-template-columns: 120px 1fr; }
  .role-name { display: none; }
  .foot { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .scan { opacity: 0 !important; }
}
