/* Zado — base: structure, states and the MECHANICS of the animations..
   Lo-fi on purpose: boxes and words. Every colour, font and duration comes from a token of theme.css.
   Animations move transform and opacity only (cheap on weak phones). */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; } /* a display rule of the theme must never reveal a hidden state */

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.4;
}
.app {
  max-width: 30rem;
  margin: 0 auto;
  padding: 12px max(16px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
h1, h2, p, ul, dl, dd { margin: 0; }
ul { padding-left: 1.2em; }
h1 { font-family: var(--font-title); font-size: 1.5rem; line-height: 1.15; }
h2 { font-family: var(--font-title); font-size: 1rem; }
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
h1:focus-visible { outline: none; } /* titles receive focus by script after a change of step */

.skip { position: absolute; left: -9999px; top: 0; }
.skip:focus { left: 8px; top: 8px; background: var(--paper); padding: 8px; z-index: 5; }

.view, .step { display: grid; gap: 12px; }
.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 32px; }
.brand { font-weight: 700; }
.place, .infos, .hint, .notice { color: var(--muted); font-size: 0.875rem; }
.back { color: var(--ink); display: inline-flex; align-items: center; min-height: 48px; min-width: 48px; }

/* Image slots: fixed ratio, so nothing moves when the design pass drops the pictures in. */
.slot { display: grid; place-items: center; border: 1.5px dashed var(--line); border-radius: var(--radius); color: var(--muted); font-size: 0.8rem; }
.slot-hero { aspect-ratio: 16 / 9; }

.prix strong { font-size: 1.5rem; }
/* Decided on 29 Nov 2026: the price in green, the other price in red and struck through. */
.prix-zado { color: var(--price); }
.prix-barre { color: var(--price-old); text-decoration: line-through; font-size: 1.1rem; margin-right: 6px; }
.don, .box, .totaux, .etat, .fallback { border: 1.5px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.etat { background: var(--fill); font-weight: 600; }
.fallback { margin-top: 16px; display: grid; gap: 8px; }
.pied { margin-top: 20px; color: var(--muted); font-size: 0.8rem; }
.conditions summary { padding: 16px 0; cursor: pointer; } /* a thumb-sized target */
.conditions p { margin-top: 8px; }
.signature { margin-top: 12px; font-size: 0.75rem; }

/* Buttons: touch targets of 48 px at least. */
.btn, .btn-round {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 10px 16px;
  border: 2px solid var(--ink); border-radius: var(--radius);
  background: var(--paper); color: var(--ink);
  font: inherit; font-weight: 700; text-align: center; text-decoration: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.btn-main { background: var(--ink); color: var(--on-ink); width: 100%; }
.btn-ghost { width: 100%; }
.btn[disabled], .btn-round[disabled] { opacity: 0.4; cursor: default; }
.btn-round { width: 56px; height: 56px; padding: 0; font-size: 1.6rem; touch-action: manipulation; }
.btn-choice[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); }
/* On the confirmation step, the main button depends on the state of the order. */
[data-order-status="declaree"] [data-step-panel="D"] [data-action="send-ref"],
[data-order-status="payee"] [data-step-panel="D"] [data-action="share"],
[data-order-status="livree"] [data-step-panel="D"] [data-action="share"],
[data-order-status="expiree"] [data-step-panel="D"] [data-action="new-order"],
[data-order-status="annulee"] [data-step-panel="D"] [data-action="new-order"] { background: var(--ink); color: var(--on-ink); }
.link { border: 0; background: none; padding: 0; min-height: 48px; font: inherit; color: var(--ink); text-decoration: underline; cursor: pointer; }

/* The delivery hint: it calls the eye when it appears or changes (two pulses), then rests. Vertical move and
   opacity only: a sideways move or a zoom would make the page scroll sideways. */
[data-out="delivery-hint"] { color: var(--ink); font-weight: 700; font-size: 1rem; }
[data-out="delivery-hint"]:empty { display: none; }
[data-out="delivery-hint"][data-nudge="1"] { animation: nudge var(--dur-nudge) ease-in-out 2; }
@keyframes nudge {
  0%, 100% { opacity: 1; transform: translateY(0); }
  40% { opacity: 0.2; transform: translateY(-4px); }
}

.stepper { display: flex; align-items: center; justify-content: center; gap: 20px; }
.qty { min-width: 3ch; text-align: center; font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.totaux { display: grid; gap: 4px; }
.ligne { display: flex; justify-content: space-between; gap: 12px; }
.ligne-total { font-weight: 700; }
.methods { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ref { font-size: 1.25rem; letter-spacing: 0.06em; white-space: nowrap; }
.step-count { color: var(--muted); font-size: 0.875rem; }
.step-count:empty { display: none; }
.ref-big { font-size: 1.1rem; }
.recap { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.field { display: grid; gap: 4px; }
.field label { font-weight: 600; }
.field input, .field select {
  width: 100%; min-height: 48px; padding: 8px 10px;
  border: 1.5px solid var(--line); border-radius: var(--radius);
  background: var(--paper); color: var(--ink); font: inherit; font-size: 1rem; /* 16 px: iOS does not zoom */
}
.field [aria-invalid="true"] { border-color: var(--danger); border-width: 2px; }
.error { color: var(--danger); font-size: 0.875rem; font-weight: 600; }
.facture { font-size: 0.875rem; font-weight: 600; }
/* An optional box (the photo of the handing-over): the whole line is the target, at least 48 px high. */
.check { display: flex; align-items: center; gap: 12px; min-height: 48px; }
.check input { flex: none; width: 24px; height: 24px; margin: 0; accent-color: var(--ink); }
.check label { font-size: 0.875rem; padding: 6px 0; cursor: pointer; }
.stock-note { text-align: center; font-size: 0.875rem; font-weight: 700; }

/* ---------- The quartier field: an input that filters a list ---------- */
/* The list sits in the flow, right under the input: on a phone nothing can hide it or cut it. */
.combo { display: grid; gap: 4px; }
.combo-list {
  position: relative; /* the offset parent of the options: the keyboard keeps the active one in sight */
  list-style: none; margin: 0; padding: 0;
  max-height: 248px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  border: 1.5px solid var(--ink); border-radius: var(--radius); background: var(--paper);
}
.combo-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 48px; padding: 8px 12px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.combo-list li:last-child { border-bottom: 0; }
.combo-list li[data-active="1"] { background: var(--fill); outline: 2px solid var(--ink); outline-offset: -2px; }
.combo-list li[aria-selected="true"] { font-weight: 700; }
.combo-commune { flex: none; font-size: 0.8rem; color: var(--muted); }
.combo-list .combo-empty { cursor: default; color: var(--muted); font-size: 0.875rem; }
.combo-list .combo-other { font-weight: 600; }
.trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- The gauge ---------- */
/* A large track with the rooster inside. At the first step it is also the handle of the quantity: the client
   slides the rooster. Everything that moves is moved with a transform; the track clips, so the page never
   scrolls sideways. --pad and --goal are the fixed parts at both ends; the rail between them is the steps of one lap (RULES.gaugeSize). */
.gauge { margin-top: 16px; padding-top: 12px; border-top: 1.5px solid var(--line); display: grid; gap: 6px; --p-total: 0; --p-base: 0; --pad: 34px; --goal: 88px; } /* --goal leaves room for the prize AND for the rooster standing next to it when the gauge is full */
.gauge-track {
  position: relative; height: 68px; overflow: hidden;
  border: 2px solid var(--ink); border-radius: 34px; background: var(--paper);
  touch-action: pan-y; /* a sideways drag is ours, an up-and-down drag still scrolls the page */
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
.gauge-measure, .gauge-rail { position: absolute; left: var(--pad); right: var(--goal); top: 0; bottom: 0; pointer-events: none; }
.gauge-rail { transform: translateX(calc(var(--p-total) * 100%)); transition: transform var(--dur-step) ease-out; }
.gauge-rail-base { transform: translateX(calc(var(--p-base) * 100%)); }
.gauge-trail { position: absolute; right: 100%; top: 0; bottom: 0; width: 200vw; } /* everything behind the rooster */
.gauge-rail-total .gauge-trail { background: var(--fill); }
.gauge-rail-base .gauge-trail { background: var(--line); }
.gauge[data-instant="1"] .gauge-rail, .gauge[data-dragging="1"] .gauge-rail { transition: none; }
.gauge-goal {
  position: absolute; right: 6px; top: 6px; width: 52px; height: 52px;
  display: grid; place-items: center; border: 1.5px dashed var(--line); border-radius: 50%;
  background: var(--paper); color: var(--muted); font-size: 0.7rem;
}
/* The real control for the keyboard and for screen readers: a native slider, invisible, on top of the track. */
.gauge-range { position: absolute; left: 0; top: 0; width: 100%; height: 100%; margin: 0; opacity: 0; pointer-events: none; }
.gauge-track:focus-within { outline: 3px solid var(--ink); outline-offset: 2px; }
.gauge[data-slider="1"] .gauge-track { cursor: grab; }
.gauge[data-dragging="1"] .gauge-track { cursor: grabbing; }
.gauge-help { font-size: 0.875rem; font-weight: 600; }
.gauge-number { margin-top: 2px; }
.gauge-count { font-size: 0.875rem; font-variant-numeric: tabular-nums; }
.gauge-text { font-size: 0.875rem; color: var(--muted); min-height: 2.5em; }

/* The rooster. data-art="lofi": the drawn face below. data-art="sprite": the two strips of the design pass. */
.mascot { position: absolute; left: -26px; top: 6px; width: 52px; height: 52px; }
/* Waiting to go: while the client can slide it, the rooster shifts from foot to foot now and then. */
.mascot[data-idle="1"][data-walking="0"] .mascot-lofi, .mascot[data-idle="1"][data-walking="0"] .mascot-sprite { animation: idle-wait 2.6s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes idle-wait {
  0%, 55%, 100% { transform: translateY(0) rotate(0deg); }
  62% { transform: translateY(-4px) rotate(7deg); }
  70% { transform: translateY(0) rotate(7deg); }
  78% { transform: translateY(-4px) rotate(7deg); }
  88% { transform: translateY(0) rotate(0deg); }
}
.mascot-lofi { display: block; overflow: visible; }
.mascot-lofi .m-head { fill: var(--paper); stroke: var(--ink); stroke-width: 2; }
.mascot-lofi path { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.mascot-lofi .m-eye, .mascot-lofi .m-open { fill: var(--ink); }
.mascot-lofi g { display: none; }
.mascot[data-mood="1"] g[data-face="1"], .mascot[data-mood="2"] g[data-face="2"], .mascot[data-mood="3"] g[data-face="3"],
.mascot[data-mood="4"] g[data-face="4"], .mascot[data-mood="5"] g[data-face="5"], .mascot[data-mood="6"] g[data-face="6"] { display: inline; }
.mascot[data-walking="1"] .mascot-lofi { animation: walk-bob var(--dur-walk) steps(1, end) infinite; }
@keyframes walk-bob {
  0% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-3px) rotate(-4deg); }
  50% { transform: translateY(0) rotate(0deg); }
  75% { transform: translateY(-3px) rotate(4deg); }
}

.mascot-sprite { display: none; position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: hidden; }
.gauge[data-art="sprite"] .mascot-lofi { display: none; }
.gauge[data-art="sprite"] .mascot-sprite { display: block; }
.mascot-strip { position: absolute; left: 0; top: 0; height: 100%; background-repeat: no-repeat; background-size: 100% 100%; }
.mascot-strip-moods { width: 600%; background-image: var(--mascot-moods, none); } /* 6 frames side by side */
.mascot-strip-walk { width: 400%; background-image: var(--mascot-walk, none); display: none; } /* 4 frames side by side */
.mascot[data-mood="2"] .mascot-strip-moods { transform: translateX(-16.6667%); }
.mascot[data-mood="3"] .mascot-strip-moods { transform: translateX(-33.3333%); }
.mascot[data-mood="4"] .mascot-strip-moods { transform: translateX(-50%); }
.mascot[data-mood="5"] .mascot-strip-moods { transform: translateX(-66.6667%); }
.mascot[data-mood="6"] .mascot-strip-moods { transform: translateX(-83.3333%); }
.mascot[data-walking="1"] .mascot-strip-moods { display: none; }
.mascot[data-walking="1"] .mascot-strip-walk { display: block; animation: walk-strip var(--dur-walk) steps(4) infinite; }
@keyframes walk-strip { to { transform: translateX(-100%); } }

[data-celebrate="1"] { display: inline-block; animation: pop var(--dur-step) ease-out; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.8); } 100% { transform: scale(1); } }

/* On a short screen, step A must show the + button and the gauge together. */
@media (max-height: 600px) {
  .view, .step { gap: 8px; }
  h1 { font-size: 1.25rem; }
  .qty { font-size: 1.6rem; }
  .btn-round { width: 48px; height: 48px; }
  .gauge { margin-top: 8px; padding-top: 8px; }
  .gauge-text { min-height: 0; }
}

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