/* 
   ================================================
   Global CSS - Mobile First 
   ================================================ 
*/

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background-color: #fff;
  overflow-x: hidden;
  font-family: 'Public Sans', sans-serif;
  color: #1d6895;
}

a {
  color: #1d6895;
  text-decoration: none;
}
a:hover {
  color: #2b8ec2;
}

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

/* Layout */
.container {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}

@media (min-width: 768px) {
  .container {
    padding-left: 32px;
    padding-right: 32px;
  }
}

.section {
  padding-top: 60px;
  padding-bottom: 60px;
}

@media (min-width: 768px) {
  .section {
    padding-top: 100px;
    padding-bottom: 100px;
  }
}

/* Grids - Mobile First (1 column) */
.grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.grid-gap-1 {
  gap: 1px;
}

/* Grids - Tablet (2 columns) */
@media (min-width: 768px) {
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Grids - Desktop */
@media (min-width: 1024px) {
  .grid-3 {
    grid-template-columns: repeat(3, 1fr);
  }
  .grid-4 {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* UI Elements */
.card {
  background: #fff;
  padding: 24px;
}

@media (min-width: 768px) {
  .card {
    padding: 32px;
  }
}

.btn {
  display: inline-block;
  background: #1d6895;
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  padding: 12px 22px;
  border-radius: 6px;
  text-align: center;
  border: none;
  cursor: pointer;
}

.btn:hover {
  background: #164f72;
  color: #fff;
}

.btn-outline {
  background: transparent;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  color: #fff;
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

/* Header & Mobile Menu */
.header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: #fff;
  border-bottom: 1px solid #e6e9ec;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  padding-bottom: 12px;
}

@media (min-width: 768px) {
  .header-inner {
    padding-top: 18px;
    padding-bottom: 18px;
  }
}

/* Nav Menu */
.nav-menu {
  display: none; /* hidden on mobile by default */
  flex-direction: column;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  padding: 20px;
  border-bottom: 1px solid #e6e9ec;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  gap: 16px;
}

.nav-menu.active {
  display: flex;
}

@media (min-width: 1024px) {
  .nav-menu {
    display: flex;
    flex-direction: row;
    position: static;
    background: transparent;
    padding: 0;
    border: none;
    box-shadow: none;
    gap: 16px;
    align-items: center;
  }
}

.nav-link {
  font-weight: 600;
  font-size: 14px;
  color: #4a5866;
  white-space: nowrap;
}

.nav-link.active {
  font-weight: 700;
  color: #1d6895;
}

/* Hamburger toggle — pure CSS (checkbox hack). The DC template engine
   compiles a literal onclick="..." string into a React onClick PROP
   holding that same string, not a function, so React silently no-ops
   it; a checkbox + label sidesteps the template engine's event system
   entirely and needs no JS at all. */
.nav-toggle-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.nav-toggle-input:checked ~ .nav-menu {
  display: flex;
}

.hamburger {
  display: block;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
}

.hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background-color: #1d6895;
  margin-bottom: 5px;
  border-radius: 2px;
}

.hamburger span:last-child {
  margin-bottom: 0;
}

@media (min-width: 1024px) {
  .hamburger {
    display: none;
  }
}

/* Utilities */
.hide-on-mobile {
  display: none;
}
@media (min-width: 768px) {
  .hide-on-mobile {
    display: block;
  }
}

.hide-on-desktop {
  display: block;
}
@media (min-width: 768px) {
  .hide-on-desktop {
    display: none;
  }
}

.flex {
  display: flex;
}
.flex-col {
  flex-direction: column;
}
.items-center {
  align-items: center;
}
.justify-between {
  justify-content: space-between;
}
.justify-center {
  justify-content: center;
}
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.gap-6 { gap: 24px; }
.gap-8 { gap: 32px; }

@media (min-width: 768px) {
  .md-flex-row {
    flex-direction: row;
  }
}

/* ================================================
   Mobile-first additions: hero, grids-5, media,
   forms, footer, gallery/lightbox, admin panel
   ================================================ */

/* 5-column grid (partners logos) — same tiers as grid-2/3/4 */
@media (min-width: 768px) {
  .grid-5 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
  .grid-5 { grid-template-columns: repeat(5, 1fr); }
}

/* Accueil hero — much larger padding than a regular .section */
.hero-pad {
  padding: 64px 20px 56px;
}
@media (min-width: 768px) {
  .hero-pad { padding: 96px 28px 90px; }
}
@media (min-width: 1024px) {
  .hero-pad { padding: 130px 32px 150px; }
}

/* Fixed-height image wrappers — scale with viewport up to their
   original desktop height, set per-instance via --media-h */
.media-fluid {
  height: clamp(calc(var(--media-h, 280px) * 0.55), 34vw, var(--media-h, 280px));
}
@media (min-width: 1024px) {
  .media-fluid { height: var(--media-h, 280px); }
}

/* 2-up form rows (Prénom / Nom) — stack sooner than the main grids,
   two short inputs don't need to wait for tablet width */
.form-row-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 480px) {
  .form-row-2 { grid-template-columns: 1fr 1fr; }
}

/* Footer — stacked on mobile, 3 columns from tablet up */
.footer-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
}
@media (min-width: 768px) {
  .footer-grid { grid-template-columns: 1.4fr 1fr 1fr; gap: 48px; }
}

/* Galerie masonry grid */
.gallery-grid {
  display: grid;
  grid-template-columns: 1fr;
  grid-auto-rows: 220px;
  gap: 12px;
}
@media (max-width: 767px) {
  /* neutralize each photo's inline grid-row:span N while stacked 1-col */
  .gallery-grid > div { grid-row: span 1 !important; }
}
@media (min-width: 768px) {
  .gallery-grid { grid-template-columns: repeat(2, 1fr); grid-auto-rows: 180px; gap: 16px; }
}
@media (min-width: 1024px) {
  .gallery-grid { grid-template-columns: repeat(4, 1fr); }
}

/* Lightbox modal */
.lightbox-backdrop { padding: 16px; }
@media (min-width: 768px) {
  .lightbox-backdrop { padding: 40px; }
}
.lightbox-close { top: 12px; right: 16px; font-size: 32px; }
@media (min-width: 768px) {
  .lightbox-close { top: 30px; right: 40px; font-size: 40px; }
}

/* Admin shell — sidebar stacks above content on mobile,
   becomes a fixed sidebar + content grid from desktop width */
.admin-shell {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 16px;
}
@media (min-width: 1024px) {
  .admin-shell {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 32px;
    padding: 32px;
    align-items: start;
  }
}

/* Admin sidebar nav — horizontal scrollable tab strip on mobile,
   sticky vertical list from desktop width */
.admin-nav {
  display: flex;
  flex-direction: row;
  gap: 4px;
  overflow-x: auto;
  padding: 8px;
}
@media (min-width: 1024px) {
  .admin-nav {
    flex-direction: column;
    position: sticky;
    top: 80px;
    padding: 10px;
    overflow-x: visible;
  }
}

/* Admin form repeater rows — stacked 1-col on mobile, restore the
   original multi-column layout from tablet width */
.admin-row-5, .admin-row-4, .admin-row-3, .admin-row-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 768px) {
  .admin-row-5 { grid-template-columns: 72px 1fr 1fr 1fr auto; align-items: end; }
  .admin-row-4 { grid-template-columns: 72px 1fr 1fr auto; align-items: end; }
  .admin-row-3 { grid-template-columns: 1fr 1fr auto; align-items: end; }
  .admin-row-2 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 767px) {
  /* neutralize inline grid-column spans (Supprimer button, description
     row, file-picker row) while the parent row is stacked 1-col */
  .admin-full-row { grid-column: 1 !important; }
}
