/* Bourriche de Bouzigues — identité propre (nacre, ardoise, vert d'eau).
   Principes d'interaction appliqués (skill apple-design) : retour à l'appui, ressorts
   critiques sans rebond, entrées/sorties symétriques, matériaux translucides avec
   bord estompé, tracking selon la taille, mouvement / transparence / contraste réduits. */
:root {
  --bg: #f3efe7;          /* nacre */
  --surface: #fffcf6;
  --surface-2: #e9e3d6;
  --text: #13282f;        /* ardoise marine */
  --muted: #5b6a6e;
  --line: rgba(19, 40, 47, 0.1);
  --accent: #0d6b61;      /* vert d'eau profond */
  --accent-press: #0a564e;
  --accent-soft: rgba(13, 107, 97, 0.12);
  --accent-text: #ffffff;
  --sand: #b0823a;
  --ok: #1e7a4a;
  --ok-bg: rgba(30, 122, 74, 0.12);
  --warn: #8f5a00;
  --warn-bg: rgba(176, 130, 58, 0.18);
  --danger: #b3261e;
  --danger-bg: rgba(179, 38, 30, 0.09);
  --material: rgba(255, 252, 246, 0.74);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 0 rgba(19, 40, 47, 0.05), 0 6px 20px rgba(19, 40, 47, 0.06);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  /* Ressort critique (amortissement 1.0, réponse ~0.35 s) approché en bézier */
  --spring: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a161b;
    --surface: #11232a;
    --surface-2: #1a3039;
    --text: #edf1ee;
    --muted: #93a5a8;
    --line: rgba(237, 241, 238, 0.1);
    --accent: #5cc8b5;
    --accent-press: #48b3a1;
    --accent-soft: rgba(92, 200, 181, 0.14);
    --accent-text: #062420;
    --sand: #d9ad62;
    --ok: #5fd39a;
    --ok-bg: rgba(95, 211, 154, 0.14);
    --warn: #e8bd6f;
    --warn-bg: rgba(217, 173, 98, 0.16);
    --danger: #ff8a80;
    --danger-bg: rgba(255, 138, 128, 0.12);
    --material: rgba(10, 22, 27, 0.74);
    --shadow: 0 0 0 1px rgba(237, 241, 238, 0.06);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 100%/1.5 var(--sans);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { margin: 0; }
.mark { width: 1.6em; height: 1.6em; flex-shrink: 0; color: var(--accent); }

/* ---------- Typographie : grand = serré, petit = légèrement ouvert ---------- */
.display { font-family: var(--serif); font-size: clamp(2.1rem, 6.5vw, 3.1rem); line-height: 1.06; letter-spacing: -0.018em; font-weight: 600; text-wrap: balance; }
.title { font-family: var(--serif); font-size: clamp(1.8rem, 4vw, 2.4rem); line-height: 1.1; letter-spacing: -0.015em; font-weight: 600; }
.section-title { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 650; color: var(--muted); margin: 2.25rem 4px 0.6rem; }
.eyebrow { margin: 0 0 0.6rem; color: var(--sand); font-weight: 650; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; }
.lead { font-size: 1.15rem; line-height: 1.45; color: var(--muted); margin: 0.8rem 0 1.5rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.fine { font-size: 0.8rem; color: var(--muted); letter-spacing: 0.01em; line-height: 1.5; margin: 0.75rem 4px 0; }

/* ---------- Mises en page ---------- */
.brandbar { display: flex; align-items: center; gap: 10px; max-width: 640px; margin: 0 auto; padding: 20px 16px 0;
  font-family: var(--serif); font-size: 1.15rem; font-weight: 600; letter-spacing: -0.005em; }
.narrow { max-width: 640px; margin: 0 auto; padding: 2.5rem 16px 9rem; }
.wide-page { max-width: 1040px; margin: 0 auto; padding: 2rem 16px 5rem; }
.center-page { text-align: center; padding-top: 10vh; }
.center-page .card { text-align: left; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- Page salarié ---------- */
.hero { margin-bottom: 0.5rem; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin-top: 1.75rem; }
.fact { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 18px; display: flex; flex-direction: column; border-left: 3px solid var(--accent); }
.fact span { font-size: 0.78rem; color: var(--muted); font-weight: 600; letter-spacing: 0.02em; }
.fact strong { font-size: 1.15rem; letter-spacing: -0.01em; }
.fact strong::first-letter { text-transform: uppercase; }
.fact small { color: var(--muted); }
.note { border-radius: var(--radius-sm); padding: 12px 16px; margin: 14px 0 0; white-space: pre-line; background: var(--warn-bg); }

/* Couverture photo */
.cover { margin: 0 0 1.75rem; border-radius: 20px; overflow: hidden; aspect-ratio: 4 / 3; box-shadow: var(--shadow); background: var(--surface-2); }
.cover img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 30%; display: block; }
.center-page .cover { max-width: 520px; margin-left: auto; margin-right: auto; }
@media (min-width: 560px) { .cover { aspect-ratio: 16 / 10; } }

.products { list-style: none; margin: 0; padding: 0; }
.product { display: grid; grid-template-columns: 112px 1fr; align-items: center; gap: 16px; padding: 16px; transition: background-color 240ms var(--spring); }
.p-visual { width: 112px; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; }
.p-visual img { width: 100%; height: 100%; object-fit: cover; }
.p-info .stepper { margin-top: 10px; width: fit-content; }
@media (min-width: 560px) {
  .product { grid-template-columns: 140px 1fr; }
  .p-visual { width: 140px; }
}
.product + .product { border-top: 1px solid var(--line); }
.product.has-qty { background: var(--accent-soft); }
.products .product:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.products .product:last-child { border-radius: 0 0 var(--radius) var(--radius); }
.p-info { flex: 1; min-width: 0; }
.p-info h3 { font-family: var(--serif); font-size: 1.25rem; font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
.p-info p { margin: 2px 0 0; font-size: 0.9rem; }
.price { font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums; }

.stepper { display: flex; align-items: center; gap: 2px; background: var(--surface-2); border-radius: 12px; padding: 3px; flex-shrink: 0; }
.stepper input {
  width: 2.4rem; text-align: center; border: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 1.05rem; font-weight: 650; font-variant-numeric: tabular-nums; -moz-appearance: textfield; appearance: textfield; padding: 0;
}
.stepper input::-webkit-inner-spin-button, .stepper input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.step {
  width: 40px; height: 40px; border-radius: 9px; border: 0; background: var(--surface); color: var(--accent);
  font-size: 1.3rem; line-height: 1; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,.08);
  transition: transform 220ms var(--spring), background-color 160ms, opacity 160ms;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.step[data-step="1"] { background: var(--accent); color: var(--accent-text); }
.step:disabled { opacity: 0.35; cursor: default; }
/* La quantité « pulse » d'un cran dans le sens du geste */
.stepper input.up { animation: nudge-up 260ms var(--spring); }
.stepper input.down { animation: nudge-down 260ms var(--spring); }
@keyframes nudge-up { from { transform: translateY(6px); opacity: .4; } }
@keyframes nudge-down { from { transform: translateY(-6px); opacity: .4; } }

.fields { padding: 4px 18px; }
.fields label { display: flex; flex-direction: column; padding: 10px 0; }
.fields label + label { border-top: 1px solid var(--line); }
.fields label > span { font-size: 0.78rem; color: var(--muted); font-weight: 600; letter-spacing: 0.02em; transition: color 160ms; }
.fields input:not([type="checkbox"]), .fields textarea {
  border: 0; background: transparent; color: var(--text); font: inherit; font-size: 1.05rem; padding: 4px 0; outline: none; width: 100%; resize: vertical;
}
.fields input::placeholder, .fields textarea::placeholder { color: var(--muted); opacity: 0.6; }
.fields label:focus-within > span { color: var(--accent); }
.fields label.invalid > span, .field-msg { color: var(--danger); }
.field-msg { font-size: 0.8rem; font-weight: 500; }

/* Barre de paiement : matériau translucide, bord estompé (pas de filet dur).
   Elle entre par le bas quand un produit est choisi et ressort par le même chemin. */
.paybar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  background: var(--material); backdrop-filter: blur(20px) saturate(160%); -webkit-backdrop-filter: blur(20px) saturate(160%);
  box-shadow: 0 -12px 24px -12px rgba(19, 40, 47, 0.18);
  transition: transform 420ms var(--spring), opacity 300ms; }
.paybar[data-empty] { transform: translateY(110%); opacity: 0; pointer-events: none; }
.paybar-inner { max-width: 608px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.paybar-total { display: flex; flex-direction: column; line-height: 1.15; }
.paybar-total span { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.paybar-total strong { font-family: var(--serif); font-size: 1.6rem; letter-spacing: -0.015em; font-variant-numeric: tabular-nums; }
.paybar .btn { min-width: 9.5rem; }

/* ---------- Boutons : retour au contact (pointer-down), pas au relâchement ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 0 20px; border-radius: 12px; border: 0;
  background: var(--surface-2); color: var(--accent); font: inherit; font-weight: 650; font-size: 1rem;
  cursor: pointer; text-decoration: none !important; list-style: none;
  transition: transform 220ms var(--spring), background-color 160ms, opacity 160ms;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; user-select: none;
}
.btn.primary { background: var(--accent); color: var(--accent-text); }
.btn.small { min-height: 36px; padding: 0 14px; font-size: 0.9rem; border-radius: 10px; }
.btn.wide { width: 100%; }
.btn:active, .step:active:not(:disabled) { transform: scale(0.95); transition-duration: 60ms; }
.btn.primary:active { background: var(--accent-press); }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; }
.btn.done { background: var(--ok); color: #fff; }
.btn:focus-visible, .step:focus-visible, a:focus-visible, summary:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 2px; }
.linklike { background: none; border: 0; color: var(--accent); font: inherit; cursor: pointer; padding: 0; }

.alert { background: var(--danger-bg); color: var(--danger); padding: 12px 16px; border-radius: var(--radius-sm); margin: 1rem 0; font-weight: 500; text-align: left; }
.alert.info { background: var(--warn-bg); color: var(--warn); }
.closed { padding: 24px; margin-top: 2rem; }
.closed h2 { font-family: var(--serif); font-weight: 600; }
.closed p { margin-bottom: 0; }

/* ---------- Confirmation : la pastille se matérialise (échelle + opacité ensemble) ---------- */
.check {
  width: 76px; height: 76px; margin: 0 auto 1.25rem; border-radius: 50%; background: var(--ok); color: #fff;
  display: grid; place-items: center; font-size: 2.2rem; font-weight: 700;
  animation: materialize 520ms var(--spring) both;
}
.check.pending { background: var(--surface-2); color: var(--muted); }
@keyframes materialize { from { transform: scale(0.6); opacity: 0; } }
.recap { padding: 4px 18px; margin: 0 0 1.25rem; }
.recap-row { display: flex; justify-content: space-between; gap: 16px; padding: 12px 0; font-variant-numeric: tabular-nums; }
.recap-row + .recap-row { border-top: 1px solid var(--line); }
.recap-row.total { font-weight: 700; font-size: 1.1rem; }
.card > .recap-row { padding-left: 18px; padding-right: 18px; }
.pad { padding: 16px 18px; margin: 0; }
.next-steps { display: flex; flex-direction: column; gap: 10px; max-width: 400px; margin: 1.75rem auto 0; }
.next-steps form { margin: 0; }

/* ---------- Admin ---------- */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--material);
  backdrop-filter: blur(20px) saturate(160%); -webkit-backdrop-filter: blur(20px) saturate(160%);
  box-shadow: 0 10px 20px -16px rgba(19, 40, 47, 0.35); }
.topbar-inner { max-width: 1040px; margin: 0 auto; padding: 0 16px; height: 56px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 8px; color: var(--text); font-family: var(--serif); font-size: 1.1rem; font-weight: 600; white-space: nowrap; overflow: hidden; }
.brand span { overflow: hidden; text-overflow: ellipsis; }
.brand:hover { text-decoration: none; }
.topbar form { margin: 0; }
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 3px; border-radius: 11px; }
.tab { padding: 7px 14px; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: 0.92rem; white-space: nowrap; text-decoration: none !important; transition: background-color 160ms, color 160ms; }
.tab:hover { color: var(--text); }
.tab[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1); }
.page-head { display: flex; align-items: center; gap: 12px; margin: 0.5rem 0 1.25rem; flex-wrap: wrap; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.back { display: inline-block; margin-bottom: 0.5rem; font-weight: 600; }

.sheet { margin: 0 0 1.5rem; padding: 0; overflow: hidden; }
.sheet > summary { margin: 14px; }
.sheet > summary::-webkit-details-marker { display: none; }
.sheet[open] > summary { background: var(--surface-2); color: var(--accent); }
.sheet-body { padding: 0 4px 12px; transform-origin: top left; animation: unfold 360ms var(--spring); }
@keyframes unfold { from { opacity: 0; transform: translateY(-8px) scale(0.98); } }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; column-gap: 20px; }
.grid2 .span2 { grid-column: 1 / -1; }
.grid2 label + label { border-top: 0; }
.grid2 label { border-bottom: 1px solid var(--line); }
.grid2 > div { padding: 14px 0 6px; }
.check-row { flex-direction: row !important; align-items: center; gap: 10px; border-bottom: 0 !important; }
.check-row input { width: 20px; height: 20px; accent-color: var(--accent); }
.check-row span { font-size: 1rem !important; color: var(--text) !important; font-weight: 500 !important; }
.right { display: flex; justify-content: flex-end; align-items: center; }
.product-edit { margin-bottom: 12px; padding-top: 8px; padding-bottom: 8px; }
.product-edit.inactive { opacity: 0.6; }

/* Listes de l'admin : une ligne = un élément, toute la ligne est cliquable */
.intro { margin: -0.5rem 0 1.25rem; }
.list { margin-bottom: 1.5rem; overflow: hidden; }
.list-row { display: flex; align-items: center; gap: 20px; padding: 14px 18px; color: var(--text); }
.list-row + .list-row { border-top: 1px solid var(--line); }
.list-row .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.list-row .num { display: flex; flex-direction: column; align-items: flex-end; min-width: 5.5rem; }
a.list-row { text-decoration: none !important; transition: background-color 160ms; }
a.list-row:hover { background: var(--accent-soft); }
a.list-row:active { background: var(--surface-2); }
.chevron { color: var(--muted); font-size: 1.4rem; line-height: 1; }
.product-row label { display: flex; flex-direction: column; }
.product-row label > span:first-child { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.product-row input:not([type="checkbox"]) { border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--text); font: inherit; font-size: 1.05rem; padding: 4px 0; outline: none; width: 100%; }
.product-row input:not([type="checkbox"]):focus { border-bottom-color: var(--accent); }
.price-input { width: 7rem; }
.with-unit { display: flex; align-items: baseline; gap: 4px; }
.with-unit b { color: var(--muted); font-weight: 500; }
.product-row.inactive .grow input { color: var(--muted); text-decoration: line-through; }
.push { margin-left: auto; }
.resend { margin: 6px 0 0; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
.resend .linklike { font-size: 0.85rem; font-weight: 600; }

.kpis > div { display: flex; flex-direction: column; }
.kpis strong { font-size: 1.25rem; letter-spacing: -0.015em; font-variant-numeric: tabular-nums; }
.kpis span { font-size: 0.8rem; color: var(--muted); }
.kpis.big { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 14px; }
.kpis.big > div { padding: 16px 18px; }
.kpis.big strong { font-family: var(--serif); font-size: 1.8rem; font-weight: 600; }
.empty { text-align: center; padding: 2rem 0; }

.pill { display: inline-block; font-size: 0.75rem; font-weight: 650; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }

.link-card { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 20px; flex-wrap: wrap; border-left: 3px solid var(--accent); }
.link-card > div:first-child { min-width: 0; flex: 1; }
.label { display: block; font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.link-card code { font: 500 0.95rem ui-monospace, "SF Mono", Menlo, Consolas, monospace; word-break: break-all; }
.actions { display: flex; gap: 8px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th { text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 650; padding: 12px 14px; border-bottom: 1px solid var(--line); }
td { padding: 12px 14px; vertical-align: top; border-bottom: 1px solid var(--line); }
tr:last-child td { border-bottom: 0; }
tr.pending td { color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.login { max-width: 380px; margin: 1.5rem auto 0; padding-bottom: 16px; }
.login .btn { margin-top: 10px; }

@media (max-width: 640px) {
  .grid2 { grid-template-columns: 1fr; }
  .kpis.big { grid-template-columns: 1fr; }
  .kpis.big > div { flex-direction: row; justify-content: space-between; align-items: baseline; }
  .tab { padding: 6px 10px; font-size: 0.85rem; }
  .hide-sm { display: none !important; }
  .list-row { gap: 12px; }
  .product-row { flex-wrap: wrap; }
  .product-row .grow { flex-basis: 100%; }
  .product-row .btn { margin-left: auto; }
  .brand span { display: none; }
  .product { padding: 16px 14px; gap: 12px; }
  .paybar .btn { min-width: 8rem; }
  .actions { width: 100%; }
  .actions .btn { flex: 1; }
}

/* ---------- Accessibilité ---------- */
@media (prefers-reduced-motion: reduce) {
  /* Pas de glissements ni d'échelle : de simples fondus courts */
  *, *::before, *::after { animation: none !important; transition-property: opacity, background-color, color !important; transition-duration: 150ms !important; }
  .paybar[data-empty] { transform: none; }
  .btn:active, .step:active { transform: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .paybar, .topbar { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; }
}
@media (prefers-contrast: more) {
  :root { --line: rgba(127, 127, 127, 0.6); --muted: var(--text); }
  .card, .fact { box-shadow: none; border: 1px solid var(--line); }
  .paybar, .topbar { background: var(--surface); backdrop-filter: none; border-color: var(--line); }
}
