/* ============================================================
   Woopets ID — prise de photo guidée (public/js/woopets-id-capture.js)

   Tout est sous .wid. Les couleurs viennent de woopets-tokens.css (jamais redéfinies ici) ;
   la feuille n'ajoute que SES variables : les voiles posés sur l'image de la caméra.
   Un seul corail (--c-accent-vivid) par écran : le déclencheur quand la truffe est trouvée,
   le bouton final de la relecture quand tout est vérifié.

   Mouvement : seulement transform / opacity (et le tracé de PETITS dessins). Le grand voile
   troué (.wid__sight) n'est jamais animé : il serait repeint en entier à chaque image de la
   caméra. Le viseur que l'on anime est un petit élément à part (.wid__finder).
   L'état du viseur est porté par .wid[data-lock] : search | found | shot.
   ============================================================ */

html.wid-open {
    overflow: hidden;
}

.wid {
    --wid-veil: rgba(12, 26, 24, 0.62);        /* autour du viseur */
    --wid-veil-soft: rgba(12, 26, 24, 0.6);    /* boutons et témoins posés sur l'image (sans flou : il serait recalculé à chaque image) */
    --wid-veil-deep: rgba(12, 26, 24, 0.86);
    --wid-line: rgba(255, 255, 255, 0.94);
    --wid-line-dim: rgba(255, 255, 255, 0.42);
    --wid-safe-top: env(safe-area-inset-top, 0px);
    --wid-safe-right: env(safe-area-inset-right, 0px);
    --wid-safe-bottom: env(safe-area-inset-bottom, 0px);
    --wid-safe-left: env(safe-area-inset-left, 0px);

    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    overflow: hidden;
    background: var(--c-text);
    color: var(--c-text-inverse);
    font-family: var(--f-body);
    font-size: 0.94rem;
    line-height: 1.45;
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

.wid::backdrop {
    background: var(--c-text);
}

.wid *,
.wid *::before,
.wid *::after {
    box-sizing: border-box;
}

.wid [hidden] {
    display: none !important;
}

:where(.wid) button,
:where(.wid) label {
    font: inherit;
    color: inherit;
    cursor: pointer;
}

:where(.wid) button:disabled {
    cursor: default;
}

.wid :focus-visible {
    outline: 3px solid var(--c-primary-soft);
    outline-offset: 3px;
}

.wid__icon {
    width: 24px;
    height: 24px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ---------- Scène : la vidéo et le viseur ---------- */

.wid[data-stage="intro"],
.wid[data-stage="review"] {
    background: var(--c-bg);
}

.wid__stage {
    position: absolute;
    inset: 0;
    overflow: hidden;
    background: var(--c-text);
}

.wid__video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform-origin: 50% 50%;
    background: var(--c-text);
    opacity: 0;
    transition: opacity 320ms var(--ease-out);
}

.wid__video.is-live {
    opacity: 1;
}

/* Le voile troué : statique. */
.wid__sight {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.wid__scrim {
    fill: var(--wid-veil);
}

.wid__corners {
    fill: none;
    stroke: var(--wid-line);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
    opacity: 0.7;
    transition: stroke 200ms var(--ease-out);
}

.wid[data-lock="found"] .wid__corners,
.wid[data-lock="shot"] .wid__corners {
    stroke: var(--c-primary-soft);
}

/* Le viseur : posé par le script sur le trou du voile. Les traits de la truffe sont dessinés
   dans son repère ; --wid-k ramène leur épaisseur à des pixels d'écran, --wid-hold-ms est ce
   qu'il reste de la tenue quand la truffe est trouvée. */
.wid__finder {
    --wid-k: 1;
    --wid-hold-ms: 500ms;
    position: absolute;
    pointer-events: none;
    transform-origin: 50% 50%;
    transition: opacity 200ms var(--ease-out);
}

.wid__finder.is-waiting {
    opacity: 0;
    transition: none;
}

/* Trouvée : un seul « clac ». */
.wid__finder.is-clac {
    animation: wid-clac 360ms var(--ease-spring);
}

@keyframes wid-clac {
    from { transform: scale(1.035); }
    to { transform: none; }
}

.wid__nose {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.wid__nose-line,
.wid__nose-hold,
.wid__nose-hints {
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Chercher : contour blanc, narines en pointillés, immobile. */
.wid__nose-line {
    stroke: var(--wid-line);
    stroke-width: calc(2.5px / var(--wid-k));
    transition: stroke 200ms var(--ease-out), opacity 200ms var(--ease-out);
}

.wid__nose-hints {
    stroke: var(--wid-line-dim);
    stroke-width: calc(1.5px / var(--wid-k));
    stroke-dasharray: 3 7;
    transition: opacity 200ms var(--ease-out);
}

/* Tenir : la jauge se trace depuis l'encoche du haut, le temps de la tenue ET de la rafale
   (.is-holding, posée par le script tant que la tenue court) : elle se ferme à l'éclat. La perdre
   la ramène à zéro en un instant, même si le message « parfait » est encore affiché. */
.wid__nose-hold {
    stroke: var(--c-primary-soft);
    stroke-width: calc(6px / var(--wid-k));
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    opacity: 0;
    transition: stroke-dashoffset 160ms var(--ease-out), opacity 160ms var(--ease-out);
}

.wid[data-lock="found"] .wid__nose-line {
    stroke: var(--c-primary-soft);
    opacity: 0.45;
}

.wid[data-lock="found"] .wid__nose-hints,
.wid[data-lock="shot"] .wid__nose-hints {
    opacity: 0;
}

.wid[data-lock="found"] .wid__finder.is-holding .wid__nose-hold {
    stroke-dashoffset: 0;
    opacity: 1;
    transition: stroke-dashoffset var(--wid-hold-ms) linear, opacity 80ms linear;
}

/* Déclenché : le contour s'épaissit un instant, puis la truffe s'illumine — dans sa forme, pas
   sur tout l'écran. */
.wid__nose-flash {
    fill: rgb(255, 255, 255);
    opacity: 0;
}

.wid[data-lock="shot"] .wid__nose-line {
    animation: wid-shot-line 320ms var(--ease-out);
}

.wid[data-lock="shot"] .wid__nose-flash {
    animation: wid-shot-fill 320ms var(--ease-out);
}

@keyframes wid-shot-line {
    0%, 25% { stroke: rgb(255, 255, 255); stroke-width: calc(6px / var(--wid-k)); opacity: 1; }
    100% { stroke: var(--wid-line); stroke-width: calc(2.5px / var(--wid-k)); opacity: 1; }
}

@keyframes wid-shot-fill {
    0% { opacity: 0; }
    25% { opacity: 0.5; }
    100% { opacity: 0; }
}

/* Animal entier : le même éclat, dans le cadre. */
.wid__finder-flash {
    position: absolute;
    inset: 0;
    border-radius: 14px;
    background: rgb(255, 255, 255);
    opacity: 0;
}

.wid[data-lock="shot"] .wid__finder-flash {
    animation: wid-shot-fill 320ms var(--ease-out);
}

/* Le dessin des conseils qui file vers le viseur, et la photo qui file vers sa vignette. */
.wid__fly-nose {
    position: absolute;
    z-index: 3;
    overflow: visible;
    pointer-events: none;
    color: var(--wid-line);
    transform-origin: 50% 50%;
    animation: wid-fly-ink 450ms var(--ease-out) both;
}

.wid__fly-nose path {
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
}

@keyframes wid-fly-ink {
    from { color: var(--c-primary); }
    to { color: var(--wid-line); }
}

/* Ni liseré ni ombre : agrandie plusieurs fois dans le viseur, la copie dessinerait un second
   contour blanc sur celui de la truffe. Son rayon est celui de l'image dans la vignette. */
.wid__fly {
    position: absolute;
    z-index: 3;
    border-radius: 9px;
    box-shadow: none;
    pointer-events: none;
    transform-origin: 50% 50%;
    will-change: transform, opacity;
}

/* ---------- Par-dessus la scène ---------- */

.wid__hud {
    --wid-guide-top: 60%;
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-rows: auto auto minmax(0, 1fr) auto auto auto;
    justify-items: center;
    padding: calc(var(--wid-safe-top) + 10px) calc(var(--wid-safe-right) + 14px) calc(var(--wid-safe-bottom) + 14px) calc(var(--wid-safe-left) + 14px);
    pointer-events: none;
}

.wid__hud > * {
    pointer-events: auto;
}

.wid__top {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) 48px;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 720px;
}

.wid__round {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 0;
    border-radius: var(--r-full);
    background: var(--wid-veil-soft);
    color: var(--c-text-inverse);
    font-weight: 600;
    font-size: 0.94rem;
    font-variant-numeric: tabular-nums;
    transition: background var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}

.wid__round:active {
    transform: scale(0.94);
}

.wid__title {
    margin: 0;
    font-family: var(--f-display);
    font-weight: 600;
    font-size: 1.1rem;
    line-height: 1.2;
    text-align: center;
    text-wrap: balance;
    text-shadow: 0 1px 8px var(--wid-veil);
}

/* Compteur : un segment par photo (pointillés = facultative), et la ligne qui le dit. */
.wid__count {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    min-height: 34px;
    margin: 8px 0 0;
}

.wid__segs {
    display: flex;
    gap: 5px;
}

.wid__seg {
    position: relative;
    width: 28px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.32);
    overflow: hidden;
}

.wid__seg[data-optional] {
    background: repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.5) 0 4px, rgba(255, 255, 255, 0) 4px 8px);
}

.wid__seg b {
    position: absolute;
    inset: 0;
    border-radius: 2px;
    background: var(--c-primary-soft);
    transform: scaleX(0);
    transform-origin: 0 50%;
    transition: transform 300ms var(--ease-out);
}

.wid__seg[data-on="1"] b {
    transform: none;
}

.wid__count-text {
    margin: 0;
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    opacity: 0.92;
    text-shadow: 0 1px 6px var(--wid-veil);
}

.wid__count-text.is-swap,
.wid__guide-text.is-swap {
    animation: wid-swap 220ms var(--ease-out);
}

@keyframes wid-swap {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

/* L'emplacement du viseur : le script y centre la truffe. */
.wid__slot {
    width: 100%;
    min-height: 120px;
    pointer-events: none;
}

/* La place gardée au message dans la colonne (le viseur ne change pas de taille). */
.wid__guide-room {
    width: 100%;
    height: 52px;
    pointer-events: none;
}

/* Le message : toujours la même largeur, collé sous le viseur (--wid-guide-top, posé par le script). */
.wid__guide {
    position: absolute;
    top: var(--wid-guide-top);
    left: calc(var(--wid-safe-left) + 14px);
    right: calc(var(--wid-safe-right) + 14px);
    display: flex;
    align-items: center;
    gap: 10px;
    width: min(100% - 28px, 360px);
    min-height: 52px;
    margin: 0 auto;
    padding: 7px 18px 7px 7px;
    border-radius: 26px;
    background: var(--c-bg-card);
    color: var(--c-text);
    box-shadow: var(--shadow-lg);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.25;
    text-wrap: balance;
    transition: background var(--dur-normal) var(--ease-out), color var(--dur-normal) var(--ease-out);
}

.wid__guide-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: none;
    width: 38px;
    height: 38px;
    border-radius: var(--r-full);
    background: var(--c-primary-light);
    color: var(--c-primary);
    transition: background var(--dur-normal) var(--ease-out), color var(--dur-normal) var(--ease-out);
}

.wid__guide-icon .wid__icon {
    width: 22px;
    height: 22px;
}

.wid__guide-text {
    display: block;
    min-width: 0;
}

.wid__guide[data-code="ok"] .wid__guide-icon,
.wid__guide[data-code="full"] .wid__guide-icon {
    background: var(--c-primary);
    color: var(--c-text-inverse);
}

.wid__guide[data-code="notice"] {
    background: var(--c-warning-light);
    color: var(--c-warning-text);
}

.wid__guide[data-code="notice"] .wid__guide-icon {
    background: var(--c-warning-border);
    color: var(--c-warning-text);
}

.wid__chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    margin: 12px 0 0;
    padding: 0;
    list-style: none;
}

.wid__chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px 5px 8px;
    border-radius: var(--r-full);
    background: var(--wid-veil-soft);
    font-size: 0.8rem;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
}

/* Cinq témoins (avec « Truffe ») : un peu plus serrés, pour tenir sur une ligne d'un téléphone. */
.wid__chips[data-n="5"] {
    gap: 3px;
}

.wid__chips[data-n="5"] .wid__chip {
    gap: 4px;
    padding: 5px 7px 5px 6px;
    font-size: 0.74rem;
}

/* L'état ne passe pas par la seule couleur : inconnu = petit point pâle, bon = disque plein,
   à corriger = anneau creux. */
.wid__dot {
    width: 9px;
    height: 9px;
    border: 2px solid transparent;
    border-radius: var(--r-full);
    background: var(--wid-line-dim);
    transform: scale(0.6);
    transition: background var(--dur-normal) var(--ease-out), border-color var(--dur-normal) var(--ease-out), transform var(--dur-normal) var(--ease-spring);
}

.wid__chip[data-s="ok"] .wid__dot {
    background: var(--c-primary-soft);
    transform: none;
}

.wid__chip[data-s="bad"] .wid__dot {
    border-color: var(--c-accent);
    background: transparent;
    transform: none;
}

.wid__chip[data-s="bad"] {
    color: var(--c-accent-soft);
}

.wid__bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: 560px;
    margin-top: 16px;
}

.wid__thumbs {
    display: flex;
    gap: 7px;
    justify-self: start;
}

.wid__thumb {
    position: relative;
    width: 46px;
    height: 46px;
    padding: 0;
    border: 2px solid var(--wid-line);
    border-radius: var(--r-md);
    background: var(--wid-veil-deep);
    overflow: visible;
    transition: border-color var(--dur-normal) var(--ease-out);
}

/* Seule une NOUVELLE vignette s'anime (classe posée une fois, retirée à la fin). */
.wid__thumb.is-new {
    animation: wid-pop var(--dur-slow) var(--ease-spring);
}

.wid__thumb.is-landing {
    opacity: 0;
}

/* La photo vient de se poser sur sa vignette : elle « prend », sans disparaître. */
.wid__thumb.is-landed {
    animation: wid-land 380ms var(--ease-spring);
}

@keyframes wid-land {
    from { transform: scale(1.16); }
    to { transform: none; }
}

.wid__thumb canvas {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 9px;
}

/* Pastille de la vignette : anneau blanc qui tourne = en cours · disque teal = retenue ·
   ambre et « ! » = à refaire. */
.wid__thumb-mark {
    position: absolute;
    right: -6px;
    top: -6px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border: 2px solid var(--wid-line);
    border-radius: var(--r-full);
    background: var(--c-primary-soft);
    color: var(--c-warning-text);
    font-style: normal;
    font-size: 10px;
    font-weight: 800;
    line-height: 1;
    transition: background var(--dur-normal) var(--ease-out), border-color var(--dur-normal) var(--ease-out);
}

.wid__thumb[data-state="checking"] .wid__thumb-mark,
.wid__thumb[data-state="encoding"] .wid__thumb-mark {
    border-color: var(--wid-line) rgba(255, 255, 255, 0.28) rgba(255, 255, 255, 0.28) rgba(255, 255, 255, 0.28);
    background: var(--wid-veil-deep);
    animation: wid-spin 900ms linear infinite;
}

.wid__thumb[data-state="refused"] {
    border-color: var(--c-warning-border);
}

/* Gardée sans l'avis du site (il n'a pas répondu) : anneau creux, immobile — ni retenue, ni refusée. */
.wid__thumb[data-state="later"] .wid__thumb-mark {
    background: var(--wid-veil-deep);
}

/* La photo que l'on refait : en retrait, bord en pointillés. Elle reste si l'on renonce. */
.wid__thumb[data-swap="1"] {
    border-style: dashed;
}

.wid__thumb[data-swap="1"] canvas {
    opacity: 0.5;
}

.wid__thumb[data-state="refused"] .wid__thumb-mark {
    border-color: var(--c-warning-border);
    background: var(--c-warning-border);
}

.wid__thumb[data-state="refused"] .wid__thumb-mark::before {
    content: "!";
}

/* Le déclencheur : discret tant que l'on cherche, corail quand la truffe est trouvée. */
.wid__shutter {
    position: relative;
    width: 78px;
    height: 78px;
    padding: 0;
    border: 3px solid var(--wid-line);
    border-radius: var(--r-full);
    background: transparent;
    transition: transform var(--dur-fast) var(--ease-out);
}

.wid__shutter-core {
    position: absolute;
    inset: 5px;
    border-radius: var(--r-full);
    background: rgba(255, 255, 255, 0.28);
    transition: background 200ms var(--ease-out), transform var(--dur-fast) var(--ease-out);
}

.wid[data-lock="found"] .wid__shutter-core,
.wid[data-lock="shot"] .wid__shutter-core {
    background: var(--c-accent-vivid);
}

.wid__shutter:active .wid__shutter-core,
.wid[data-busy="1"] .wid__shutter-core {
    transform: scale(0.86);
}

@media (hover: hover) {
    .wid__shutter:hover .wid__shutter-core {
        background: rgba(255, 255, 255, 0.4);
    }

    .wid[data-lock="found"] .wid__shutter:hover .wid__shutter-core {
        background: var(--c-accent-vivid-hover);
    }
}

.wid__shutter:focus-visible {
    outline-color: var(--wid-line);
}

.wid__done {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    justify-self: end;
    min-height: 48px;
    padding: 0 16px 0 12px;
    border: 0;
    border-radius: var(--r-full);
    background: var(--c-bg-card);
    color: var(--c-primary);
    font-weight: 600;
    font-size: 0.94rem;
    white-space: nowrap;
    box-shadow: var(--shadow-md);
}

/* À son arrivée (le minimum de photos est atteint) : il se pose, puis UNE pulsation. */
.wid__done.is-new {
    animation: wid-done-in 760ms var(--ease-spring);
}

@keyframes wid-done-in {
    0% { opacity: 0; transform: scale(0.9); }
    45% { opacity: 1; transform: none; }
    72% { transform: scale(1.04); }
    100% { transform: none; }
}

.wid__done:disabled {
    color: var(--c-text-muted);
}

/* En attente de la vérification : la roue d'abord, le mot ensuite, sans toucher le déclencheur
   (écran de 360 px, toutes langues : le bouton ne sort jamais de sa colonne). */
.wid__done[data-wait="1"] {
    gap: 4px;
    max-width: 100%;
    padding: 0 9px 0 7px;
}

@media (max-width: 400px) {
    .wid__done[data-wait="1"] {
        font-size: 0.76rem;
    }
}

.wid__done[data-wait="1"] .wid__label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wid__done .wid__spin {
    width: 14px;
    height: 14px;
}

.wid__done .wid__spin,
.wid__btn .wid__spin {
    order: -1;
}

.wid__done .wid__icon {
    width: 20px;
    height: 20px;
}

/* La petite roue d'attente (boutons, pastilles). */
.wid__spin {
    display: none;
    flex: none;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: var(--r-full);
    animation: wid-spin 900ms linear infinite;
}

.wid [data-wait="1"] > .wid__spin {
    display: block;
}

.wid [data-wait="1"] > .wid__icon {
    display: none;
}

@keyframes wid-spin {
    to { transform: rotate(360deg); }
}

@keyframes wid-pop {
    from { transform: scale(0.6); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Lecteurs d'écran seulement. */
.wid__live {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

/* ---------- Panneaux : accueil (et repli « fichier »), relecture ---------- */

.wid__panel {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: calc(var(--wid-safe-top) + 68px) calc(var(--wid-safe-right) + 22px) calc(var(--wid-safe-bottom) + 28px) calc(var(--wid-safe-left) + 22px);
    background: var(--c-bg);
    color: var(--c-text);
}

.wid__close--panel {
    position: absolute;
    top: calc(var(--wid-safe-top) + 10px);
    left: calc(var(--wid-safe-left) + 14px);
    background: var(--c-bg-warm);
    color: var(--c-text);
}

.wid__box {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    max-width: 440px;
    margin: auto 0;
}

/* La relecture change de hauteur (un problème apparaît, une aide passe sur deux lignes, un bouton
   vient ou s'en va) : ancrée en haut, rien ne saute. --wid-n = nombre de photos (posé par le script). */
.wid__review .wid__box {
    --wid-n: 1;
    margin: clamp(0px, 6vh, 56px) 0 auto;
}

.wid__review .wid__lead {
    min-height: 2.9em;       /* deux lignes, toujours */
}

/* Indicateur d'étapes (facultatif) : trois points reliés. En cours = point plein, faite = coche. */
.wid__steps {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    max-width: 340px;
    margin: 0 auto 26px;
    padding: 0;
    list-style: none;
}

.wid__step {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    color: var(--c-text-muted);
    font-size: 0.76rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    transition: color var(--dur-normal) var(--ease-out);
}

.wid__step + .wid__step::before,
.wid__step + .wid__step::after {
    content: "";
    position: absolute;
    top: 10px;
    left: calc(-50% + 17px);
    right: calc(50% + 17px);
    height: 2px;
    border-radius: 1px;
    background: var(--c-border);
}

.wid__step + .wid__step::after {
    background: var(--c-primary);
    transform: scaleX(0);
    transform-origin: 0 50%;
    transition: transform 320ms var(--ease-out);
}

.wid__step[data-s="done"] + .wid__step::after {
    transform: none;
}

.wid__step-dot {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: 2px solid var(--c-border);
    border-radius: var(--r-full);
    background: var(--c-bg);
    color: var(--c-text-inverse);
    transition: background var(--dur-normal) var(--ease-out), border-color var(--dur-normal) var(--ease-out), box-shadow var(--dur-normal) var(--ease-out);
}

.wid__step-dot .wid__icon {
    width: 12px;
    height: 12px;
    stroke-width: 3.2;
    opacity: 0;
    transition: opacity var(--dur-normal) var(--ease-out);
}

.wid__step[data-s="current"],
.wid__step[data-s="done"] {
    color: var(--c-text);
}

.wid__step[data-s="current"] .wid__step-dot {
    border-color: var(--c-primary);
    background: var(--c-primary);
    box-shadow: 0 0 0 4px var(--c-primary-light);
    animation: wid-dot-a 300ms var(--ease-spring);
}

.wid__step[data-s="done"] .wid__step-dot {
    border-color: var(--c-primary);
    background: var(--c-primary);
    animation: wid-dot-b 300ms var(--ease-spring);
}

.wid__step[data-s="done"] .wid__step-dot .wid__icon {
    opacity: 1;
}

@keyframes wid-dot-a {
    from { transform: scale(0.6); }
    to { transform: none; }
}

@keyframes wid-dot-b {
    from { transform: scale(0.6); }
    to { transform: none; }
}

/* Le médaillon des conseils : le viseur lui-même, en petit. */
.wid__badge {
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: center;
    width: 104px;
    height: 104px;
    margin-bottom: 18px;
    border-radius: var(--r-full);
    background: var(--c-primary-light);
    color: var(--c-primary);
}

.wid__badge .wid__icon {
    width: 52px;
    height: 52px;
    stroke-width: 1.5;
}

.wid__badge-nose {
    width: 68px;
    height: auto;
    overflow: visible;
}

.wid__badge-fill {
    fill: var(--c-bg-card);
}

.wid__badge-line,
.wid__badge-hints {
    fill: none;
    stroke: var(--c-primary);
    stroke-linecap: round;
    stroke-linejoin: round;
}

.wid__badge-line {
    stroke-width: 11;
    stroke-dasharray: 100;
}

.wid__badge-hints {
    stroke-width: 6;
    stroke-dasharray: 9 15;
    opacity: 0.55;
}

.wid__heading {
    margin: 0 0 8px;
    font-family: var(--f-display);
    font-weight: 600;
    font-size: clamp(1.55rem, 6vw, 2rem);
    line-height: 1.12;
    letter-spacing: -0.01em;
    text-align: center;
    text-wrap: balance;
}

.wid__heading:focus {
    outline: none;
}

.wid__lead {
    margin: 0 0 22px;
    color: var(--c-text-secondary);
    font-size: 0.94rem;
    text-align: center;
    text-wrap: pretty;
}

.wid__tips {
    display: grid;
    gap: 12px;
    margin: 0 0 24px;
    padding: 18px;
    border: 1px solid var(--c-border-light);
    border-radius: var(--r-xl);
    background: var(--c-bg-card);
    list-style: none;
}

.wid__tip {
    display: grid;
    grid-template-columns: 40px minmax(0, 1fr);
    align-items: center;
    gap: 12px;
    font-size: 0.94rem;
    line-height: 1.35;
}

.wid__tip .wid__icon {
    width: 40px;
    height: 40px;
    padding: 9px;
    border-radius: var(--r-md);
    background: var(--c-primary-light);
    color: var(--c-primary);
}

.wid__notice {
    margin: 0 0 16px;
    padding: 12px 14px;
    border: 1px solid var(--c-warning-border);
    border-radius: var(--r-md);
    background: var(--c-warning-light);
    color: var(--c-warning-text);
    font-size: 0.94rem;
}

.wid__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 54px;
    margin-bottom: 10px;
    padding: 10px 20px;
    border: 1px solid transparent;
    border-radius: var(--r-full);
    font-size: 0.94rem;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    transition: background var(--dur-normal) var(--ease-out), color var(--dur-normal) var(--ease-out), border-color var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}

.wid__btn:active {
    transform: scale(0.98);
}

.wid__btn--primary {
    background: var(--c-primary);
    color: var(--c-text-inverse);
}

.wid__btn--primary:disabled {
    background: var(--c-border);
    color: var(--c-text-muted);
}

.wid__btn--ghost {
    border-color: var(--c-border);
    background: transparent;
    color: var(--c-primary);
}

/* Le bouton final de la relecture : la seule action forte de l'écran — corail, texte encre. */
.wid__final:not(:disabled) {
    background: var(--c-accent-vivid);
    color: var(--c-on-vivid);
}

.wid__final:focus-visible {
    outline-color: var(--c-primary);
}

.wid__review[data-ready="1"] .wid__final {
    animation: wid-ready 320ms var(--ease-spring);
}

@keyframes wid-ready {
    from { transform: scale(0.96); }
    to { transform: none; }
}

@media (hover: hover) {
    .wid__btn--primary:hover:not(:disabled) {
        background: var(--c-primary-hover);
    }

    .wid__final:hover:not(:disabled) {
        background: var(--c-accent-vivid-hover);
    }

    .wid__btn--ghost:hover {
        background: var(--c-bg-warm);
    }
}

.wid__btn--small {
    min-height: 44px;
    margin: 0;
    padding: 6px 14px;
    border-color: var(--c-warning-border);
    background: var(--c-bg-card);
    color: var(--c-warning-text);
    font-size: 0.82rem;
}

.wid__btn--small .wid__icon {
    width: 18px;
    height: 18px;
}

/* Le champ de fichier reste dans l'arbre d'accessibilité : c'est lui qui prend le focus. */
.wid__pick {
    position: relative;
}

.wid__file {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    font-size: 16px;
}

.wid__pick:focus-within {
    outline: 3px solid var(--c-primary-soft);
    outline-offset: 3px;
}

.wid__note {
    margin: 8px 0 0;
    color: var(--c-text-muted);
    font-size: 0.8rem;
    text-align: center;
    text-wrap: pretty;
}

/* ---------- Relecture ---------- */

/* Le sceau : la truffe se trace, cochée, quand toutes les photos sont retenues. */
.wid__seal {
    align-self: center;
    width: 64px;
    margin: 0 0 14px;
}

.wid__seal svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.wid__seal path {
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.wid__seal-base {
    stroke: var(--c-border);
    stroke-width: 10;
}

.wid__seal-line {
    stroke: var(--c-primary);
    stroke-width: 10;
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    opacity: 0;
}

.wid__seal-check {
    stroke: var(--c-primary);
    stroke-width: 13;
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    opacity: 0;
}

.wid__review[data-ready="1"]:not([data-unverified]) .wid__seal-line {
    stroke-dashoffset: 0;
    opacity: 1;
    transition: stroke-dashoffset 500ms var(--ease-out), opacity 60ms linear;
}

.wid__review[data-ready="1"]:not([data-unverified]) .wid__seal-check {
    stroke-dashoffset: 0;
    opacity: 1;
    transition: stroke-dashoffset 300ms var(--ease-out) 260ms, opacity 60ms linear 260ms;
}

.wid__review[data-doubt] .wid__seal,
.wid__review[data-doubt] .wid__steps {
    display: none;
}

/* Une rangée de N photos carrées. */
.wid__cards {
    display: grid;
    grid-template-columns: repeat(var(--wid-n), minmax(0, 1fr));
    gap: 14px;
    align-self: center;
    width: 100%;
    max-width: calc(var(--wid-n) * 172px);
    margin: 4px 0 20px;
}

.wid__cards[data-count="1"] {
    max-width: 224px;
}

.wid__cards[data-count="0"] {
    display: none;
}

.wid__card {
    position: relative;
}

.wid__card-pic {
    position: relative;
    aspect-ratio: 1;
    border-radius: var(--r-lg);
    overflow: hidden;
    background: var(--c-bg-warm);
    box-shadow: 0 0 0 1px var(--c-border-light), var(--shadow-sm);
    transition: box-shadow var(--dur-normal) var(--ease-out);
}

.wid__card-pic canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.wid__card[data-state="refused"] .wid__card-pic,
.wid__card[data-state="doubt"] .wid__card-pic {
    box-shadow: 0 0 0 3px var(--c-warning-border), var(--shadow-sm);
}

/* En vérification : une bande de lumière descend sur la photo, en boucle. */
.wid__scan {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 36%;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0) 0%, var(--c-primary-soft) 82%, rgba(255, 255, 255, 0) 100%);
    opacity: 0.42;
    pointer-events: none;
    will-change: transform;
}

.wid__card[data-state="checking"] .wid__scan,
.wid__card[data-state="encoding"] .wid__scan {
    display: block;
    animation: wid-scan 1400ms cubic-bezier(0.45, 0, 0.55, 1) infinite;
}

@keyframes wid-scan {
    from { transform: translateY(-100%); }
    to { transform: translateY(280%); }
}

/* La pastille d'état : roue = en vérification · coche = retenue · « ! » = à refaire. */
.wid__mark {
    position: absolute;
    left: 7px;
    bottom: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: var(--r-full);
    background: var(--wid-veil-deep);
    color: var(--c-text-inverse);
    box-shadow: 0 0 0 2px var(--c-bg-card);
    transition: background var(--dur-normal) var(--ease-out), color var(--dur-normal) var(--ease-out);
}

.wid__mark > * {
    position: absolute;
}

.wid__mark .wid__spin {
    width: 14px;
    height: 14px;
}

.wid__card[data-state="checking"] .wid__mark .wid__spin,
.wid__card[data-state="encoding"] .wid__mark .wid__spin {
    display: block;
}

.wid__mark-check {
    width: 16px;
    height: 16px;
    stroke-width: 2.8;
    stroke-dasharray: 20;
    stroke-dashoffset: 20;
    opacity: 0;
}

.wid__mark-bang {
    font-size: 15px;
    font-weight: 800;
    line-height: 1;
    opacity: 0;
    transition: opacity var(--dur-normal) var(--ease-out);
}

.wid__card[data-state="ok"] .wid__mark {
    background: var(--c-primary);
    animation: wid-mark 360ms var(--ease-spring);
}

.wid__card[data-state="ok"] .wid__mark-check {
    opacity: 1;
    stroke-dashoffset: 0;
    transition: stroke-dashoffset 280ms var(--ease-out) 80ms;
}

.wid__card[data-state="refused"] .wid__mark,
.wid__card[data-state="doubt"] .wid__mark {
    background: var(--c-warning-border);
    color: var(--c-warning-text);
}

/* Gardée, mais le site n'a pas pu la vérifier : pastille neutre (une horloge), jamais la coche. */
.wid__mark-later {
    width: 18px;
    height: 18px;
    opacity: 0;
    transition: opacity var(--dur-normal) var(--ease-out);
}

.wid__card[data-state="later"] .wid__mark {
    background: var(--c-bg-card);
    color: var(--c-text-secondary);
    box-shadow: 0 0 0 1px var(--c-border), 0 0 0 2px var(--c-bg-card);
}

.wid__card[data-state="later"] .wid__mark-later {
    opacity: 1;
}

.wid__card[data-state="refused"] .wid__mark-bang,
.wid__card[data-state="doubt"] .wid__mark-bang {
    opacity: 1;
}

@keyframes wid-mark {
    from { transform: scale(0.5); }
    to { transform: none; }
}

/* « Refaire » : un bouton rond sur le coin de la photo (cible de 44 px). */
.wid__retake {
    position: absolute;
    top: -9px;
    right: -9px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--c-border-light);
    border-radius: var(--r-full);
    background: var(--c-bg-card);
    color: var(--c-primary);
    box-shadow: var(--shadow-md);
    transition: transform var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}

.wid__retake::after {
    content: "";
    position: absolute;
    inset: -5px;
    border-radius: var(--r-full);
}

.wid__retake .wid__icon {
    width: 18px;
    height: 18px;
}

.wid__retake:active {
    transform: scale(0.92);
}

/* Sous la rangée : seulement ce qui ne va pas. */
.wid__issues {
    display: grid;
    gap: 8px;
    margin: 0 0 20px;
    padding: 0;
    list-style: none;
}

.wid__issue {
    display: grid;
    grid-template-columns: 26px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 10px 10px 10px 12px;
    border: 1px solid var(--c-border-light);
    border-radius: var(--r-lg);
    background: var(--c-bg-card);
    color: var(--c-text-secondary);
    font-size: 0.86rem;
    line-height: 1.35;
    animation: wid-fade 250ms var(--ease-out);
}

.wid__issue[data-state="refused"] {
    border-color: var(--c-warning-border);
    background: var(--c-warning-light);
    color: var(--c-warning-text);
}

.wid__issue-n {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: var(--r-full);
    background: var(--c-bg-warm);
    color: var(--c-text);
    font-size: 0.8rem;
    font-weight: 700;
}

.wid__issue[data-state="refused"] .wid__issue-n {
    background: var(--c-warning-border);
    color: var(--c-warning-text);
}

.wid__issue-text {
    margin: 0;
}

.wid__issue-text strong {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

@keyframes wid-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ---------- Entrées et sorties (jouées une fois : repère data-enter, posé puis retiré) ---------- */

@keyframes wid-rise {
    from { opacity: 0; transform: translateY(var(--wid-rise, 8px)); }
    to { opacity: 1; transform: none; }
}

@keyframes wid-trace {
    from { stroke-dashoffset: 100; }
    to { stroke-dashoffset: 0; }
}

@keyframes wid-grow {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: none; }
}

/* Conseils : le contour du médaillon se trace, puis tout arrive en cascade (≤ 550 ms). */
.wid[data-enter="intro"] .wid__badge-line {
    animation: wid-trace 600ms var(--ease-out) backwards;
}

.wid[data-enter="intro"] .wid__badge-fill {
    animation: wid-fade 200ms linear 420ms backwards;
}

.wid[data-enter="intro"] .wid__badge-hints {
    animation: wid-fade 200ms linear 360ms backwards;
}

.wid[data-enter="intro"] .wid__intro .wid__steps,
.wid[data-enter="intro"] .wid__intro .wid__heading,
.wid[data-enter="intro"] .wid__intro .wid__lead,
.wid[data-enter="intro"] .wid__intro .wid__tip,
.wid[data-enter="intro"] .wid__intro .wid__btn,
.wid[data-enter="intro"] .wid__intro .wid__note {
    animation: wid-rise 300ms var(--ease-out) backwards;
}

.wid[data-enter="intro"] .wid__intro .wid__lead { animation-delay: 40ms; }
.wid[data-enter="intro"] .wid__intro .wid__tip:nth-child(1) { animation-delay: 90ms; }
.wid[data-enter="intro"] .wid__intro .wid__tip:nth-child(2) { animation-delay: 140ms; }
.wid[data-enter="intro"] .wid__intro .wid__tip:nth-child(3) { animation-delay: 190ms; }
.wid[data-enter="intro"] .wid__intro .wid__btn { animation-delay: 230ms; }
.wid[data-enter="intro"] .wid__intro .wid__btn + .wid__btn,
.wid[data-enter="intro"] .wid__intro .wid__note { animation-delay: 260ms; }

/* Des conseils à la caméra : le panneau s'efface, la scène paraît, les commandes montent. */
.wid__intro.is-leaving {
    z-index: 2;
    pointer-events: none;
    animation: wid-leave 200ms var(--ease-out) forwards;
}

@keyframes wid-leave {
    to { opacity: 0; transform: scale(0.98); }
}

.wid[data-enter="camera"] .wid__stage {
    animation: wid-fade 300ms linear backwards;
}

.wid[data-enter="camera"] .wid__top,
.wid[data-enter="camera"] .wid__count,
.wid[data-enter="camera"] .wid__guide,
.wid[data-enter="camera"] .wid__chips,
.wid[data-enter="camera"] .wid__bar {
    --wid-rise: 12px;
    animation: wid-rise 380ms var(--ease-out) 120ms backwards;
}

.wid[data-enter="camera"] .wid__count { animation-delay: 180ms; }
.wid[data-enter="camera"] .wid__guide { animation-delay: 240ms; }
.wid[data-enter="camera"] .wid__chips { animation-delay: 300ms; }
.wid[data-enter="camera"] .wid__bar { animation-delay: 360ms; }

/* Relecture : le panneau monte, les photos se posent l'une après l'autre. */
.wid[data-enter="review"] .wid__review .wid__box {
    --wid-rise: 24px;
    animation: wid-rise 360ms var(--ease-out) backwards;
}

.wid[data-enter="review"] .wid__card {
    animation: wid-grow 320ms var(--ease-out) calc(120ms + var(--wid-i, 0) * 60ms) backwards;
}

/* « Terminer » : tout s'efface, puis la fenêtre se ferme. */
.wid.is-leaving .wid__box,
.wid.is-leaving .wid__close,
.wid.is-leaving .wid__hud,
.wid.is-leaving .wid__stage {
    opacity: 0;
    transition: opacity 200ms var(--ease-out);
    pointer-events: none;
}

/* ---------- Écrans larges, écrans bas ---------- */

@media (min-width: 768px) {
    .wid__hud {
        padding-top: calc(var(--wid-safe-top) + 18px);
        padding-bottom: calc(var(--wid-safe-bottom) + 22px);
    }

    .wid__review .wid__box {
        max-width: 560px;
    }

    .wid__cards {
        gap: 18px;
    }

    /* Aussi larges que la rangée de photos qu'ils concluent (n × 172 px, espaces compris). */
    .wid__review .wid__btn:not(.wid__btn--small) {
        align-self: center;
        width: 100%;
        max-width: max(344px, calc(var(--wid-n) * 172px));
    }
}

/* Petit téléphone (360 px) : les cinq témoins tiennent encore sur une ligne. */
@media (max-width: 380px) {
    .wid__chips[data-n="5"] {
        gap: 2px;
    }

    .wid__chips[data-n="5"] .wid__chip {
        gap: 3px;
        padding: 5px 5px 5px 4px;
        font-size: 0.7rem;
    }
}

@media (max-height: 520px) {
    .wid__chips {
        display: none;
    }

    .wid__bar {
        margin-top: 8px;
    }

    .wid__shutter {
        width: 64px;
        height: 64px;
    }

    .wid__panel {
        padding-top: calc(var(--wid-safe-top) + 62px);
    }

    .wid__badge,
    .wid__seal {
        display: none;
    }
}

/* Mouvement réduit : mêmes étapes, mêmes textes, mêmes retours d'état — seulement de courts
   fondus. Ni tracé, ni vol, ni bande de lumière, ni roue (une icône fixe et le texte le disent). */
@media (prefers-reduced-motion: reduce) {
    .wid *,
    .wid *::before,
    .wid *::after {
        animation: none !important;
        transition-property: opacity, background-color, color, border-color, stroke, box-shadow !important;
        transition-duration: 120ms !important;
        transition-delay: 0ms !important;
    }

    .wid__scan {
        display: none !important;
    }
}
