/**
 * Mobile-first responsive — Groupe Électrogène Services
 * Chargé en dernier sur toutes les pages (après les styles inline ou category/product).
 */

/* ===== Tokens ===== */
:root {
  --page-gutter: 16px;
  --touch-target: 44px;
  --header-compact-h: 56px;
}

/* ===== Base : mobile par défaut ===== */
html {
  overflow-x: clip;
  -webkit-text-size-adjust: 100%;
}

html:not(:has(body.page-product)) {
  scroll-padding-top: calc(var(--header-compact-h) + 12px);
}

html:has(body.page-product) {
  scroll-padding-top: var(--header-sub-total, 142px);
}

body {
  overflow-x: clip;
  min-width: 0;
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
}

img,
video,
picture,
svg {
  max-width: 100%;
  height: auto;
}

img {
  object-fit: contain;
}

.container {
  width: 100%;
  max-width: 1180px;
  margin-inline: auto;
  padding-inline: max(var(--page-gutter), env(safe-area-inset-left, 0px))
    max(var(--page-gutter), env(safe-area-inset-right, 0px));
}

.header-main .container.header-brand-banner {
  max-width: none;
  margin-inline: 0;
  padding-inline: max(12px, env(safe-area-inset-left, 0px))
    max(16px, env(safe-area-inset-right, 0px));
}

main.container {
  min-width: 0;
}

/* ===== Grilles : 1 colonne sur mobile ===== */
.cards,
.catalog-grid,
.related-grid,
.contact-grid,
.shops-grid,
.shops-callout-grid,
.footer-grid,
.hero-offerings,
.expertise-panels,
.check-list {
  grid-template-columns: 1fr;
  gap: clamp(14px, 4vw, 24px);
}

.footer-shops {
  grid-template-columns: 1fr;
}

/* ===== Cartes produit (accueil) ===== */
.cards {
  gap: clamp(18px, 4vw, 30px);
}

.card {
  min-width: 0;
}

.card-body {
  padding: clamp(18px, 4vw, 30px);
  min-width: 0;
}

.card-body h3 {
  font-size: clamp(1.05rem, 4.2vw, 1.32rem);
  overflow-wrap: anywhere;
}

.card-link {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  width: auto;
  max-width: 100%;
  font-size: clamp(0.8rem, 3.4vw, 0.94rem);
  line-height: 1.35;
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
  min-height: var(--touch-target);
  margin-top: auto;
  align-self: flex-start;
  padding: 10px 0 2px;
  border-radius: 0;
}

.card-link svg {
  flex-shrink: 0;
}

/* ===== Titres fluides ===== */
#expertise-title {
  white-space: normal;
  overflow-wrap: anywhere;
  font-size: clamp(1rem, 4.5vw, 1.7rem);
}

.section-title {
  font-size: clamp(1.35rem, 5vw, 2.3rem);
}

.content-seo h2 {
  font-size: clamp(1.25rem, 4.8vw, 1.92rem);
}

.hero h1 {
  font-size: clamp(1.35rem, 5.5vw, 2.55rem);
}

.category-hero h1,
.header-category-title {
  font-size: clamp(0.85rem, 3.8vw, 1.85rem);
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.header-category-title {
  flex: 1;
  min-width: 0;
  text-align: left;
}

/* ===== Zones tactiles (44×44 px min.) ===== */
.nav-toggle,
.btn,
button:not(.nav-toggle),
.catalog-pagination button,
.back-to-top,
.nav-primary a,
.nav-catalog a,
.header-nav a,
.header-nav nav ul a,
.contact-item a,
.shop-details a,
.footer-links a {
  min-height: var(--touch-target);
}

.nav-primary a,
.nav-catalog a,
.header-nav nav ul a {
  display: inline-flex;
  align-items: center;
}

.back-link {
  min-height: var(--touch-target);
  align-items: center;
}

/* ===== Boutons pleine largeur si espace réduit ===== */
.btn,
.hero-actions .btn,
.contact-box .btn,
.product-page > p .btn,
.cta-band .btn,
.catalog-empty .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  text-align: center;
  max-width: 100%;
  box-sizing: border-box;
}

@media (max-width: 480px) {
  .btn,
  .hero-actions .btn,
  .contact-box .btn,
  .product-page > p .btn,
  .cta-band .btn,
  .catalog-empty .btn {
    width: 100%;
  }
}

/* ===== Formulaires : pas de zoom (< 16 px) ===== */
input,
select,
textarea {
  font-size: max(16px, 1rem);
  max-width: 100%;
  box-sizing: border-box;
}

input[type="search"],
input[type="email"],
input[type="tel"],
input[type="text"],
input[type="number"],
textarea,
select {
  width: 100%;
  min-height: var(--touch-target);
  padding: 12px 16px;
  border: 1px solid var(--line, #e4e9ee);
  border-radius: var(--radius-sm, 8px);
  background: var(--surface-card, #fff);
  color: inherit;
}

input[type="search"] {
  margin-bottom: 16px;
}

/* ===== Menu hamburger — mobile uniquement (< 769 px) ===== */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: var(--touch-target);
  height: var(--touch-target);
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

@media (max-width: 768px) {
  .nav-toggle {
    display: inline-flex;
  }
}

.nav-toggle-bar {
  display: block;
  width: 20px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform 0.25s ease, opacity 0.25s ease;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) {
  opacity: 0;
}

.nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

body.nav-open {
  overflow: hidden;
}

/* Sous-pages : navigation mobile */
.site-header-sub .header-brand-banner {
  display: flex;
  align-items: center;
  gap: 10px 12px;
  min-height: var(--header-compact-h);
  padding: 8px 0;
  --header-sub-brand-h: var(--header-compact-h);
}

.site-header-sub .logo-sticker {
  width: clamp(42px, 11vw, 48px);
}

.site-header-sub .header-nav {
  display: none;
  position: fixed;
  top: var(--header-compact-h);
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 99;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--surface-card, #fff);
  border-bottom: 1px solid var(--line, #e4e9ee);
  padding-bottom: max(16px, env(safe-area-inset-bottom, 0px));
}

.site-header-sub.nav-open .header-nav {
  display: block;
}

.site-header-sub .header-nav-inner {
  flex-direction: column;
  align-items: stretch;
  padding: 16px 0;
}

.site-header-sub .header-nav nav ul {
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
}

.site-header-sub .header-nav nav a {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  font-size: 0.95rem;
  border-radius: var(--radius-sm, 8px);
}

.site-header-sub .header-nav nav a:hover,
.site-header-sub .header-nav nav a:focus-visible {
  background: var(--surface-muted, #eef2f6);
}

/* ===== Tableaux catalogue ===== */
.catalog-table-wrap {
  -webkit-overflow-scrolling: touch;
}

.catalog-ref,
.product-ref-badge,
.product-ref {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.product-details-table th {
  width: auto;
}

.product-hero-head,
.product-meta {
  min-width: 0;
}

.product-image img {
  width: 100%;
  max-height: min(320px, 50vh);
  object-fit: contain;
}

/* ===== Contact / footer ===== */
.contact-box {
  padding: clamp(24px, 5vw, 40px) var(--page-gutter);
}

.contact-item {
  min-width: 0;
}

.contact-item strong {
  overflow-wrap: anywhere;
}

a.contact-item[href^="mailto:"] strong {
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
}

.contact-item strong.contact-iban {
  display: block;
  white-space: normal;
  overflow-wrap: normal;
  word-break: normal;
  font-size: 0.88rem;
  line-height: 1.35;
}

.shop-card,
.footer-shop-card,
.shops-callout-card {
  min-width: 0;
}

.tel-line {
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
  font-size: clamp(0.76rem, 2.8vw, 0.9rem);
}

.footer-links.footer-contact a[href^="tel:"] {
  min-height: 0;
}

.footer-links.footer-contact a[href^="mailto:"],
.footer-contact-email a {
  display: inline;
  min-height: 0;
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: normal;
  line-height: inherit;
}

.shop-details a[href^="tel:"] {
  min-height: 0;
}

.footer-grid {
  gap: 24px;
}

.footer-about-head {
  flex-wrap: wrap;
}

/* ===== Fil d'Ariane ===== */
.breadcrumb ol {
  overflow-wrap: anywhere;
}

/* ===== Safe areas header sticky ===== */
#site-header,
.header-main {
  padding-top: env(safe-area-inset-top, 0);
}

.back-to-top {
  bottom: max(16px, env(safe-area-inset-bottom, 0px));
  right: max(12px, env(safe-area-inset-right, 0px));
}

/* ===== Images responsives (picture / WebP ready) ===== */
picture {
  display: block;
}

picture img {
  width: 100%;
  height: auto;
}

.card-visual img,
.category-hero-media img {
  width: 100%;
  height: auto;
  object-fit: contain;
}

/* ===== Breakpoints progressifs (mobile-first) ===== */
@media (min-width: 360px) {
  .card-link {
    font-size: clamp(0.84rem, 3.2vw, 0.94rem);
  }
}

@media (min-width: 390px) {
  :root {
    --header-compact-h: 58px;
  }
}

@media (min-width: 412px) {
  .header-category-title {
    -webkit-line-clamp: unset;
    display: block;
  }
}

@media (min-width: 481px) {
  .cards {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  }

  .check-list {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
  }

  .btn,
  .hero-actions .btn,
  .contact-box .btn,
  .product-page > p .btn,
  .cta-band .btn {
    width: auto;
  }
}

@media (min-width: 600px) {
  .contact-grid,
  .shops-grid,
  .shops-callout-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  }

  .related-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
  }
}

@media (min-width: 769px) {
  html:not(:has(body.page-product)) {
    scroll-padding-top: var(--header-sub-total, 142px);
  }

  html:has(body.page-product) {
    scroll-padding-top: var(--header-sub-total, 142px);
  }

  .container {
    padding-inline: 24px;
  }

  .cards {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  }

  .catalog-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }

  .contact-grid {
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  }

  .shops-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  }

  .hero-offerings {
    grid-template-columns: repeat(3, 1fr);
  }

  .expertise-panels {
    grid-template-columns: repeat(3, 1fr);
  }

  .footer-grid {
    grid-template-columns: 1.15fr 1fr 1.25fr;
    gap: 32px;
  }

  /* PC : pas de hamburger (accueil + sous-pages) */
  .nav-toggle {
    display: none !important;
  }

  .site-header-sub .header-nav {
    display: block;
    position: static;
    overflow: visible;
    background: var(--surface-card, #fff);
    border-bottom: 1px solid var(--line, #e4e9ee);
    --header-sub-nav-h: 52px;
  }

  .site-header-sub .header-nav-inner {
    flex-direction: row;
    align-items: center;
    min-height: 52px;
    padding: 0;
  }

  .site-header-sub .header-nav nav ul {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px 18px;
  }

  .site-header-sub .header-nav nav a {
    padding: 0;
    min-height: auto;
  }

  .product-details-table th {
    width: 28%;
  }

  input[type="search"] {
    width: 100%;
  }
}

@media (min-width: 901px) {
  .footer-grid {
    grid-template-columns: 1.15fr 1fr 1.25fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .nav-toggle-bar {
    transition: none;
  }
}
