/* ========================================================================
   BS CUSTOM — BOTTOM NAV MOBILE (Phase 10.2 — liquid glass sombre)
   5 items : Accueil / Services / Boutique / Panier / Compte.
   Verre en 2 prototypes commutables via [data-glass="a|b"] (cookie bs_glass).
   Dépend des tokens de theme.css (--gold, --ease-out, --ease-emph, --dur-*).
   ======================================================================== */

:root {
  --nav-h: 60px;
  --nav-icon: 22px;
  --nav-label: #EDE6D6;            /* blanc cassé : contraste sûr sur le verre */
  --nav-label-dim: rgba(237, 230, 214, .68);
  --nav-gold-edge: rgba(198, 169, 109, .22);
  --nav-pill: rgba(198, 169, 109, .16);
}

/* ==================== CONTENEUR ==================== */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 9998;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom, 0px));

  /* Fallback opaque par défaut ; le verre arrive en @supports plus bas. */
  background: rgba(15, 15, 15, .96);
  border-top: 1px solid var(--nav-gold-edge);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, .35), inset 0 1px 0 rgba(255, 255, 255, .06);

  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
  /* Masquée uniquement quand le clavier virtuel s'ouvre (voir :has plus bas). */
  transition: transform var(--dur-med, 280ms) var(--ease-emph, ease);
}

/* Reflet spéculaire haut (léger dégradé blanc), n'intercepte pas les clics. */
.mobile-bottom-nav::before {
  content: "";
  position: absolute; inset: 0 0 auto 0; height: 42%;
  background: linear-gradient(rgba(255, 255, 255, .05), transparent);
  pointer-events: none;
}

/* ---- Verre translucide (choix Exaucé : variante A) ----
   Un SEUL backdrop-filter par vue, jamais imbriqué, blur <= 24px.
   brightness < 1 assombrit le fond derrière (protège le contraste, leçon iOS 26). */
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .mobile-bottom-nav {
    background: rgba(15, 15, 15, .62);
    -webkit-backdrop-filter: blur(20px) saturate(160%) brightness(.9);
    backdrop-filter: blur(20px) saturate(160%) brightness(.9);
  }
}

/* prefers-reduced-transparency : on repasse opaque (accessibilité). */
@media (prefers-reduced-transparency: reduce) {
  .mobile-bottom-nav {
    background: rgba(15, 15, 15, .98) !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }
}

.mobile-bottom-nav-inner {
  display: flex;
  align-items: stretch;
  justify-content: space-around;
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
}

/* ==================== ITEM (colonne entièrement cliquable) ==================== */
.mobile-nav-item {
  flex: 1 1 0;
  min-width: 0;
  min-height: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 6px 2px;
  border: none;
  background: transparent;
  color: var(--nav-label-dim);
  text-decoration: none;
  cursor: pointer;
  position: relative;
  border-radius: 16px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: transform 130ms var(--ease-out, ease), color var(--dur-fast, 180ms) ease;
}

/* Enfoncement au tap (jamais < 0.9). */
.mobile-nav-item:active { transform: scale(.92); }

/* Pilule M3 derrière l'item actif (view-transition-name : morphe entre pages en 10.4). */
.mobile-nav-item.active::before {
  content: "";
  position: absolute;
  inset: 4px 8px;
  border-radius: 14px;
  background: var(--nav-pill);
  box-shadow: inset 0 0 0 1px rgba(198, 169, 109, .18);
  view-transition-name: navpill;
  animation: navPillIn 320ms var(--ease-emph, ease);
}

@keyframes navPillIn {
  from { opacity: 0; transform: scale(.86); }
  to   { opacity: 1; transform: scale(1); }
}

/* ==================== ICÔNE ==================== */
.mobile-nav-icon {
  position: relative;
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
}
.mobile-nav-icon svg {
  width: var(--nav-icon); height: var(--nav-icon);
  color: var(--nav-label);
  transition: color var(--dur-fast, 180ms) ease, transform var(--dur-fast, 180ms) var(--ease-out, ease);
}

/* ==================== LABEL ==================== */
.mobile-nav-label {
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: .02em;
  line-height: 1;
  white-space: nowrap;
  color: var(--nav-label-dim);
  transition: color var(--dur-fast, 180ms) ease, font-weight var(--dur-fast, 180ms) ease;
}

/* ==================== ÉTAT ACTIF (or) ==================== */
.mobile-nav-item.active .mobile-nav-icon svg {
  color: var(--gold, #C6A96D);
  fill: rgba(198, 169, 109, .14);         /* "rempli" léger : icône outline -> filled */
  transform: translateY(-1px) scale(1.04);
}
.mobile-nav-item.active .mobile-nav-label {
  color: var(--gold, #C6A96D);
  font-weight: 600;
}

/* Focus clavier : liseré or (cohérent focus-visible global). */
.mobile-nav-item:focus-visible {
  outline: 2px solid var(--gold, #C6A96D);
  outline-offset: -3px;
}

/* Survol (souris seulement). */
@media (hover: hover) and (pointer: fine) {
  .mobile-nav-item:hover:not(.active) .mobile-nav-icon svg,
  .mobile-nav-item:hover:not(.active) .mobile-nav-label { color: #fff; }
}

/* ==================== BADGE PANIER ==================== */
.mobile-nav-badge {
  position: absolute;
  top: -4px; right: -8px;
  min-width: 17px; height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--gold, #C6A96D);
  color: #0F0F0F;
  font-size: 10px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  display: flex; align-items: center; justify-content: center;
  border: 1.5px solid rgba(15, 15, 15, .9);
  animation: navBadgeIn 260ms var(--ease-out, ease);
}
@keyframes navBadgeIn {
  from { opacity: 0; transform: scale(.25); filter: blur(4px); }
  to   { opacity: 1; transform: scale(1);   filter: blur(0); }
}

/* ==================== FEUILLE "SERVICES" ==================== */
.mobile-services-backdrop {
  position: fixed; inset: 0;
  z-index: 9997;
  background: rgba(0, 0, 0, .5);
  opacity: 0;
  transition: opacity var(--dur-med, 280ms) ease;
}
.mobile-services-backdrop.is-open { opacity: 1; }

.mobile-services-sheet {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(var(--nav-h) + 14px + env(safe-area-inset-bottom, 0px));
  z-index: 9999;
  padding: 10px;
  border-radius: 20px;
  background: rgba(20, 20, 20, .97);
  border: 1px solid var(--nav-gold-edge);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .55);
  max-width: 460px; margin: 0 auto;
  transform: translateY(12px) scale(.98);
  opacity: 0;
  transition: transform var(--dur-med, 280ms) var(--ease-emph, ease), opacity var(--dur-med, 280ms) ease;
}
@supports ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .mobile-services-sheet { background: rgba(20, 20, 20, .78); -webkit-backdrop-filter: blur(22px) saturate(150%); backdrop-filter: blur(22px) saturate(150%); }
}
.mobile-services-sheet.is-open { transform: translateY(0) scale(1); opacity: 1; }

.mss-title {
  margin: 4px 6px 8px;
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--nav-label-dim);
}
.mss-item {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 12px;
  border-radius: 14px;
  color: var(--nav-label);
  text-decoration: none;
  transition: background var(--dur-fast, 180ms) ease, transform 130ms var(--ease-out, ease);
}
.mss-item + .mss-item { margin-top: 2px; }
.mss-item svg { width: 24px; height: 24px; color: var(--gold, #C6A96D); flex: none; }
.mss-item span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mss-item strong { font-size: 14px; font-weight: 600; }
.mss-item small { font-size: 12px; color: var(--nav-label-dim); }
.mss-item:active { transform: scale(.98); }
.mss-item.is-active { background: var(--nav-pill); }
@media (hover: hover) and (pointer: fine) {
  .mss-item:hover { background: rgba(255, 255, 255, .06); }
}
.mss-item:focus-visible { outline: 2px solid var(--gold, #C6A96D); outline-offset: -2px; }

/* ==================== AFFICHAGE : mobile <= 1023px, desktop dès 1024 ==================== */
@media (max-width: 1023px) {
  .mobile-bottom-nav { display: block; }
  .nav .menu { display: none !important; }
}

/* Fenêtre desktop (souris + pointeur fin) dès 768px : nav classique, pas de bottom nav. */
@media (min-width: 768px) and (hover: hover) and (pointer: fine) {
  .mobile-bottom-nav { display: none !important; }
  .nav .menu { display: flex !important; }
}

/* ==================== CLAVIER VIRTUEL : masque la barre ==================== */
body:has(:is(input, textarea, select):focus) .mobile-bottom-nav {
  transform: translateY(120%);
}

/* ==================== PETITS ÉCRANS ==================== */
@media (max-width: 360px) {
  :root { --nav-icon: 20px; }
  .mobile-nav-label { font-size: 10px; letter-spacing: 0; }
  .mobile-nav-item { padding: 6px 1px; }
}

/* ==================== REDUCED MOTION ==================== */
@media (prefers-reduced-motion: reduce) {
  .mobile-bottom-nav,
  .mobile-nav-item,
  .mobile-nav-item.active::before,
  .mobile-nav-icon svg,
  .mobile-nav-badge,
  .mobile-services-sheet,
  .mobile-services-backdrop {
    transition: none !important;
    animation: none !important;
  }
}

/* ==================== CONTRASTE ÉLEVÉ ==================== */
@media (prefers-contrast: more) {
  .mobile-nav-item.active { outline: 1.5px solid var(--gold, #C6A96D); outline-offset: -3px; }
  .mobile-nav-label { color: #fff; }
}

/* ==================== IMPRESSION ==================== */
@media print {
  .mobile-bottom-nav, .mobile-services-sheet, .mobile-services-backdrop { display: none !important; }
}
