:root {
  --bg: #f4f6f5;
  --surface: #ffffff;
  --text: #17211c;
  --muted: #5b6b63;
  --line: #dde4e0;
  --brand: #0b6b46;
  --brand-ink: #ffffff;
  --danger: #b3261e;
  --ok-bg: #e2f4ea; --ok-fg: #0b5a3a;
  --warn-bg: #fff1d6; --warn-fg: #7a4b00;
  --bad-bg: #fde6e4; --bad-fg: #8c1d18;
  --neutral-bg: #e9edeb; --neutral-fg: #3f4d46;
  --radius: 12px;
  --focus: #1a73e8;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1613; --surface: #17211c; --text: #e8efeb; --muted: #9db0a6; --line: #2a3a32;
    --brand: #2fb67c; --brand-ink: #06130d; --danger: #ff8a80;
    --ok-bg: #12382a; --ok-fg: #8fe0b7;
    --warn-bg: #3b2d0f; --warn-fg: #f3cf85;
    --bad-bg: #402018; --bad-fg: #ffb4a8;
    --neutral-bg: #26332c; --neutral-fg: #c3d1c9;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.05rem; margin: 0; }
p { margin: 0.25rem 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.muted { color: var(--muted); }
.noscript { padding: 1rem; }
.center { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.login { width: 100%; max-width: 380px; }
.login h1 { text-align: center; color: var(--brand); margin-bottom: 0.25rem; }
.lead { text-align: center; color: var(--muted); margin-bottom: 1rem; }

label { display: block; font-weight: 600; margin: 0.5rem 0 0.25rem; }
input, select {
  width: 100%; font: inherit; color: inherit; background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 12px;
}
select { width: auto; padding: 8px; }
input#code { letter-spacing: 0.4em; text-align: center; font-size: 1.4rem; }
.hint { color: var(--muted); font-size: 0.9rem; }
.form-error, .inline-error { color: var(--danger); font-size: 0.9rem; min-height: 1.2em; }

.btn {
  font: inherit; font-weight: 600; cursor: pointer; border-radius: 8px; padding: 10px 14px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); min-height: 44px;
}
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-quiet { background: transparent; border-color: transparent; color: var(--muted); }
.btn-block { width: 100%; margin-top: 0.75rem; }
.row-between { display: flex; justify-content: space-between; gap: 8px; margin-top: 0.75rem; flex-wrap: wrap; }

.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 2; }
.topbar-inner { max-width: 960px; margin: 0 auto; padding: 8px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.brand { font-weight: 800; color: var(--brand); font-size: 1.2rem; }
.topbar nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.topbar nav a { padding: 8px 12px; border-radius: 8px; text-decoration: none; color: var(--text); }
.topbar nav a.active { background: var(--ok-bg); color: var(--ok-fg); font-weight: 700; }
.who { display: flex; align-items: center; gap: 4px; }
.page { max-width: 960px; margin: 0 auto; padding: 16px; }

.tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; }
.tab { font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 999px; padding: 8px 14px; white-space: nowrap; min-height: 40px; }
.tab.active { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); font-weight: 700; }

.list { display: grid; gap: 12px; }
.item-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.sub { margin-top: 8px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: flex-start; }
.confirm { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.renew { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.more { margin-top: 12px; text-align: center; }
.status { color: var(--muted); }
.card + .card, .card + p, p + .card { margin-top: 12px; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.8rem; font-weight: 700; white-space: nowrap; }
.badge-ok { background: var(--ok-bg); color: var(--ok-fg); }
.badge-warn { background: var(--warn-bg); color: var(--warn-fg); }
.badge-bad { background: var(--bad-bg); color: var(--bad-fg); }
.badge-neutral { background: var(--neutral-bg); color: var(--neutral-fg); }

.notice { background: var(--warn-bg); color: var(--warn-fg); border-radius: 8px; padding: 10px 12px; margin: 10px 0; }
.notice-bad { background: var(--bad-bg); color: var(--bad-fg); }


@media (max-width: 520px) {
  .item-head { flex-direction: column; }
  .products th:nth-child(4), .products td:nth-child(4) { display: none; }
}

/* Formulaires et fiches de gestion */
.field { margin-top: 8px; }
.field-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 0 12px; }
.form { margin-top: 8px; }
.form .btn { margin-top: 8px; }
h3 { font-size: 0.95rem; margin: 16px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.disclosure { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 8px; }
.disclosure > summary { cursor: pointer; font-weight: 600; color: var(--brand); padding: 6px 0; min-height: 36px; }
.products-list { display: grid; gap: 10px; }
.product { border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.product .actions { margin-top: 6px; }

/* Commandes */
.order-lines { list-style: none; padding: 0; margin: 10px 0 6px; display: grid; gap: 4px; }
.order-lines li { display: flex; justify-content: space-between; gap: 12px; }
.order-total, .order-address { margin-top: 6px; }
.payment-line { margin-top: 8px; }
.payment { margin-top: 10px; }

/* Application client */
.login-wrap { display: grid; place-items: start center; padding-top: 16px; }
.brand { text-decoration: none; }
.shop-card { display: block; text-decoration: none; color: inherit; }
.shop-card:hover { border-color: var(--brand); }
.item-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.qty { display: inline-flex; align-items: center; gap: 10px; }
.qty .btn { min-width: 44px; padding: 8px 12px; }
.count { display: inline-block; min-width: 1.4em; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--brand); color: var(--brand-ink); font-size: 0.8rem; font-weight: 700; text-align: center; }
.count[hidden] { display: none; }
.cart-bar { position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 30%); margin-top: 12px; }
.cart-bar .btn { text-align: center; text-decoration: none; display: block; }
a.btn { text-decoration: none; display: inline-block; }
.switch-notice .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.choices { display: grid; gap: 8px; margin: 8px 0; }
.choice { display: flex; gap: 10px; align-items: flex-start; font-weight: normal; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; }
.choice input { width: auto; margin-top: 4px; }
.choice .hint { display: block; }
.form h2 { margin-top: 16px; }
.hint-big { font-size: 1.05rem; margin: 10px 0; }
.code-card { text-align: center; margin: 12px 0; }
.code { font-size: 2.4rem; font-weight: 800; letter-spacing: 0.3em; margin: 4px 0; color: var(--brand); }
.pay { margin: 12px 0; }
.pay-lines { padding-left: 1.1rem; }
.timeline { padding-left: 1.2rem; margin: 6px 0 0; }
.order-lines { list-style: none; padding: 0; margin: 10px 0 6px; display: grid; gap: 4px; }
.order-lines li { display: flex; justify-content: space-between; gap: 12px; }
.order-total { margin-top: 6px; }
.card + .card, .notice + .card, .hint-big + .card { margin-top: 12px; }
a { color: var(--brand); }
.topbar nav a { white-space: nowrap; color: var(--text); }
@media (max-width: 640px) {
  .topbar-inner { justify-content: space-between; gap: 4px 8px; }
  .topbar nav { order: 3; flex-basis: 100%; justify-content: space-between; }
  .topbar nav a { padding: 8px 10px; font-size: 0.95rem; }
}

/* Suivi en direct de la livraison */
.track-eta { font-size: 1.3rem; font-weight: 700; margin: 4px 0; }
.track-warn { color: var(--warn-fg); }

/* Radar de la livraison */
.radar-box { margin: 8px auto 4px; max-width: 320px; }
.radar-box[hidden] { display: none; }
.radar { display: block; width: 100%; height: auto; }
.radar-bg { fill: var(--surface); stroke: var(--line); stroke-width: 1; }
.radar-ring { fill: none; stroke: var(--line); stroke-width: 0.8; stroke-dasharray: 2 3; }
.radar-axis { stroke: var(--line); stroke-width: 0.6; }
.radar-ring-label, .radar-north, .radar-home-label { fill: var(--muted); font-size: 7px; font-family: system-ui, sans-serif; }
.radar-home-label { fill: var(--text); font-weight: 700; font-size: 8px; }
.radar-sweep-beam { fill: var(--brand); opacity: 0.14; }
.radar-sweep { transform-origin: 100px 100px; animation: radar-spin 4s linear infinite; }
.radar-trail { fill: none; stroke: var(--brand); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; opacity: 0.55; }
.radar-trail-dot { fill: var(--brand); }
.radar-home { fill: var(--text); }
.radar-courier { fill: var(--brand); stroke: var(--surface); stroke-width: 1.5; }
.radar-pulse { fill: none; stroke: var(--brand); stroke-width: 1.2; transform-box: fill-box; transform-origin: center; animation: radar-pulse 2s ease-out infinite; }
.radar-caption { text-align: center; margin: 4px 0 8px; font-weight: 600; }
@keyframes radar-spin { to { transform: rotate(360deg); } }
@keyframes radar-pulse { from { transform: scale(1); opacity: 0.9; } to { transform: scale(3.2); opacity: 0; } }
@media (prefers-reduced-motion: reduce) {
  .radar-sweep, .radar-pulse { animation: none; }
}

/* ==========================================================================
   Interface animée : photos, cartes, transitions.
   Règles : on n'anime que `transform` et `opacity` (fluide même sur un téléphone modeste),
   et tout s'arrête pour qui a demandé « réduire les animations ».
   ========================================================================== */
:root {
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --shadow: 0 1px 2px rgba(16, 24, 20, 0.06), 0 8px 24px rgba(16, 24, 20, 0.08);
  --shadow-up: 0 2px 4px rgba(16, 24, 20, 0.08), 0 14px 32px rgba(16, 24, 20, 0.14);
}
.topbar { backdrop-filter: saturate(1.4) blur(10px); background: color-mix(in srgb, var(--surface) 88%, transparent); }
.card { border-radius: 16px; box-shadow: var(--shadow); }
.btn { transition: transform 0.12s var(--ease), background-color 0.2s, border-color 0.2s, opacity 0.2s; }
.btn:active:not(:disabled) { transform: scale(0.96); }
.tab { transition: background-color 0.2s, color 0.2s, border-color 0.2s, transform 0.12s var(--ease); }
.tab:active { transform: scale(0.95); }
.tab.active { box-shadow: 0 4px 12px color-mix(in srgb, var(--brand) 35%, transparent); }

/* Transition entre écrans */
.view-enter { animation: view-in 0.35s var(--ease); }
@keyframes view-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* Apparition en cascade (délai = --i × 60 ms, réglé par le script) */
.reveal { opacity: 0; transform: translateY(16px); animation: reveal 0.5s var(--ease) forwards; animation-delay: calc(var(--i, 0) * 60ms); }
@keyframes reveal { to { opacity: 1; transform: none; } }

/* Photo : un fond coloré avec l'initiale, remplacé en fondu par la vraie image quand elle est chargée */
.media { position: relative; overflow: hidden; background: var(--neutral-bg); }
.tone-0 { background: linear-gradient(135deg, #0b6b46, #36c28a); }
.tone-1 { background: linear-gradient(135deg, #c2561b, #f2a65a); }
.tone-2 { background: linear-gradient(135deg, #3b5bdb, #74a0ff); }
.tone-3 { background: linear-gradient(135deg, #a1306b, #f06ca8); }
.tone-4 { background: linear-gradient(135deg, #7a5a00, #e8c04a); }
.tone-5 { background: linear-gradient(135deg, #1b7a8c, #62d0d9); }
.media-initial { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: clamp(1.6rem, 7vw, 3rem); color: rgba(255, 255, 255, 0.9); text-shadow: 0 2px 8px rgba(0, 0, 0, 0.18); transition: opacity 0.4s; }
.media-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transform: scale(1.06); transition: opacity 0.5s var(--ease), transform 0.9s var(--ease); }
.media.has-image .media-img { opacity: 1; transform: none; }
.media.has-image .media-initial { opacity: 0; }

/* Bandeau d'accueil */
.hero { position: relative; overflow: hidden; border-radius: 22px; padding: 26px 20px; margin-bottom: 18px; color: #fff; background: linear-gradient(120deg, #0b6b46, #14935f 45%, #e69a2e); background-size: 220% 220%; animation: hero-flow 14s ease-in-out infinite; }
.hero::before, .hero::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, 0.14); animation: hero-float 9s ease-in-out infinite; }
.hero::before { width: 140px; height: 140px; right: -30px; top: -40px; }
.hero::after { width: 90px; height: 90px; right: 70px; bottom: -36px; animation-delay: -4s; }
.hero h1 { color: #fff; margin: 0 0 6px; font-size: clamp(1.5rem, 6vw, 2rem); position: relative; }
.hero-sub { margin: 0; opacity: 0.92; position: relative; max-width: 28rem; }
@keyframes hero-flow { 0%, 100% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } }
@keyframes hero-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(14px); } }

/* Cartes des boutiques */
.shop-list { gap: 16px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.shop-card { display: grid; grid-template-columns: 1fr; padding: 0; overflow: hidden; transition: transform 0.28s var(--ease), box-shadow 0.28s var(--ease); }
.shop-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-up); }
.shop-card:active { transform: scale(0.98); }
.shop-cover { grid-row: 1; grid-column: 1; aspect-ratio: 16 / 9; width: 100%; }
.shop-card:hover .media-img { transform: scale(1.05); }
.shop-logo { grid-row: 1; grid-column: 1; align-self: end; justify-self: start; z-index: 2; width: 56px; height: 56px; margin: 0 0 -26px 16px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: var(--shadow); }
.shop-logo .media-initial { font-size: 1.4rem; }
.shop-body { grid-row: 2; grid-column: 1; padding: 14px 16px 16px; position: relative; }
.shop-logo ~ .shop-body { padding-top: 34px; }
.shop-body h2 { font-size: 1.15rem; margin-bottom: 2px; }
.open-pill { position: absolute; top: 14px; right: 14px; display: inline-flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 700; color: var(--ok-fg); background: var(--ok-bg); border-radius: 999px; padding: 3px 10px; }
.open-pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--brand); animation: pulse-dot 1.8s ease-out infinite; }
@keyframes pulse-dot { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--brand) 60%, transparent); } 100% { box-shadow: 0 0 0 8px transparent; } }

/* Chargement : des formes grises qui brillent */
.skeleton { pointer-events: none; }
.skeleton .media, .skeleton-line { background: linear-gradient(100deg, var(--neutral-bg) 30%, var(--surface) 50%, var(--neutral-bg) 70%); background-size: 220% 100%; animation: shimmer 1.3s linear infinite; }
.skeleton-line { height: 14px; border-radius: 7px; margin: 8px 0; width: 70%; }
.skeleton-line.short { width: 40%; }
@keyframes shimmer { from { background-position: 220% 0; } to { background-position: -220% 0; } }

/* Page d'une boutique : grande couverture */
.shop-hero { position: relative; overflow: hidden; border-radius: 22px; aspect-ratio: 2 / 1; min-height: 190px; max-height: 320px; margin-bottom: 18px; color: #fff; box-shadow: var(--shadow-up); animation: hero-in 0.6s var(--ease); }
@keyframes hero-in { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: none; } }
.hero-cover { position: absolute; inset: 0; }
.hero-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0, 0, 0, 0.38), rgba(0, 0, 0, 0) 38%, rgba(0, 0, 0, 0.68)); }
.hero-back { position: absolute; top: 12px; left: 12px; z-index: 2; color: #fff; text-decoration: none; background: rgba(0, 0, 0, 0.42); backdrop-filter: blur(6px); padding: 8px 14px; border-radius: 999px; font-weight: 600; }
.hero-info { position: absolute; left: 16px; right: 16px; bottom: 14px; z-index: 2; display: flex; gap: 12px; align-items: center; }
.hero-info h1 { color: #fff; margin: 0; font-size: clamp(1.3rem, 5vw, 1.9rem); text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5); }
.hero-info p { margin: 0; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5); }
.hero-logo { flex: none; width: 64px; height: 64px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35); }

/* Articles : de grandes photos sur deux colonnes (une seule sur très petit écran) */
.item-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 640px) { .item-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; } }
@media (max-width: 340px) { .item-grid { grid-template-columns: 1fr; } }
.item-card { display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; padding: 0; overflow: hidden; gap: 0; }
.item-card + .item-card { margin-top: 0; }
.item-photo { width: 100%; aspect-ratio: 4 / 3; }
.item-photo-btn { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; transition: transform 0.2s var(--ease); }
.item-photo-btn:active { transform: scale(0.98); }
.item-photo-btn:hover .media-img { transform: scale(1.05); }
.item-body { padding: 10px 12px 4px; flex: 1; }
.item-body h2 { font-size: 1rem; line-height: 1.25; }
.item-desc { font-size: 0.85rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item-price { margin-top: 4px; font-weight: 800; color: var(--brand); }
.item-controls { padding: 8px 12px 12px; display: flex; justify-content: center; }
.item-controls .add-btn { width: 100%; }
.item-controls .qty { width: 100%; justify-content: space-between; }
.item-card.is-out .item-photo { filter: grayscale(1); opacity: 0.7; }
.qty strong { min-width: 1.6em; text-align: center; display: inline-block; }
.qty strong.bump { animation: bump 0.32s var(--ease); }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.5); color: var(--brand); } 100% { transform: scale(1); } }

/* Barre du panier : monte du bas de l'écran */
.cart-bar { z-index: 3; }
.cart-bar .btn { box-shadow: 0 8px 24px color-mix(in srgb, var(--brand) 45%, transparent); }
.cart-bar.enter { animation: bar-in 0.45s var(--ease); }
@keyframes bar-in { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: none; } }

/* Photo en grand */
dialog.lightbox { border: 0; padding: 0; border-radius: 22px; width: min(92vw, 640px); max-height: 90vh; overflow: auto; background: var(--surface); color: var(--text); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5); animation: lightbox-in 0.38s var(--ease); }
dialog.lightbox::backdrop { background: rgba(8, 14, 11, 0.74); backdrop-filter: blur(5px); animation: fade-in 0.3s ease; }
.lightbox-figure { margin: 0; }
.lightbox-img { display: block; width: 100%; max-height: 62vh; object-fit: cover; }
.lightbox-figure figcaption { display: grid; gap: 4px; padding: 14px 16px 4px; }
.lightbox-price { font-weight: 800; color: var(--brand); font-size: 1.15rem; }
.lightbox-actions { display: flex; gap: 8px; padding: 10px 16px 16px; flex-wrap: wrap; }
.lightbox-actions .btn-primary { flex: 1; }
@keyframes lightbox-in { from { opacity: 0; transform: translateY(24px) scale(0.94); } to { opacity: 1; transform: none; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; transform: none; }
  .media-img { transform: none; }
}
