:root {
  --fond: #08121d;
  --surface: #0f1d2c;
  --surface-2: #152a3e;
  --trait: #22394f;
  --texte: #e9eff6;
  --doux: #93a6ba;
  --accent: #2f8cff;          /* produit présenté (bleu Soprema éclairci pour fond sombre) */
  --regard: #fec62e;          /* « regardez ici » : zoom et encadré dans le téléphone */
  --gtin: #6fb3ff;            /* code : le produit */
  --lot: #fc6944;             /* code : le lot */
  --serie: #8ee6a8;           /* code : l'exemplaire (AI 21) */
  --resolveur: #9aa8b8;
  --ok: #36c27a;
  --attention: #f0a340;
  --titre: "Archivo", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --r: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
html { overflow-x: clip; }
body {
  background: radial-gradient(1200px 700px at 78% 40%, #10263b 0%, var(--fond) 60%) fixed, var(--fond);
  color: var(--texte); font: 400 16px/1.5 var(--titre);
  min-height: 100dvh; display: grid; grid-template-rows: auto 1fr auto;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .38; }
:focus-visible { outline: 2px solid var(--regard); outline-offset: 2px; }

/* ---------- barre du haut ---------- */
.barre { display: flex; align-items: center; gap: 16px; padding: 12px clamp(16px, 3vw, 40px); border-bottom: 1px solid var(--trait); flex-wrap: wrap; }
.marque { display: flex; align-items: center; gap: 10px; font-weight: 600; letter-spacing: .01em; white-space: nowrap; }
.marque em { font-style: normal; color: var(--doux); font-weight: 400; margin-left: 4px; }
.pastille-marque { width: 12px; height: 12px; border-radius: 3px; background: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 25%, transparent); }
.produits, .mode { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--trait); border-radius: 999px; background: var(--surface); }
.produits button, .mode button { border: 0; background: none; padding: 6px 14px; border-radius: 999px; color: var(--doux); white-space: nowrap; }
.produits button small { font-size: 12px; opacity: .8; margin-left: 4px; }
.produits button[aria-pressed="true"], .mode button[aria-pressed="true"] { background: var(--surface-2); color: var(--texte); box-shadow: inset 0 0 0 1px var(--trait); }
.produits { margin-right: auto; }
.direct { display: flex; align-items: center; gap: 12px; }
.liaison { font-size: 13px; color: var(--doux); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.liaison::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #5b6b7c; }
.liaison[data-etat="ws"]::before { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 30%, transparent); }
.liaison[data-etat="bc"]::before { background: var(--attention); }
.presents { list-style: none; display: flex; margin: 0; padding: 0; }
.presents li { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #08121d; margin-left: -6px; border: 2px solid var(--fond); position: relative; }
.presents li.meneur { box-shadow: 0 0 0 2px var(--regard); z-index: 1; }
.presents li.meneur::after { content: "♛"; position: absolute; top: -13px; font-size: 12px; color: var(--regard); }
.presents li.moi { outline: 2px dashed color-mix(in srgb, var(--texte) 45%, transparent); outline-offset: 2px; }

/* ---------- scène : deck à gauche, téléphone à droite ---------- */
.scene { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: clamp(24px, 4vw, 72px); align-items: center; padding: clamp(16px, 2.5vh, 32px) clamp(16px, 4vw, 64px); min-height: 0; }
body.tel-gauche .scene { grid-template-columns: auto minmax(0, 1fr); }
body.tel-gauche .tel-col { order: -1; }
.deck { max-width: 900px; min-width: 0; }
.compteur { display: flex; align-items: baseline; gap: 14px; margin: 0 0 10px; font-family: var(--mono); color: var(--doux); font-size: clamp(13px, 1.1vw, 16px); }
.compteur #num { color: var(--accent); font-weight: 600; }
.compteur .sur { text-transform: uppercase; letter-spacing: .14em; }
h1 { font-weight: 800; font-size: clamp(28px, 3.4vw, 60px); line-height: 1.04; letter-spacing: -.02em; margin: 0 0 16px; text-wrap: balance; }
.texte { font-size: clamp(16px, 1.45vw, 24px); color: #c6d3e0; max-width: 46ch; margin: 0 0 clamp(16px, 3vh, 36px); text-wrap: pretty; }
.visuel { margin: 0; }

/* visuel : adresse GS1 Digital Link décomposée */
.url { font-family: var(--mono); font-size: clamp(13px, 1.2vw, 22px); display: flex; flex-wrap: wrap; row-gap: 14px; }
.url span { display: inline-flex; flex-direction: column; padding: 0 2px; }
.url b { font-weight: 600; border-bottom: 3px solid currentColor; padding-bottom: 4px; }
.url i { font-style: normal; font-family: var(--titre); font-size: clamp(12px, .95vw, 15px); margin-top: 6px; opacity: .9; }
.url .res { color: var(--resolveur); } .url .gtin { color: var(--gtin); } .url .lot { color: var(--lot); } .url .ser { color: var(--serie); }
.segments { margin: 22px 0 0; display: grid; gap: 8px; max-width: 760px; }
.segments div { display: grid; grid-template-columns: 12.5em 1fr; gap: 14px; align-items: baseline; padding-left: 12px; border-left: 3px solid currentColor; }
.segments dt { font-family: var(--mono); font-weight: 600; font-size: clamp(12px, .95vw, 16px); }
.segments dd { margin: 0; color: var(--texte); font-size: clamp(13px, 1vw, 17px); line-height: 1.4; }
.segments .res { color: var(--resolveur); } .segments .gtin { color: var(--gtin); } .segments .lot { color: var(--lot); } .segments .ser { color: var(--serie); }
@media (max-width: 600px) { .segments div { grid-template-columns: 1fr; gap: 2px; } }

/* visuel : zoom sur un champ du passeport */
.zoom { position: relative; border-radius: var(--r); overflow: hidden; background-color: #fff; background-repeat: no-repeat; box-shadow: 0 0 0 2px var(--regard), 0 24px 60px -20px #000; max-width: 640px; }
.zoom-legende { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: clamp(13px, 1vw, 16px); color: var(--doux); }
.zoom-legende::before { content: ""; width: 22px; height: 2px; background: var(--regard); }
.vide { padding: 20px 22px; border: 1px dashed var(--trait); border-radius: var(--r); color: var(--doux); max-width: 520px; }

/* ---------- téléphone ---------- */
.tel-col { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.tel { --s: .72; width: calc(414px * var(--s)); height: calc(868px * var(--s)); position: relative; }
.tel::before { content: ""; position: absolute; inset: 0; border-radius: calc(62px * var(--s)); background: linear-gradient(145deg, #2a3a4c, #0b1520 40%, #1d2b3a); box-shadow: 0 40px 80px -30px #000, inset 0 0 0 1px #3a4a5c; }
.tel-ecran { position: absolute; left: 0; top: 0; width: 390px; height: 844px; transform-origin: 0 0; transform: translate(calc(12px * var(--s)), calc(12px * var(--s))) scale(var(--s)); border-radius: 50px; overflow: hidden; background: #f5f5fa; }
.tel-encoche { position: absolute; top: calc(22px * var(--s)); left: 50%; translate: -50% 0; width: calc(110px * var(--s)); height: calc(30px * var(--s)); border-radius: 999px; background: #05090e; z-index: 5; }
.tel-pied { display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--doux); }
.discret { white-space: nowrap; border: 1px solid var(--trait); background: var(--surface); border-radius: 999px; padding: 6px 14px; font-size: 13px; }
.note-mode { max-width: 280px; }

/* écran en mode copie */
/* barre d'état : 44 px sous l'encoche, la page commence dessous */
.statut { position: absolute; left: 0; top: 0; width: 390px; height: 44px; z-index: 5; background: #fff; color: #0b1520; display: flex; align-items: center; justify-content: space-between; padding: 0 30px 0 38px; font: 600 15px/1 var(--titre); box-shadow: 0 1px 0 rgba(0,0,0,.06); }
.statut .icones { display: flex; gap: 5px; align-items: center; }
.statut .icones i { display: block; background: #0b1520; border-radius: 2px; }
.statut .icones i:nth-child(1) { width: 17px; height: 10px; clip-path: polygon(0 100%, 100% 0, 100% 100%); }
.statut .icones i:nth-child(2) { width: 14px; height: 10px; border-radius: 7px 7px 2px 2px; clip-path: polygon(50% 100%, 0 0, 100% 0); }
.statut .icones i:nth-child(3) { width: 24px; height: 11px; border-radius: 3px; box-shadow: inset 0 0 0 1.5px #0b1520; background: linear-gradient(90deg, #0b1520 70%, transparent 70%) 2px 2px / 18px 7px no-repeat; }
.copie { position: absolute; inset: 44px 0 0 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; }
.copie::-webkit-scrollbar { display: none; }
.copie .page { position: relative; width: 390px; }
.copie .page img { display: block; width: 390px; }
.nav { position: absolute; left: 0; bottom: 0; width: 390px; z-index: 3; }
.nav img { display: block; width: 390px; }
.zone { position: absolute; border: 0; background: transparent; padding: 0; border-radius: 10px; }
.suiveur .zone, .suiveur .copie { pointer-events: none; }
.repere { position: absolute; border-radius: 10px; box-shadow: 0 0 0 3px var(--regard), 0 0 0 9999px rgba(5, 12, 20, .28); pointer-events: none; transition: opacity .3s; }
.modale { position: absolute; inset: 0; z-index: 4; }
.modale img { width: 390px; display: block; }
iframe.direct-cadre { position: absolute; left: 0; top: 44px; width: 390px; height: 800px; border: 0; background: #fff; }

/* écran : scan du QR code */
.scan { position: absolute; inset: 0; background: #0b0f14; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; overflow: hidden; }
.scan::before { content: ""; position: absolute; inset: -40px; background: var(--photo) center 30% / 120% no-repeat, #3a3a3a; filter: blur(14px) brightness(.45); }
.scan > * { position: relative; }
.scan .viseur { width: 240px; height: 240px; display: grid; place-items: center; position: relative; }
.scan .viseur img { width: 176px; height: 176px; border-radius: 10px; background: #fff; padding: 8px; }
.scan .viseur::before, .scan .viseur::after { content: ""; position: absolute; inset: 0; border: 4px solid #fff; border-radius: 26px; clip-path: polygon(0 0, 30% 0, 30% 4px, 4px 4px, 4px 30%, 0 30%, 0 70%, 4px 70%, 4px calc(100% - 4px), 30% calc(100% - 4px), 30% 100%, 70% 100%, 70% calc(100% - 4px), calc(100% - 4px) calc(100% - 4px), calc(100% - 4px) 70%, 100% 70%, 100% 30%, calc(100% - 4px) 30%, calc(100% - 4px) 4px, 70% 4px, 70% 0); }
.scan .ligne { position: absolute; left: 22px; right: 22px; height: 2px; background: var(--regard); box-shadow: 0 0 12px var(--regard); animation: balaye 2.4s ease-in-out infinite alternate; }
@keyframes balaye { from { top: 26px; } to { top: 212px; } }
.scan .detecte { width: 330px; background: rgba(255,255,255,.96); color: #0b1520; border-radius: 22px; padding: 18px 20px; font-size: 15px; }
.scan .detecte small { display: block; color: #4b5563; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; margin-bottom: 4px; }
.scan .detecte code { font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
.scan .ouvrir { margin-top: 12px; width: 100%; border: 0; border-radius: 999px; padding: 12px; background: #0072ce; color: #fff; font-weight: 700; letter-spacing: .04em; }
.scan .entete { position: absolute; top: 64px; font-size: 15px; opacity: .85; }


/* ---------- barre de pilotage ---------- */
.pilote { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; padding: 12px clamp(16px, 4vw, 64px); border-top: 1px solid var(--trait); background: color-mix(in srgb, var(--fond) 88%, transparent); backdrop-filter: blur(8px); }
.role { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--doux); flex-wrap: wrap; }
.role strong { color: var(--texte); }
.role label { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.pas { list-style: none; display: flex; gap: 6px; margin: 0; padding: 0; }
.pas button { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--trait); background: var(--surface); font-family: var(--mono); font-size: 13px; color: var(--doux); }
.pas button[aria-current="step"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.fleches { display: flex; gap: 10px; justify-content: flex-end; }
.fleches button { border: 1px solid var(--trait); background: var(--surface); border-radius: 999px; padding: 10px 22px; font-weight: 600; }
.fleches .fort { background: var(--texte); color: var(--fond); border-color: var(--texte); }
.annonce { position: fixed; left: 50%; top: 70px; translate: -50% 0; background: var(--surface-2); border: 1px solid var(--trait); padding: 10px 18px; border-radius: 999px; font-size: 14px; opacity: 0; transition: opacity .25s; pointer-events: none; z-index: 20; }
.annonce.voir { opacity: 1; }

/* ---------- tablette et téléphone ---------- */
@media (max-width: 900px), (orientation: portrait) {
  body { grid-template-rows: auto auto auto; }
  .scene { grid-template-columns: 1fr; align-items: start; padding-bottom: 24px; }
  body.tel-gauche .tel-col { order: 0; }
  .deck { max-width: none; }
  .pilote { position: sticky; bottom: 0; z-index: 20; grid-template-columns: 1fr auto; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .pilote .role { grid-column: 1 / -1; order: 2; }
  .zoom { max-width: 100%; }
}
@media (max-width: 600px) {
  .barre { gap: 10px; padding-top: 10px; padding-bottom: 10px; }
  .marque em { display: none; }
  .marque { font-size: 15px; }
  .produits { order: 3; width: 100%; margin: 0; }
  .produits button { flex: 1; padding: 6px 8px; }
  .produits button small { display: none; }
  .produits button, .deck, .texte { min-width: 0; }
  .direct { margin-left: auto; gap: 8px; }
  .mode button { padding: 4px 10px; font-size: 14px; }
  .liaison span { display: none; }
  .presents li { width: 28px; height: 28px; font-size: 11px; }
  .tel-pied { flex-direction: column; text-align: center; }
  .pas { display: none; }
  .pilote { grid-template-columns: 1fr; }
  .fleches { justify-content: stretch; }
  .fleches button { flex: 1; }
}
@media (prefers-reduced-motion: reduce) { .scan .ligne { animation: none; top: 120px; } * { scroll-behavior: auto !important; } }
