/**
 * Couche « app native » JeuneXpert (PWA).
 * Chargé de façon bloquante dans le <head> : le splash est donc peint
 * dès le premier rendu, sans flash de contenu.
 */

:root {
  --jx-safe-top: env(safe-area-inset-top, 0px);
  --jx-safe-bottom: env(safe-area-inset-bottom, 0px);
  --jx-safe-left: env(safe-area-inset-left, 0px);
  --jx-safe-right: env(safe-area-inset-right, 0px);
}

/* ------------------------------------------------------------------ */
/* Splash / boot screen — visible uniquement en app installée          */
/* ------------------------------------------------------------------ */

#jx-splash {
  display: none;
}

@media all and (display-mode: standalone), all and (display-mode: fullscreen), all and (display-mode: minimal-ui) {
  #jx-splash {
    display: flex;
  }
}

html.jx-standalone #jx-splash {
  display: flex;
}

#jx-splash {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  background: linear-gradient(135deg, var(--jx-brand-start, #4b55a8) 0%, var(--jx-brand-mid, #7e4395) 50%, var(--jx-brand-end, #b3458b) 100%);
  opacity: 1;
  transition: opacity 0.32s ease;
}

#jx-splash.jx-splash-hide {
  opacity: 0;
  pointer-events: none;
}

html.jx-splash-done #jx-splash {
  display: none !important;
}

#jx-splash .jx-splash-logo {
  width: min(340px, 82vw);
  height: auto;
  padding: 0;
  border-radius: 0;
  overflow: visible;
  background: transparent;
  box-shadow: none;
  animation: jxSplashPop 0.5s ease-out both;
  display: flex;
  align-items: center;
  justify-content: center;
}

#jx-splash .jx-splash-logo img {
  width: 100%;
  height: auto;
  max-height: min(140px, 28vh);
  object-fit: contain;
  object-position: center;
  display: block;
  filter: drop-shadow(0 18px 36px rgba(0, 0, 0, 0.35));
}

#jx-splash .jx-splash-bar {
  width: 140px;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  overflow: hidden;
}

#jx-splash .jx-splash-bar span {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: 999px;
  background: #fff;
  animation: jxSplashSlide 1.1s ease-in-out infinite;
}

@keyframes jxSplashPop {
  from {
    opacity: 0;
    transform: scale(0.88);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes jxSplashSlide {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(250%);
  }
}

@media (prefers-reduced-motion: reduce) {
  #jx-splash .jx-splash-logo,
  #jx-splash .jx-splash-bar span {
    animation: none;
  }
}

/* ------------------------------------------------------------------ */
/* Mode app installée : gommer le « look site web »                    */
/* ------------------------------------------------------------------ */

@media all and (display-mode: standalone), all and (display-mode: fullscreen) {
  /* Pas de sélection/callout involontaires au tap long */
  body {
    -webkit-touch-callout: none;
    overscroll-behavior-y: contain;
  }

  /* Zones réservées à la navigation web (footer marketing, bandeaux SEO) */
  .jx-hide-in-app {
    display: none !important;
  }

  /* Header collant sous l'encoche */
  .jx-safe-top {
    padding-top: var(--jx-safe-top);
  }
}

html.jx-standalone .jx-hide-in-app {
  display: none !important;
}

html.jx-standalone body {
  -webkit-touch-callout: none;
  overscroll-behavior-y: contain;
  padding-left: var(--jx-safe-left);
  padding-right: var(--jx-safe-right);
}

html.jx-standalone .jx-tabbar {
  box-shadow: 0 -12px 28px -16px rgba(15, 23, 42, 0.28);
}

@media all and (display-mode: standalone) {
  .jx-tabbar {
    box-shadow: 0 -12px 28px -16px rgba(15, 23, 42, 0.28);
  }
}

/* Dans l'app installée : masquer les invites d'install (header + menu).
   Dans le navigateur : le bouton du menu latéral reste toujours visible. */
html.jx-standalone .jx-header-install,
html.jx-standalone [data-jx-install-trigger]:not([data-jx-install-menu]),
html.jx-standalone .jx-menu-install,
html.jx-standalone #jx-install-banner,
html.jx-standalone #jx-ios-sheet,
html.jx-standalone #jx-openapp-bar {
  display: none !important;
}

/* Navigateur Android : pas d'install web, les boutons mènent à Google Play. */
html.jx-android-browser #jx-install-banner,
html.jx-android-browser #jx-ios-sheet {
  display: none !important;
}

.jx-header-install[hidden],
[data-jx-install-trigger][hidden]:not([data-jx-install-menu]) {
  display: none !important;
}

/* ------------------------------------------------------------------ */
/* Barre de progression de navigation (feedback « natif »)             */
/* ------------------------------------------------------------------ */

#jx-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0;
  z-index: 2147482000;
  background: linear-gradient(90deg, var(--jx-brand-start, #4b55a8), var(--jx-brand-end, #b3458b));
  box-shadow: none;
  opacity: 0;
  transition: width 0.2s ease, opacity 0.2s ease;
  pointer-events: none;
}

html.jx-standalone #jx-progress {
  top: var(--jx-safe-top, 0px);
}

#jx-progress.jx-progress-on {
  opacity: 1;
}

/* ------------------------------------------------------------------ */
/* Bandeau d'installation (Android / Chrome)                           */
/* ------------------------------------------------------------------ */

#jx-install-banner {
  position: fixed;
  z-index: 2147481000;
  left: max(12px, var(--jx-safe-left));
  right: max(12px, var(--jx-safe-right));
  bottom: calc(var(--jx-safe-bottom) + 84px);
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 18px 40px -18px rgba(15, 23, 42, 0.45);
  transform: translateY(14px);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

#jx-install-banner.jx-show {
  display: flex;
  transform: translateY(0);
  opacity: 1;
}

@media (min-width: 768px) {
  #jx-install-banner {
    bottom: calc(var(--jx-safe-bottom) + 20px);
    left: auto;
    right: 20px;
    max-width: 380px;
  }
}

#jx-install-banner .jx-ib-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  flex: none;
  overflow: hidden;
}

#jx-install-banner .jx-ib-icon img {
  width: 100%;
  height: 100%;
  display: block;
}

#jx-install-banner .jx-ib-text {
  min-width: 0;
  flex: 1 1 auto;
}

#jx-install-banner .jx-ib-title {
  font-size: 14px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.25;
}

#jx-install-banner .jx-ib-sub {
  font-size: 12px;
  color: #64748b;
  line-height: 1.35;
  margin-top: 2px;
}

.jx-btn-install {
  flex: none;
  appearance: none;
  border: 0;
  cursor: pointer;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--jx-brand-start, #4b55a8), var(--jx-brand-end, #b3458b));
}

.jx-btn-dismiss {
  flex: none;
  appearance: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  color: #94a3b8;
  font-size: 20px;
  line-height: 1;
}

.jx-btn-dismiss:hover {
  background: #f1f5f9;
  color: #475569;
}

/* ------------------------------------------------------------------ */
/* Feuille d'instructions iOS (« Sur l'écran d'accueil »)              */
/* ------------------------------------------------------------------ */

#jx-ios-sheet {
  position: fixed;
  inset: 0;
  z-index: 2147481500;
  display: none;
  align-items: flex-end;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(2px);
}

#jx-ios-sheet.jx-show {
  display: flex;
}

#jx-ios-sheet .jx-sheet {
  width: 100%;
  background: #fff;
  border-radius: 22px 22px 0 0;
  padding: 20px 20px calc(20px + var(--jx-safe-bottom));
  animation: jxSheetUp 0.28s ease-out both;
}

@keyframes jxSheetUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

#jx-ios-sheet h3 {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 800;
  color: #0f172a;
}

#jx-ios-sheet p {
  margin: 0 0 14px;
  font-size: 13px;
  color: #64748b;
  line-height: 1.5;
}

#jx-ios-sheet ol {
  margin: 0;
  padding-left: 20px;
  font-size: 14px;
  color: #334155;
  line-height: 1.9;
}

#jx-ios-sheet .jx-sheet-close {
  margin-top: 18px;
  width: 100%;
  appearance: none;
  border: 0;
  cursor: pointer;
  min-height: 46px;
  border-radius: 14px;
  font: inherit;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--jx-brand-start, #4b55a8), var(--jx-brand-end, #b3458b));
}

/* ------------------------------------------------------------------ */
/* Bandeau « ouvrir dans l'app » (deep links depuis le navigateur)     */
/* ------------------------------------------------------------------ */

#jx-openapp-bar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 14px calc(10px + var(--jx-safe-top));
  background: linear-gradient(135deg, var(--jx-brand-start, #4b55a8), var(--jx-brand-end, #b3458b));
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}

#jx-openapp-bar.jx-show {
  display: flex;
}

#jx-openapp-bar a {
  color: #fff;
  text-decoration: underline;
  font-weight: 800;
  white-space: nowrap;
}

#jx-openapp-bar button {
  margin-left: auto;
  appearance: none;
  border: 0;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  border-radius: 9px;
  width: 26px;
  height: 26px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  flex: none;
}

/* Toast générique PWA (activation notifications, mise à jour dispo) */
#jx-toast {
  position: fixed;
  z-index: 2147482500;
  left: 50%;
  transform: translate(-50%, 20px);
  bottom: calc(var(--jx-safe-bottom) + 88px);
  max-width: min(520px, calc(100vw - 24px));
  display: none;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 14px;
  background: #0f172a;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 18px 40px -18px rgba(15, 23, 42, 0.7);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

#jx-toast.jx-show {
  display: flex;
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Toast mise à jour : centré à l’écran */
#jx-toast.jx-toast-center {
  top: 50%;
  bottom: auto;
  left: 50%;
  right: auto;
  width: min(360px, calc(100vw - 32px));
  max-width: min(360px, calc(100vw - 32px));
  flex-direction: column;
  text-align: center;
  gap: 14px;
  padding: 22px 20px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.4;
  transform: translate(-50%, -40%);
  box-shadow:
    0 24px 60px -12px rgba(15, 23, 42, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.06);
}

#jx-toast.jx-toast-center.jx-show {
  transform: translate(-50%, -50%);
}

#jx-toast.jx-toast-center button {
  width: 100%;
  padding: 11px 16px;
  border-radius: 12px;
  background: #4f46e5;
  font-size: 14px;
}

#jx-toast button {
  appearance: none;
  border: 0;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border-radius: 9px;
  padding: 7px 12px;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

/* Bannière message in-app — glisse du haut (style WhatsApp) */
#jx-msg-banner {
  position: fixed !important;
  z-index: 2147483646 !important;
  left: 10px !important;
  right: 10px !important;
  top: max(10px, calc(var(--jx-safe-top, 0px) + 10px)) !important;
  width: auto !important;
  max-width: 440px;
  margin: 0 auto;
  display: flex !important;
  flex-direction: column;
  gap: 0;
  padding: 0;
  border-radius: 14px;
  background: #1f2c34 !important;
  color: #e9edef !important;
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.06);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-140%);
  transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  overflow: visible;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

#jx-msg-banner.jx-show {
  opacity: 1 !important;
  pointer-events: auto !important;
  transform: translateY(0) !important;
}

#jx-msg-banner .jx-msg-banner-main {
  display: flex;
  align-items: stretch;
  min-width: 0;
}

#jx-msg-banner .jx-msg-banner-hit {
  appearance: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  text-align: left;
  padding: 12px 6px 12px 12px;
  color: inherit;
  font: inherit;
}

#jx-msg-banner .jx-msg-banner-logos {
  position: relative;
  flex: none;
  width: 44px;
  height: 44px;
}

#jx-msg-banner .jx-msg-banner-brand {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: contain;
  background: #fff;
  display: block;
}

#jx-msg-banner .jx-msg-banner-actor,
#jx-msg-banner .jx-msg-banner-actor-fallback {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #1f2c34;
  object-fit: cover;
  background: #00a884;
  color: #fff;
  font-size: 9px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

#jx-msg-banner .jx-msg-banner-actor[hidden],
#jx-msg-banner .jx-msg-banner-actor-fallback[hidden] {
  display: none !important;
}

#jx-msg-banner .jx-msg-banner-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

#jx-msg-banner .jx-msg-banner-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

#jx-msg-banner .jx-msg-banner-app {
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  color: #8696a0;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#jx-msg-banner .jx-msg-banner-kind {
  flex: none;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 999px;
  background: rgba(0, 168, 132, 0.22);
  color: #25d366;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

#jx-msg-banner .jx-msg-banner-kind[data-kind='follow'] {
  background: rgba(139, 92, 246, 0.25);
  color: #c4b5fd;
}

#jx-msg-banner .jx-msg-banner-kind[data-kind='post'] {
  background: rgba(245, 158, 11, 0.22);
  color: #fbbf24;
}

#jx-msg-banner .jx-msg-banner-kind[data-kind='like'] {
  background: rgba(244, 63, 94, 0.22);
  color: #fb7185;
}

#jx-msg-banner .jx-msg-banner-kind[data-kind='comment'] {
  background: rgba(99, 102, 241, 0.22);
  color: #a5b4fc;
}

#jx-msg-banner .jx-msg-banner-title {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  color: #e9edef;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#jx-msg-banner .jx-msg-banner-body {
  font-size: 13px;
  font-weight: 400;
  line-height: 1.3;
  color: #8696a0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#jx-msg-banner .jx-msg-banner-close {
  appearance: none;
  border: 0;
  background: transparent;
  cursor: pointer;
  flex: none;
  width: 42px;
  color: #8696a0;
  font-size: 24px;
  line-height: 1;
  padding: 0;
}

#jx-msg-banner .jx-msg-banner-close:hover {
  color: #e9edef;
  background: rgba(255, 255, 255, 0.06);
}

#jx-msg-banner .jx-msg-banner-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 0 12px 12px;
  border-top: 0;
}

#jx-msg-banner .jx-msg-banner-actions[hidden] {
  display: none !important;
}

#jx-msg-banner .jx-msg-banner-reply {
  appearance: none;
  border: 0;
  cursor: pointer;
  background: #00a884;
  color: #fff;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(0, 168, 132, 0.35);
}

#jx-msg-banner .jx-msg-banner-reply:hover {
  background: #029e7a;
}

@media (min-width: 640px) {
  #jx-msg-banner {
    left: 50% !important;
    right: auto !important;
    width: min(420px, calc(100vw - 24px)) !important;
    transform: translate(-50%, -130%);
  }
  #jx-msg-banner.jx-show {
    transform: translate(-50%, 0) !important;
  }
}
