/* Feuille de style principale (CSS natif, sans étape de build).
   Les couleurs ne sont jamais écrites ici : elles viennent de config/advent.php, servies par /theme.css. */

/* Polices hébergées localement (RGPD : aucun appel à un service externe). Licence SIL OFL 1.1. */
@font-face {
  font-family: 'Bricolage Grotesque';
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  font-stretch: 75% 100%;
  src: url('../fonts/bricolage-grotesque-latin.woff2') format('woff2-variations'), url('../fonts/bricolage-grotesque-latin.woff2') format('woff2');
}
@font-face {
  font-family: 'Figtree';
  font-style: normal;
  font-display: swap;
  font-weight: 300 900;
  src: url('../fonts/figtree-latin.woff2') format('woff2-variations'), url('../fonts/figtree-latin.woff2') format('woff2');
}

:root {
  --shadow: 0 10px 30px rgba(14, 39, 66, .16);
  --f-display: 'Bricolage Grotesque', 'Trebuchet MS', system-ui, sans-serif;
  --f-body: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --shadow: 0 10px 30px rgba(0, 0, 0, .5); }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--outer); color: var(--ink); font-family: var(--f-body); font-size: 16px; line-height: 1.5; }
h1, h2, h3, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.ic { width: 1.25em; height: 1.25em; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.gut {
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.app { max-width: 480px; margin: 0 auto; background: var(--bg); min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; box-shadow: 0 0 0 1px var(--line); }
.app > main { flex: 1; }
.fine { font-size: 13px; color: var(--muted); }

/* Ciel d'hiver (prototype client) */
.sky { position: relative; overflow: hidden; background: linear-gradient(180deg, var(--sky-top), var(--sky-mid) 60%, var(--sky-bot)); color: var(--on-sky); padding-top: 30px; padding-bottom: 104px; }
.sky .gut { position: relative; z-index: 2; }
.logo { position: absolute; z-index: 3; top: 18px; right: max(16px, env(safe-area-inset-right, 0px)); width: 68px; height: auto; filter: drop-shadow(0 1px 4px rgba(8, 30, 56, .35)); }
.sky .kicker, .sky .brand, .sky .sub { text-shadow: 0 1px 3px rgba(8, 30, 56, .3); }
.ridges { position: absolute; left: 0; right: 0; bottom: -1px; width: 100%; height: 110px; z-index: 1; display: block; }
.ridges .r1 { fill: var(--ridge-1); }
.ridges .r2 { fill: var(--ridge-2); }
.ridges .r3 { fill: var(--bg); }
.flake { position: absolute; top: -10px; left: var(--x); width: var(--s); height: var(--s); border-radius: 50%; background: var(--on-sky); opacity: .8; animation: fall var(--t) linear var(--dl) infinite; z-index: 1; }
.flake:nth-of-type(1){--x:11%;--s:2px;--t:7s;--dl:-0.0s;--w:-10px}
.flake:nth-of-type(2){--x:48%;--s:3px;--t:10s;--dl:-1.7s;--w:17px}
.flake:nth-of-type(3){--x:85%;--s:4px;--t:7s;--dl:-3.4s;--w:-24px}
.flake:nth-of-type(4){--x:22%;--s:5px;--t:10s;--dl:-5.1s;--w:31px}
.flake:nth-of-type(5){--x:59%;--s:2px;--t:7s;--dl:-6.8s;--w:-38px}
.flake:nth-of-type(6){--x:96%;--s:3px;--t:10s;--dl:-8.5s;--w:15px}
.flake:nth-of-type(7){--x:33%;--s:4px;--t:7s;--dl:-1.2s;--w:-22px}
.flake:nth-of-type(8){--x:70%;--s:5px;--t:10s;--dl:-2.9s;--w:29px}
.flake:nth-of-type(9){--x:7%;--s:2px;--t:7s;--dl:-4.6s;--w:-36px}
.flake:nth-of-type(10){--x:44%;--s:3px;--t:10s;--dl:-6.3s;--w:13px}
.flake:nth-of-type(11){--x:81%;--s:4px;--t:7s;--dl:-8.0s;--w:-20px}
.flake:nth-of-type(12){--x:18%;--s:5px;--t:10s;--dl:-0.7s;--w:27px}
.flake:nth-of-type(13){--x:55%;--s:2px;--t:7s;--dl:-2.4s;--w:-34px}
.flake:nth-of-type(14){--x:92%;--s:3px;--t:10s;--dl:-4.1s;--w:11px}
.flake:nth-of-type(15){--x:29%;--s:4px;--t:7s;--dl:-5.8s;--w:-18px}
.flake:nth-of-type(16){--x:66%;--s:5px;--t:10s;--dl:-7.5s;--w:25px}
@keyframes fall { to { transform: translate3d(var(--w), 380px, 0); } }
.kicker { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; font-weight: 600; opacity: .9; }
.brand { font-family: var(--f-display); font-weight: 800; font-size: clamp(2.1rem, 9.5vw, 2.9rem); line-height: 1.02; margin-top: 10px; max-width: calc(100% - 80px); text-wrap: balance; letter-spacing: -.01em; }
.sub { margin-top: 12px; max-width: 34ch; opacity: .95; }

/* Cartes et formulaires */
.lift { position: relative; z-index: 3; margin-top: -76px; }
.card { background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); padding: 18px; }
.card h2 { font-family: var(--f-display); font-weight: 800; font-size: 1.35rem; line-height: 1.15; text-wrap: balance; }
.card .lead { margin-top: 6px; color: var(--muted); }
.card .fine { margin-top: 12px; }
.fine a { color: var(--primary); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.field + .field { margin-top: 0; }
.field label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field .opt { font-weight: 400; color: var(--muted); }
.field input { width: 100%; min-height: 52px; border: 2px solid var(--line); border-radius: 14px; background: var(--bg); color: var(--ink); padding: 0 14px; }
.field input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--focus); }
.field input[aria-invalid="true"] { border-color: var(--err); }
.codein { text-align: center; font-size: 1.7rem !important; letter-spacing: .4em; font-variant-numeric: tabular-nums; }
.check { display: grid; grid-template-columns: 24px 1fr; gap: 10px; align-items: start; font-size: 15px; }
.check input { width: 22px; height: 22px; margin: 1px 0 0; accent-color: var(--primary); cursor: pointer; }
.check label { cursor: pointer; }
.check a { color: var(--primary); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.err { min-height: 1.4em; margin: 6px 0 8px; font-size: 13.5px; color: var(--err); font-weight: 600; }
.card .btn.primary { margin-top: 0; }
.note { margin-bottom: 14px; padding: 10px 12px; border-radius: 12px; background: var(--soft); color: var(--ink); font-weight: 600; font-size: 14px; }
.row2 { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 14px; }
.link { background: none; border: 0; padding: 0; color: var(--primary); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; font-size: inherit; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 50px; padding: 0 20px; border-radius: 14px; border: 2px solid transparent; font-weight: 700; margin-top: 14px; }
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn.block { width: 100%; }

/* Calendrier (prototype client) */
.cal { padding-top: 24px; padding-bottom: 28px; }
.sec-h { font-family: var(--f-display); font-weight: 800; font-size: 1.45rem; margin-bottom: 14px; }
.cal-lead { color: var(--muted); margin-bottom: 14px; }
.cal > .fine { margin-bottom: 10px; }
.c0 { --c: var(--door-0); --on: var(--on-door); }
.c1 { --c: var(--door-1); --on: var(--on-door); }
.c2 { --c: var(--door-2); --on: var(--on-door); }
.c3 { --c: var(--door-3); --on: var(--on-door); }
.c4 { --c: var(--door-4); --on: var(--on-gold); }
.grid { position: relative; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; padding: 10px; background: var(--frame); border-radius: 24px; box-shadow: var(--shadow); }
.door { position: relative; display: block; aspect-ratio: 20 / 19; perspective: 700px; border: 0; background: none; padding: 0; overflow: visible; cursor: pointer; -webkit-tap-highlight-color: transparent; color: inherit; }
.door:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 14px; }
.back, .front { position: absolute; inset: 0; border-radius: 14px; display: block; }
.back { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line), inset 0 10px 22px rgba(0, 0, 0, .16); overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 8px 6px 8px 12px; text-align: center; color: var(--ink); }
.back::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 50% 38%, var(--glow) 0, transparent 68%); opacity: .34; }
.back > * { position: relative; }
.back .nm { font-size: 10.5px; overflow-wrap: anywhere; font-weight: 700; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 100%; }
.back .st { font-size: 10.5px; font-weight: 700; color: var(--muted); }
.front { transform-origin: left center; transition: transform .9s cubic-bezier(.3, .7, .2, 1); background-color: var(--c); background-image: var(--ill, none); background-repeat: no-repeat; background-size: cover; background-position: center; color: var(--door-text, var(--on)); text-shadow: 0 0 8px var(--halo, transparent), 0 1px 2px var(--halo, transparent); display: grid; grid-template-rows: 1fr auto 1fr; justify-items: center; align-items: center; padding: 8px; box-shadow: 0 4px 10px rgba(0, 0, 0, .25); }
.front .wd { align-self: start; font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; opacity: .85; }
.front .num { font-family: var(--f-display); font-weight: 800; font-size: clamp(1.6rem, 8vw, 2.2rem); line-height: 1; }
.front .bt { align-self: end; font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; min-height: 1em; }
.door[data-s="open"] .front, .door.is-opening .front { transform: rotateY(-84deg); }
.door[data-s="open"] .front > * { opacity: 0; }
.door[data-s="missed"] .front { filter: grayscale(.85) brightness(.85); opacity: .75; }
.door.shake { animation: shake .4s; }
@keyframes shake { 20% { transform: translateX(-5px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(3px); } }
.door.is-opening .back::before { animation: flash .95s ease-out; }
@keyframes flash { 0% { opacity: 0; } 35% { opacity: 1; transform: scale(1.3); } 100% { opacity: .34; } }
.spark { position: absolute; left: 50%; top: 50%; width: 8px; height: 8px; border-radius: 2px; pointer-events: none; z-index: 5; background: var(--spark, var(--glow)); animation: spark .95s ease-out forwards; }
@keyframes spark { 0% { opacity: 1; transform: translate(-50%, -50%) rotate(0) scale(1); } 100% { opacity: 0; transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) rotate(var(--r)) scale(.4); } }
.logout { margin-top: 22px; text-align: center; }

/* Fiche d'une case */
.scrim { position: fixed; inset: 0; background: rgba(5, 16, 17, .6); opacity: 0; pointer-events: none; transition: opacity .3s; z-index: 30; }
.scrim.on { opacity: 1; pointer-events: auto; }
.sheet { position: fixed; left: 50%; bottom: 0; width: 100%; max-width: 480px; max-height: 92vh; max-height: 92dvh; overflow: auto; transform: translate(-50%, 105%); transition: transform .5s cubic-bezier(.2, .9, .2, 1); background: var(--surface); border-radius: 24px 24px 0 0; z-index: 31; overscroll-behavior: contain; }
.sheet.on { transform: translate(-50%, 0); }
.sheet[hidden] { display: none; }
.sh-head { position: relative; overflow: hidden; background: var(--c); color: var(--on); padding: 24px max(20px, env(safe-area-inset-left, 0px)) 24px; }
.sh-num { position: absolute; right: -4px; bottom: -40px; font-family: var(--f-display); font-weight: 800; font-size: 10rem; line-height: 1; opacity: .15; }
.sh-head.fresh::after { content: ""; position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .4) 50%, transparent 70%); transform: translateX(-100%); animation: shine 1.3s .25s ease-out forwards; }
@keyframes shine { to { transform: translateX(100%); } }
.close { position: absolute; top: 12px; right: 12px; width: 42px; height: 42px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .22); color: inherit; display: grid; place-items: center; z-index: 2; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; }
.chip.onhead { background: rgba(255, 255, 255, .22); color: inherit; }
.sh-merchant { font-family: var(--f-display); font-weight: 800; font-size: 1.75rem; line-height: 1.1; margin-top: 12px; max-width: 82%; text-wrap: balance; }
.sh-cat { margin-top: 6px; opacity: .92; font-size: 14.5px; }
.sh-body { padding: 20px max(20px, env(safe-area-inset-left, 0px)) calc(26px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 14px; }
.valuebox { display: flex; align-items: center; gap: 14px; background: var(--soft); border-radius: 18px; padding: 14px; }
.val { font-family: var(--f-display); font-weight: 800; font-size: 2.7rem; line-height: 1; color: var(--c); }
.vt { font-weight: 600; line-height: 1.3; margin-top: 2px; }

/* Fiche : contenu selon le type */
.sh-head.has-img { color: var(--on-sky); min-height: 190px; display: flex; flex-direction: column; justify-content: flex-end; align-items: flex-start; }
.sh-head.has-img::before { content: ""; position: absolute; inset: 0; z-index: 1; background: linear-gradient(180deg, rgba(8, 22, 40, .05) 20%, rgba(8, 22, 40, .78) 100%); }
.sh-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.sh-head.has-img > *:not(.sh-img) { position: relative; z-index: 2; }
.sh-head.has-img .close { position: absolute; background: rgba(8, 22, 40, .55); }
.sh-head.has-img .chip.onhead { position: absolute; top: 14px; left: max(20px, env(safe-area-inset-left, 0px)); background: rgba(8, 22, 40, .55); }
.sh-head.has-img .sh-merchant { text-shadow: 0 1px 8px rgba(0, 0, 0, .45); }
.sh-head.has-img .sh-cat { text-shadow: 0 1px 6px rgba(0, 0, 0, .5); }
.chip .ic { width: 1em; height: 1em; }
.bub { flex: none; width: 54px; height: 54px; border-radius: 15px; background: var(--c); color: var(--on); display: grid; place-items: center; font-size: 24px; }
.val.sm { font-size: 1.5rem; }
.txt { margin: 0; }
.facts { display: grid; gap: 12px; padding-top: 16px; border-top: 1px solid var(--line); margin: 0; }
.facts dt { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }
.note { font-size: 13.5px; color: var(--muted); text-align: center; }
.state { display: flex; align-items: center; gap: 12px; background: var(--soft); border-radius: 14px; padding: 14px; font-weight: 600; }
.state .ic { color: var(--ok); font-size: 24px; }
.state.mute .ic { color: var(--muted); }
.sh-body .btn { margin-top: 0; }

/* Écran à montrer au commerçant */
.show { position: fixed; inset: 0; z-index: 40; background: linear-gradient(170deg, var(--door-0), var(--sky-top)); color: var(--on-sky); display: flex; align-items: center; justify-content: center; padding: calc(24px + env(safe-area-inset-top, 0px)) max(20px, env(safe-area-inset-left, 0px)) calc(24px + env(safe-area-inset-bottom, 0px)); overflow: auto; }
.show[hidden] { display: none; }
.show .in { width: 100%; max-width: 420px; text-align: center; display: grid; gap: 14px; justify-items: center; }
.show .sh-merchant { max-width: 100%; margin-top: 0; }
.show .fine { color: var(--on-sky); opacity: .8; }
.show .show-error { opacity: 1; font-weight: 700; color: var(--glow); min-height: 1.2em; }
.ovvalue { font-family: var(--f-display); font-weight: 800; font-size: 3.6rem; line-height: 1; color: var(--glow); }
.band { width: 100%; height: 14px; border-radius: 7px; background: repeating-linear-gradient(120deg, var(--glow) 0 18px, transparent 18px 36px); background-size: 36px 100%; animation: slide 1s linear infinite; opacity: .9; }
@keyframes slide { to { background-position: 36px 0; } }
.clock { font-variant-numeric: tabular-nums; font-family: var(--f-display); font-weight: 800; font-size: 3.2rem; line-height: 1; }
.hold { position: relative; overflow: hidden; width: 100%; min-height: 62px; border-radius: 16px; border: 2px solid var(--on-sky); background: transparent; color: var(--on-sky); font-weight: 700; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; margin-top: 6px; }
.hold::before { content: ""; position: absolute; inset: 0; background: rgba(255, 255, 255, .34); transform: scaleX(var(--p, 0)); transform-origin: left; }
.hold span { position: relative; }
.btn.light { border-color: rgba(255, 255, 255, .5); color: var(--on-sky); }
.okmark { width: 96px; height: 96px; fill: none; stroke: var(--on-sky); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.okmark circle { stroke-dasharray: 145; stroke-dashoffset: 145; animation: draw .6s ease-out forwards; }
.okmark path { stroke-dasharray: 40; stroke-dashoffset: 40; animation: draw .4s .45s ease-out forwards; stroke: var(--glow); }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* Barre d'onglets */
.tabs { position: sticky; bottom: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line); display: grid; grid-template-columns: 1fr 1fr; padding-bottom: env(safe-area-inset-bottom, 0px); }
.tab { position: relative; min-height: 60px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12.5px; font-weight: 600; color: var(--muted); text-decoration: none; }
.tab .ic { font-size: 21px; }
.tab[aria-current="page"] { color: var(--primary); }
.tab[aria-current="page"]::before { content: ""; position: absolute; top: -1px; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: currentColor; }
.badge { position: absolute; top: 8px; left: calc(50% + 10px); min-width: 18px; height: 18px; border-radius: 9px; background: var(--badge); color: var(--on-primary); font-size: 11px; font-weight: 700; display: grid; place-items: center; padding: 0 5px; }

/* Mes offres */
.sec { padding-top: 26px; padding-bottom: 28px; }
.pg { font-family: var(--f-display); font-weight: 800; font-size: 2rem; line-height: 1.1; }
.muted { color: var(--muted); }
.gt { font-size: 13px; letter-spacing: .1em; text-transform: uppercase; font-weight: 700; color: var(--muted); margin: 24px 0 10px; }
.list { display: grid; gap: 10px; }
.item { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 12px; align-items: center; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px; color: var(--ink); text-decoration: none; }
.item .n { width: 48px; height: 58px; border-radius: 10px; background: var(--c); color: var(--on); display: grid; place-items: center; font-family: var(--f-display); font-weight: 800; font-size: 1.5rem; }
.item .tx { display: grid; gap: 2px; min-width: 0; }
.item .tx b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .tx > span:not(.chip) { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .chip { justify-self: start; background: var(--soft); color: var(--ink); margin-top: 3px; font-size: 12px; padding: 3px 10px; }
.chip.ok { color: var(--ok); } .chip.warn { color: var(--warn); } .chip.mute { color: var(--muted); }
.empty { margin-top: 24px; background: var(--surface); border: 1px dashed var(--line); border-radius: 16px; padding: 22px; text-align: center; display: grid; gap: 12px; justify-items: center; }

/* Messages courts */
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 16px); background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 16px; font-size: 14px; font-weight: 600; opacity: 0; pointer-events: none; transition: opacity .3s, transform .3s; z-index: 50; width: max-content; max-width: min(92vw, 420px); text-align: center; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast:empty { display: none; }

/* Ajouter à l'écran d'accueil */
.install { margin-top: 16px; display: grid; gap: 12px; }
.install[hidden], .install [hidden] { display: none; }
.install-head { display: grid; grid-template-columns: 48px 1fr; gap: 12px; align-items: center; }
.install-head img { width: 48px; height: 48px; border-radius: 12px; }
.install h2 { font-size: 1.1rem; }
.install .lead { margin-top: 2px; font-size: 14.5px; }
.steps { margin: 0; padding-left: 1.3em; display: grid; gap: 6px; list-style: decimal; }
.install .btn { margin-top: 0; }
.install-dismiss { justify-self: start; font-size: 14px; }

/* Comment ça marche */
.how { display: grid; gap: 14px; padding-top: 24px; padding-bottom: 12px; }
.how li { display: grid; grid-template-columns: 40px 1fr; gap: 12px; align-items: start; }
.how .bub { width: 40px; height: 40px; border-radius: 12px; background: var(--soft); color: var(--primary); display: grid; place-items: center; font-size: 20px; }
.how b { display: block; }
.how span { color: var(--muted); font-size: 14.5px; }

.foot { padding-top: 24px; padding-bottom: 24px; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .flake, .spark { display: none; }
  .band { animation: none; }
  .front { transition: opacity .3s; }
  .door[data-s="open"] .front, .door.is-opening .front { transform: none; opacity: 0; }
}
