/**
 * BPC Triathlon - Styles Mobile Consolides
 * Fusionne mobile-optimizations.css, mobile-advanced.css et mobile-fixes.css
 */

/* ==================== VARIABLES MOBILE ==================== */

:root {
  --bpc-safe-top: env(safe-area-inset-top, 0px);
  --bpc-safe-bottom: env(safe-area-inset-bottom, 0px);
  --bpc-mobile-padding: 16px;
  --bpc-mobile-gap: 18px;
  --bpc-mobile-radius: 14px;
}

@media (max-width: 768px) {
  :root {
    --radius: var(--bpc-mobile-radius);
    --spacing-md: 24px;
    --spacing-sm: 16px;
    --spacing-lg: 48px;
  }
}

/* ==================== BASE MOBILE ==================== */

html, body {
  overflow-x: hidden;
  max-width: 100vw;
}

*, *::before, *::after {
  box-sizing: border-box;
  max-width: 100%;
}

body {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

img, video, iframe {
  max-width: 100%;
  height: auto;
}

h1, h2, h3, h4, h5, h6, p {
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

@supports (padding: max(0px)) {
  body {
    padding-top: var(--bpc-safe-top);
    padding-bottom: var(--bpc-safe-bottom);
  }
}

/* ==================== ZONES TACTILES ==================== */

@media (hover: none) and (pointer: coarse) {
  a, button, input, select, textarea {
    min-height: 44px;
    min-width: 44px;
  }
}

/* ==================== TYPOGRAPHIE MOBILE ==================== */

@media (max-width: 768px) {
  html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
  }

  h1 {
    font-size: clamp(1.75rem, 5vw, 2.5rem) !important;
    line-height: 1.2 !important;
  }

  h2 {
    font-size: clamp(1.5rem, 4vw, 2rem) !important;
    line-height: 1.3 !important;
  }

  h3 {
    font-size: clamp(1.25rem, 3.5vw, 1.5rem) !important;
    line-height: 1.4 !important;
  }

  p {
    font-size: clamp(0.95rem, 2.5vw, 1.1rem);
    line-height: 1.6;
  }
}

/* ==================== GRILLES ET LAYOUTS ==================== */

@media (max-width: 900px) {
  section, .section {
    padding-left: var(--bpc-mobile-padding);
    padding-right: var(--bpc-mobile-padding);
  }

  .grid,
  [style*="grid-template-columns: auto 1fr"],
  [style*="grid-template-columns: 1fr 2fr"],
  [style*="grid-template-columns: 2fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: var(--bpc-mobile-gap);
  }
}

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4,
  .comparison-grid, .pricing-grid,
  .blog-grid, .stats-grid {
    display: flex !important;
    flex-direction: column;
    gap: var(--spacing-md);
  }

  .container {
    padding-left: 16px;
    padding-right: 16px;
  }

  section, .section {
    padding-left: 16px !important;
    padding-right: 16px !important;
    width: 100%;
    max-width: 100vw;
  }
}

/* ==================== HERO SECTION ==================== */

@media (max-width: 900px) {
  .hero-modern {
    margin-block: 32px;
    border-radius: 12px;
    min-height: auto;
  }

  .hero-modern h1 {
    font-size: clamp(28px, 6vw, 40px);
    line-height: 1.1;
  }

  .hero-modern .lead {
    font-size: clamp(16px, 4vw, 19px);
  }

  .hero-modern .actions,
  .cta-actions, .cta-buttons {
    flex-direction: column;
    align-items: stretch;
  }

  .hero-modern .btn,
  .cta-actions .btn,
  .actions .btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 768px) {
  .hero, .hero-modern {
    width: 100%;
    max-width: 100vw;
    overflow: hidden;
    padding: var(--spacing-lg) 0;
  }

  .hero .container,
  .hero-modern .container {
    padding-left: 16px;
    padding-right: 16px;
  }
}

/* ==================== BOUTONS ET CTA ==================== */

@media (max-width: 768px) {
  .btn-primary, .btn-secondary, .btn-ghost,
  .btn, button[type="button"], button[type="submit"] {
    min-height: 48px;
    padding: 12px 24px;
    font-size: 16px;
    border-radius: 12px;
    max-width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .cta-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
  }
}

@media (max-width: 480px) {
  .btn-primary, .btn-hero {
    width: 100%;
    max-width: none;
  }
}

/* ==================== CARTES ==================== */

@media (max-width: 900px) {
  .card, .panel, .box {
    border-radius: var(--bpc-mobile-radius);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  }
}

@media (max-width: 768px) {
  .card, .article-card, .pricing-card,
  .stat-card, .comparison-card {
    border-radius: 12px;
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    width: 100%;
    max-width: 100%;
  }

  .card img, .article-card img {
    width: 100%;
    height: auto;
    object-fit: cover;
    border-radius: 8px;
  }
}

/* ==================== HEADER ==================== */

@media (max-width: 768px) {
  .site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 100vw;
    overflow: hidden;
  }

  .site-header .container {
    padding: 12px 16px;
  }

  .brand .logo, .brand .logo img {
    width: 50px;
    height: 50px;
  }

  .header-menu-toggle {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .header-cta {
    display: none !important;
  }

  .brand {
    max-width: calc(100vw - 120px);
  }

  .brand strong, .brand .note {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* ==================== MENU MOBILE ==================== */

@media (max-width: 768px) {
  .sliding-menu {
    right: -105%;
    width: min(100%, 420px);
    max-width: 100%;
    padding-bottom: calc(24px + var(--bpc-safe-bottom));
    -webkit-overflow-scrolling: touch;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.16);
  }

  .sliding-menu.active {
    right: 0;
  }

  .sliding-menu-header {
    padding: 24px;
    padding-top: calc(20px + var(--bpc-safe-top));
  }

  .sliding-menu-header h3 {
    font-size: 18px;
  }

  .sliding-menu-close {
    width: 42px;
    height: 42px;
    font-size: 22px;
  }

  .sliding-menu-content {
    padding: 24px 16px;
    max-width: 100%;
  }

  .sliding-menu-section {
    margin-bottom: 32px;
  }

  .sliding-menu-nav a {
    padding: 14px 16px;
    border-radius: 14px;
    min-height: 52px;
    font-size: 16px;
    gap: 14px;
    word-wrap: break-word;
    white-space: normal;
  }

  .sliding-menu-nav .icon {
    font-size: 20px;
    width: 24px;
  }

  .sliding-menu-stages {
    padding: 18px;
    border-radius: 14px;
  }

  .stage-card {
    padding: 16px;
    border-radius: 12px;
  }

  .sliding-menu-contact {
    padding: 18px;
    border-radius: 14px;
  }

  .menu-overlay {
    backdrop-filter: blur(2px);
  }

  body.menu-open {
    overflow: hidden;
    height: 100vh;
    touch-action: none;
  }
}

/* ==================== MENU TOGGLE ==================== */

@media (max-width: 768px) {
  .menu-toggle {
    position: fixed;
    bottom: 24px !important;
    right: 16px !important;
    left: auto !important;
    width: 56px !important;
    height: 56px !important;
    z-index: 2200;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    margin: 0;
    transform: none;
  }

  body:has(.mobile-sticky-cta) .menu-toggle,
  body:has(.fab-cta) .menu-toggle {
    bottom: 90px !important;
  }
}

@media (max-width: 480px) {
  .menu-toggle {
    width: 52px !important;
    height: 52px !important;
    bottom: 20px !important;
    right: 12px !important;
  }

  body:has(.mobile-sticky-cta) .menu-toggle,
  body:has(.fab-cta) .menu-toggle {
    bottom: 80px !important;
  }
}

/* ==================== STICKY CTA ==================== */

@media (max-width: 900px) {
  .fab-cta {
    right: 14px;
    bottom: calc(16px + var(--bpc-safe-bottom));
  }
}

@media (max-width: 768px) {
  .mobile-sticky-cta, .fab-cta {
    position: fixed;
    left: 16px !important;
    right: 16px !important;
    bottom: 16px !important;
    width: auto !important;
    max-width: calc(100vw - 32px) !important;
    z-index: 1800;
    display: inline-flex;
    justify-content: center;
    margin: 0;
    padding: 14px 24px;
    transform: none;
  }
}

@media (max-width: 480px) {
  .mobile-sticky-cta, .fab-cta {
    left: 12px !important;
    right: 12px !important;
    bottom: 12px !important;
    font-size: 15px;
    padding: 12px 20px;
  }
}

/* ==================== TABLEAUX ==================== */

@media (max-width: 768px) {
  table {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    display: block;
  }

  .dates-table thead {
    display: none;
  }

  .dates-table, .dates-table tbody,
  .dates-table tr, .dates-table td {
    display: block;
    width: 100%;
  }

  .dates-table tr {
    margin-bottom: 16px;
    border: 1px solid var(--bpc-border-light, #e0e0e0);
    border-radius: 12px;
    padding: 16px;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  }

  .dates-table td {
    padding: 8px 0;
    border: none;
    text-align: left !important;
  }

  .dates-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--bpc-primary);
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    text-transform: uppercase;
  }

  .dates-table-container {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* ==================== IMAGES ET GALERIE ==================== */

@media (max-width: 768px) {
  img {
    max-width: 100%;
    height: auto;
    display: block;
  }

  .carousel-slide img {
    aspect-ratio: 4/3;
    object-fit: cover;
    width: 100%;
  }

  .gallery-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  .gallery-item img {
    aspect-ratio: 16/9;
    width: 100%;
  }
}

/* ==================== FORMULAIRES ==================== */

@media (max-width: 768px) {
  input, textarea, select {
    min-height: 48px;
    font-size: 16px;
    padding: 12px 16px;
    border-radius: 8px;
    width: 100%;
    max-width: 100%;
    -webkit-appearance: none;
    appearance: none;
  }

  label {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    display: block;
  }
}

/* ==================== FOOTER ==================== */

@media (max-width: 768px) {
  footer {
    padding: 40px 16px 24px 16px !important;
    overflow-x: hidden;
  }

  footer .container {
    padding: 0 !important;
    max-width: 100%;
  }

  footer > .container > div[style*="grid"],
  footer .container > div[style*="grid-template-columns"] {
    display: flex !important;
    flex-direction: column !important;
    gap: 32px !important;
  }

  footer h3 {
    font-size: 18px !important;
    margin-bottom: 16px !important;
  }

  footer ul {
    padding: 0 !important;
    margin: 0 !important;
    list-style: none;
  }

  footer li {
    margin-bottom: 12px !important;
    line-height: 1.6;
  }

  footer a {
    display: inline-block;
    padding: 4px 0;
    font-size: 15px;
  }

  footer p {
    line-height: 1.6;
    margin-bottom: 12px;
    font-size: 15px;
  }
}

@media (max-width: 480px) {
  footer {
    padding: 32px 12px 20px 12px !important;
  }

  footer h3 {
    font-size: 16px !important;
  }

  footer a, footer p {
    font-size: 14px;
  }
}

/* ==================== BADGES ET TAGS ==================== */

@media (max-width: 768px) {
  .badge, .badge-accent, .article-tag, .level-badge {
    font-size: 12px;
    padding: 6px 12px;
    border-radius: 20px;
    white-space: nowrap;
  }

  .chips {
    gap: 10px;
  }
}

/* ==================== MODALS ==================== */

@media (max-width: 768px) {
  .modal, .popup {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    margin: 0;
  }

  .menu-overlay, .modal-overlay {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
  }
}

/* ==================== SAFE ZONES ==================== */

@media (max-width: 768px) {
  body {
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
    padding-bottom: 100px;
  }

  body:has(.mobile-sticky-cta),
  body:has(.fab-cta) {
    padding-bottom: 140px;
  }
}

/* ==================== ACCESSIBILITE ==================== */

@media (max-width: 768px) {
  a, button, input[type="checkbox"],
  input[type="radio"], .carousel-dot, .carousel-btn {
    min-width: 44px;
    min-height: 44px;
    padding: 12px;
  }

  a:focus-visible, button:focus-visible {
    outline: 3px solid var(--bpc-accent);
    outline-offset: 2px;
    border-radius: 4px;
  }

  * {
    -webkit-tap-highlight-color: transparent;
  }
}

/* ==================== PERFORMANCE ==================== */

@media (max-width: 768px) {
  *, *::before, *::after {
    animation-duration: 0.3s !important;
    transition-duration: 0.3s !important;
  }

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

  .carousel-container, .sliding-menu {
    will-change: transform;
  }
}

/* ==================== PETITS ECRANS ==================== */

@media (max-width: 540px) {
  .hero-modern .hero-inner {
    padding-inline: var(--bpc-mobile-padding);
  }

  .card .title {
    font-size: 22px;
  }

  .card .meta {
    font-size: 14px;
  }

  .badge-price {
    font-size: 15px;
  }

  .sliding-menu-nav a {
    font-size: 15px;
  }
}

@media (max-width: 380px) {
  h1 {
    font-size: 1.5rem;
  }

  h2 {
    font-size: 1.25rem;
  }

  .btn-primary {
    font-size: 14px;
    padding: 10px 16px;
  }

  .container {
    padding-left: 12px;
    padding-right: 12px;
  }
}

/* ==================== LANDSCAPE ==================== */

@media (max-width: 768px) and (orientation: landscape) {
  .hero {
    padding: var(--spacing-md) 0;
  }

  .comparison-grid, .pricing-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-sm);
  }
}

/* ==================== PRINT ==================== */

@media print {
  .menu-toggle, .sliding-menu, .mobile-sticky-cta,
  .carousel-btn, .header-menu-toggle {
    display: none;
  }

  * {
    background: white;
    color: black;
  }

  a {
    text-decoration: underline;
  }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
  }
}
