/* App client /commander/ : base commune (variante C « Photo », thème nuit). Jetons repris de DESIGN.md (démo) et de
   la charte du site. Aucun style en ligne dans l'app : tout passe par ces classes. Polices locales (/fonts/fonts.css). */

:root {
    --navy: #171D24;
    --navy-2: #1f2630;
    --navy-3: #283039;
    --cream: #EFEDE7;
    --cream-2: #F7F6F2;
    --cream-3: #E3E0D8;
    --cream-muted: #d8d4cb;
    --caramel: #B38662;
    --caramel-bright: #CCA077;
    --caramel-deep: #8a5f33;
    --terracotta: #B0592B;
    --terracotta-deep: #9b4c23;
    --terracotta-wash: #f3dfd3;
    --terracotta-ink: #7d3713;
    --ink: #171D24;
    --ink-2: #48505c;
    --ink-on-navy-2: #b8b3a9;
    --rule-light: #d9d5cc;
    --rule-dark: #333c47;
    --paper: #FFFFFF;
    --r: 8px;
    --r-card: 12px;
    --pill: 999px;
    --font: 'Barlow', system-ui, sans-serif;
    --font-cond: 'Barlow Condensed', 'Barlow', sans-serif;
    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --gutter: 16px;
    --nav-h: 58px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --bottom-space: calc(var(--nav-h) + var(--safe-bottom));
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--navy); touch-action: manipulation; }
/* Double toucher sans zoom (plusieurs touches rapides sur « + » zoomaient l'app) ; le pincement reste permis. */
button, a, input, select, textarea, label, [role="button"], [role="switch"] { touch-action: manipulation; }
body {
    margin: 0; min-height: 100vh; background: var(--navy); color: var(--cream);
    font-family: var(--font); font-size: 16px; line-height: 1.5; font-variant-numeric: tabular-nums;
    padding-bottom: var(--bottom-space);
}
body.no-nav { --bottom-space: var(--safe-bottom); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; font-family: var(--font-cond); font-weight: 600; line-height: 1.1; letter-spacing: 0.005em; }
p { margin: 0; }
a { color: var(--caramel-bright); text-underline-offset: 3px; }
.cond { font-family: var(--font-cond); }
.ic { flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
::selection { background: var(--caramel); color: var(--navy); }
:focus-visible { outline: 2px solid var(--caramel-bright); outline-offset: 2px; border-radius: 4px; }
#app:focus { outline: none; }

.skip { position: absolute; left: 8px; top: -60px; z-index: 100; display: inline-flex; align-items: center; min-height: 44px; padding: 0 1rem; border-radius: var(--r); background: var(--cream); color: var(--navy); font-weight: 600; }
.skip:focus { top: 8px; }

.page { max-width: 1120px; margin: 0 auto; padding: 0 var(--gutter) 1.5rem; }
.page-narrow { max-width: 640px; margin: 0 auto; padding: 0 var(--gutter) 1.5rem; }
.page-head { display: flex; align-items: center; gap: 8px; min-height: 60px; padding: max(12px, env(safe-area-inset-top)) 0 8px; }
.page-head .icon-btn { margin-left: -12px; }
.page-head h1 { font-size: 1.5rem; }
.page-head .tag { margin-left: auto; }

/* Boutons : 44px au moins partout, 52 à 56px pour l'action principale (règle du pouce). */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
    min-height: 44px; padding: 0.6rem 1.1rem; border-radius: var(--pill); border: 1px solid transparent;
    font-weight: 700; text-decoration: none; white-space: nowrap; background: none;
    transition: background-color 160ms var(--ease), border-color 160ms var(--ease), transform 120ms var(--ease);
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { cursor: not-allowed; opacity: 0.45; }
.btn-primary { background: var(--caramel); color: var(--navy); }
.btn-primary:hover:not(:disabled) { background: var(--caramel-bright); }
.btn-ghost { border-color: var(--rule-dark); color: var(--cream); }
.btn-ghost:hover:not(:disabled) { border-color: var(--caramel); }
.btn-alert { background: var(--terracotta); color: var(--paper); }
.btn-alert:hover:not(:disabled) { background: var(--terracotta-deep); }
.btn-lg { min-height: 54px; font-size: 1rem; padding: 0.75rem 1.4rem; }
.btn-block { width: 100%; }
.icon-btn {
    width: 44px; height: 44px; flex: none; display: inline-flex; align-items: center; justify-content: center;
    border-radius: var(--pill); border: 0; background: transparent; color: var(--cream); text-decoration: none;
}
.icon-btn:hover { background: var(--navy-3); }
.link-btn {
    display: inline-flex; align-items: center; justify-self: start; min-height: 44px; border: 0; background: none; padding: 0;
    color: var(--cream-muted); font-weight: 600; text-decoration: underline; text-underline-offset: 3px;
}
.tag { display: inline-flex; align-items: center; min-height: 30px; padding: 0 12px; border-radius: var(--pill); background: var(--navy-3); color: var(--cream-muted); font-size: 0.8125rem; font-weight: 600; }

/* Messages */
.notice { display: flex; gap: 0.6rem; align-items: flex-start; padding: 0.75rem 0.9rem; border-radius: var(--r); background: var(--navy-2); border: 1px solid var(--rule-dark); color: var(--cream-muted); font-size: 0.9375rem; }
.notice .ic { margin-top: 0.15rem; color: var(--caramel-bright); }
.notice.is-alert { background: rgba(176, 89, 43, 0.16); border-color: rgba(176, 89, 43, 0.5); color: #f3d6c6; }
.notice.is-alert .ic { color: #e8a37f; }
.notice a { color: inherit; font-weight: 600; }
.notice-body { display: grid; gap: 8px; justify-items: start; }
/* Action d'un message (« Appeler le … » pendant la pause) : pilule fantôme de 44 px dans la couleur du message. */
.notice-action {
    display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: var(--pill);
    border: 1px solid currentColor; text-decoration: none; font-weight: 700; white-space: nowrap;
}
.notice-action:hover { background: rgba(243, 214, 198, 0.12); }
.error-text { color: #f0b493; font-size: 0.9375rem; font-weight: 600; }
.hint { color: var(--ink-on-navy-2); font-size: 0.875rem; }
.loading { padding: 3rem var(--gutter); text-align: center; color: var(--ink-on-navy-2); }
.state-screen { max-width: 520px; margin: 0 auto; padding: 4rem var(--gutter) 2rem; display: grid; gap: 1rem; justify-items: center; text-align: center; }
.state-screen h1 { font-size: 1.9rem; }
.state-screen p { color: var(--cream-muted); }

/* Barre de navigation basse (maquettes C1, C4) */
.app-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; justify-content: center;
    background: var(--navy-2); border-top: 1px solid var(--rule-dark); padding: 4px 12px var(--safe-bottom);
}
.app-nav[hidden] { display: none; }
.app-nav-inner { display: flex; width: 100%; max-width: 560px; }
.nav-link {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    min-height: 52px; color: var(--ink-on-navy-2); font-size: 0.75rem; font-weight: 600; text-decoration: none; position: relative;
}
.nav-link[aria-current="page"] { color: var(--cream); }
.nav-badge { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--pill); background: var(--caramel); color: var(--navy); font-size: 0.6875rem; font-weight: 700; display: grid; place-items: center; }

/* Barre panier flottante (C1) : pilule caramel, total dans une pastille nuit, au-dessus de la navigation. */
.cart-bar {
    position: fixed; left: var(--gutter); right: var(--gutter); bottom: calc(var(--bottom-space) + 12px); z-index: 30;
    max-width: 560px; margin: 0 auto; height: 54px; border-radius: var(--pill); background: var(--caramel); color: var(--navy);
    display: flex; align-items: center; justify-content: space-between; padding: 0 8px 0 18px; text-decoration: none; font-weight: 700;
    box-shadow: 0 8px 24px rgba(10, 13, 17, 0.35);
}
.cart-bar-total { font-family: var(--font-cond); font-size: 1.2rem; background: var(--navy); color: var(--cream); height: 40px; padding: 0 14px; border-radius: var(--pill); display: flex; align-items: center; }
.has-cart-bar { padding-bottom: 84px; }

/* Barre d'action basse des écrans plat, panier et commande */
.action-bar { position: fixed; left: 0; right: 0; bottom: var(--bottom-space); z-index: 30; background: var(--navy); border-top: 1px solid var(--rule-dark); padding: 12px var(--gutter); }
.action-bar-inner { max-width: 640px; margin: 0 auto; display: grid; gap: 8px; }
.action-sum { display: flex; justify-content: space-between; align-items: baseline; color: var(--cream-muted); font-size: 0.9375rem; }
.action-sum strong { font-family: var(--font-cond); font-size: 1.4rem; color: var(--cream); }
.action-legal { font-size: 0.75rem; line-height: 1.4; color: var(--ink-on-navy-2); text-align: center; }
.has-action-bar { padding-bottom: 170px; }

/* Bandeau hors connexion et notifications brèves */
.offline-banner { position: sticky; top: 0; z-index: 60; padding: 0.5rem var(--gutter); background: var(--navy-3); color: var(--cream); font-size: 0.875rem; font-weight: 600; text-align: center; }
.offline-banner[hidden] { display: none; }
.toasts { position: fixed; left: var(--gutter); right: var(--gutter); top: max(12px, env(safe-area-inset-top)); z-index: 80; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { max-width: 480px; padding: 0.75rem 0.9rem; border-radius: var(--r); background: var(--cream); color: var(--navy); font-weight: 600; box-shadow: 0 8px 24px rgba(10, 13, 17, 0.4); }
.toast-error { background: var(--terracotta); color: var(--paper); }

/* Tirer pour actualiser (app installée, pull-refresh.mjs) : la pastille descend pendant le glissé, se retourne au seuil,
   tourne pendant le rechargement. */
.pull-refresh {
    position: fixed; left: 50%; top: max(12px, env(safe-area-inset-top)); z-index: 85; width: 44px; height: 44px; margin-left: -22px;
    border-radius: var(--pill); border: 1px solid var(--rule-dark); background: var(--navy-2); color: var(--caramel-bright);
    display: grid; place-items: center; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35); pointer-events: none;
    opacity: 0; transform: translateY(-72px); transition: transform 180ms var(--ease), opacity 180ms var(--ease);
}
.pull-refresh .ic { transition: transform 180ms var(--ease); }
.pull-refresh.is-pulling, .pull-refresh.is-refreshing { opacity: 1; transform: translateY(0); }
.pull-refresh.is-ready { background: var(--caramel); border-color: var(--caramel); color: var(--navy); }
.pull-refresh.is-ready .ic { transform: rotate(180deg); }
.pull-refresh.is-refreshing .ic { animation: pull-spin 800ms linear infinite; }
@keyframes pull-spin { to { transform: rotate(360deg); } }

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