/*
 * ONIZOUKA SHOP - Architecture Super-App Marketplace (Alibaba / Mobile-First / PWA & Capacitor Ready)
 * Identité : Obsidian (#0d0e12 / #0f172a) & Gold Haute Énergie (#facc15 / #eab308 / #f59e0b)
 * Surface Marketplace : #f2f4f7 (contraste franc pour cartes produits blanches haute densité)
 */

@view-transition {
  navigation: auto;
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  overflow-x: clip;
  max-width: 100vw;
  width: 100%;
  background-color: #0d0e12;
}

[x-cloak] {
  display: none !important;
}

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-color: #f2f4f7;
  color: #0f172a;
  overflow-x: clip;
  max-width: 100vw;
  width: 100%;
  position: relative;
  overscroll-behavior-y: none;
}

img, svg, video, canvas {
  max-width: 100%;
}

/* Protection défensive anti-SVG géant si une classe utilitaire manque */
svg:not([width]):not([class*="w-"]) {
  width: 1.25rem;
  height: 1.25rem;
}

a, button, input, select, textarea, label {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.font-heading,
.font-display {
  font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  letter-spacing: -0.02em;
}

/* Safe areas natives pour PWA Standalone & Capacitor Android/iOS */
.pt-safe-top {
  padding-top: env(safe-area-inset-top, 0px);
}

.pb-safe-bottom {
  padding-bottom: max(env(safe-area-inset-bottom, 0px), 8px);
}

/* Scrollbar discrète sur Desktop, masquée sur carrousels tactiles */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.no-scrollbar::-webkit-scrollbar,
.scrollbar-hide::-webkit-scrollbar {
  display: none;
}
.no-scrollbar,
.scrollbar-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

/* Dock Mobile App Natif (Style Alibaba / Super-App) */
.app-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  padding-bottom: max(env(safe-area-inset-bottom, 0px), 6px);
  padding-top: 4px;
  box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.06);
}

.app-tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.12s cubic-bezier(0.16, 1, 0.3, 1), color 0.15s ease;
}

.app-tab-item:active {
  transform: scale(0.90);
}

/* Titres Produits Marketplace 2 lignes nettes */
.product-card-title {
  display: -webkit-box !important;
  -webkit-box-orient: vertical !important;
  -webkit-line-clamp: 2 !important;
  line-clamp: 2 !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  line-height: 1.32 !important;
  min-height: 2.64em;
  word-break: break-word;
}

/* Fluidité GPU 60fps sur téléphones Android & iPhone */
header.sticky,
.app-bottom-bar {
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.product-card-perf {
  content-visibility: auto;
  contain-intrinsic-size: auto 295px;
}

/* Sidebar sticky catalogue desktop */
.catalog-sticky-sidebar {
  position: sticky;
  top: calc(var(--hdr) + 12px);
  max-height: calc(100vh - var(--hdr) - 24px);
  overflow-y: auto;
  align-self: flex-start;
  z-index: 10;
  scrollbar-width: thin;
}

/* Indicateur de chargement HTMX fluide */
.htmx-indicator {
  display: none;
}
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: flex;
}

/* ========================================================================= */
/* EXPÉRIENCE NATIVE SUPER-APP : BARRE DE PROGRESSION + SKELETON SHIMMER     */
/* ========================================================================= */
#app-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 2.5px;
  width: 0%;
  z-index: 9999;
  background: linear-gradient(90deg, #facc15 0%, #f59e0b 60%, #fef08a 100%);
  box-shadow: 0 0 10px rgba(250, 204, 21, 0.75);
  pointer-events: none;
  opacity: 0;
  transition: width 0.22s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.18s ease;
}

@keyframes onzShimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton-shimmer {
  background: linear-gradient(90deg, #eef1f5 25%, #f8fafc 50%, #eef1f5 75%);
  background-size: 200% 100%;
  animation: onzShimmer 1.15s ease-in-out infinite;
}

/* Hauteur réelle du header (mise à jour en JS) pour les éléments collants */
:root { --hdr: 132px; }
@media (min-width: 1024px) { :root { --hdr: 100px; } }

/* Filtrage stable : atténuation retardée (aucun clignotement si la réponse est rapide) */
#catalog-workspace.htmx-request .catalog-results-live,
#home-feed-wrapper.htmx-request,
#search-results-zone.htmx-request,
#bo-live-results.htmx-request {
  opacity: 0.5;
  pointer-events: none;
  transition: opacity 0.15s ease 0.09s;
}

/* Skeleton en surimpression : zéro décalage de mise en page */
.onz-loading-overlay {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease;
}
#catalog-workspace.htmx-request .onz-loading-overlay {
  opacity: 1;
  visibility: visible;
  transition-delay: 0.18s;
}

@keyframes appFadeIn {
  from { opacity: 0.6; }
  to { opacity: 1; }
}

.app-view-enter {
  animation: appFadeIn 0.16s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Sensation tactile native iOS / Android sur les barres & boutons */
header, nav, .app-bottom-bar, button, a.app-tab-item {
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

@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;
  }
}
