/* =========================================================
   Comptoir — design system "Citrus Glass"
   Palette vive (corail/framboise/menthe) sur fond lavande
   très clair, cartes vitrées, accent signature : la barre
   de total en verre à bordure dégradée qui "respire" à
   chaque ajout au panier.
   ========================================================= */

:root {
  --bg: #F6F5FB;
  --bg-glow-1: #FFE3D9;
  --bg-glow-2: #E4F7F1;
  --surface: #FFFFFF;
  --surface-soft: #F0EDFB;

  --ink: #211B3D;
  --ink-soft: #6F6890;
  --line: #E3DEF5;

  --coral: #FF6B4A;
  --raspberry: #FF3E7F;
  --mint: #00B894;
  --mint-tint: #DCF7EF;
  --amber: #FFB200;
  --danger: #E0395B;
  --danger-tint: #FDE3E9;

  --gradient-brand: linear-gradient(135deg, var(--coral), var(--raspberry));

  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;

  --shadow: 0 10px 28px rgba(33, 27, 61, 0.09);
  --shadow-lift: 0 20px 44px rgba(33, 27, 61, 0.22);

  --font-display: "Bricolage Grotesque", "Manrope", sans-serif;
  --font-body: "Manrope", system-ui, sans-serif;
  --font-mono: "Space Mono", "SF Mono", monospace;

  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
  background: var(--bg);
}
body {
  padding-bottom: calc(96px + var(--safe-bottom));
  background:
    radial-gradient(520px 340px at 8% -6%, var(--bg-glow-1) 0%, transparent 70%),
    radial-gradient(480px 320px at 96% 8%, var(--bg-glow-2) 0%, transparent 70%),
    var(--bg);
  min-height: 100vh;
}
h1, h2 { font-family: var(--font-display); margin: 0; font-weight: 700; }
button { font-family: inherit; }

/* ===== Top bar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  backdrop-filter: blur(14px);
  background: rgba(246, 245, 251, 0.78);
}
.brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 23px;
  letter-spacing: -0.01em;
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.status {
  font-size: 11.5px;
  color: var(--mint);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 4px var(--mint-tint);
  display: inline-block;
}

/* ===== Catalog grid ===== */
.catalog {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 14px 16px;
  max-width: 720px;
  margin: 0 auto;
}
@media (min-width: 540px) {
  .catalog { grid-template-columns: repeat(3, 1fr); }
}
.loading {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--ink-soft);
  padding: 40px 0;
}

.card {
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 9px;
  position: relative;
  border: 1.5px solid transparent;
  transition: border-color 0.18s ease, transform 0.18s ease;
}
.card.has-qty {
  border-color: rgba(255, 62, 127, 0.35);
  transform: translateY(-1px);
}

.card-emoji {
  font-size: 21px;
  line-height: 1;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  background: var(--surface-soft);
}
.card:nth-child(3n+2) .card-emoji { background: var(--mint-tint); }
.card:nth-child(3n) .card-emoji { background: #FFE7DD; }

.card-name {
  font-weight: 700;
  font-size: 14.5px;
  line-height: 1.25;
  min-height: 36px;
}
.card-price {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--ink-soft);
  font-size: 13.5px;
}

.stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--surface-soft);
  border-radius: 999px;
  padding: 4px;
}
.stepper-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: var(--surface);
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(33, 27, 61, 0.10);
}
.stepper-btn:active { transform: scale(0.90); }
.stepper-btn.plus {
  background: var(--gradient-brand);
  color: #fff;
  box-shadow: 0 4px 10px rgba(255, 62, 127, 0.35);
}
.stepper-qty {
  font-family: var(--font-mono);
  font-weight: 700;
  min-width: 22px;
  text-align: center;
  font-size: 14.5px;
}

.qty-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: var(--gradient-brand);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  min-width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 8px rgba(255, 62, 127, 0.45);
}

/* ===== Total bar — signature : verre + bordure dégradée animée ===== */
.totalbar {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: calc(14px + var(--safe-bottom));
  z-index: 20;
  border: none;
  border-radius: var(--radius-lg);
  padding: 3px;
  display: block;
  max-width: 720px;
  margin: 0 auto;
  width: calc(100% - 28px);
  background: var(--gradient-brand);
  background-size: 220% 220%;
  box-shadow: var(--shadow-lift);
  animation: gradient-drift 9s ease infinite;
}
@keyframes gradient-drift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
.totalbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  border-radius: calc(var(--radius-lg) - 3px);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
}
.totalbar-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
}
.totalbar-count {
  color: var(--ink-soft);
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}
.totalbar-amount {
  font-family: var(--font-mono);
  color: var(--ink);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  transition: transform 0.18s ease;
}
.totalbar.bump .totalbar-amount { transform: scale(1.14); }
.totalbar-cta {
  color: #fff;
  background: var(--gradient-brand);
  font-weight: 700;
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ===== Bottom sheets ===== */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(33, 27, 61, 0.38);
  backdrop-filter: blur(2px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease;
  z-index: 29;
}
.overlay.open { opacity: 1; visibility: visible; }

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
  border-radius: 26px 26px 0 0;
  padding: 10px 18px calc(20px + var(--safe-bottom));
  max-width: 720px;
  margin: 0 auto;
  transform: translateY(105%);
  transition: transform 0.3s cubic-bezier(.32,.72,0,1);
  max-height: 86vh;
  overflow-y: auto;
  box-shadow: 0 -10px 40px rgba(33, 27, 61, 0.18);
  border-top: 1px solid rgba(255,255,255,0.6);
}
.sheet.open { transform: translateY(0); }

.sheet-handle {
  width: 38px;
  height: 4px;
  background: var(--line);
  border-radius: 999px;
  margin: 6px auto 12px;
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.icon-btn {
  border: none;
  background: var(--surface-soft);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 14px;
  color: var(--ink);
}

.cart-items { display: flex; flex-direction: column; gap: 9px; }
.cart-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  box-shadow: 0 2px 8px rgba(33, 27, 61, 0.06);
}
.cart-row .card-emoji { width: 30px; height: 30px; font-size: 16px; flex-shrink: 0; }
.cart-row-name { font-weight: 700; font-size: 14px; flex: 1; }
.cart-row-price {
  font-family: var(--font-mono);
  color: var(--ink-soft);
  font-size: 12.5px;
  white-space: nowrap;
}
.cart-empty { text-align: center; color: var(--ink-soft); padding: 30px 0; }

.sheet-footer {
  position: sticky;
  bottom: 0;
  background: transparent;
  padding-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.cart-subtotal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
  color: var(--ink-soft);
  padding-bottom: 6px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
.cart-subtotal strong {
  font-family: var(--font-mono);
  font-size: 19px;
  color: var(--ink);
}

.btn {
  border: none;
  border-radius: 999px;
  font-weight: 700;
  font-size: 15.5px;
  padding: 15px;
  min-height: 50px;
}
.btn-block { width: 100%; }
.btn-primary {
  background: var(--gradient-brand);
  color: #fff;
  box-shadow: 0 8px 20px rgba(255, 62, 127, 0.32);
}
.btn-primary:disabled { background: var(--line); color: var(--ink-soft); box-shadow: none; }
.btn-primary:active:not(:disabled) { transform: scale(0.98); }
.btn-ghost {
  background: var(--surface-soft);
  color: var(--ink);
}
.btn-ghost:disabled { color: var(--ink-soft); opacity: 0.6; }

.pay-amount {
  font-family: var(--font-mono);
  font-size: 30px;
  font-weight: 700;
  text-align: center;
  margin: 4px 0 16px;
}
.pay-error {
  color: var(--danger);
  background: var(--danger-tint);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13.5px;
  margin-top: 12px;
}

.sheet-success { text-align: center; }
.success-mark {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--mint-tint);
  color: var(--mint);
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 8px auto 14px;
}

.qrcode-wrap {
  display: flex;
  justify-content: center;
  padding: 16px;
  background: #fff;
  border-radius: var(--radius-md);
  width: fit-content;
  margin: 0 auto 14px;
  box-shadow: var(--shadow);
}
.qr-status {
  text-align: center;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.qr-status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
  animation: pulse 1.4s infinite ease-in-out;
}
.qr-status.is-paid::before { background: var(--mint); animation: none; }
.qr-fallback {
  text-align: center;
  font-size: 12px;
  color: var(--ink-soft);
  margin-top: 6px;
  word-break: break-all;
}
.qr-fallback a { color: var(--raspberry); font-weight: 700; }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.7); }
}

@media (prefers-reduced-motion: reduce) {
  .sheet, .overlay, .stepper-btn, .totalbar-amount { transition: none; }
  .totalbar { animation: none; }
  .qr-status::before { animation: none; }
}