/* ============================================================
   AzurVolt · Mobile AAA · Loaded last, highest specificity.
   Three breakpoints: tablet ≤ 900px, phone ≤ 640px, small ≤ 420px.
   ============================================================ */

/* ============ GLOBAL GUARDS ============ */
html { -webkit-text-size-adjust: 100%; }
body { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

/* Kill any runaway horizontal overflow — root cause of bleed-eye zoom */
html, body { overflow-x: hidden; max-width: 100%; }
img, video, svg { max-width: 100%; height: auto; }
table { max-width: 100%; }

/* Respect safe areas on notched devices */
@supports (padding: max(0px)) {
  body { padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
  .site-header { padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
}

/* Prevent autozoom on iOS form focus */
input, select, textarea { font-size: 16px !important; }
@media (min-width: 641px) {
  input, select, textarea { font-size: inherit !important; }
}

/* ============ TABLET ≤ 900 ============ */
@media (max-width: 900px) {

  /* Header compact */
  .site-header { padding: 8px 14px !important; min-height: 48px; }
  .brand-name { font-size: 0.95rem !important; }

  /* Main container padding */
  .page-main { padding: 14px !important; }
  .section { padding: 28px 18px !important; }
  .section.reveal { padding: 28px 18px !important; border-radius: 16px !important; }

  /* Titles scale down */
  h1, .section-title { font-size: clamp(1.4rem, 5.2vw, 2rem) !important; line-height: 1.2 !important; }
  h2 { font-size: clamp(1.25rem, 4.6vw, 1.6rem) !important; line-height: 1.25 !important; }
  h3, .wp-h3 { font-size: 1.05rem !important; }
  .page-hero-title { font-size: clamp(1.6rem, 5vw, 2.4rem) !important; }
  .landing-hero-title { font-size: clamp(1.8rem, 6vw, 2.8rem) !important; line-height: 1.15 !important; }
  .cfg-title { font-size: 1rem !important; }

  /* Lead paragraphs */
  .lead-p, .landing-lead, .landing-hero-sub {
    font-size: 0.92rem !important;
    line-height: 1.55 !important;
    max-width: 100% !important;
  }
  .section-tag { font-size: 0.65rem !important; padding: 5px 10px; letter-spacing: 1px; }

  /* Landing metrics → 2 cols */
  .landing-metrics { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; padding: 0 14px !important; }
  .landing-metric { padding: 16px 12px !important; }
  .landing-metric-value { font-size: 1.7rem !important; }
  .landing-hero { padding: 52px 18px 60px !important; border-radius: 18px !important; margin: 12px 14px 20px !important; max-width: calc(100% - 28px) !important; }
  .landing-hero-inner { padding: 0; }
  .landing-hero-trust { font-size: 0.72rem !important; }
  .btn-primary-xl, .btn-ghost-xl { padding: 13px 22px !important; font-size: 0.95rem !important; }
  .btn-primary, .btn-ghost { padding: 12px 20px !important; font-size: 0.92rem !important; }

  /* Teaser grids → 1 col */
  .site-teaser-grid,
  .business-teaser-grid,
  .three-step,
  .two-col-grid { grid-template-columns: 1fr !important; }
  .landing-final-cta { padding: 40px 20px !important; margin: 20px 14px !important; border-radius: 18px !important; }
  .landing-final-cta h2 { font-size: 1.6rem !important; }

  /* KPI rows */
  .kpi-row { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
  .kpi-card { padding: 16px 12px !important; }
  .kpi-value { font-size: 1.8rem !important; }
  .kpi-unit { font-size: 0.68rem !important; }
  .kpi-label { font-size: 0.72rem !important; }

  /* Flow container */
  .flow-container { padding: 14px !important; }
  .flow-row { flex-direction: column !important; gap: 8px !important; }
  .flow-box { min-width: 0 !important; width: 100% !important; padding: 12px !important; font-size: 0.85rem !important; }
  .flow-arrow { transform: rotate(90deg); padding: 0 !important; }

  /* Chimie */
  .chem-grid { grid-template-columns: 1fr !important; gap: 14px !important; }
  .chem-card { padding: 20px !important; }

  /* Comparison table */
  .comp-table { font-size: 0.78rem !important; }
  .comp-table th, .comp-table td { padding: 8px 10px !important; }

  /* Bar charts */
  .bar-chart-section { grid-template-columns: 1fr !important; }
  .bar-row { grid-template-columns: 80px 1fr !important; gap: 8px !important; }
  .bar-label { font-size: 0.75rem !important; }

  /* Ecosystem grid */
  .dz-eco-grid { grid-template-columns: 1fr !important; gap: 14px !important; }
  .dz-eco-cat { padding: 18px !important; }
  .dz-eco-stats { grid-template-columns: repeat(2, 1fr) !important; padding: 18px !important; }

  /* Sponsors */
  .sponsors-grid { grid-template-columns: 1fr 1fr !important; gap: 14px !important; }
  .sponsor-card { padding: 16px !important; }
  .sponsor-portrait { width: 84px !important; height: 84px !important; }
  .sponsor-name { font-size: 0.95rem !important; }
  .sponsor-role { font-size: 0.75rem !important; }
  .sponsor-inst { font-size: 0.68rem !important; }
  .sponsor-why { font-size: 0.78rem !important; }
  .sponsors-stats { grid-template-columns: 1fr 1fr !important; padding: 20px !important; }
  .sponsors-stat strong { font-size: 2rem !important; }

  /* Financing cards */
  .fin-grid, .fin-grid-3 { grid-template-columns: 1fr 1fr !important; gap: 12px !important; }
  .fin-card { padding: 16px !important; }
  .fin-title { font-size: 0.88rem !important; }
  .fin-money strong { font-size: 1rem !important; }
  .fin-kpis { grid-template-columns: repeat(2, 1fr) !important; gap: 10px !important; }
  .fin-kpi { padding: 14px 10px !important; }
  .fin-kpi strong { font-size: 1.15rem !important; }
  .fin-summary { padding: 20px !important; border-radius: 16px !important; }
  .fin-summary-title { font-size: 1.05rem !important; text-align: center; }
  .fin-summary-table { font-size: 0.72rem !important; }
  .fin-summary-table td, .fin-summary-table th { padding: 6px 8px !important; }
  .fin-site-picker { padding: 10px !important; gap: 6px !important; }
  .fin-pick { padding: 6px 10px !important; font-size: 0.72rem !important; }

  /* Tax table */
  .fin-tax-table { font-size: 0.72rem !important; }
  .fin-tax-table th, .fin-tax-table td { padding: 6px 8px !important; }
  .fin-tax-total { padding: 16px !important; font-size: 0.85rem !important; }
  .fin-tax-amount { font-size: 1.3rem !important; margin-left: 0 !important; }

  /* Configurator McDo */
  .cfg-grid { grid-template-columns: 1fr !important; gap: 14px !important; max-height: none !important; }
  .cfg-menu { max-height: none !important; overflow: visible !important; }
  .cfg-ticket { position: static !important; max-height: none !important; }

  /* Site dimensioning */
  .site-dim { padding: 18px !important; }
  .site-dim-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 8px !important; }
  .site-dim-kpi { padding: 10px 6px !important; }
  .site-dim-kpi strong { font-size: 1rem !important; }
  .site-dim-kpi span { font-size: 0.6rem !important; }
  .site-dim-split { grid-template-columns: 1fr !important; }
  .site-dim-bar-row { grid-template-columns: 1fr !important; gap: 4px !important; }
  .site-dim-title { font-size: 1.1rem !important; }

  /* Map */
  .dz-map-shell { grid-template-columns: 1fr !important; gap: 14px !important; }
  .dz-leaflet { height: 380px !important; }
  .dz-detail-panel { min-height: 0 !important; padding: 20px !important; }
  .dz-detail-metrics { grid-template-columns: 1fr !important; }
  .dz-detail-title { font-size: 1.4rem !important; }

  /* Salinity */
  .dz-salinity-grid { grid-template-columns: 1fr !important; gap: 12px !important; }
  .dz-sal-card { padding: 16px !important; }
  .dz-sal-val { font-size: 2rem !important; }

  /* Impact */
  .impact-grid { grid-template-columns: 1fr !important; gap: 14px !important; }
  .impact-pillar { padding: 18px !important; }
  .impact-big { font-size: 1.9rem !important; }
  .impact-risks-grid { grid-template-columns: 1fr !important; }

  /* Chiffres infographic */
  .infographic { padding: 18px !important; }
  .ig-hero-row { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
  .ig-hero-item { padding: 16px 12px !important; }
  .ig-hero-num { font-size: 2rem !important; }
  .ig-hero-unit { font-size: 0.72rem !important; }
  .ig-section { padding: 18px !important; margin-bottom: 14px !important; }
  .ig-section-title { font-size: 0.95rem !important; margin-bottom: 12px !important; }
  .ig-flow { grid-template-columns: 1fr !important; gap: 10px !important; }
  .ig-flow-arrow { transform: rotate(90deg); }
  .ig-flow-step { padding: 14px 10px !important; }
  .ig-cycle { grid-template-columns: 1fr !important; }
  .ig-cycle-day, .ig-cycle-night { padding: 16px !important; }
  .ig-money-grid, .ig-social-grid { grid-template-columns: 1fr 1fr !important; gap: 10px !important; }
  .ig-money-card, .ig-social-item { padding: 14px 10px !important; }
  .ig-money-big { font-size: 1.4rem !important; }
  .ig-social-big { font-size: 1.4rem !important; }
  .ig-timeline { flex-wrap: wrap; gap: 8px; overflow-x: auto; }
  .ig-time-step { min-width: 90px !important; font-size: 0.68rem !important; padding: 10px 6px !important; }
  .ig-time-arrow { display: none; }
  .ig-footnote { font-size: 0.68rem !important; padding: 12px !important; }

  /* World map */
  .world-map-wrap { padding: 16px !important; }
  .world-leaflet { height: 360px !important; }
  .world-map-toolbar { flex-direction: column !important; align-items: stretch !important; gap: 10px !important; }
  .world-kpi-grid { grid-template-columns: 1fr 1fr !important; }
  .world-kpi { padding: 16px !important; }
  .world-kpi strong { font-size: 1.5rem !important; }
  .world-pitch-grid { grid-template-columns: 1fr !important; }
  .world-legend { grid-template-columns: 1fr !important; }
  .world-cta { padding: 20px !important; }
  .world-cta h3 { font-size: 1.1rem !important; }

  /* Business/Strategy */
  .dz-strategy-grid { grid-template-columns: 1fr !important; gap: 14px !important; }
  .dz-strategy-card { padding: 18px !important; }
  .dz-roadmap { padding: 20px !important; }
  .dz-roadmap-track { grid-template-columns: 1fr !important; gap: 10px !important; }

  /* Whitepaper */
  .wp-container { padding: 20px !important; }
  .wp-table { font-size: 0.75rem !important; }
  .wp-table th, .wp-table td { padding: 6px 8px !important; }
  .wp-h2 { font-size: 1.25rem !important; }

  /* Contact form */
  .contact-grid { grid-template-columns: 1fr !important; gap: 16px !important; }
  .form-row { grid-template-columns: 1fr !important; gap: 12px !important; }
  .contact-form { padding: 20px !important; }

  /* Teasing page */
  .teasing-main { grid-template-columns: 1fr !important; padding: 16px !important; gap: 24px !important; }
  .teasing-pitch h1 { font-size: clamp(1.6rem, 6.5vw, 2.4rem) !important; }
  .teasing-highlights { grid-template-columns: 1fr 1fr !important; max-width: 100% !important; gap: 8px !important; }
  .teasing-hl { padding: 12px 10px !important; }
  .teasing-hl strong { font-size: 1.1rem !important; }
  .teasing-card { padding: 24px 20px !important; border-radius: 18px !important; }

  /* Admin */
  .admin-user { flex-direction: column !important; align-items: stretch !important; }
  .admin-user-actions { justify-content: flex-start !important; margin-top: 10px; }
  .admin-tabs { flex-wrap: wrap; }
  .admin-tab { padding: 6px 12px !important; font-size: 0.78rem !important; }

  /* Footer */
  .footer-inner { grid-template-columns: 1fr 1fr !important; gap: 24px !important; }
  .footer-bottom { flex-direction: column !important; gap: 12px !important; text-align: center; }

  /* User chip (gate) */
  .azurvolt-chip { top: 8px !important; right: 8px !important; font-size: 0.7rem !important; padding: 3px 8px 3px 3px !important; }
  .azurvolt-chip img { width: 22px !important; height: 22px !important; }

  /* Scroll progress thinner */
  .scroll-progress { height: 2px !important; }
}

/* ============ PHONE ≤ 640 ============ */
@media (max-width: 640px) {
  .landing-metrics { grid-template-columns: 1fr 1fr !important; }
  .kpi-row { grid-template-columns: 1fr 1fr !important; }
  .sponsors-grid { grid-template-columns: 1fr !important; }
  .fin-grid, .fin-grid-3 { grid-template-columns: 1fr !important; }
  .fin-kpis { grid-template-columns: 1fr 1fr !important; }
  .ig-money-grid, .ig-social-grid { grid-template-columns: 1fr !important; }
  .ig-hero-row { grid-template-columns: 1fr !important; }
  .site-dim-grid { grid-template-columns: 1fr 1fr !important; }
  .world-kpi-grid { grid-template-columns: 1fr !important; }
  .sponsors-stats, .dz-eco-stats { grid-template-columns: 1fr 1fr !important; }
  .footer-inner { grid-template-columns: 1fr !important; text-align: center; }
  .footer-tagline { max-width: 100% !important; }

  /* Hero card more compact */
  .hero-card { padding: 24px 20px !important; gap: 10px !important; }
  .hero-title { font-size: clamp(1.6rem, 7vw, 2.4rem) !important; }
  .hero-subtitle { font-size: 0.75rem !important; letter-spacing: 1px !important; }
  .hero-tagline { font-size: 0.7rem !important; padding: 6px 12px !important; }

  /* Buttons stack */
  .landing-cta-row { flex-direction: column !important; align-items: stretch !important; }
  .landing-cta-row .btn-primary-xl,
  .landing-cta-row .btn-ghost-xl,
  .landing-cta-row .btn-primary,
  .landing-cta-row .btn-ghost { width: 100% !important; text-align: center; }

  /* Partners strip wrap */
  .partners-strip { justify-content: stretch !important; }
  .partners-item { font-size: 0.78rem !important; padding: 10px 14px !important; }

  /* Site picker */
  .fin-site-picker { flex-direction: column; align-items: stretch; }
  .fin-pick, .fin-pick-all { width: 100%; }

  /* Page hero */
  .page-hero { padding: 30px 18px !important; border-radius: 16px !important; }
  .page-hero-title { font-size: 1.5rem !important; }
  .page-hero-sub { font-size: 0.88rem !important; }

  /* Impact pillars */
  .impact-pillar p, .risk-card p, .tech-intro-card { font-size: 0.85rem !important; }

  /* Teasing stack + reduce card shadow */
  .teasing-header { padding: 14px 16px !important; }
  .teasing-brand { font-size: 0.95rem !important; }
  .teasing-card { box-shadow: 0 8px 24px rgba(0,0,0,0.3) !important; }
  .panel h2 { font-size: 1.15rem !important; }

  /* Hide less critical nav items in drawer is handled, but keep it readable */
  .main-nav a { font-size: 1rem !important; padding: 14px 16px !important; }

  /* Whitepaper extra compact */
  .wp-h3 { font-size: 0.95rem !important; }
  .wp-p, .wp-list li { font-size: 0.88rem !important; }
  .wp-container { padding: 16px !important; }

  /* PID diagram scrolls horizontally on phones (SVG too big otherwise) */
  .pid-diagram { min-width: 720px; }
  .pid-wrap { overflow-x: auto; padding: 16px !important; }
  .pid-kpi-strip { grid-template-columns: 1fr 1fr !important; }

  /* Cell-diagram on comment-ca-marche */
  .cell-diagram { min-width: 100%; }
  .explainer-core { grid-template-columns: 1fr !important; gap: 16px !important; }
  .aha-callout { padding: 18px !important; }

  /* Timeline 24h */
  .tl-grid { grid-template-columns: 1fr !important; gap: 10px !important; }
  .tl-block { padding: 20px !important; }
  .tl-arrow-v { transform: rotate(0deg); text-align: center; font-size: 0.85rem; }
  .ba-table { font-size: 0.72rem; }
  .ba-table th, .ba-table td { padding: 8px !important; }
}

/* ============ SMALL ≤ 420 ============ */
@media (max-width: 420px) {
  /* Ultra compact */
  .section { padding: 22px 14px !important; }
  .section.reveal { padding: 22px 14px !important; }
  .landing-hero { padding: 40px 14px 50px !important; }
  .landing-metric-value { font-size: 1.5rem !important; }
  .page-hero-title, h1 { font-size: 1.35rem !important; }
  .landing-hero-title { font-size: 1.6rem !important; }
  .btn-primary-xl, .btn-primary { padding: 12px 18px !important; font-size: 0.9rem !important; }
  .ig-hero-num { font-size: 1.7rem !important; }
  .impact-big { font-size: 1.6rem !important; }
  .sponsor-portrait { width: 72px !important; height: 72px !important; }
  .site-header { padding: 6px 12px !important; min-height: 44px; }
  .brand-name { font-size: 0.88rem !important; letter-spacing: 1px !important; }
  .brand-flag, .brand-mark svg { width: 20px !important; height: 20px !important; }
  .btn-cta { display: none; } /* hide Contact button, still accessible via drawer */
  .scroll-progress { height: 2px !important; }

  /* Teasing extra tight */
  .teasing-pitch h1 { font-size: 1.55rem !important; }
  .teasing-hl strong { font-size: 0.95rem !important; }
  .teasing-hl span { font-size: 0.62rem !important; }
  .teasing-gate-notice { font-size: 0.75rem !important; padding: 10px 12px !important; }

  /* Configurator prices take full width below */
  .cfg-item { grid-template-columns: 16px 10px 1fr !important; }
  .cfg-item .cfg-price { grid-column: 1 / -1; justify-self: stretch; text-align: right; margin-top: 4px; }

  /* WP tables — horizontal scroll with indicator */
  .wp-table, .fin-summary-table, .fin-tax-table, .ba-table, .comp-table {
    display: block; overflow-x: auto; white-space: nowrap; font-size: 0.7rem !important;
  }
}

/* ============ 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;
  }
}

/* ============ DARK MODE POLISH ============ */
@media (prefers-color-scheme: dark) {
  /* We don't fully re-theme — keep light brand, but tweak teaser colors */
  .page-body { background: #F4F6FA; }
}

/* ============ TAP TARGET SIZES (a11y) ============ */
@media (hover: none) and (pointer: coarse) {
  a, button, .cfg-item, .nav-toggle, .fin-pick {
    min-height: 44px; /* Apple HIG min touch target */
  }
}
