/* ─── Base mobile (< 480px) ─── */
@media (max-width: 479px) {
  :root {
    --header-pad-top: 0.75rem;
    --header-pad-bottom: 0.5rem;
    --header-bar: 2.75rem;
    --hero-gap-top: 1.75rem;
  }

  .container {
    padding: 0 1rem;
  }

  .section {
    padding: 2.75rem 0;
  }

  .section-title {
    font-size: 1.35rem;
    padding: 0 0.25rem;
  }

  .section-subtitle {
    font-size: 0.9rem;
    margin-bottom: 1.75rem;
    padding: 0 0.25rem;
  }

  .brand {
    font-size: 0.95rem;
    gap: 0.5rem;
  }

  .brand img {
    width: 34px;
    height: 34px;
  }

  .brand span small {
    font-size: 0.6rem;
    letter-spacing: 0.08em;
  }

  .hero-grid {
    padding: 1.5rem 0 2.5rem;
    gap: 1.75rem;
  }

  .hero h1 {
    font-size: 1.35rem;
  }

  .hero-subtitle {
    font-size: 0.9rem;
  }

  .hero-text {
    font-size: 0.85rem;
  }

  .hero-badge {
    font-size: 0.72rem;
    width: 100%;
    text-align: left;
  }

  .hero-image-frame {
    min-height: 280px;
    border-radius: 16px;
  }

  .hero-image-frame img {
    min-height: 280px;
  }

  .stat-number {
    font-size: 2rem;
  }

  .stat-label {
    font-size: 0.8rem;
  }

  .stats-grid {
    gap: 1.25rem;
  }

  .demo-window {
    border-radius: 12px;
    margin: 0 -0.25rem;
  }

  .demo-titlebar span {
    font-size: 0.7rem;
  }

  .demo-sidebar {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.35rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0.75rem;
    border-bottom: 1px solid var(--color-border);
  }

  .demo-sidebar button {
    width: auto;
    flex-shrink: 0;
    white-space: nowrap;
    font-size: 0.78rem;
    padding: 0.5rem 0.65rem;
    border-left: none;
    border: 1px solid var(--color-border);
    background: var(--color-white);
  }

  .demo-sidebar button.active {
    border-color: var(--color-wine);
    border-left: 1px solid var(--color-wine);
  }

  .demo-panel {
    padding: 1rem;
    max-height: none;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .report-grid {
    grid-template-columns: 1fr;
  }

  .bar-chart {
    height: 72px;
  }

  .chain-flow {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }

  .chain-arrow {
    display: block;
    text-align: center;
    transform: rotate(90deg);
    padding: 0.25rem 0;
    font-size: 1rem;
  }

  .chain-step {
    min-width: 0;
    width: 100%;
  }

  .why-grid .why-card:last-child {
    grid-column: span 1;
  }

  .editions-intro-card .btn {
    width: 100%;
    justify-content: center;
  }

  .demo-message {
    font-size: 0.95rem;
    padding: 0 0.25rem;
  }

  .btn-lg {
    padding: 0.9rem 1.25rem;
    font-size: 0.95rem;
  }

  .contact-form {
    padding: 1.25rem;
  }

  .footer-grid {
    text-align: center;
  }

  .footer-grid .brand {
    justify-content: center;
  }
}

/* ─── Mobile large (480px – 767px) ─── */
@media (min-width: 480px) and (max-width: 767px) {
  .hero-image-frame {
    min-height: 340px;
  }

  .hero-image-frame img {
    min-height: 340px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .report-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .chain-flow {
    flex-direction: column;
    align-items: stretch;
  }

  .chain-arrow {
    display: block;
    text-align: center;
    transform: rotate(90deg);
    padding: 0.15rem 0;
  }

  .chain-step {
    min-width: 0;
    width: 100%;
  }

  .demo-sidebar {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.35rem;
  }

  .demo-sidebar button {
    width: 100%;
    font-size: 0.75rem;
  }
}

/* ─── Mobile commun (≤ 767px) ─── */
@media (max-width: 767px) {
  .hero {
    min-height: auto;
  }

  .hero-cta {
    flex-direction: column;
  }

  .hero-cta .btn {
    width: 100%;
    justify-content: center;
    min-height: 44px;
  }

  .hero-content {
    max-width: 100%;
  }

  .hero-grid {
    padding: 2rem 0 3rem;
  }

  .nav-mobile a {
    min-height: 44px;
    display: flex;
    align-items: center;
  }

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

  .demo-body {
    min-height: 320px;
  }

  .demo-cta-block .btn-lg {
    width: 100%;
  }

  .targets-grid .geo-card {
    grid-column: 1 / -1;
  }

  .geo-flags {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
  }

  .contact-urgency {
    margin-left: 0;
    margin-right: 0;
  }

  .liq-table {
    font-size: 0.78rem;
  }

  .balance-table {
    font-size: 0.72rem;
  }

  .pricing-card.featured {
    transform: none;
  }

  .compare-table-wrap::after {
    content: '← Faites défiler →';
    display: block;
    text-align: center;
    font-size: 0.7rem;
    color: var(--color-text-light);
    padding: 0.5rem;
    background: var(--color-bg-alt);
  }
}

/* ─── Tablette (768px – 1023px) ─── */
@media (min-width: 768px) {
  :root {
    --header-pad-top: 1.125rem;
    --header-pad-bottom: 0.875rem;
    --header-bar: 3.5rem;
    --hero-gap-top: 3rem;
  }

  .nav-desktop {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .nav-desktop a.btn-nav-cta {
    display: inline-flex;
  }

  .menu-toggle {
    display: none;
  }

  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
  }

  .stat-number {
    font-size: 2.25rem;
  }

  .hero-grid {
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: center;
    padding: 2.5rem 0 3.5rem;
  }

  .hero-content {
    max-width: 100%;
  }

  .hero-visual {
    order: 0;
  }

  .hero-image-frame {
    min-height: 420px;
    max-width: 100%;
  }

  .hero-image-frame img {
    min-height: 420px;
  }

  .demo-body {
    grid-template-columns: 200px 1fr;
    min-height: 380px;
  }

  .demo-sidebar {
    border-bottom: none;
    border-right: 1px solid var(--color-border);
    display: block;
    overflow: visible;
  }

  .demo-sidebar button {
    width: 100%;
    white-space: normal;
  }

  .demo-nav {
    flex-wrap: wrap;
    overflow-x: visible;
  }

  .why-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .why-grid .why-card:last-child {
    grid-column: span 2;
  }

  .editions-intro {
    grid-template-columns: repeat(2, 1fr);
  }

  .targets-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .targets-grid .geo-card {
    grid-column: 1 / -1;
  }

  .contact-grid {
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
  }

  .footer-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .report-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .chain-flow {
    gap: 0.35rem;
  }

  .chain-step {
    min-width: 110px;
    flex: 1 1 auto;
  }

  .chain-arrow {
    flex-shrink: 0;
  }
}

/* ─── Desktop (1024px+) ─── */
@media (min-width: 1024px) {
  :root {
    --hero-gap-top: 3.5rem;
  }

  .nav-desktop {
    gap: 1.5rem;
    flex-wrap: nowrap;
  }

  .hero {
    min-height: calc(100vh - var(--header-h));
  }

  .hero-grid {
    grid-template-columns: minmax(0, 44%) minmax(0, 56%);
    gap: 2rem 3.5rem;
    padding: 2rem 0 4rem;
    align-items: stretch;
    min-height: calc(100vh - var(--header-h) - 2rem);
  }

  .hero-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-right: 0.5rem;
    max-width: 100%;
  }

  .hero-visual {
    justify-content: stretch;
    align-self: stretch;
    order: 0;
  }

  .hero-image-frame {
    min-height: min(82vh, 880px);
    height: 100%;
    max-width: none;
    border-radius: 24px;
    box-shadow: 0 32px 80px rgba(107, 29, 42, 0.14), 0 12px 40px rgba(0, 0, 0, 0.1);
  }

  .hero-image-frame img {
    min-height: min(82vh, 880px);
  }

  .demo-body {
    grid-template-columns: 240px 1fr;
    min-height: 420px;
  }

  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .report-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .why-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .why-grid .why-card:last-child {
    grid-column: span 1;
  }

  .chain-step {
    min-width: 130px;
  }
}

/* ─── Large desktop (1280px+) ─── */
@media (min-width: 1280px) {
  .container {
    padding: 0 2rem;
  }

  .hero > .container {
    max-width: 1320px;
  }

  .hero-grid {
    grid-template-columns: minmax(0, 40%) minmax(0, 60%);
    gap: 2rem 4rem;
  }

  .hero-image-frame {
    min-height: min(88vh, 920px);
  }

  .hero-image-frame img {
    min-height: min(88vh, 920px);
  }

  .why-grid {
    grid-template-columns: repeat(5, 1fr);
  }

  .nav-desktop {
    gap: 1.75rem;
  }

  .section {
    padding: 5rem 0;
  }
}

/* ─── Très grands écrans ─── */
@media (min-width: 1536px) {
  .hero > .container {
    max-width: 1400px;
  }
}

/* ─── Préférences utilisateur ─── */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .fade-in-up,
  .fade-in-left,
  .fade-in-right {
    opacity: 1 !important;
    animation: none !important;
    transform: none !important;
  }
}

/* ─── Safe area (encoches mobile) ─── */
@supports (padding: max(0px)) {
  .site-header {
    padding-top: max(var(--header-pad-top), env(safe-area-inset-top, 0px));
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
  }

  .container {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }

  @media (min-width: 1280px) {
    .container {
      padding-left: max(2rem, env(safe-area-inset-left));
      padding-right: max(2rem, env(safe-area-inset-right));
    }
  }
}
