/* ==========================================================================
   MAIN.CSS — Reset, Custom Fonts, CSS Variables, Utilities
   Groupe Archipel — Design System Foundation
   ========================================================================== */

/* --------------------------------------------------------------------------
   @FONT-FACE — Self-hosted brand fonts
   -------------------------------------------------------------------------- */

@font-face {
  font-family: 'Code Next';
  src: url('../fonts/CodeNext-ExtraBold.woff2') format('woff2'),
       url('../fonts/CodeNext-ExtraBold.woff') format('woff');
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Code Next';
  src: url('../fonts/CodeNext-Heavy.woff2') format('woff2'),
       url('../fonts/CodeNext-Heavy.woff') format('woff');
  font-weight: 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Space Grotesk';
  src: url('../fonts/SpaceGrotesk-VariableFont_wght.ttf') format('truetype');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}

/* --------------------------------------------------------------------------
   CSS CUSTOM PROPERTIES — Single source of truth for all design tokens
   -------------------------------------------------------------------------- */

:root {
  /* --- Colors --- */
  --color-primary:        #0049FF;
  --color-primary-dark:   #0038CC;
  --color-primary-light:  #3370FF;
  --color-navy:           #001B56;
  --color-navy-light:     #1A2D6B;
  --color-peach:          #FFE5D7;
  --color-sunrise:        #FFCCA9;
  --color-orange:         #E8956D;
  --color-orange-light:   #F5C4A8;
  --color-sand:           #FAF5EF;
  --color-white:          #FFFFFF;
  --color-grey:           #6B7280;
  --color-grey-light:     #F8F6F3;
  --color-grey-mid:       #D1D5DB;
  --color-text:           #1A1A1A;
  --color-text-light:     #4B5563;
  --color-overlay:        rgba(0, 27, 86, 0.72);
  --color-overlay-light:  rgba(0, 27, 86, 0.45);

  /* --- Typography --- */
  --font-display:   'Code Next', system-ui, sans-serif;
  --font-body:      'Space Grotesk', system-ui, sans-serif;

  --fw-light:       300;
  --fw-regular:     400;
  --fw-medium:      500;
  --fw-semibold:    600;
  --fw-bold:        700;
  --fw-extrabold:   800;
  --fw-heavy:       900;

  /* Fluid type scale (clamp: min, preferred, max) */
  --text-xs:        clamp(0.7rem,   0.65rem + 0.25vw,  0.8rem);
  --text-sm:        clamp(0.8rem,   0.75rem + 0.25vw,  0.9rem);
  --text-base:      clamp(0.95rem,  0.9rem  + 0.25vw,  1.05rem);
  --text-lg:        clamp(1.1rem,   1rem    + 0.5vw,   1.3rem);
  --text-xl:        clamp(1.25rem,  1.1rem  + 0.75vw,  1.6rem);
  --text-2xl:       clamp(1.5rem,   1.2rem  + 1.5vw,   2.2rem);
  --text-3xl:       clamp(1.8rem,   1.4rem  + 2vw,     2.8rem);
  --text-4xl:       clamp(2.2rem,   1.6rem  + 3vw,     3.8rem);
  --text-5xl:       clamp(2.8rem,   2rem    + 4vw,     5rem);

  --leading-tight:  1.15;
  --leading-snug:   1.3;
  --leading-normal: 1.6;
  --leading-relaxed:1.75;

  --tracking-tight: -0.02em;
  --tracking-normal: 0;
  --tracking-wide:   0.04em;
  --tracking-wider:  0.12em;
  --tracking-caps:   0.16em;

  /* --- Spacing (8px base grid) --- */
  --space-1:   0.25rem;   /*  4px */
  --space-2:   0.5rem;    /*  8px */
  --space-3:   0.75rem;   /* 12px */
  --space-4:   1rem;      /* 16px */
  --space-5:   1.25rem;   /* 20px */
  --space-6:   1.5rem;    /* 24px */
  --space-8:   2rem;      /* 32px */
  --space-10:  2.5rem;    /* 40px */
  --space-12:  3rem;      /* 48px */
  --space-16:  4rem;      /* 64px */
  --space-20:  5rem;      /* 80px */
  --space-24:  6rem;      /* 96px */
  --space-32:  8rem;      /* 128px */

  /* --- Section padding (responsive) --- */
  --section-py:  clamp(4rem, 6vw, 7rem);
  --section-px:  clamp(1.25rem, 5vw, 5rem);

  /* --- Layout --- */
  --max-width:     1280px;
  --max-width-sm:  800px;
  --max-width-xs:  640px;
  --navbar-height: 100px;

  /* --- Borders & Radius --- */
  --radius-sm:   6px;
  --radius-md:   12px;
  --radius-lg:   20px;
  --radius-xl:   28px;
  --radius-full: 100px;

  /* --- Shadows --- */
  --shadow-sm:   0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.06);
  --shadow-md:   0 4px 12px rgba(0, 0, 0, 0.08), 0 8px 32px rgba(0, 0, 0, 0.08);
  --shadow-lg:   0 8px 24px rgba(0, 0, 0, 0.1), 0 16px 48px rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 0 24px rgba(0, 73, 255, 0.2);

  /* --- Transitions --- */
  --ease-out:    cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast:   150ms;
  --duration-normal: 300ms;
  --duration-slow:   500ms;

  /* --- Z-index scale --- */
  --z-base:    1;
  --z-above:   10;
  --z-navbar:  100;
  --z-overlay: 200;
  --z-modal:   300;
}

/* --------------------------------------------------------------------------
   CSS RESET — Modern, minimal
   -------------------------------------------------------------------------- */

*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: var(--navbar-height);
}

body {
  font-family: var(--font-body);
  font-weight: var(--fw-regular);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-text);
  background-color: var(--color-white);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

a {
  color: inherit;
  text-decoration: none;
}

ul,
ol {
  list-style: none;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: var(--fw-extrabold);
  line-height: var(--leading-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--color-navy);
  text-wrap: balance;
}

h1 { font-size: var(--text-5xl); }
h2 { font-size: var(--text-4xl); }
h3 { font-size: var(--text-3xl); }
h4 { font-size: var(--text-2xl); }
h5 { font-size: var(--text-xl);  }
h6 { font-size: var(--text-lg);  }

p {
  max-width: 70ch;
  color: var(--color-text-light);
}

::selection {
  background: var(--color-primary);
  color: var(--color-white);
}

/* Focus visible for keyboard accessibility */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* --------------------------------------------------------------------------
   UTILITY CLASSES
   -------------------------------------------------------------------------- */

/* --- Container --- */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: var(--section-px);
}

.container--sm {
  max-width: var(--max-width-sm);
}

.container--xs {
  max-width: var(--max-width-xs);
}

/* --- Section spacing --- */
.section {
  padding-block: var(--section-py);
}

/* --- Text --- */
.text-center   { text-align: center; }
.text-left     { text-align: left; }
.text-right    { text-align: right; }

.text-primary  { color: var(--color-primary); }
.text-navy     { color: var(--color-navy); }
.text-white    { color: var(--color-white); }
.text-orange   { color: var(--color-orange); }
.text-grey     { color: var(--color-grey); }

/* --- Section label (small uppercase text above titles) --- */
.section__label {
  display: inline-block;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--tracking-caps);
  color: var(--color-primary);
  margin-bottom: var(--space-4);
}

.section__label--light {
  color: var(--color-sunrise);
}

/* --- Section title --- */
.section__title {
  margin-bottom: var(--space-6);
}

/* --- Section subtitle / description --- */
.section__desc {
  font-size: var(--text-lg);
  max-width: 60ch;
  margin-bottom: var(--space-10);
}

.section__desc--centered {
  margin-inline: auto;
  text-align: center;
}

/* --- Backgrounds --- */
.bg-white      { background-color: var(--color-white); }
.bg-sand       { background-color: var(--color-sand); }
.bg-grey-light { background-color: var(--color-grey-light); }
.bg-navy       { background-color: var(--color-navy); }
.bg-primary    { background-color: var(--color-primary); }
.bg-peach      { background-color: var(--color-peach); }

/* --- Flex / Grid helpers --- */
.flex          { display: flex; }
.flex-col      { flex-direction: column; }
.flex-wrap     { flex-wrap: wrap; }
.items-center  { align-items: center; }
.items-start   { align-items: flex-start; }
.justify-center{ justify-content: center; }
.justify-between{ justify-content: space-between; }
.gap-2         { gap: var(--space-2); }
.gap-4         { gap: var(--space-4); }
.gap-6         { gap: var(--space-6); }
.gap-8         { gap: var(--space-8); }
.gap-10        { gap: var(--space-10); }

.grid {
  display: grid;
  gap: var(--space-6);
}

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

/* --- Responsive grid collapse --- */
@media (max-width: 900px) {
  .grid-3,
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
  .grid-2 { grid-template-columns: 1fr; }

  /* Carousel horizontal sur mobile pour les grilles 3 et 4 colonnes */
  .grid-3,
  .grid-4 {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: var(--space-4);
    padding-bottom: var(--space-4);
    /* Débord sur les bords pour permettre le scroll depuis les marges */
    margin-inline: calc(-1 * var(--section-px));
    padding-inline: var(--section-px);
    scrollbar-width: none;
  }
  .grid-3::-webkit-scrollbar,
  .grid-4::-webkit-scrollbar { display: none; }

  .grid-3 > *,
  .grid-4 > * {
    flex: 0 0 82%;
    max-width: 82%;
    scroll-snap-align: start;
  }
}

/* --- Visibility --- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Hide on mobile / desktop */
@media (max-width: 900px) {
  .hide-mobile { display: none !important; }
}

@media (min-width: 901px) {
  .hide-desktop { display: none !important; }
}

/* --- Gradient text (brand blue → orange) --- */
.gradient-text {
  background: linear-gradient(135deg, var(--color-navy) 0%, var(--color-primary) 50%, var(--color-orange) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* --- Reveal on scroll (used by animations.js) --- */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity var(--duration-slow) var(--ease-out),
              transform var(--duration-slow) var(--ease-out);
}

.reveal.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered reveal delays for grid children */
.reveal-stagger > *:nth-child(1) { transition-delay: 0ms; }
.reveal-stagger > *:nth-child(2) { transition-delay: 100ms; }
.reveal-stagger > *:nth-child(3) { transition-delay: 200ms; }
.reveal-stagger > *:nth-child(4) { transition-delay: 300ms; }
.reveal-stagger > *:nth-child(5) { transition-delay: 400ms; }
.reveal-stagger > *:nth-child(6) { transition-delay: 500ms; }
