/* ============================================
   WINNART — LAYOUT 3 COLONNES (10/80/10)
   Style : Flashscore-like, responsive
   ============================================ */

/* === VARIABLES === */
:root {
  --sidebar-width: clamp(100px, 10vw, 180px);
  --sidebar-gap: clamp(12px, 1.5vw, 24px);
  --content-max: 1200px;
  --banner-transition: opacity 0.5s ease;
  --sidebar-bg: transparent;
  --sidebar-sticky-top: 100px;
  --mobile-nav-speed: 0.3s;
}

/* === FLUIDITÉ GLOBALE (anti flash blanc, GPU acceleration) === */
* {
  -webkit-tap-highlight-color: transparent;
}

body {
  background-color: var(--bg-body, #f5f5f5);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

img, video, iframe, .banner-img {
  aspect-ratio: auto;
  content-visibility: auto;
  contain-intrinsic-size: 1px 500px;
}

/* === GRILLE PRINCIPALE 3 COLONNES === */
.page-layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr var(--sidebar-width);
  gap: var(--sidebar-gap);
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 0 clamp(8px, 2vw, 24px);
  min-height: 60vh;
  position: relative;
}

/* Colonne centrale */
.content-center {
  min-width: 0; /* évite le débordement Grid */
  width: 100%;
}

.content-center > * {
  max-width: 100%;
}

/* === SIDEBARS === */
.sidebar-left,
.sidebar-right {
  position: sticky;
  top: var(--sidebar-sticky-top);
  height: fit-content;
  max-height: calc(100vh - var(--sidebar-sticky-top) - 20px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(26,43,109,0.15) transparent;
  padding: 8px 0;
  /* GPU acceleration — évite les reflows et flashs blancs */
  will-change: transform;
  transform: translateZ(0);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  /* Contient le layout de chaque widget */
  contain: layout style;
}

.sidebar-left::-webkit-scrollbar,
.sidebar-right::-webkit-scrollbar {
  width: 3px;
}

.sidebar-left::-webkit-scrollbar-thumb,
.sidebar-right::-webkit-scrollbar-thumb {
  background: rgba(26,43,109,0.15);
  border-radius: 4px;
}

/* === WIDGETS SIDEBAR — Système unifié === */
.sidebar-left,
.sidebar-right {
  z-index: 10;
}

/* Widget = bloc cohérent dans la sidebar */
.sidebar-widget {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px 8px;
  margin-bottom: 10px;
  transition: box-shadow 0.2s ease;
}

.sidebar-widget:hover {
  box-shadow: 0 2px 12px rgba(0,0,0,0.04);
}

/* Titre de widget */
.sidebar-widget-title {
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--gray);
  text-align: center;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-color);
}

/* Contenu du widget */
.sidebar-widget-content {
  font-size: 0.65rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* Conteneur bannières */
.banner-rotator {
  width: 100%;
  max-width: 120px;
  margin: 0 auto;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  position: relative;
}

.banner-rotator-wrapper {
  position: relative;
  width: 100%;
  line-height: 0;
}

.banner-rotator-wrapper a {
  display: block;
  width: 100%;
  height: 100%;
}

.banner-img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 10px;
}

.banner-link {
  display: block;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border-radius: 10px;
  overflow: hidden;
}

.banner-link:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0,0,0,0.15);
}

.banner-link:active {
  transform: translateY(0);
}

/* Indicateur de défilement (dots) */
.banner-dots {
  display: flex;
  justify-content: center;
  gap: 4px;
  padding: 6px 0 0;
  position: absolute;
  bottom: 6px;
  left: 0;
  right: 0;
  z-index: 2;
}

.banner-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,255,255,0.4);
  transition: background 0.3s ease, transform 0.3s ease;
  cursor: default;
}

.banner-dot.active {
  background: #fff;
  transform: scale(1.3);
}

/* === SIDEBAR GAUCHE : Widgets spécifiques === */

/* Milena card (sans bordure, fond dégradé) */
.milena-sidebar-card {
  background: linear-gradient(135deg, var(--primary), #0f1a45);
  border-radius: 12px;
  padding: 14px 12px;
  text-align: center;
  margin-bottom: 10px;
  position: relative;
  overflow: hidden;
}

.milena-sidebar-card::before {
  content: '✦';
  position: absolute;
  top: -8px;
  right: -4px;
  font-size: 3rem;
  color: rgba(232,119,34,0.1);
  transform: rotate(15deg);
}

.milena-sidebar-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  margin: 0 auto 8px;
  display: block;
  border: 2px solid var(--secondary);
  object-fit: cover;
}

.milena-sidebar-name {
  font-size: 0.7rem;
  font-weight: 700;
  color: #fff;
}

.milena-sidebar-role {
  font-size: 0.55rem;
  color: rgba(255,255,255,0.7);
  margin-bottom: 8px;
}

.milena-sidebar-btn {
  display: inline-block;
  padding: 5px 16px;
  background: var(--secondary);
  color: #fff;
  border-radius: 20px;
  font-size: 0.6rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s ease;
}

.milena-sidebar-btn:hover {
  background: #d4691e;
}

/* Micro stats */
.sidebar-micro-stats {
  text-align: center;
}

.sidebar-micro-stats .stat-row {
  display: flex;
  justify-content: space-around;
  gap: 4px;
}

.sidebar-micro-stats .stat-item {
  flex: 1;
  padding: 4px;
}

.sidebar-micro-stats .stat-value {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.2;
}

.sidebar-micro-stats .stat-label {
  font-size: 0.5rem;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 2px;
}

/* Réseaux sociaux */
.sidebar-social {
  display: flex;
  justify-content: center;
  gap: 6px;
}

.sidebar-social a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--light);
  color: var(--primary);
  font-size: 0.8rem;
  text-decoration: none;
  transition: all 0.2s ease;
}

.sidebar-social a:hover {
  background: var(--primary);
  color: #fff;
  transform: translateY(-2px);
}

/* === SIDEBAR DROITE : Widgets spécifiques === */

/* Bannières partenaires (fallback si pas AdSense) */
.partner-banner {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 12px 10px;
  text-align: center;
  margin-bottom: 8px;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.partner-banner:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.06);
}

.partner-icon {
  font-size: 1.3rem;
  margin-bottom: 4px;
}

.partner-title {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 2px;
}

.partner-desc {
  font-size: 0.6rem;
  color: var(--gray);
  line-height: 1.3;
}

.partner-cta {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 14px;
  background: var(--secondary);
  color: #fff;
  border-radius: 20px;
  font-size: 0.6rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.2s ease;
}

.partner-cta:hover {
  background: var(--primary);
}

.partner-methods {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin-top: 6px;
}

.partner-methods span {
  display: inline-block;
  padding: 2px 6px;
  background: var(--light);
  border-radius: 4px;
  font-size: 0.5rem;
  font-weight: 700;
  color: var(--primary);
}

/* Bloc partenaire (location) */
.partner-spot {
  background: linear-gradient(135deg, var(--bg-card), #fef5ee);
  border: 2px solid var(--secondary);
  border-radius: 12px;
  padding: 16px 12px;
  text-align: center;
  margin-top: 12px;
  position: relative;
  box-shadow: 0 4px 16px rgba(232,119,34,0.12);
}

.partner-spot-badge {
  display: inline-block;
  background: var(--secondary);
  color: #fff;
  font-size: 0.55rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 3px 10px;
  border-radius: 10px;
  margin-bottom: 8px;
}

.partner-spot-title {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 6px;
}

.partner-spot-offer {
  font-size: 1rem;
  font-weight: 800;
  color: var(--secondary);
  margin-bottom: 4px;
}

.partner-spot-desc {
  font-size: 0.6rem;
  color: var(--gray);
  line-height: 1.5;
  margin-bottom: 8px;
}

.partner-spot-features {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 10px;
}

.partner-spot-features span {
  font-size: 0.55rem;
  color: var(--dark);
  opacity: 0.8;
}

.partner-spot-cta {
  display: inline-block;
  padding: 7px 18px;
  background: #25D366;
  color: #fff;
  border-radius: 20px;
  font-size: 0.65rem;
  font-weight: 700;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.partner-spot-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37,211,102,0.3);
}

.partner-spot-foot {
  font-size: 0.5rem;
  color: var(--gray);
  margin-top: 8px;
}

.partner-spot-foot a {
  color: var(--primary);
  text-decoration: none;
}

/* === GOOGLE ADSENSE PLACEHOLDER === */
.adsense-container {
  width: 100%;
  min-height: 100px;
  margin: 8px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--light);
  border: 1px dashed var(--border-color);
  border-radius: 8px;
  overflow: hidden;
}

.adsense-container ins {
  display: block;
}

.adsense-placeholder {
  text-align: center;
  padding: 12px 8px;
  color: var(--gray);
  font-size: 0.6rem;
  line-height: 1.5;
}

.adsense-placeholder strong {
  display: block;
  color: var(--primary);
  font-size: 0.7rem;
}

.adsense-label {
  font-size: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gray);
  text-align: center;
  margin: 8px 0 4px;
  opacity: 0.6;
}



/* === RESPONSIVE — TABLETTE (768-1024px) === */
@media (max-width: 1100px) {
  .page-layout {
    grid-template-columns: 100px 1fr 100px;
    gap: 10px;
  }

  .banner-rotator {
    max-width: 90px;
  }
}

@media (max-width: 900px) {
  .page-layout {
    grid-template-columns: 80px 1fr 80px;
    gap: 6px;
  }

  .banner-rotator {
    max-width: 70px;
  }
}

/* === RESPONSIVE — MOBILE (< 768px) === */
@media (max-width: 767px) {
  :root {
    --sidebar-sticky-top: 80px;
  }

  .page-layout {
    grid-template-columns: 1fr;
    gap: 0;
    padding: 0;
    /* Stabilise le layout pendant le scroll */
    content-visibility: auto;
    contain-intrinsic-size: 1px 5000px;
  }

  .sidebar-left,
  .sidebar-right {
    position: relative !important;
    top: auto !important;
    max-height: none !important;
    overflow: visible !important;
    padding: 0 16px 16px;
    margin-bottom: 0;
    /* GPU layer iOS */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .sidebar-left {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 10px 12px;
    background: var(--bg-body);
    border-bottom: 1px solid var(--border-color);
  }

  .sidebar-left .sidebar-widget { margin-bottom: 0; }

  .sidebar-left .sidebar-widget:first-child { display: none; } /* Milena en bubble */

  .sidebar-left .banner-rotator { max-width: none; width: 100%; }

  .sidebar-left .banner-rotator { border-radius: 6px; }

  .sidebar-right {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 10px 12px;
    background: var(--light);
    border-top: 1px solid var(--border-color);
  }

  .sidebar-right .sidebar-widget { margin-bottom: 0; }

  .sidebar-right .sidebar-widget:last-child { grid-column: 1 / -1; } /* Partner spot full width */

  .sidebar-right .adsense-container { min-height: 80px; }

  /* Bannières horizontales sur mobile */
  .banner-img {
    width: 100%;
    height: auto;
  }

  .banner-rotator {
    border-radius: 6px;
  }

  /* Hero padding fix on mobile */
  .content-center .hero {
    padding-left: 16px;
    padding-right: 16px;
  }

  .content-center .products {
    padding-left: 16px;
    padding-right: 16px;
  }
}

/* === RESPONSIVE — PETIT MOBILE (< 480px) === */
@media (max-width: 480px) {
  .sidebar-left {
    grid-template-columns: repeat(2, 1fr);
    padding: 8px 10px;
    gap: 6px;
  }

  .sidebar-left .sidebar-widget { padding: 8px 6px; }

  .sidebar-right {
    grid-template-columns: 1fr 1fr;
    padding: 8px 10px;
    gap: 6px;
  }

  .sidebar-right .sidebar-widget { padding: 8px 6px; }

  .sidebar-left .banner-rotator { max-width: none; }
}

/* === PRINT === */
@media print {
  .sidebar-left,
  .sidebar-right {
    display: none !important;
  }

  .page-layout {
    grid-template-columns: 1fr;
  }
}

/* === ACCESSIBILITÉ (prefers-reduced-motion) === */
@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;
  }

  .banner-rotator-wrapper,
  .banner-link,
  .partner-banner {
    transition: none !important;
  }

  .banner-rotator-wrapper {
    opacity: 1 !important;
  }

  .reveal-on-scroll {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }

  .skeleton {
    animation: none !important;
    background: var(--light) !important;
  }

  .reading-progress {
    animation: none !important;
    scale: none !important;
    display: none !important;
  }
}

/* === ANIMATIONS === */
@keyframes bannerFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.banner-rotator-wrapper {
  animation: bannerFadeIn 0.4s ease;
}

/* === BARRE DE PROGRESSION DE LECTURE (scroll-driven) === */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--secondary), var(--primary));
  z-index: 9999;
  transform-origin: left center;
  scale: 0 1;
  animation: progress-grow linear;
  animation-timeline: scroll(root block);
}

@keyframes progress-grow {
  from { scale: 0 1; }
  to { scale: 1 1; }
}

/* === RÉVÉLATION AU SCROLL (view timeline) === */
.reveal-on-scroll {
  animation: fade-up linear both;
  animation-timeline: view();
  animation-range: entry 0% cover 30%;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* === ENTRÉE DES ÉLÉMENTS (@starting-style) === */
.toast {
  transition: opacity 300ms, transform 300ms, display 300ms allow-discrete;
}

@starting-style {
  .toast {
    opacity: 0;
    transform: translateY(-12px);
  }
}

.toast.hidden { display: none; }

/* === MICRO-INTERACTIONS BOUTONS (ui-animations skill) === */
.btn:active,
button:active,
.cta-button:active {
  transform: scale(0.96);
  transition: transform 100ms ease-out;
}

.btn, button, .cta-button {
  transition: transform 150ms ease-out, background-color 150ms ease-out, box-shadow 150ms ease-out;
}

/* === SQUELETTE CHARGEMENT === */
.skeleton {
  background: linear-gradient(90deg, var(--light) 25%, #e8ecf4 50%, var(--light) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: 8px;
}

@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -200% 0; }
}

.skeleton-card {
  height: 280px;
  border-radius: 16px;
}

.skeleton-text {
  height: 14px;
  margin-bottom: 8px;
  width: 80%;
}

.skeleton-text:last-child { width: 60%; }

/* === VIEW TRANSITIONS API (transitions entre pages) === */
@view-transition {
  navigation: auto;
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 300ms;
  animation-timing-function: ease-out;
}

::view-transition-old(root) {
  animation-name: fade-out;
}

::view-transition-new(root) {
  animation-name: fade-in;
}

@keyframes fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 0.01ms !important;
  }
}

/* === DARK MODE SUPPORT === */
@media (prefers-color-scheme: dark) {
  .sidebar-left,
  .sidebar-right {
    --sidebar-bg: rgba(26,43,109,0.05);
  }

  .partner-banner {
    background: rgba(255,255,255,0.03);
    border-color: rgba(255,255,255,0.06);
  }

  .adsense-container {
    background: rgba(255,255,255,0.03);
    border-color: rgba(255,255,255,0.06);
  }

  .sidebar-micro-stats {
    background: rgba(255,255,255,0.03);
    border-color: rgba(255,255,255,0.06);
  }
}
