/* Responsive overrides — Mathilde Lazzari site
   Strategy: keep the React inline styles for desktop defaults,
   override grids/typography/layouts via media queries here. */

html { scroll-behavior: smooth; }

/* Accessibility — focus ring */
:focus-visible {
  outline: 2px solid var(--terracotta);
  outline-offset: 3px;
  border-radius: 2px;
}
button:focus:not(:focus-visible) { outline: none; }

/* Images fill their container without aspect ratio drama */
img { max-width: 100%; height: auto; }

/* Approach — "créer ensemble" cards lift on hover */
.d2v2-create-card:hover { transform: translateY(-8px); }
@media (hover: none) { .d2v2-create-card:hover { transform: none; } }

/* Flat cards — clean lift on hover, no shadow */
.d2v2-mcard { transition: transform .4s cubic-bezier(.2,.7,.2,1), background-color .3s ease; }
.d2v2-mcard:hover { transform: translateY(-4px); }
@media (hover: none) { .d2v2-mcard:hover { transform: none; } }
/* Comparison rows highlight on hover */
.d2v2-cmp-row { transition: background .25s ease; }
.d2v2-cmp-row:hover { background: rgba(26,21,18,0.04); }

/* Let very long words break only when they would overflow (no forced hyphenation) */
h1, h2, h3, p, div, span { overflow-wrap: break-word; }

/* ==========================================================
   TABLET ≤ 1100px — nav burger kicks in (JS) + small reflow
   ========================================================== */
@media (max-width: 1100px) {
  section[style*="padding"]:not(.d2v2-bleed):not(.d2v2-hero),
  article[style*="padding"]:not(.d2v2-bleed) {
    padding-left: clamp(20px, 4vw, 48px) !important;
    padding-right: clamp(20px, 4vw, 48px) !important;
  }
  footer[style*="padding"] {
    padding-left: clamp(20px, 4vw, 48px) !important;
    padding-right: clamp(20px, 4vw, 48px) !important;
  }
  /* Hero fills the visible viewport minus the now-opaque mobile nav */
  .d2v2-hero { height: calc(100dvh - 70px) !important; min-height: 480px !important; }
  /* Full-bleed sections keep their intrinsic horizontal padding (0) */
  .d2v2-bleed { padding-left: 0 !important; padding-right: 0 !important; }
  .d2v2-bleed > div[style*="padding"]:not([class]) {
    padding-left: clamp(20px, 4vw, 48px) !important;
    padding-right: clamp(20px, 4vw, 48px) !important;
  }
}

/* ==========================================================
   TABLET ≤ 960px
   ========================================================== */
@media (max-width: 960px) {
  /* Stack ANONYMOUS grids (no className) — both the section/article/footer
     itself and its descendants. Named grids (.d2v2-* / .cfg-*) handle
     themselves below so they don't fight specificity with !important. */
  section[style*="grid-template-columns"]:not([class]),
  article[style*="grid-template-columns"]:not([class]),
  footer[style*="grid-template-columns"]:not([class]),
  section *[style*="grid-template-columns"]:not([class]):not([data-shell-nav]),
  article *[style*="grid-template-columns"]:not([class]):not([data-shell-nav]),
  footer *[style*="grid-template-columns"]:not([class]):not([data-shell-nav]) {
    grid-template-columns: 1fr !important;
    gap: 28px !important;
  }

  /* Headings — cap large display typography at tablet */
  h1 { font-size: clamp(52px, 10vw, 96px) !important; line-height: 0.95 !important; letter-spacing: -0.035em !important; }
  h2 { font-size: clamp(40px, 8vw, 72px) !important; line-height: 0.98 !important; letter-spacing: -0.03em !important; }
  h3 { font-size: clamp(24px, 5vw, 44px) !important; }

  /* Cap large inline font-sizes on div/p (non-heading display text) */
  [style*="font-size: 160px"] { font-size: clamp(44px, 11vw, 96px) !important; line-height: 0.95 !important; }
  [style*="font-size: 140px"] { font-size: clamp(42px, 10vw, 84px) !important; line-height: 0.95 !important; }
  [style*="font-size: 128px"] { font-size: clamp(40px, 10vw, 80px) !important; line-height: 0.95 !important; }
  [style*="font-size: 120px"] { font-size: clamp(40px, 9vw, 72px) !important; line-height: 0.95 !important; }
  [style*="font-size: 100px"] { font-size: clamp(36px, 8vw, 64px) !important; }
  [style*="font-size: 96px"] { font-size: clamp(36px, 8vw, 64px) !important; }
  [style*="font-size: 88px"] { font-size: clamp(32px, 7vw, 60px) !important; }
  [style*="font-size: 80px"] { font-size: clamp(32px, 7vw, 56px) !important; }
  [style*="font-size: 76px"] { font-size: clamp(28px, 6.5vw, 52px) !important; }
  [style*="font-size: 72px"] { font-size: clamp(28px, 6vw, 52px) !important; }
  [style*="font-size: 64px"] { font-size: clamp(26px, 5.5vw, 48px) !important; }
  [style*="font-size: 56px"] { font-size: clamp(22px, 5vw, 44px) !important; }
  [style*="font-size: 48px"] { font-size: clamp(22px, 4.5vw, 40px) !important; }
  [style*="font-size: 44px"] { font-size: clamp(20px, 4vw, 36px) !important; }
  [style*="font-size: 40px"] { font-size: clamp(20px, 4vw, 34px) !important; }

  /* Home mosaic — keep 2 cols + auto rows */
  .d2v2-mosaic {
    grid-template-columns: 1fr 1fr !important;
    grid-template-rows: auto !important;
  }
  .d2v2-mosaic > * { height: 240px !important; }
  .d2v2-mosaic > :first-child { grid-row: span 2 !important; height: 100% !important; min-height: 480px; }

  /* Process timeline — remove central line, stack left-aligned */
  .d2v2-process-line { display: none !important; }
  .d2v2-process-row {
    grid-template-columns: 1fr !important;
    gap: 12px !important;
    padding: 40px 0 !important;
    border-top: 1px solid var(--line) !important;
  }
  .d2v2-process-row > :empty { display: none !important; }
  .d2v2-process-row > div:first-child { text-align: left !important; }
  .d2v2-process-row > div[style*="flex-direction: column"] {
    order: -1 !important;
    align-items: flex-start !important;
  }

  /* About bio grid + chapters */
  .d2v2-bio-grid {
    grid-template-columns: 1fr !important;
    gap: 48px !important;
  }
  .d2v2-bio-chapter {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
    padding: 40px 0 !important;
  }
  .d2v2-bio-chapter > * { text-align: left !important; }

  /* Approach pillars / project rows — stack image under text */
  .d2v2-approach-row {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 28px !important;
    padding: 48px 0 !important;
  }
  /* Project row image keeps its aspect-ratio height when stacked */
  .d2v2-projrow-img { flex: none !important; width: 100% !important; }
  /* Projects — one per line stacks (image above info) */
  .d2v2-projline { grid-template-columns: 1fr !important; gap: 18px !important; padding: 28px 0 !important; }

  /* Contact grid */
  .d2v2-contact-grid {
    grid-template-columns: 1fr !important;
    gap: 48px !important;
  }
  .d2v2-contact-grid > :nth-child(2) > div { position: static !important; }

  /* Materials grid (project tab) */
  section [style*="repeat(4, 1fr)"],
  article [style*="repeat(4, 1fr)"] {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Récit columns */
  .d2v2-recit-columns {
    column-count: 1 !important;
  }

  /* Projects mosaic — 2 columns on tablet */
  .d2v2-proj-grid {
    grid-template-columns: 1fr 1fr !important;
  }

  /* Project gallery — 2 columns on tablet */
  .d2v2-gallery { column-count: 2 !important; }

  /* Configurator — begin shrinking illustration panel */
  .cfg-modal {
    grid-template-columns: 280px 1fr !important;
    height: 88dvh !important;
    max-height: 820px !important;
  }
  .cfg-illus { padding: 28px !important; }
  .cfg-illus > div[style*="font-size: 64px"] { font-size: 40px !important; }
  .cfg-illus svg { width: 140px !important; height: 160px !important; }
}

/* ==========================================================
   SMALL TABLET ≤ 768px
   ========================================================== */
@media (max-width: 768px) {
  /* Offer comparison — stack the pricing cards */
  .d2v2-compare { grid-template-columns: 1fr !important; }

  /* Accompagnement — stack constat text + image */
  .d2v2-constat-row { grid-template-columns: 1fr !important; gap: 32px !important; }

  /* Accompagnement — schéma 360° : vertical timeline on mobile */
  .d2v2-360-row { flex-direction: column !important; gap: 22px !important; }
  .d2v2-360-node { flex-direction: row !important; gap: 14px !important; justify-content: flex-start !important; }
  .d2v2-360-line { display: none !important; }

  /* Press — hide table header, stack cells as card */
  .d2v2-press-head { display: none !important; }
  .d2v2-press-row {
    grid-template-columns: 1fr !important;
    gap: 6px !important;
    padding: 20px 0 !important;
  }
  .d2v2-press-row > :last-child { display: none !important; }

  /* Journal rows & lead */
  .d2v2-journal-row,
  .d2v2-journal-lead {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  .d2v2-journal-row > :last-child { height: 220px !important; order: -1; }
  .d2v2-journal-lead > :last-child { height: 260px !important; }

  /* Contact form row */
  .d2v2-form-row {
    grid-template-columns: 1fr !important;
    gap: 28px !important;
  }

  /* Footer grid */
  footer > div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
    gap: 40px !important;
  }

  /* Configurator — modal becomes fullscreen, illus band on top */
  .cfg-overlay { padding: 0 !important; }
  .cfg-modal {
    width: 100% !important;
    max-width: none !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    grid-template-columns: 1fr !important;
    grid-template-rows: auto 1fr !important;
  }
  .cfg-illus {
    padding: 24px !important;
    min-height: 160px;
  }
  .cfg-illus > div:last-of-type { position: static !important; margin-top: 16px; }
  .cfg-illus > div[style*="font-size: 64px"],
  .cfg-illus > div[style*="fontSize: 64"] { font-size: 36px !important; }
  .cfg-illus svg { display: none !important; }
  .cfg-form { padding: 24px !important; }
}

/* CTA flex boxes handled per-class (.d2v2-form-submit etc.) to avoid
   stacking every flex+space-between row by accident. */

/* ==========================================================
   MOBILE ≤ 640px
   ========================================================== */
@media (max-width: 640px) {
  /* Reduce CTA card padding on mobile for breathing room */
  .d2v2-cta-card { padding: 24px !important; }

  h1 { font-size: clamp(40px, 11vw, 64px) !important; }
  h2 { font-size: clamp(32px, 9vw, 52px) !important; }
  h3 { font-size: clamp(20px, 5.5vw, 32px) !important; }
  /* Long single-word titles (e.g. "L'Accompagnement") must fit small screens */
  .d2v2-h1-long { font-size: clamp(26px, 8vw, 42px) !important; }

  section[style*="padding"],
  article[style*="padding"] {
    padding-top: clamp(48px, 10vw, 80px) !important;
    padding-bottom: clamp(48px, 10vw, 80px) !important;
    padding-left: 20px !important;
    padding-right: 20px !important;
  }
  footer[style*="padding"] {
    padding: 48px 20px 24px !important;
  }

  /* Footer bottom row stacks */
  footer div[style*="justify-content: space-between"] {
    flex-direction: column !important;
    gap: 12px !important;
    align-items: flex-start !important;
  }

  /* Buttons too wide become full-width */
  form button[type="submit"] {
    width: 100% !important;
    justify-content: center !important;
  }
  .d2v2-form-submit {
    flex-direction: column !important;
    align-items: stretch !important;
  }

  /* Projects mosaic — shrink caption title on small tiles */
  .d2v2-proj-cap [style*="font-size: 34px"] { font-size: 22px !important; }
  .d2v2-proj-cap { padding: 16px !important; }

  /* Project gallery — single column on phones */
  .d2v2-gallery { column-count: 1 !important; }

  /* Home mosaic back to 1 col */
  .d2v2-mosaic {
    grid-template-columns: 1fr !important;
  }
  .d2v2-mosaic > :first-child { min-height: 320px; }
  .d2v2-mosaic > * { height: 220px !important; }

  /* Marquee slows on small screens */
  @media (prefers-reduced-motion: no-preference) {
    section > div[style*="d2Marq"] { animation-duration: 80s !important; }
  }
}

/* ==========================================================
   VERY SMALL ≤ 420px — tighten up
   ========================================================== */
@media (max-width: 420px) {
  h1 { font-size: clamp(36px, 12vw, 52px) !important; }
  h2 { font-size: clamp(28px, 9vw, 40px) !important; }
}

/* ==========================================================
   PASSE UX 09/2026 — lisibilité, confort tactile, questionnaire
   ========================================================== */
/* Vérifié le 18/09 : la barre fixe du bas ne masque pas la fin de page —
   le pied de page garde sa propre marge basse. Pas de padding à ajouter. */
@media (max-width: 768px) {
  /* Questionnaire : les cartes de choix restaient sur 2 colonnes et
     débordaient du panneau (« Rénovation » coupé à droite). */
  .cfg-form [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
  .cfg-form button { min-width: 0 !important; }

  /* Confort tactile — cibles trop fines au doigt (< 36px de haut) :
     pastilles du diaporama, retour, liens du pied de page. */
  button[aria-label^="Projet "] { height: 36px !important; }
  button[data-cursor="Retour"] { padding: 11px 0 !important; }
  .d2v2-hero button[data-cursor="Voir"] { padding: 10px 0 !important; }
  footer a { display: inline-block; padding: 10px 0; }
}

@media (max-width: 640px) {
  /* Lisibilité — rien sous 10px sur téléphone (la signature du logo
     tombait à 8px, les libellés de pied de page et de fiche à 10px). */
  [style*="font-size: 8px"] { font-size: 10px !important; letter-spacing: 0.06em !important; }
  [style*="font-size: 9px"] { font-size: 11px !important; }
  [style*="font-size: 10px"] { font-size: 11px !important; }
  [style*="font-size: 11px"] { font-size: 12px !important; }
}

/* Fiche projet — les infos sont courtes : 2 colonnes plutôt que 6 lignes empilées */
@media (max-width: 960px) {
  .d2v2-facts { grid-template-columns: 1fr 1fr !important; gap: 20px !important; }
}

/* ==========================================================
   REDUCED MOTION — kill long/looped animations
   ========================================================== */
@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;
  }
  /* Still allow fades but disable marquee & scale creep */
  [style*="d2Marq"] { animation: none !important; transform: none !important; }
  [style*="transform: scale(1.08)"] { transform: none !important; }
}

/* ==========================================================
   TOUCH — hide desktop-only custom cursor hints
   ========================================================== */
@media (hover: none) {
  [data-cursor] { cursor: pointer; }
  /* No hover on touch — show project captions permanently */
  .d2v2-proj-cap { opacity: 1 !important; }
  .d2v2-proj-cap > div { transform: none !important; }
}
