/* ==========================================================================
   KAZA CAFÉ — BASE COMMUNE
   Mécanique partagée par les deux directions : reset, mascottes animées,
   médias/placeholders, barre de catégories, fiche détaillée (bottom-sheet /
   panneau), options. Les couleurs et la typo viennent de a.css ou b.css.
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body { margin: 0; background: var(--bg); color: var(--fg); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
img, svg, video { display: block; max-width: 100%; }
a { color: inherit; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
h1, h2, h3, h4, p, ul, ol, figure, dl, dd, blockquote { margin: 0; }
ul, ol { padding: 0; list-style: none; }
h1, h2, h3 { text-wrap: balance; }
p { text-wrap: pretty; }
[hidden] { display: none !important; }

.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; z-index: 200; background: var(--navy); color: var(--cream); padding: 10px 14px; text-decoration: none; }
.skip:focus { top: calc(12px + env(safe-area-inset-top, 0px)); }
:focus-visible { outline: 2px solid var(--focus, var(--navy)); outline-offset: 3px; }

.wrap {
  width: 100%; max-width: var(--max, 1240px); margin-inline: auto;
  padding-left: max(var(--gutter, 20px), env(safe-area-inset-left, 0px));
  padding-right: max(var(--gutter, 20px), env(safe-area-inset-right, 0px));
}

/* ---------- Mascottes ---------- */
.m { width: 100%; height: auto; overflow: visible; }
.m .leg, .m .eyes, .m .steam path { transform-box: fill-box; }
.m .leg { transform-origin: 50% 0; }
.m .eyes { transform-origin: 50% 50%; }
@media (prefers-reduced-motion: no-preference) {
  .m-walk .leg-l { animation: kz-step .5s ease-in-out infinite alternate; }
  .m-walk .leg-r { animation: kz-step .5s ease-in-out infinite alternate-reverse; }
  .m-walk > svg, svg.m-walk { animation: kz-bob .5s ease-in-out infinite alternate; }
  .m-cup .steam path { animation: kz-steam 2.8s ease-in-out infinite; }
  .m-cup .steam path:nth-child(2) { animation-delay: .5s; }
  .m-cup .steam path:nth-child(3) { animation-delay: 1s; }
  .m-cookie .eyes { animation: kz-blink 5.2s infinite; }
  .is-idle .m .steam path, .is-idle .m .eyes { animation-play-state: paused; }
}
@keyframes kz-step { from { transform: rotate(-14deg); } to { transform: rotate(14deg); } }
@keyframes kz-bob { from { transform: translateY(0); } to { transform: translateY(-1.5px); } }
@keyframes kz-steam { 0% { opacity: 0; transform: translateY(4px); } 30% { opacity: 1; } 100% { opacity: 0; transform: translateY(-5px); } }
@keyframes kz-blink { 0%, 93%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.1); } }

/* ---------- Médias : photo, ou mascotte tant que la photo n'existe pas ---------- */
.media { position: relative; overflow: hidden; background: var(--ph-bg); color: var(--ph-fg); isolation: isolate; }
.media .ph { position: absolute; inset: 0; display: grid; place-items: center; }
.media .ph .m { width: var(--ph-size, 38%); max-width: 150px; }
.media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .35s ease; }
.media.has-img img { opacity: 1; }
.media.has-img .ph { visibility: hidden; }
.media-fly { pointer-events: none; will-change: left, top, width, height; }
.media-fly img { transition: none; }

/* Placeholders clairement identifiés (hero, galerie) */
.ph-label {
  position: absolute; left: 12px; bottom: 12px; right: 12px; z-index: 1;
  font: 500 11px/1.35 var(--f-mono, ui-monospace, monospace); letter-spacing: .02em; color: var(--ph-fg);
}
.ph-label code { font: inherit; opacity: .75; display: block; overflow-wrap: anywhere; }

/* ---------- Carte d'item ---------- */
.card { display: flex; flex-direction: column; text-decoration: none; color: inherit; position: relative; min-width: 0; -webkit-tap-highlight-color: transparent; }
.card-meta { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.card-name { min-width: 0; }
.leader { flex: 1 1 12px; min-width: 12px; border-bottom: 1.5px dotted currentColor; opacity: .35; transform: translateY(-4px); }
.card-price { flex: none; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Barre de catégories ---------- */
.catbar { display: flex; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
.catbar::-webkit-scrollbar { display: none; }
.cat-chip { flex: none; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; white-space: nowrap; }
.cat-chip-icon { width: 22px; flex: none; }
.cat-icon { display: inline-block; width: 34px; flex: none; }
.cat-section { scroll-margin-top: calc(var(--sticky-h, 64px) + env(safe-area-inset-top, 0px) + 12px); }

/* ---------- Fiche détaillée ---------- */
html.sheet-open { overflow: hidden; }
.sheet-root { position: fixed; inset: 0; z-index: 100; }
.sheet-backdrop { position: absolute; inset: 0; background: var(--scrim); }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--sheet-bg); color: var(--sheet-fg);
  outline: none; touch-action: pan-y;
}
.sheet.is-dragging { transition: none; }
.sheet-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.sheet-media { width: 100%; aspect-ratio: 5 / 4; max-height: 52vh; }
.sheet-grip { position: absolute; top: 8px; left: 50%; width: 44px; height: 5px; margin-left: -22px; border-radius: 3px; background: var(--grip); z-index: 3; }
.sheet-close {
  position: absolute; z-index: 4; top: 12px; right: max(12px, env(safe-area-inset-right, 0px));
  width: 44px; height: 44px; display: grid; place-items: center;
}
.sheet-close svg { width: 18px; height: 18px; }
.sheet-body { padding: 22px max(20px, env(safe-area-inset-right, 0px)) calc(28px + env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px)); display: flex; flex-direction: column; gap: 18px; }
.sheet-cat { display: flex; align-items: center; gap: 8px; }
.sheet-cat .cat-icon { width: 22px; }
.sheet-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.sheet-ing { display: flex; flex-wrap: wrap; }
.sheet-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; }

@media (min-width: 720px) {
  .sheet-root { display: grid; place-items: center; padding: 40px max(24px, env(safe-area-inset-right, 0px)) 40px max(24px, env(safe-area-inset-left, 0px)); }
  .sheet { position: relative; inset: auto; width: min(980px, 100%); height: min(640px, calc(100vh - 80px)); }
  .sheet-scroll { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); overflow: hidden; }
  .sheet-media { aspect-ratio: auto; height: 100%; max-height: none; }
  .sheet-body { overflow-y: auto; padding: 44px 40px 36px; }
  .sheet-grip { display: none; }
}

/* Options */
.sheet-opts { display: flex; flex-direction: column; gap: 20px; }
.sheet-opts:empty { display: none; }
.opt { border: 0; margin: 0; padding: 0; min-width: 0; }
.opt legend { padding: 0; margin-bottom: 10px; }
.opt-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.opt-choice { position: relative; display: inline-flex; cursor: pointer; }
.opt-choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.opt-choice span { display: inline-block; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* mascottes posées dans un placeholder via data-mascot-el */
.media .ph [data-mascot-el] .m { width: 100%; max-width: none; }
