/*
 * main.css — Assurance à Juste Prix
 * Global custom properties, reset, typography, layout utilities
 * Fonts loaded via <link> in HTML <head>
 */

/* ============================================================
   1. CSS CUSTOM PROPERTIES
   ============================================================ */
:root {
  /* Brand colors — AAJP Identity v2 */
  --color-primary:      #003466;   /* Marine AAJP */
  --color-secondary:    #FF7F00;   /* Orange AAJP */
  --color-accent:       #1A4F8A;   /* Marine Moyen */
  --color-accent-2:     #2C6DB5;   /* Bleu Accent */
  --color-secondary-hover: #FFB347; /* Orange Clair */
  --color-bg:           #F8F7F4;   /* Blanc Doux */
  --color-text:         #1C1C2E;
  --color-text-light:   #6B7280;
  --color-success:      #059669;
  --color-white:        #FFFFFF;

  /* Semantic derivatives */
  --color-error:        #DC2626;
  --color-warning:      #D97706;
  --color-border:       #E5E7EB;
  --color-border-focus: var(--color-primary);
  --color-overlay:      rgba(0, 52, 102, 0.72);

  /* Navy tints */
  --color-primary-90:   rgba(0, 52, 102, 0.90);
  --color-primary-10:   rgba(0, 52, 102, 0.08);
  --color-secondary-10: rgba(255, 127, 0, 0.12);
  --color-secondary-20: rgba(255, 127, 0, 0.22);

  /* Typography — AAJP Identity v2 */
  --font-display: 'Lora', Georgia, 'Times New Roman', serif;
  --font-body:    'Poppins', system-ui, -apple-system, sans-serif;
  --font-mono:    'DM Mono', 'Courier New', monospace;

  /* Type scale (fluid between 375px and 1280px) */
  --text-xs:   0.75rem;    /* 12px */
  --text-sm:   0.875rem;   /* 14px */
  --text-base: 1rem;       /* 16px */
  --text-lg:   1.125rem;   /* 18px */
  --text-xl:   1.25rem;    /* 20px */
  --text-2xl:  1.5rem;     /* 24px */
  --text-3xl:  1.875rem;   /* 30px */
  --text-4xl:  2.25rem;    /* 36px */
  --text-5xl:  3rem;       /* 48px */
  --text-6xl:  3.75rem;    /* 60px */

  /* Font weights */
  --weight-light:    300;
  --weight-regular:  400;
  --weight-medium:   500;
  --weight-semibold: 600;
  --weight-bold:     700;

  /* Line heights */
  --leading-tight:  1.2;
  --leading-snug:   1.35;
  --leading-normal: 1.6;
  --leading-relaxed:1.75;

  /* Spacing scale */
  --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 */

  /* Border radius */
  --radius-sm:   4px;
  --radius-md:   8px;
  --radius-lg:   12px;
  --radius-xl:   16px;
  --radius-2xl:  24px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-xs:  0 1px 2px rgba(0, 52, 102, 0.06);
  --shadow-sm:  0 1px 4px rgba(0, 52, 102, 0.08);
  --shadow-md:  0 4px 16px rgba(0, 52, 102, 0.10);
  --shadow-lg:  0 8px 32px rgba(0, 52, 102, 0.13);
  --shadow-xl:  0 16px 48px rgba(0, 52, 102, 0.16);
  --shadow-gold: 0 4px 20px rgba(255, 127, 0, 0.30);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Z-index layers */
  --z-base:   1;
  --z-raised: 10;
  --z-nav:    100;
  --z-modal:  200;
  --z-toast:  300;

  /* Layout */
  --max-w-xs:  480px;
  --max-w-sm:  640px;
  --max-w-md:  768px;
  --max-w-lg:  1024px;
  --max-w-xl:  1200px;
  --max-w-2xl: 1400px;
  --container-px: clamp(1rem, 5vw, 2.5rem);

  /* Nav height (used in sticky offset calculations) */
  --nav-height: 72px;
}

/* ============================================================
   2. MODERN CSS RESET
   ============================================================ */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

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

img,
video,
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(--weight-bold);
  line-height: var(--leading-tight);
  color: var(--color-primary);
}

p {
  max-width: 72ch;
}

strong {
  font-weight: var(--weight-semibold);
}

address {
  font-style: normal;
}

/* Remove default fieldset styles */
fieldset {
  border: none;
  margin: 0;
  padding: 0;
}

/* Remove list styles on ul/ol with role="list" */
ul[role='list'],
ol[role='list'] {
  list-style: none;
}

/* Focus ring — accessible but not intrusive */
:focus-visible {
  outline: 2px solid var(--color-secondary);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

/* ============================================================
   3. TYPOGRAPHY SCALE
   ============================================================ */

/* Headings */
h1, .h1 {
  font-size: clamp(var(--text-3xl), 5vw, var(--text-5xl));
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  letter-spacing: -0.02em;
}

h2, .h2 {
  font-size: clamp(var(--text-2xl), 3.5vw, var(--text-4xl));
  font-weight: var(--weight-bold);
  line-height: var(--leading-snug);
  letter-spacing: -0.015em;
}

h3, .h3 {
  font-size: clamp(var(--text-xl), 2.5vw, var(--text-2xl));
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
}

h4, .h4 {
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-snug);
}

h5, .h5 {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}

h6, .h6 {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Display text (for hero headlines) */
.text-display {
  font-family: var(--font-display);
  font-size: clamp(var(--text-4xl), 6vw, var(--text-6xl));
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  letter-spacing: -0.025em;
}

/* Body variants */
.text-lead {
  font-size: var(--text-lg);
  line-height: var(--leading-relaxed);
  color: var(--color-text-light);
}

.text-sm   { font-size: var(--text-sm); }
.text-xs   { font-size: var(--text-xs); }
.text-base { font-size: var(--text-base); }
.text-lg   { font-size: var(--text-lg); }
.text-xl   { font-size: var(--text-xl); }
.text-2xl  { font-size: var(--text-2xl); }
.text-3xl  { font-size: var(--text-3xl); }

/* Color utilities */
.text-primary     { color: var(--color-primary); }
.text-secondary   { color: var(--color-secondary); }
.text-light       { color: var(--color-text-light); }
.text-white       { color: var(--color-white); }
.text-success     { color: var(--color-success); }
.text-error       { color: var(--color-error); }

/* Weight utilities */
.font-light    { font-weight: var(--weight-light); }
.font-regular  { font-weight: var(--weight-regular); }
.font-medium   { font-weight: var(--weight-medium); }
.font-semibold { font-weight: var(--weight-semibold); }
.font-bold     { font-weight: var(--weight-bold); }

/* Family utilities */
.font-display { font-family: var(--font-display); }
.font-body    { font-family: var(--font-body); }
.font-mono    { font-family: var(--font-mono); }

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

/* Decorative rule under section titles */
.text-underline-gold {
  position: relative;
  display: inline-block;
}
.text-underline-gold::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--color-secondary);
  border-radius: var(--radius-full);
}

/* Highlighted span in headlines */
.highlight {
  color: var(--color-secondary);
}

/* ============================================================
   4. LAYOUT — CONTAINER & GRID
   ============================================================ */

.container {
  width: 100%;
  max-width: var(--max-w-xl);
  margin-inline: auto;
  padding-inline: var(--container-px);
}

.container--sm  { max-width: var(--max-w-sm); }
.container--md  { max-width: var(--max-w-md); }
.container--lg  { max-width: var(--max-w-lg); }
.container--2xl { max-width: var(--max-w-2xl); }

/* Section padding */
.section {
  padding-block: clamp(var(--space-12), 8vw, var(--space-24));
}

.section--sm {
  padding-block: clamp(var(--space-8), 5vw, var(--space-16));
}

.section--lg {
  padding-block: clamp(var(--space-16), 10vw, var(--space-32));
}

/* Section header (title + subtitle) */
.section-header {
  text-align: center;
  margin-bottom: clamp(var(--space-8), 5vw, var(--space-12));
}

.section-header__label {
  display: inline-block;
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-secondary);
  margin-bottom: var(--space-3);
}

.section-header__title {
  margin-bottom: var(--space-4);
}

.section-header__subtitle {
  font-size: var(--text-lg);
  color: var(--color-text-light);
  max-width: 60ch;
  margin-inline: auto;
}

/* Grid utilities */
.grid { display: grid; }
.flex { display: flex; }

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

.flex-center    { display: flex; align-items: center; justify-content: center; }
.flex-between   { display: flex; align-items: center; justify-content: space-between; }
.flex-start     { display: flex; align-items: flex-start; }
.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-4  { gap: var(--space-4); }
.gap-6  { gap: var(--space-6); }
.gap-8  { gap: var(--space-8); }
.gap-10 { gap: var(--space-10); }

/* ============================================================
   5. BACKGROUND UTILITIES
   ============================================================ */

.bg-primary    { background-color: var(--color-primary); color: var(--color-white); }
.bg-secondary  { background-color: var(--color-secondary); color: var(--color-primary); }
.bg-white      { background-color: var(--color-white); }
.bg-light      { background-color: var(--color-bg); }
.bg-accent     { background-color: var(--color-accent); color: var(--color-white); }
.bg-navy-dark  { background-color: #060F20; color: var(--color-white); }

/* Hero gradient background */
.bg-hero {
  background:
    linear-gradient(135deg, #003466 0%, #1A4F8A 50%, #0D2550 100%);
  position: relative;
  overflow: hidden;
}

/* Subtle geometric pattern overlay */
.bg-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 20% 80%, rgba(255, 127, 0, 0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(255, 255, 255, 0.04) 0%, transparent 40%);
  pointer-events: none;
}

/* Striped section divider */
.section--striped {
  background-color: var(--color-white);
}

/* ============================================================
   6. BUTTON SYSTEM
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.75rem 1.75rem;
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  line-height: 1;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background-color var(--transition-base),
    color var(--transition-base),
    border-color var(--transition-base),
    box-shadow var(--transition-base),
    transform var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}

.btn:active {
  transform: scale(0.97);
}

/* Primary — gold CTA */
.btn--primary {
  background-color: var(--color-secondary);
  color: var(--color-primary);
  border-color: var(--color-secondary);
  box-shadow: var(--shadow-gold);
}
.btn--primary:hover {
  background-color: #C4972F;
  border-color: #C4972F;
  box-shadow: 0 6px 24px rgba(255, 127, 0, 0.40);
  transform: translateY(-1px);
}

/* Secondary — navy outline */
.btn--secondary {
  background-color: transparent;
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.btn--secondary:hover {
  background-color: var(--color-primary);
  color: var(--color-white);
}

/* Ghost — white outline (for dark backgrounds) */
.btn--ghost {
  background-color: transparent;
  color: var(--color-white);
  border-color: rgba(255, 255, 255, 0.50);
}
.btn--ghost:hover {
  background-color: rgba(255, 255, 255, 0.12);
  border-color: var(--color-white);
}

/* White button (on dark bg) */
.btn--white {
  background-color: var(--color-white);
  color: var(--color-primary);
  border-color: var(--color-white);
}
.btn--white:hover {
  background-color: var(--color-secondary);
  border-color: var(--color-secondary);
  color: var(--color-primary);
}

/* Sizes */
.btn--sm {
  padding: 0.5rem 1.25rem;
  font-size: var(--text-sm);
}

.btn--lg {
  padding: 1rem 2.25rem;
  font-size: var(--text-lg);
  border-radius: var(--radius-lg);
}

.btn--xl {
  padding: 1.125rem 2.75rem;
  font-size: var(--text-xl);
  border-radius: var(--radius-lg);
}

/* Full width button */
.btn--full { width: 100%; }

/* Icon inside button */
.btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.btn--lg svg,
.btn--xl svg {
  width: 20px;
  height: 20px;
}

/* Link button */
.btn--link {
  background: none;
  border: none;
  color: var(--color-accent);
  padding: 0;
  font-weight: var(--weight-medium);
  text-decoration: underline;
  text-underline-offset: 3px;
  box-shadow: none;
}
.btn--link:hover {
  color: var(--color-secondary);
  transform: none;
}

/* ============================================================
   7. SPACING UTILITIES
   ============================================================ */

.mt-0  { margin-top: 0; }
.mt-4  { margin-top: var(--space-4); }
.mt-6  { margin-top: var(--space-6); }
.mt-8  { margin-top: var(--space-8); }
.mt-10 { margin-top: var(--space-10); }
.mt-12 { margin-top: var(--space-12); }
.mt-16 { margin-top: var(--space-16); }

.mb-0  { margin-bottom: 0; }
.mb-2  { margin-bottom: var(--space-2); }
.mb-4  { margin-bottom: var(--space-4); }
.mb-6  { margin-bottom: var(--space-6); }
.mb-8  { margin-bottom: var(--space-8); }
.mb-10 { margin-bottom: var(--space-10); }
.mb-12 { margin-bottom: var(--space-12); }

.pt-0  { padding-top: 0; }
.pt-4  { padding-top: var(--space-4); }
.pt-8  { padding-top: var(--space-8); }
.pb-0  { padding-bottom: 0; }
.pb-4  { padding-bottom: var(--space-4); }
.pb-8  { padding-bottom: var(--space-8); }

/* ============================================================
   8. ACCESSIBILITY & VISIBILITY
   ============================================================ */

/* Visually hidden but accessible to screen readers */
.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;
}

.hidden    { display: none !important; }
.invisible { visibility: hidden; }

/* Responsive display utilities */
@media (max-width: 767px) {
  .hide-mobile { display: none !important; }
}
@media (min-width: 768px) {
  .hide-desktop { display: none !important; }
}

/* ============================================================
   9. ANIMATIONS & TRANSITIONS
   ============================================================ */

/* Fade in on scroll (JS adds .is-visible) */
.reveal {
  opacity: 0;
  transform: translateY(24px);
  transition:
    opacity var(--transition-slow),
    transform var(--transition-slow);
}

.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.reveal--delay-1 { transition-delay: 100ms; }
.reveal--delay-2 { transition-delay: 200ms; }
.reveal--delay-3 { transition-delay: 300ms; }
.reveal--delay-4 { transition-delay: 400ms; }

/* Pulse animation for badges/alerts */
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.65; }
}

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Spin animation */
@keyframes spin {
  to { transform: rotate(360deg); }
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* ============================================================
   10. RESPONSIVE BREAKPOINTS
   ============================================================ */
/*
 * Mobile first approach:
 *   sm  ≥ 480px
 *   md  ≥ 768px
 *   lg  ≥ 1024px
 *   xl  ≥ 1200px
 *   2xl ≥ 1400px
 */

@media (max-width: 767px) {
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  h1, .h1 { font-size: var(--text-3xl); }
  h2, .h2 { font-size: var(--text-2xl); }

  .section-header__subtitle { font-size: var(--text-base); }
}

@media (min-width: 480px) and (max-width: 767px) {
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 768px) and (max-width: 1023px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

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

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

/* ============================================================
   11. PRINT STYLES
   ============================================================ */

@media print {
  .no-print,
  nav,
  .site-nav,
  .site-footer,
  .btn--primary { display: none !important; }

  body {
    font-size: 12pt;
    color: #000;
    background: #fff;
  }

  a::after { content: " (" attr(href) ")"; font-size: 10pt; }
  h1, h2, h3 { page-break-after: avoid; }
}
